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_A02 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: ROL (Role) <b>optional repeating</b></li>
028                     * <li>6: PV1 (Patient visit) <b> </b></li>
029                     * <li>7: PV2 (Patient visit - additional information) <b>optional </b></li>
030                     * <li>8: ROL (Role) <b>optional repeating</b></li>
031                     * <li>9: DB1 (Disability) <b>optional repeating</b></li>
032                     * <li>10: OBX (Observation/Result) <b>optional repeating</b></li>
033                     * <li>11: PDA (Patient death and autopsy) <b>optional </b></li>
034     * </ul>
035     */
036    public class ADT_A02 extends AbstractMessage  {
037    
038        /**
039         * Creates a new ADT_A02 message with DefaultModelClassFactory. 
040         */ 
041        public ADT_A02() { 
042           this(new DefaultModelClassFactory());
043        }
044    
045        /** 
046         * Creates a new ADT_A02 message with custom ModelClassFactory.
047         */
048        public ADT_A02(ModelClassFactory factory) {
049           super(factory);
050           init(factory);
051        }
052    
053        private void init(ModelClassFactory factory) {
054           try {
055                              this.add(MSH.class, true, false);
056                              this.add(EVN.class, true, false);
057                              this.add(PID.class, true, false);
058                              this.add(PD1.class, false, false);
059                              this.add(ROL.class, false, true);
060                              this.add(PV1.class, true, false);
061                              this.add(PV2.class, false, false);
062                              this.add(ROL.class, false, true);
063                              this.add(DB1.class, false, true);
064                              this.add(OBX.class, false, true);
065                              this.add(PDA.class, false, false);
066           } catch(HL7Exception e) {
067              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ADT_A02 - this is probably a bug in the source code generator.", e);
068           }
069        }
070    
071        /** 
072         * Returns "2.4"
073         */
074        public String getVersion() {
075           return "2.4";
076        }
077    
078    
079    
080        /**
081         * Returns
082         * MSH (Message Header) - creates it if necessary
083         */
084        public MSH getMSH() { 
085           MSH ret = null;
086           try {
087              ret = (MSH)this.get("MSH");
088           } catch(HL7Exception e) {
089              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
090              throw new RuntimeException(e);
091           }
092           return ret;
093        }
094    
095    
096    
097    
098        /**
099         * Returns
100         * EVN (Event Type) - creates it if necessary
101         */
102        public EVN getEVN() { 
103           EVN ret = null;
104           try {
105              ret = (EVN)this.get("EVN");
106           } catch(HL7Exception e) {
107              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
108              throw new RuntimeException(e);
109           }
110           return ret;
111        }
112    
113    
114    
115    
116        /**
117         * Returns
118         * PID (Patient identification) - creates it if necessary
119         */
120        public PID getPID() { 
121           PID ret = null;
122           try {
123              ret = (PID)this.get("PID");
124           } catch(HL7Exception e) {
125              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
126              throw new RuntimeException(e);
127           }
128           return ret;
129        }
130    
131    
132    
133    
134        /**
135         * Returns
136         * PD1 (patient additional demographic) - creates it if necessary
137         */
138        public PD1 getPD1() { 
139           PD1 ret = null;
140           try {
141              ret = (PD1)this.get("PD1");
142           } catch(HL7Exception e) {
143              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
144              throw new RuntimeException(e);
145           }
146           return ret;
147        }
148    
149    
150    
151    
152        /**
153         * Returns
154         * the first repetition of 
155         * ROL (Role) - creates it if necessary
156         */
157        public ROL getROL() { 
158           ROL ret = null;
159           try {
160              ret = (ROL)this.get("ROL");
161           } catch(HL7Exception e) {
162              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
163              throw new RuntimeException(e);
164           }
165           return ret;
166        }
167    
168    
169        /**
170         * Returns a specific repetition of
171         * ROL (Role) - creates it if necessary
172         *
173         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
174         * @throws HL7Exception if the repetition requested is more than one 
175         *     greater than the number of existing repetitions.
176         */
177        public ROL getROL(int rep) { 
178           ROL ret = null;
179           try {
180              ret = (ROL)this.get("ROL", rep);
181           } catch(HL7Exception e) {
182              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
183              throw new RuntimeException(e);
184           }
185           return ret;
186        }
187    
188        /** 
189         * Returns the number of existing repetitions of ROL 
190         */ 
191        public int getROLReps() { 
192            int reps = -1; 
193            try { 
194                reps = this.getAll("ROL").length; 
195            } catch (HL7Exception e) { 
196                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
197                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
198                throw new RuntimeException(message);
199            } 
200            return reps; 
201        } 
202    
203        /**
204         * Inserts a specific repetition of ROL (Role)
205         * @see AbstractGroup\#insertRepetition(Structure, int) 
206         */
207        public void insertROL(ROL structure, int rep) throws HL7Exception { 
208           super.insertRepetition( "ROL", structure, rep);
209        }
210    
211    
212        /**
213         * Inserts a specific repetition of ROL (Role)
214         * @see AbstractGroup\#insertRepetition(Structure, int) 
215         */
216        public ROL insertROL(int rep) throws HL7Exception { 
217           return (ROL)super.insertRepetition("ROL", rep);
218        }
219    
220    
221        /**
222         * Removes a specific repetition of ROL (Role)
223         * @see AbstractGroup\#removeRepetition(String, int) 
224         */
225        public ROL removeROL(int rep) throws HL7Exception { 
226           return (ROL)super.removeRepetition("ROL", rep);
227        }
228    
229    
230    
231        /**
232         * Returns
233         * PV1 (Patient visit) - creates it if necessary
234         */
235        public PV1 getPV1() { 
236           PV1 ret = null;
237           try {
238              ret = (PV1)this.get("PV1");
239           } catch(HL7Exception e) {
240              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
241              throw new RuntimeException(e);
242           }
243           return ret;
244        }
245    
246    
247    
248    
249        /**
250         * Returns
251         * PV2 (Patient visit - additional information) - creates it if necessary
252         */
253        public PV2 getPV2() { 
254           PV2 ret = null;
255           try {
256              ret = (PV2)this.get("PV2");
257           } catch(HL7Exception e) {
258              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
259              throw new RuntimeException(e);
260           }
261           return ret;
262        }
263    
264    
265    
266    
267        /**
268         * Returns
269         * the first repetition of 
270         * ROL2 (Role) - creates it if necessary
271         */
272        public ROL getROL2() { 
273           ROL ret = null;
274           try {
275              ret = (ROL)this.get("ROL2");
276           } catch(HL7Exception e) {
277              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
278              throw new RuntimeException(e);
279           }
280           return ret;
281        }
282    
283    
284        /**
285         * Returns a specific repetition of
286         * ROL2 (Role) - creates it if necessary
287         *
288         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
289         * @throws HL7Exception if the repetition requested is more than one 
290         *     greater than the number of existing repetitions.
291         */
292        public ROL getROL2(int rep) { 
293           ROL ret = null;
294           try {
295              ret = (ROL)this.get("ROL2", rep);
296           } catch(HL7Exception e) {
297              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
298              throw new RuntimeException(e);
299           }
300           return ret;
301        }
302    
303        /** 
304         * Returns the number of existing repetitions of ROL2 
305         */ 
306        public int getROL2Reps() { 
307            int reps = -1; 
308            try { 
309                reps = this.getAll("ROL2").length; 
310            } catch (HL7Exception e) { 
311                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
312                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
313                throw new RuntimeException(message);
314            } 
315            return reps; 
316        } 
317    
318        /**
319         * Inserts a specific repetition of ROL2 (Role)
320         * @see AbstractGroup\#insertRepetition(Structure, int) 
321         */
322        public void insertROL2(ROL structure, int rep) throws HL7Exception { 
323           super.insertRepetition( "ROL2", structure, rep);
324        }
325    
326    
327        /**
328         * Inserts a specific repetition of ROL2 (Role)
329         * @see AbstractGroup\#insertRepetition(Structure, int) 
330         */
331        public ROL insertROL2(int rep) throws HL7Exception { 
332           return (ROL)super.insertRepetition("ROL2", rep);
333        }
334    
335    
336        /**
337         * Removes a specific repetition of ROL2 (Role)
338         * @see AbstractGroup\#removeRepetition(String, int) 
339         */
340        public ROL removeROL2(int rep) throws HL7Exception { 
341           return (ROL)super.removeRepetition("ROL2", rep);
342        }
343    
344    
345    
346        /**
347         * Returns
348         * the first repetition of 
349         * DB1 (Disability) - creates it if necessary
350         */
351        public DB1 getDB1() { 
352           DB1 ret = null;
353           try {
354              ret = (DB1)this.get("DB1");
355           } catch(HL7Exception e) {
356              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
357              throw new RuntimeException(e);
358           }
359           return ret;
360        }
361    
362    
363        /**
364         * Returns a specific repetition of
365         * DB1 (Disability) - creates it if necessary
366         *
367         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
368         * @throws HL7Exception if the repetition requested is more than one 
369         *     greater than the number of existing repetitions.
370         */
371        public DB1 getDB1(int rep) { 
372           DB1 ret = null;
373           try {
374              ret = (DB1)this.get("DB1", rep);
375           } catch(HL7Exception e) {
376              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
377              throw new RuntimeException(e);
378           }
379           return ret;
380        }
381    
382        /** 
383         * Returns the number of existing repetitions of DB1 
384         */ 
385        public int getDB1Reps() { 
386            int reps = -1; 
387            try { 
388                reps = this.getAll("DB1").length; 
389            } catch (HL7Exception e) { 
390                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
391                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
392                throw new RuntimeException(message);
393            } 
394            return reps; 
395        } 
396    
397        /**
398         * Inserts a specific repetition of DB1 (Disability)
399         * @see AbstractGroup\#insertRepetition(Structure, int) 
400         */
401        public void insertDB1(DB1 structure, int rep) throws HL7Exception { 
402           super.insertRepetition( "DB1", structure, rep);
403        }
404    
405    
406        /**
407         * Inserts a specific repetition of DB1 (Disability)
408         * @see AbstractGroup\#insertRepetition(Structure, int) 
409         */
410        public DB1 insertDB1(int rep) throws HL7Exception { 
411           return (DB1)super.insertRepetition("DB1", rep);
412        }
413    
414    
415        /**
416         * Removes a specific repetition of DB1 (Disability)
417         * @see AbstractGroup\#removeRepetition(String, int) 
418         */
419        public DB1 removeDB1(int rep) throws HL7Exception { 
420           return (DB1)super.removeRepetition("DB1", rep);
421        }
422    
423    
424    
425        /**
426         * Returns
427         * the first repetition of 
428         * OBX (Observation/Result) - creates it if necessary
429         */
430        public OBX getOBX() { 
431           OBX ret = null;
432           try {
433              ret = (OBX)this.get("OBX");
434           } catch(HL7Exception e) {
435              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
436              throw new RuntimeException(e);
437           }
438           return ret;
439        }
440    
441    
442        /**
443         * Returns a specific repetition of
444         * OBX (Observation/Result) - creates it if necessary
445         *
446         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
447         * @throws HL7Exception if the repetition requested is more than one 
448         *     greater than the number of existing repetitions.
449         */
450        public OBX getOBX(int rep) { 
451           OBX ret = null;
452           try {
453              ret = (OBX)this.get("OBX", rep);
454           } catch(HL7Exception e) {
455              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
456              throw new RuntimeException(e);
457           }
458           return ret;
459        }
460    
461        /** 
462         * Returns the number of existing repetitions of OBX 
463         */ 
464        public int getOBXReps() { 
465            int reps = -1; 
466            try { 
467                reps = this.getAll("OBX").length; 
468            } catch (HL7Exception e) { 
469                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
470                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
471                throw new RuntimeException(message);
472            } 
473            return reps; 
474        } 
475    
476        /**
477         * Inserts a specific repetition of OBX (Observation/Result)
478         * @see AbstractGroup\#insertRepetition(Structure, int) 
479         */
480        public void insertOBX(OBX structure, int rep) throws HL7Exception { 
481           super.insertRepetition( "OBX", structure, rep);
482        }
483    
484    
485        /**
486         * Inserts a specific repetition of OBX (Observation/Result)
487         * @see AbstractGroup\#insertRepetition(Structure, int) 
488         */
489        public OBX insertOBX(int rep) throws HL7Exception { 
490           return (OBX)super.insertRepetition("OBX", rep);
491        }
492    
493    
494        /**
495         * Removes a specific repetition of OBX (Observation/Result)
496         * @see AbstractGroup\#removeRepetition(String, int) 
497         */
498        public OBX removeOBX(int rep) throws HL7Exception { 
499           return (OBX)super.removeRepetition("OBX", rep);
500        }
501    
502    
503    
504        /**
505         * Returns
506         * PDA (Patient death and autopsy) - creates it if necessary
507         */
508        public PDA getPDA() { 
509           PDA ret = null;
510           try {
511              ret = (PDA)this.get("PDA");
512           } catch(HL7Exception e) {
513              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
514              throw new RuntimeException(e);
515           }
516           return ret;
517        }
518    
519    
520    
521    
522    }
523