001    /*
002     * This class is an auto-generated source file for a HAPI
003     * HL7 v2.x standard structure class.
004     *
005     * For more information, visit: http://hl7api.sourceforge.net/
006     */
007    
008    package ca.uhn.hl7v2.model.v24.datatype;
009    
010    import ca.uhn.hl7v2.model.Composite;
011    import ca.uhn.hl7v2.model.DataTypeException;
012    import ca.uhn.hl7v2.model.Message;
013    import ca.uhn.hl7v2.model.Type;
014    import ca.uhn.hl7v2.model.AbstractType;
015    import ca.uhn.log.HapiLogFactory;
016    
017    /**
018     * <p>Represents an HL7 CWE (coded with exceptions) data type. 
019     * This type consists of the following components:</p>
020     * <ul>
021     * <li>identifier (ST) (ST)
022     * <li>text (ST)
023     * <li>name of coding system (IS)
024     * <li>alternate identifier (ST) (ST)
025     * <li>alternate text (ST)
026     * <li>name of alternate coding system (IS)
027     * <li>coding system version ID (ST)
028     * <li>alternate coding system version ID (ST)
029     * <li>original text (ST)
030     * </ul>
031     */
032    public class CWE extends AbstractType implements Composite {
033    
034        private Type[] data;
035    
036        /** 
037         * Creates a new CWE type
038         */
039        public CWE(Message message) {
040            super(message);
041            init();
042        }
043    
044        private void init() {
045            data = new Type[9];    
046            data[0] = new ST(getMessage());
047            data[1] = new ST(getMessage());
048            data[2] = new IS(getMessage(), 0);
049            data[3] = new ST(getMessage());
050            data[4] = new ST(getMessage());
051            data[5] = new IS(getMessage(), 0);
052            data[6] = new ST(getMessage());
053            data[7] = new ST(getMessage());
054            data[8] = new ST(getMessage());
055        }
056    
057    
058        /**
059         * Returns an array containing the data elements.
060         */
061        public Type[] getComponents() { 
062            return this.data; 
063        }
064    
065        /**
066         * Returns an individual data component.
067         *
068         * @param number The component number (0-indexed)
069         * @throws DataTypeException if the given element number is out of range.
070         */
071        public Type getComponent(int number) throws DataTypeException { 
072    
073            try { 
074                return this.data[number]; 
075            } catch (ArrayIndexOutOfBoundsException e) { 
076                throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)"); 
077            } 
078        } 
079    
080    
081        /**
082         * Returns identifier (ST) (component #1).  This is a convenience method that saves you from 
083         * casting and handling an exception.
084         */
085        public ST getIdentifier() {
086           ST ret = null;
087           try {
088              ret = (ST)getComponent(0);
089           } catch (DataTypeException e) {
090              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
091              throw new RuntimeException(e);
092           }
093           return ret;
094        }
095    
096        
097        /**
098         * Returns identifier (ST) (component #1).  This is a convenience method that saves you from 
099         * casting and handling an exception.
100         */
101        public ST getCwe1_Identifier() {
102           ST ret = null;
103           try {
104              ret = (ST)getComponent(0);
105           } catch (DataTypeException e) {
106              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
107              throw new RuntimeException(e);
108           }
109           return ret;
110        }
111    
112    
113        /**
114         * Returns text (component #2).  This is a convenience method that saves you from 
115         * casting and handling an exception.
116         */
117        public ST getText() {
118           ST ret = null;
119           try {
120              ret = (ST)getComponent(1);
121           } catch (DataTypeException e) {
122              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
123              throw new RuntimeException(e);
124           }
125           return ret;
126        }
127    
128        
129        /**
130         * Returns text (component #2).  This is a convenience method that saves you from 
131         * casting and handling an exception.
132         */
133        public ST getCwe2_Text() {
134           ST ret = null;
135           try {
136              ret = (ST)getComponent(1);
137           } catch (DataTypeException e) {
138              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
139              throw new RuntimeException(e);
140           }
141           return ret;
142        }
143    
144    
145        /**
146         * Returns name of coding system (component #3).  This is a convenience method that saves you from 
147         * casting and handling an exception.
148         */
149        public IS getNameOfCodingSystem() {
150           IS ret = null;
151           try {
152              ret = (IS)getComponent(2);
153           } catch (DataTypeException e) {
154              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
155              throw new RuntimeException(e);
156           }
157           return ret;
158        }
159    
160        
161        /**
162         * Returns name of coding system (component #3).  This is a convenience method that saves you from 
163         * casting and handling an exception.
164         */
165        public IS getCwe3_NameOfCodingSystem() {
166           IS ret = null;
167           try {
168              ret = (IS)getComponent(2);
169           } catch (DataTypeException e) {
170              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
171              throw new RuntimeException(e);
172           }
173           return ret;
174        }
175    
176    
177        /**
178         * Returns alternate identifier (ST) (component #4).  This is a convenience method that saves you from 
179         * casting and handling an exception.
180         */
181        public ST getAlternateIdentifier() {
182           ST ret = null;
183           try {
184              ret = (ST)getComponent(3);
185           } catch (DataTypeException e) {
186              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
187              throw new RuntimeException(e);
188           }
189           return ret;
190        }
191    
192        
193        /**
194         * Returns alternate identifier (ST) (component #4).  This is a convenience method that saves you from 
195         * casting and handling an exception.
196         */
197        public ST getCwe4_AlternateIdentifier() {
198           ST ret = null;
199           try {
200              ret = (ST)getComponent(3);
201           } catch (DataTypeException e) {
202              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
203              throw new RuntimeException(e);
204           }
205           return ret;
206        }
207    
208    
209        /**
210         * Returns alternate text (component #5).  This is a convenience method that saves you from 
211         * casting and handling an exception.
212         */
213        public ST getAlternateText() {
214           ST ret = null;
215           try {
216              ret = (ST)getComponent(4);
217           } catch (DataTypeException e) {
218              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
219              throw new RuntimeException(e);
220           }
221           return ret;
222        }
223    
224        
225        /**
226         * Returns alternate text (component #5).  This is a convenience method that saves you from 
227         * casting and handling an exception.
228         */
229        public ST getCwe5_AlternateText() {
230           ST ret = null;
231           try {
232              ret = (ST)getComponent(4);
233           } catch (DataTypeException e) {
234              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
235              throw new RuntimeException(e);
236           }
237           return ret;
238        }
239    
240    
241        /**
242         * Returns name of alternate coding system (component #6).  This is a convenience method that saves you from 
243         * casting and handling an exception.
244         */
245        public IS getNameOfAlternateCodingSystem() {
246           IS ret = null;
247           try {
248              ret = (IS)getComponent(5);
249           } catch (DataTypeException e) {
250              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
251              throw new RuntimeException(e);
252           }
253           return ret;
254        }
255    
256        
257        /**
258         * Returns name of alternate coding system (component #6).  This is a convenience method that saves you from 
259         * casting and handling an exception.
260         */
261        public IS getCwe6_NameOfAlternateCodingSystem() {
262           IS ret = null;
263           try {
264              ret = (IS)getComponent(5);
265           } catch (DataTypeException e) {
266              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
267              throw new RuntimeException(e);
268           }
269           return ret;
270        }
271    
272    
273        /**
274         * Returns coding system version ID (component #7).  This is a convenience method that saves you from 
275         * casting and handling an exception.
276         */
277        public ST getCodingSystemVersionID() {
278           ST ret = null;
279           try {
280              ret = (ST)getComponent(6);
281           } catch (DataTypeException e) {
282              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
283              throw new RuntimeException(e);
284           }
285           return ret;
286        }
287    
288        
289        /**
290         * Returns coding system version ID (component #7).  This is a convenience method that saves you from 
291         * casting and handling an exception.
292         */
293        public ST getCwe7_CodingSystemVersionID() {
294           ST ret = null;
295           try {
296              ret = (ST)getComponent(6);
297           } catch (DataTypeException e) {
298              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
299              throw new RuntimeException(e);
300           }
301           return ret;
302        }
303    
304    
305        /**
306         * Returns alternate coding system version ID (component #8).  This is a convenience method that saves you from 
307         * casting and handling an exception.
308         */
309        public ST getAlternateCodingSystemVersionID() {
310           ST ret = null;
311           try {
312              ret = (ST)getComponent(7);
313           } catch (DataTypeException e) {
314              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
315              throw new RuntimeException(e);
316           }
317           return ret;
318        }
319    
320        
321        /**
322         * Returns alternate coding system version ID (component #8).  This is a convenience method that saves you from 
323         * casting and handling an exception.
324         */
325        public ST getCwe8_AlternateCodingSystemVersionID() {
326           ST ret = null;
327           try {
328              ret = (ST)getComponent(7);
329           } catch (DataTypeException e) {
330              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
331              throw new RuntimeException(e);
332           }
333           return ret;
334        }
335    
336    
337        /**
338         * Returns original text (component #9).  This is a convenience method that saves you from 
339         * casting and handling an exception.
340         */
341        public ST getOriginalText() {
342           ST ret = null;
343           try {
344              ret = (ST)getComponent(8);
345           } catch (DataTypeException e) {
346              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
347              throw new RuntimeException(e);
348           }
349           return ret;
350        }
351    
352        
353        /**
354         * Returns original text (component #9).  This is a convenience method that saves you from 
355         * casting and handling an exception.
356         */
357        public ST getCwe9_OriginalText() {
358           ST ret = null;
359           try {
360              ret = (ST)getComponent(8);
361           } catch (DataTypeException e) {
362              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
363              throw new RuntimeException(e);
364           }
365           return ret;
366        }
367    
368    
369    
370    }
371