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 MFR_M01 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: MSA (Message Acknowledgment) <b> </b></li>
025                     * <li>3: ERR (Error) <b>optional </b></li>
026                     * <li>4: QAK (Query Acknowledgment) <b>optional </b></li>
027                     * <li>5: QRD (Original-Style Query Definition) <b> </b></li>
028                     * <li>6: QRF (Original Style Query Filter) <b>optional </b></li>
029                     * <li>7: MFI (Master File Identification) <b> </b></li>
030                     * <li>8: MFR_M01_MF_QUERY (a Group object) <b> repeating</b></li>
031                     * <li>9: DSC (Continuation Pointer) <b>optional </b></li>
032     * </ul>
033     */
034    public class MFR_M01 extends AbstractMessage  {
035    
036        /**
037         * Creates a new MFR_M01 message with DefaultModelClassFactory. 
038         */ 
039        public MFR_M01() { 
040           this(new DefaultModelClassFactory());
041        }
042    
043        /** 
044         * Creates a new MFR_M01 message with custom ModelClassFactory.
045         */
046        public MFR_M01(ModelClassFactory factory) {
047           super(factory);
048           init(factory);
049        }
050    
051        private void init(ModelClassFactory factory) {
052           try {
053                              this.add(MSH.class, true, false);
054                              this.add(MSA.class, true, false);
055                              this.add(ERR.class, false, false);
056                              this.add(QAK.class, false, false);
057                              this.add(QRD.class, true, false);
058                              this.add(QRF.class, false, false);
059                              this.add(MFI.class, true, false);
060                              this.add(MFR_M01_MF_QUERY.class, true, true);
061                              this.add(DSC.class, false, false);
062           } catch(HL7Exception e) {
063              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating MFR_M01 - this is probably a bug in the source code generator.", e);
064           }
065        }
066    
067        /** 
068         * Returns "2.4"
069         */
070        public String getVersion() {
071           return "2.4";
072        }
073    
074    
075    
076        /**
077         * Returns
078         * MSH (Message Header) - creates it if necessary
079         */
080        public MSH getMSH() { 
081           MSH ret = null;
082           try {
083              ret = (MSH)this.get("MSH");
084           } catch(HL7Exception e) {
085              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
086              throw new RuntimeException(e);
087           }
088           return ret;
089        }
090    
091    
092    
093    
094        /**
095         * Returns
096         * MSA (Message Acknowledgment) - creates it if necessary
097         */
098        public MSA getMSA() { 
099           MSA ret = null;
100           try {
101              ret = (MSA)this.get("MSA");
102           } catch(HL7Exception e) {
103              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
104              throw new RuntimeException(e);
105           }
106           return ret;
107        }
108    
109    
110    
111    
112        /**
113         * Returns
114         * ERR (Error) - creates it if necessary
115         */
116        public ERR getERR() { 
117           ERR ret = null;
118           try {
119              ret = (ERR)this.get("ERR");
120           } catch(HL7Exception e) {
121              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
122              throw new RuntimeException(e);
123           }
124           return ret;
125        }
126    
127    
128    
129    
130        /**
131         * Returns
132         * QAK (Query Acknowledgment) - creates it if necessary
133         */
134        public QAK getQAK() { 
135           QAK ret = null;
136           try {
137              ret = (QAK)this.get("QAK");
138           } catch(HL7Exception e) {
139              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
140              throw new RuntimeException(e);
141           }
142           return ret;
143        }
144    
145    
146    
147    
148        /**
149         * Returns
150         * QRD (Original-Style Query Definition) - creates it if necessary
151         */
152        public QRD getQRD() { 
153           QRD ret = null;
154           try {
155              ret = (QRD)this.get("QRD");
156           } catch(HL7Exception e) {
157              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
158              throw new RuntimeException(e);
159           }
160           return ret;
161        }
162    
163    
164    
165    
166        /**
167         * Returns
168         * QRF (Original Style Query Filter) - creates it if necessary
169         */
170        public QRF getQRF() { 
171           QRF ret = null;
172           try {
173              ret = (QRF)this.get("QRF");
174           } catch(HL7Exception e) {
175              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
176              throw new RuntimeException(e);
177           }
178           return ret;
179        }
180    
181    
182    
183    
184        /**
185         * Returns
186         * MFI (Master File Identification) - creates it if necessary
187         */
188        public MFI getMFI() { 
189           MFI ret = null;
190           try {
191              ret = (MFI)this.get("MFI");
192           } catch(HL7Exception e) {
193              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
194              throw new RuntimeException(e);
195           }
196           return ret;
197        }
198    
199    
200    
201    
202        /**
203         * Returns
204         * the first repetition of 
205         * MF_QUERY (a Group object) - creates it if necessary
206         */
207        public MFR_M01_MF_QUERY getMF_QUERY() { 
208           MFR_M01_MF_QUERY ret = null;
209           try {
210              ret = (MFR_M01_MF_QUERY)this.get("MF_QUERY");
211           } catch(HL7Exception e) {
212              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
213              throw new RuntimeException(e);
214           }
215           return ret;
216        }
217    
218    
219        /**
220         * Returns a specific repetition of
221         * MF_QUERY (a Group object) - creates it if necessary
222         *
223         * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0)
224         * @throws HL7Exception if the repetition requested is more than one 
225         *     greater than the number of existing repetitions.
226         */
227        public MFR_M01_MF_QUERY getMF_QUERY(int rep) { 
228           MFR_M01_MF_QUERY ret = null;
229           try {
230              ret = (MFR_M01_MF_QUERY)this.get("MF_QUERY", rep);
231           } catch(HL7Exception e) {
232              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
233              throw new RuntimeException(e);
234           }
235           return ret;
236        }
237    
238        /** 
239         * Returns the number of existing repetitions of MF_QUERY 
240         */ 
241        public int getMF_QUERYReps() { 
242            int reps = -1; 
243            try { 
244                reps = this.getAll("MF_QUERY").length; 
245            } catch (HL7Exception e) { 
246                String message = "Unexpected error accessing data - this is probably a bug in the source code generator."; 
247                HapiLogFactory.getHapiLog(this.getClass()).error(message, e); 
248                throw new RuntimeException(message);
249            } 
250            return reps; 
251        } 
252    
253        /**
254         * Inserts a specific repetition of MF_QUERY (a Group object)
255         * @see AbstractGroup\#insertRepetition(Structure, int) 
256         */
257        public void insertMF_QUERY(MFR_M01_MF_QUERY structure, int rep) throws HL7Exception { 
258           super.insertRepetition( "MF_QUERY", structure, rep);
259        }
260    
261    
262        /**
263         * Inserts a specific repetition of MF_QUERY (a Group object)
264         * @see AbstractGroup\#insertRepetition(Structure, int) 
265         */
266        public MFR_M01_MF_QUERY insertMF_QUERY(int rep) throws HL7Exception { 
267           return (MFR_M01_MF_QUERY)super.insertRepetition("MF_QUERY", rep);
268        }
269    
270    
271        /**
272         * Removes a specific repetition of MF_QUERY (a Group object)
273         * @see AbstractGroup\#removeRepetition(String, int) 
274         */
275        public MFR_M01_MF_QUERY removeMF_QUERY(int rep) throws HL7Exception { 
276           return (MFR_M01_MF_QUERY)super.removeRepetition("MF_QUERY", rep);
277        }
278    
279    
280    
281        /**
282         * Returns
283         * DSC (Continuation Pointer) - creates it if necessary
284         */
285        public DSC getDSC() { 
286           DSC ret = null;
287           try {
288              ret = (DSC)this.get("DSC");
289           } catch(HL7Exception e) {
290              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error accessing data - this is probably a bug in the source code generator.", e);
291              throw new RuntimeException(e);
292           }
293           return ret;
294        }
295    
296    
297    
298    
299    }
300