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.datatype;
009
010 import ca.uhn.hl7v2.model.Composite;
011 import ca.uhn.hl7v2.model.DataTypeException;
012 import ca.uhn.hl7v2.model.Message;
013 import ca.uhn.hl7v2.model.Type;
014 import ca.uhn.hl7v2.model.AbstractType;
015 import ca.uhn.log.HapiLogFactory;
016
017 /**
018 * <p>Represents an HL7 TQ (timing quantity) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>quantity (CQ)
022 * <li>interval (RI)
023 * <li>duration (ST)
024 * <li>start date/time (TS)
025 * <li>end date/time (TS)
026 * <li>priority (ST)
027 * <li>condition (ST)
028 * <li>text (TX) (TX)
029 * <li>conjunction component (ID)
030 * <li>order sequencing (OSD)
031 * <li>occurrence duration (CE)
032 * <li>total occurences (NM)
033 * </ul>
034 */
035 public class TQ extends AbstractType implements Composite {
036
037 private Type[] data;
038
039 /**
040 * Creates a new TQ type
041 */
042 public TQ(Message message) {
043 super(message);
044 init();
045 }
046
047 private void init() {
048 data = new Type[12];
049 data[0] = new CQ(getMessage());
050 data[1] = new RI(getMessage());
051 data[2] = new ST(getMessage());
052 data[3] = new TS(getMessage());
053 data[4] = new TS(getMessage());
054 data[5] = new ST(getMessage());
055 data[6] = new ST(getMessage());
056 data[7] = new TX(getMessage());
057 data[8] = new ID(getMessage(), 0);
058 data[9] = new OSD(getMessage());
059 data[10] = new CE(getMessage());
060 data[11] = new NM(getMessage());
061 }
062
063
064 /**
065 * Returns an array containing the data elements.
066 */
067 public Type[] getComponents() {
068 return this.data;
069 }
070
071 /**
072 * Returns an individual data component.
073 *
074 * @param number The component number (0-indexed)
075 * @throws DataTypeException if the given element number is out of range.
076 */
077 public Type getComponent(int number) throws DataTypeException {
078
079 try {
080 return this.data[number];
081 } catch (ArrayIndexOutOfBoundsException e) {
082 throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)");
083 }
084 }
085
086
087 /**
088 * Returns quantity (component #1). This is a convenience method that saves you from
089 * casting and handling an exception.
090 */
091 public CQ getQuantity() {
092 CQ ret = null;
093 try {
094 ret = (CQ)getComponent(0);
095 } catch (DataTypeException e) {
096 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
097 throw new RuntimeException(e);
098 }
099 return ret;
100 }
101
102
103 /**
104 * Returns quantity (component #1). This is a convenience method that saves you from
105 * casting and handling an exception.
106 */
107 public CQ getTq1_Quantity() {
108 CQ ret = null;
109 try {
110 ret = (CQ)getComponent(0);
111 } catch (DataTypeException e) {
112 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
113 throw new RuntimeException(e);
114 }
115 return ret;
116 }
117
118
119 /**
120 * Returns interval (component #2). This is a convenience method that saves you from
121 * casting and handling an exception.
122 */
123 public RI getInterval() {
124 RI ret = null;
125 try {
126 ret = (RI)getComponent(1);
127 } catch (DataTypeException e) {
128 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
129 throw new RuntimeException(e);
130 }
131 return ret;
132 }
133
134
135 /**
136 * Returns interval (component #2). This is a convenience method that saves you from
137 * casting and handling an exception.
138 */
139 public RI getTq2_Interval() {
140 RI ret = null;
141 try {
142 ret = (RI)getComponent(1);
143 } catch (DataTypeException e) {
144 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
145 throw new RuntimeException(e);
146 }
147 return ret;
148 }
149
150
151 /**
152 * Returns duration (component #3). This is a convenience method that saves you from
153 * casting and handling an exception.
154 */
155 public ST getDuration() {
156 ST ret = null;
157 try {
158 ret = (ST)getComponent(2);
159 } catch (DataTypeException e) {
160 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
161 throw new RuntimeException(e);
162 }
163 return ret;
164 }
165
166
167 /**
168 * Returns duration (component #3). This is a convenience method that saves you from
169 * casting and handling an exception.
170 */
171 public ST getTq3_Duration() {
172 ST ret = null;
173 try {
174 ret = (ST)getComponent(2);
175 } catch (DataTypeException e) {
176 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
177 throw new RuntimeException(e);
178 }
179 return ret;
180 }
181
182
183 /**
184 * Returns start date/time (component #4). This is a convenience method that saves you from
185 * casting and handling an exception.
186 */
187 public TS getStartDateTime() {
188 TS ret = null;
189 try {
190 ret = (TS)getComponent(3);
191 } catch (DataTypeException e) {
192 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
193 throw new RuntimeException(e);
194 }
195 return ret;
196 }
197
198
199 /**
200 * Returns start date/time (component #4). This is a convenience method that saves you from
201 * casting and handling an exception.
202 */
203 public TS getTq4_StartDateTime() {
204 TS ret = null;
205 try {
206 ret = (TS)getComponent(3);
207 } catch (DataTypeException e) {
208 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
209 throw new RuntimeException(e);
210 }
211 return ret;
212 }
213
214
215 /**
216 * Returns end date/time (component #5). This is a convenience method that saves you from
217 * casting and handling an exception.
218 */
219 public TS getEndDateTime() {
220 TS ret = null;
221 try {
222 ret = (TS)getComponent(4);
223 } catch (DataTypeException e) {
224 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
225 throw new RuntimeException(e);
226 }
227 return ret;
228 }
229
230
231 /**
232 * Returns end date/time (component #5). This is a convenience method that saves you from
233 * casting and handling an exception.
234 */
235 public TS getTq5_EndDateTime() {
236 TS ret = null;
237 try {
238 ret = (TS)getComponent(4);
239 } catch (DataTypeException e) {
240 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
241 throw new RuntimeException(e);
242 }
243 return ret;
244 }
245
246
247 /**
248 * Returns priority (component #6). This is a convenience method that saves you from
249 * casting and handling an exception.
250 */
251 public ST getPriority() {
252 ST ret = null;
253 try {
254 ret = (ST)getComponent(5);
255 } catch (DataTypeException e) {
256 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
257 throw new RuntimeException(e);
258 }
259 return ret;
260 }
261
262
263 /**
264 * Returns priority (component #6). This is a convenience method that saves you from
265 * casting and handling an exception.
266 */
267 public ST getTq6_Priority() {
268 ST ret = null;
269 try {
270 ret = (ST)getComponent(5);
271 } catch (DataTypeException e) {
272 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
273 throw new RuntimeException(e);
274 }
275 return ret;
276 }
277
278
279 /**
280 * Returns condition (component #7). This is a convenience method that saves you from
281 * casting and handling an exception.
282 */
283 public ST getCondition() {
284 ST ret = null;
285 try {
286 ret = (ST)getComponent(6);
287 } catch (DataTypeException e) {
288 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
289 throw new RuntimeException(e);
290 }
291 return ret;
292 }
293
294
295 /**
296 * Returns condition (component #7). This is a convenience method that saves you from
297 * casting and handling an exception.
298 */
299 public ST getTq7_Condition() {
300 ST ret = null;
301 try {
302 ret = (ST)getComponent(6);
303 } catch (DataTypeException e) {
304 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
305 throw new RuntimeException(e);
306 }
307 return ret;
308 }
309
310
311 /**
312 * Returns text (TX) (component #8). This is a convenience method that saves you from
313 * casting and handling an exception.
314 */
315 public TX getText() {
316 TX ret = null;
317 try {
318 ret = (TX)getComponent(7);
319 } catch (DataTypeException e) {
320 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
321 throw new RuntimeException(e);
322 }
323 return ret;
324 }
325
326
327 /**
328 * Returns text (TX) (component #8). This is a convenience method that saves you from
329 * casting and handling an exception.
330 */
331 public TX getTq8_Text() {
332 TX ret = null;
333 try {
334 ret = (TX)getComponent(7);
335 } catch (DataTypeException e) {
336 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
337 throw new RuntimeException(e);
338 }
339 return ret;
340 }
341
342
343 /**
344 * Returns conjunction component (component #9). This is a convenience method that saves you from
345 * casting and handling an exception.
346 */
347 public ID getConjunctionComponent() {
348 ID ret = null;
349 try {
350 ret = (ID)getComponent(8);
351 } catch (DataTypeException e) {
352 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
353 throw new RuntimeException(e);
354 }
355 return ret;
356 }
357
358
359 /**
360 * Returns conjunction component (component #9). This is a convenience method that saves you from
361 * casting and handling an exception.
362 */
363 public ID getTq9_ConjunctionComponent() {
364 ID ret = null;
365 try {
366 ret = (ID)getComponent(8);
367 } catch (DataTypeException e) {
368 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
369 throw new RuntimeException(e);
370 }
371 return ret;
372 }
373
374
375 /**
376 * Returns order sequencing (component #10). This is a convenience method that saves you from
377 * casting and handling an exception.
378 */
379 public OSD getOrderSequencing() {
380 OSD ret = null;
381 try {
382 ret = (OSD)getComponent(9);
383 } catch (DataTypeException e) {
384 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
385 throw new RuntimeException(e);
386 }
387 return ret;
388 }
389
390
391 /**
392 * Returns order sequencing (component #10). This is a convenience method that saves you from
393 * casting and handling an exception.
394 */
395 public OSD getTq10_OrderSequencing() {
396 OSD ret = null;
397 try {
398 ret = (OSD)getComponent(9);
399 } catch (DataTypeException e) {
400 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
401 throw new RuntimeException(e);
402 }
403 return ret;
404 }
405
406
407 /**
408 * Returns occurrence duration (component #11). This is a convenience method that saves you from
409 * casting and handling an exception.
410 */
411 public CE getOccurrenceDuration() {
412 CE ret = null;
413 try {
414 ret = (CE)getComponent(10);
415 } catch (DataTypeException e) {
416 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
417 throw new RuntimeException(e);
418 }
419 return ret;
420 }
421
422
423 /**
424 * Returns occurrence duration (component #11). This is a convenience method that saves you from
425 * casting and handling an exception.
426 */
427 public CE getTq11_OccurrenceDuration() {
428 CE ret = null;
429 try {
430 ret = (CE)getComponent(10);
431 } catch (DataTypeException e) {
432 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
433 throw new RuntimeException(e);
434 }
435 return ret;
436 }
437
438
439 /**
440 * Returns total occurences (component #12). This is a convenience method that saves you from
441 * casting and handling an exception.
442 */
443 public NM getTotalOccurences() {
444 NM ret = null;
445 try {
446 ret = (NM)getComponent(11);
447 } catch (DataTypeException e) {
448 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
449 throw new RuntimeException(e);
450 }
451 return ret;
452 }
453
454
455 /**
456 * Returns total occurences (component #12). This is a convenience method that saves you from
457 * casting and handling an exception.
458 */
459 public NM getTq12_TotalOccurences() {
460 NM ret = null;
461 try {
462 ret = (NM)getComponent(11);
463 } catch (DataTypeException e) {
464 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
465 throw new RuntimeException(e);
466 }
467 return ret;
468 }
469
470
471
472 }
473