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