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 ORF_R04_ORDER 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: ORC (Common Order) <b>optional </b></li>
028                     * <li>2: OBR (Observation Request) <b> </b></li>
029                     * <li>3: NTE (Notes and Comments) <b>optional repeating</b></li>
030                     * <li>4: CTD (Contact Data) <b>optional </b></li>
031                     * <li>5: ORF_R04_OBSERVATION (a Group object) <b> repeating</b></li>
032                     * <li>6: CTI (Clinical Trial Identification) <b>optional repeating</b></li>
033     * </ul>
034     */
035    public class ORF_R04_ORDER extends AbstractGroup {
036    
037        /** 
038         * Creates a new ORF_R04_ORDER group
039         */
040        public ORF_R04_ORDER(Group parent, ModelClassFactory factory) {
041           super(parent, factory);
042           init(factory);
043        }
044    
045        private void init(ModelClassFactory factory) {
046           try {
047                              this.add(ORC.class, false, false);
048                              this.add(OBR.class, true, false);
049                              this.add(NTE.class, false, true);
050                              this.add(CTD.class, false, false);
051                              this.add(ORF_R04_OBSERVATION.class, true, true);
052                              this.add(CTI.class, false, true);
053           } catch(HL7Exception e) {
054              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ORF_R04_ORDER - this is probably a bug in the source code generator.", e);
055           }
056        }
057    
058        /** 
059         * Returns "2.4"
060         */
061        public String getVersion() {
062           return "2.4";
063        }
064    
065    
066    
067        /**
068         * Returns
069         * ORC (Common Order) - creates it if necessary
070         */
071        public ORC getORC() { 
072           ORC ret = null;
073           try {
074              ret = (ORC)this.get("ORC");
075           } catch(HL7Exception e) {
076              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
077              throw new RuntimeException(e);
078           }
079           return ret;
080        }
081    
082    
083    
084    
085        /**
086         * Returns
087         * OBR (Observation Request) - creates it if necessary
088         */
089        public OBR getOBR() { 
090           OBR ret = null;
091           try {
092              ret = (OBR)this.get("OBR");
093           } catch(HL7Exception e) {
094              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
095              throw new RuntimeException(e);
096           }
097           return ret;
098        }
099    
100    
101    
102    
103        /**
104         * Returns
105         * the first repetition of 
106         * NTE (Notes and Comments) - creates it if necessary
107         */
108        public NTE getNTE() { 
109           NTE ret = null;
110           try {
111              ret = (NTE)this.get("NTE");
112           } catch(HL7Exception e) {
113              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
114              throw new RuntimeException(e);
115           }
116           return ret;
117        }
118    
119    
120        /**
121         * Returns a specific repetition of
122         * NTE (Notes and Comments) - creates it if necessary
123         *
124         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
125         * @throws HL7Exception if the repetition requested is more than one 
126         *     greater than the number of existing repetitions.
127         */
128        public NTE getNTE(int rep) { 
129           NTE ret = null;
130           try {
131              ret = (NTE)this.get("NTE", rep);
132           } catch(HL7Exception e) {
133              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
134              throw new RuntimeException(e);
135           }
136           return ret;
137        }
138    
139        /** 
140         * Returns the number of existing repetitions of NTE 
141         */ 
142        public int getNTEReps() { 
143            int reps = -1; 
144            try { 
145                reps = this.getAll("NTE").length; 
146            } catch (HL7Exception e) { 
147                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
148                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
149                throw new RuntimeException(message);
150            } 
151            return reps; 
152        } 
153    
154        /**
155         * Inserts a specific repetition of NTE (Notes and Comments)
156         * @see AbstractGroup#insertRepetition(Structure, int) 
157         */
158        public void insertNTE(NTE structure, int rep) throws HL7Exception { 
159           super.insertRepetition("NTE", structure, rep);
160        }
161    
162    
163        /**
164         * Inserts a specific repetition of NTE (Notes and Comments)
165         * @see AbstractGroup#insertRepetition(Structure, int) 
166         */
167        public NTE insertNTE(int rep) throws HL7Exception { 
168           return (NTE)super.insertRepetition("NTE", rep);
169        }
170    
171    
172        /**
173         * Removes a specific repetition of NTE (Notes and Comments)
174         * @see AbstractGroup#removeRepetition(String, int) 
175         */
176        public NTE removeNTE(int rep) throws HL7Exception { 
177           return (NTE)super.removeRepetition("NTE", rep);
178        }
179    
180    
181    
182        /**
183         * Returns
184         * CTD (Contact Data) - creates it if necessary
185         */
186        public CTD getCTD() { 
187           CTD ret = null;
188           try {
189              ret = (CTD)this.get("CTD");
190           } catch(HL7Exception e) {
191              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
192              throw new RuntimeException(e);
193           }
194           return ret;
195        }
196    
197    
198    
199    
200        /**
201         * Returns
202         * the first repetition of 
203         * OBSERVATION (a Group object) - creates it if necessary
204         */
205        public ORF_R04_OBSERVATION getOBSERVATION() { 
206           ORF_R04_OBSERVATION ret = null;
207           try {
208              ret = (ORF_R04_OBSERVATION)this.get("OBSERVATION");
209           } catch(HL7Exception e) {
210              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
211              throw new RuntimeException(e);
212           }
213           return ret;
214        }
215    
216    
217        /**
218         * Returns a specific repetition of
219         * OBSERVATION (a Group object) - creates it if necessary
220         *
221         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
222         * @throws HL7Exception if the repetition requested is more than one 
223         *     greater than the number of existing repetitions.
224         */
225        public ORF_R04_OBSERVATION getOBSERVATION(int rep) { 
226           ORF_R04_OBSERVATION ret = null;
227           try {
228              ret = (ORF_R04_OBSERVATION)this.get("OBSERVATION", rep);
229           } catch(HL7Exception e) {
230              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
231              throw new RuntimeException(e);
232           }
233           return ret;
234        }
235    
236        /** 
237         * Returns the number of existing repetitions of OBSERVATION 
238         */ 
239        public int getOBSERVATIONReps() { 
240            int reps = -1; 
241            try { 
242                reps = this.getAll("OBSERVATION").length; 
243            } catch (HL7Exception e) { 
244                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
245                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
246                throw new RuntimeException(message);
247            } 
248            return reps; 
249        } 
250    
251        /**
252         * Inserts a specific repetition of OBSERVATION (a Group object)
253         * @see AbstractGroup#insertRepetition(Structure, int) 
254         */
255        public void insertOBSERVATION(ORF_R04_OBSERVATION structure, int rep) throws HL7Exception { 
256           super.insertRepetition("OBSERVATION", structure, rep);
257        }
258    
259    
260        /**
261         * Inserts a specific repetition of OBSERVATION (a Group object)
262         * @see AbstractGroup#insertRepetition(Structure, int) 
263         */
264        public ORF_R04_OBSERVATION insertOBSERVATION(int rep) throws HL7Exception { 
265           return (ORF_R04_OBSERVATION)super.insertRepetition("OBSERVATION", rep);
266        }
267    
268    
269        /**
270         * Removes a specific repetition of OBSERVATION (a Group object)
271         * @see AbstractGroup#removeRepetition(String, int) 
272         */
273        public ORF_R04_OBSERVATION removeOBSERVATION(int rep) throws HL7Exception { 
274           return (ORF_R04_OBSERVATION)super.removeRepetition("OBSERVATION", rep);
275        }
276    
277    
278    
279        /**
280         * Returns
281         * the first repetition of 
282         * CTI (Clinical Trial Identification) - creates it if necessary
283         */
284        public CTI getCTI() { 
285           CTI ret = null;
286           try {
287              ret = (CTI)this.get("CTI");
288           } catch(HL7Exception e) {
289              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
290              throw new RuntimeException(e);
291           }
292           return ret;
293        }
294    
295    
296        /**
297         * Returns a specific repetition of
298         * CTI (Clinical Trial Identification) - creates it if necessary
299         *
300         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
301         * @throws HL7Exception if the repetition requested is more than one 
302         *     greater than the number of existing repetitions.
303         */
304        public CTI getCTI(int rep) { 
305           CTI ret = null;
306           try {
307              ret = (CTI)this.get("CTI", rep);
308           } catch(HL7Exception e) {
309              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
310              throw new RuntimeException(e);
311           }
312           return ret;
313        }
314    
315        /** 
316         * Returns the number of existing repetitions of CTI 
317         */ 
318        public int getCTIReps() { 
319            int reps = -1; 
320            try { 
321                reps = this.getAll("CTI").length; 
322            } catch (HL7Exception e) { 
323                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
324                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
325                throw new RuntimeException(message);
326            } 
327            return reps; 
328        } 
329    
330        /**
331         * Inserts a specific repetition of CTI (Clinical Trial Identification)
332         * @see AbstractGroup#insertRepetition(Structure, int) 
333         */
334        public void insertCTI(CTI structure, int rep) throws HL7Exception { 
335           super.insertRepetition("CTI", structure, rep);
336        }
337    
338    
339        /**
340         * Inserts a specific repetition of CTI (Clinical Trial Identification)
341         * @see AbstractGroup#insertRepetition(Structure, int) 
342         */
343        public CTI insertCTI(int rep) throws HL7Exception { 
344           return (CTI)super.insertRepetition("CTI", rep);
345        }
346    
347    
348        /**
349         * Removes a specific repetition of CTI (Clinical Trial Identification)
350         * @see AbstractGroup#removeRepetition(String, int) 
351         */
352        public CTI removeCTI(int rep) throws HL7Exception { 
353           return (CTI)super.removeRepetition("CTI", rep);
354        }
355    
356    
357    
358    }
359