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 ECD message segment (Equipment Command).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>ECD-1: Reference Command Number (NM) <b> </b>
027 * <li>ECD-2: Remote Control Command (CE) <b> </b>
028 * <li>ECD-3: Response Required (ID) <b>optional </b>
029 * <li>ECD-4: Requested Completion Time (TQ) <b>optional </b>
030 * <li>ECD-5: Parameters (ST) <b>optional repeating</b>
031 * </ul>
032 */
033 public class ECD extends AbstractSegment {
034
035 /**
036 * Creates a new ECD segment
037 */
038 public ECD(Group parent, ModelClassFactory factory) {
039 super(parent, factory);
040 init(factory);
041 }
042
043 private void init(ModelClassFactory factory) {
044 try {
045 this.add(NM.class, true, 1, 20, new Object[]{ getMessage(), new Integer(0) }, "Reference Command Number");
046 this.add(CE.class, true, 1, 250, new Object[]{ getMessage(), new Integer(368) }, "Remote Control Command");
047 this.add(ID.class, false, 1, 80, new Object[]{ getMessage() }, "Response Required");
048 this.add(TQ.class, false, 1, 200, new Object[]{ getMessage(), new Integer(0) }, "Requested Completion Time");
049 this.add(ST.class, false, 0, 65536, new Object[]{ getMessage(), new Integer(0) }, "Parameters");
050 } catch(HL7Exception e) {
051 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating ECD - this is probably a bug in the source code generator.", e);
052 }
053 }
054
055
056
057 /**
058 * Returns
059 * ECD-1: "Reference Command Number" - creates it if necessary
060 */
061 public NM getReferenceCommandNumber() {
062 NM ret = null;
063 try {
064 Type t = this.getField(1, 0);
065 ret = (NM)t;
066 } catch (ClassCastException cce) {
067 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
068 throw new RuntimeException(cce);
069 } catch (HL7Exception he) {
070 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
071 throw new RuntimeException(he);
072 }
073 return ret;
074 }
075
076
077 /**
078 * Returns
079 * ECD-1: "Reference Command Number" - creates it if necessary
080 */
081 public NM getEcd1_ReferenceCommandNumber() {
082 NM ret = null;
083 try {
084 Type t = this.getField(1, 0);
085 ret = (NM)t;
086 } catch (ClassCastException cce) {
087 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
088 throw new RuntimeException(cce);
089 } catch (HL7Exception he) {
090 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
091 throw new RuntimeException(he);
092 }
093 return ret;
094 }
095
096
097
098 /**
099 * Returns
100 * ECD-2: "Remote Control Command" - creates it if necessary
101 */
102 public CE getRemoteControlCommand() {
103 CE ret = null;
104 try {
105 Type t = this.getField(2, 0);
106 ret = (CE)t;
107 } catch (ClassCastException cce) {
108 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
109 throw new RuntimeException(cce);
110 } catch (HL7Exception he) {
111 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
112 throw new RuntimeException(he);
113 }
114 return ret;
115 }
116
117
118 /**
119 * Returns
120 * ECD-2: "Remote Control Command" - creates it if necessary
121 */
122 public CE getEcd2_RemoteControlCommand() {
123 CE ret = null;
124 try {
125 Type t = this.getField(2, 0);
126 ret = (CE)t;
127 } catch (ClassCastException cce) {
128 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
129 throw new RuntimeException(cce);
130 } catch (HL7Exception he) {
131 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
132 throw new RuntimeException(he);
133 }
134 return ret;
135 }
136
137
138
139 /**
140 * Returns
141 * ECD-3: "Response Required" - creates it if necessary
142 */
143 public ID getResponseRequired() {
144 ID ret = null;
145 try {
146 Type t = this.getField(3, 0);
147 ret = (ID)t;
148 } catch (ClassCastException cce) {
149 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
150 throw new RuntimeException(cce);
151 } catch (HL7Exception he) {
152 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
153 throw new RuntimeException(he);
154 }
155 return ret;
156 }
157
158
159 /**
160 * Returns
161 * ECD-3: "Response Required" - creates it if necessary
162 */
163 public ID getEcd3_ResponseRequired() {
164 ID ret = null;
165 try {
166 Type t = this.getField(3, 0);
167 ret = (ID)t;
168 } catch (ClassCastException cce) {
169 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
170 throw new RuntimeException(cce);
171 } catch (HL7Exception he) {
172 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
173 throw new RuntimeException(he);
174 }
175 return ret;
176 }
177
178
179
180 /**
181 * Returns
182 * ECD-4: "Requested Completion Time" - creates it if necessary
183 */
184 public TQ getRequestedCompletionTime() {
185 TQ ret = null;
186 try {
187 Type t = this.getField(4, 0);
188 ret = (TQ)t;
189 } catch (ClassCastException cce) {
190 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
191 throw new RuntimeException(cce);
192 } catch (HL7Exception he) {
193 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
194 throw new RuntimeException(he);
195 }
196 return ret;
197 }
198
199
200 /**
201 * Returns
202 * ECD-4: "Requested Completion Time" - creates it if necessary
203 */
204 public TQ getEcd4_RequestedCompletionTime() {
205 TQ ret = null;
206 try {
207 Type t = this.getField(4, 0);
208 ret = (TQ)t;
209 } catch (ClassCastException cce) {
210 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
211 throw new RuntimeException(cce);
212 } catch (HL7Exception he) {
213 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
214 throw new RuntimeException(he);
215 }
216 return ret;
217 }
218
219
220 /**
221 * Returns all repetitions of Parameters (ECD-5).
222 */
223 public ST[] getParameters() {
224 ST[] ret = null;
225 try {
226 Type[] t = this.getField(5);
227 ret = new ST[t.length];
228 for (int i = 0; i < ret.length; i++) {
229 ret[i] = (ST)t[i];
230 }
231 } catch (ClassCastException cce) {
232 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
233 throw new RuntimeException(cce);
234 } catch (HL7Exception he) {
235 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
236 throw new RuntimeException(he);
237 }
238 return ret;
239 }
240
241
242 /**
243 * Returns a count of the current number of repetitions of Parameters (ECD-5).
244 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
245 * it will return zero.
246 */
247 public int getParametersReps() {
248 ST[] ret = null;
249 try {
250 Type[] t = this.getField(5);
251 return t.length;
252 } catch (ClassCastException cce) {
253 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
254 throw new RuntimeException(cce);
255 } catch (HL7Exception he) {
256 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
257 throw new RuntimeException(he);
258 }
259 }
260
261
262 /**
263 * Returns a specific repetition of
264 * ECD-5: "Parameters" - creates it if necessary
265 *
266 * @param rep The repetition index (0-indexed)
267 */
268 public ST getParameters(int rep) {
269 ST ret = null;
270 try {
271 Type t = this.getField(5, rep);
272 ret = (ST)t;
273 } catch (ClassCastException cce) {
274 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
275 throw new RuntimeException(cce);
276 } catch (HL7Exception he) {
277 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
278 throw new RuntimeException(he);
279 }
280 return ret;
281 }
282
283 /**
284 * Returns a specific repetition of
285 * ECD-5: "Parameters" - creates it if necessary
286 *
287 * @param rep The repetition index (0-indexed)
288 */
289 public ST getEcd5_Parameters(int rep) {
290 ST ret = null;
291 try {
292 Type t = this.getField(5, rep);
293 ret = (ST)t;
294 } catch (ClassCastException cce) {
295 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
296 throw new RuntimeException(cce);
297 } catch (HL7Exception he) {
298 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
299 throw new RuntimeException(he);
300 }
301 return ret;
302 }
303
304
305 /**
306 * Returns a count of the current number of repetitions of Parameters (ECD-5).
307 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
308 * it will return zero.
309 */
310 public int getEcd5_ParametersReps() {
311 ST[] ret = null;
312 try {
313 Type[] t = this.getField(5);
314 return t.length;
315 } catch (ClassCastException cce) {
316 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
317 throw new RuntimeException(cce);
318 } catch (HL7Exception he) {
319 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
320 throw new RuntimeException(he);
321 }
322 }
323
324
325
326 /**
327 * Inserts a repetition of
328 * ECD-5: "Parameters" at a specific index
329 *
330 * @param rep The repetition index (0-indexed)
331 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
332 */
333 public ST insertParameters(int rep) throws HL7Exception {
334 return (ST) super.insertRepetition(5, rep);
335 }
336
337
338
339 /**
340 * Inserts a repetition of
341 * ECD-5: "Parameters" at a specific index
342 *
343 * @param rep The repetition index (0-indexed)
344 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
345 */
346 public ST insertEcd5_Parameters(int rep) throws HL7Exception {
347 return (ST) super.insertRepetition(5, rep);
348 }
349
350
351 /**
352 * Removes a repetition of
353 * ECD-5: "Parameters" at a specific index
354 *
355 * @param rep The repetition index (0-indexed)
356 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
357 */
358 public ST removeParameters(int rep) throws HL7Exception {
359 return (ST) super.removeRepetition(5, rep);
360 }
361
362
363 /**
364 * Removes a repetition of
365 * ECD-5: "Parameters" at a specific index
366 *
367 * @param rep The repetition index (0-indexed)
368 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
369 */
370 public ST removeEcd5_Parameters(int rep) throws HL7Exception {
371 return (ST) super.removeRepetition(5, rep);
372 }
373
374
375
376
377
378
379 /** {@inheritDoc} */
380 protected Type createNewTypeWithoutReflection(int field) {
381 switch (field) {
382 case 0: return new NM(getMessage());
383 case 1: return new CE(getMessage());
384 case 2: return new ID(getMessage(), new Integer( 136 ));
385 case 3: return new TQ(getMessage());
386 case 4: return new ST(getMessage());
387 default: return null;
388 }
389 }
390
391
392 }
393