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 RAS_O17_ORDER_DETAIL_SUPPLEMENT 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: NTE (Notes and Comments) <b> repeating</b></li>
028                     * <li>2: RXR (Pharmacy/Treatment Route) <b> repeating</b></li>
029                     * <li>3: RAS_O17_COMPONENTS (a Group object) <b>optional </b></li>
030     * </ul>
031     */
032    public class RAS_O17_ORDER_DETAIL_SUPPLEMENT extends AbstractGroup {
033    
034        /** 
035         * Creates a new RAS_O17_ORDER_DETAIL_SUPPLEMENT group
036         */
037        public RAS_O17_ORDER_DETAIL_SUPPLEMENT(Group parent, ModelClassFactory factory) {
038           super(parent, factory);
039           init(factory);
040        }
041    
042        private void init(ModelClassFactory factory) {
043           try {
044                              this.add(NTE.class, true, true);
045                              this.add(RXR.class, true, true);
046                              this.add(RAS_O17_COMPONENTS.class, false, false);
047           } catch(HL7Exception e) {
048              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating RAS_O17_ORDER_DETAIL_SUPPLEMENT - this is probably a bug in the source code generator.", e);
049           }
050        }
051    
052        /** 
053         * Returns "2.4"
054         */
055        public String getVersion() {
056           return "2.4";
057        }
058    
059    
060    
061        /**
062         * Returns
063         * the first repetition of 
064         * NTE (Notes and Comments) - creates it if necessary
065         */
066        public NTE getNTE() { 
067           NTE ret = null;
068           try {
069              ret = (NTE)this.get("NTE");
070           } catch(HL7Exception e) {
071              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
072              throw new RuntimeException(e);
073           }
074           return ret;
075        }
076    
077    
078        /**
079         * Returns a specific repetition of
080         * NTE (Notes and Comments) - creates it if necessary
081         *
082         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
083         * @throws HL7Exception if the repetition requested is more than one 
084         *     greater than the number of existing repetitions.
085         */
086        public NTE getNTE(int rep) { 
087           NTE ret = null;
088           try {
089              ret = (NTE)this.get("NTE", rep);
090           } catch(HL7Exception e) {
091              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
092              throw new RuntimeException(e);
093           }
094           return ret;
095        }
096    
097        /** 
098         * Returns the number of existing repetitions of NTE 
099         */ 
100        public int getNTEReps() { 
101            int reps = -1; 
102            try { 
103                reps = this.getAll("NTE").length; 
104            } catch (HL7Exception e) { 
105                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
106                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
107                throw new RuntimeException(message);
108            } 
109            return reps; 
110        } 
111    
112        /**
113         * Inserts a specific repetition of NTE (Notes and Comments)
114         * @see AbstractGroup#insertRepetition(Structure, int) 
115         */
116        public void insertNTE(NTE structure, int rep) throws HL7Exception { 
117           super.insertRepetition("NTE", structure, rep);
118        }
119    
120    
121        /**
122         * Inserts a specific repetition of NTE (Notes and Comments)
123         * @see AbstractGroup#insertRepetition(Structure, int) 
124         */
125        public NTE insertNTE(int rep) throws HL7Exception { 
126           return (NTE)super.insertRepetition("NTE", rep);
127        }
128    
129    
130        /**
131         * Removes a specific repetition of NTE (Notes and Comments)
132         * @see AbstractGroup#removeRepetition(String, int) 
133         */
134        public NTE removeNTE(int rep) throws HL7Exception { 
135           return (NTE)super.removeRepetition("NTE", rep);
136        }
137    
138    
139    
140        /**
141         * Returns
142         * the first repetition of 
143         * RXR (Pharmacy/Treatment Route) - creates it if necessary
144         */
145        public RXR getRXR() { 
146           RXR ret = null;
147           try {
148              ret = (RXR)this.get("RXR");
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         * Returns a specific repetition of
159         * RXR (Pharmacy/Treatment Route) - creates it if necessary
160         *
161         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
162         * @throws HL7Exception if the repetition requested is more than one 
163         *     greater than the number of existing repetitions.
164         */
165        public RXR getRXR(int rep) { 
166           RXR ret = null;
167           try {
168              ret = (RXR)this.get("RXR", rep);
169           } catch(HL7Exception e) {
170              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
171              throw new RuntimeException(e);
172           }
173           return ret;
174        }
175    
176        /** 
177         * Returns the number of existing repetitions of RXR 
178         */ 
179        public int getRXRReps() { 
180            int reps = -1; 
181            try { 
182                reps = this.getAll("RXR").length; 
183            } catch (HL7Exception e) { 
184                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
185                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
186                throw new RuntimeException(message);
187            } 
188            return reps; 
189        } 
190    
191        /**
192         * Inserts a specific repetition of RXR (Pharmacy/Treatment Route)
193         * @see AbstractGroup#insertRepetition(Structure, int) 
194         */
195        public void insertRXR(RXR structure, int rep) throws HL7Exception { 
196           super.insertRepetition("RXR", structure, rep);
197        }
198    
199    
200        /**
201         * Inserts a specific repetition of RXR (Pharmacy/Treatment Route)
202         * @see AbstractGroup#insertRepetition(Structure, int) 
203         */
204        public RXR insertRXR(int rep) throws HL7Exception { 
205           return (RXR)super.insertRepetition("RXR", rep);
206        }
207    
208    
209        /**
210         * Removes a specific repetition of RXR (Pharmacy/Treatment Route)
211         * @see AbstractGroup#removeRepetition(String, int) 
212         */
213        public RXR removeRXR(int rep) throws HL7Exception { 
214           return (RXR)super.removeRepetition("RXR", rep);
215        }
216    
217    
218    
219        /**
220         * Returns
221         * COMPONENTS (a Group object) - creates it if necessary
222         */
223        public RAS_O17_COMPONENTS getCOMPONENTS() { 
224           RAS_O17_COMPONENTS ret = null;
225           try {
226              ret = (RAS_O17_COMPONENTS)this.get("COMPONENTS");
227           } catch(HL7Exception e) {
228              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
229              throw new RuntimeException(e);
230           }
231           return ret;
232        }
233    
234    
235    
236    
237    }
238