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 OM3 message segment (Categorical Service/Test/Observation). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>OM3-1: Sequence Number - Test/ Observation Master File (NM) <b>optional </b>
027         * <li>OM3-2: Preferred Coding System (CE) <b>optional </b>
028         * <li>OM3-3: Valid Coded "Answers" (CE) <b>optional </b>
029         * <li>OM3-4: Normal Text/Codes for Categorical Observations (CE) <b>optional repeating</b>
030         * <li>OM3-5: Abnormal Text/Codes for Categorical Observations (CE) <b>optional </b>
031         * <li>OM3-6: Critical Text/Codes for Categorical Observations (CE) <b>optional </b>
032         * <li>OM3-7: Value Type (ID) <b>optional </b>
033     * </ul>
034     */
035    public class OM3 extends AbstractSegment {
036    
037        /** 
038         * Creates a new OM3 segment
039         */
040        public OM3(Group parent, ModelClassFactory factory) {
041           super(parent, factory);
042           init(factory);
043        }
044    
045        private void init(ModelClassFactory factory) {
046           try {
047                                      this.add(NM.class, false, 1, 4, new Object[]{ getMessage(), new Integer(0) }, "Sequence Number - Test/ Observation Master File");
048                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(9999) }, "Preferred Coding System");
049                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(9999) }, "Valid Coded \"Answers\"");
050                                      this.add(CE.class, false, 0, 250, new Object[]{ getMessage(), new Integer(9999) }, "Normal Text/Codes for Categorical Observations");
051                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(9999) }, "Abnormal Text/Codes for Categorical Observations");
052                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(9999) }, "Critical Text/Codes for Categorical Observations");
053                                      this.add(ID.class, false, 1, 2, new Object[]{ getMessage() }, "Value Type");
054           } catch(HL7Exception e) {
055              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating OM3 - this is probably a bug in the source code generator.", e);
056           }
057        }
058    
059    
060    
061        /**
062         * Returns
063         * OM3-1: "Sequence Number - Test/ Observation Master File" - creates it if necessary
064         */
065        public NM getSequenceNumberTestObservationMasterFile() { 
066            NM ret = null;
067            try {
068                Type t = this.getField(1, 0);
069                ret = (NM)t;
070            } catch (ClassCastException cce) {
071                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
072                throw new RuntimeException(cce);
073            } catch (HL7Exception he) {
074                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
075                throw new RuntimeException(he);
076            }
077            return ret;
078        }
079    
080    
081        /**
082         * Returns
083         * OM3-1: "Sequence Number - Test/ Observation Master File" - creates it if necessary
084         */
085        public NM getOm31_SequenceNumberTestObservationMasterFile() { 
086            NM ret = null;
087            try {
088                Type t = this.getField(1, 0);
089                ret = (NM)t;
090            } catch (ClassCastException cce) {
091                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
092                throw new RuntimeException(cce);
093            } catch (HL7Exception he) {
094                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
095                throw new RuntimeException(he);
096            }
097            return ret;
098        }
099    
100    
101    
102        /**
103         * Returns
104         * OM3-2: "Preferred Coding System" - creates it if necessary
105         */
106        public CE getPreferredCodingSystem() { 
107            CE ret = null;
108            try {
109                Type t = this.getField(2, 0);
110                ret = (CE)t;
111            } catch (ClassCastException cce) {
112                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
113                throw new RuntimeException(cce);
114            } catch (HL7Exception he) {
115                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
116                throw new RuntimeException(he);
117            }
118            return ret;
119        }
120    
121    
122        /**
123         * Returns
124         * OM3-2: "Preferred Coding System" - creates it if necessary
125         */
126        public CE getOm32_PreferredCodingSystem() { 
127            CE ret = null;
128            try {
129                Type t = this.getField(2, 0);
130                ret = (CE)t;
131            } catch (ClassCastException cce) {
132                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
133                throw new RuntimeException(cce);
134            } catch (HL7Exception he) {
135                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
136                throw new RuntimeException(he);
137            }
138            return ret;
139        }
140    
141    
142    
143        /**
144         * Returns
145         * OM3-3: "Valid Coded "Answers"" - creates it if necessary
146         */
147        public CE getValidCodedAnswers() { 
148            CE ret = null;
149            try {
150                Type t = this.getField(3, 0);
151                ret = (CE)t;
152            } catch (ClassCastException cce) {
153                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
154                throw new RuntimeException(cce);
155            } catch (HL7Exception he) {
156                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
157                throw new RuntimeException(he);
158            }
159            return ret;
160        }
161    
162    
163        /**
164         * Returns
165         * OM3-3: "Valid Coded "Answers"" - creates it if necessary
166         */
167        public CE getOm33_ValidCodedAnswers() { 
168            CE ret = null;
169            try {
170                Type t = this.getField(3, 0);
171                ret = (CE)t;
172            } catch (ClassCastException cce) {
173                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
174                throw new RuntimeException(cce);
175            } catch (HL7Exception he) {
176                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
177                throw new RuntimeException(he);
178            }
179            return ret;
180        }
181    
182    
183        /**
184         * Returns all repetitions of Normal Text/Codes for Categorical Observations (OM3-4).
185         */
186        public CE[] getNormalTextCodesForCategoricalObservations() {
187            CE[] ret = null;
188            try {
189                Type[] t = this.getField(4);  
190                ret = new CE[t.length];
191                for (int i = 0; i < ret.length; i++) {
192                    ret[i] = (CE)t[i];
193                }
194            } catch (ClassCastException cce) {
195                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
196                throw new RuntimeException(cce);
197            } catch (HL7Exception he) {
198                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
199                throw new RuntimeException(he);
200            }
201            return ret;
202        }
203    
204    
205        /**
206         * Returns a count of the current number of repetitions of Normal Text/Codes for Categorical Observations (OM3-4).
207         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
208         * it will return zero.
209         */
210        public int getNormalTextCodesForCategoricalObservationsReps() {
211            CE[] ret = null;
212            try {
213                Type[] t = this.getField(4);
214                return t.length;  
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        }
223    
224    
225        /**
226         * Returns a specific repetition of
227         * OM3-4: "Normal Text/Codes for Categorical Observations" - creates it if necessary
228         *
229         * @param rep The repetition index (0-indexed)
230         */
231        public CE getNormalTextCodesForCategoricalObservations(int rep) { 
232            CE ret = null;
233            try {
234                Type t = this.getField(4, rep);
235                ret = (CE)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         * Returns a specific repetition of
248         * OM3-4: "Normal Text/Codes for Categorical Observations" - creates it if necessary
249         *
250         * @param rep The repetition index (0-indexed)
251         */
252        public CE getOm34_NormalTextCodesForCategoricalObservations(int rep) { 
253            CE ret = null;
254            try {
255                Type t = this.getField(4, rep);
256                ret = (CE)t;
257            } catch (ClassCastException cce) {
258                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
259                throw new RuntimeException(cce);
260            } catch (HL7Exception he) {
261                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
262                throw new RuntimeException(he);
263            }
264            return ret;
265        }
266    
267    
268        /**
269         * Returns a count of the current number of repetitions of Normal Text/Codes for Categorical Observations (OM3-4).
270         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
271         * it will return zero.
272         */
273        public int getOm34_NormalTextCodesForCategoricalObservationsReps() {
274            CE[] ret = null;
275            try {
276                Type[] t = this.getField(4);
277                return t.length;  
278            } catch (ClassCastException cce) {
279                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
280                throw new RuntimeException(cce);
281            } catch (HL7Exception he) {
282                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
283                throw new RuntimeException(he);
284            }
285        }
286    
287    
288    
289        /**
290         * Inserts a repetition of
291         * OM3-4: "Normal Text/Codes for Categorical Observations" at a specific index
292         *
293         * @param rep The repetition index (0-indexed)
294         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
295         */
296        public CE insertNormalTextCodesForCategoricalObservations(int rep) throws HL7Exception { 
297            return (CE) super.insertRepetition(4, rep);
298        }
299    
300    
301    
302        /**
303         * Inserts a repetition of
304         * OM3-4: "Normal Text/Codes for Categorical Observations" at a specific index
305         *
306         * @param rep The repetition index (0-indexed)
307         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
308         */
309        public CE insertOm34_NormalTextCodesForCategoricalObservations(int rep) throws HL7Exception { 
310            return (CE) super.insertRepetition(4, rep);
311        }
312    
313    
314        /**
315         * Removes a repetition of
316         * OM3-4: "Normal Text/Codes for Categorical Observations" at a specific index
317         *
318         * @param rep The repetition index (0-indexed)
319         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
320         */
321        public CE removeNormalTextCodesForCategoricalObservations(int rep) throws HL7Exception { 
322            return (CE) super.removeRepetition(4, rep);
323        }
324    
325    
326        /**
327         * Removes a repetition of
328         * OM3-4: "Normal Text/Codes for Categorical Observations" at a specific index
329         *
330         * @param rep The repetition index (0-indexed)
331         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
332         */
333        public CE removeOm34_NormalTextCodesForCategoricalObservations(int rep) throws HL7Exception { 
334            return (CE) super.removeRepetition(4, rep);
335        }
336    
337    
338    
339    
340        /**
341         * Returns
342         * OM3-5: "Abnormal Text/Codes for Categorical Observations" - creates it if necessary
343         */
344        public CE getAbnormalTextCodesForCategoricalObservations() { 
345            CE ret = null;
346            try {
347                Type t = this.getField(5, 0);
348                ret = (CE)t;
349            } catch (ClassCastException cce) {
350                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
351                throw new RuntimeException(cce);
352            } catch (HL7Exception he) {
353                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
354                throw new RuntimeException(he);
355            }
356            return ret;
357        }
358    
359    
360        /**
361         * Returns
362         * OM3-5: "Abnormal Text/Codes for Categorical Observations" - creates it if necessary
363         */
364        public CE getOm35_AbnormalTextCodesForCategoricalObservations() { 
365            CE ret = null;
366            try {
367                Type t = this.getField(5, 0);
368                ret = (CE)t;
369            } catch (ClassCastException cce) {
370                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
371                throw new RuntimeException(cce);
372            } catch (HL7Exception he) {
373                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
374                throw new RuntimeException(he);
375            }
376            return ret;
377        }
378    
379    
380    
381        /**
382         * Returns
383         * OM3-6: "Critical Text/Codes for Categorical Observations" - creates it if necessary
384         */
385        public CE getCriticalTextCodesForCategoricalObservations() { 
386            CE ret = null;
387            try {
388                Type t = this.getField(6, 0);
389                ret = (CE)t;
390            } catch (ClassCastException cce) {
391                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
392                throw new RuntimeException(cce);
393            } catch (HL7Exception he) {
394                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
395                throw new RuntimeException(he);
396            }
397            return ret;
398        }
399    
400    
401        /**
402         * Returns
403         * OM3-6: "Critical Text/Codes for Categorical Observations" - creates it if necessary
404         */
405        public CE getOm36_CriticalTextCodesForCategoricalObservations() { 
406            CE ret = null;
407            try {
408                Type t = this.getField(6, 0);
409                ret = (CE)t;
410            } catch (ClassCastException cce) {
411                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
412                throw new RuntimeException(cce);
413            } catch (HL7Exception he) {
414                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
415                throw new RuntimeException(he);
416            }
417            return ret;
418        }
419    
420    
421    
422        /**
423         * Returns
424         * OM3-7: "Value Type" - creates it if necessary
425         */
426        public ID getValueType() { 
427            ID ret = null;
428            try {
429                Type t = this.getField(7, 0);
430                ret = (ID)t;
431            } catch (ClassCastException cce) {
432                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
433                throw new RuntimeException(cce);
434            } catch (HL7Exception he) {
435                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
436                throw new RuntimeException(he);
437            }
438            return ret;
439        }
440    
441    
442        /**
443         * Returns
444         * OM3-7: "Value Type" - creates it if necessary
445         */
446        public ID getOm37_ValueType() { 
447            ID ret = null;
448            try {
449                Type t = this.getField(7, 0);
450                ret = (ID)t;
451            } catch (ClassCastException cce) {
452                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
453                throw new RuntimeException(cce);
454            } catch (HL7Exception he) {
455                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
456                throw new RuntimeException(he);
457            }
458            return ret;
459        }
460    
461    
462    
463    
464    
465        /** {@inheritDoc} */   
466        protected Type createNewTypeWithoutReflection(int field) {
467           switch (field) {
468              case 0: return new NM(getMessage());
469              case 1: return new CE(getMessage());
470              case 2: return new CE(getMessage());
471              case 3: return new CE(getMessage());
472              case 4: return new CE(getMessage());
473              case 5: return new CE(getMessage());
474              case 6: return new ID(getMessage(), new Integer( 125 ));
475              default: return null;
476           }
477       }
478    
479    
480    }
481