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 BAR_P10 message structure (see chapter 6). 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: PV1 (Patient visit) <b> </b></li>
027                     * <li>5: DG1 (Diagnosis) <b>optional repeating</b></li>
028                     * <li>6: GP1 (Grouping/Reimbursement - Visit) <b> </b></li>
029                     * <li>7: BAR_P10_PROCEDURE (a Group object) <b>optional repeating</b></li>
030     * </ul>
031     */
032    public class BAR_P10 extends AbstractMessage  {
033    
034        /**
035         * Creates a new BAR_P10 message with DefaultModelClassFactory. 
036         */ 
037        public BAR_P10() { 
038           this(new DefaultModelClassFactory());
039        }
040    
041        /** 
042         * Creates a new BAR_P10 message with custom ModelClassFactory.
043         */
044        public BAR_P10(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(EVN.class, true, false);
053                              this.add(PID.class, true, false);
054                              this.add(PV1.class, true, false);
055                              this.add(DG1.class, false, true);
056                              this.add(GP1.class, true, false);
057                              this.add(BAR_P10_PROCEDURE.class, false, true);
058           } catch(HL7Exception e) {
059              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating BAR_P10 - 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         * EVN (Event Type) - creates it if necessary
093         */
094        public EVN getEVN() { 
095           EVN ret = null;
096           try {
097              ret = (EVN)this.get("EVN");
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         * PID (Patient identification) - creates it if necessary
111         */
112        public PID getPID() { 
113           PID ret = null;
114           try {
115              ret = (PID)this.get("PID");
116           } catch(HL7Exception e) {
117              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
118              throw new RuntimeException(e);
119           }
120           return ret;
121        }
122    
123    
124    
125    
126        /**
127         * Returns
128         * PV1 (Patient visit) - creates it if necessary
129         */
130        public PV1 getPV1() { 
131           PV1 ret = null;
132           try {
133              ret = (PV1)this.get("PV1");
134           } catch(HL7Exception e) {
135              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
136              throw new RuntimeException(e);
137           }
138           return ret;
139        }
140    
141    
142    
143    
144        /**
145         * Returns
146         * the first repetition of 
147         * DG1 (Diagnosis) - creates it if necessary
148         */
149        public DG1 getDG1() { 
150           DG1 ret = null;
151           try {
152              ret = (DG1)this.get("DG1");
153           } catch(HL7Exception e) {
154              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
155              throw new RuntimeException(e);
156           }
157           return ret;
158        }
159    
160    
161        /**
162         * Returns a specific repetition of
163         * DG1 (Diagnosis) - creates it if necessary
164         *
165         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
166         * @throws HL7Exception if the repetition requested is more than one 
167         *     greater than the number of existing repetitions.
168         */
169        public DG1 getDG1(int rep) { 
170           DG1 ret = null;
171           try {
172              ret = (DG1)this.get("DG1", rep);
173           } catch(HL7Exception e) {
174              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
175              throw new RuntimeException(e);
176           }
177           return ret;
178        }
179    
180        /** 
181         * Returns the number of existing repetitions of DG1 
182         */ 
183        public int getDG1Reps() { 
184            int reps = -1; 
185            try { 
186                reps = this.getAll("DG1").length; 
187            } catch (HL7Exception e) { 
188                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
189                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
190                throw new RuntimeException(message);
191            } 
192            return reps; 
193        } 
194    
195        /**
196         * Inserts a specific repetition of DG1 (Diagnosis)
197         * @see AbstractGroup\#insertRepetition(Structure, int) 
198         */
199        public void insertDG1(DG1 structure, int rep) throws HL7Exception { 
200           super.insertRepetition( "DG1", structure, rep);
201        }
202    
203    
204        /**
205         * Inserts a specific repetition of DG1 (Diagnosis)
206         * @see AbstractGroup\#insertRepetition(Structure, int) 
207         */
208        public DG1 insertDG1(int rep) throws HL7Exception { 
209           return (DG1)super.insertRepetition("DG1", rep);
210        }
211    
212    
213        /**
214         * Removes a specific repetition of DG1 (Diagnosis)
215         * @see AbstractGroup\#removeRepetition(String, int) 
216         */
217        public DG1 removeDG1(int rep) throws HL7Exception { 
218           return (DG1)super.removeRepetition("DG1", rep);
219        }
220    
221    
222    
223        /**
224         * Returns
225         * GP1 (Grouping/Reimbursement - Visit) - creates it if necessary
226         */
227        public GP1 getGP1() { 
228           GP1 ret = null;
229           try {
230              ret = (GP1)this.get("GP1");
231           } catch(HL7Exception e) {
232              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
233              throw new RuntimeException(e);
234           }
235           return ret;
236        }
237    
238    
239    
240    
241        /**
242         * Returns
243         * the first repetition of 
244         * PROCEDURE (a Group object) - creates it if necessary
245         */
246        public BAR_P10_PROCEDURE getPROCEDURE() { 
247           BAR_P10_PROCEDURE ret = null;
248           try {
249              ret = (BAR_P10_PROCEDURE)this.get("PROCEDURE");
250           } catch(HL7Exception e) {
251              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
252              throw new RuntimeException(e);
253           }
254           return ret;
255        }
256    
257    
258        /**
259         * Returns a specific repetition of
260         * PROCEDURE (a Group object) - creates it if necessary
261         *
262         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
263         * @throws HL7Exception if the repetition requested is more than one 
264         *     greater than the number of existing repetitions.
265         */
266        public BAR_P10_PROCEDURE getPROCEDURE(int rep) { 
267           BAR_P10_PROCEDURE ret = null;
268           try {
269              ret = (BAR_P10_PROCEDURE)this.get("PROCEDURE", rep);
270           } catch(HL7Exception e) {
271              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
272              throw new RuntimeException(e);
273           }
274           return ret;
275        }
276    
277        /** 
278         * Returns the number of existing repetitions of PROCEDURE 
279         */ 
280        public int getPROCEDUREReps() { 
281            int reps = -1; 
282            try { 
283                reps = this.getAll("PROCEDURE").length; 
284            } catch (HL7Exception e) { 
285                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
286                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
287                throw new RuntimeException(message);
288            } 
289            return reps; 
290        } 
291    
292        /**
293         * Inserts a specific repetition of PROCEDURE (a Group object)
294         * @see AbstractGroup\#insertRepetition(Structure, int) 
295         */
296        public void insertPROCEDURE(BAR_P10_PROCEDURE structure, int rep) throws HL7Exception { 
297           super.insertRepetition( "PROCEDURE", structure, rep);
298        }
299    
300    
301        /**
302         * Inserts a specific repetition of PROCEDURE (a Group object)
303         * @see AbstractGroup\#insertRepetition(Structure, int) 
304         */
305        public BAR_P10_PROCEDURE insertPROCEDURE(int rep) throws HL7Exception { 
306           return (BAR_P10_PROCEDURE)super.insertRepetition("PROCEDURE", rep);
307        }
308    
309    
310        /**
311         * Removes a specific repetition of PROCEDURE (a Group object)
312         * @see AbstractGroup\#removeRepetition(String, int) 
313         */
314        public BAR_P10_PROCEDURE removePROCEDURE(int rep) throws HL7Exception { 
315           return (BAR_P10_PROCEDURE)super.removeRepetition("PROCEDURE", rep);
316        }
317    
318    
319    
320    }
321