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_A24 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>optional </b></li>
028                     * <li>6: DB1 (Disability) <b>optional repeating</b></li>
029                     * <li>7: PID (Patient identification) <b> </b></li>
030                     * <li>8: PD1 (patient additional demographic) <b>optional </b></li>
031                     * <li>9: PV1 (Patient visit) <b>optional </b></li>
032                     * <li>10: DB1 (Disability) <b>optional repeating</b></li>
033     * </ul>
034     */
035    public class ADT_A24 extends AbstractMessage  {
036    
037        /**
038         * Creates a new ADT_A24 message with DefaultModelClassFactory. 
039         */ 
040        public ADT_A24() { 
041           this(new DefaultModelClassFactory());
042        }
043    
044        /** 
045         * Creates a new ADT_A24 message with custom ModelClassFactory.
046         */
047        public ADT_A24(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, false, false);
059                              this.add(DB1.class, false, true);
060                              this.add(PID.class, true, false);
061                              this.add(PD1.class, false, false);
062                              this.add(PV1.class, false, false);
063                              this.add(DB1.class, false, true);
064           } catch(HL7Exception e) {
065              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ADT_A24 - 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         * the first repetition of 
171         * DB1 (Disability) - creates it if necessary
172         */
173        public DB1 getDB1() { 
174           DB1 ret = null;
175           try {
176              ret = (DB1)this.get("DB1");
177           } catch(HL7Exception e) {
178              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
179              throw new RuntimeException(e);
180           }
181           return ret;
182        }
183    
184    
185        /**
186         * Returns a specific repetition of
187         * DB1 (Disability) - creates it if necessary
188         *
189         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
190         * @throws HL7Exception if the repetition requested is more than one 
191         *     greater than the number of existing repetitions.
192         */
193        public DB1 getDB1(int rep) { 
194           DB1 ret = null;
195           try {
196              ret = (DB1)this.get("DB1", rep);
197           } catch(HL7Exception e) {
198              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
199              throw new RuntimeException(e);
200           }
201           return ret;
202        }
203    
204        /** 
205         * Returns the number of existing repetitions of DB1 
206         */ 
207        public int getDB1Reps() { 
208            int reps = -1; 
209            try { 
210                reps = this.getAll("DB1").length; 
211            } catch (HL7Exception e) { 
212                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
213                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
214                throw new RuntimeException(message);
215            } 
216            return reps; 
217        } 
218    
219        /**
220         * Inserts a specific repetition of DB1 (Disability)
221         * @see AbstractGroup\#insertRepetition(Structure, int) 
222         */
223        public void insertDB1(DB1 structure, int rep) throws HL7Exception { 
224           super.insertRepetition( "DB1", structure, rep);
225        }
226    
227    
228        /**
229         * Inserts a specific repetition of DB1 (Disability)
230         * @see AbstractGroup\#insertRepetition(Structure, int) 
231         */
232        public DB1 insertDB1(int rep) throws HL7Exception { 
233           return (DB1)super.insertRepetition("DB1", rep);
234        }
235    
236    
237        /**
238         * Removes a specific repetition of DB1 (Disability)
239         * @see AbstractGroup\#removeRepetition(String, int) 
240         */
241        public DB1 removeDB1(int rep) throws HL7Exception { 
242           return (DB1)super.removeRepetition("DB1", rep);
243        }
244    
245    
246    
247        /**
248         * Returns
249         * PID2 (Patient identification) - creates it if necessary
250         */
251        public PID getPID2() { 
252           PID ret = null;
253           try {
254              ret = (PID)this.get("PID2");
255           } catch(HL7Exception e) {
256              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
257              throw new RuntimeException(e);
258           }
259           return ret;
260        }
261    
262    
263    
264    
265        /**
266         * Returns
267         * PD12 (patient additional demographic) - creates it if necessary
268         */
269        public PD1 getPD12() { 
270           PD1 ret = null;
271           try {
272              ret = (PD1)this.get("PD12");
273           } catch(HL7Exception e) {
274              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
275              throw new RuntimeException(e);
276           }
277           return ret;
278        }
279    
280    
281    
282    
283        /**
284         * Returns
285         * PV12 (Patient visit) - creates it if necessary
286         */
287        public PV1 getPV12() { 
288           PV1 ret = null;
289           try {
290              ret = (PV1)this.get("PV12");
291           } catch(HL7Exception e) {
292              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
293              throw new RuntimeException(e);
294           }
295           return ret;
296        }
297    
298    
299    
300    
301        /**
302         * Returns
303         * the first repetition of 
304         * DB12 (Disability) - creates it if necessary
305         */
306        public DB1 getDB12() { 
307           DB1 ret = null;
308           try {
309              ret = (DB1)this.get("DB12");
310           } catch(HL7Exception e) {
311              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
312              throw new RuntimeException(e);
313           }
314           return ret;
315        }
316    
317    
318        /**
319         * Returns a specific repetition of
320         * DB12 (Disability) - creates it if necessary
321         *
322         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
323         * @throws HL7Exception if the repetition requested is more than one 
324         *     greater than the number of existing repetitions.
325         */
326        public DB1 getDB12(int rep) { 
327           DB1 ret = null;
328           try {
329              ret = (DB1)this.get("DB12", rep);
330           } catch(HL7Exception e) {
331              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
332              throw new RuntimeException(e);
333           }
334           return ret;
335        }
336    
337        /** 
338         * Returns the number of existing repetitions of DB12 
339         */ 
340        public int getDB12Reps() { 
341            int reps = -1; 
342            try { 
343                reps = this.getAll("DB12").length; 
344            } catch (HL7Exception e) { 
345                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
346                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
347                throw new RuntimeException(message);
348            } 
349            return reps; 
350        } 
351    
352        /**
353         * Inserts a specific repetition of DB12 (Disability)
354         * @see AbstractGroup\#insertRepetition(Structure, int) 
355         */
356        public void insertDB12(DB1 structure, int rep) throws HL7Exception { 
357           super.insertRepetition( "DB12", structure, rep);
358        }
359    
360    
361        /**
362         * Inserts a specific repetition of DB12 (Disability)
363         * @see AbstractGroup\#insertRepetition(Structure, int) 
364         */
365        public DB1 insertDB12(int rep) throws HL7Exception { 
366           return (DB1)super.insertRepetition("DB12", rep);
367        }
368    
369    
370        /**
371         * Removes a specific repetition of DB12 (Disability)
372         * @see AbstractGroup\#removeRepetition(String, int) 
373         */
374        public DB1 removeDB12(int rep) throws HL7Exception { 
375           return (DB1)super.removeRepetition("DB12", rep);
376        }
377    
378    
379    
380    }
381