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.v231.segment;
009    
010    // import ca.uhn.hl7v2.model.v231.group.*;
011    import ca.uhn.hl7v2.model.v231.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 MSH message segment (MSH - message header segment). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>MSH-1: Field Separator (ST) <b> </b>
027         * <li>MSH-2: Encoding Characters (ST) <b> </b>
028         * <li>MSH-3: Sending Application (HD) <b>optional </b>
029         * <li>MSH-4: Sending Facility (HD) <b>optional </b>
030         * <li>MSH-5: Receiving Application (HD) <b>optional </b>
031         * <li>MSH-6: Receiving Facility (HD) <b>optional </b>
032         * <li>MSH-7: Date/Time Of Message (TS) <b>optional </b>
033         * <li>MSH-8: Security (ST) <b>optional </b>
034         * <li>MSH-9: Message Type (MSG) <b> </b>
035         * <li>MSH-10: Message Control ID (ST) <b> </b>
036         * <li>MSH-11: Processing ID (PT) <b> </b>
037         * <li>MSH-12: Version ID (VID) <b> </b>
038         * <li>MSH-13: Sequence Number (NM) <b>optional </b>
039         * <li>MSH-14: Continuation Pointer (ST) <b>optional </b>
040         * <li>MSH-15: Accept Acknowledgment Type (ID) <b>optional </b>
041         * <li>MSH-16: Application Acknowledgment Type (ID) <b>optional </b>
042         * <li>MSH-17: Country Code (ID) <b>optional </b>
043         * <li>MSH-18: Character Set (ID) <b>optional repeating</b>
044         * <li>MSH-19: Principal Language Of Message (CE) <b>optional </b>
045         * <li>MSH-20: Alternate Character Set Handling Scheme (ID) <b>optional </b>
046     * </ul>
047     */
048    public class MSH extends AbstractSegment {
049    
050        /** 
051         * Creates a new MSH segment
052         */
053        public MSH(Group parent, ModelClassFactory factory) {
054           super(parent, factory);
055           init(factory);
056        }
057    
058        private void init(ModelClassFactory factory) {
059           try {
060                                      this.add(ST.class, true, 1, 1, new Object[]{ getMessage(), new Integer(0) }, "Field Separator");
061                                      this.add(ST.class, true, 1, 4, new Object[]{ getMessage(), new Integer(0) }, "Encoding Characters");
062                                      this.add(HD.class, false, 1, 180, new Object[]{ getMessage(), new Integer(361) }, "Sending Application");
063                                      this.add(HD.class, false, 1, 180, new Object[]{ getMessage(), new Integer(362) }, "Sending Facility");
064                                      this.add(HD.class, false, 1, 180, new Object[]{ getMessage(), new Integer(361) }, "Receiving Application");
065                                      this.add(HD.class, false, 1, 180, new Object[]{ getMessage(), new Integer(362) }, "Receiving Facility");
066                                      this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Date/Time Of Message");
067                                      this.add(ST.class, false, 1, 40, new Object[]{ getMessage(), new Integer(0) }, "Security");
068                                      this.add(MSG.class, true, 1, 7, new Object[]{ getMessage(), new Integer(76) }, "Message Type");
069                                      this.add(ST.class, true, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "Message Control ID");
070                                      this.add(PT.class, true, 1, 3, new Object[]{ getMessage(), new Integer(0) }, "Processing ID");
071                                      this.add(VID.class, true, 1, 60, new Object[]{ getMessage(), new Integer(104) }, "Version ID");
072                                      this.add(NM.class, false, 1, 15, new Object[]{ getMessage(), new Integer(0) }, "Sequence Number");
073                                      this.add(ST.class, false, 1, 180, new Object[]{ getMessage(), new Integer(0) }, "Continuation Pointer");
074                                      this.add(ID.class, false, 1, 2, new Object[]{ getMessage() }, "Accept Acknowledgment Type");
075                                      this.add(ID.class, false, 1, 2, new Object[]{ getMessage() }, "Application Acknowledgment Type");
076                                      this.add(ID.class, false, 1, 2, new Object[]{ getMessage() }, "Country Code");
077                                      this.add(ID.class, false, 0, 16, new Object[]{ getMessage() }, "Character Set");
078                                      this.add(CE.class, false, 1, 60, new Object[]{ getMessage(), new Integer(0) }, "Principal Language Of Message");
079                                      this.add(ID.class, false, 1, 20, new Object[]{ getMessage() }, "Alternate Character Set Handling Scheme");
080           } catch(HL7Exception e) {
081              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating MSH - this is probably a bug in the source code generator.", e);
082           }
083        }
084    
085    
086    
087        /**
088         * Returns
089         * MSH-1: "Field Separator" - creates it if necessary
090         */
091        public ST getFieldSeparator() { 
092            ST ret = null;
093            try {
094                Type t = this.getField(1, 0);
095                ret = (ST)t;
096            } catch (ClassCastException cce) {
097                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
098                throw new RuntimeException(cce);
099            } catch (HL7Exception he) {
100                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
101                throw new RuntimeException(he);
102            }
103            return ret;
104        }
105    
106    
107        /**
108         * Returns
109         * MSH-1: "Field Separator" - creates it if necessary
110         */
111        public ST getMsh1_FieldSeparator() { 
112            ST ret = null;
113            try {
114                Type t = this.getField(1, 0);
115                ret = (ST)t;
116            } catch (ClassCastException cce) {
117                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
118                throw new RuntimeException(cce);
119            } catch (HL7Exception he) {
120                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
121                throw new RuntimeException(he);
122            }
123            return ret;
124        }
125    
126    
127    
128        /**
129         * Returns
130         * MSH-2: "Encoding Characters" - creates it if necessary
131         */
132        public ST getEncodingCharacters() { 
133            ST ret = null;
134            try {
135                Type t = this.getField(2, 0);
136                ret = (ST)t;
137            } catch (ClassCastException cce) {
138                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
139                throw new RuntimeException(cce);
140            } catch (HL7Exception he) {
141                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
142                throw new RuntimeException(he);
143            }
144            return ret;
145        }
146    
147    
148        /**
149         * Returns
150         * MSH-2: "Encoding Characters" - creates it if necessary
151         */
152        public ST getMsh2_EncodingCharacters() { 
153            ST ret = null;
154            try {
155                Type t = this.getField(2, 0);
156                ret = (ST)t;
157            } catch (ClassCastException cce) {
158                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
159                throw new RuntimeException(cce);
160            } catch (HL7Exception he) {
161                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
162                throw new RuntimeException(he);
163            }
164            return ret;
165        }
166    
167    
168    
169        /**
170         * Returns
171         * MSH-3: "Sending Application" - creates it if necessary
172         */
173        public HD getSendingApplication() { 
174            HD ret = null;
175            try {
176                Type t = this.getField(3, 0);
177                ret = (HD)t;
178            } catch (ClassCastException cce) {
179                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
180                throw new RuntimeException(cce);
181            } catch (HL7Exception he) {
182                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
183                throw new RuntimeException(he);
184            }
185            return ret;
186        }
187    
188    
189        /**
190         * Returns
191         * MSH-3: "Sending Application" - creates it if necessary
192         */
193        public HD getMsh3_SendingApplication() { 
194            HD ret = null;
195            try {
196                Type t = this.getField(3, 0);
197                ret = (HD)t;
198            } catch (ClassCastException cce) {
199                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
200                throw new RuntimeException(cce);
201            } catch (HL7Exception he) {
202                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
203                throw new RuntimeException(he);
204            }
205            return ret;
206        }
207    
208    
209    
210        /**
211         * Returns
212         * MSH-4: "Sending Facility" - creates it if necessary
213         */
214        public HD getSendingFacility() { 
215            HD ret = null;
216            try {
217                Type t = this.getField(4, 0);
218                ret = (HD)t;
219            } catch (ClassCastException cce) {
220                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
221                throw new RuntimeException(cce);
222            } catch (HL7Exception he) {
223                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
224                throw new RuntimeException(he);
225            }
226            return ret;
227        }
228    
229    
230        /**
231         * Returns
232         * MSH-4: "Sending Facility" - creates it if necessary
233         */
234        public HD getMsh4_SendingFacility() { 
235            HD ret = null;
236            try {
237                Type t = this.getField(4, 0);
238                ret = (HD)t;
239            } catch (ClassCastException cce) {
240                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
241                throw new RuntimeException(cce);
242            } catch (HL7Exception he) {
243                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
244                throw new RuntimeException(he);
245            }
246            return ret;
247        }
248    
249    
250    
251        /**
252         * Returns
253         * MSH-5: "Receiving Application" - creates it if necessary
254         */
255        public HD getReceivingApplication() { 
256            HD ret = null;
257            try {
258                Type t = this.getField(5, 0);
259                ret = (HD)t;
260            } catch (ClassCastException cce) {
261                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
262                throw new RuntimeException(cce);
263            } catch (HL7Exception he) {
264                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
265                throw new RuntimeException(he);
266            }
267            return ret;
268        }
269    
270    
271        /**
272         * Returns
273         * MSH-5: "Receiving Application" - creates it if necessary
274         */
275        public HD getMsh5_ReceivingApplication() { 
276            HD ret = null;
277            try {
278                Type t = this.getField(5, 0);
279                ret = (HD)t;
280            } catch (ClassCastException cce) {
281                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
282                throw new RuntimeException(cce);
283            } catch (HL7Exception he) {
284                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
285                throw new RuntimeException(he);
286            }
287            return ret;
288        }
289    
290    
291    
292        /**
293         * Returns
294         * MSH-6: "Receiving Facility" - creates it if necessary
295         */
296        public HD getReceivingFacility() { 
297            HD ret = null;
298            try {
299                Type t = this.getField(6, 0);
300                ret = (HD)t;
301            } catch (ClassCastException cce) {
302                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
303                throw new RuntimeException(cce);
304            } catch (HL7Exception he) {
305                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
306                throw new RuntimeException(he);
307            }
308            return ret;
309        }
310    
311    
312        /**
313         * Returns
314         * MSH-6: "Receiving Facility" - creates it if necessary
315         */
316        public HD getMsh6_ReceivingFacility() { 
317            HD ret = null;
318            try {
319                Type t = this.getField(6, 0);
320                ret = (HD)t;
321            } catch (ClassCastException cce) {
322                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
323                throw new RuntimeException(cce);
324            } catch (HL7Exception he) {
325                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
326                throw new RuntimeException(he);
327            }
328            return ret;
329        }
330    
331    
332    
333        /**
334         * Returns
335         * MSH-7: "Date/Time Of Message" - creates it if necessary
336         */
337        public TS getDateTimeOfMessage() { 
338            TS ret = null;
339            try {
340                Type t = this.getField(7, 0);
341                ret = (TS)t;
342            } catch (ClassCastException cce) {
343                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
344                throw new RuntimeException(cce);
345            } catch (HL7Exception he) {
346                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
347                throw new RuntimeException(he);
348            }
349            return ret;
350        }
351    
352    
353        /**
354         * Returns
355         * MSH-7: "Date/Time Of Message" - creates it if necessary
356         */
357        public TS getMsh7_DateTimeOfMessage() { 
358            TS ret = null;
359            try {
360                Type t = this.getField(7, 0);
361                ret = (TS)t;
362            } catch (ClassCastException cce) {
363                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
364                throw new RuntimeException(cce);
365            } catch (HL7Exception he) {
366                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
367                throw new RuntimeException(he);
368            }
369            return ret;
370        }
371    
372    
373    
374        /**
375         * Returns
376         * MSH-8: "Security" - creates it if necessary
377         */
378        public ST getSecurity() { 
379            ST ret = null;
380            try {
381                Type t = this.getField(8, 0);
382                ret = (ST)t;
383            } catch (ClassCastException cce) {
384                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
385                throw new RuntimeException(cce);
386            } catch (HL7Exception he) {
387                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
388                throw new RuntimeException(he);
389            }
390            return ret;
391        }
392    
393    
394        /**
395         * Returns
396         * MSH-8: "Security" - creates it if necessary
397         */
398        public ST getMsh8_Security() { 
399            ST ret = null;
400            try {
401                Type t = this.getField(8, 0);
402                ret = (ST)t;
403            } catch (ClassCastException cce) {
404                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
405                throw new RuntimeException(cce);
406            } catch (HL7Exception he) {
407                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
408                throw new RuntimeException(he);
409            }
410            return ret;
411        }
412    
413    
414    
415        /**
416         * Returns
417         * MSH-9: "Message Type" - creates it if necessary
418         */
419        public MSG getMessageType() { 
420            MSG ret = null;
421            try {
422                Type t = this.getField(9, 0);
423                ret = (MSG)t;
424            } catch (ClassCastException cce) {
425                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
426                throw new RuntimeException(cce);
427            } catch (HL7Exception he) {
428                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
429                throw new RuntimeException(he);
430            }
431            return ret;
432        }
433    
434    
435        /**
436         * Returns
437         * MSH-9: "Message Type" - creates it if necessary
438         */
439        public MSG getMsh9_MessageType() { 
440            MSG ret = null;
441            try {
442                Type t = this.getField(9, 0);
443                ret = (MSG)t;
444            } catch (ClassCastException cce) {
445                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
446                throw new RuntimeException(cce);
447            } catch (HL7Exception he) {
448                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
449                throw new RuntimeException(he);
450            }
451            return ret;
452        }
453    
454    
455    
456        /**
457         * Returns
458         * MSH-10: "Message Control ID" - creates it if necessary
459         */
460        public ST getMessageControlID() { 
461            ST ret = null;
462            try {
463                Type t = this.getField(10, 0);
464                ret = (ST)t;
465            } catch (ClassCastException cce) {
466                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
467                throw new RuntimeException(cce);
468            } catch (HL7Exception he) {
469                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
470                throw new RuntimeException(he);
471            }
472            return ret;
473        }
474    
475    
476        /**
477         * Returns
478         * MSH-10: "Message Control ID" - creates it if necessary
479         */
480        public ST getMsh10_MessageControlID() { 
481            ST ret = null;
482            try {
483                Type t = this.getField(10, 0);
484                ret = (ST)t;
485            } catch (ClassCastException cce) {
486                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
487                throw new RuntimeException(cce);
488            } catch (HL7Exception he) {
489                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
490                throw new RuntimeException(he);
491            }
492            return ret;
493        }
494    
495    
496    
497        /**
498         * Returns
499         * MSH-11: "Processing ID" - creates it if necessary
500         */
501        public PT getProcessingID() { 
502            PT ret = null;
503            try {
504                Type t = this.getField(11, 0);
505                ret = (PT)t;
506            } catch (ClassCastException cce) {
507                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
508                throw new RuntimeException(cce);
509            } catch (HL7Exception he) {
510                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
511                throw new RuntimeException(he);
512            }
513            return ret;
514        }
515    
516    
517        /**
518         * Returns
519         * MSH-11: "Processing ID" - creates it if necessary
520         */
521        public PT getMsh11_ProcessingID() { 
522            PT ret = null;
523            try {
524                Type t = this.getField(11, 0);
525                ret = (PT)t;
526            } catch (ClassCastException cce) {
527                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
528                throw new RuntimeException(cce);
529            } catch (HL7Exception he) {
530                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
531                throw new RuntimeException(he);
532            }
533            return ret;
534        }
535    
536    
537    
538        /**
539         * Returns
540         * MSH-12: "Version ID" - creates it if necessary
541         */
542        public VID getVersionID() { 
543            VID ret = null;
544            try {
545                Type t = this.getField(12, 0);
546                ret = (VID)t;
547            } catch (ClassCastException cce) {
548                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
549                throw new RuntimeException(cce);
550            } catch (HL7Exception he) {
551                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
552                throw new RuntimeException(he);
553            }
554            return ret;
555        }
556    
557    
558        /**
559         * Returns
560         * MSH-12: "Version ID" - creates it if necessary
561         */
562        public VID getMsh12_VersionID() { 
563            VID ret = null;
564            try {
565                Type t = this.getField(12, 0);
566                ret = (VID)t;
567            } catch (ClassCastException cce) {
568                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
569                throw new RuntimeException(cce);
570            } catch (HL7Exception he) {
571                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
572                throw new RuntimeException(he);
573            }
574            return ret;
575        }
576    
577    
578    
579        /**
580         * Returns
581         * MSH-13: "Sequence Number" - creates it if necessary
582         */
583        public NM getSequenceNumber() { 
584            NM ret = null;
585            try {
586                Type t = this.getField(13, 0);
587                ret = (NM)t;
588            } catch (ClassCastException cce) {
589                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
590                throw new RuntimeException(cce);
591            } catch (HL7Exception he) {
592                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
593                throw new RuntimeException(he);
594            }
595            return ret;
596        }
597    
598    
599        /**
600         * Returns
601         * MSH-13: "Sequence Number" - creates it if necessary
602         */
603        public NM getMsh13_SequenceNumber() { 
604            NM ret = null;
605            try {
606                Type t = this.getField(13, 0);
607                ret = (NM)t;
608            } catch (ClassCastException cce) {
609                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
610                throw new RuntimeException(cce);
611            } catch (HL7Exception he) {
612                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
613                throw new RuntimeException(he);
614            }
615            return ret;
616        }
617    
618    
619    
620        /**
621         * Returns
622         * MSH-14: "Continuation Pointer" - creates it if necessary
623         */
624        public ST getContinuationPointer() { 
625            ST ret = null;
626            try {
627                Type t = this.getField(14, 0);
628                ret = (ST)t;
629            } catch (ClassCastException cce) {
630                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
631                throw new RuntimeException(cce);
632            } catch (HL7Exception he) {
633                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
634                throw new RuntimeException(he);
635            }
636            return ret;
637        }
638    
639    
640        /**
641         * Returns
642         * MSH-14: "Continuation Pointer" - creates it if necessary
643         */
644        public ST getMsh14_ContinuationPointer() { 
645            ST ret = null;
646            try {
647                Type t = this.getField(14, 0);
648                ret = (ST)t;
649            } catch (ClassCastException cce) {
650                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
651                throw new RuntimeException(cce);
652            } catch (HL7Exception he) {
653                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
654                throw new RuntimeException(he);
655            }
656            return ret;
657        }
658    
659    
660    
661        /**
662         * Returns
663         * MSH-15: "Accept Acknowledgment Type" - creates it if necessary
664         */
665        public ID getAcceptAcknowledgmentType() { 
666            ID ret = null;
667            try {
668                Type t = this.getField(15, 0);
669                ret = (ID)t;
670            } catch (ClassCastException cce) {
671                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
672                throw new RuntimeException(cce);
673            } catch (HL7Exception he) {
674                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
675                throw new RuntimeException(he);
676            }
677            return ret;
678        }
679    
680    
681        /**
682         * Returns
683         * MSH-15: "Accept Acknowledgment Type" - creates it if necessary
684         */
685        public ID getMsh15_AcceptAcknowledgmentType() { 
686            ID ret = null;
687            try {
688                Type t = this.getField(15, 0);
689                ret = (ID)t;
690            } catch (ClassCastException cce) {
691                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
692                throw new RuntimeException(cce);
693            } catch (HL7Exception he) {
694                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
695                throw new RuntimeException(he);
696            }
697            return ret;
698        }
699    
700    
701    
702        /**
703         * Returns
704         * MSH-16: "Application Acknowledgment Type" - creates it if necessary
705         */
706        public ID getApplicationAcknowledgmentType() { 
707            ID ret = null;
708            try {
709                Type t = this.getField(16, 0);
710                ret = (ID)t;
711            } catch (ClassCastException cce) {
712                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
713                throw new RuntimeException(cce);
714            } catch (HL7Exception he) {
715                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
716                throw new RuntimeException(he);
717            }
718            return ret;
719        }
720    
721    
722        /**
723         * Returns
724         * MSH-16: "Application Acknowledgment Type" - creates it if necessary
725         */
726        public ID getMsh16_ApplicationAcknowledgmentType() { 
727            ID ret = null;
728            try {
729                Type t = this.getField(16, 0);
730                ret = (ID)t;
731            } catch (ClassCastException cce) {
732                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
733                throw new RuntimeException(cce);
734            } catch (HL7Exception he) {
735                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
736                throw new RuntimeException(he);
737            }
738            return ret;
739        }
740    
741    
742    
743        /**
744         * Returns
745         * MSH-17: "Country Code" - creates it if necessary
746         */
747        public ID getCountryCode() { 
748            ID ret = null;
749            try {
750                Type t = this.getField(17, 0);
751                ret = (ID)t;
752            } catch (ClassCastException cce) {
753                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
754                throw new RuntimeException(cce);
755            } catch (HL7Exception he) {
756                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
757                throw new RuntimeException(he);
758            }
759            return ret;
760        }
761    
762    
763        /**
764         * Returns
765         * MSH-17: "Country Code" - creates it if necessary
766         */
767        public ID getMsh17_CountryCode() { 
768            ID ret = null;
769            try {
770                Type t = this.getField(17, 0);
771                ret = (ID)t;
772            } catch (ClassCastException cce) {
773                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
774                throw new RuntimeException(cce);
775            } catch (HL7Exception he) {
776                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
777                throw new RuntimeException(he);
778            }
779            return ret;
780        }
781    
782    
783        /**
784         * Returns all repetitions of Character Set (MSH-18).
785         */
786        public ID[] getCharacterSet() {
787            ID[] ret = null;
788            try {
789                Type[] t = this.getField(18);  
790                ret = new ID[t.length];
791                for (int i = 0; i < ret.length; i++) {
792                    ret[i] = (ID)t[i];
793                }
794            } catch (ClassCastException cce) {
795                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
796                throw new RuntimeException(cce);
797            } catch (HL7Exception he) {
798                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
799                throw new RuntimeException(he);
800            }
801            return ret;
802        }
803    
804    
805        /**
806         * Returns a count of the current number of repetitions of Character Set (MSH-18).
807         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
808         * it will return zero.
809         */
810        public int getCharacterSetReps() {
811            ID[] ret = null;
812            try {
813                Type[] t = this.getField(18);
814                return t.length;  
815            } catch (ClassCastException cce) {
816                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
817                throw new RuntimeException(cce);
818            } catch (HL7Exception he) {
819                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
820                throw new RuntimeException(he);
821            }
822        }
823    
824    
825        /**
826         * Returns a specific repetition of
827         * MSH-18: "Character Set" - creates it if necessary
828         *
829         * @param rep The repetition index (0-indexed)
830         */
831        public ID getCharacterSet(int rep) { 
832            ID ret = null;
833            try {
834                Type t = this.getField(18, rep);
835                ret = (ID)t;
836            } catch (ClassCastException cce) {
837                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
838                throw new RuntimeException(cce);
839            } catch (HL7Exception he) {
840                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
841                throw new RuntimeException(he);
842            }
843            return ret;
844        }
845    
846        /**
847         * Returns a specific repetition of
848         * MSH-18: "Character Set" - creates it if necessary
849         *
850         * @param rep The repetition index (0-indexed)
851         */
852        public ID getMsh18_CharacterSet(int rep) { 
853            ID ret = null;
854            try {
855                Type t = this.getField(18, rep);
856                ret = (ID)t;
857            } catch (ClassCastException cce) {
858                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
859                throw new RuntimeException(cce);
860            } catch (HL7Exception he) {
861                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
862                throw new RuntimeException(he);
863            }
864            return ret;
865        }
866    
867    
868        /**
869         * Returns a count of the current number of repetitions of Character Set (MSH-18).
870         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
871         * it will return zero.
872         */
873        public int getMsh18_CharacterSetReps() {
874            ID[] ret = null;
875            try {
876                Type[] t = this.getField(18);
877                return t.length;  
878            } catch (ClassCastException cce) {
879                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
880                throw new RuntimeException(cce);
881            } catch (HL7Exception he) {
882                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
883                throw new RuntimeException(he);
884            }
885        }
886    
887    
888    
889        /**
890         * Inserts a repetition of
891         * MSH-18: "Character Set" at a specific index
892         *
893         * @param rep The repetition index (0-indexed)
894         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
895         */
896        public ID insertCharacterSet(int rep) throws HL7Exception { 
897            return (ID) super.insertRepetition(18, rep);
898        }
899    
900    
901    
902        /**
903         * Inserts a repetition of
904         * MSH-18: "Character Set" at a specific index
905         *
906         * @param rep The repetition index (0-indexed)
907         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
908         */
909        public ID insertMsh18_CharacterSet(int rep) throws HL7Exception { 
910            return (ID) super.insertRepetition(18, rep);
911        }
912    
913    
914        /**
915         * Removes a repetition of
916         * MSH-18: "Character Set" at a specific index
917         *
918         * @param rep The repetition index (0-indexed)
919         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
920         */
921        public ID removeCharacterSet(int rep) throws HL7Exception { 
922            return (ID) super.removeRepetition(18, rep);
923        }
924    
925    
926        /**
927         * Removes a repetition of
928         * MSH-18: "Character Set" at a specific index
929         *
930         * @param rep The repetition index (0-indexed)
931         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
932         */
933        public ID removeMsh18_CharacterSet(int rep) throws HL7Exception { 
934            return (ID) super.removeRepetition(18, rep);
935        }
936    
937    
938    
939    
940        /**
941         * Returns
942         * MSH-19: "Principal Language Of Message" - creates it if necessary
943         */
944        public CE getPrincipalLanguageOfMessage() { 
945            CE ret = null;
946            try {
947                Type t = this.getField(19, 0);
948                ret = (CE)t;
949            } catch (ClassCastException cce) {
950                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
951                throw new RuntimeException(cce);
952            } catch (HL7Exception he) {
953                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
954                throw new RuntimeException(he);
955            }
956            return ret;
957        }
958    
959    
960        /**
961         * Returns
962         * MSH-19: "Principal Language Of Message" - creates it if necessary
963         */
964        public CE getMsh19_PrincipalLanguageOfMessage() { 
965            CE ret = null;
966            try {
967                Type t = this.getField(19, 0);
968                ret = (CE)t;
969            } catch (ClassCastException cce) {
970                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
971                throw new RuntimeException(cce);
972            } catch (HL7Exception he) {
973                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
974                throw new RuntimeException(he);
975            }
976            return ret;
977        }
978    
979    
980    
981        /**
982         * Returns
983         * MSH-20: "Alternate Character Set Handling Scheme" - creates it if necessary
984         */
985        public ID getAlternateCharacterSetHandlingScheme() { 
986            ID ret = null;
987            try {
988                Type t = this.getField(20, 0);
989                ret = (ID)t;
990            } catch (ClassCastException cce) {
991                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
992                throw new RuntimeException(cce);
993            } catch (HL7Exception he) {
994                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
995                throw new RuntimeException(he);
996            }
997            return ret;
998        }
999    
1000    
1001        /**
1002         * Returns
1003         * MSH-20: "Alternate Character Set Handling Scheme" - creates it if necessary
1004         */
1005        public ID getMsh20_AlternateCharacterSetHandlingScheme() { 
1006            ID ret = null;
1007            try {
1008                Type t = this.getField(20, 0);
1009                ret = (ID)t;
1010            } catch (ClassCastException cce) {
1011                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
1012                throw new RuntimeException(cce);
1013            } catch (HL7Exception he) {
1014                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
1015                throw new RuntimeException(he);
1016            }
1017            return ret;
1018        }
1019    
1020    
1021    
1022    
1023    
1024        /** {@inheritDoc} */   
1025        protected Type createNewTypeWithoutReflection(int field) {
1026           switch (field) {
1027              case 0: return new ST(getMessage());
1028              case 1: return new ST(getMessage());
1029              case 2: return new HD(getMessage());
1030              case 3: return new HD(getMessage());
1031              case 4: return new HD(getMessage());
1032              case 5: return new HD(getMessage());
1033              case 6: return new TS(getMessage());
1034              case 7: return new ST(getMessage());
1035              case 8: return new MSG(getMessage());
1036              case 9: return new ST(getMessage());
1037              case 10: return new PT(getMessage());
1038              case 11: return new VID(getMessage());
1039              case 12: return new NM(getMessage());
1040              case 13: return new ST(getMessage());
1041              case 14: return new ID(getMessage(), new Integer( 155 ));
1042              case 15: return new ID(getMessage(), new Integer( 155 ));
1043              case 16: return new ID(getMessage(), new Integer( 0 ));
1044              case 17: return new ID(getMessage(), new Integer( 211 ));
1045              case 18: return new CE(getMessage());
1046              case 19: return new ID(getMessage(), new Integer( 356 ));
1047              default: return null;
1048           }
1049       }
1050    
1051    
1052    }
1053