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.segment;
009    
010    // import ca.uhn.hl7v2.model.v24.group.*;
011    import ca.uhn.hl7v2.model.v24.datatype.*;
012    import ca.uhn.log.HapiLogFactory;
013    import ca.uhn.hl7v2.HL7Exception;
014    import ca.uhn.hl7v2.parser.ModelClassFactory;
015    import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
016    import ca.uhn.hl7v2.model.AbstractMessage;
017    import ca.uhn.hl7v2.model.Group;
018    import ca.uhn.hl7v2.model.Type;
019    import ca.uhn.hl7v2.model.AbstractSegment;
020    import ca.uhn.hl7v2.model.Varies;
021    
022    /**
023     *<p>Represents an HL7 TCD message segment (Test Code Detail). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>TCD-1: Universal Service Identifier (CE) <b> </b>
027         * <li>TCD-2: Auto-Dilution Factor (SN) <b>optional </b>
028         * <li>TCD-3: Rerun Dilution Factor (SN) <b>optional </b>
029         * <li>TCD-4: Pre-Dilution Factor (SN) <b>optional </b>
030         * <li>TCD-5: Endogenous Content of Pre-Dilution Diluent (SN) <b>optional </b>
031         * <li>TCD-6: Automatic Repeat Allowed (ID) <b>optional </b>
032         * <li>TCD-7: Reflex Allowed (ID) <b>optional </b>
033         * <li>TCD-8: Analyte Repeat Status (CE) <b>optional </b>
034     * </ul>
035     */
036    public class TCD extends AbstractSegment {
037    
038        /** 
039         * Creates a new TCD segment
040         */
041        public TCD(Group parent, ModelClassFactory factory) {
042           super(parent, factory);
043           init(factory);
044        }
045    
046        private void init(ModelClassFactory factory) {
047           try {
048                                      this.add(CE.class, true, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Universal Service Identifier");
049                                      this.add(SN.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "Auto-Dilution Factor");
050                                      this.add(SN.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "Rerun Dilution Factor");
051                                      this.add(SN.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "Pre-Dilution Factor");
052                                      this.add(SN.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "Endogenous Content of Pre-Dilution Diluent");
053                                      this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Automatic Repeat Allowed");
054                                      this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Reflex Allowed");
055                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(389) }, "Analyte Repeat Status");
056           } catch(HL7Exception e) {
057              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating TCD - this is probably a bug in the source code generator.", e);
058           }
059        }
060    
061    
062    
063        /**
064         * Returns
065         * TCD-1: "Universal Service Identifier" - creates it if necessary
066         */
067        public CE getUniversalServiceIdentifier() { 
068            CE ret = null;
069            try {
070                Type t = this.getField(1, 0);
071                ret = (CE)t;
072            } catch (ClassCastException cce) {
073                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
074                throw new RuntimeException(cce);
075            } catch (HL7Exception he) {
076                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
077                throw new RuntimeException(he);
078            }
079            return ret;
080        }
081    
082    
083        /**
084         * Returns
085         * TCD-1: "Universal Service Identifier" - creates it if necessary
086         */
087        public CE getTcd1_UniversalServiceIdentifier() { 
088            CE ret = null;
089            try {
090                Type t = this.getField(1, 0);
091                ret = (CE)t;
092            } catch (ClassCastException cce) {
093                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
094                throw new RuntimeException(cce);
095            } catch (HL7Exception he) {
096                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
097                throw new RuntimeException(he);
098            }
099            return ret;
100        }
101    
102    
103    
104        /**
105         * Returns
106         * TCD-2: "Auto-Dilution Factor" - creates it if necessary
107         */
108        public SN getAutoDilutionFactor() { 
109            SN ret = null;
110            try {
111                Type t = this.getField(2, 0);
112                ret = (SN)t;
113            } catch (ClassCastException cce) {
114                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
115                throw new RuntimeException(cce);
116            } catch (HL7Exception he) {
117                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
118                throw new RuntimeException(he);
119            }
120            return ret;
121        }
122    
123    
124        /**
125         * Returns
126         * TCD-2: "Auto-Dilution Factor" - creates it if necessary
127         */
128        public SN getTcd2_AutoDilutionFactor() { 
129            SN ret = null;
130            try {
131                Type t = this.getField(2, 0);
132                ret = (SN)t;
133            } catch (ClassCastException cce) {
134                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
135                throw new RuntimeException(cce);
136            } catch (HL7Exception he) {
137                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
138                throw new RuntimeException(he);
139            }
140            return ret;
141        }
142    
143    
144    
145        /**
146         * Returns
147         * TCD-3: "Rerun Dilution Factor" - creates it if necessary
148         */
149        public SN getRerunDilutionFactor() { 
150            SN ret = null;
151            try {
152                Type t = this.getField(3, 0);
153                ret = (SN)t;
154            } catch (ClassCastException cce) {
155                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
156                throw new RuntimeException(cce);
157            } catch (HL7Exception he) {
158                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
159                throw new RuntimeException(he);
160            }
161            return ret;
162        }
163    
164    
165        /**
166         * Returns
167         * TCD-3: "Rerun Dilution Factor" - creates it if necessary
168         */
169        public SN getTcd3_RerunDilutionFactor() { 
170            SN ret = null;
171            try {
172                Type t = this.getField(3, 0);
173                ret = (SN)t;
174            } catch (ClassCastException cce) {
175                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
176                throw new RuntimeException(cce);
177            } catch (HL7Exception he) {
178                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
179                throw new RuntimeException(he);
180            }
181            return ret;
182        }
183    
184    
185    
186        /**
187         * Returns
188         * TCD-4: "Pre-Dilution Factor" - creates it if necessary
189         */
190        public SN getPreDilutionFactor() { 
191            SN ret = null;
192            try {
193                Type t = this.getField(4, 0);
194                ret = (SN)t;
195            } catch (ClassCastException cce) {
196                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
197                throw new RuntimeException(cce);
198            } catch (HL7Exception he) {
199                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
200                throw new RuntimeException(he);
201            }
202            return ret;
203        }
204    
205    
206        /**
207         * Returns
208         * TCD-4: "Pre-Dilution Factor" - creates it if necessary
209         */
210        public SN getTcd4_PreDilutionFactor() { 
211            SN ret = null;
212            try {
213                Type t = this.getField(4, 0);
214                ret = (SN)t;
215            } catch (ClassCastException cce) {
216                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
217                throw new RuntimeException(cce);
218            } catch (HL7Exception he) {
219                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
220                throw new RuntimeException(he);
221            }
222            return ret;
223        }
224    
225    
226    
227        /**
228         * Returns
229         * TCD-5: "Endogenous Content of Pre-Dilution Diluent" - creates it if necessary
230         */
231        public SN getEndogenousContentOfPreDilutionDiluent() { 
232            SN ret = null;
233            try {
234                Type t = this.getField(5, 0);
235                ret = (SN)t;
236            } catch (ClassCastException cce) {
237                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
238                throw new RuntimeException(cce);
239            } catch (HL7Exception he) {
240                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
241                throw new RuntimeException(he);
242            }
243            return ret;
244        }
245    
246    
247        /**
248         * Returns
249         * TCD-5: "Endogenous Content of Pre-Dilution Diluent" - creates it if necessary
250         */
251        public SN getTcd5_EndogenousContentOfPreDilutionDiluent() { 
252            SN ret = null;
253            try {
254                Type t = this.getField(5, 0);
255                ret = (SN)t;
256            } catch (ClassCastException cce) {
257                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
258                throw new RuntimeException(cce);
259            } catch (HL7Exception he) {
260                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
261                throw new RuntimeException(he);
262            }
263            return ret;
264        }
265    
266    
267    
268        /**
269         * Returns
270         * TCD-6: "Automatic Repeat Allowed" - creates it if necessary
271         */
272        public ID getAutomaticRepeatAllowed() { 
273            ID ret = null;
274            try {
275                Type t = this.getField(6, 0);
276                ret = (ID)t;
277            } catch (ClassCastException cce) {
278                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
279                throw new RuntimeException(cce);
280            } catch (HL7Exception he) {
281                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
282                throw new RuntimeException(he);
283            }
284            return ret;
285        }
286    
287    
288        /**
289         * Returns
290         * TCD-6: "Automatic Repeat Allowed" - creates it if necessary
291         */
292        public ID getTcd6_AutomaticRepeatAllowed() { 
293            ID ret = null;
294            try {
295                Type t = this.getField(6, 0);
296                ret = (ID)t;
297            } catch (ClassCastException cce) {
298                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
299                throw new RuntimeException(cce);
300            } catch (HL7Exception he) {
301                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
302                throw new RuntimeException(he);
303            }
304            return ret;
305        }
306    
307    
308    
309        /**
310         * Returns
311         * TCD-7: "Reflex Allowed" - creates it if necessary
312         */
313        public ID getReflexAllowed() { 
314            ID ret = null;
315            try {
316                Type t = this.getField(7, 0);
317                ret = (ID)t;
318            } catch (ClassCastException cce) {
319                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
320                throw new RuntimeException(cce);
321            } catch (HL7Exception he) {
322                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
323                throw new RuntimeException(he);
324            }
325            return ret;
326        }
327    
328    
329        /**
330         * Returns
331         * TCD-7: "Reflex Allowed" - creates it if necessary
332         */
333        public ID getTcd7_ReflexAllowed() { 
334            ID ret = null;
335            try {
336                Type t = this.getField(7, 0);
337                ret = (ID)t;
338            } catch (ClassCastException cce) {
339                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
340                throw new RuntimeException(cce);
341            } catch (HL7Exception he) {
342                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
343                throw new RuntimeException(he);
344            }
345            return ret;
346        }
347    
348    
349    
350        /**
351         * Returns
352         * TCD-8: "Analyte Repeat Status" - creates it if necessary
353         */
354        public CE getAnalyteRepeatStatus() { 
355            CE ret = null;
356            try {
357                Type t = this.getField(8, 0);
358                ret = (CE)t;
359            } catch (ClassCastException cce) {
360                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
361                throw new RuntimeException(cce);
362            } catch (HL7Exception he) {
363                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
364                throw new RuntimeException(he);
365            }
366            return ret;
367        }
368    
369    
370        /**
371         * Returns
372         * TCD-8: "Analyte Repeat Status" - creates it if necessary
373         */
374        public CE getTcd8_AnalyteRepeatStatus() { 
375            CE ret = null;
376            try {
377                Type t = this.getField(8, 0);
378                ret = (CE)t;
379            } catch (ClassCastException cce) {
380                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
381                throw new RuntimeException(cce);
382            } catch (HL7Exception he) {
383                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
384                throw new RuntimeException(he);
385            }
386            return ret;
387        }
388    
389    
390    
391    
392    
393        /** {@inheritDoc} */   
394        protected Type createNewTypeWithoutReflection(int field) {
395           switch (field) {
396              case 0: return new CE(getMessage());
397              case 1: return new SN(getMessage());
398              case 2: return new SN(getMessage());
399              case 3: return new SN(getMessage());
400              case 4: return new SN(getMessage());
401              case 5: return new ID(getMessage(), new Integer( 136 ));
402              case 6: return new ID(getMessage(), new Integer( 136 ));
403              case 7: return new CE(getMessage());
404              default: return null;
405           }
406       }
407    
408    
409    }
410