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 OMG_O19 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: OMG_O19_PATIENT (a Group object) <b>optional </b></li>
026                     * <li>4: OMG_O19_ORDER (a Group object) <b> repeating</b></li>
027     * </ul>
028     */
029    public class OMG_O19 extends AbstractMessage  {
030    
031        /**
032         * Creates a new OMG_O19 message with DefaultModelClassFactory. 
033         */ 
034        public OMG_O19() { 
035           this(new DefaultModelClassFactory());
036        }
037    
038        /** 
039         * Creates a new OMG_O19 message with custom ModelClassFactory.
040         */
041        public OMG_O19(ModelClassFactory factory) {
042           super(factory);
043           init(factory);
044        }
045    
046        private void init(ModelClassFactory factory) {
047           try {
048                              this.add(MSH.class, true, false);
049                              this.add(NTE.class, false, true);
050                              this.add(OMG_O19_PATIENT.class, false, false);
051                              this.add(OMG_O19_ORDER.class, true, true);
052           } catch(HL7Exception e) {
053              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating OMG_O19 - this is probably a bug in the source code generator.", e);
054           }
055        }
056    
057        /** 
058         * Returns "2.4"
059         */
060        public String getVersion() {
061           return "2.4";
062        }
063    
064    
065    
066        /**
067         * Returns
068         * MSH (Message Header) - creates it if necessary
069         */
070        public MSH getMSH() { 
071           MSH ret = null;
072           try {
073              ret = (MSH)this.get("MSH");
074           } catch(HL7Exception e) {
075              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
076              throw new RuntimeException(e);
077           }
078           return ret;
079        }
080    
081    
082    
083    
084        /**
085         * Returns
086         * the first repetition of 
087         * NTE (Notes and Comments) - creates it if necessary
088         */
089        public NTE getNTE() { 
090           NTE ret = null;
091           try {
092              ret = (NTE)this.get("NTE");
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         * Returns a specific repetition of
103         * NTE (Notes and Comments) - creates it if necessary
104         *
105         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
106         * @throws HL7Exception if the repetition requested is more than one 
107         *     greater than the number of existing repetitions.
108         */
109        public NTE getNTE(int rep) { 
110           NTE ret = null;
111           try {
112              ret = (NTE)this.get("NTE", rep);
113           } catch(HL7Exception e) {
114              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
115              throw new RuntimeException(e);
116           }
117           return ret;
118        }
119    
120        /** 
121         * Returns the number of existing repetitions of NTE 
122         */ 
123        public int getNTEReps() { 
124            int reps = -1; 
125            try { 
126                reps = this.getAll("NTE").length; 
127            } catch (HL7Exception e) { 
128                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
129                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
130                throw new RuntimeException(message);
131            } 
132            return reps; 
133        } 
134    
135        /**
136         * Inserts a specific repetition of NTE (Notes and Comments)
137         * @see AbstractGroup\#insertRepetition(Structure, int) 
138         */
139        public void insertNTE(NTE structure, int rep) throws HL7Exception { 
140           super.insertRepetition( "NTE", structure, rep);
141        }
142    
143    
144        /**
145         * Inserts a specific repetition of NTE (Notes and Comments)
146         * @see AbstractGroup\#insertRepetition(Structure, int) 
147         */
148        public NTE insertNTE(int rep) throws HL7Exception { 
149           return (NTE)super.insertRepetition("NTE", rep);
150        }
151    
152    
153        /**
154         * Removes a specific repetition of NTE (Notes and Comments)
155         * @see AbstractGroup\#removeRepetition(String, int) 
156         */
157        public NTE removeNTE(int rep) throws HL7Exception { 
158           return (NTE)super.removeRepetition("NTE", rep);
159        }
160    
161    
162    
163        /**
164         * Returns
165         * PATIENT (a Group object) - creates it if necessary
166         */
167        public OMG_O19_PATIENT getPATIENT() { 
168           OMG_O19_PATIENT ret = null;
169           try {
170              ret = (OMG_O19_PATIENT)this.get("PATIENT");
171           } catch(HL7Exception e) {
172              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
173              throw new RuntimeException(e);
174           }
175           return ret;
176        }
177    
178    
179    
180    
181        /**
182         * Returns
183         * the first repetition of 
184         * ORDER (a Group object) - creates it if necessary
185         */
186        public OMG_O19_ORDER getORDER() { 
187           OMG_O19_ORDER ret = null;
188           try {
189              ret = (OMG_O19_ORDER)this.get("ORDER");
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         * Returns a specific repetition of
200         * ORDER (a Group object) - creates it if necessary
201         *
202         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
203         * @throws HL7Exception if the repetition requested is more than one 
204         *     greater than the number of existing repetitions.
205         */
206        public OMG_O19_ORDER getORDER(int rep) { 
207           OMG_O19_ORDER ret = null;
208           try {
209              ret = (OMG_O19_ORDER)this.get("ORDER", rep);
210           } catch(HL7Exception e) {
211              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
212              throw new RuntimeException(e);
213           }
214           return ret;
215        }
216    
217        /** 
218         * Returns the number of existing repetitions of ORDER 
219         */ 
220        public int getORDERReps() { 
221            int reps = -1; 
222            try { 
223                reps = this.getAll("ORDER").length; 
224            } catch (HL7Exception e) { 
225                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
226                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
227                throw new RuntimeException(message);
228            } 
229            return reps; 
230        } 
231    
232        /**
233         * Inserts a specific repetition of ORDER (a Group object)
234         * @see AbstractGroup\#insertRepetition(Structure, int) 
235         */
236        public void insertORDER(OMG_O19_ORDER structure, int rep) throws HL7Exception { 
237           super.insertRepetition( "ORDER", structure, rep);
238        }
239    
240    
241        /**
242         * Inserts a specific repetition of ORDER (a Group object)
243         * @see AbstractGroup\#insertRepetition(Structure, int) 
244         */
245        public OMG_O19_ORDER insertORDER(int rep) throws HL7Exception { 
246           return (OMG_O19_ORDER)super.insertRepetition("ORDER", rep);
247        }
248    
249    
250        /**
251         * Removes a specific repetition of ORDER (a Group object)
252         * @see AbstractGroup\#removeRepetition(String, int) 
253         */
254        public OMG_O19_ORDER removeORDER(int rep) throws HL7Exception { 
255           return (OMG_O19_ORDER)super.removeRepetition("ORDER", rep);
256        }
257    
258    
259    
260    }
261