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