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 PEX_P07_ASSOCIATED_PERSON 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: NK1 (Next of kin / associated parties) <b> </b></li>
028                     * <li>2: PEX_P07_ASSOCIATED_RX_ORDER (a Group object) <b>optional </b></li>
029                     * <li>3: PEX_P07_ASSOCIATED_RX_ADMIN (a Group object) <b>optional repeating</b></li>
030                     * <li>4: PRB (Problem Details) <b>optional repeating</b></li>
031                     * <li>5: OBX (Observation/Result) <b>optional repeating</b></li>
032     * </ul>
033     */
034    public class PEX_P07_ASSOCIATED_PERSON extends AbstractGroup {
035    
036        /** 
037         * Creates a new PEX_P07_ASSOCIATED_PERSON group
038         */
039        public PEX_P07_ASSOCIATED_PERSON(Group parent, ModelClassFactory factory) {
040           super(parent, factory);
041           init(factory);
042        }
043    
044        private void init(ModelClassFactory factory) {
045           try {
046                              this.add(NK1.class, true, false);
047                              this.add(PEX_P07_ASSOCIATED_RX_ORDER.class, false, false);
048                              this.add(PEX_P07_ASSOCIATED_RX_ADMIN.class, false, true);
049                              this.add(PRB.class, false, true);
050                              this.add(OBX.class, false, true);
051           } catch(HL7Exception e) {
052              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating PEX_P07_ASSOCIATED_PERSON - this is probably a bug in the source code generator.", e);
053           }
054        }
055    
056        /** 
057         * Returns "2.4"
058         */
059        public String getVersion() {
060           return "2.4";
061        }
062    
063    
064    
065        /**
066         * Returns
067         * NK1 (Next of kin / associated parties) - creates it if necessary
068         */
069        public NK1 getNK1() { 
070           NK1 ret = null;
071           try {
072              ret = (NK1)this.get("NK1");
073           } catch(HL7Exception e) {
074              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
075              throw new RuntimeException(e);
076           }
077           return ret;
078        }
079    
080    
081    
082    
083        /**
084         * Returns
085         * ASSOCIATED_RX_ORDER (a Group object) - creates it if necessary
086         */
087        public PEX_P07_ASSOCIATED_RX_ORDER getASSOCIATED_RX_ORDER() { 
088           PEX_P07_ASSOCIATED_RX_ORDER ret = null;
089           try {
090              ret = (PEX_P07_ASSOCIATED_RX_ORDER)this.get("ASSOCIATED_RX_ORDER");
091           } catch(HL7Exception e) {
092              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
093              throw new RuntimeException(e);
094           }
095           return ret;
096        }
097    
098    
099    
100    
101        /**
102         * Returns
103         * the first repetition of 
104         * ASSOCIATED_RX_ADMIN (a Group object) - creates it if necessary
105         */
106        public PEX_P07_ASSOCIATED_RX_ADMIN getASSOCIATED_RX_ADMIN() { 
107           PEX_P07_ASSOCIATED_RX_ADMIN ret = null;
108           try {
109              ret = (PEX_P07_ASSOCIATED_RX_ADMIN)this.get("ASSOCIATED_RX_ADMIN");
110           } catch(HL7Exception e) {
111              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
112              throw new RuntimeException(e);
113           }
114           return ret;
115        }
116    
117    
118        /**
119         * Returns a specific repetition of
120         * ASSOCIATED_RX_ADMIN (a Group object) - creates it if necessary
121         *
122         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
123         * @throws HL7Exception if the repetition requested is more than one 
124         *     greater than the number of existing repetitions.
125         */
126        public PEX_P07_ASSOCIATED_RX_ADMIN getASSOCIATED_RX_ADMIN(int rep) { 
127           PEX_P07_ASSOCIATED_RX_ADMIN ret = null;
128           try {
129              ret = (PEX_P07_ASSOCIATED_RX_ADMIN)this.get("ASSOCIATED_RX_ADMIN", rep);
130           } catch(HL7Exception e) {
131              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
132              throw new RuntimeException(e);
133           }
134           return ret;
135        }
136    
137        /** 
138         * Returns the number of existing repetitions of ASSOCIATED_RX_ADMIN 
139         */ 
140        public int getASSOCIATED_RX_ADMINReps() { 
141            int reps = -1; 
142            try { 
143                reps = this.getAll("ASSOCIATED_RX_ADMIN").length; 
144            } catch (HL7Exception e) { 
145                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
146                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
147                throw new RuntimeException(message);
148            } 
149            return reps; 
150        } 
151    
152        /**
153         * Inserts a specific repetition of ASSOCIATED_RX_ADMIN (a Group object)
154         * @see AbstractGroup#insertRepetition(Structure, int) 
155         */
156        public void insertASSOCIATED_RX_ADMIN(PEX_P07_ASSOCIATED_RX_ADMIN structure, int rep) throws HL7Exception { 
157           super.insertRepetition("ASSOCIATED_RX_ADMIN", structure, rep);
158        }
159    
160    
161        /**
162         * Inserts a specific repetition of ASSOCIATED_RX_ADMIN (a Group object)
163         * @see AbstractGroup#insertRepetition(Structure, int) 
164         */
165        public PEX_P07_ASSOCIATED_RX_ADMIN insertASSOCIATED_RX_ADMIN(int rep) throws HL7Exception { 
166           return (PEX_P07_ASSOCIATED_RX_ADMIN)super.insertRepetition("ASSOCIATED_RX_ADMIN", rep);
167        }
168    
169    
170        /**
171         * Removes a specific repetition of ASSOCIATED_RX_ADMIN (a Group object)
172         * @see AbstractGroup#removeRepetition(String, int) 
173         */
174        public PEX_P07_ASSOCIATED_RX_ADMIN removeASSOCIATED_RX_ADMIN(int rep) throws HL7Exception { 
175           return (PEX_P07_ASSOCIATED_RX_ADMIN)super.removeRepetition("ASSOCIATED_RX_ADMIN", rep);
176        }
177    
178    
179    
180        /**
181         * Returns
182         * the first repetition of 
183         * PRB (Problem Details) - creates it if necessary
184         */
185        public PRB getPRB() { 
186           PRB ret = null;
187           try {
188              ret = (PRB)this.get("PRB");
189           } catch(HL7Exception e) {
190              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
191              throw new RuntimeException(e);
192           }
193           return ret;
194        }
195    
196    
197        /**
198         * Returns a specific repetition of
199         * PRB (Problem Details) - creates it if necessary
200         *
201         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
202         * @throws HL7Exception if the repetition requested is more than one 
203         *     greater than the number of existing repetitions.
204         */
205        public PRB getPRB(int rep) { 
206           PRB ret = null;
207           try {
208              ret = (PRB)this.get("PRB", rep);
209           } catch(HL7Exception e) {
210              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
211              throw new RuntimeException(e);
212           }
213           return ret;
214        }
215    
216        /** 
217         * Returns the number of existing repetitions of PRB 
218         */ 
219        public int getPRBReps() { 
220            int reps = -1; 
221            try { 
222                reps = this.getAll("PRB").length; 
223            } catch (HL7Exception e) { 
224                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
225                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
226                throw new RuntimeException(message);
227            } 
228            return reps; 
229        } 
230    
231        /**
232         * Inserts a specific repetition of PRB (Problem Details)
233         * @see AbstractGroup#insertRepetition(Structure, int) 
234         */
235        public void insertPRB(PRB structure, int rep) throws HL7Exception { 
236           super.insertRepetition("PRB", structure, rep);
237        }
238    
239    
240        /**
241         * Inserts a specific repetition of PRB (Problem Details)
242         * @see AbstractGroup#insertRepetition(Structure, int) 
243         */
244        public PRB insertPRB(int rep) throws HL7Exception { 
245           return (PRB)super.insertRepetition("PRB", rep);
246        }
247    
248    
249        /**
250         * Removes a specific repetition of PRB (Problem Details)
251         * @see AbstractGroup#removeRepetition(String, int) 
252         */
253        public PRB removePRB(int rep) throws HL7Exception { 
254           return (PRB)super.removeRepetition("PRB", rep);
255        }
256    
257    
258    
259        /**
260         * Returns
261         * the first repetition of 
262         * OBX (Observation/Result) - creates it if necessary
263         */
264        public OBX getOBX() { 
265           OBX ret = null;
266           try {
267              ret = (OBX)this.get("OBX");
268           } catch(HL7Exception e) {
269              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
270              throw new RuntimeException(e);
271           }
272           return ret;
273        }
274    
275    
276        /**
277         * Returns a specific repetition of
278         * OBX (Observation/Result) - creates it if necessary
279         *
280         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
281         * @throws HL7Exception if the repetition requested is more than one 
282         *     greater than the number of existing repetitions.
283         */
284        public OBX getOBX(int rep) { 
285           OBX ret = null;
286           try {
287              ret = (OBX)this.get("OBX", rep);
288           } catch(HL7Exception e) {
289              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
290              throw new RuntimeException(e);
291           }
292           return ret;
293        }
294    
295        /** 
296         * Returns the number of existing repetitions of OBX 
297         */ 
298        public int getOBXReps() { 
299            int reps = -1; 
300            try { 
301                reps = this.getAll("OBX").length; 
302            } catch (HL7Exception e) { 
303                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
304                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
305                throw new RuntimeException(message);
306            } 
307            return reps; 
308        } 
309    
310        /**
311         * Inserts a specific repetition of OBX (Observation/Result)
312         * @see AbstractGroup#insertRepetition(Structure, int) 
313         */
314        public void insertOBX(OBX structure, int rep) throws HL7Exception { 
315           super.insertRepetition("OBX", structure, rep);
316        }
317    
318    
319        /**
320         * Inserts a specific repetition of OBX (Observation/Result)
321         * @see AbstractGroup#insertRepetition(Structure, int) 
322         */
323        public OBX insertOBX(int rep) throws HL7Exception { 
324           return (OBX)super.insertRepetition("OBX", rep);
325        }
326    
327    
328        /**
329         * Removes a specific repetition of OBX (Observation/Result)
330         * @see AbstractGroup#removeRepetition(String, int) 
331         */
332        public OBX removeOBX(int rep) throws HL7Exception { 
333           return (OBX)super.removeRepetition("OBX", rep);
334        }
335    
336    
337    
338    }
339