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