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.message;
009    
010    import ca.uhn.hl7v2.model.v231.group.*;
011    import ca.uhn.hl7v2.model.v231.segment.*;
012    
013    import ca.uhn.log.HapiLogFactory;
014    import ca.uhn.hl7v2.HL7Exception;
015    import ca.uhn.hl7v2.parser.ModelClassFactory;
016    import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
017    import ca.uhn.hl7v2.model.AbstractMessage;
018    
019    /**
020     * <p>Represents a ADT_A45 message structure (see chapter ?). This structure contains the 
021     * following elements: </p>
022     * <ul>
023                     * <li>1: MSH (MSH - message header segment) <b> </b></li>
024                     * <li>2: EVN (EVN - event type segment) <b> </b></li>
025                     * <li>3: PID (PID - patient identification segment) <b> </b></li>
026                     * <li>4: PD1 (PD1 - patient additional demographic segment) <b>optional </b></li>
027                     * <li>5: ADT_A45_MRGPV1 (a Group object) <b> repeating</b></li>
028     * </ul>
029     */
030    public class ADT_A45 extends AbstractMessage  {
031    
032        /**
033         * Creates a new ADT_A45 message with DefaultModelClassFactory. 
034         */ 
035        public ADT_A45() { 
036           this(new DefaultModelClassFactory());
037        }
038    
039        /** 
040         * Creates a new ADT_A45 message with custom ModelClassFactory.
041         */
042        public ADT_A45(ModelClassFactory factory) {
043           super(factory);
044           init(factory);
045        }
046    
047        private void init(ModelClassFactory factory) {
048           try {
049                              this.add(MSH.class, true, false);
050                              this.add(EVN.class, true, false);
051                              this.add(PID.class, true, false);
052                              this.add(PD1.class, false, false);
053                              this.add(ADT_A45_MRGPV1.class, true, true);
054           } catch(HL7Exception e) {
055              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ADT_A45 - this is probably a bug in the source code generator.", e);
056           }
057        }
058    
059        /** 
060         * Returns "2.3.1"
061         */
062        public String getVersion() {
063           return "2.3.1";
064        }
065    
066    
067    
068        /**
069         * Returns
070         * MSH (MSH - message header segment) - creates it if necessary
071         */
072        public MSH getMSH() { 
073           MSH ret = null;
074           try {
075              ret = (MSH)this.get("MSH");
076           } catch(HL7Exception e) {
077              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
078              throw new RuntimeException(e);
079           }
080           return ret;
081        }
082    
083    
084    
085    
086        /**
087         * Returns
088         * EVN (EVN - event type segment) - creates it if necessary
089         */
090        public EVN getEVN() { 
091           EVN ret = null;
092           try {
093              ret = (EVN)this.get("EVN");
094           } catch(HL7Exception e) {
095              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
096              throw new RuntimeException(e);
097           }
098           return ret;
099        }
100    
101    
102    
103    
104        /**
105         * Returns
106         * PID (PID - patient identification segment) - creates it if necessary
107         */
108        public PID getPID() { 
109           PID ret = null;
110           try {
111              ret = (PID)this.get("PID");
112           } catch(HL7Exception e) {
113              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
114              throw new RuntimeException(e);
115           }
116           return ret;
117        }
118    
119    
120    
121    
122        /**
123         * Returns
124         * PD1 (PD1 - patient additional demographic segment) - creates it if necessary
125         */
126        public PD1 getPD1() { 
127           PD1 ret = null;
128           try {
129              ret = (PD1)this.get("PD1");
130           } catch(HL7Exception e) {
131              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
132              throw new RuntimeException(e);
133           }
134           return ret;
135        }
136    
137    
138    
139    
140        /**
141         * Returns
142         * the first repetition of 
143         * MRGPV1 (a Group object) - creates it if necessary
144         */
145        public ADT_A45_MRGPV1 getMRGPV1() { 
146           ADT_A45_MRGPV1 ret = null;
147           try {
148              ret = (ADT_A45_MRGPV1)this.get("MRGPV1");
149           } catch(HL7Exception e) {
150              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
151              throw new RuntimeException(e);
152           }
153           return ret;
154        }
155    
156    
157        /**
158         * Returns a specific repetition of
159         * MRGPV1 (a Group object) - creates it if necessary
160         *
161         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
162         * @throws HL7Exception if the repetition requested is more than one 
163         *     greater than the number of existing repetitions.
164         */
165        public ADT_A45_MRGPV1 getMRGPV1(int rep) { 
166           ADT_A45_MRGPV1 ret = null;
167           try {
168              ret = (ADT_A45_MRGPV1)this.get("MRGPV1", rep);
169           } catch(HL7Exception e) {
170              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
171              throw new RuntimeException(e);
172           }
173           return ret;
174        }
175    
176        /** 
177         * Returns the number of existing repetitions of MRGPV1 
178         */ 
179        public int getMRGPV1Reps() { 
180            int reps = -1; 
181            try { 
182                reps = this.getAll("MRGPV1").length; 
183            } catch (HL7Exception e) { 
184                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
185                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
186                throw new RuntimeException(message);
187            } 
188            return reps; 
189        } 
190    
191        /**
192         * Inserts a specific repetition of MRGPV1 (a Group object)
193         * @see AbstractGroup\#insertRepetition(Structure, int) 
194         */
195        public void insertMRGPV1(ADT_A45_MRGPV1 structure, int rep) throws HL7Exception { 
196           super.insertRepetition( "MRGPV1", structure, rep);
197        }
198    
199    
200        /**
201         * Inserts a specific repetition of MRGPV1 (a Group object)
202         * @see AbstractGroup\#insertRepetition(Structure, int) 
203         */
204        public ADT_A45_MRGPV1 insertMRGPV1(int rep) throws HL7Exception { 
205           return (ADT_A45_MRGPV1)super.insertRepetition("MRGPV1", rep);
206        }
207    
208    
209        /**
210         * Removes a specific repetition of MRGPV1 (a Group object)
211         * @see AbstractGroup\#removeRepetition(String, int) 
212         */
213        public ADT_A45_MRGPV1 removeMRGPV1(int rep) throws HL7Exception { 
214           return (ADT_A45_MRGPV1)super.removeRepetition("MRGPV1", rep);
215        }
216    
217    
218    
219    }
220