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 SIU_S12_PATIENT 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: PID (Patient identification) <b> </b></li>
028                     * <li>2: PD1 (patient additional demographic) <b>optional </b></li>
029                     * <li>3: PV1 (Patient visit) <b>optional </b></li>
030                     * <li>4: PV2 (Patient visit - additional information) <b>optional </b></li>
031                     * <li>5: OBX (Observation/Result) <b>optional repeating</b></li>
032                     * <li>6: DG1 (Diagnosis) <b>optional repeating</b></li>
033     * </ul>
034     */
035    public class SIU_S12_PATIENT extends AbstractGroup {
036    
037        /** 
038         * Creates a new SIU_S12_PATIENT group
039         */
040        public SIU_S12_PATIENT(Group parent, ModelClassFactory factory) {
041           super(parent, factory);
042           init(factory);
043        }
044    
045        private void init(ModelClassFactory factory) {
046           try {
047                              this.add(PID.class, true, false);
048                              this.add(PD1.class, false, false);
049                              this.add(PV1.class, false, false);
050                              this.add(PV2.class, false, false);
051                              this.add(OBX.class, false, true);
052                              this.add(DG1.class, false, true);
053           } catch(HL7Exception e) {
054              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating SIU_S12_PATIENT - this is probably a bug in the source code generator.", e);
055           }
056        }
057    
058        /** 
059         * Returns "2.4"
060         */
061        public String getVersion() {
062           return "2.4";
063        }
064    
065    
066    
067        /**
068         * Returns
069         * PID (Patient identification) - creates it if necessary
070         */
071        public PID getPID() { 
072           PID ret = null;
073           try {
074              ret = (PID)this.get("PID");
075           } catch(HL7Exception e) {
076              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
077              throw new RuntimeException(e);
078           }
079           return ret;
080        }
081    
082    
083    
084    
085        /**
086         * Returns
087         * PD1 (patient additional demographic) - creates it if necessary
088         */
089        public PD1 getPD1() { 
090           PD1 ret = null;
091           try {
092              ret = (PD1)this.get("PD1");
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    
103        /**
104         * Returns
105         * PV1 (Patient visit) - creates it if necessary
106         */
107        public PV1 getPV1() { 
108           PV1 ret = null;
109           try {
110              ret = (PV1)this.get("PV1");
111           } catch(HL7Exception e) {
112              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
113              throw new RuntimeException(e);
114           }
115           return ret;
116        }
117    
118    
119    
120    
121        /**
122         * Returns
123         * PV2 (Patient visit - additional information) - creates it if necessary
124         */
125        public PV2 getPV2() { 
126           PV2 ret = null;
127           try {
128              ret = (PV2)this.get("PV2");
129           } catch(HL7Exception e) {
130              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
131              throw new RuntimeException(e);
132           }
133           return ret;
134        }
135    
136    
137    
138    
139        /**
140         * Returns
141         * the first repetition of 
142         * OBX (Observation/Result) - creates it if necessary
143         */
144        public OBX getOBX() { 
145           OBX ret = null;
146           try {
147              ret = (OBX)this.get("OBX");
148           } catch(HL7Exception e) {
149              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
150              throw new RuntimeException(e);
151           }
152           return ret;
153        }
154    
155    
156        /**
157         * Returns a specific repetition of
158         * OBX (Observation/Result) - creates it if necessary
159         *
160         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
161         * @throws HL7Exception if the repetition requested is more than one 
162         *     greater than the number of existing repetitions.
163         */
164        public OBX getOBX(int rep) { 
165           OBX ret = null;
166           try {
167              ret = (OBX)this.get("OBX", rep);
168           } catch(HL7Exception e) {
169              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
170              throw new RuntimeException(e);
171           }
172           return ret;
173        }
174    
175        /** 
176         * Returns the number of existing repetitions of OBX 
177         */ 
178        public int getOBXReps() { 
179            int reps = -1; 
180            try { 
181                reps = this.getAll("OBX").length; 
182            } catch (HL7Exception e) { 
183                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
184                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
185                throw new RuntimeException(message);
186            } 
187            return reps; 
188        } 
189    
190        /**
191         * Inserts a specific repetition of OBX (Observation/Result)
192         * @see AbstractGroup#insertRepetition(Structure, int) 
193         */
194        public void insertOBX(OBX structure, int rep) throws HL7Exception { 
195           super.insertRepetition("OBX", structure, rep);
196        }
197    
198    
199        /**
200         * Inserts a specific repetition of OBX (Observation/Result)
201         * @see AbstractGroup#insertRepetition(Structure, int) 
202         */
203        public OBX insertOBX(int rep) throws HL7Exception { 
204           return (OBX)super.insertRepetition("OBX", rep);
205        }
206    
207    
208        /**
209         * Removes a specific repetition of OBX (Observation/Result)
210         * @see AbstractGroup#removeRepetition(String, int) 
211         */
212        public OBX removeOBX(int rep) throws HL7Exception { 
213           return (OBX)super.removeRepetition("OBX", rep);
214        }
215    
216    
217    
218        /**
219         * Returns
220         * the first repetition of 
221         * DG1 (Diagnosis) - creates it if necessary
222         */
223        public DG1 getDG1() { 
224           DG1 ret = null;
225           try {
226              ret = (DG1)this.get("DG1");
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         * Returns a specific repetition of
237         * DG1 (Diagnosis) - creates it if necessary
238         *
239         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
240         * @throws HL7Exception if the repetition requested is more than one 
241         *     greater than the number of existing repetitions.
242         */
243        public DG1 getDG1(int rep) { 
244           DG1 ret = null;
245           try {
246              ret = (DG1)this.get("DG1", rep);
247           } catch(HL7Exception e) {
248              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
249              throw new RuntimeException(e);
250           }
251           return ret;
252        }
253    
254        /** 
255         * Returns the number of existing repetitions of DG1 
256         */ 
257        public int getDG1Reps() { 
258            int reps = -1; 
259            try { 
260                reps = this.getAll("DG1").length; 
261            } catch (HL7Exception e) { 
262                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
263                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
264                throw new RuntimeException(message);
265            } 
266            return reps; 
267        } 
268    
269        /**
270         * Inserts a specific repetition of DG1 (Diagnosis)
271         * @see AbstractGroup#insertRepetition(Structure, int) 
272         */
273        public void insertDG1(DG1 structure, int rep) throws HL7Exception { 
274           super.insertRepetition("DG1", structure, rep);
275        }
276    
277    
278        /**
279         * Inserts a specific repetition of DG1 (Diagnosis)
280         * @see AbstractGroup#insertRepetition(Structure, int) 
281         */
282        public DG1 insertDG1(int rep) throws HL7Exception { 
283           return (DG1)super.insertRepetition("DG1", rep);
284        }
285    
286    
287        /**
288         * Removes a specific repetition of DG1 (Diagnosis)
289         * @see AbstractGroup#removeRepetition(String, int) 
290         */
291        public DG1 removeDG1(int rep) throws HL7Exception { 
292           return (DG1)super.removeRepetition("DG1", rep);
293        }
294    
295    
296    
297    }
298