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.message;
009    
010    import ca.uhn.hl7v2.model.v24.group.*;
011    import ca.uhn.hl7v2.model.v24.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_A09 message structure (see chapter 3). This structure contains the 
021     * following elements: </p>
022     * <ul>
023                     * <li>1: MSH (Message Header) <b> </b></li>
024                     * <li>2: EVN (Event Type) <b> </b></li>
025                     * <li>3: PID (Patient identification) <b> </b></li>
026                     * <li>4: PD1 (patient additional demographic) <b>optional </b></li>
027                     * <li>5: PV1 (Patient visit) <b> </b></li>
028                     * <li>6: PV2 (Patient visit - additional information) <b>optional </b></li>
029                     * <li>7: DB1 (Disability) <b>optional repeating</b></li>
030                     * <li>8: OBX (Observation/Result) <b>optional repeating</b></li>
031                     * <li>9: DG1 (Diagnosis) <b>optional repeating</b></li>
032     * </ul>
033     */
034    public class ADT_A09 extends AbstractMessage  {
035    
036        /**
037         * Creates a new ADT_A09 message with DefaultModelClassFactory. 
038         */ 
039        public ADT_A09() { 
040           this(new DefaultModelClassFactory());
041        }
042    
043        /** 
044         * Creates a new ADT_A09 message with custom ModelClassFactory.
045         */
046        public ADT_A09(ModelClassFactory factory) {
047           super(factory);
048           init(factory);
049        }
050    
051        private void init(ModelClassFactory factory) {
052           try {
053                              this.add(MSH.class, true, false);
054                              this.add(EVN.class, true, false);
055                              this.add(PID.class, true, false);
056                              this.add(PD1.class, false, false);
057                              this.add(PV1.class, true, false);
058                              this.add(PV2.class, false, false);
059                              this.add(DB1.class, false, true);
060                              this.add(OBX.class, false, true);
061                              this.add(DG1.class, false, true);
062           } catch(HL7Exception e) {
063              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ADT_A09 - this is probably a bug in the source code generator.", e);
064           }
065        }
066    
067        /** 
068         * Returns "2.4"
069         */
070        public String getVersion() {
071           return "2.4";
072        }
073    
074    
075    
076        /**
077         * Returns
078         * MSH (Message Header) - creates it if necessary
079         */
080        public MSH getMSH() { 
081           MSH ret = null;
082           try {
083              ret = (MSH)this.get("MSH");
084           } catch(HL7Exception e) {
085              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
086              throw new RuntimeException(e);
087           }
088           return ret;
089        }
090    
091    
092    
093    
094        /**
095         * Returns
096         * EVN (Event Type) - creates it if necessary
097         */
098        public EVN getEVN() { 
099           EVN ret = null;
100           try {
101              ret = (EVN)this.get("EVN");
102           } catch(HL7Exception e) {
103              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
104              throw new RuntimeException(e);
105           }
106           return ret;
107        }
108    
109    
110    
111    
112        /**
113         * Returns
114         * PID (Patient identification) - creates it if necessary
115         */
116        public PID getPID() { 
117           PID ret = null;
118           try {
119              ret = (PID)this.get("PID");
120           } catch(HL7Exception e) {
121              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
122              throw new RuntimeException(e);
123           }
124           return ret;
125        }
126    
127    
128    
129    
130        /**
131         * Returns
132         * PD1 (patient additional demographic) - creates it if necessary
133         */
134        public PD1 getPD1() { 
135           PD1 ret = null;
136           try {
137              ret = (PD1)this.get("PD1");
138           } catch(HL7Exception e) {
139              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
140              throw new RuntimeException(e);
141           }
142           return ret;
143        }
144    
145    
146    
147    
148        /**
149         * Returns
150         * PV1 (Patient visit) - creates it if necessary
151         */
152        public PV1 getPV1() { 
153           PV1 ret = null;
154           try {
155              ret = (PV1)this.get("PV1");
156           } catch(HL7Exception e) {
157              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
158              throw new RuntimeException(e);
159           }
160           return ret;
161        }
162    
163    
164    
165    
166        /**
167         * Returns
168         * PV2 (Patient visit - additional information) - creates it if necessary
169         */
170        public PV2 getPV2() { 
171           PV2 ret = null;
172           try {
173              ret = (PV2)this.get("PV2");
174           } catch(HL7Exception e) {
175              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
176              throw new RuntimeException(e);
177           }
178           return ret;
179        }
180    
181    
182    
183    
184        /**
185         * Returns
186         * the first repetition of 
187         * DB1 (Disability) - creates it if necessary
188         */
189        public DB1 getDB1() { 
190           DB1 ret = null;
191           try {
192              ret = (DB1)this.get("DB1");
193           } catch(HL7Exception e) {
194              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
195              throw new RuntimeException(e);
196           }
197           return ret;
198        }
199    
200    
201        /**
202         * Returns a specific repetition of
203         * DB1 (Disability) - creates it if necessary
204         *
205         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
206         * @throws HL7Exception if the repetition requested is more than one 
207         *     greater than the number of existing repetitions.
208         */
209        public DB1 getDB1(int rep) { 
210           DB1 ret = null;
211           try {
212              ret = (DB1)this.get("DB1", rep);
213           } catch(HL7Exception e) {
214              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
215              throw new RuntimeException(e);
216           }
217           return ret;
218        }
219    
220        /** 
221         * Returns the number of existing repetitions of DB1 
222         */ 
223        public int getDB1Reps() { 
224            int reps = -1; 
225            try { 
226                reps = this.getAll("DB1").length; 
227            } catch (HL7Exception e) { 
228                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
229                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
230                throw new RuntimeException(message);
231            } 
232            return reps; 
233        } 
234    
235        /**
236         * Inserts a specific repetition of DB1 (Disability)
237         * @see AbstractGroup\#insertRepetition(Structure, int) 
238         */
239        public void insertDB1(DB1 structure, int rep) throws HL7Exception { 
240           super.insertRepetition( "DB1", structure, rep);
241        }
242    
243    
244        /**
245         * Inserts a specific repetition of DB1 (Disability)
246         * @see AbstractGroup\#insertRepetition(Structure, int) 
247         */
248        public DB1 insertDB1(int rep) throws HL7Exception { 
249           return (DB1)super.insertRepetition("DB1", rep);
250        }
251    
252    
253        /**
254         * Removes a specific repetition of DB1 (Disability)
255         * @see AbstractGroup\#removeRepetition(String, int) 
256         */
257        public DB1 removeDB1(int rep) throws HL7Exception { 
258           return (DB1)super.removeRepetition("DB1", rep);
259        }
260    
261    
262    
263        /**
264         * Returns
265         * the first repetition of 
266         * OBX (Observation/Result) - creates it if necessary
267         */
268        public OBX getOBX() { 
269           OBX ret = null;
270           try {
271              ret = (OBX)this.get("OBX");
272           } catch(HL7Exception e) {
273              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
274              throw new RuntimeException(e);
275           }
276           return ret;
277        }
278    
279    
280        /**
281         * Returns a specific repetition of
282         * OBX (Observation/Result) - creates it if necessary
283         *
284         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
285         * @throws HL7Exception if the repetition requested is more than one 
286         *     greater than the number of existing repetitions.
287         */
288        public OBX getOBX(int rep) { 
289           OBX ret = null;
290           try {
291              ret = (OBX)this.get("OBX", rep);
292           } catch(HL7Exception e) {
293              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
294              throw new RuntimeException(e);
295           }
296           return ret;
297        }
298    
299        /** 
300         * Returns the number of existing repetitions of OBX 
301         */ 
302        public int getOBXReps() { 
303            int reps = -1; 
304            try { 
305                reps = this.getAll("OBX").length; 
306            } catch (HL7Exception e) { 
307                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
308                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
309                throw new RuntimeException(message);
310            } 
311            return reps; 
312        } 
313    
314        /**
315         * Inserts a specific repetition of OBX (Observation/Result)
316         * @see AbstractGroup\#insertRepetition(Structure, int) 
317         */
318        public void insertOBX(OBX structure, int rep) throws HL7Exception { 
319           super.insertRepetition( "OBX", structure, rep);
320        }
321    
322    
323        /**
324         * Inserts a specific repetition of OBX (Observation/Result)
325         * @see AbstractGroup\#insertRepetition(Structure, int) 
326         */
327        public OBX insertOBX(int rep) throws HL7Exception { 
328           return (OBX)super.insertRepetition("OBX", rep);
329        }
330    
331    
332        /**
333         * Removes a specific repetition of OBX (Observation/Result)
334         * @see AbstractGroup\#removeRepetition(String, int) 
335         */
336        public OBX removeOBX(int rep) throws HL7Exception { 
337           return (OBX)super.removeRepetition("OBX", rep);
338        }
339    
340    
341    
342        /**
343         * Returns
344         * the first repetition of 
345         * DG1 (Diagnosis) - creates it if necessary
346         */
347        public DG1 getDG1() { 
348           DG1 ret = null;
349           try {
350              ret = (DG1)this.get("DG1");
351           } catch(HL7Exception e) {
352              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
353              throw new RuntimeException(e);
354           }
355           return ret;
356        }
357    
358    
359        /**
360         * Returns a specific repetition of
361         * DG1 (Diagnosis) - creates it if necessary
362         *
363         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
364         * @throws HL7Exception if the repetition requested is more than one 
365         *     greater than the number of existing repetitions.
366         */
367        public DG1 getDG1(int rep) { 
368           DG1 ret = null;
369           try {
370              ret = (DG1)this.get("DG1", rep);
371           } catch(HL7Exception e) {
372              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
373              throw new RuntimeException(e);
374           }
375           return ret;
376        }
377    
378        /** 
379         * Returns the number of existing repetitions of DG1 
380         */ 
381        public int getDG1Reps() { 
382            int reps = -1; 
383            try { 
384                reps = this.getAll("DG1").length; 
385            } catch (HL7Exception e) { 
386                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
387                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
388                throw new RuntimeException(message);
389            } 
390            return reps; 
391        } 
392    
393        /**
394         * Inserts a specific repetition of DG1 (Diagnosis)
395         * @see AbstractGroup\#insertRepetition(Structure, int) 
396         */
397        public void insertDG1(DG1 structure, int rep) throws HL7Exception { 
398           super.insertRepetition( "DG1", structure, rep);
399        }
400    
401    
402        /**
403         * Inserts a specific repetition of DG1 (Diagnosis)
404         * @see AbstractGroup\#insertRepetition(Structure, int) 
405         */
406        public DG1 insertDG1(int rep) throws HL7Exception { 
407           return (DG1)super.insertRepetition("DG1", rep);
408        }
409    
410    
411        /**
412         * Removes a specific repetition of DG1 (Diagnosis)
413         * @see AbstractGroup\#removeRepetition(String, int) 
414         */
415        public DG1 removeDG1(int rep) throws HL7Exception { 
416           return (DG1)super.removeRepetition("DG1", rep);
417        }
418    
419    
420    
421    }
422