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.v231.message;
009    
010    import ca.uhn.hl7v2.model.v231.group.*;
011    import ca.uhn.hl7v2.model.v231.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_O01 message structure (see chapter 4.6). This structure contains the 
021     * following elements: </p>
022     * <ul>
023                     * <li>1: MSH (MSH - message header segment) <b> </b></li>
024                     * <li>2: NTE (NTE - notes and comments segment) <b>optional repeating</b></li>
025                     * <li>3: OMD_O01_PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1 (a Group object) <b>optional </b></li>
026                     * <li>4: OMD_O01_ORCODSNTEOBXNTE (a Group object) <b> repeating</b></li>
027                     * <li>5: OMD_O01_ORCODTNTE (a Group object) <b>optional repeating</b></li>
028     * </ul>
029     */
030    public class OMD_O01 extends AbstractMessage  {
031    
032        /**
033         * Creates a new OMD_O01 message with DefaultModelClassFactory. 
034         */ 
035        public OMD_O01() { 
036           this(new DefaultModelClassFactory());
037        }
038    
039        /** 
040         * Creates a new OMD_O01 message with custom ModelClassFactory.
041         */
042        public OMD_O01(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_O01_PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1.class, false, false);
052                              this.add(OMD_O01_ORCODSNTEOBXNTE.class, true, true);
053                              this.add(OMD_O01_ORCODTNTE.class, false, true);
054           } catch(HL7Exception e) {
055              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating OMD_O01 - this is probably a bug in the source code generator.", e);
056           }
057        }
058    
059        /** 
060         * Returns "2.3.1"
061         */
062        public String getVersion() {
063           return "2.3.1";
064        }
065    
066    
067    
068        /**
069         * Returns
070         * MSH (MSH - message header segment) - 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 (NTE - notes and comments segment) - 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 (NTE - notes and comments segment) - 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 (NTE - notes and comments segment)
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 (NTE - notes and comments segment)
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 (NTE - notes and comments segment)
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         * PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1 (a Group object) - creates it if necessary
168         */
169        public OMD_O01_PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1 getPIDPD1NTEPV1PV2IN1IN2IN3GT1AL1() { 
170           OMD_O01_PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1 ret = null;
171           try {
172              ret = (OMD_O01_PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1)this.get("PIDPD1NTEPV1PV2IN1IN2IN3GT1AL1");
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         * ORCODSNTEOBXNTE (a Group object) - creates it if necessary
187         */
188        public OMD_O01_ORCODSNTEOBXNTE getORCODSNTEOBXNTE() { 
189           OMD_O01_ORCODSNTEOBXNTE ret = null;
190           try {
191              ret = (OMD_O01_ORCODSNTEOBXNTE)this.get("ORCODSNTEOBXNTE");
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         * ORCODSNTEOBXNTE (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_O01_ORCODSNTEOBXNTE getORCODSNTEOBXNTE(int rep) { 
209           OMD_O01_ORCODSNTEOBXNTE ret = null;
210           try {
211              ret = (OMD_O01_ORCODSNTEOBXNTE)this.get("ORCODSNTEOBXNTE", 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 ORCODSNTEOBXNTE 
221         */ 
222        public int getORCODSNTEOBXNTEReps() { 
223            int reps = -1; 
224            try { 
225                reps = this.getAll("ORCODSNTEOBXNTE").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 ORCODSNTEOBXNTE (a Group object)
236         * @see AbstractGroup\#insertRepetition(Structure, int) 
237         */
238        public void insertORCODSNTEOBXNTE(OMD_O01_ORCODSNTEOBXNTE structure, int rep) throws HL7Exception { 
239           super.insertRepetition( "ORCODSNTEOBXNTE", structure, rep);
240        }
241    
242    
243        /**
244         * Inserts a specific repetition of ORCODSNTEOBXNTE (a Group object)
245         * @see AbstractGroup\#insertRepetition(Structure, int) 
246         */
247        public OMD_O01_ORCODSNTEOBXNTE insertORCODSNTEOBXNTE(int rep) throws HL7Exception { 
248           return (OMD_O01_ORCODSNTEOBXNTE)super.insertRepetition("ORCODSNTEOBXNTE", rep);
249        }
250    
251    
252        /**
253         * Removes a specific repetition of ORCODSNTEOBXNTE (a Group object)
254         * @see AbstractGroup\#removeRepetition(String, int) 
255         */
256        public OMD_O01_ORCODSNTEOBXNTE removeORCODSNTEOBXNTE(int rep) throws HL7Exception { 
257           return (OMD_O01_ORCODSNTEOBXNTE)super.removeRepetition("ORCODSNTEOBXNTE", rep);
258        }
259    
260    
261    
262        /**
263         * Returns
264         * the first repetition of 
265         * ORCODTNTE (a Group object) - creates it if necessary
266         */
267        public OMD_O01_ORCODTNTE getORCODTNTE() { 
268           OMD_O01_ORCODTNTE ret = null;
269           try {
270              ret = (OMD_O01_ORCODTNTE)this.get("ORCODTNTE");
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         * ORCODTNTE (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_O01_ORCODTNTE getORCODTNTE(int rep) { 
288           OMD_O01_ORCODTNTE ret = null;
289           try {
290              ret = (OMD_O01_ORCODTNTE)this.get("ORCODTNTE", 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 ORCODTNTE 
300         */ 
301        public int getORCODTNTEReps() { 
302            int reps = -1; 
303            try { 
304                reps = this.getAll("ORCODTNTE").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 ORCODTNTE (a Group object)
315         * @see AbstractGroup\#insertRepetition(Structure, int) 
316         */
317        public void insertORCODTNTE(OMD_O01_ORCODTNTE structure, int rep) throws HL7Exception { 
318           super.insertRepetition( "ORCODTNTE", structure, rep);
319        }
320    
321    
322        /**
323         * Inserts a specific repetition of ORCODTNTE (a Group object)
324         * @see AbstractGroup\#insertRepetition(Structure, int) 
325         */
326        public OMD_O01_ORCODTNTE insertORCODTNTE(int rep) throws HL7Exception { 
327           return (OMD_O01_ORCODTNTE)super.insertRepetition("ORCODTNTE", rep);
328        }
329    
330    
331        /**
332         * Removes a specific repetition of ORCODTNTE (a Group object)
333         * @see AbstractGroup\#removeRepetition(String, int) 
334         */
335        public OMD_O01_ORCODTNTE removeORCODTNTE(int rep) throws HL7Exception { 
336           return (OMD_O01_ORCODTNTE)super.removeRepetition("ORCODTNTE", rep);
337        }
338    
339    
340    
341    }
342