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.message;
009    
010    import ca.uhn.hl7v2.model.v24.group.*;
011    import ca.uhn.hl7v2.model.v24.segment.*;
012    
013    import ca.uhn.log.HapiLogFactory;
014    import ca.uhn.hl7v2.HL7Exception;
015    import ca.uhn.hl7v2.parser.ModelClassFactory;
016    import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
017    import ca.uhn.hl7v2.model.AbstractMessage;
018    
019    /**
020     * <p>Represents a MFN_M09 message structure (see chapter 8). This structure contains the 
021     * following elements: </p>
022     * <ul>
023                     * <li>1: MSH (Message Header) <b> </b></li>
024                     * <li>2: MFI (Master File Identification) <b> </b></li>
025                     * <li>3: MFN_M09_MF_TEST_CATEGORICAL (a Group object) <b> repeating</b></li>
026     * </ul>
027     */
028    public class MFN_M09 extends AbstractMessage  {
029    
030        /**
031         * Creates a new MFN_M09 message with DefaultModelClassFactory. 
032         */ 
033        public MFN_M09() { 
034           this(new DefaultModelClassFactory());
035        }
036    
037        /** 
038         * Creates a new MFN_M09 message with custom ModelClassFactory.
039         */
040        public MFN_M09(ModelClassFactory factory) {
041           super(factory);
042           init(factory);
043        }
044    
045        private void init(ModelClassFactory factory) {
046           try {
047                              this.add(MSH.class, true, false);
048                              this.add(MFI.class, true, false);
049                              this.add(MFN_M09_MF_TEST_CATEGORICAL.class, true, true);
050           } catch(HL7Exception e) {
051              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating MFN_M09 - this is probably a bug in the source code generator.", e);
052           }
053        }
054    
055        /** 
056         * Returns "2.4"
057         */
058        public String getVersion() {
059           return "2.4";
060        }
061    
062    
063    
064        /**
065         * Returns
066         * MSH (Message Header) - creates it if necessary
067         */
068        public MSH getMSH() { 
069           MSH ret = null;
070           try {
071              ret = (MSH)this.get("MSH");
072           } catch(HL7Exception e) {
073              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
074              throw new RuntimeException(e);
075           }
076           return ret;
077        }
078    
079    
080    
081    
082        /**
083         * Returns
084         * MFI (Master File Identification) - creates it if necessary
085         */
086        public MFI getMFI() { 
087           MFI ret = null;
088           try {
089              ret = (MFI)this.get("MFI");
090           } catch(HL7Exception e) {
091              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
092              throw new RuntimeException(e);
093           }
094           return ret;
095        }
096    
097    
098    
099    
100        /**
101         * Returns
102         * the first repetition of 
103         * MF_TEST_CATEGORICAL (a Group object) - creates it if necessary
104         */
105        public MFN_M09_MF_TEST_CATEGORICAL getMF_TEST_CATEGORICAL() { 
106           MFN_M09_MF_TEST_CATEGORICAL ret = null;
107           try {
108              ret = (MFN_M09_MF_TEST_CATEGORICAL)this.get("MF_TEST_CATEGORICAL");
109           } catch(HL7Exception e) {
110              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
111              throw new RuntimeException(e);
112           }
113           return ret;
114        }
115    
116    
117        /**
118         * Returns a specific repetition of
119         * MF_TEST_CATEGORICAL (a Group object) - creates it if necessary
120         *
121         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
122         * @throws HL7Exception if the repetition requested is more than one 
123         *     greater than the number of existing repetitions.
124         */
125        public MFN_M09_MF_TEST_CATEGORICAL getMF_TEST_CATEGORICAL(int rep) { 
126           MFN_M09_MF_TEST_CATEGORICAL ret = null;
127           try {
128              ret = (MFN_M09_MF_TEST_CATEGORICAL)this.get("MF_TEST_CATEGORICAL", rep);
129           } catch(HL7Exception e) {
130              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
131              throw new RuntimeException(e);
132           }
133           return ret;
134        }
135    
136        /** 
137         * Returns the number of existing repetitions of MF_TEST_CATEGORICAL 
138         */ 
139        public int getMF_TEST_CATEGORICALReps() { 
140            int reps = -1; 
141            try { 
142                reps = this.getAll("MF_TEST_CATEGORICAL").length; 
143            } catch (HL7Exception e) { 
144                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
145                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
146                throw new RuntimeException(message);
147            } 
148            return reps; 
149        } 
150    
151        /**
152         * Inserts a specific repetition of MF_TEST_CATEGORICAL (a Group object)
153         * @see AbstractGroup\#insertRepetition(Structure, int) 
154         */
155        public void insertMF_TEST_CATEGORICAL(MFN_M09_MF_TEST_CATEGORICAL structure, int rep) throws HL7Exception { 
156           super.insertRepetition( "MF_TEST_CATEGORICAL", structure, rep);
157        }
158    
159    
160        /**
161         * Inserts a specific repetition of MF_TEST_CATEGORICAL (a Group object)
162         * @see AbstractGroup\#insertRepetition(Structure, int) 
163         */
164        public MFN_M09_MF_TEST_CATEGORICAL insertMF_TEST_CATEGORICAL(int rep) throws HL7Exception { 
165           return (MFN_M09_MF_TEST_CATEGORICAL)super.insertRepetition("MF_TEST_CATEGORICAL", rep);
166        }
167    
168    
169        /**
170         * Removes a specific repetition of MF_TEST_CATEGORICAL (a Group object)
171         * @see AbstractGroup\#removeRepetition(String, int) 
172         */
173        public MFN_M09_MF_TEST_CATEGORICAL removeMF_TEST_CATEGORICAL(int rep) throws HL7Exception { 
174           return (MFN_M09_MF_TEST_CATEGORICAL)super.removeRepetition("MF_TEST_CATEGORICAL", rep);
175        }
176    
177    
178    
179    }
180