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 FHS message segment (File Header). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>FHS-1: File Field Separator (ST) <b> </b>
027         * <li>FHS-2: File Encoding Characters (ST) <b> </b>
028         * <li>FHS-3: File Sending Application (ST) <b>optional </b>
029         * <li>FHS-4: File Sending Facility (ST) <b>optional </b>
030         * <li>FHS-5: File Receiving Application (ST) <b>optional </b>
031         * <li>FHS-6: File Receiving Facility (ST) <b>optional </b>
032         * <li>FHS-7: File Creation Date/Time (TS) <b>optional </b>
033         * <li>FHS-8: File Security (ST) <b>optional </b>
034         * <li>FHS-9: File Name/ID (ST) <b>optional </b>
035         * <li>FHS-10: File Header Comment (ST) <b>optional </b>
036         * <li>FHS-11: File Control ID (ST) <b>optional </b>
037         * <li>FHS-12: Reference File Control ID (ST) <b>optional </b>
038     * </ul>
039     */
040    public class FHS extends AbstractSegment {
041    
042        /** 
043         * Creates a new FHS segment
044         */
045        public FHS(Group parent, ModelClassFactory factory) {
046           super(parent, factory);
047           init(factory);
048        }
049    
050        private void init(ModelClassFactory factory) {
051           try {
052                                      this.add(ST.class, true, 1, 1, new Object[]{ getMessage(), new Integer(0) }, "File Field Separator");
053                                      this.add(ST.class, true, 1, 4, new Object[]{ getMessage(), new Integer(0) }, "File Encoding Characters");
054                                      this.add(ST.class, false, 1, 15, new Object[]{ getMessage(), new Integer(0) }, "File Sending Application");
055                                      this.add(ST.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "File Sending Facility");
056                                      this.add(ST.class, false, 1, 15, new Object[]{ getMessage(), new Integer(0) }, "File Receiving Application");
057                                      this.add(ST.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "File Receiving Facility");
058                                      this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "File Creation Date/Time");
059                                      this.add(ST.class, false, 1, 40, new Object[]{ getMessage(), new Integer(0) }, "File Security");
060                                      this.add(ST.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "File Name/ID");
061                                      this.add(ST.class, false, 1, 80, new Object[]{ getMessage(), new Integer(0) }, "File Header Comment");
062                                      this.add(ST.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "File Control ID");
063                                      this.add(ST.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "Reference File Control ID");
064           } catch(HL7Exception e) {
065              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating FHS - this is probably a bug in the source code generator.", e);
066           }
067        }
068    
069    
070    
071        /**
072         * Returns
073         * FHS-1: "File Field Separator" - creates it if necessary
074         */
075        public ST getFileFieldSeparator() { 
076            ST ret = null;
077            try {
078                Type t = this.getField(1, 0);
079                ret = (ST)t;
080            } catch (ClassCastException cce) {
081                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
082                throw new RuntimeException(cce);
083            } catch (HL7Exception he) {
084                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
085                throw new RuntimeException(he);
086            }
087            return ret;
088        }
089    
090    
091        /**
092         * Returns
093         * FHS-1: "File Field Separator" - creates it if necessary
094         */
095        public ST getFhs1_FileFieldSeparator() { 
096            ST ret = null;
097            try {
098                Type t = this.getField(1, 0);
099                ret = (ST)t;
100            } catch (ClassCastException cce) {
101                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
102                throw new RuntimeException(cce);
103            } catch (HL7Exception he) {
104                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
105                throw new RuntimeException(he);
106            }
107            return ret;
108        }
109    
110    
111    
112        /**
113         * Returns
114         * FHS-2: "File Encoding Characters" - creates it if necessary
115         */
116        public ST getFileEncodingCharacters() { 
117            ST ret = null;
118            try {
119                Type t = this.getField(2, 0);
120                ret = (ST)t;
121            } catch (ClassCastException cce) {
122                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
123                throw new RuntimeException(cce);
124            } catch (HL7Exception he) {
125                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
126                throw new RuntimeException(he);
127            }
128            return ret;
129        }
130    
131    
132        /**
133         * Returns
134         * FHS-2: "File Encoding Characters" - creates it if necessary
135         */
136        public ST getFhs2_FileEncodingCharacters() { 
137            ST ret = null;
138            try {
139                Type t = this.getField(2, 0);
140                ret = (ST)t;
141            } catch (ClassCastException cce) {
142                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
143                throw new RuntimeException(cce);
144            } catch (HL7Exception he) {
145                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
146                throw new RuntimeException(he);
147            }
148            return ret;
149        }
150    
151    
152    
153        /**
154         * Returns
155         * FHS-3: "File Sending Application" - creates it if necessary
156         */
157        public ST getFileSendingApplication() { 
158            ST ret = null;
159            try {
160                Type t = this.getField(3, 0);
161                ret = (ST)t;
162            } catch (ClassCastException cce) {
163                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
164                throw new RuntimeException(cce);
165            } catch (HL7Exception he) {
166                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
167                throw new RuntimeException(he);
168            }
169            return ret;
170        }
171    
172    
173        /**
174         * Returns
175         * FHS-3: "File Sending Application" - creates it if necessary
176         */
177        public ST getFhs3_FileSendingApplication() { 
178            ST ret = null;
179            try {
180                Type t = this.getField(3, 0);
181                ret = (ST)t;
182            } catch (ClassCastException cce) {
183                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
184                throw new RuntimeException(cce);
185            } catch (HL7Exception he) {
186                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
187                throw new RuntimeException(he);
188            }
189            return ret;
190        }
191    
192    
193    
194        /**
195         * Returns
196         * FHS-4: "File Sending Facility" - creates it if necessary
197         */
198        public ST getFileSendingFacility() { 
199            ST ret = null;
200            try {
201                Type t = this.getField(4, 0);
202                ret = (ST)t;
203            } catch (ClassCastException cce) {
204                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
205                throw new RuntimeException(cce);
206            } catch (HL7Exception he) {
207                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
208                throw new RuntimeException(he);
209            }
210            return ret;
211        }
212    
213    
214        /**
215         * Returns
216         * FHS-4: "File Sending Facility" - creates it if necessary
217         */
218        public ST getFhs4_FileSendingFacility() { 
219            ST ret = null;
220            try {
221                Type t = this.getField(4, 0);
222                ret = (ST)t;
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            return ret;
231        }
232    
233    
234    
235        /**
236         * Returns
237         * FHS-5: "File Receiving Application" - creates it if necessary
238         */
239        public ST getFileReceivingApplication() { 
240            ST ret = null;
241            try {
242                Type t = this.getField(5, 0);
243                ret = (ST)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        /**
256         * Returns
257         * FHS-5: "File Receiving Application" - creates it if necessary
258         */
259        public ST getFhs5_FileReceivingApplication() { 
260            ST ret = null;
261            try {
262                Type t = this.getField(5, 0);
263                ret = (ST)t;
264            } catch (ClassCastException cce) {
265                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
266                throw new RuntimeException(cce);
267            } catch (HL7Exception he) {
268                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
269                throw new RuntimeException(he);
270            }
271            return ret;
272        }
273    
274    
275    
276        /**
277         * Returns
278         * FHS-6: "File Receiving Facility" - creates it if necessary
279         */
280        public ST getFileReceivingFacility() { 
281            ST ret = null;
282            try {
283                Type t = this.getField(6, 0);
284                ret = (ST)t;
285            } catch (ClassCastException cce) {
286                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
287                throw new RuntimeException(cce);
288            } catch (HL7Exception he) {
289                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
290                throw new RuntimeException(he);
291            }
292            return ret;
293        }
294    
295    
296        /**
297         * Returns
298         * FHS-6: "File Receiving Facility" - creates it if necessary
299         */
300        public ST getFhs6_FileReceivingFacility() { 
301            ST ret = null;
302            try {
303                Type t = this.getField(6, 0);
304                ret = (ST)t;
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        /**
318         * Returns
319         * FHS-7: "File Creation Date/Time" - creates it if necessary
320         */
321        public TS getFileCreationDateTime() { 
322            TS ret = null;
323            try {
324                Type t = this.getField(7, 0);
325                ret = (TS)t;
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            return ret;
334        }
335    
336    
337        /**
338         * Returns
339         * FHS-7: "File Creation Date/Time" - creates it if necessary
340         */
341        public TS getFhs7_FileCreationDateTime() { 
342            TS ret = null;
343            try {
344                Type t = this.getField(7, 0);
345                ret = (TS)t;
346            } catch (ClassCastException cce) {
347                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
348                throw new RuntimeException(cce);
349            } catch (HL7Exception he) {
350                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
351                throw new RuntimeException(he);
352            }
353            return ret;
354        }
355    
356    
357    
358        /**
359         * Returns
360         * FHS-8: "File Security" - creates it if necessary
361         */
362        public ST getFileSecurity() { 
363            ST ret = null;
364            try {
365                Type t = this.getField(8, 0);
366                ret = (ST)t;
367            } catch (ClassCastException cce) {
368                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
369                throw new RuntimeException(cce);
370            } catch (HL7Exception he) {
371                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
372                throw new RuntimeException(he);
373            }
374            return ret;
375        }
376    
377    
378        /**
379         * Returns
380         * FHS-8: "File Security" - creates it if necessary
381         */
382        public ST getFhs8_FileSecurity() { 
383            ST ret = null;
384            try {
385                Type t = this.getField(8, 0);
386                ret = (ST)t;
387            } catch (ClassCastException cce) {
388                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
389                throw new RuntimeException(cce);
390            } catch (HL7Exception he) {
391                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
392                throw new RuntimeException(he);
393            }
394            return ret;
395        }
396    
397    
398    
399        /**
400         * Returns
401         * FHS-9: "File Name/ID" - creates it if necessary
402         */
403        public ST getFileNameID() { 
404            ST ret = null;
405            try {
406                Type t = this.getField(9, 0);
407                ret = (ST)t;
408            } catch (ClassCastException cce) {
409                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
410                throw new RuntimeException(cce);
411            } catch (HL7Exception he) {
412                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
413                throw new RuntimeException(he);
414            }
415            return ret;
416        }
417    
418    
419        /**
420         * Returns
421         * FHS-9: "File Name/ID" - creates it if necessary
422         */
423        public ST getFhs9_FileNameID() { 
424            ST ret = null;
425            try {
426                Type t = this.getField(9, 0);
427                ret = (ST)t;
428            } catch (ClassCastException cce) {
429                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
430                throw new RuntimeException(cce);
431            } catch (HL7Exception he) {
432                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
433                throw new RuntimeException(he);
434            }
435            return ret;
436        }
437    
438    
439    
440        /**
441         * Returns
442         * FHS-10: "File Header Comment" - creates it if necessary
443         */
444        public ST getFileHeaderComment() { 
445            ST ret = null;
446            try {
447                Type t = this.getField(10, 0);
448                ret = (ST)t;
449            } catch (ClassCastException cce) {
450                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
451                throw new RuntimeException(cce);
452            } catch (HL7Exception he) {
453                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
454                throw new RuntimeException(he);
455            }
456            return ret;
457        }
458    
459    
460        /**
461         * Returns
462         * FHS-10: "File Header Comment" - creates it if necessary
463         */
464        public ST getFhs10_FileHeaderComment() { 
465            ST ret = null;
466            try {
467                Type t = this.getField(10, 0);
468                ret = (ST)t;
469            } catch (ClassCastException cce) {
470                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
471                throw new RuntimeException(cce);
472            } catch (HL7Exception he) {
473                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
474                throw new RuntimeException(he);
475            }
476            return ret;
477        }
478    
479    
480    
481        /**
482         * Returns
483         * FHS-11: "File Control ID" - creates it if necessary
484         */
485        public ST getFileControlID() { 
486            ST ret = null;
487            try {
488                Type t = this.getField(11, 0);
489                ret = (ST)t;
490            } catch (ClassCastException cce) {
491                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
492                throw new RuntimeException(cce);
493            } catch (HL7Exception he) {
494                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
495                throw new RuntimeException(he);
496            }
497            return ret;
498        }
499    
500    
501        /**
502         * Returns
503         * FHS-11: "File Control ID" - creates it if necessary
504         */
505        public ST getFhs11_FileControlID() { 
506            ST ret = null;
507            try {
508                Type t = this.getField(11, 0);
509                ret = (ST)t;
510            } catch (ClassCastException cce) {
511                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
512                throw new RuntimeException(cce);
513            } catch (HL7Exception he) {
514                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
515                throw new RuntimeException(he);
516            }
517            return ret;
518        }
519    
520    
521    
522        /**
523         * Returns
524         * FHS-12: "Reference File Control ID" - creates it if necessary
525         */
526        public ST getReferenceFileControlID() { 
527            ST ret = null;
528            try {
529                Type t = this.getField(12, 0);
530                ret = (ST)t;
531            } catch (ClassCastException cce) {
532                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
533                throw new RuntimeException(cce);
534            } catch (HL7Exception he) {
535                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
536                throw new RuntimeException(he);
537            }
538            return ret;
539        }
540    
541    
542        /**
543         * Returns
544         * FHS-12: "Reference File Control ID" - creates it if necessary
545         */
546        public ST getFhs12_ReferenceFileControlID() { 
547            ST ret = null;
548            try {
549                Type t = this.getField(12, 0);
550                ret = (ST)t;
551            } catch (ClassCastException cce) {
552                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
553                throw new RuntimeException(cce);
554            } catch (HL7Exception he) {
555                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
556                throw new RuntimeException(he);
557            }
558            return ret;
559        }
560    
561    
562    
563    
564    
565        /** {@inheritDoc} */   
566        protected Type createNewTypeWithoutReflection(int field) {
567           switch (field) {
568              case 0: return new ST(getMessage());
569              case 1: return new ST(getMessage());
570              case 2: return new ST(getMessage());
571              case 3: return new ST(getMessage());
572              case 4: return new ST(getMessage());
573              case 5: return new ST(getMessage());
574              case 6: return new TS(getMessage());
575              case 7: return new ST(getMessage());
576              case 8: return new ST(getMessage());
577              case 9: return new ST(getMessage());
578              case 10: return new ST(getMessage());
579              case 11: return new ST(getMessage());
580              default: return null;
581           }
582       }
583    
584    
585    }
586