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