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