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 PDA message segment (Patient death and autopsy).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>PDA-1: Death Cause Code (CE) <b>optional repeating</b>
027 * <li>PDA-2: Death Location (PL) <b>optional </b>
028 * <li>PDA-3: Death Certified Indicator (ID) <b>optional </b>
029 * <li>PDA-4: Death Certificate Signed Date/Time (TS) <b>optional </b>
030 * <li>PDA-5: Death Certified By (XCN) <b>optional </b>
031 * <li>PDA-6: Autopsy Indicator (ID) <b>optional </b>
032 * <li>PDA-7: Autopsy Start and End Date/Time (DR) <b>optional </b>
033 * <li>PDA-8: Autopsy Performed By (XCN) <b>optional </b>
034 * <li>PDA-9: Coroner Indicator (ID) <b>optional </b>
035 * </ul>
036 */
037 public class PDA extends AbstractSegment {
038
039 /**
040 * Creates a new PDA segment
041 */
042 public PDA(Group parent, ModelClassFactory factory) {
043 super(parent, factory);
044 init(factory);
045 }
046
047 private void init(ModelClassFactory factory) {
048 try {
049 this.add(CE.class, false, 0, 250, new Object[]{ getMessage(), new Integer(0) }, "Death Cause Code");
050 this.add(PL.class, false, 1, 80, new Object[]{ getMessage(), new Integer(0) }, "Death Location");
051 this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Death Certified Indicator");
052 this.add(TS.class, false, 1, 26, new Object[]{ getMessage(), new Integer(0) }, "Death Certificate Signed Date/Time");
053 this.add(XCN.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Death Certified By");
054 this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Autopsy Indicator");
055 this.add(DR.class, false, 1, 53, new Object[]{ getMessage(), new Integer(0) }, "Autopsy Start and End Date/Time");
056 this.add(XCN.class, false, 1, 250, new Object[]{ getMessage(), new Integer(0) }, "Autopsy Performed By");
057 this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Coroner Indicator");
058 } catch(HL7Exception e) {
059 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating PDA - this is probably a bug in the source code generator.", e);
060 }
061 }
062
063
064 /**
065 * Returns all repetitions of Death Cause Code (PDA-1).
066 */
067 public CE[] getDeathCauseCode() {
068 CE[] ret = null;
069 try {
070 Type[] t = this.getField(1);
071 ret = new CE[t.length];
072 for (int i = 0; i < ret.length; i++) {
073 ret[i] = (CE)t[i];
074 }
075 } catch (ClassCastException cce) {
076 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
077 throw new RuntimeException(cce);
078 } catch (HL7Exception he) {
079 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
080 throw new RuntimeException(he);
081 }
082 return ret;
083 }
084
085
086 /**
087 * Returns a count of the current number of repetitions of Death Cause Code (PDA-1).
088 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
089 * it will return zero.
090 */
091 public int getDeathCauseCodeReps() {
092 CE[] ret = null;
093 try {
094 Type[] t = this.getField(1);
095 return t.length;
096 } catch (ClassCastException cce) {
097 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
098 throw new RuntimeException(cce);
099 } catch (HL7Exception he) {
100 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
101 throw new RuntimeException(he);
102 }
103 }
104
105
106 /**
107 * Returns a specific repetition of
108 * PDA-1: "Death Cause Code" - creates it if necessary
109 *
110 * @param rep The repetition index (0-indexed)
111 */
112 public CE getDeathCauseCode(int rep) {
113 CE ret = null;
114 try {
115 Type t = this.getField(1, rep);
116 ret = (CE)t;
117 } catch (ClassCastException cce) {
118 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
119 throw new RuntimeException(cce);
120 } catch (HL7Exception he) {
121 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
122 throw new RuntimeException(he);
123 }
124 return ret;
125 }
126
127 /**
128 * Returns a specific repetition of
129 * PDA-1: "Death Cause Code" - creates it if necessary
130 *
131 * @param rep The repetition index (0-indexed)
132 */
133 public CE getPda1_DeathCauseCode(int rep) {
134 CE ret = null;
135 try {
136 Type t = this.getField(1, rep);
137 ret = (CE)t;
138 } catch (ClassCastException cce) {
139 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
140 throw new RuntimeException(cce);
141 } catch (HL7Exception he) {
142 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
143 throw new RuntimeException(he);
144 }
145 return ret;
146 }
147
148
149 /**
150 * Returns a count of the current number of repetitions of Death Cause Code (PDA-1).
151 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
152 * it will return zero.
153 */
154 public int getPda1_DeathCauseCodeReps() {
155 CE[] ret = null;
156 try {
157 Type[] t = this.getField(1);
158 return t.length;
159 } catch (ClassCastException cce) {
160 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
161 throw new RuntimeException(cce);
162 } catch (HL7Exception he) {
163 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
164 throw new RuntimeException(he);
165 }
166 }
167
168
169
170 /**
171 * Inserts a repetition of
172 * PDA-1: "Death Cause Code" at a specific index
173 *
174 * @param rep The repetition index (0-indexed)
175 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
176 */
177 public CE insertDeathCauseCode(int rep) throws HL7Exception {
178 return (CE) super.insertRepetition(1, rep);
179 }
180
181
182
183 /**
184 * Inserts a repetition of
185 * PDA-1: "Death Cause Code" at a specific index
186 *
187 * @param rep The repetition index (0-indexed)
188 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
189 */
190 public CE insertPda1_DeathCauseCode(int rep) throws HL7Exception {
191 return (CE) super.insertRepetition(1, rep);
192 }
193
194
195 /**
196 * Removes a repetition of
197 * PDA-1: "Death Cause Code" at a specific index
198 *
199 * @param rep The repetition index (0-indexed)
200 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
201 */
202 public CE removeDeathCauseCode(int rep) throws HL7Exception {
203 return (CE) super.removeRepetition(1, rep);
204 }
205
206
207 /**
208 * Removes a repetition of
209 * PDA-1: "Death Cause Code" at a specific index
210 *
211 * @param rep The repetition index (0-indexed)
212 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
213 */
214 public CE removePda1_DeathCauseCode(int rep) throws HL7Exception {
215 return (CE) super.removeRepetition(1, rep);
216 }
217
218
219
220
221 /**
222 * Returns
223 * PDA-2: "Death Location" - creates it if necessary
224 */
225 public PL getDeathLocation() {
226 PL ret = null;
227 try {
228 Type t = this.getField(2, 0);
229 ret = (PL)t;
230 } catch (ClassCastException cce) {
231 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
232 throw new RuntimeException(cce);
233 } catch (HL7Exception he) {
234 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
235 throw new RuntimeException(he);
236 }
237 return ret;
238 }
239
240
241 /**
242 * Returns
243 * PDA-2: "Death Location" - creates it if necessary
244 */
245 public PL getPda2_DeathLocation() {
246 PL ret = null;
247 try {
248 Type t = this.getField(2, 0);
249 ret = (PL)t;
250 } catch (ClassCastException cce) {
251 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
252 throw new RuntimeException(cce);
253 } catch (HL7Exception he) {
254 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
255 throw new RuntimeException(he);
256 }
257 return ret;
258 }
259
260
261
262 /**
263 * Returns
264 * PDA-3: "Death Certified Indicator" - creates it if necessary
265 */
266 public ID getDeathCertifiedIndicator() {
267 ID ret = null;
268 try {
269 Type t = this.getField(3, 0);
270 ret = (ID)t;
271 } catch (ClassCastException cce) {
272 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
273 throw new RuntimeException(cce);
274 } catch (HL7Exception he) {
275 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
276 throw new RuntimeException(he);
277 }
278 return ret;
279 }
280
281
282 /**
283 * Returns
284 * PDA-3: "Death Certified Indicator" - creates it if necessary
285 */
286 public ID getPda3_DeathCertifiedIndicator() {
287 ID ret = null;
288 try {
289 Type t = this.getField(3, 0);
290 ret = (ID)t;
291 } catch (ClassCastException cce) {
292 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
293 throw new RuntimeException(cce);
294 } catch (HL7Exception he) {
295 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
296 throw new RuntimeException(he);
297 }
298 return ret;
299 }
300
301
302
303 /**
304 * Returns
305 * PDA-4: "Death Certificate Signed Date/Time" - creates it if necessary
306 */
307 public TS getDeathCertificateSignedDateTime() {
308 TS ret = null;
309 try {
310 Type t = this.getField(4, 0);
311 ret = (TS)t;
312 } catch (ClassCastException cce) {
313 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
314 throw new RuntimeException(cce);
315 } catch (HL7Exception he) {
316 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
317 throw new RuntimeException(he);
318 }
319 return ret;
320 }
321
322
323 /**
324 * Returns
325 * PDA-4: "Death Certificate Signed Date/Time" - creates it if necessary
326 */
327 public TS getPda4_DeathCertificateSignedDateTime() {
328 TS ret = null;
329 try {
330 Type t = this.getField(4, 0);
331 ret = (TS)t;
332 } catch (ClassCastException cce) {
333 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
334 throw new RuntimeException(cce);
335 } catch (HL7Exception he) {
336 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
337 throw new RuntimeException(he);
338 }
339 return ret;
340 }
341
342
343
344 /**
345 * Returns
346 * PDA-5: "Death Certified By" - creates it if necessary
347 */
348 public XCN getDeathCertifiedBy() {
349 XCN ret = null;
350 try {
351 Type t = this.getField(5, 0);
352 ret = (XCN)t;
353 } catch (ClassCastException cce) {
354 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
355 throw new RuntimeException(cce);
356 } catch (HL7Exception he) {
357 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
358 throw new RuntimeException(he);
359 }
360 return ret;
361 }
362
363
364 /**
365 * Returns
366 * PDA-5: "Death Certified By" - creates it if necessary
367 */
368 public XCN getPda5_DeathCertifiedBy() {
369 XCN ret = null;
370 try {
371 Type t = this.getField(5, 0);
372 ret = (XCN)t;
373 } catch (ClassCastException cce) {
374 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
375 throw new RuntimeException(cce);
376 } catch (HL7Exception he) {
377 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
378 throw new RuntimeException(he);
379 }
380 return ret;
381 }
382
383
384
385 /**
386 * Returns
387 * PDA-6: "Autopsy Indicator" - creates it if necessary
388 */
389 public ID getAutopsyIndicator() {
390 ID ret = null;
391 try {
392 Type t = this.getField(6, 0);
393 ret = (ID)t;
394 } catch (ClassCastException cce) {
395 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
396 throw new RuntimeException(cce);
397 } catch (HL7Exception he) {
398 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
399 throw new RuntimeException(he);
400 }
401 return ret;
402 }
403
404
405 /**
406 * Returns
407 * PDA-6: "Autopsy Indicator" - creates it if necessary
408 */
409 public ID getPda6_AutopsyIndicator() {
410 ID ret = null;
411 try {
412 Type t = this.getField(6, 0);
413 ret = (ID)t;
414 } catch (ClassCastException cce) {
415 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
416 throw new RuntimeException(cce);
417 } catch (HL7Exception he) {
418 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
419 throw new RuntimeException(he);
420 }
421 return ret;
422 }
423
424
425
426 /**
427 * Returns
428 * PDA-7: "Autopsy Start and End Date/Time" - creates it if necessary
429 */
430 public DR getAutopsyStartAndEndDateTime() {
431 DR ret = null;
432 try {
433 Type t = this.getField(7, 0);
434 ret = (DR)t;
435 } catch (ClassCastException cce) {
436 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
437 throw new RuntimeException(cce);
438 } catch (HL7Exception he) {
439 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
440 throw new RuntimeException(he);
441 }
442 return ret;
443 }
444
445
446 /**
447 * Returns
448 * PDA-7: "Autopsy Start and End Date/Time" - creates it if necessary
449 */
450 public DR getPda7_AutopsyStartAndEndDateTime() {
451 DR ret = null;
452 try {
453 Type t = this.getField(7, 0);
454 ret = (DR)t;
455 } catch (ClassCastException cce) {
456 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
457 throw new RuntimeException(cce);
458 } catch (HL7Exception he) {
459 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
460 throw new RuntimeException(he);
461 }
462 return ret;
463 }
464
465
466
467 /**
468 * Returns
469 * PDA-8: "Autopsy Performed By" - creates it if necessary
470 */
471 public XCN getAutopsyPerformedBy() {
472 XCN ret = null;
473 try {
474 Type t = this.getField(8, 0);
475 ret = (XCN)t;
476 } catch (ClassCastException cce) {
477 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
478 throw new RuntimeException(cce);
479 } catch (HL7Exception he) {
480 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
481 throw new RuntimeException(he);
482 }
483 return ret;
484 }
485
486
487 /**
488 * Returns
489 * PDA-8: "Autopsy Performed By" - creates it if necessary
490 */
491 public XCN getPda8_AutopsyPerformedBy() {
492 XCN ret = null;
493 try {
494 Type t = this.getField(8, 0);
495 ret = (XCN)t;
496 } catch (ClassCastException cce) {
497 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
498 throw new RuntimeException(cce);
499 } catch (HL7Exception he) {
500 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
501 throw new RuntimeException(he);
502 }
503 return ret;
504 }
505
506
507
508 /**
509 * Returns
510 * PDA-9: "Coroner Indicator" - creates it if necessary
511 */
512 public ID getCoronerIndicator() {
513 ID ret = null;
514 try {
515 Type t = this.getField(9, 0);
516 ret = (ID)t;
517 } catch (ClassCastException cce) {
518 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
519 throw new RuntimeException(cce);
520 } catch (HL7Exception he) {
521 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
522 throw new RuntimeException(he);
523 }
524 return ret;
525 }
526
527
528 /**
529 * Returns
530 * PDA-9: "Coroner Indicator" - creates it if necessary
531 */
532 public ID getPda9_CoronerIndicator() {
533 ID ret = null;
534 try {
535 Type t = this.getField(9, 0);
536 ret = (ID)t;
537 } catch (ClassCastException cce) {
538 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
539 throw new RuntimeException(cce);
540 } catch (HL7Exception he) {
541 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
542 throw new RuntimeException(he);
543 }
544 return ret;
545 }
546
547
548
549
550
551 /** {@inheritDoc} */
552 protected Type createNewTypeWithoutReflection(int field) {
553 switch (field) {
554 case 0: return new CE(getMessage());
555 case 1: return new PL(getMessage());
556 case 2: return new ID(getMessage(), new Integer( 136 ));
557 case 3: return new TS(getMessage());
558 case 4: return new XCN(getMessage());
559 case 5: return new ID(getMessage(), new Integer( 136 ));
560 case 6: return new DR(getMessage());
561 case 7: return new XCN(getMessage());
562 case 8: return new ID(getMessage(), new Integer( 136 ));
563 default: return null;
564 }
565 }
566
567
568 }
569