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 CSU_C09_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: NTE (Notes and Comments) <b>optional repeating</b></li>
030                     * <li>4: CSU_C09_VISIT (a Group object) <b>optional </b></li>
031                     * <li>5: CSR (Clinical Study Registration) <b> </b></li>
032                     * <li>6: CSU_C09_STUDY_PHASE (a Group object) <b> repeating</b></li>
033     * </ul>
034     */
035    public class CSU_C09_PATIENT extends AbstractGroup {
036    
037        /** 
038         * Creates a new CSU_C09_PATIENT group
039         */
040        public CSU_C09_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(NTE.class, false, true);
050                              this.add(CSU_C09_VISIT.class, false, false);
051                              this.add(CSR.class, true, false);
052                              this.add(CSU_C09_STUDY_PHASE.class, true, true);
053           } catch(HL7Exception e) {
054              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating CSU_C09_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         * the first repetition of 
106         * NTE (Notes and Comments) - creates it if necessary
107         */
108        public NTE getNTE() { 
109           NTE ret = null;
110           try {
111              ret = (NTE)this.get("NTE");
112           } catch(HL7Exception e) {
113              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
114              throw new RuntimeException(e);
115           }
116           return ret;
117        }
118    
119    
120        /**
121         * Returns a specific repetition of
122         * NTE (Notes and Comments) - creates it if necessary
123         *
124         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
125         * @throws HL7Exception if the repetition requested is more than one 
126         *     greater than the number of existing repetitions.
127         */
128        public NTE getNTE(int rep) { 
129           NTE ret = null;
130           try {
131              ret = (NTE)this.get("NTE", rep);
132           } catch(HL7Exception e) {
133              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
134              throw new RuntimeException(e);
135           }
136           return ret;
137        }
138    
139        /** 
140         * Returns the number of existing repetitions of NTE 
141         */ 
142        public int getNTEReps() { 
143            int reps = -1; 
144            try { 
145                reps = this.getAll("NTE").length; 
146            } catch (HL7Exception e) { 
147                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
148                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
149                throw new RuntimeException(message);
150            } 
151            return reps; 
152        } 
153    
154        /**
155         * Inserts a specific repetition of NTE (Notes and Comments)
156         * @see AbstractGroup#insertRepetition(Structure, int) 
157         */
158        public void insertNTE(NTE structure, int rep) throws HL7Exception { 
159           super.insertRepetition("NTE", structure, rep);
160        }
161    
162    
163        /**
164         * Inserts a specific repetition of NTE (Notes and Comments)
165         * @see AbstractGroup#insertRepetition(Structure, int) 
166         */
167        public NTE insertNTE(int rep) throws HL7Exception { 
168           return (NTE)super.insertRepetition("NTE", rep);
169        }
170    
171    
172        /**
173         * Removes a specific repetition of NTE (Notes and Comments)
174         * @see AbstractGroup#removeRepetition(String, int) 
175         */
176        public NTE removeNTE(int rep) throws HL7Exception { 
177           return (NTE)super.removeRepetition("NTE", rep);
178        }
179    
180    
181    
182        /**
183         * Returns
184         * VISIT (a Group object) - creates it if necessary
185         */
186        public CSU_C09_VISIT getVISIT() { 
187           CSU_C09_VISIT ret = null;
188           try {
189              ret = (CSU_C09_VISIT)this.get("VISIT");
190           } catch(HL7Exception e) {
191              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
192              throw new RuntimeException(e);
193           }
194           return ret;
195        }
196    
197    
198    
199    
200        /**
201         * Returns
202         * CSR (Clinical Study Registration) - creates it if necessary
203         */
204        public CSR getCSR() { 
205           CSR ret = null;
206           try {
207              ret = (CSR)this.get("CSR");
208           } catch(HL7Exception e) {
209              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
210              throw new RuntimeException(e);
211           }
212           return ret;
213        }
214    
215    
216    
217    
218        /**
219         * Returns
220         * the first repetition of 
221         * STUDY_PHASE (a Group object) - creates it if necessary
222         */
223        public CSU_C09_STUDY_PHASE getSTUDY_PHASE() { 
224           CSU_C09_STUDY_PHASE ret = null;
225           try {
226              ret = (CSU_C09_STUDY_PHASE)this.get("STUDY_PHASE");
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         * STUDY_PHASE (a Group object) - 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 CSU_C09_STUDY_PHASE getSTUDY_PHASE(int rep) { 
244           CSU_C09_STUDY_PHASE ret = null;
245           try {
246              ret = (CSU_C09_STUDY_PHASE)this.get("STUDY_PHASE", 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 STUDY_PHASE 
256         */ 
257        public int getSTUDY_PHASEReps() { 
258            int reps = -1; 
259            try { 
260                reps = this.getAll("STUDY_PHASE").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 STUDY_PHASE (a Group object)
271         * @see AbstractGroup#insertRepetition(Structure, int) 
272         */
273        public void insertSTUDY_PHASE(CSU_C09_STUDY_PHASE structure, int rep) throws HL7Exception { 
274           super.insertRepetition("STUDY_PHASE", structure, rep);
275        }
276    
277    
278        /**
279         * Inserts a specific repetition of STUDY_PHASE (a Group object)
280         * @see AbstractGroup#insertRepetition(Structure, int) 
281         */
282        public CSU_C09_STUDY_PHASE insertSTUDY_PHASE(int rep) throws HL7Exception { 
283           return (CSU_C09_STUDY_PHASE)super.insertRepetition("STUDY_PHASE", rep);
284        }
285    
286    
287        /**
288         * Removes a specific repetition of STUDY_PHASE (a Group object)
289         * @see AbstractGroup#removeRepetition(String, int) 
290         */
291        public CSU_C09_STUDY_PHASE removeSTUDY_PHASE(int rep) throws HL7Exception { 
292           return (CSU_C09_STUDY_PHASE)super.removeRepetition("STUDY_PHASE", rep);
293        }
294    
295    
296    
297    }
298