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 RSP_Z86_COMMON_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> </b></li>
028                     * <li>2: RSP_Z86_ORDER_DETAIL (a Group object) <b>optional </b></li>
029                     * <li>3: RSP_Z86_ENCODED_ORDER (a Group object) <b>optional </b></li>
030                     * <li>4: RSP_Z86_DISPENSE (a Group object) <b>optional </b></li>
031                     * <li>5: RSP_Z86_GIVE (a Group object) <b>optional </b></li>
032                     * <li>6: RSP_Z86_ADMINISTRATION (a Group object) <b>optional </b></li>
033                     * <li>7: RSP_Z86_OBSERVATION (a Group object) <b> repeating</b></li>
034     * </ul>
035     */
036    public class RSP_Z86_COMMON_ORDER extends AbstractGroup {
037    
038        /** 
039         * Creates a new RSP_Z86_COMMON_ORDER group
040         */
041        public RSP_Z86_COMMON_ORDER(Group parent, ModelClassFactory factory) {
042           super(parent, factory);
043           init(factory);
044        }
045    
046        private void init(ModelClassFactory factory) {
047           try {
048                              this.add(ORC.class, true, false);
049                              this.add(RSP_Z86_ORDER_DETAIL.class, false, false);
050                              this.add(RSP_Z86_ENCODED_ORDER.class, false, false);
051                              this.add(RSP_Z86_DISPENSE.class, false, false);
052                              this.add(RSP_Z86_GIVE.class, false, false);
053                              this.add(RSP_Z86_ADMINISTRATION.class, false, false);
054                              this.add(RSP_Z86_OBSERVATION.class, true, true);
055           } catch(HL7Exception e) {
056              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating RSP_Z86_COMMON_ORDER - this is probably a bug in the source code generator.", e);
057           }
058        }
059    
060        /** 
061         * Returns "2.4"
062         */
063        public String getVersion() {
064           return "2.4";
065        }
066    
067    
068    
069        /**
070         * Returns
071         * ORC (Common Order) - creates it if necessary
072         */
073        public ORC getORC() { 
074           ORC ret = null;
075           try {
076              ret = (ORC)this.get("ORC");
077           } catch(HL7Exception e) {
078              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
079              throw new RuntimeException(e);
080           }
081           return ret;
082        }
083    
084    
085    
086    
087        /**
088         * Returns
089         * ORDER_DETAIL (a Group object) - creates it if necessary
090         */
091        public RSP_Z86_ORDER_DETAIL getORDER_DETAIL() { 
092           RSP_Z86_ORDER_DETAIL ret = null;
093           try {
094              ret = (RSP_Z86_ORDER_DETAIL)this.get("ORDER_DETAIL");
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    
105        /**
106         * Returns
107         * ENCODED_ORDER (a Group object) - creates it if necessary
108         */
109        public RSP_Z86_ENCODED_ORDER getENCODED_ORDER() { 
110           RSP_Z86_ENCODED_ORDER ret = null;
111           try {
112              ret = (RSP_Z86_ENCODED_ORDER)this.get("ENCODED_ORDER");
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    
122    
123        /**
124         * Returns
125         * DISPENSE (a Group object) - creates it if necessary
126         */
127        public RSP_Z86_DISPENSE getDISPENSE() { 
128           RSP_Z86_DISPENSE ret = null;
129           try {
130              ret = (RSP_Z86_DISPENSE)this.get("DISPENSE");
131           } catch(HL7Exception e) {
132              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
133              throw new RuntimeException(e);
134           }
135           return ret;
136        }
137    
138    
139    
140    
141        /**
142         * Returns
143         * GIVE (a Group object) - creates it if necessary
144         */
145        public RSP_Z86_GIVE getGIVE() { 
146           RSP_Z86_GIVE ret = null;
147           try {
148              ret = (RSP_Z86_GIVE)this.get("GIVE");
149           } catch(HL7Exception e) {
150              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
151              throw new RuntimeException(e);
152           }
153           return ret;
154        }
155    
156    
157    
158    
159        /**
160         * Returns
161         * ADMINISTRATION (a Group object) - creates it if necessary
162         */
163        public RSP_Z86_ADMINISTRATION getADMINISTRATION() { 
164           RSP_Z86_ADMINISTRATION ret = null;
165           try {
166              ret = (RSP_Z86_ADMINISTRATION)this.get("ADMINISTRATION");
167           } catch(HL7Exception e) {
168              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
169              throw new RuntimeException(e);
170           }
171           return ret;
172        }
173    
174    
175    
176    
177        /**
178         * Returns
179         * the first repetition of 
180         * OBSERVATION (a Group object) - creates it if necessary
181         */
182        public RSP_Z86_OBSERVATION getOBSERVATION() { 
183           RSP_Z86_OBSERVATION ret = null;
184           try {
185              ret = (RSP_Z86_OBSERVATION)this.get("OBSERVATION");
186           } catch(HL7Exception e) {
187              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
188              throw new RuntimeException(e);
189           }
190           return ret;
191        }
192    
193    
194        /**
195         * Returns a specific repetition of
196         * OBSERVATION (a Group object) - creates it if necessary
197         *
198         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
199         * @throws HL7Exception if the repetition requested is more than one 
200         *     greater than the number of existing repetitions.
201         */
202        public RSP_Z86_OBSERVATION getOBSERVATION(int rep) { 
203           RSP_Z86_OBSERVATION ret = null;
204           try {
205              ret = (RSP_Z86_OBSERVATION)this.get("OBSERVATION", rep);
206           } catch(HL7Exception e) {
207              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
208              throw new RuntimeException(e);
209           }
210           return ret;
211        }
212    
213        /** 
214         * Returns the number of existing repetitions of OBSERVATION 
215         */ 
216        public int getOBSERVATIONReps() { 
217            int reps = -1; 
218            try { 
219                reps = this.getAll("OBSERVATION").length; 
220            } catch (HL7Exception e) { 
221                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
222                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
223                throw new RuntimeException(message);
224            } 
225            return reps; 
226        } 
227    
228        /**
229         * Inserts a specific repetition of OBSERVATION (a Group object)
230         * @see AbstractGroup#insertRepetition(Structure, int) 
231         */
232        public void insertOBSERVATION(RSP_Z86_OBSERVATION structure, int rep) throws HL7Exception { 
233           super.insertRepetition("OBSERVATION", structure, rep);
234        }
235    
236    
237        /**
238         * Inserts a specific repetition of OBSERVATION (a Group object)
239         * @see AbstractGroup#insertRepetition(Structure, int) 
240         */
241        public RSP_Z86_OBSERVATION insertOBSERVATION(int rep) throws HL7Exception { 
242           return (RSP_Z86_OBSERVATION)super.insertRepetition("OBSERVATION", rep);
243        }
244    
245    
246        /**
247         * Removes a specific repetition of OBSERVATION (a Group object)
248         * @see AbstractGroup#removeRepetition(String, int) 
249         */
250        public RSP_Z86_OBSERVATION removeOBSERVATION(int rep) throws HL7Exception { 
251           return (RSP_Z86_OBSERVATION)super.removeRepetition("OBSERVATION", rep);
252        }
253    
254    
255    
256    }
257