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 MFA message segment (Master File Acknowledgment). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>MFA-1: Record-Level Event Code (ID) <b> </b>
027         * <li>MFA-2: MFN Control ID (ST) <b>optional </b>
028         * <li>MFA-3: Event Completion Date/Time (TS) <b>optional </b>
029         * <li>MFA-4: MFN Record Level Error Return (CE) <b> </b>
030         * <li>MFA-5: Primary Key Value - MFA (CE) <b> repeating</b>
031         * <li>MFA-6: Primary Key Value Type - MFA (ID) <b> repeating</b>
032     * </ul>
033     */
034    public class MFA extends AbstractSegment {
035    
036        /** 
037         * Creates a new MFA segment
038         */
039        public MFA(Group parent, ModelClassFactory factory) {
040           super(parent, factory);
041           init(factory);
042        }
043    
044        private void init(ModelClassFactory factory) {
045           try {
046                                      this.add(ID.class, true, 1, 3, new Object[]{ getMessage() }, "Record-Level Event Code");
047                                      this.add(ST.class, false, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "MFN Control ID");
048                                      this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Event Completion Date/Time");
049                                      this.add(CE.class, true, 1, 250, new Object[]{ getMessage(), new Integer(181) }, "MFN Record Level Error Return");
050                                      this.add(CE.class, true, 0, 250, new Object[]{ getMessage(), new Integer(9999) }, "Primary Key Value - MFA");
051                                      this.add(ID.class, true, 0, 3, new Object[]{ getMessage() }, "Primary Key Value Type - MFA");
052           } catch(HL7Exception e) {
053              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating MFA - this is probably a bug in the source code generator.", e);
054           }
055        }
056    
057    
058    
059        /**
060         * Returns
061         * MFA-1: "Record-Level Event Code" - creates it if necessary
062         */
063        public ID getRecordLevelEventCode() { 
064            ID ret = null;
065            try {
066                Type t = this.getField(1, 0);
067                ret = (ID)t;
068            } catch (ClassCastException cce) {
069                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
070                throw new RuntimeException(cce);
071            } catch (HL7Exception he) {
072                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
073                throw new RuntimeException(he);
074            }
075            return ret;
076        }
077    
078    
079        /**
080         * Returns
081         * MFA-1: "Record-Level Event Code" - creates it if necessary
082         */
083        public ID getMfa1_RecordLevelEventCode() { 
084            ID ret = null;
085            try {
086                Type t = this.getField(1, 0);
087                ret = (ID)t;
088            } catch (ClassCastException cce) {
089                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
090                throw new RuntimeException(cce);
091            } catch (HL7Exception he) {
092                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
093                throw new RuntimeException(he);
094            }
095            return ret;
096        }
097    
098    
099    
100        /**
101         * Returns
102         * MFA-2: "MFN Control ID" - creates it if necessary
103         */
104        public ST getMFNControlID() { 
105            ST ret = null;
106            try {
107                Type t = this.getField(2, 0);
108                ret = (ST)t;
109            } catch (ClassCastException cce) {
110                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
111                throw new RuntimeException(cce);
112            } catch (HL7Exception he) {
113                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
114                throw new RuntimeException(he);
115            }
116            return ret;
117        }
118    
119    
120        /**
121         * Returns
122         * MFA-2: "MFN Control ID" - creates it if necessary
123         */
124        public ST getMfa2_MFNControlID() { 
125            ST ret = null;
126            try {
127                Type t = this.getField(2, 0);
128                ret = (ST)t;
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            return ret;
137        }
138    
139    
140    
141        /**
142         * Returns
143         * MFA-3: "Event Completion Date/Time" - creates it if necessary
144         */
145        public TS getEventCompletionDateTime() { 
146            TS ret = null;
147            try {
148                Type t = this.getField(3, 0);
149                ret = (TS)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        /**
162         * Returns
163         * MFA-3: "Event Completion Date/Time" - creates it if necessary
164         */
165        public TS getMfa3_EventCompletionDateTime() { 
166            TS ret = null;
167            try {
168                Type t = this.getField(3, 0);
169                ret = (TS)t;
170            } catch (ClassCastException cce) {
171                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
172                throw new RuntimeException(cce);
173            } catch (HL7Exception he) {
174                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
175                throw new RuntimeException(he);
176            }
177            return ret;
178        }
179    
180    
181    
182        /**
183         * Returns
184         * MFA-4: "MFN Record Level Error Return" - creates it if necessary
185         */
186        public CE getMFNRecordLevelErrorReturn() { 
187            CE ret = null;
188            try {
189                Type t = this.getField(4, 0);
190                ret = (CE)t;
191            } catch (ClassCastException cce) {
192                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
193                throw new RuntimeException(cce);
194            } catch (HL7Exception he) {
195                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
196                throw new RuntimeException(he);
197            }
198            return ret;
199        }
200    
201    
202        /**
203         * Returns
204         * MFA-4: "MFN Record Level Error Return" - creates it if necessary
205         */
206        public CE getMfa4_MFNRecordLevelErrorReturn() { 
207            CE ret = null;
208            try {
209                Type t = this.getField(4, 0);
210                ret = (CE)t;
211            } catch (ClassCastException cce) {
212                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
213                throw new RuntimeException(cce);
214            } catch (HL7Exception he) {
215                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
216                throw new RuntimeException(he);
217            }
218            return ret;
219        }
220    
221    
222        /**
223         * Returns all repetitions of Primary Key Value - MFA (MFA-5).
224         */
225        public CE[] getPrimaryKeyValueMFA() {
226            CE[] ret = null;
227            try {
228                Type[] t = this.getField(5);  
229                ret = new CE[t.length];
230                for (int i = 0; i < ret.length; i++) {
231                    ret[i] = (CE)t[i];
232                }
233            } catch (ClassCastException cce) {
234                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
235                throw new RuntimeException(cce);
236            } catch (HL7Exception he) {
237                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
238                throw new RuntimeException(he);
239            }
240            return ret;
241        }
242    
243    
244        /**
245         * Returns a count of the current number of repetitions of Primary Key Value - MFA (MFA-5).
246         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
247         * it will return zero.
248         */
249        public int getPrimaryKeyValueMFAReps() {
250            CE[] ret = null;
251            try {
252                Type[] t = this.getField(5);
253                return t.length;  
254            } catch (ClassCastException cce) {
255                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
256                throw new RuntimeException(cce);
257            } catch (HL7Exception he) {
258                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
259                throw new RuntimeException(he);
260            }
261        }
262    
263    
264        /**
265         * Returns a specific repetition of
266         * MFA-5: "Primary Key Value - MFA" - creates it if necessary
267         *
268         * @param rep The repetition index (0-indexed)
269         */
270        public CE getPrimaryKeyValueMFA(int rep) { 
271            CE ret = null;
272            try {
273                Type t = this.getField(5, rep);
274                ret = (CE)t;
275            } catch (ClassCastException cce) {
276                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
277                throw new RuntimeException(cce);
278            } catch (HL7Exception he) {
279                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
280                throw new RuntimeException(he);
281            }
282            return ret;
283        }
284    
285        /**
286         * Returns a specific repetition of
287         * MFA-5: "Primary Key Value - MFA" - creates it if necessary
288         *
289         * @param rep The repetition index (0-indexed)
290         */
291        public CE getMfa5_PrimaryKeyValueMFA(int rep) { 
292            CE ret = null;
293            try {
294                Type t = this.getField(5, rep);
295                ret = (CE)t;
296            } catch (ClassCastException cce) {
297                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
298                throw new RuntimeException(cce);
299            } catch (HL7Exception he) {
300                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
301                throw new RuntimeException(he);
302            }
303            return ret;
304        }
305    
306    
307        /**
308         * Returns a count of the current number of repetitions of Primary Key Value - MFA (MFA-5).
309         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
310         * it will return zero.
311         */
312        public int getMfa5_PrimaryKeyValueMFAReps() {
313            CE[] ret = null;
314            try {
315                Type[] t = this.getField(5);
316                return t.length;  
317            } catch (ClassCastException cce) {
318                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
319                throw new RuntimeException(cce);
320            } catch (HL7Exception he) {
321                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
322                throw new RuntimeException(he);
323            }
324        }
325    
326    
327    
328        /**
329         * Inserts a repetition of
330         * MFA-5: "Primary Key Value - MFA" at a specific index
331         *
332         * @param rep The repetition index (0-indexed)
333         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
334         */
335        public CE insertPrimaryKeyValueMFA(int rep) throws HL7Exception { 
336            return (CE) super.insertRepetition(5, rep);
337        }
338    
339    
340    
341        /**
342         * Inserts a repetition of
343         * MFA-5: "Primary Key Value - MFA" at a specific index
344         *
345         * @param rep The repetition index (0-indexed)
346         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
347         */
348        public CE insertMfa5_PrimaryKeyValueMFA(int rep) throws HL7Exception { 
349            return (CE) super.insertRepetition(5, rep);
350        }
351    
352    
353        /**
354         * Removes a repetition of
355         * MFA-5: "Primary Key Value - MFA" at a specific index
356         *
357         * @param rep The repetition index (0-indexed)
358         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
359         */
360        public CE removePrimaryKeyValueMFA(int rep) throws HL7Exception { 
361            return (CE) super.removeRepetition(5, rep);
362        }
363    
364    
365        /**
366         * Removes a repetition of
367         * MFA-5: "Primary Key Value - MFA" at a specific index
368         *
369         * @param rep The repetition index (0-indexed)
370         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
371         */
372        public CE removeMfa5_PrimaryKeyValueMFA(int rep) throws HL7Exception { 
373            return (CE) super.removeRepetition(5, rep);
374        }
375    
376    
377    
378        /**
379         * Returns all repetitions of Primary Key Value Type - MFA (MFA-6).
380         */
381        public ID[] getPrimaryKeyValueTypeMFA() {
382            ID[] ret = null;
383            try {
384                Type[] t = this.getField(6);  
385                ret = new ID[t.length];
386                for (int i = 0; i < ret.length; i++) {
387                    ret[i] = (ID)t[i];
388                }
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            return ret;
397        }
398    
399    
400        /**
401         * Returns a count of the current number of repetitions of Primary Key Value Type - MFA (MFA-6).
402         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
403         * it will return zero.
404         */
405        public int getPrimaryKeyValueTypeMFAReps() {
406            ID[] ret = null;
407            try {
408                Type[] t = this.getField(6);
409                return t.length;  
410            } catch (ClassCastException cce) {
411                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
412                throw new RuntimeException(cce);
413            } catch (HL7Exception he) {
414                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
415                throw new RuntimeException(he);
416            }
417        }
418    
419    
420        /**
421         * Returns a specific repetition of
422         * MFA-6: "Primary Key Value Type - MFA" - creates it if necessary
423         *
424         * @param rep The repetition index (0-indexed)
425         */
426        public ID getPrimaryKeyValueTypeMFA(int rep) { 
427            ID ret = null;
428            try {
429                Type t = this.getField(6, rep);
430                ret = (ID)t;
431            } catch (ClassCastException cce) {
432                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
433                throw new RuntimeException(cce);
434            } catch (HL7Exception he) {
435                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
436                throw new RuntimeException(he);
437            }
438            return ret;
439        }
440    
441        /**
442         * Returns a specific repetition of
443         * MFA-6: "Primary Key Value Type - MFA" - creates it if necessary
444         *
445         * @param rep The repetition index (0-indexed)
446         */
447        public ID getMfa6_PrimaryKeyValueTypeMFA(int rep) { 
448            ID ret = null;
449            try {
450                Type t = this.getField(6, rep);
451                ret = (ID)t;
452            } catch (ClassCastException cce) {
453                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
454                throw new RuntimeException(cce);
455            } catch (HL7Exception he) {
456                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
457                throw new RuntimeException(he);
458            }
459            return ret;
460        }
461    
462    
463        /**
464         * Returns a count of the current number of repetitions of Primary Key Value Type - MFA (MFA-6).
465         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
466         * it will return zero.
467         */
468        public int getMfa6_PrimaryKeyValueTypeMFAReps() {
469            ID[] ret = null;
470            try {
471                Type[] t = this.getField(6);
472                return t.length;  
473            } catch (ClassCastException cce) {
474                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
475                throw new RuntimeException(cce);
476            } catch (HL7Exception he) {
477                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
478                throw new RuntimeException(he);
479            }
480        }
481    
482    
483    
484        /**
485         * Inserts a repetition of
486         * MFA-6: "Primary Key Value Type - MFA" at a specific index
487         *
488         * @param rep The repetition index (0-indexed)
489         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
490         */
491        public ID insertPrimaryKeyValueTypeMFA(int rep) throws HL7Exception { 
492            return (ID) super.insertRepetition(6, rep);
493        }
494    
495    
496    
497        /**
498         * Inserts a repetition of
499         * MFA-6: "Primary Key Value Type - MFA" at a specific index
500         *
501         * @param rep The repetition index (0-indexed)
502         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
503         */
504        public ID insertMfa6_PrimaryKeyValueTypeMFA(int rep) throws HL7Exception { 
505            return (ID) super.insertRepetition(6, rep);
506        }
507    
508    
509        /**
510         * Removes a repetition of
511         * MFA-6: "Primary Key Value Type - MFA" at a specific index
512         *
513         * @param rep The repetition index (0-indexed)
514         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
515         */
516        public ID removePrimaryKeyValueTypeMFA(int rep) throws HL7Exception { 
517            return (ID) super.removeRepetition(6, rep);
518        }
519    
520    
521        /**
522         * Removes a repetition of
523         * MFA-6: "Primary Key Value Type - MFA" at a specific index
524         *
525         * @param rep The repetition index (0-indexed)
526         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
527         */
528        public ID removeMfa6_PrimaryKeyValueTypeMFA(int rep) throws HL7Exception { 
529            return (ID) super.removeRepetition(6, rep);
530        }
531    
532    
533    
534    
535    
536    
537        /** {@inheritDoc} */   
538        protected Type createNewTypeWithoutReflection(int field) {
539           switch (field) {
540              case 0: return new ID(getMessage(), new Integer( 180 ));
541              case 1: return new ST(getMessage());
542              case 2: return new TS(getMessage());
543              case 3: return new CE(getMessage());
544              case 4: return new CE(getMessage());
545              case 5: return new ID(getMessage(), new Integer( 355 ));
546              default: return null;
547           }
548       }
549    
550    
551    }
552