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 RF1 message segment (Referral Information). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>RF1-1: Referral Status (CE) <b>optional </b>
027         * <li>RF1-2: Referral Priority (CE) <b>optional </b>
028         * <li>RF1-3: Referral Type (CE) <b>optional </b>
029         * <li>RF1-4: Referral Disposition (CE) <b>optional repeating</b>
030         * <li>RF1-5: Referral Category (CE) <b>optional </b>
031         * <li>RF1-6: Originating Referral Identifier (EI) <b> </b>
032         * <li>RF1-7: Effective Date (TS) <b>optional </b>
033         * <li>RF1-8: Expiration Date (TS) <b>optional </b>
034         * <li>RF1-9: Process Date (TS) <b>optional </b>
035         * <li>RF1-10: Referral Reason (CE) <b>optional repeating</b>
036         * <li>RF1-11: External Referral Identifier (EI) <b>optional repeating</b>
037     * </ul>
038     */
039    public class RF1 extends AbstractSegment {
040    
041        /** 
042         * Creates a new RF1 segment
043         */
044        public RF1(Group parent, ModelClassFactory factory) {
045           super(parent, factory);
046           init(factory);
047        }
048    
049        private void init(ModelClassFactory factory) {
050           try {
051                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(283) }, "Referral Status");
052                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(280) }, "Referral Priority");
053                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(281) }, "Referral Type");
054                                      this.add(CE.class, false, 0, 250, new Object[]{ getMessage(), new Integer(282) }, "Referral Disposition");
055                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(284) }, "Referral Category");
056                                      this.add(EI.class, true, 1, 30, new Object[]{ getMessage(), new Integer(0) }, "Originating Referral Identifier");
057                                      this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Effective Date");
058                                      this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Expiration Date");
059                                      this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Process Date");
060                                      this.add(CE.class, false, 0, 250, new Object[]{ getMessage(), new Integer(336) }, "Referral Reason");
061                                      this.add(EI.class, false, 0, 30, new Object[]{ getMessage(), new Integer(0) }, "External Referral Identifier");
062           } catch(HL7Exception e) {
063              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating RF1 - this is probably a bug in the source code generator.", e);
064           }
065        }
066    
067    
068    
069        /**
070         * Returns
071         * RF1-1: "Referral Status" - creates it if necessary
072         */
073        public CE getReferralStatus() { 
074            CE ret = null;
075            try {
076                Type t = this.getField(1, 0);
077                ret = (CE)t;
078            } catch (ClassCastException cce) {
079                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
080                throw new RuntimeException(cce);
081            } catch (HL7Exception he) {
082                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
083                throw new RuntimeException(he);
084            }
085            return ret;
086        }
087    
088    
089        /**
090         * Returns
091         * RF1-1: "Referral Status" - creates it if necessary
092         */
093        public CE getRf11_ReferralStatus() { 
094            CE ret = null;
095            try {
096                Type t = this.getField(1, 0);
097                ret = (CE)t;
098            } catch (ClassCastException cce) {
099                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
100                throw new RuntimeException(cce);
101            } catch (HL7Exception he) {
102                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
103                throw new RuntimeException(he);
104            }
105            return ret;
106        }
107    
108    
109    
110        /**
111         * Returns
112         * RF1-2: "Referral Priority" - creates it if necessary
113         */
114        public CE getReferralPriority() { 
115            CE ret = null;
116            try {
117                Type t = this.getField(2, 0);
118                ret = (CE)t;
119            } catch (ClassCastException cce) {
120                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
121                throw new RuntimeException(cce);
122            } catch (HL7Exception he) {
123                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
124                throw new RuntimeException(he);
125            }
126            return ret;
127        }
128    
129    
130        /**
131         * Returns
132         * RF1-2: "Referral Priority" - creates it if necessary
133         */
134        public CE getRf12_ReferralPriority() { 
135            CE ret = null;
136            try {
137                Type t = this.getField(2, 0);
138                ret = (CE)t;
139            } catch (ClassCastException cce) {
140                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
141                throw new RuntimeException(cce);
142            } catch (HL7Exception he) {
143                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
144                throw new RuntimeException(he);
145            }
146            return ret;
147        }
148    
149    
150    
151        /**
152         * Returns
153         * RF1-3: "Referral Type" - creates it if necessary
154         */
155        public CE getReferralType() { 
156            CE ret = null;
157            try {
158                Type t = this.getField(3, 0);
159                ret = (CE)t;
160            } catch (ClassCastException cce) {
161                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
162                throw new RuntimeException(cce);
163            } catch (HL7Exception he) {
164                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
165                throw new RuntimeException(he);
166            }
167            return ret;
168        }
169    
170    
171        /**
172         * Returns
173         * RF1-3: "Referral Type" - creates it if necessary
174         */
175        public CE getRf13_ReferralType() { 
176            CE ret = null;
177            try {
178                Type t = this.getField(3, 0);
179                ret = (CE)t;
180            } catch (ClassCastException cce) {
181                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
182                throw new RuntimeException(cce);
183            } catch (HL7Exception he) {
184                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
185                throw new RuntimeException(he);
186            }
187            return ret;
188        }
189    
190    
191        /**
192         * Returns all repetitions of Referral Disposition (RF1-4).
193         */
194        public CE[] getReferralDisposition() {
195            CE[] ret = null;
196            try {
197                Type[] t = this.getField(4);  
198                ret = new CE[t.length];
199                for (int i = 0; i < ret.length; i++) {
200                    ret[i] = (CE)t[i];
201                }
202            } catch (ClassCastException cce) {
203                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
204                throw new RuntimeException(cce);
205            } catch (HL7Exception he) {
206                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
207                throw new RuntimeException(he);
208            }
209            return ret;
210        }
211    
212    
213        /**
214         * Returns a count of the current number of repetitions of Referral Disposition (RF1-4).
215         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
216         * it will return zero.
217         */
218        public int getReferralDispositionReps() {
219            CE[] ret = null;
220            try {
221                Type[] t = this.getField(4);
222                return t.length;  
223            } catch (ClassCastException cce) {
224                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
225                throw new RuntimeException(cce);
226            } catch (HL7Exception he) {
227                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
228                throw new RuntimeException(he);
229            }
230        }
231    
232    
233        /**
234         * Returns a specific repetition of
235         * RF1-4: "Referral Disposition" - creates it if necessary
236         *
237         * @param rep The repetition index (0-indexed)
238         */
239        public CE getReferralDisposition(int rep) { 
240            CE ret = null;
241            try {
242                Type t = this.getField(4, rep);
243                ret = (CE)t;
244            } catch (ClassCastException cce) {
245                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
246                throw new RuntimeException(cce);
247            } catch (HL7Exception he) {
248                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
249                throw new RuntimeException(he);
250            }
251            return ret;
252        }
253    
254        /**
255         * Returns a specific repetition of
256         * RF1-4: "Referral Disposition" - creates it if necessary
257         *
258         * @param rep The repetition index (0-indexed)
259         */
260        public CE getRf14_ReferralDisposition(int rep) { 
261            CE ret = null;
262            try {
263                Type t = this.getField(4, rep);
264                ret = (CE)t;
265            } catch (ClassCastException cce) {
266                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
267                throw new RuntimeException(cce);
268            } catch (HL7Exception he) {
269                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
270                throw new RuntimeException(he);
271            }
272            return ret;
273        }
274    
275    
276        /**
277         * Returns a count of the current number of repetitions of Referral Disposition (RF1-4).
278         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
279         * it will return zero.
280         */
281        public int getRf14_ReferralDispositionReps() {
282            CE[] ret = null;
283            try {
284                Type[] t = this.getField(4);
285                return t.length;  
286            } catch (ClassCastException cce) {
287                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
288                throw new RuntimeException(cce);
289            } catch (HL7Exception he) {
290                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
291                throw new RuntimeException(he);
292            }
293        }
294    
295    
296    
297        /**
298         * Inserts a repetition of
299         * RF1-4: "Referral Disposition" at a specific index
300         *
301         * @param rep The repetition index (0-indexed)
302         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
303         */
304        public CE insertReferralDisposition(int rep) throws HL7Exception { 
305            return (CE) super.insertRepetition(4, rep);
306        }
307    
308    
309    
310        /**
311         * Inserts a repetition of
312         * RF1-4: "Referral Disposition" at a specific index
313         *
314         * @param rep The repetition index (0-indexed)
315         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
316         */
317        public CE insertRf14_ReferralDisposition(int rep) throws HL7Exception { 
318            return (CE) super.insertRepetition(4, rep);
319        }
320    
321    
322        /**
323         * Removes a repetition of
324         * RF1-4: "Referral Disposition" at a specific index
325         *
326         * @param rep The repetition index (0-indexed)
327         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
328         */
329        public CE removeReferralDisposition(int rep) throws HL7Exception { 
330            return (CE) super.removeRepetition(4, rep);
331        }
332    
333    
334        /**
335         * Removes a repetition of
336         * RF1-4: "Referral Disposition" at a specific index
337         *
338         * @param rep The repetition index (0-indexed)
339         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
340         */
341        public CE removeRf14_ReferralDisposition(int rep) throws HL7Exception { 
342            return (CE) super.removeRepetition(4, rep);
343        }
344    
345    
346    
347    
348        /**
349         * Returns
350         * RF1-5: "Referral Category" - creates it if necessary
351         */
352        public CE getReferralCategory() { 
353            CE ret = null;
354            try {
355                Type t = this.getField(5, 0);
356                ret = (CE)t;
357            } catch (ClassCastException cce) {
358                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
359                throw new RuntimeException(cce);
360            } catch (HL7Exception he) {
361                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
362                throw new RuntimeException(he);
363            }
364            return ret;
365        }
366    
367    
368        /**
369         * Returns
370         * RF1-5: "Referral Category" - creates it if necessary
371         */
372        public CE getRf15_ReferralCategory() { 
373            CE ret = null;
374            try {
375                Type t = this.getField(5, 0);
376                ret = (CE)t;
377            } catch (ClassCastException cce) {
378                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
379                throw new RuntimeException(cce);
380            } catch (HL7Exception he) {
381                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
382                throw new RuntimeException(he);
383            }
384            return ret;
385        }
386    
387    
388    
389        /**
390         * Returns
391         * RF1-6: "Originating Referral Identifier" - creates it if necessary
392         */
393        public EI getOriginatingReferralIdentifier() { 
394            EI ret = null;
395            try {
396                Type t = this.getField(6, 0);
397                ret = (EI)t;
398            } catch (ClassCastException cce) {
399                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
400                throw new RuntimeException(cce);
401            } catch (HL7Exception he) {
402                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
403                throw new RuntimeException(he);
404            }
405            return ret;
406        }
407    
408    
409        /**
410         * Returns
411         * RF1-6: "Originating Referral Identifier" - creates it if necessary
412         */
413        public EI getRf16_OriginatingReferralIdentifier() { 
414            EI ret = null;
415            try {
416                Type t = this.getField(6, 0);
417                ret = (EI)t;
418            } catch (ClassCastException cce) {
419                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
420                throw new RuntimeException(cce);
421            } catch (HL7Exception he) {
422                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
423                throw new RuntimeException(he);
424            }
425            return ret;
426        }
427    
428    
429    
430        /**
431         * Returns
432         * RF1-7: "Effective Date" - creates it if necessary
433         */
434        public TS getEffectiveDate() { 
435            TS ret = null;
436            try {
437                Type t = this.getField(7, 0);
438                ret = (TS)t;
439            } catch (ClassCastException cce) {
440                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
441                throw new RuntimeException(cce);
442            } catch (HL7Exception he) {
443                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
444                throw new RuntimeException(he);
445            }
446            return ret;
447        }
448    
449    
450        /**
451         * Returns
452         * RF1-7: "Effective Date" - creates it if necessary
453         */
454        public TS getRf17_EffectiveDate() { 
455            TS ret = null;
456            try {
457                Type t = this.getField(7, 0);
458                ret = (TS)t;
459            } catch (ClassCastException cce) {
460                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
461                throw new RuntimeException(cce);
462            } catch (HL7Exception he) {
463                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
464                throw new RuntimeException(he);
465            }
466            return ret;
467        }
468    
469    
470    
471        /**
472         * Returns
473         * RF1-8: "Expiration Date" - creates it if necessary
474         */
475        public TS getExpirationDate() { 
476            TS ret = null;
477            try {
478                Type t = this.getField(8, 0);
479                ret = (TS)t;
480            } catch (ClassCastException cce) {
481                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
482                throw new RuntimeException(cce);
483            } catch (HL7Exception he) {
484                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
485                throw new RuntimeException(he);
486            }
487            return ret;
488        }
489    
490    
491        /**
492         * Returns
493         * RF1-8: "Expiration Date" - creates it if necessary
494         */
495        public TS getRf18_ExpirationDate() { 
496            TS ret = null;
497            try {
498                Type t = this.getField(8, 0);
499                ret = (TS)t;
500            } catch (ClassCastException cce) {
501                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
502                throw new RuntimeException(cce);
503            } catch (HL7Exception he) {
504                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
505                throw new RuntimeException(he);
506            }
507            return ret;
508        }
509    
510    
511    
512        /**
513         * Returns
514         * RF1-9: "Process Date" - creates it if necessary
515         */
516        public TS getProcessDate() { 
517            TS ret = null;
518            try {
519                Type t = this.getField(9, 0);
520                ret = (TS)t;
521            } catch (ClassCastException cce) {
522                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
523                throw new RuntimeException(cce);
524            } catch (HL7Exception he) {
525                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
526                throw new RuntimeException(he);
527            }
528            return ret;
529        }
530    
531    
532        /**
533         * Returns
534         * RF1-9: "Process Date" - creates it if necessary
535         */
536        public TS getRf19_ProcessDate() { 
537            TS ret = null;
538            try {
539                Type t = this.getField(9, 0);
540                ret = (TS)t;
541            } catch (ClassCastException cce) {
542                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
543                throw new RuntimeException(cce);
544            } catch (HL7Exception he) {
545                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
546                throw new RuntimeException(he);
547            }
548            return ret;
549        }
550    
551    
552        /**
553         * Returns all repetitions of Referral Reason (RF1-10).
554         */
555        public CE[] getReferralReason() {
556            CE[] ret = null;
557            try {
558                Type[] t = this.getField(10);  
559                ret = new CE[t.length];
560                for (int i = 0; i < ret.length; i++) {
561                    ret[i] = (CE)t[i];
562                }
563            } catch (ClassCastException cce) {
564                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
565                throw new RuntimeException(cce);
566            } catch (HL7Exception he) {
567                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
568                throw new RuntimeException(he);
569            }
570            return ret;
571        }
572    
573    
574        /**
575         * Returns a count of the current number of repetitions of Referral Reason (RF1-10).
576         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
577         * it will return zero.
578         */
579        public int getReferralReasonReps() {
580            CE[] ret = null;
581            try {
582                Type[] t = this.getField(10);
583                return t.length;  
584            } catch (ClassCastException cce) {
585                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
586                throw new RuntimeException(cce);
587            } catch (HL7Exception he) {
588                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
589                throw new RuntimeException(he);
590            }
591        }
592    
593    
594        /**
595         * Returns a specific repetition of
596         * RF1-10: "Referral Reason" - creates it if necessary
597         *
598         * @param rep The repetition index (0-indexed)
599         */
600        public CE getReferralReason(int rep) { 
601            CE ret = null;
602            try {
603                Type t = this.getField(10, rep);
604                ret = (CE)t;
605            } catch (ClassCastException cce) {
606                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
607                throw new RuntimeException(cce);
608            } catch (HL7Exception he) {
609                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
610                throw new RuntimeException(he);
611            }
612            return ret;
613        }
614    
615        /**
616         * Returns a specific repetition of
617         * RF1-10: "Referral Reason" - creates it if necessary
618         *
619         * @param rep The repetition index (0-indexed)
620         */
621        public CE getRf110_ReferralReason(int rep) { 
622            CE ret = null;
623            try {
624                Type t = this.getField(10, rep);
625                ret = (CE)t;
626            } catch (ClassCastException cce) {
627                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
628                throw new RuntimeException(cce);
629            } catch (HL7Exception he) {
630                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
631                throw new RuntimeException(he);
632            }
633            return ret;
634        }
635    
636    
637        /**
638         * Returns a count of the current number of repetitions of Referral Reason (RF1-10).
639         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
640         * it will return zero.
641         */
642        public int getRf110_ReferralReasonReps() {
643            CE[] ret = null;
644            try {
645                Type[] t = this.getField(10);
646                return t.length;  
647            } catch (ClassCastException cce) {
648                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
649                throw new RuntimeException(cce);
650            } catch (HL7Exception he) {
651                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
652                throw new RuntimeException(he);
653            }
654        }
655    
656    
657    
658        /**
659         * Inserts a repetition of
660         * RF1-10: "Referral Reason" at a specific index
661         *
662         * @param rep The repetition index (0-indexed)
663         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
664         */
665        public CE insertReferralReason(int rep) throws HL7Exception { 
666            return (CE) super.insertRepetition(10, rep);
667        }
668    
669    
670    
671        /**
672         * Inserts a repetition of
673         * RF1-10: "Referral Reason" at a specific index
674         *
675         * @param rep The repetition index (0-indexed)
676         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
677         */
678        public CE insertRf110_ReferralReason(int rep) throws HL7Exception { 
679            return (CE) super.insertRepetition(10, rep);
680        }
681    
682    
683        /**
684         * Removes a repetition of
685         * RF1-10: "Referral Reason" at a specific index
686         *
687         * @param rep The repetition index (0-indexed)
688         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
689         */
690        public CE removeReferralReason(int rep) throws HL7Exception { 
691            return (CE) super.removeRepetition(10, rep);
692        }
693    
694    
695        /**
696         * Removes a repetition of
697         * RF1-10: "Referral Reason" at a specific index
698         *
699         * @param rep The repetition index (0-indexed)
700         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
701         */
702        public CE removeRf110_ReferralReason(int rep) throws HL7Exception { 
703            return (CE) super.removeRepetition(10, rep);
704        }
705    
706    
707    
708        /**
709         * Returns all repetitions of External Referral Identifier (RF1-11).
710         */
711        public EI[] getExternalReferralIdentifier() {
712            EI[] ret = null;
713            try {
714                Type[] t = this.getField(11);  
715                ret = new EI[t.length];
716                for (int i = 0; i < ret.length; i++) {
717                    ret[i] = (EI)t[i];
718                }
719            } catch (ClassCastException cce) {
720                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
721                throw new RuntimeException(cce);
722            } catch (HL7Exception he) {
723                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
724                throw new RuntimeException(he);
725            }
726            return ret;
727        }
728    
729    
730        /**
731         * Returns a count of the current number of repetitions of External Referral Identifier (RF1-11).
732         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
733         * it will return zero.
734         */
735        public int getExternalReferralIdentifierReps() {
736            EI[] ret = null;
737            try {
738                Type[] t = this.getField(11);
739                return t.length;  
740            } catch (ClassCastException cce) {
741                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
742                throw new RuntimeException(cce);
743            } catch (HL7Exception he) {
744                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
745                throw new RuntimeException(he);
746            }
747        }
748    
749    
750        /**
751         * Returns a specific repetition of
752         * RF1-11: "External Referral Identifier" - creates it if necessary
753         *
754         * @param rep The repetition index (0-indexed)
755         */
756        public EI getExternalReferralIdentifier(int rep) { 
757            EI ret = null;
758            try {
759                Type t = this.getField(11, rep);
760                ret = (EI)t;
761            } catch (ClassCastException cce) {
762                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
763                throw new RuntimeException(cce);
764            } catch (HL7Exception he) {
765                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
766                throw new RuntimeException(he);
767            }
768            return ret;
769        }
770    
771        /**
772         * Returns a specific repetition of
773         * RF1-11: "External Referral Identifier" - creates it if necessary
774         *
775         * @param rep The repetition index (0-indexed)
776         */
777        public EI getRf111_ExternalReferralIdentifier(int rep) { 
778            EI ret = null;
779            try {
780                Type t = this.getField(11, rep);
781                ret = (EI)t;
782            } catch (ClassCastException cce) {
783                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
784                throw new RuntimeException(cce);
785            } catch (HL7Exception he) {
786                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
787                throw new RuntimeException(he);
788            }
789            return ret;
790        }
791    
792    
793        /**
794         * Returns a count of the current number of repetitions of External Referral Identifier (RF1-11).
795         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
796         * it will return zero.
797         */
798        public int getRf111_ExternalReferralIdentifierReps() {
799            EI[] ret = null;
800            try {
801                Type[] t = this.getField(11);
802                return t.length;  
803            } catch (ClassCastException cce) {
804                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
805                throw new RuntimeException(cce);
806            } catch (HL7Exception he) {
807                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
808                throw new RuntimeException(he);
809            }
810        }
811    
812    
813    
814        /**
815         * Inserts a repetition of
816         * RF1-11: "External Referral Identifier" at a specific index
817         *
818         * @param rep The repetition index (0-indexed)
819         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
820         */
821        public EI insertExternalReferralIdentifier(int rep) throws HL7Exception { 
822            return (EI) super.insertRepetition(11, rep);
823        }
824    
825    
826    
827        /**
828         * Inserts a repetition of
829         * RF1-11: "External Referral Identifier" at a specific index
830         *
831         * @param rep The repetition index (0-indexed)
832         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
833         */
834        public EI insertRf111_ExternalReferralIdentifier(int rep) throws HL7Exception { 
835            return (EI) super.insertRepetition(11, rep);
836        }
837    
838    
839        /**
840         * Removes a repetition of
841         * RF1-11: "External Referral Identifier" at a specific index
842         *
843         * @param rep The repetition index (0-indexed)
844         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
845         */
846        public EI removeExternalReferralIdentifier(int rep) throws HL7Exception { 
847            return (EI) super.removeRepetition(11, rep);
848        }
849    
850    
851        /**
852         * Removes a repetition of
853         * RF1-11: "External Referral Identifier" at a specific index
854         *
855         * @param rep The repetition index (0-indexed)
856         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
857         */
858        public EI removeRf111_ExternalReferralIdentifier(int rep) throws HL7Exception { 
859            return (EI) super.removeRepetition(11, rep);
860        }
861    
862    
863    
864    
865    
866    
867        /** {@inheritDoc} */   
868        protected Type createNewTypeWithoutReflection(int field) {
869           switch (field) {
870              case 0: return new CE(getMessage());
871              case 1: return new CE(getMessage());
872              case 2: return new CE(getMessage());
873              case 3: return new CE(getMessage());
874              case 4: return new CE(getMessage());
875              case 5: return new EI(getMessage());
876              case 6: return new TS(getMessage());
877              case 7: return new TS(getMessage());
878              case 8: return new TS(getMessage());
879              case 9: return new CE(getMessage());
880              case 10: return new EI(getMessage());
881              default: return null;
882           }
883       }
884    
885    
886    }
887