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