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.segment;
009    
010    // import ca.uhn.hl7v2.model.v24.group.*;
011    import ca.uhn.hl7v2.model.v24.datatype.*;
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.Type;
019    import ca.uhn.hl7v2.model.AbstractSegment;
020    import ca.uhn.hl7v2.model.Varies;
021    
022    /**
023     *<p>Represents an HL7 RCP message segment (Response Control Parameter). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>RCP-1: Query Priority (ID) <b>optional </b>
027         * <li>RCP-2: Quantity Limited Request (CQ) <b>optional </b>
028         * <li>RCP-3: Response Modality (CE) <b>optional </b>
029         * <li>RCP-4: Execution and Delivery Time (TS) <b>optional </b>
030         * <li>RCP-5: Modify Indicator (ID) <b>optional </b>
031         * <li>RCP-6: Sort-by Field (SRT) <b>optional repeating</b>
032         * <li>RCP-7: Segment group inclusion (ID) <b>optional repeating</b>
033     * </ul>
034     */
035    public class RCP extends AbstractSegment {
036    
037        /** 
038         * Creates a new RCP segment
039         */
040        public RCP(Group parent, ModelClassFactory factory) {
041           super(parent, factory);
042           init(factory);
043        }
044    
045        private void init(ModelClassFactory factory) {
046           try {
047                                      this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Query Priority");
048                                      this.add(CQ.class, false, 1, 10, new Object[]{ getMessage(), new Integer(126) }, "Quantity Limited Request");
049                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(394) }, "Response Modality");
050                                      this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Execution and Delivery Time");
051                                      this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Modify Indicator");
052                                      this.add(SRT.class, false, 0, 512, new Object[]{ getMessage(), new Integer(0) }, "Sort-by Field");
053                                      this.add(ID.class, false, 0, 256, new Object[]{ getMessage() }, "Segment group inclusion");
054           } catch(HL7Exception e) {
055              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating RCP - this is probably a bug in the source code generator.", e);
056           }
057        }
058    
059    
060    
061        /**
062         * Returns
063         * RCP-1: "Query Priority" - creates it if necessary
064         */
065        public ID getQueryPriority() { 
066            ID ret = null;
067            try {
068                Type t = this.getField(1, 0);
069                ret = (ID)t;
070            } catch (ClassCastException cce) {
071                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
072                throw new RuntimeException(cce);
073            } catch (HL7Exception he) {
074                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
075                throw new RuntimeException(he);
076            }
077            return ret;
078        }
079    
080    
081        /**
082         * Returns
083         * RCP-1: "Query Priority" - creates it if necessary
084         */
085        public ID getRcp1_QueryPriority() { 
086            ID ret = null;
087            try {
088                Type t = this.getField(1, 0);
089                ret = (ID)t;
090            } catch (ClassCastException cce) {
091                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
092                throw new RuntimeException(cce);
093            } catch (HL7Exception he) {
094                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
095                throw new RuntimeException(he);
096            }
097            return ret;
098        }
099    
100    
101    
102        /**
103         * Returns
104         * RCP-2: "Quantity Limited Request" - creates it if necessary
105         */
106        public CQ getQuantityLimitedRequest() { 
107            CQ ret = null;
108            try {
109                Type t = this.getField(2, 0);
110                ret = (CQ)t;
111            } catch (ClassCastException cce) {
112                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
113                throw new RuntimeException(cce);
114            } catch (HL7Exception he) {
115                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
116                throw new RuntimeException(he);
117            }
118            return ret;
119        }
120    
121    
122        /**
123         * Returns
124         * RCP-2: "Quantity Limited Request" - creates it if necessary
125         */
126        public CQ getRcp2_QuantityLimitedRequest() { 
127            CQ ret = null;
128            try {
129                Type t = this.getField(2, 0);
130                ret = (CQ)t;
131            } catch (ClassCastException cce) {
132                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
133                throw new RuntimeException(cce);
134            } catch (HL7Exception he) {
135                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
136                throw new RuntimeException(he);
137            }
138            return ret;
139        }
140    
141    
142    
143        /**
144         * Returns
145         * RCP-3: "Response Modality" - creates it if necessary
146         */
147        public CE getResponseModality() { 
148            CE ret = null;
149            try {
150                Type t = this.getField(3, 0);
151                ret = (CE)t;
152            } catch (ClassCastException cce) {
153                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
154                throw new RuntimeException(cce);
155            } catch (HL7Exception he) {
156                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
157                throw new RuntimeException(he);
158            }
159            return ret;
160        }
161    
162    
163        /**
164         * Returns
165         * RCP-3: "Response Modality" - creates it if necessary
166         */
167        public CE getRcp3_ResponseModality() { 
168            CE ret = null;
169            try {
170                Type t = this.getField(3, 0);
171                ret = (CE)t;
172            } catch (ClassCastException cce) {
173                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
174                throw new RuntimeException(cce);
175            } catch (HL7Exception he) {
176                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
177                throw new RuntimeException(he);
178            }
179            return ret;
180        }
181    
182    
183    
184        /**
185         * Returns
186         * RCP-4: "Execution and Delivery Time" - creates it if necessary
187         */
188        public TS getExecutionAndDeliveryTime() { 
189            TS ret = null;
190            try {
191                Type t = this.getField(4, 0);
192                ret = (TS)t;
193            } catch (ClassCastException cce) {
194                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
195                throw new RuntimeException(cce);
196            } catch (HL7Exception he) {
197                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
198                throw new RuntimeException(he);
199            }
200            return ret;
201        }
202    
203    
204        /**
205         * Returns
206         * RCP-4: "Execution and Delivery Time" - creates it if necessary
207         */
208        public TS getRcp4_ExecutionAndDeliveryTime() { 
209            TS ret = null;
210            try {
211                Type t = this.getField(4, 0);
212                ret = (TS)t;
213            } catch (ClassCastException cce) {
214                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
215                throw new RuntimeException(cce);
216            } catch (HL7Exception he) {
217                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
218                throw new RuntimeException(he);
219            }
220            return ret;
221        }
222    
223    
224    
225        /**
226         * Returns
227         * RCP-5: "Modify Indicator" - creates it if necessary
228         */
229        public ID getModifyIndicator() { 
230            ID ret = null;
231            try {
232                Type t = this.getField(5, 0);
233                ret = (ID)t;
234            } catch (ClassCastException cce) {
235                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
236                throw new RuntimeException(cce);
237            } catch (HL7Exception he) {
238                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
239                throw new RuntimeException(he);
240            }
241            return ret;
242        }
243    
244    
245        /**
246         * Returns
247         * RCP-5: "Modify Indicator" - creates it if necessary
248         */
249        public ID getRcp5_ModifyIndicator() { 
250            ID ret = null;
251            try {
252                Type t = this.getField(5, 0);
253                ret = (ID)t;
254            } catch (ClassCastException cce) {
255                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
256                throw new RuntimeException(cce);
257            } catch (HL7Exception he) {
258                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
259                throw new RuntimeException(he);
260            }
261            return ret;
262        }
263    
264    
265        /**
266         * Returns all repetitions of Sort-by Field (RCP-6).
267         */
268        public SRT[] getSortByField() {
269            SRT[] ret = null;
270            try {
271                Type[] t = this.getField(6);  
272                ret = new SRT[t.length];
273                for (int i = 0; i < ret.length; i++) {
274                    ret[i] = (SRT)t[i];
275                }
276            } catch (ClassCastException cce) {
277                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
278                throw new RuntimeException(cce);
279            } catch (HL7Exception he) {
280                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
281                throw new RuntimeException(he);
282            }
283            return ret;
284        }
285    
286    
287        /**
288         * Returns a count of the current number of repetitions of Sort-by Field (RCP-6).
289         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
290         * it will return zero.
291         */
292        public int getSortByFieldReps() {
293            SRT[] ret = null;
294            try {
295                Type[] t = this.getField(6);
296                return t.length;  
297            } catch (ClassCastException cce) {
298                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
299                throw new RuntimeException(cce);
300            } catch (HL7Exception he) {
301                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
302                throw new RuntimeException(he);
303            }
304        }
305    
306    
307        /**
308         * Returns a specific repetition of
309         * RCP-6: "Sort-by Field" - creates it if necessary
310         *
311         * @param rep The repetition index (0-indexed)
312         */
313        public SRT getSortByField(int rep) { 
314            SRT ret = null;
315            try {
316                Type t = this.getField(6, rep);
317                ret = (SRT)t;
318            } catch (ClassCastException cce) {
319                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
320                throw new RuntimeException(cce);
321            } catch (HL7Exception he) {
322                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
323                throw new RuntimeException(he);
324            }
325            return ret;
326        }
327    
328        /**
329         * Returns a specific repetition of
330         * RCP-6: "Sort-by Field" - creates it if necessary
331         *
332         * @param rep The repetition index (0-indexed)
333         */
334        public SRT getRcp6_SortByField(int rep) { 
335            SRT ret = null;
336            try {
337                Type t = this.getField(6, rep);
338                ret = (SRT)t;
339            } catch (ClassCastException cce) {
340                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
341                throw new RuntimeException(cce);
342            } catch (HL7Exception he) {
343                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
344                throw new RuntimeException(he);
345            }
346            return ret;
347        }
348    
349    
350        /**
351         * Returns a count of the current number of repetitions of Sort-by Field (RCP-6).
352         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
353         * it will return zero.
354         */
355        public int getRcp6_SortByFieldReps() {
356            SRT[] ret = null;
357            try {
358                Type[] t = this.getField(6);
359                return t.length;  
360            } catch (ClassCastException cce) {
361                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
362                throw new RuntimeException(cce);
363            } catch (HL7Exception he) {
364                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
365                throw new RuntimeException(he);
366            }
367        }
368    
369    
370    
371        /**
372         * Inserts a repetition of
373         * RCP-6: "Sort-by Field" at a specific index
374         *
375         * @param rep The repetition index (0-indexed)
376         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
377         */
378        public SRT insertSortByField(int rep) throws HL7Exception { 
379            return (SRT) super.insertRepetition(6, rep);
380        }
381    
382    
383    
384        /**
385         * Inserts a repetition of
386         * RCP-6: "Sort-by Field" at a specific index
387         *
388         * @param rep The repetition index (0-indexed)
389         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
390         */
391        public SRT insertRcp6_SortByField(int rep) throws HL7Exception { 
392            return (SRT) super.insertRepetition(6, rep);
393        }
394    
395    
396        /**
397         * Removes a repetition of
398         * RCP-6: "Sort-by Field" at a specific index
399         *
400         * @param rep The repetition index (0-indexed)
401         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
402         */
403        public SRT removeSortByField(int rep) throws HL7Exception { 
404            return (SRT) super.removeRepetition(6, rep);
405        }
406    
407    
408        /**
409         * Removes a repetition of
410         * RCP-6: "Sort-by Field" at a specific index
411         *
412         * @param rep The repetition index (0-indexed)
413         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
414         */
415        public SRT removeRcp6_SortByField(int rep) throws HL7Exception { 
416            return (SRT) super.removeRepetition(6, rep);
417        }
418    
419    
420    
421        /**
422         * Returns all repetitions of Segment group inclusion (RCP-7).
423         */
424        public ID[] getSegmentGroupInclusion() {
425            ID[] ret = null;
426            try {
427                Type[] t = this.getField(7);  
428                ret = new ID[t.length];
429                for (int i = 0; i < ret.length; i++) {
430                    ret[i] = (ID)t[i];
431                }
432            } catch (ClassCastException cce) {
433                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
434                throw new RuntimeException(cce);
435            } catch (HL7Exception he) {
436                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
437                throw new RuntimeException(he);
438            }
439            return ret;
440        }
441    
442    
443        /**
444         * Returns a count of the current number of repetitions of Segment group inclusion (RCP-7).
445         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
446         * it will return zero.
447         */
448        public int getSegmentGroupInclusionReps() {
449            ID[] ret = null;
450            try {
451                Type[] t = this.getField(7);
452                return t.length;  
453            } catch (ClassCastException cce) {
454                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
455                throw new RuntimeException(cce);
456            } catch (HL7Exception he) {
457                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
458                throw new RuntimeException(he);
459            }
460        }
461    
462    
463        /**
464         * Returns a specific repetition of
465         * RCP-7: "Segment group inclusion" - creates it if necessary
466         *
467         * @param rep The repetition index (0-indexed)
468         */
469        public ID getSegmentGroupInclusion(int rep) { 
470            ID ret = null;
471            try {
472                Type t = this.getField(7, rep);
473                ret = (ID)t;
474            } catch (ClassCastException cce) {
475                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
476                throw new RuntimeException(cce);
477            } catch (HL7Exception he) {
478                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
479                throw new RuntimeException(he);
480            }
481            return ret;
482        }
483    
484        /**
485         * Returns a specific repetition of
486         * RCP-7: "Segment group inclusion" - creates it if necessary
487         *
488         * @param rep The repetition index (0-indexed)
489         */
490        public ID getRcp7_SegmentGroupInclusion(int rep) { 
491            ID ret = null;
492            try {
493                Type t = this.getField(7, rep);
494                ret = (ID)t;
495            } catch (ClassCastException cce) {
496                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
497                throw new RuntimeException(cce);
498            } catch (HL7Exception he) {
499                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
500                throw new RuntimeException(he);
501            }
502            return ret;
503        }
504    
505    
506        /**
507         * Returns a count of the current number of repetitions of Segment group inclusion (RCP-7).
508         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
509         * it will return zero.
510         */
511        public int getRcp7_SegmentGroupInclusionReps() {
512            ID[] ret = null;
513            try {
514                Type[] t = this.getField(7);
515                return t.length;  
516            } catch (ClassCastException cce) {
517                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
518                throw new RuntimeException(cce);
519            } catch (HL7Exception he) {
520                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
521                throw new RuntimeException(he);
522            }
523        }
524    
525    
526    
527        /**
528         * Inserts a repetition of
529         * RCP-7: "Segment group inclusion" at a specific index
530         *
531         * @param rep The repetition index (0-indexed)
532         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
533         */
534        public ID insertSegmentGroupInclusion(int rep) throws HL7Exception { 
535            return (ID) super.insertRepetition(7, rep);
536        }
537    
538    
539    
540        /**
541         * Inserts a repetition of
542         * RCP-7: "Segment group inclusion" at a specific index
543         *
544         * @param rep The repetition index (0-indexed)
545         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
546         */
547        public ID insertRcp7_SegmentGroupInclusion(int rep) throws HL7Exception { 
548            return (ID) super.insertRepetition(7, rep);
549        }
550    
551    
552        /**
553         * Removes a repetition of
554         * RCP-7: "Segment group inclusion" at a specific index
555         *
556         * @param rep The repetition index (0-indexed)
557         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
558         */
559        public ID removeSegmentGroupInclusion(int rep) throws HL7Exception { 
560            return (ID) super.removeRepetition(7, rep);
561        }
562    
563    
564        /**
565         * Removes a repetition of
566         * RCP-7: "Segment group inclusion" at a specific index
567         *
568         * @param rep The repetition index (0-indexed)
569         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
570         */
571        public ID removeRcp7_SegmentGroupInclusion(int rep) throws HL7Exception { 
572            return (ID) super.removeRepetition(7, rep);
573        }
574    
575    
576    
577    
578    
579    
580        /** {@inheritDoc} */   
581        protected Type createNewTypeWithoutReflection(int field) {
582           switch (field) {
583              case 0: return new ID(getMessage(), new Integer( 91 ));
584              case 1: return new CQ(getMessage());
585              case 2: return new CE(getMessage());
586              case 3: return new TS(getMessage());
587              case 4: return new ID(getMessage(), new Integer( 395 ));
588              case 5: return new SRT(getMessage());
589              case 6: return new ID(getMessage(), new Integer( 0 ));
590              default: return null;
591           }
592       }
593    
594    
595    }
596