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 ACC message segment (Accident). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>ACC-1: Accident Date/Time (TS) <b>optional </b>
027         * <li>ACC-2: Accident Code (CE) <b>optional </b>
028         * <li>ACC-3: Accident Location (ST) <b>optional </b>
029         * <li>ACC-4: Auto Accident State (CE) <b>optional </b>
030         * <li>ACC-5: Accident Job Related Indicator (ID) <b>optional </b>
031         * <li>ACC-6: Accident Death Indicator (ID) <b>optional </b>
032         * <li>ACC-7: Entered By (XCN) <b>optional </b>
033         * <li>ACC-8: Accident Description (ST) <b>optional </b>
034         * <li>ACC-9: Brought In By (ST) <b>optional </b>
035         * <li>ACC-10: Police Notified Indicator (ID) <b>optional </b>
036     * </ul>
037     */
038    public class ACC extends AbstractSegment {
039    
040        /** 
041         * Creates a new ACC segment
042         */
043        public ACC(Group parent, ModelClassFactory factory) {
044           super(parent, factory);
045           init(factory);
046        }
047    
048        private void init(ModelClassFactory factory) {
049           try {
050                                      this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Accident Date/Time");
051                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(50) }, "Accident Code");
052                                      this.add(ST.class, false, 1, 25, new Object[]{ getMessage(), new Integer(0) }, "Accident Location");
053                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(347) }, "Auto Accident State");
054                                      this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Accident Job Related Indicator");
055                                      this.add(ID.class, false, 1, 12, new Object[]{ getMessage() }, "Accident Death Indicator");
056                                      this.add(XCN.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Entered By");
057                                      this.add(ST.class, false, 1, 25, new Object[]{ getMessage(), new Integer(0) }, "Accident Description");
058                                      this.add(ST.class, false, 1, 80, new Object[]{ getMessage(), new Integer(0) }, "Brought In By");
059                                      this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Police Notified Indicator");
060           } catch(HL7Exception e) {
061              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ACC - this is probably a bug in the source code generator.", e);
062           }
063        }
064    
065    
066    
067        /**
068         * Returns
069         * ACC-1: "Accident Date/Time" - creates it if necessary
070         */
071        public TS getAccidentDateTime() { 
072            TS ret = null;
073            try {
074                Type t = this.getField(1, 0);
075                ret = (TS)t;
076            } catch (ClassCastException cce) {
077                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
078                throw new RuntimeException(cce);
079            } catch (HL7Exception he) {
080                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
081                throw new RuntimeException(he);
082            }
083            return ret;
084        }
085    
086    
087        /**
088         * Returns
089         * ACC-1: "Accident Date/Time" - creates it if necessary
090         */
091        public TS getAcc1_AccidentDateTime() { 
092            TS ret = null;
093            try {
094                Type t = this.getField(1, 0);
095                ret = (TS)t;
096            } catch (ClassCastException cce) {
097                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
098                throw new RuntimeException(cce);
099            } catch (HL7Exception he) {
100                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
101                throw new RuntimeException(he);
102            }
103            return ret;
104        }
105    
106    
107    
108        /**
109         * Returns
110         * ACC-2: "Accident Code" - creates it if necessary
111         */
112        public CE getAccidentCode() { 
113            CE ret = null;
114            try {
115                Type t = this.getField(2, 0);
116                ret = (CE)t;
117            } catch (ClassCastException cce) {
118                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
119                throw new RuntimeException(cce);
120            } catch (HL7Exception he) {
121                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
122                throw new RuntimeException(he);
123            }
124            return ret;
125        }
126    
127    
128        /**
129         * Returns
130         * ACC-2: "Accident Code" - creates it if necessary
131         */
132        public CE getAcc2_AccidentCode() { 
133            CE ret = null;
134            try {
135                Type t = this.getField(2, 0);
136                ret = (CE)t;
137            } catch (ClassCastException cce) {
138                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
139                throw new RuntimeException(cce);
140            } catch (HL7Exception he) {
141                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
142                throw new RuntimeException(he);
143            }
144            return ret;
145        }
146    
147    
148    
149        /**
150         * Returns
151         * ACC-3: "Accident Location" - creates it if necessary
152         */
153        public ST getAccidentLocation() { 
154            ST ret = null;
155            try {
156                Type t = this.getField(3, 0);
157                ret = (ST)t;
158            } catch (ClassCastException cce) {
159                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
160                throw new RuntimeException(cce);
161            } catch (HL7Exception he) {
162                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
163                throw new RuntimeException(he);
164            }
165            return ret;
166        }
167    
168    
169        /**
170         * Returns
171         * ACC-3: "Accident Location" - creates it if necessary
172         */
173        public ST getAcc3_AccidentLocation() { 
174            ST ret = null;
175            try {
176                Type t = this.getField(3, 0);
177                ret = (ST)t;
178            } catch (ClassCastException cce) {
179                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
180                throw new RuntimeException(cce);
181            } catch (HL7Exception he) {
182                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
183                throw new RuntimeException(he);
184            }
185            return ret;
186        }
187    
188    
189    
190        /**
191         * Returns
192         * ACC-4: "Auto Accident State" - creates it if necessary
193         */
194        public CE getAutoAccidentState() { 
195            CE ret = null;
196            try {
197                Type t = this.getField(4, 0);
198                ret = (CE)t;
199            } catch (ClassCastException cce) {
200                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
201                throw new RuntimeException(cce);
202            } catch (HL7Exception he) {
203                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
204                throw new RuntimeException(he);
205            }
206            return ret;
207        }
208    
209    
210        /**
211         * Returns
212         * ACC-4: "Auto Accident State" - creates it if necessary
213         */
214        public CE getAcc4_AutoAccidentState() { 
215            CE ret = null;
216            try {
217                Type t = this.getField(4, 0);
218                ret = (CE)t;
219            } catch (ClassCastException cce) {
220                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
221                throw new RuntimeException(cce);
222            } catch (HL7Exception he) {
223                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
224                throw new RuntimeException(he);
225            }
226            return ret;
227        }
228    
229    
230    
231        /**
232         * Returns
233         * ACC-5: "Accident Job Related Indicator" - creates it if necessary
234         */
235        public ID getAccidentJobRelatedIndicator() { 
236            ID ret = null;
237            try {
238                Type t = this.getField(5, 0);
239                ret = (ID)t;
240            } catch (ClassCastException cce) {
241                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
242                throw new RuntimeException(cce);
243            } catch (HL7Exception he) {
244                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
245                throw new RuntimeException(he);
246            }
247            return ret;
248        }
249    
250    
251        /**
252         * Returns
253         * ACC-5: "Accident Job Related Indicator" - creates it if necessary
254         */
255        public ID getAcc5_AccidentJobRelatedIndicator() { 
256            ID ret = null;
257            try {
258                Type t = this.getField(5, 0);
259                ret = (ID)t;
260            } catch (ClassCastException cce) {
261                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
262                throw new RuntimeException(cce);
263            } catch (HL7Exception he) {
264                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
265                throw new RuntimeException(he);
266            }
267            return ret;
268        }
269    
270    
271    
272        /**
273         * Returns
274         * ACC-6: "Accident Death Indicator" - creates it if necessary
275         */
276        public ID getAccidentDeathIndicator() { 
277            ID ret = null;
278            try {
279                Type t = this.getField(6, 0);
280                ret = (ID)t;
281            } catch (ClassCastException cce) {
282                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
283                throw new RuntimeException(cce);
284            } catch (HL7Exception he) {
285                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
286                throw new RuntimeException(he);
287            }
288            return ret;
289        }
290    
291    
292        /**
293         * Returns
294         * ACC-6: "Accident Death Indicator" - creates it if necessary
295         */
296        public ID getAcc6_AccidentDeathIndicator() { 
297            ID ret = null;
298            try {
299                Type t = this.getField(6, 0);
300                ret = (ID)t;
301            } catch (ClassCastException cce) {
302                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
303                throw new RuntimeException(cce);
304            } catch (HL7Exception he) {
305                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
306                throw new RuntimeException(he);
307            }
308            return ret;
309        }
310    
311    
312    
313        /**
314         * Returns
315         * ACC-7: "Entered By" - creates it if necessary
316         */
317        public XCN getEnteredBy() { 
318            XCN ret = null;
319            try {
320                Type t = this.getField(7, 0);
321                ret = (XCN)t;
322            } catch (ClassCastException cce) {
323                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
324                throw new RuntimeException(cce);
325            } catch (HL7Exception he) {
326                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
327                throw new RuntimeException(he);
328            }
329            return ret;
330        }
331    
332    
333        /**
334         * Returns
335         * ACC-7: "Entered By" - creates it if necessary
336         */
337        public XCN getAcc7_EnteredBy() { 
338            XCN ret = null;
339            try {
340                Type t = this.getField(7, 0);
341                ret = (XCN)t;
342            } catch (ClassCastException cce) {
343                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
344                throw new RuntimeException(cce);
345            } catch (HL7Exception he) {
346                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
347                throw new RuntimeException(he);
348            }
349            return ret;
350        }
351    
352    
353    
354        /**
355         * Returns
356         * ACC-8: "Accident Description" - creates it if necessary
357         */
358        public ST getAccidentDescription() { 
359            ST ret = null;
360            try {
361                Type t = this.getField(8, 0);
362                ret = (ST)t;
363            } catch (ClassCastException cce) {
364                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
365                throw new RuntimeException(cce);
366            } catch (HL7Exception he) {
367                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
368                throw new RuntimeException(he);
369            }
370            return ret;
371        }
372    
373    
374        /**
375         * Returns
376         * ACC-8: "Accident Description" - creates it if necessary
377         */
378        public ST getAcc8_AccidentDescription() { 
379            ST ret = null;
380            try {
381                Type t = this.getField(8, 0);
382                ret = (ST)t;
383            } catch (ClassCastException cce) {
384                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
385                throw new RuntimeException(cce);
386            } catch (HL7Exception he) {
387                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
388                throw new RuntimeException(he);
389            }
390            return ret;
391        }
392    
393    
394    
395        /**
396         * Returns
397         * ACC-9: "Brought In By" - creates it if necessary
398         */
399        public ST getBroughtInBy() { 
400            ST ret = null;
401            try {
402                Type t = this.getField(9, 0);
403                ret = (ST)t;
404            } catch (ClassCastException cce) {
405                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
406                throw new RuntimeException(cce);
407            } catch (HL7Exception he) {
408                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
409                throw new RuntimeException(he);
410            }
411            return ret;
412        }
413    
414    
415        /**
416         * Returns
417         * ACC-9: "Brought In By" - creates it if necessary
418         */
419        public ST getAcc9_BroughtInBy() { 
420            ST ret = null;
421            try {
422                Type t = this.getField(9, 0);
423                ret = (ST)t;
424            } catch (ClassCastException cce) {
425                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
426                throw new RuntimeException(cce);
427            } catch (HL7Exception he) {
428                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
429                throw new RuntimeException(he);
430            }
431            return ret;
432        }
433    
434    
435    
436        /**
437         * Returns
438         * ACC-10: "Police Notified Indicator" - creates it if necessary
439         */
440        public ID getPoliceNotifiedIndicator() { 
441            ID ret = null;
442            try {
443                Type t = this.getField(10, 0);
444                ret = (ID)t;
445            } catch (ClassCastException cce) {
446                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
447                throw new RuntimeException(cce);
448            } catch (HL7Exception he) {
449                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
450                throw new RuntimeException(he);
451            }
452            return ret;
453        }
454    
455    
456        /**
457         * Returns
458         * ACC-10: "Police Notified Indicator" - creates it if necessary
459         */
460        public ID getAcc10_PoliceNotifiedIndicator() { 
461            ID ret = null;
462            try {
463                Type t = this.getField(10, 0);
464                ret = (ID)t;
465            } catch (ClassCastException cce) {
466                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
467                throw new RuntimeException(cce);
468            } catch (HL7Exception he) {
469                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
470                throw new RuntimeException(he);
471            }
472            return ret;
473        }
474    
475    
476    
477    
478    
479        /** {@inheritDoc} */   
480        protected Type createNewTypeWithoutReflection(int field) {
481           switch (field) {
482              case 0: return new TS(getMessage());
483              case 1: return new CE(getMessage());
484              case 2: return new ST(getMessage());
485              case 3: return new CE(getMessage());
486              case 4: return new ID(getMessage(), new Integer( 136 ));
487              case 5: return new ID(getMessage(), new Integer( 136 ));
488              case 6: return new XCN(getMessage());
489              case 7: return new ST(getMessage());
490              case 8: return new ST(getMessage());
491              case 9: return new ID(getMessage(), new Integer( 136 ));
492              default: return null;
493           }
494       }
495    
496    
497    }
498