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 * The contents of this file are subject to the Mozilla Public License Version 1.1 
008 * (the "License"); you may not use this file except in compliance with the License. 
009 * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
010 * Software distributed under the License is distributed on an "AS IS" basis, 
011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
012 * specific language governing rights and limitations under the License. 
013 * 
014 * The Original Code is "[file_name]".  Description: 
015 * "[one_line_description]" 
016 * 
017 * The Initial Developer of the Original Code is University Health Network. Copyright (C) 
018 * 2012.  All Rights Reserved. 
019 * 
020 * Contributor(s): ______________________________________. 
021 * 
022 * Alternatively, the contents of this file may be used under the terms of the 
023 * GNU General Public License (the  "GPL"), in which case the provisions of the GPL are 
024 * applicable instead of those above.  If you wish to allow use of your version of this 
025 * file only under the terms of the GPL and not to allow others to use your version 
026 * of this file under the MPL, indicate your decision by deleting  the provisions above 
027 * and replace  them with the notice and other provisions required by the GPL License.  
028 * If you do not delete the provisions above, a recipient may use your version of 
029 * this file under either the MPL or the GPL. 
030 * 
031 */
032
033
034package ca.uhn.hl7v2.model.v25.segment;
035
036// import ca.uhn.hl7v2.model.v25.group.*;
037import ca.uhn.hl7v2.model.v25.datatype.*;
038import ca.uhn.hl7v2.HL7Exception;
039import ca.uhn.hl7v2.parser.ModelClassFactory;
040import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
041import ca.uhn.hl7v2.model.AbstractMessage;
042import ca.uhn.hl7v2.model.Group;
043import ca.uhn.hl7v2.model.Type;
044import ca.uhn.hl7v2.model.AbstractSegment;
045import ca.uhn.hl7v2.model.Varies;
046
047/**
048 *<p>Represents an HL7 MSH message segment (Message Header). 
049 * This segment has the following fields:</p>
050 * <ul>
051     * <li>MSH-1: Field Separator (ST) <b> </b>
052     * <li>MSH-2: Encoding Characters (ST) <b> </b>
053     * <li>MSH-3: Sending Application (HD) <b>optional </b>
054     * <li>MSH-4: Sending Facility (HD) <b>optional </b>
055     * <li>MSH-5: Receiving Application (HD) <b>optional </b>
056     * <li>MSH-6: Receiving Facility (HD) <b>optional </b>
057     * <li>MSH-7: Date/Time Of Message (TS) <b> </b>
058     * <li>MSH-8: Security (ST) <b>optional </b>
059     * <li>MSH-9: Message Type (MSG) <b> </b>
060     * <li>MSH-10: Message Control ID (ST) <b> </b>
061     * <li>MSH-11: Processing ID (PT) <b> </b>
062     * <li>MSH-12: Version ID (VID) <b> </b>
063     * <li>MSH-13: Sequence Number (NM) <b>optional </b>
064     * <li>MSH-14: Continuation Pointer (ST) <b>optional </b>
065     * <li>MSH-15: Accept Acknowledgment Type (ID) <b>optional </b>
066     * <li>MSH-16: Application Acknowledgment Type (ID) <b>optional </b>
067     * <li>MSH-17: Country Code (ID) <b>optional </b>
068     * <li>MSH-18: Character Set (ID) <b>optional repeating</b>
069     * <li>MSH-19: Principal Language Of Message (CE) <b>optional </b>
070     * <li>MSH-20: Alternate Character Set Handling Scheme (ID) <b>optional </b>
071     * <li>MSH-21: Message Profile Identifier (EI) <b>optional repeating</b>
072 * </ul>
073 */
074@SuppressWarnings("unused")
075public class MSH extends AbstractSegment {
076
077    /** 
078     * Creates a new MSH segment
079     */
080    public MSH(Group parent, ModelClassFactory factory) {
081       super(parent, factory);
082       init(factory);
083    }
084
085    private void init(ModelClassFactory factory) {
086       try {
087                                  this.add(ST.class, true, 1, 1, new Object[]{ getMessage() }, "Field Separator");
088                                  this.add(ST.class, true, 1, 4, new Object[]{ getMessage() }, "Encoding Characters");
089                                  this.add(HD.class, false, 1, 227, new Object[]{ getMessage() }, "Sending Application");
090                                  this.add(HD.class, false, 1, 227, new Object[]{ getMessage() }, "Sending Facility");
091                                  this.add(HD.class, false, 1, 227, new Object[]{ getMessage() }, "Receiving Application");
092                                  this.add(HD.class, false, 1, 227, new Object[]{ getMessage() }, "Receiving Facility");
093                                  this.add(TS.class, true, 1, 26, new Object[]{ getMessage() }, "Date/Time Of Message");
094                                  this.add(ST.class, false, 1, 40, new Object[]{ getMessage() }, "Security");
095                                  this.add(MSG.class, true, 1, 15, new Object[]{ getMessage() }, "Message Type");
096                                  this.add(ST.class, true, 1, 20, new Object[]{ getMessage() }, "Message Control ID");
097                                  this.add(PT.class, true, 1, 3, new Object[]{ getMessage() }, "Processing ID");
098                                  this.add(VID.class, true, 1, 60, new Object[]{ getMessage() }, "Version ID");
099                                  this.add(NM.class, false, 1, 15, new Object[]{ getMessage() }, "Sequence Number");
100                                  this.add(ST.class, false, 1, 180, new Object[]{ getMessage() }, "Continuation Pointer");
101                                              this.add(ID.class, false, 1, 2, new Object[]{ getMessage(), new Integer(155) }, "Accept Acknowledgment Type");
102                                              this.add(ID.class, false, 1, 2, new Object[]{ getMessage(), new Integer(155) }, "Application Acknowledgment Type");
103                                              this.add(ID.class, false, 1, 3, new Object[]{ getMessage(), new Integer(399) }, "Country Code");
104                                              this.add(ID.class, false, 0, 16, new Object[]{ getMessage(), new Integer(211) }, "Character Set");
105                                  this.add(CE.class, false, 1, 250, new Object[]{ getMessage() }, "Principal Language Of Message");
106                                              this.add(ID.class, false, 1, 20, new Object[]{ getMessage(), new Integer(356) }, "Alternate Character Set Handling Scheme");
107                                  this.add(EI.class, false, 0, 427, new Object[]{ getMessage() }, "Message Profile Identifier");
108       } catch(HL7Exception e) {
109          log.error("Unexpected error creating MSH - this is probably a bug in the source code generator.", e);
110       }
111    }
112
113
114
115    /**
116     * Returns
117     * MSH-1: "Field Separator" - creates it if necessary
118     */
119    public ST getFieldSeparator() { 
120                ST retVal = this.getTypedField(1, 0);
121                return retVal;
122    }
123    
124    /**
125     * Returns
126     * MSH-1: "Field Separator" - creates it if necessary
127     */
128    public ST getMsh1_FieldSeparator() { 
129                ST retVal = this.getTypedField(1, 0);
130                return retVal;
131    }
132
133
134
135    /**
136     * Returns
137     * MSH-2: "Encoding Characters" - creates it if necessary
138     */
139    public ST getEncodingCharacters() { 
140                ST retVal = this.getTypedField(2, 0);
141                return retVal;
142    }
143    
144    /**
145     * Returns
146     * MSH-2: "Encoding Characters" - creates it if necessary
147     */
148    public ST getMsh2_EncodingCharacters() { 
149                ST retVal = this.getTypedField(2, 0);
150                return retVal;
151    }
152
153
154
155    /**
156     * Returns
157     * MSH-3: "Sending Application" - creates it if necessary
158     */
159    public HD getSendingApplication() { 
160                HD retVal = this.getTypedField(3, 0);
161                return retVal;
162    }
163    
164    /**
165     * Returns
166     * MSH-3: "Sending Application" - creates it if necessary
167     */
168    public HD getMsh3_SendingApplication() { 
169                HD retVal = this.getTypedField(3, 0);
170                return retVal;
171    }
172
173
174
175    /**
176     * Returns
177     * MSH-4: "Sending Facility" - creates it if necessary
178     */
179    public HD getSendingFacility() { 
180                HD retVal = this.getTypedField(4, 0);
181                return retVal;
182    }
183    
184    /**
185     * Returns
186     * MSH-4: "Sending Facility" - creates it if necessary
187     */
188    public HD getMsh4_SendingFacility() { 
189                HD retVal = this.getTypedField(4, 0);
190                return retVal;
191    }
192
193
194
195    /**
196     * Returns
197     * MSH-5: "Receiving Application" - creates it if necessary
198     */
199    public HD getReceivingApplication() { 
200                HD retVal = this.getTypedField(5, 0);
201                return retVal;
202    }
203    
204    /**
205     * Returns
206     * MSH-5: "Receiving Application" - creates it if necessary
207     */
208    public HD getMsh5_ReceivingApplication() { 
209                HD retVal = this.getTypedField(5, 0);
210                return retVal;
211    }
212
213
214
215    /**
216     * Returns
217     * MSH-6: "Receiving Facility" - creates it if necessary
218     */
219    public HD getReceivingFacility() { 
220                HD retVal = this.getTypedField(6, 0);
221                return retVal;
222    }
223    
224    /**
225     * Returns
226     * MSH-6: "Receiving Facility" - creates it if necessary
227     */
228    public HD getMsh6_ReceivingFacility() { 
229                HD retVal = this.getTypedField(6, 0);
230                return retVal;
231    }
232
233
234
235    /**
236     * Returns
237     * MSH-7: "Date/Time Of Message" - creates it if necessary
238     */
239    public TS getDateTimeOfMessage() { 
240                TS retVal = this.getTypedField(7, 0);
241                return retVal;
242    }
243    
244    /**
245     * Returns
246     * MSH-7: "Date/Time Of Message" - creates it if necessary
247     */
248    public TS getMsh7_DateTimeOfMessage() { 
249                TS retVal = this.getTypedField(7, 0);
250                return retVal;
251    }
252
253
254
255    /**
256     * Returns
257     * MSH-8: "Security" - creates it if necessary
258     */
259    public ST getSecurity() { 
260                ST retVal = this.getTypedField(8, 0);
261                return retVal;
262    }
263    
264    /**
265     * Returns
266     * MSH-8: "Security" - creates it if necessary
267     */
268    public ST getMsh8_Security() { 
269                ST retVal = this.getTypedField(8, 0);
270                return retVal;
271    }
272
273
274
275    /**
276     * Returns
277     * MSH-9: "Message Type" - creates it if necessary
278     */
279    public MSG getMessageType() { 
280                MSG retVal = this.getTypedField(9, 0);
281                return retVal;
282    }
283    
284    /**
285     * Returns
286     * MSH-9: "Message Type" - creates it if necessary
287     */
288    public MSG getMsh9_MessageType() { 
289                MSG retVal = this.getTypedField(9, 0);
290                return retVal;
291    }
292
293
294
295    /**
296     * Returns
297     * MSH-10: "Message Control ID" - creates it if necessary
298     */
299    public ST getMessageControlID() { 
300                ST retVal = this.getTypedField(10, 0);
301                return retVal;
302    }
303    
304    /**
305     * Returns
306     * MSH-10: "Message Control ID" - creates it if necessary
307     */
308    public ST getMsh10_MessageControlID() { 
309                ST retVal = this.getTypedField(10, 0);
310                return retVal;
311    }
312
313
314
315    /**
316     * Returns
317     * MSH-11: "Processing ID" - creates it if necessary
318     */
319    public PT getProcessingID() { 
320                PT retVal = this.getTypedField(11, 0);
321                return retVal;
322    }
323    
324    /**
325     * Returns
326     * MSH-11: "Processing ID" - creates it if necessary
327     */
328    public PT getMsh11_ProcessingID() { 
329                PT retVal = this.getTypedField(11, 0);
330                return retVal;
331    }
332
333
334
335    /**
336     * Returns
337     * MSH-12: "Version ID" - creates it if necessary
338     */
339    public VID getVersionID() { 
340                VID retVal = this.getTypedField(12, 0);
341                return retVal;
342    }
343    
344    /**
345     * Returns
346     * MSH-12: "Version ID" - creates it if necessary
347     */
348    public VID getMsh12_VersionID() { 
349                VID retVal = this.getTypedField(12, 0);
350                return retVal;
351    }
352
353
354
355    /**
356     * Returns
357     * MSH-13: "Sequence Number" - creates it if necessary
358     */
359    public NM getSequenceNumber() { 
360                NM retVal = this.getTypedField(13, 0);
361                return retVal;
362    }
363    
364    /**
365     * Returns
366     * MSH-13: "Sequence Number" - creates it if necessary
367     */
368    public NM getMsh13_SequenceNumber() { 
369                NM retVal = this.getTypedField(13, 0);
370                return retVal;
371    }
372
373
374
375    /**
376     * Returns
377     * MSH-14: "Continuation Pointer" - creates it if necessary
378     */
379    public ST getContinuationPointer() { 
380                ST retVal = this.getTypedField(14, 0);
381                return retVal;
382    }
383    
384    /**
385     * Returns
386     * MSH-14: "Continuation Pointer" - creates it if necessary
387     */
388    public ST getMsh14_ContinuationPointer() { 
389                ST retVal = this.getTypedField(14, 0);
390                return retVal;
391    }
392
393
394
395    /**
396     * Returns
397     * MSH-15: "Accept Acknowledgment Type" - creates it if necessary
398     */
399    public ID getAcceptAcknowledgmentType() { 
400                ID retVal = this.getTypedField(15, 0);
401                return retVal;
402    }
403    
404    /**
405     * Returns
406     * MSH-15: "Accept Acknowledgment Type" - creates it if necessary
407     */
408    public ID getMsh15_AcceptAcknowledgmentType() { 
409                ID retVal = this.getTypedField(15, 0);
410                return retVal;
411    }
412
413
414
415    /**
416     * Returns
417     * MSH-16: "Application Acknowledgment Type" - creates it if necessary
418     */
419    public ID getApplicationAcknowledgmentType() { 
420                ID retVal = this.getTypedField(16, 0);
421                return retVal;
422    }
423    
424    /**
425     * Returns
426     * MSH-16: "Application Acknowledgment Type" - creates it if necessary
427     */
428    public ID getMsh16_ApplicationAcknowledgmentType() { 
429                ID retVal = this.getTypedField(16, 0);
430                return retVal;
431    }
432
433
434
435    /**
436     * Returns
437     * MSH-17: "Country Code" - creates it if necessary
438     */
439    public ID getCountryCode() { 
440                ID retVal = this.getTypedField(17, 0);
441                return retVal;
442    }
443    
444    /**
445     * Returns
446     * MSH-17: "Country Code" - creates it if necessary
447     */
448    public ID getMsh17_CountryCode() { 
449                ID retVal = this.getTypedField(17, 0);
450                return retVal;
451    }
452
453
454    /**
455     * Returns all repetitions of Character Set (MSH-18).
456     */
457    public ID[] getCharacterSet() {
458        ID[] retVal = this.getTypedField(18, new ID[0]);
459        return retVal;
460    }
461
462
463    /**
464     * Returns all repetitions of Character Set (MSH-18).
465     */
466    public ID[] getMsh18_CharacterSet() {
467        ID[] retVal = this.getTypedField(18, new ID[0]);
468        return retVal;
469    }
470
471
472    /**
473     * Returns a count of the current number of repetitions of Character Set (MSH-18).
474     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
475     * it will return zero.
476     */
477    public int getCharacterSetReps() {
478        return this.getReps(18);
479    }
480
481
482    /**
483     * Returns a specific repetition of
484     * MSH-18: "Character Set" - creates it if necessary
485     *
486     * @param rep The repetition index (0-indexed)
487     */
488    public ID getCharacterSet(int rep) { 
489                ID retVal = this.getTypedField(18, rep);
490                return retVal;
491    }
492
493    /**
494     * Returns a specific repetition of
495     * MSH-18: "Character Set" - creates it if necessary
496     *
497     * @param rep The repetition index (0-indexed)
498     */
499    public ID getMsh18_CharacterSet(int rep) { 
500                ID retVal = this.getTypedField(18, rep);
501                return retVal;
502    }
503
504    /**
505     * Returns a count of the current number of repetitions of Character Set (MSH-18).
506     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
507     * it will return zero.
508     */
509    public int getMsh18_CharacterSetReps() {
510        return this.getReps(18);
511    }
512
513
514    /**
515     * Inserts a repetition of
516     * MSH-18: "Character Set" at a specific index
517     *
518     * @param rep The repetition index (0-indexed)
519     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
520     */
521    public ID insertCharacterSet(int rep) throws HL7Exception { 
522        return (ID) super.insertRepetition(18, rep);
523    }
524
525
526    /**
527     * Inserts a repetition of
528     * MSH-18: "Character Set" at a specific index
529     *
530     * @param rep The repetition index (0-indexed)
531     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
532     */
533    public ID insertMsh18_CharacterSet(int rep) throws HL7Exception { 
534        return (ID) super.insertRepetition(18, rep);
535    }
536
537
538    /**
539     * Removes a repetition of
540     * MSH-18: "Character Set" at a specific index
541     *
542     * @param rep The repetition index (0-indexed)
543     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
544     */
545    public ID removeCharacterSet(int rep) throws HL7Exception { 
546        return (ID) super.removeRepetition(18, rep);
547    }
548
549
550    /**
551     * Removes a repetition of
552     * MSH-18: "Character Set" at a specific index
553     *
554     * @param rep The repetition index (0-indexed)
555     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
556     */
557    public ID removeMsh18_CharacterSet(int rep) throws HL7Exception { 
558        return (ID) super.removeRepetition(18, rep);
559    }
560
561
562
563
564    /**
565     * Returns
566     * MSH-19: "Principal Language Of Message" - creates it if necessary
567     */
568    public CE getPrincipalLanguageOfMessage() { 
569                CE retVal = this.getTypedField(19, 0);
570                return retVal;
571    }
572    
573    /**
574     * Returns
575     * MSH-19: "Principal Language Of Message" - creates it if necessary
576     */
577    public CE getMsh19_PrincipalLanguageOfMessage() { 
578                CE retVal = this.getTypedField(19, 0);
579                return retVal;
580    }
581
582
583
584    /**
585     * Returns
586     * MSH-20: "Alternate Character Set Handling Scheme" - creates it if necessary
587     */
588    public ID getAlternateCharacterSetHandlingScheme() { 
589                ID retVal = this.getTypedField(20, 0);
590                return retVal;
591    }
592    
593    /**
594     * Returns
595     * MSH-20: "Alternate Character Set Handling Scheme" - creates it if necessary
596     */
597    public ID getMsh20_AlternateCharacterSetHandlingScheme() { 
598                ID retVal = this.getTypedField(20, 0);
599                return retVal;
600    }
601
602
603    /**
604     * Returns all repetitions of Message Profile Identifier (MSH-21).
605     */
606    public EI[] getMessageProfileIdentifier() {
607        EI[] retVal = this.getTypedField(21, new EI[0]);
608        return retVal;
609    }
610
611
612    /**
613     * Returns all repetitions of Message Profile Identifier (MSH-21).
614     */
615    public EI[] getMsh21_MessageProfileIdentifier() {
616        EI[] retVal = this.getTypedField(21, new EI[0]);
617        return retVal;
618    }
619
620
621    /**
622     * Returns a count of the current number of repetitions of Message Profile Identifier (MSH-21).
623     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
624     * it will return zero.
625     */
626    public int getMessageProfileIdentifierReps() {
627        return this.getReps(21);
628    }
629
630
631    /**
632     * Returns a specific repetition of
633     * MSH-21: "Message Profile Identifier" - creates it if necessary
634     *
635     * @param rep The repetition index (0-indexed)
636     */
637    public EI getMessageProfileIdentifier(int rep) { 
638                EI retVal = this.getTypedField(21, rep);
639                return retVal;
640    }
641
642    /**
643     * Returns a specific repetition of
644     * MSH-21: "Message Profile Identifier" - creates it if necessary
645     *
646     * @param rep The repetition index (0-indexed)
647     */
648    public EI getMsh21_MessageProfileIdentifier(int rep) { 
649                EI retVal = this.getTypedField(21, rep);
650                return retVal;
651    }
652
653    /**
654     * Returns a count of the current number of repetitions of Message Profile Identifier (MSH-21).
655     * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
656     * it will return zero.
657     */
658    public int getMsh21_MessageProfileIdentifierReps() {
659        return this.getReps(21);
660    }
661
662
663    /**
664     * Inserts a repetition of
665     * MSH-21: "Message Profile Identifier" at a specific index
666     *
667     * @param rep The repetition index (0-indexed)
668     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
669     */
670    public EI insertMessageProfileIdentifier(int rep) throws HL7Exception { 
671        return (EI) super.insertRepetition(21, rep);
672    }
673
674
675    /**
676     * Inserts a repetition of
677     * MSH-21: "Message Profile Identifier" at a specific index
678     *
679     * @param rep The repetition index (0-indexed)
680     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
681     */
682    public EI insertMsh21_MessageProfileIdentifier(int rep) throws HL7Exception { 
683        return (EI) super.insertRepetition(21, rep);
684    }
685
686
687    /**
688     * Removes a repetition of
689     * MSH-21: "Message Profile Identifier" at a specific index
690     *
691     * @param rep The repetition index (0-indexed)
692     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
693     */
694    public EI removeMessageProfileIdentifier(int rep) throws HL7Exception { 
695        return (EI) super.removeRepetition(21, rep);
696    }
697
698
699    /**
700     * Removes a repetition of
701     * MSH-21: "Message Profile Identifier" at a specific index
702     *
703     * @param rep The repetition index (0-indexed)
704     * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
705     */
706    public EI removeMsh21_MessageProfileIdentifier(int rep) throws HL7Exception { 
707        return (EI) super.removeRepetition(21, rep);
708    }
709
710
711
712
713
714
715    /** {@inheritDoc} */   
716    protected Type createNewTypeWithoutReflection(int field) {
717       switch (field) {
718          case 0: return new ST(getMessage());
719          case 1: return new ST(getMessage());
720          case 2: return new HD(getMessage());
721          case 3: return new HD(getMessage());
722          case 4: return new HD(getMessage());
723          case 5: return new HD(getMessage());
724          case 6: return new TS(getMessage());
725          case 7: return new ST(getMessage());
726          case 8: return new MSG(getMessage());
727          case 9: return new ST(getMessage());
728          case 10: return new PT(getMessage());
729          case 11: return new VID(getMessage());
730          case 12: return new NM(getMessage());
731          case 13: return new ST(getMessage());
732          case 14: return new ID(getMessage(), new Integer( 155 ));
733          case 15: return new ID(getMessage(), new Integer( 155 ));
734          case 16: return new ID(getMessage(), new Integer( 399 ));
735          case 17: return new ID(getMessage(), new Integer( 211 ));
736          case 18: return new CE(getMessage());
737          case 19: return new ID(getMessage(), new Integer( 356 ));
738          case 20: return new EI(getMessage());
739          default: return null;
740       }
741   }
742
743
744}
745