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