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.v231.message;
009    
010    import ca.uhn.hl7v2.model.v231.group.*;
011    import ca.uhn.hl7v2.model.v231.segment.*;
012    
013    import ca.uhn.log.HapiLogFactory;
014    import ca.uhn.hl7v2.HL7Exception;
015    import ca.uhn.hl7v2.parser.ModelClassFactory;
016    import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
017    import ca.uhn.hl7v2.model.AbstractMessage;
018    
019    /**
020     * <p>Represents a SRM_S01 message structure (see chapter ${chapter}). This structure contains the 
021     * following elements: </p>
022     * <ul>
023                     * <li>1: MSH (MSH - message header segment) <b> </b></li>
024                     * <li>2: ARQ (ARQ - appointment request segment) <b> </b></li>
025                     * <li>3: APR (APR - appointment preferences segment) <b>optional </b></li>
026                     * <li>4: NTE (NTE - notes and comments segment) <b>optional repeating</b></li>
027                     * <li>5: SRM_S01_PIDPV1PV2OBXDG1 (a Group object) <b>optional repeating</b></li>
028                     * <li>6: SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE (a Group object) <b> repeating</b></li>
029     * </ul>
030     */
031    public class SRM_S01 extends AbstractMessage  {
032    
033        /**
034         * Creates a new SRM_S01 message with DefaultModelClassFactory. 
035         */ 
036        public SRM_S01() { 
037           this(new DefaultModelClassFactory());
038        }
039    
040        /** 
041         * Creates a new SRM_S01 message with custom ModelClassFactory.
042         */
043        public SRM_S01(ModelClassFactory factory) {
044           super(factory);
045           init(factory);
046        }
047    
048        private void init(ModelClassFactory factory) {
049           try {
050                              this.add(MSH.class, true, false);
051                              this.add(ARQ.class, true, false);
052                              this.add(APR.class, false, false);
053                              this.add(NTE.class, false, true);
054                              this.add(SRM_S01_PIDPV1PV2OBXDG1.class, false, true);
055                              this.add(SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE.class, true, true);
056           } catch(HL7Exception e) {
057              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating SRM_S01 - this is probably a bug in the source code generator.", e);
058           }
059        }
060    
061        /** 
062         * Returns "2.3.1"
063         */
064        public String getVersion() {
065           return "2.3.1";
066        }
067    
068    
069    
070        /**
071         * Returns
072         * MSH (MSH - message header segment) - creates it if necessary
073         */
074        public MSH getMSH() { 
075           MSH ret = null;
076           try {
077              ret = (MSH)this.get("MSH");
078           } catch(HL7Exception e) {
079              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
080              throw new RuntimeException(e);
081           }
082           return ret;
083        }
084    
085    
086    
087    
088        /**
089         * Returns
090         * ARQ (ARQ - appointment request segment) - creates it if necessary
091         */
092        public ARQ getARQ() { 
093           ARQ ret = null;
094           try {
095              ret = (ARQ)this.get("ARQ");
096           } catch(HL7Exception e) {
097              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
098              throw new RuntimeException(e);
099           }
100           return ret;
101        }
102    
103    
104    
105    
106        /**
107         * Returns
108         * APR (APR - appointment preferences segment) - creates it if necessary
109         */
110        public APR getAPR() { 
111           APR ret = null;
112           try {
113              ret = (APR)this.get("APR");
114           } catch(HL7Exception e) {
115              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
116              throw new RuntimeException(e);
117           }
118           return ret;
119        }
120    
121    
122    
123    
124        /**
125         * Returns
126         * the first repetition of 
127         * NTE (NTE - notes and comments segment) - creates it if necessary
128         */
129        public NTE getNTE() { 
130           NTE ret = null;
131           try {
132              ret = (NTE)this.get("NTE");
133           } catch(HL7Exception e) {
134              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
135              throw new RuntimeException(e);
136           }
137           return ret;
138        }
139    
140    
141        /**
142         * Returns a specific repetition of
143         * NTE (NTE - notes and comments segment) - creates it if necessary
144         *
145         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
146         * @throws HL7Exception if the repetition requested is more than one 
147         *     greater than the number of existing repetitions.
148         */
149        public NTE getNTE(int rep) { 
150           NTE ret = null;
151           try {
152              ret = (NTE)this.get("NTE", rep);
153           } catch(HL7Exception e) {
154              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
155              throw new RuntimeException(e);
156           }
157           return ret;
158        }
159    
160        /** 
161         * Returns the number of existing repetitions of NTE 
162         */ 
163        public int getNTEReps() { 
164            int reps = -1; 
165            try { 
166                reps = this.getAll("NTE").length; 
167            } catch (HL7Exception e) { 
168                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
169                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
170                throw new RuntimeException(message);
171            } 
172            return reps; 
173        } 
174    
175        /**
176         * Inserts a specific repetition of NTE (NTE - notes and comments segment)
177         * @see AbstractGroup\#insertRepetition(Structure, int) 
178         */
179        public void insertNTE(NTE structure, int rep) throws HL7Exception { 
180           super.insertRepetition( "NTE", structure, rep);
181        }
182    
183    
184        /**
185         * Inserts a specific repetition of NTE (NTE - notes and comments segment)
186         * @see AbstractGroup\#insertRepetition(Structure, int) 
187         */
188        public NTE insertNTE(int rep) throws HL7Exception { 
189           return (NTE)super.insertRepetition("NTE", rep);
190        }
191    
192    
193        /**
194         * Removes a specific repetition of NTE (NTE - notes and comments segment)
195         * @see AbstractGroup\#removeRepetition(String, int) 
196         */
197        public NTE removeNTE(int rep) throws HL7Exception { 
198           return (NTE)super.removeRepetition("NTE", rep);
199        }
200    
201    
202    
203        /**
204         * Returns
205         * the first repetition of 
206         * PIDPV1PV2OBXDG1 (a Group object) - creates it if necessary
207         */
208        public SRM_S01_PIDPV1PV2OBXDG1 getPIDPV1PV2OBXDG1() { 
209           SRM_S01_PIDPV1PV2OBXDG1 ret = null;
210           try {
211              ret = (SRM_S01_PIDPV1PV2OBXDG1)this.get("PIDPV1PV2OBXDG1");
212           } catch(HL7Exception e) {
213              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
214              throw new RuntimeException(e);
215           }
216           return ret;
217        }
218    
219    
220        /**
221         * Returns a specific repetition of
222         * PIDPV1PV2OBXDG1 (a Group object) - creates it if necessary
223         *
224         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
225         * @throws HL7Exception if the repetition requested is more than one 
226         *     greater than the number of existing repetitions.
227         */
228        public SRM_S01_PIDPV1PV2OBXDG1 getPIDPV1PV2OBXDG1(int rep) { 
229           SRM_S01_PIDPV1PV2OBXDG1 ret = null;
230           try {
231              ret = (SRM_S01_PIDPV1PV2OBXDG1)this.get("PIDPV1PV2OBXDG1", rep);
232           } catch(HL7Exception e) {
233              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
234              throw new RuntimeException(e);
235           }
236           return ret;
237        }
238    
239        /** 
240         * Returns the number of existing repetitions of PIDPV1PV2OBXDG1 
241         */ 
242        public int getPIDPV1PV2OBXDG1Reps() { 
243            int reps = -1; 
244            try { 
245                reps = this.getAll("PIDPV1PV2OBXDG1").length; 
246            } catch (HL7Exception e) { 
247                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
248                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
249                throw new RuntimeException(message);
250            } 
251            return reps; 
252        } 
253    
254        /**
255         * Inserts a specific repetition of PIDPV1PV2OBXDG1 (a Group object)
256         * @see AbstractGroup\#insertRepetition(Structure, int) 
257         */
258        public void insertPIDPV1PV2OBXDG1(SRM_S01_PIDPV1PV2OBXDG1 structure, int rep) throws HL7Exception { 
259           super.insertRepetition( "PIDPV1PV2OBXDG1", structure, rep);
260        }
261    
262    
263        /**
264         * Inserts a specific repetition of PIDPV1PV2OBXDG1 (a Group object)
265         * @see AbstractGroup\#insertRepetition(Structure, int) 
266         */
267        public SRM_S01_PIDPV1PV2OBXDG1 insertPIDPV1PV2OBXDG1(int rep) throws HL7Exception { 
268           return (SRM_S01_PIDPV1PV2OBXDG1)super.insertRepetition("PIDPV1PV2OBXDG1", rep);
269        }
270    
271    
272        /**
273         * Removes a specific repetition of PIDPV1PV2OBXDG1 (a Group object)
274         * @see AbstractGroup\#removeRepetition(String, int) 
275         */
276        public SRM_S01_PIDPV1PV2OBXDG1 removePIDPV1PV2OBXDG1(int rep) throws HL7Exception { 
277           return (SRM_S01_PIDPV1PV2OBXDG1)super.removeRepetition("PIDPV1PV2OBXDG1", rep);
278        }
279    
280    
281    
282        /**
283         * Returns
284         * the first repetition of 
285         * RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE (a Group object) - creates it if necessary
286         */
287        public SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE getRGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE() { 
288           SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE ret = null;
289           try {
290              ret = (SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE)this.get("RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE");
291           } catch(HL7Exception e) {
292              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
293              throw new RuntimeException(e);
294           }
295           return ret;
296        }
297    
298    
299        /**
300         * Returns a specific repetition of
301         * RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE (a Group object) - creates it if necessary
302         *
303         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
304         * @throws HL7Exception if the repetition requested is more than one 
305         *     greater than the number of existing repetitions.
306         */
307        public SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE getRGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE(int rep) { 
308           SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE ret = null;
309           try {
310              ret = (SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE)this.get("RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE", rep);
311           } catch(HL7Exception e) {
312              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
313              throw new RuntimeException(e);
314           }
315           return ret;
316        }
317    
318        /** 
319         * Returns the number of existing repetitions of RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE 
320         */ 
321        public int getRGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTEReps() { 
322            int reps = -1; 
323            try { 
324                reps = this.getAll("RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE").length; 
325            } catch (HL7Exception e) { 
326                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
327                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
328                throw new RuntimeException(message);
329            } 
330            return reps; 
331        } 
332    
333        /**
334         * Inserts a specific repetition of RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE (a Group object)
335         * @see AbstractGroup\#insertRepetition(Structure, int) 
336         */
337        public void insertRGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE(SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE structure, int rep) throws HL7Exception { 
338           super.insertRepetition( "RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE", structure, rep);
339        }
340    
341    
342        /**
343         * Inserts a specific repetition of RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE (a Group object)
344         * @see AbstractGroup\#insertRepetition(Structure, int) 
345         */
346        public SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE insertRGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE(int rep) throws HL7Exception { 
347           return (SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE)super.insertRepetition("RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE", rep);
348        }
349    
350    
351        /**
352         * Removes a specific repetition of RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE (a Group object)
353         * @see AbstractGroup\#removeRepetition(String, int) 
354         */
355        public SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE removeRGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE(int rep) throws HL7Exception { 
356           return (SRM_S01_RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE)super.removeRepetition("RGSAISAPRNTEAIGAPRNTEAILAPRNTEAIPAPRNTE", rep);
357        }
358    
359    
360    
361    }
362