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 GP1 message segment (Grouping/Reimbursement - Visit). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>GP1-1: Type of Bill Code (IS) <b> </b>
027         * <li>GP1-2: Revenue Code (IS) <b>optional repeating</b>
028         * <li>GP1-3: Overall Claim Disposition Code (IS) <b>optional </b>
029         * <li>GP1-4: OCE Edits per Visit Code (IS) <b>optional repeating</b>
030         * <li>GP1-5: Outlier Cost (CP) <b>optional </b>
031     * </ul>
032     */
033    public class GP1 extends AbstractSegment {
034    
035        /** 
036         * Creates a new GP1 segment
037         */
038        public GP1(Group parent, ModelClassFactory factory) {
039           super(parent, factory);
040           init(factory);
041        }
042    
043        private void init(ModelClassFactory factory) {
044           try {
045                                      this.add(IS.class, true, 1, 3, new Object[]{ getMessage() }, "Type of Bill Code");
046                                      this.add(IS.class, false, 0, 3, new Object[]{ getMessage() }, "Revenue Code");
047                                      this.add(IS.class, false, 1, 1, new Object[]{ getMessage() }, "Overall Claim Disposition Code");
048                                      this.add(IS.class, false, 0, 2, new Object[]{ getMessage() }, "OCE Edits per Visit Code");
049                                      this.add(CP.class, false, 1, 12, new Object[]{ getMessage(), new Integer(0) }, "Outlier Cost");
050           } catch(HL7Exception e) {
051              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating GP1 - this is probably a bug in the source code generator.", e);
052           }
053        }
054    
055    
056    
057        /**
058         * Returns
059         * GP1-1: "Type of Bill Code" - creates it if necessary
060         */
061        public IS getTypeOfBillCode() { 
062            IS ret = null;
063            try {
064                Type t = this.getField(1, 0);
065                ret = (IS)t;
066            } catch (ClassCastException cce) {
067                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
068                throw new RuntimeException(cce);
069            } catch (HL7Exception he) {
070                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
071                throw new RuntimeException(he);
072            }
073            return ret;
074        }
075    
076    
077        /**
078         * Returns
079         * GP1-1: "Type of Bill Code" - creates it if necessary
080         */
081        public IS getGp11_TypeOfBillCode() { 
082            IS ret = null;
083            try {
084                Type t = this.getField(1, 0);
085                ret = (IS)t;
086            } catch (ClassCastException cce) {
087                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
088                throw new RuntimeException(cce);
089            } catch (HL7Exception he) {
090                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
091                throw new RuntimeException(he);
092            }
093            return ret;
094        }
095    
096    
097        /**
098         * Returns all repetitions of Revenue Code (GP1-2).
099         */
100        public IS[] getRevenueCode() {
101            IS[] ret = null;
102            try {
103                Type[] t = this.getField(2);  
104                ret = new IS[t.length];
105                for (int i = 0; i < ret.length; i++) {
106                    ret[i] = (IS)t[i];
107                }
108            } catch (ClassCastException cce) {
109                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
110                throw new RuntimeException(cce);
111            } catch (HL7Exception he) {
112                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
113                throw new RuntimeException(he);
114            }
115            return ret;
116        }
117    
118    
119        /**
120         * Returns a count of the current number of repetitions of Revenue Code (GP1-2).
121         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
122         * it will return zero.
123         */
124        public int getRevenueCodeReps() {
125            IS[] ret = null;
126            try {
127                Type[] t = this.getField(2);
128                return t.length;  
129            } catch (ClassCastException cce) {
130                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
131                throw new RuntimeException(cce);
132            } catch (HL7Exception he) {
133                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
134                throw new RuntimeException(he);
135            }
136        }
137    
138    
139        /**
140         * Returns a specific repetition of
141         * GP1-2: "Revenue Code" - creates it if necessary
142         *
143         * @param rep The repetition index (0-indexed)
144         */
145        public IS getRevenueCode(int rep) { 
146            IS ret = null;
147            try {
148                Type t = this.getField(2, rep);
149                ret = (IS)t;
150            } catch (ClassCastException cce) {
151                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
152                throw new RuntimeException(cce);
153            } catch (HL7Exception he) {
154                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
155                throw new RuntimeException(he);
156            }
157            return ret;
158        }
159    
160        /**
161         * Returns a specific repetition of
162         * GP1-2: "Revenue Code" - creates it if necessary
163         *
164         * @param rep The repetition index (0-indexed)
165         */
166        public IS getGp12_RevenueCode(int rep) { 
167            IS ret = null;
168            try {
169                Type t = this.getField(2, rep);
170                ret = (IS)t;
171            } catch (ClassCastException cce) {
172                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
173                throw new RuntimeException(cce);
174            } catch (HL7Exception he) {
175                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
176                throw new RuntimeException(he);
177            }
178            return ret;
179        }
180    
181    
182        /**
183         * Returns a count of the current number of repetitions of Revenue Code (GP1-2).
184         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
185         * it will return zero.
186         */
187        public int getGp12_RevenueCodeReps() {
188            IS[] ret = null;
189            try {
190                Type[] t = this.getField(2);
191                return t.length;  
192            } catch (ClassCastException cce) {
193                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
194                throw new RuntimeException(cce);
195            } catch (HL7Exception he) {
196                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
197                throw new RuntimeException(he);
198            }
199        }
200    
201    
202    
203        /**
204         * Inserts a repetition of
205         * GP1-2: "Revenue Code" at a specific index
206         *
207         * @param rep The repetition index (0-indexed)
208         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
209         */
210        public IS insertRevenueCode(int rep) throws HL7Exception { 
211            return (IS) super.insertRepetition(2, rep);
212        }
213    
214    
215    
216        /**
217         * Inserts a repetition of
218         * GP1-2: "Revenue Code" at a specific index
219         *
220         * @param rep The repetition index (0-indexed)
221         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
222         */
223        public IS insertGp12_RevenueCode(int rep) throws HL7Exception { 
224            return (IS) super.insertRepetition(2, rep);
225        }
226    
227    
228        /**
229         * Removes a repetition of
230         * GP1-2: "Revenue Code" at a specific index
231         *
232         * @param rep The repetition index (0-indexed)
233         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
234         */
235        public IS removeRevenueCode(int rep) throws HL7Exception { 
236            return (IS) super.removeRepetition(2, rep);
237        }
238    
239    
240        /**
241         * Removes a repetition of
242         * GP1-2: "Revenue Code" at a specific index
243         *
244         * @param rep The repetition index (0-indexed)
245         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
246         */
247        public IS removeGp12_RevenueCode(int rep) throws HL7Exception { 
248            return (IS) super.removeRepetition(2, rep);
249        }
250    
251    
252    
253    
254        /**
255         * Returns
256         * GP1-3: "Overall Claim Disposition Code" - creates it if necessary
257         */
258        public IS getOverallClaimDispositionCode() { 
259            IS ret = null;
260            try {
261                Type t = this.getField(3, 0);
262                ret = (IS)t;
263            } catch (ClassCastException cce) {
264                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
265                throw new RuntimeException(cce);
266            } catch (HL7Exception he) {
267                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
268                throw new RuntimeException(he);
269            }
270            return ret;
271        }
272    
273    
274        /**
275         * Returns
276         * GP1-3: "Overall Claim Disposition Code" - creates it if necessary
277         */
278        public IS getGp13_OverallClaimDispositionCode() { 
279            IS ret = null;
280            try {
281                Type t = this.getField(3, 0);
282                ret = (IS)t;
283            } catch (ClassCastException cce) {
284                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
285                throw new RuntimeException(cce);
286            } catch (HL7Exception he) {
287                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
288                throw new RuntimeException(he);
289            }
290            return ret;
291        }
292    
293    
294        /**
295         * Returns all repetitions of OCE Edits per Visit Code (GP1-4).
296         */
297        public IS[] getOCEEditsPerVisitCode() {
298            IS[] ret = null;
299            try {
300                Type[] t = this.getField(4);  
301                ret = new IS[t.length];
302                for (int i = 0; i < ret.length; i++) {
303                    ret[i] = (IS)t[i];
304                }
305            } catch (ClassCastException cce) {
306                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
307                throw new RuntimeException(cce);
308            } catch (HL7Exception he) {
309                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
310                throw new RuntimeException(he);
311            }
312            return ret;
313        }
314    
315    
316        /**
317         * Returns a count of the current number of repetitions of OCE Edits per Visit Code (GP1-4).
318         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
319         * it will return zero.
320         */
321        public int getOCEEditsPerVisitCodeReps() {
322            IS[] ret = null;
323            try {
324                Type[] t = this.getField(4);
325                return t.length;  
326            } catch (ClassCastException cce) {
327                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
328                throw new RuntimeException(cce);
329            } catch (HL7Exception he) {
330                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
331                throw new RuntimeException(he);
332            }
333        }
334    
335    
336        /**
337         * Returns a specific repetition of
338         * GP1-4: "OCE Edits per Visit Code" - creates it if necessary
339         *
340         * @param rep The repetition index (0-indexed)
341         */
342        public IS getOCEEditsPerVisitCode(int rep) { 
343            IS ret = null;
344            try {
345                Type t = this.getField(4, rep);
346                ret = (IS)t;
347            } catch (ClassCastException cce) {
348                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
349                throw new RuntimeException(cce);
350            } catch (HL7Exception he) {
351                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
352                throw new RuntimeException(he);
353            }
354            return ret;
355        }
356    
357        /**
358         * Returns a specific repetition of
359         * GP1-4: "OCE Edits per Visit Code" - creates it if necessary
360         *
361         * @param rep The repetition index (0-indexed)
362         */
363        public IS getGp14_OCEEditsPerVisitCode(int rep) { 
364            IS ret = null;
365            try {
366                Type t = this.getField(4, rep);
367                ret = (IS)t;
368            } catch (ClassCastException cce) {
369                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
370                throw new RuntimeException(cce);
371            } catch (HL7Exception he) {
372                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
373                throw new RuntimeException(he);
374            }
375            return ret;
376        }
377    
378    
379        /**
380         * Returns a count of the current number of repetitions of OCE Edits per Visit Code (GP1-4).
381         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
382         * it will return zero.
383         */
384        public int getGp14_OCEEditsPerVisitCodeReps() {
385            IS[] ret = null;
386            try {
387                Type[] t = this.getField(4);
388                return t.length;  
389            } catch (ClassCastException cce) {
390                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
391                throw new RuntimeException(cce);
392            } catch (HL7Exception he) {
393                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
394                throw new RuntimeException(he);
395            }
396        }
397    
398    
399    
400        /**
401         * Inserts a repetition of
402         * GP1-4: "OCE Edits per Visit Code" at a specific index
403         *
404         * @param rep The repetition index (0-indexed)
405         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
406         */
407        public IS insertOCEEditsPerVisitCode(int rep) throws HL7Exception { 
408            return (IS) super.insertRepetition(4, rep);
409        }
410    
411    
412    
413        /**
414         * Inserts a repetition of
415         * GP1-4: "OCE Edits per Visit Code" at a specific index
416         *
417         * @param rep The repetition index (0-indexed)
418         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
419         */
420        public IS insertGp14_OCEEditsPerVisitCode(int rep) throws HL7Exception { 
421            return (IS) super.insertRepetition(4, rep);
422        }
423    
424    
425        /**
426         * Removes a repetition of
427         * GP1-4: "OCE Edits per Visit Code" at a specific index
428         *
429         * @param rep The repetition index (0-indexed)
430         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
431         */
432        public IS removeOCEEditsPerVisitCode(int rep) throws HL7Exception { 
433            return (IS) super.removeRepetition(4, rep);
434        }
435    
436    
437        /**
438         * Removes a repetition of
439         * GP1-4: "OCE Edits per Visit Code" at a specific index
440         *
441         * @param rep The repetition index (0-indexed)
442         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
443         */
444        public IS removeGp14_OCEEditsPerVisitCode(int rep) throws HL7Exception { 
445            return (IS) super.removeRepetition(4, rep);
446        }
447    
448    
449    
450    
451        /**
452         * Returns
453         * GP1-5: "Outlier Cost" - creates it if necessary
454         */
455        public CP getOutlierCost() { 
456            CP ret = null;
457            try {
458                Type t = this.getField(5, 0);
459                ret = (CP)t;
460            } catch (ClassCastException cce) {
461                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
462                throw new RuntimeException(cce);
463            } catch (HL7Exception he) {
464                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
465                throw new RuntimeException(he);
466            }
467            return ret;
468        }
469    
470    
471        /**
472         * Returns
473         * GP1-5: "Outlier Cost" - creates it if necessary
474         */
475        public CP getGp15_OutlierCost() { 
476            CP ret = null;
477            try {
478                Type t = this.getField(5, 0);
479                ret = (CP)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    
493    
494        /** {@inheritDoc} */   
495        protected Type createNewTypeWithoutReflection(int field) {
496           switch (field) {
497              case 0: return new IS(getMessage(), new Integer( 455 ));
498              case 1: return new IS(getMessage(), new Integer( 456 ));
499              case 2: return new IS(getMessage(), new Integer( 457 ));
500              case 3: return new IS(getMessage(), new Integer( 458 ));
501              case 4: return new CP(getMessage());
502              default: return null;
503           }
504       }
505    
506    
507    }
508