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.v231.message;
009    
010    import ca.uhn.hl7v2.model.v231.group.*;
011    import ca.uhn.hl7v2.model.v231.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 MFK_M06 message structure (see chapter ?). This structure contains the 
021     * following elements: </p>
022     * <ul>
023                     * <li>1: MSH (MSH - message header segment) <b> </b></li>
024                     * <li>2: MSA (MSA - message acknowledgment segment) <b> </b></li>
025                     * <li>3: MFI (MFI - master file identification segment) <b> </b></li>
026                     * <li>4: MFA (MFA - master file acknowledgment segment) <b>optional repeating</b></li>
027     * </ul>
028     */
029    public class MFK_M06 extends AbstractMessage  {
030    
031        /**
032         * Creates a new MFK_M06 message with DefaultModelClassFactory. 
033         */ 
034        public MFK_M06() { 
035           this(new DefaultModelClassFactory());
036        }
037    
038        /** 
039         * Creates a new MFK_M06 message with custom ModelClassFactory.
040         */
041        public MFK_M06(ModelClassFactory factory) {
042           super(factory);
043           init(factory);
044        }
045    
046        private void init(ModelClassFactory factory) {
047           try {
048                              this.add(MSH.class, true, false);
049                              this.add(MSA.class, true, false);
050                              this.add(MFI.class, true, false);
051                              this.add(MFA.class, false, true);
052           } catch(HL7Exception e) {
053              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating MFK_M06 - this is probably a bug in the source code generator.", e);
054           }
055        }
056    
057        /** 
058         * Returns "2.3.1"
059         */
060        public String getVersion() {
061           return "2.3.1";
062        }
063    
064    
065    
066        /**
067         * Returns
068         * MSH (MSH - message header segment) - creates it if necessary
069         */
070        public MSH getMSH() { 
071           MSH ret = null;
072           try {
073              ret = (MSH)this.get("MSH");
074           } catch(HL7Exception e) {
075              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
076              throw new RuntimeException(e);
077           }
078           return ret;
079        }
080    
081    
082    
083    
084        /**
085         * Returns
086         * MSA (MSA - message acknowledgment segment) - creates it if necessary
087         */
088        public MSA getMSA() { 
089           MSA ret = null;
090           try {
091              ret = (MSA)this.get("MSA");
092           } catch(HL7Exception e) {
093              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
094              throw new RuntimeException(e);
095           }
096           return ret;
097        }
098    
099    
100    
101    
102        /**
103         * Returns
104         * MFI (MFI - master file identification segment) - creates it if necessary
105         */
106        public MFI getMFI() { 
107           MFI ret = null;
108           try {
109              ret = (MFI)this.get("MFI");
110           } catch(HL7Exception e) {
111              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
112              throw new RuntimeException(e);
113           }
114           return ret;
115        }
116    
117    
118    
119    
120        /**
121         * Returns
122         * the first repetition of 
123         * MFA (MFA - master file acknowledgment segment) - creates it if necessary
124         */
125        public MFA getMFA() { 
126           MFA ret = null;
127           try {
128              ret = (MFA)this.get("MFA");
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        /**
138         * Returns a specific repetition of
139         * MFA (MFA - master file acknowledgment segment) - creates it if necessary
140         *
141         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
142         * @throws HL7Exception if the repetition requested is more than one 
143         *     greater than the number of existing repetitions.
144         */
145        public MFA getMFA(int rep) { 
146           MFA ret = null;
147           try {
148              ret = (MFA)this.get("MFA", rep);
149           } catch(HL7Exception e) {
150              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
151              throw new RuntimeException(e);
152           }
153           return ret;
154        }
155    
156        /** 
157         * Returns the number of existing repetitions of MFA 
158         */ 
159        public int getMFAReps() { 
160            int reps = -1; 
161            try { 
162                reps = this.getAll("MFA").length; 
163            } catch (HL7Exception e) { 
164                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
165                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
166                throw new RuntimeException(message);
167            } 
168            return reps; 
169        } 
170    
171        /**
172         * Inserts a specific repetition of MFA (MFA - master file acknowledgment segment)
173         * @see AbstractGroup\#insertRepetition(Structure, int) 
174         */
175        public void insertMFA(MFA structure, int rep) throws HL7Exception { 
176           super.insertRepetition( "MFA", structure, rep);
177        }
178    
179    
180        /**
181         * Inserts a specific repetition of MFA (MFA - master file acknowledgment segment)
182         * @see AbstractGroup\#insertRepetition(Structure, int) 
183         */
184        public MFA insertMFA(int rep) throws HL7Exception { 
185           return (MFA)super.insertRepetition("MFA", rep);
186        }
187    
188    
189        /**
190         * Removes a specific repetition of MFA (MFA - master file acknowledgment segment)
191         * @see AbstractGroup\#removeRepetition(String, int) 
192         */
193        public MFA removeMFA(int rep) throws HL7Exception { 
194           return (MFA)super.removeRepetition("MFA", rep);
195        }
196    
197    
198    
199    }
200