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.group;
009    
010    import ca.uhn.hl7v2.model.v24.segment.*;
011    
012    import ca.uhn.log.HapiLogFactory;
013    import ca.uhn.hl7v2.HL7Exception;
014    import ca.uhn.hl7v2.parser.ModelClassFactory;
015    import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
016    import ca.uhn.hl7v2.model.AbstractMessage;
017    import ca.uhn.hl7v2.model.Group;
018    import ca.uhn.hl7v2.model.AbstractGroup;
019    import ca.uhn.hl7v2.model.GenericSegment;
020    
021    /**
022     * <p>Represents a RGV_O15_GIVE group structure (a Group object).
023     * A Group is an ordered collection of message segments that can repeat together or be optionally in/excluded together.
024     * This Group contains the following elements:  
025     * </p>
026     * <ul>
027                     * <li>1: RXG (Pharmacy/Treatment Give) <b> </b></li>
028                     * <li>2: RXR (Pharmacy/Treatment Route) <b> repeating</b></li>
029                     * <li>3: RXC (Pharmacy/Treatment Component Order) <b>optional repeating</b></li>
030                     * <li>4: RGV_O15_OBSERVATION (a Group object) <b> repeating</b></li>
031     * </ul>
032     */
033    public class RGV_O15_GIVE extends AbstractGroup {
034    
035        /** 
036         * Creates a new RGV_O15_GIVE group
037         */
038        public RGV_O15_GIVE(Group parent, ModelClassFactory factory) {
039           super(parent, factory);
040           init(factory);
041        }
042    
043        private void init(ModelClassFactory factory) {
044           try {
045                              this.add(RXG.class, true, false);
046                              this.add(RXR.class, true, true);
047                              this.add(RXC.class, false, true);
048                              this.add(RGV_O15_OBSERVATION.class, true, true);
049           } catch(HL7Exception e) {
050              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating RGV_O15_GIVE - this is probably a bug in the source code generator.", e);
051           }
052        }
053    
054        /** 
055         * Returns "2.4"
056         */
057        public String getVersion() {
058           return "2.4";
059        }
060    
061    
062    
063        /**
064         * Returns
065         * RXG (Pharmacy/Treatment Give) - creates it if necessary
066         */
067        public RXG getRXG() { 
068           RXG ret = null;
069           try {
070              ret = (RXG)this.get("RXG");
071           } catch(HL7Exception e) {
072              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
073              throw new RuntimeException(e);
074           }
075           return ret;
076        }
077    
078    
079    
080    
081        /**
082         * Returns
083         * the first repetition of 
084         * RXR (Pharmacy/Treatment Route) - creates it if necessary
085         */
086        public RXR getRXR() { 
087           RXR ret = null;
088           try {
089              ret = (RXR)this.get("RXR");
090           } catch(HL7Exception e) {
091              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
092              throw new RuntimeException(e);
093           }
094           return ret;
095        }
096    
097    
098        /**
099         * Returns a specific repetition of
100         * RXR (Pharmacy/Treatment Route) - creates it if necessary
101         *
102         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
103         * @throws HL7Exception if the repetition requested is more than one 
104         *     greater than the number of existing repetitions.
105         */
106        public RXR getRXR(int rep) { 
107           RXR ret = null;
108           try {
109              ret = (RXR)this.get("RXR", rep);
110           } catch(HL7Exception e) {
111              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
112              throw new RuntimeException(e);
113           }
114           return ret;
115        }
116    
117        /** 
118         * Returns the number of existing repetitions of RXR 
119         */ 
120        public int getRXRReps() { 
121            int reps = -1; 
122            try { 
123                reps = this.getAll("RXR").length; 
124            } catch (HL7Exception e) { 
125                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
126                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
127                throw new RuntimeException(message);
128            } 
129            return reps; 
130        } 
131    
132        /**
133         * Inserts a specific repetition of RXR (Pharmacy/Treatment Route)
134         * @see AbstractGroup#insertRepetition(Structure, int) 
135         */
136        public void insertRXR(RXR structure, int rep) throws HL7Exception { 
137           super.insertRepetition("RXR", structure, rep);
138        }
139    
140    
141        /**
142         * Inserts a specific repetition of RXR (Pharmacy/Treatment Route)
143         * @see AbstractGroup#insertRepetition(Structure, int) 
144         */
145        public RXR insertRXR(int rep) throws HL7Exception { 
146           return (RXR)super.insertRepetition("RXR", rep);
147        }
148    
149    
150        /**
151         * Removes a specific repetition of RXR (Pharmacy/Treatment Route)
152         * @see AbstractGroup#removeRepetition(String, int) 
153         */
154        public RXR removeRXR(int rep) throws HL7Exception { 
155           return (RXR)super.removeRepetition("RXR", rep);
156        }
157    
158    
159    
160        /**
161         * Returns
162         * the first repetition of 
163         * RXC (Pharmacy/Treatment Component Order) - creates it if necessary
164         */
165        public RXC getRXC() { 
166           RXC ret = null;
167           try {
168              ret = (RXC)this.get("RXC");
169           } catch(HL7Exception e) {
170              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
171              throw new RuntimeException(e);
172           }
173           return ret;
174        }
175    
176    
177        /**
178         * Returns a specific repetition of
179         * RXC (Pharmacy/Treatment Component Order) - creates it if necessary
180         *
181         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
182         * @throws HL7Exception if the repetition requested is more than one 
183         *     greater than the number of existing repetitions.
184         */
185        public RXC getRXC(int rep) { 
186           RXC ret = null;
187           try {
188              ret = (RXC)this.get("RXC", rep);
189           } catch(HL7Exception e) {
190              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
191              throw new RuntimeException(e);
192           }
193           return ret;
194        }
195    
196        /** 
197         * Returns the number of existing repetitions of RXC 
198         */ 
199        public int getRXCReps() { 
200            int reps = -1; 
201            try { 
202                reps = this.getAll("RXC").length; 
203            } catch (HL7Exception e) { 
204                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
205                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
206                throw new RuntimeException(message);
207            } 
208            return reps; 
209        } 
210    
211        /**
212         * Inserts a specific repetition of RXC (Pharmacy/Treatment Component Order)
213         * @see AbstractGroup#insertRepetition(Structure, int) 
214         */
215        public void insertRXC(RXC structure, int rep) throws HL7Exception { 
216           super.insertRepetition("RXC", structure, rep);
217        }
218    
219    
220        /**
221         * Inserts a specific repetition of RXC (Pharmacy/Treatment Component Order)
222         * @see AbstractGroup#insertRepetition(Structure, int) 
223         */
224        public RXC insertRXC(int rep) throws HL7Exception { 
225           return (RXC)super.insertRepetition("RXC", rep);
226        }
227    
228    
229        /**
230         * Removes a specific repetition of RXC (Pharmacy/Treatment Component Order)
231         * @see AbstractGroup#removeRepetition(String, int) 
232         */
233        public RXC removeRXC(int rep) throws HL7Exception { 
234           return (RXC)super.removeRepetition("RXC", rep);
235        }
236    
237    
238    
239        /**
240         * Returns
241         * the first repetition of 
242         * OBSERVATION (a Group object) - creates it if necessary
243         */
244        public RGV_O15_OBSERVATION getOBSERVATION() { 
245           RGV_O15_OBSERVATION ret = null;
246           try {
247              ret = (RGV_O15_OBSERVATION)this.get("OBSERVATION");
248           } catch(HL7Exception e) {
249              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
250              throw new RuntimeException(e);
251           }
252           return ret;
253        }
254    
255    
256        /**
257         * Returns a specific repetition of
258         * OBSERVATION (a Group object) - creates it if necessary
259         *
260         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
261         * @throws HL7Exception if the repetition requested is more than one 
262         *     greater than the number of existing repetitions.
263         */
264        public RGV_O15_OBSERVATION getOBSERVATION(int rep) { 
265           RGV_O15_OBSERVATION ret = null;
266           try {
267              ret = (RGV_O15_OBSERVATION)this.get("OBSERVATION", rep);
268           } catch(HL7Exception e) {
269              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
270              throw new RuntimeException(e);
271           }
272           return ret;
273        }
274    
275        /** 
276         * Returns the number of existing repetitions of OBSERVATION 
277         */ 
278        public int getOBSERVATIONReps() { 
279            int reps = -1; 
280            try { 
281                reps = this.getAll("OBSERVATION").length; 
282            } catch (HL7Exception e) { 
283                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
284                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
285                throw new RuntimeException(message);
286            } 
287            return reps; 
288        } 
289    
290        /**
291         * Inserts a specific repetition of OBSERVATION (a Group object)
292         * @see AbstractGroup#insertRepetition(Structure, int) 
293         */
294        public void insertOBSERVATION(RGV_O15_OBSERVATION structure, int rep) throws HL7Exception { 
295           super.insertRepetition("OBSERVATION", structure, rep);
296        }
297    
298    
299        /**
300         * Inserts a specific repetition of OBSERVATION (a Group object)
301         * @see AbstractGroup#insertRepetition(Structure, int) 
302         */
303        public RGV_O15_OBSERVATION insertOBSERVATION(int rep) throws HL7Exception { 
304           return (RGV_O15_OBSERVATION)super.insertRepetition("OBSERVATION", rep);
305        }
306    
307    
308        /**
309         * Removes a specific repetition of OBSERVATION (a Group object)
310         * @see AbstractGroup#removeRepetition(String, int) 
311         */
312        public RGV_O15_OBSERVATION removeOBSERVATION(int rep) throws HL7Exception { 
313           return (RGV_O15_OBSERVATION)super.removeRepetition("OBSERVATION", rep);
314        }
315    
316    
317    
318    }
319