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 RQD message segment (Requisition Detail). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>RQD-1: Requisition Line Number (SI) <b>optional </b>
027         * <li>RQD-2: Item Code - Internal (CE) <b>optional </b>
028         * <li>RQD-3: Item Code - External (CE) <b>optional </b>
029         * <li>RQD-4: Hospital Item Code (CE) <b>optional </b>
030         * <li>RQD-5: Requisition Quantity (NM) <b>optional </b>
031         * <li>RQD-6: Requisition Unit of Measure (CE) <b>optional </b>
032         * <li>RQD-7: Dept. Cost Center (IS) <b>optional </b>
033         * <li>RQD-8: Item Natural Account Code (IS) <b>optional </b>
034         * <li>RQD-9: Deliver To ID (CE) <b>optional </b>
035         * <li>RQD-10: Date Needed (DT) <b>optional </b>
036     * </ul>
037     */
038    public class RQD extends AbstractSegment {
039    
040        /** 
041         * Creates a new RQD segment
042         */
043        public RQD(Group parent, ModelClassFactory factory) {
044           super(parent, factory);
045           init(factory);
046        }
047    
048        private void init(ModelClassFactory factory) {
049           try {
050                                      this.add(SI.class, false, 1, 4, new Object[]{ getMessage(), new Integer(0) }, "Requisition Line Number");
051                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Item Code - Internal");
052                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Item Code - External");
053                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Hospital Item Code");
054                                      this.add(NM.class, false, 1, 6, new Object[]{ getMessage(), new Integer(0) }, "Requisition Quantity");
055                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Requisition Unit of Measure");
056                                      this.add(IS.class, false, 1, 30, new Object[]{ getMessage() }, "Dept. Cost Center");
057                                      this.add(IS.class, false, 1, 30, new Object[]{ getMessage() }, "Item Natural Account Code");
058                                      this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Deliver To ID");
059                                      this.add(DT.class, false, 1, 8, new Object[]{ getMessage(), new Integer(0) }, "Date Needed");
060           } catch(HL7Exception e) {
061              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating RQD - this is probably a bug in the source code generator.", e);
062           }
063        }
064    
065    
066    
067        /**
068         * Returns
069         * RQD-1: "Requisition Line Number" - creates it if necessary
070         */
071        public SI getRequisitionLineNumber() { 
072            SI ret = null;
073            try {
074                Type t = this.getField(1, 0);
075                ret = (SI)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         * RQD-1: "Requisition Line Number" - creates it if necessary
090         */
091        public SI getRqd1_RequisitionLineNumber() { 
092            SI ret = null;
093            try {
094                Type t = this.getField(1, 0);
095                ret = (SI)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         * RQD-2: "Item Code - Internal" - creates it if necessary
111         */
112        public CE getItemCodeInternal() { 
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         * RQD-2: "Item Code - Internal" - creates it if necessary
131         */
132        public CE getRqd2_ItemCodeInternal() { 
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         * RQD-3: "Item Code - External" - creates it if necessary
152         */
153        public CE getItemCodeExternal() { 
154            CE ret = null;
155            try {
156                Type t = this.getField(3, 0);
157                ret = (CE)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         * RQD-3: "Item Code - External" - creates it if necessary
172         */
173        public CE getRqd3_ItemCodeExternal() { 
174            CE ret = null;
175            try {
176                Type t = this.getField(3, 0);
177                ret = (CE)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         * RQD-4: "Hospital Item Code" - creates it if necessary
193         */
194        public CE getHospitalItemCode() { 
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         * RQD-4: "Hospital Item Code" - creates it if necessary
213         */
214        public CE getRqd4_HospitalItemCode() { 
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         * RQD-5: "Requisition Quantity" - creates it if necessary
234         */
235        public NM getRequisitionQuantity() { 
236            NM ret = null;
237            try {
238                Type t = this.getField(5, 0);
239                ret = (NM)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         * RQD-5: "Requisition Quantity" - creates it if necessary
254         */
255        public NM getRqd5_RequisitionQuantity() { 
256            NM ret = null;
257            try {
258                Type t = this.getField(5, 0);
259                ret = (NM)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         * RQD-6: "Requisition Unit of Measure" - creates it if necessary
275         */
276        public CE getRequisitionUnitOfMeasure() { 
277            CE ret = null;
278            try {
279                Type t = this.getField(6, 0);
280                ret = (CE)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         * RQD-6: "Requisition Unit of Measure" - creates it if necessary
295         */
296        public CE getRqd6_RequisitionUnitOfMeasure() { 
297            CE ret = null;
298            try {
299                Type t = this.getField(6, 0);
300                ret = (CE)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         * RQD-7: "Dept. Cost Center" - creates it if necessary
316         */
317        public IS getDeptCostCenter() { 
318            IS ret = null;
319            try {
320                Type t = this.getField(7, 0);
321                ret = (IS)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         * RQD-7: "Dept. Cost Center" - creates it if necessary
336         */
337        public IS getRqd7_DeptCostCenter() { 
338            IS ret = null;
339            try {
340                Type t = this.getField(7, 0);
341                ret = (IS)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         * RQD-8: "Item Natural Account Code" - creates it if necessary
357         */
358        public IS getItemNaturalAccountCode() { 
359            IS ret = null;
360            try {
361                Type t = this.getField(8, 0);
362                ret = (IS)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         * RQD-8: "Item Natural Account Code" - creates it if necessary
377         */
378        public IS getRqd8_ItemNaturalAccountCode() { 
379            IS ret = null;
380            try {
381                Type t = this.getField(8, 0);
382                ret = (IS)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         * RQD-9: "Deliver To ID" - creates it if necessary
398         */
399        public CE getDeliverToID() { 
400            CE ret = null;
401            try {
402                Type t = this.getField(9, 0);
403                ret = (CE)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         * RQD-9: "Deliver To ID" - creates it if necessary
418         */
419        public CE getRqd9_DeliverToID() { 
420            CE ret = null;
421            try {
422                Type t = this.getField(9, 0);
423                ret = (CE)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         * RQD-10: "Date Needed" - creates it if necessary
439         */
440        public DT getDateNeeded() { 
441            DT ret = null;
442            try {
443                Type t = this.getField(10, 0);
444                ret = (DT)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         * RQD-10: "Date Needed" - creates it if necessary
459         */
460        public DT getRqd10_DateNeeded() { 
461            DT ret = null;
462            try {
463                Type t = this.getField(10, 0);
464                ret = (DT)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 SI(getMessage());
483              case 1: return new CE(getMessage());
484              case 2: return new CE(getMessage());
485              case 3: return new CE(getMessage());
486              case 4: return new NM(getMessage());
487              case 5: return new CE(getMessage());
488              case 6: return new IS(getMessage(), new Integer( 319 ));
489              case 7: return new IS(getMessage(), new Integer( 320 ));
490              case 8: return new CE(getMessage());
491              case 9: return new DT(getMessage());
492              default: return null;
493           }
494       }
495    
496    
497    }
498