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