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 ERQ message segment (Event Replay Query). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>ERQ-1: Query Tag (ST) <b>optional </b>
027         * <li>ERQ-2: Event Identifier (CE) <b> </b>
028         * <li>ERQ-3: Input Parameter List (QIP) <b>optional repeating</b>
029     * </ul>
030     */
031    public class ERQ extends AbstractSegment {
032    
033        /** 
034         * Creates a new ERQ segment
035         */
036        public ERQ(Group parent, ModelClassFactory factory) {
037           super(parent, factory);
038           init(factory);
039        }
040    
041        private void init(ModelClassFactory factory) {
042           try {
043                                      this.add(ST.class, false, 1, 32, new Object[]{ getMessage(), new Integer(0) }, "Query Tag");
044                                      this.add(CE.class, true, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Event Identifier");
045                                      this.add(QIP.class, false, 0, 256, new Object[]{ getMessage(), new Integer(0) }, "Input Parameter List");
046           } catch(HL7Exception e) {
047              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ERQ - this is probably a bug in the source code generator.", e);
048           }
049        }
050    
051    
052    
053        /**
054         * Returns
055         * ERQ-1: "Query Tag" - creates it if necessary
056         */
057        public ST getQueryTag() { 
058            ST ret = null;
059            try {
060                Type t = this.getField(1, 0);
061                ret = (ST)t;
062            } catch (ClassCastException cce) {
063                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
064                throw new RuntimeException(cce);
065            } catch (HL7Exception he) {
066                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
067                throw new RuntimeException(he);
068            }
069            return ret;
070        }
071    
072    
073        /**
074         * Returns
075         * ERQ-1: "Query Tag" - creates it if necessary
076         */
077        public ST getErq1_QueryTag() { 
078            ST ret = null;
079            try {
080                Type t = this.getField(1, 0);
081                ret = (ST)t;
082            } catch (ClassCastException cce) {
083                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
084                throw new RuntimeException(cce);
085            } catch (HL7Exception he) {
086                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
087                throw new RuntimeException(he);
088            }
089            return ret;
090        }
091    
092    
093    
094        /**
095         * Returns
096         * ERQ-2: "Event Identifier" - creates it if necessary
097         */
098        public CE getEventIdentifier() { 
099            CE ret = null;
100            try {
101                Type t = this.getField(2, 0);
102                ret = (CE)t;
103            } catch (ClassCastException cce) {
104                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
105                throw new RuntimeException(cce);
106            } catch (HL7Exception he) {
107                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
108                throw new RuntimeException(he);
109            }
110            return ret;
111        }
112    
113    
114        /**
115         * Returns
116         * ERQ-2: "Event Identifier" - creates it if necessary
117         */
118        public CE getErq2_EventIdentifier() { 
119            CE ret = null;
120            try {
121                Type t = this.getField(2, 0);
122                ret = (CE)t;
123            } catch (ClassCastException cce) {
124                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
125                throw new RuntimeException(cce);
126            } catch (HL7Exception he) {
127                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
128                throw new RuntimeException(he);
129            }
130            return ret;
131        }
132    
133    
134        /**
135         * Returns all repetitions of Input Parameter List (ERQ-3).
136         */
137        public QIP[] getInputParameterList() {
138            QIP[] ret = null;
139            try {
140                Type[] t = this.getField(3);  
141                ret = new QIP[t.length];
142                for (int i = 0; i < ret.length; i++) {
143                    ret[i] = (QIP)t[i];
144                }
145            } catch (ClassCastException cce) {
146                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
147                throw new RuntimeException(cce);
148            } catch (HL7Exception he) {
149                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
150                throw new RuntimeException(he);
151            }
152            return ret;
153        }
154    
155    
156        /**
157         * Returns a count of the current number of repetitions of Input Parameter List (ERQ-3).
158         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
159         * it will return zero.
160         */
161        public int getInputParameterListReps() {
162            QIP[] ret = null;
163            try {
164                Type[] t = this.getField(3);
165                return t.length;  
166            } catch (ClassCastException cce) {
167                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
168                throw new RuntimeException(cce);
169            } catch (HL7Exception he) {
170                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
171                throw new RuntimeException(he);
172            }
173        }
174    
175    
176        /**
177         * Returns a specific repetition of
178         * ERQ-3: "Input Parameter List" - creates it if necessary
179         *
180         * @param rep The repetition index (0-indexed)
181         */
182        public QIP getInputParameterList(int rep) { 
183            QIP ret = null;
184            try {
185                Type t = this.getField(3, rep);
186                ret = (QIP)t;
187            } catch (ClassCastException cce) {
188                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
189                throw new RuntimeException(cce);
190            } catch (HL7Exception he) {
191                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
192                throw new RuntimeException(he);
193            }
194            return ret;
195        }
196    
197        /**
198         * Returns a specific repetition of
199         * ERQ-3: "Input Parameter List" - creates it if necessary
200         *
201         * @param rep The repetition index (0-indexed)
202         */
203        public QIP getErq3_InputParameterList(int rep) { 
204            QIP ret = null;
205            try {
206                Type t = this.getField(3, rep);
207                ret = (QIP)t;
208            } catch (ClassCastException cce) {
209                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
210                throw new RuntimeException(cce);
211            } catch (HL7Exception he) {
212                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
213                throw new RuntimeException(he);
214            }
215            return ret;
216        }
217    
218    
219        /**
220         * Returns a count of the current number of repetitions of Input Parameter List (ERQ-3).
221         * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
222         * it will return zero.
223         */
224        public int getErq3_InputParameterListReps() {
225            QIP[] ret = null;
226            try {
227                Type[] t = this.getField(3);
228                return t.length;  
229            } catch (ClassCastException cce) {
230                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
231                throw new RuntimeException(cce);
232            } catch (HL7Exception he) {
233                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
234                throw new RuntimeException(he);
235            }
236        }
237    
238    
239    
240        /**
241         * Inserts a repetition of
242         * ERQ-3: "Input Parameter List" at a specific index
243         *
244         * @param rep The repetition index (0-indexed)
245         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
246         */
247        public QIP insertInputParameterList(int rep) throws HL7Exception { 
248            return (QIP) super.insertRepetition(3, rep);
249        }
250    
251    
252    
253        /**
254         * Inserts a repetition of
255         * ERQ-3: "Input Parameter List" at a specific index
256         *
257         * @param rep The repetition index (0-indexed)
258         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
259         */
260        public QIP insertErq3_InputParameterList(int rep) throws HL7Exception { 
261            return (QIP) super.insertRepetition(3, rep);
262        }
263    
264    
265        /**
266         * Removes a repetition of
267         * ERQ-3: "Input Parameter List" at a specific index
268         *
269         * @param rep The repetition index (0-indexed)
270         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
271         */
272        public QIP removeInputParameterList(int rep) throws HL7Exception { 
273            return (QIP) super.removeRepetition(3, rep);
274        }
275    
276    
277        /**
278         * Removes a repetition of
279         * ERQ-3: "Input Parameter List" at a specific index
280         *
281         * @param rep The repetition index (0-indexed)
282         * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
283         */
284        public QIP removeErq3_InputParameterList(int rep) throws HL7Exception { 
285            return (QIP) super.removeRepetition(3, rep);
286        }
287    
288    
289    
290    
291    
292    
293        /** {@inheritDoc} */   
294        protected Type createNewTypeWithoutReflection(int field) {
295           switch (field) {
296              case 0: return new ST(getMessage());
297              case 1: return new CE(getMessage());
298              case 2: return new QIP(getMessage());
299              default: return null;
300           }
301       }
302    
303    
304    }
305