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 CTD message segment (Contact Data).
024 * This segment has the following fields:</p>
025 * <ul>
026 * <li>CTD-1: Contact Role (CE) <b> repeating</b>
027 * <li>CTD-2: Contact Name (XPN) <b>optional repeating</b>
028 * <li>CTD-3: Contact Address (XAD) <b>optional repeating</b>
029 * <li>CTD-4: Contact Location (PL) <b>optional </b>
030 * <li>CTD-5: Contact Communication Information (XTN) <b>optional repeating</b>
031 * <li>CTD-6: Preferred Method of Contact (CE) <b>optional </b>
032 * <li>CTD-7: Contact Identifiers (PI) <b>optional repeating</b>
033 * </ul>
034 */
035 public class CTD extends AbstractSegment {
036
037 /**
038 * Creates a new CTD segment
039 */
040 public CTD(Group parent, ModelClassFactory factory) {
041 super(parent, factory);
042 init(factory);
043 }
044
045 private void init(ModelClassFactory factory) {
046 try {
047 this.add(CE.class, true, 0, 250, new Object[]{ getMessage(), new Integer(131) }, "Contact Role");
048 this.add(XPN.class, false, 0, 250, new Object[]{ getMessage(), new Integer(0) }, "Contact Name");
049 this.add(XAD.class, false, 0, 250, new Object[]{ getMessage(), new Integer(0) }, "Contact Address");
050 this.add(PL.class, false, 1, 60, new Object[]{ getMessage(), new Integer(0) }, "Contact Location");
051 this.add(XTN.class, false, 0, 250, new Object[]{ getMessage(), new Integer(0) }, "Contact Communication Information");
052 this.add(CE.class, false, 1, 250, new Object[]{ getMessage(), new Integer(185) }, "Preferred Method of Contact");
053 this.add(PI.class, false, 0, 100, new Object[]{ getMessage(), new Integer(0) }, "Contact Identifiers");
054 } catch(HL7Exception e) {
055 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating CTD - this is probably a bug in the source code generator.", e);
056 }
057 }
058
059
060 /**
061 * Returns all repetitions of Contact Role (CTD-1).
062 */
063 public CE[] getContactRole() {
064 CE[] ret = null;
065 try {
066 Type[] t = this.getField(1);
067 ret = new CE[t.length];
068 for (int i = 0; i < ret.length; i++) {
069 ret[i] = (CE)t[i];
070 }
071 } catch (ClassCastException cce) {
072 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
073 throw new RuntimeException(cce);
074 } catch (HL7Exception he) {
075 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
076 throw new RuntimeException(he);
077 }
078 return ret;
079 }
080
081
082 /**
083 * Returns a count of the current number of repetitions of Contact Role (CTD-1).
084 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
085 * it will return zero.
086 */
087 public int getContactRoleReps() {
088 CE[] ret = null;
089 try {
090 Type[] t = this.getField(1);
091 return t.length;
092 } catch (ClassCastException cce) {
093 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
094 throw new RuntimeException(cce);
095 } catch (HL7Exception he) {
096 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
097 throw new RuntimeException(he);
098 }
099 }
100
101
102 /**
103 * Returns a specific repetition of
104 * CTD-1: "Contact Role" - creates it if necessary
105 *
106 * @param rep The repetition index (0-indexed)
107 */
108 public CE getContactRole(int rep) {
109 CE ret = null;
110 try {
111 Type t = this.getField(1, rep);
112 ret = (CE)t;
113 } catch (ClassCastException cce) {
114 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
115 throw new RuntimeException(cce);
116 } catch (HL7Exception he) {
117 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
118 throw new RuntimeException(he);
119 }
120 return ret;
121 }
122
123 /**
124 * Returns a specific repetition of
125 * CTD-1: "Contact Role" - creates it if necessary
126 *
127 * @param rep The repetition index (0-indexed)
128 */
129 public CE getCtd1_ContactRole(int rep) {
130 CE ret = null;
131 try {
132 Type t = this.getField(1, rep);
133 ret = (CE)t;
134 } catch (ClassCastException cce) {
135 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
136 throw new RuntimeException(cce);
137 } catch (HL7Exception he) {
138 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
139 throw new RuntimeException(he);
140 }
141 return ret;
142 }
143
144
145 /**
146 * Returns a count of the current number of repetitions of Contact Role (CTD-1).
147 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
148 * it will return zero.
149 */
150 public int getCtd1_ContactRoleReps() {
151 CE[] ret = null;
152 try {
153 Type[] t = this.getField(1);
154 return t.length;
155 } catch (ClassCastException cce) {
156 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
157 throw new RuntimeException(cce);
158 } catch (HL7Exception he) {
159 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
160 throw new RuntimeException(he);
161 }
162 }
163
164
165
166 /**
167 * Inserts a repetition of
168 * CTD-1: "Contact Role" at a specific index
169 *
170 * @param rep The repetition index (0-indexed)
171 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
172 */
173 public CE insertContactRole(int rep) throws HL7Exception {
174 return (CE) super.insertRepetition(1, rep);
175 }
176
177
178
179 /**
180 * Inserts a repetition of
181 * CTD-1: "Contact Role" at a specific index
182 *
183 * @param rep The repetition index (0-indexed)
184 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
185 */
186 public CE insertCtd1_ContactRole(int rep) throws HL7Exception {
187 return (CE) super.insertRepetition(1, rep);
188 }
189
190
191 /**
192 * Removes a repetition of
193 * CTD-1: "Contact Role" at a specific index
194 *
195 * @param rep The repetition index (0-indexed)
196 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
197 */
198 public CE removeContactRole(int rep) throws HL7Exception {
199 return (CE) super.removeRepetition(1, rep);
200 }
201
202
203 /**
204 * Removes a repetition of
205 * CTD-1: "Contact Role" at a specific index
206 *
207 * @param rep The repetition index (0-indexed)
208 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
209 */
210 public CE removeCtd1_ContactRole(int rep) throws HL7Exception {
211 return (CE) super.removeRepetition(1, rep);
212 }
213
214
215
216 /**
217 * Returns all repetitions of Contact Name (CTD-2).
218 */
219 public XPN[] getContactName() {
220 XPN[] ret = null;
221 try {
222 Type[] t = this.getField(2);
223 ret = new XPN[t.length];
224 for (int i = 0; i < ret.length; i++) {
225 ret[i] = (XPN)t[i];
226 }
227 } catch (ClassCastException cce) {
228 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
229 throw new RuntimeException(cce);
230 } catch (HL7Exception he) {
231 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
232 throw new RuntimeException(he);
233 }
234 return ret;
235 }
236
237
238 /**
239 * Returns a count of the current number of repetitions of Contact Name (CTD-2).
240 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
241 * it will return zero.
242 */
243 public int getContactNameReps() {
244 XPN[] ret = null;
245 try {
246 Type[] t = this.getField(2);
247 return t.length;
248 } catch (ClassCastException cce) {
249 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
250 throw new RuntimeException(cce);
251 } catch (HL7Exception he) {
252 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
253 throw new RuntimeException(he);
254 }
255 }
256
257
258 /**
259 * Returns a specific repetition of
260 * CTD-2: "Contact Name" - creates it if necessary
261 *
262 * @param rep The repetition index (0-indexed)
263 */
264 public XPN getContactName(int rep) {
265 XPN ret = null;
266 try {
267 Type t = this.getField(2, rep);
268 ret = (XPN)t;
269 } catch (ClassCastException cce) {
270 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
271 throw new RuntimeException(cce);
272 } catch (HL7Exception he) {
273 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
274 throw new RuntimeException(he);
275 }
276 return ret;
277 }
278
279 /**
280 * Returns a specific repetition of
281 * CTD-2: "Contact Name" - creates it if necessary
282 *
283 * @param rep The repetition index (0-indexed)
284 */
285 public XPN getCtd2_ContactName(int rep) {
286 XPN ret = null;
287 try {
288 Type t = this.getField(2, rep);
289 ret = (XPN)t;
290 } catch (ClassCastException cce) {
291 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
292 throw new RuntimeException(cce);
293 } catch (HL7Exception he) {
294 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
295 throw new RuntimeException(he);
296 }
297 return ret;
298 }
299
300
301 /**
302 * Returns a count of the current number of repetitions of Contact Name (CTD-2).
303 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
304 * it will return zero.
305 */
306 public int getCtd2_ContactNameReps() {
307 XPN[] ret = null;
308 try {
309 Type[] t = this.getField(2);
310 return t.length;
311 } catch (ClassCastException cce) {
312 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
313 throw new RuntimeException(cce);
314 } catch (HL7Exception he) {
315 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
316 throw new RuntimeException(he);
317 }
318 }
319
320
321
322 /**
323 * Inserts a repetition of
324 * CTD-2: "Contact Name" at a specific index
325 *
326 * @param rep The repetition index (0-indexed)
327 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
328 */
329 public XPN insertContactName(int rep) throws HL7Exception {
330 return (XPN) super.insertRepetition(2, rep);
331 }
332
333
334
335 /**
336 * Inserts a repetition of
337 * CTD-2: "Contact Name" at a specific index
338 *
339 * @param rep The repetition index (0-indexed)
340 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
341 */
342 public XPN insertCtd2_ContactName(int rep) throws HL7Exception {
343 return (XPN) super.insertRepetition(2, rep);
344 }
345
346
347 /**
348 * Removes a repetition of
349 * CTD-2: "Contact Name" at a specific index
350 *
351 * @param rep The repetition index (0-indexed)
352 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
353 */
354 public XPN removeContactName(int rep) throws HL7Exception {
355 return (XPN) super.removeRepetition(2, rep);
356 }
357
358
359 /**
360 * Removes a repetition of
361 * CTD-2: "Contact Name" at a specific index
362 *
363 * @param rep The repetition index (0-indexed)
364 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
365 */
366 public XPN removeCtd2_ContactName(int rep) throws HL7Exception {
367 return (XPN) super.removeRepetition(2, rep);
368 }
369
370
371
372 /**
373 * Returns all repetitions of Contact Address (CTD-3).
374 */
375 public XAD[] getContactAddress() {
376 XAD[] ret = null;
377 try {
378 Type[] t = this.getField(3);
379 ret = new XAD[t.length];
380 for (int i = 0; i < ret.length; i++) {
381 ret[i] = (XAD)t[i];
382 }
383 } catch (ClassCastException cce) {
384 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
385 throw new RuntimeException(cce);
386 } catch (HL7Exception he) {
387 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
388 throw new RuntimeException(he);
389 }
390 return ret;
391 }
392
393
394 /**
395 * Returns a count of the current number of repetitions of Contact Address (CTD-3).
396 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
397 * it will return zero.
398 */
399 public int getContactAddressReps() {
400 XAD[] ret = null;
401 try {
402 Type[] t = this.getField(3);
403 return t.length;
404 } catch (ClassCastException cce) {
405 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
406 throw new RuntimeException(cce);
407 } catch (HL7Exception he) {
408 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
409 throw new RuntimeException(he);
410 }
411 }
412
413
414 /**
415 * Returns a specific repetition of
416 * CTD-3: "Contact Address" - creates it if necessary
417 *
418 * @param rep The repetition index (0-indexed)
419 */
420 public XAD getContactAddress(int rep) {
421 XAD ret = null;
422 try {
423 Type t = this.getField(3, rep);
424 ret = (XAD)t;
425 } catch (ClassCastException cce) {
426 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
427 throw new RuntimeException(cce);
428 } catch (HL7Exception he) {
429 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
430 throw new RuntimeException(he);
431 }
432 return ret;
433 }
434
435 /**
436 * Returns a specific repetition of
437 * CTD-3: "Contact Address" - creates it if necessary
438 *
439 * @param rep The repetition index (0-indexed)
440 */
441 public XAD getCtd3_ContactAddress(int rep) {
442 XAD ret = null;
443 try {
444 Type t = this.getField(3, rep);
445 ret = (XAD)t;
446 } catch (ClassCastException cce) {
447 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
448 throw new RuntimeException(cce);
449 } catch (HL7Exception he) {
450 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
451 throw new RuntimeException(he);
452 }
453 return ret;
454 }
455
456
457 /**
458 * Returns a count of the current number of repetitions of Contact Address (CTD-3).
459 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
460 * it will return zero.
461 */
462 public int getCtd3_ContactAddressReps() {
463 XAD[] ret = null;
464 try {
465 Type[] t = this.getField(3);
466 return t.length;
467 } catch (ClassCastException cce) {
468 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
469 throw new RuntimeException(cce);
470 } catch (HL7Exception he) {
471 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
472 throw new RuntimeException(he);
473 }
474 }
475
476
477
478 /**
479 * Inserts a repetition of
480 * CTD-3: "Contact Address" at a specific index
481 *
482 * @param rep The repetition index (0-indexed)
483 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
484 */
485 public XAD insertContactAddress(int rep) throws HL7Exception {
486 return (XAD) super.insertRepetition(3, rep);
487 }
488
489
490
491 /**
492 * Inserts a repetition of
493 * CTD-3: "Contact Address" at a specific index
494 *
495 * @param rep The repetition index (0-indexed)
496 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
497 */
498 public XAD insertCtd3_ContactAddress(int rep) throws HL7Exception {
499 return (XAD) super.insertRepetition(3, rep);
500 }
501
502
503 /**
504 * Removes a repetition of
505 * CTD-3: "Contact Address" at a specific index
506 *
507 * @param rep The repetition index (0-indexed)
508 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
509 */
510 public XAD removeContactAddress(int rep) throws HL7Exception {
511 return (XAD) super.removeRepetition(3, rep);
512 }
513
514
515 /**
516 * Removes a repetition of
517 * CTD-3: "Contact Address" at a specific index
518 *
519 * @param rep The repetition index (0-indexed)
520 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
521 */
522 public XAD removeCtd3_ContactAddress(int rep) throws HL7Exception {
523 return (XAD) super.removeRepetition(3, rep);
524 }
525
526
527
528
529 /**
530 * Returns
531 * CTD-4: "Contact Location" - creates it if necessary
532 */
533 public PL getContactLocation() {
534 PL ret = null;
535 try {
536 Type t = this.getField(4, 0);
537 ret = (PL)t;
538 } catch (ClassCastException cce) {
539 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
540 throw new RuntimeException(cce);
541 } catch (HL7Exception he) {
542 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
543 throw new RuntimeException(he);
544 }
545 return ret;
546 }
547
548
549 /**
550 * Returns
551 * CTD-4: "Contact Location" - creates it if necessary
552 */
553 public PL getCtd4_ContactLocation() {
554 PL ret = null;
555 try {
556 Type t = this.getField(4, 0);
557 ret = (PL)t;
558 } catch (ClassCastException cce) {
559 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
560 throw new RuntimeException(cce);
561 } catch (HL7Exception he) {
562 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
563 throw new RuntimeException(he);
564 }
565 return ret;
566 }
567
568
569 /**
570 * Returns all repetitions of Contact Communication Information (CTD-5).
571 */
572 public XTN[] getContactCommunicationInformation() {
573 XTN[] ret = null;
574 try {
575 Type[] t = this.getField(5);
576 ret = new XTN[t.length];
577 for (int i = 0; i < ret.length; i++) {
578 ret[i] = (XTN)t[i];
579 }
580 } catch (ClassCastException cce) {
581 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
582 throw new RuntimeException(cce);
583 } catch (HL7Exception he) {
584 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
585 throw new RuntimeException(he);
586 }
587 return ret;
588 }
589
590
591 /**
592 * Returns a count of the current number of repetitions of Contact Communication Information (CTD-5).
593 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
594 * it will return zero.
595 */
596 public int getContactCommunicationInformationReps() {
597 XTN[] ret = null;
598 try {
599 Type[] t = this.getField(5);
600 return t.length;
601 } catch (ClassCastException cce) {
602 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
603 throw new RuntimeException(cce);
604 } catch (HL7Exception he) {
605 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
606 throw new RuntimeException(he);
607 }
608 }
609
610
611 /**
612 * Returns a specific repetition of
613 * CTD-5: "Contact Communication Information" - creates it if necessary
614 *
615 * @param rep The repetition index (0-indexed)
616 */
617 public XTN getContactCommunicationInformation(int rep) {
618 XTN ret = null;
619 try {
620 Type t = this.getField(5, rep);
621 ret = (XTN)t;
622 } catch (ClassCastException cce) {
623 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
624 throw new RuntimeException(cce);
625 } catch (HL7Exception he) {
626 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
627 throw new RuntimeException(he);
628 }
629 return ret;
630 }
631
632 /**
633 * Returns a specific repetition of
634 * CTD-5: "Contact Communication Information" - creates it if necessary
635 *
636 * @param rep The repetition index (0-indexed)
637 */
638 public XTN getCtd5_ContactCommunicationInformation(int rep) {
639 XTN ret = null;
640 try {
641 Type t = this.getField(5, rep);
642 ret = (XTN)t;
643 } catch (ClassCastException cce) {
644 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
645 throw new RuntimeException(cce);
646 } catch (HL7Exception he) {
647 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
648 throw new RuntimeException(he);
649 }
650 return ret;
651 }
652
653
654 /**
655 * Returns a count of the current number of repetitions of Contact Communication Information (CTD-5).
656 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
657 * it will return zero.
658 */
659 public int getCtd5_ContactCommunicationInformationReps() {
660 XTN[] ret = null;
661 try {
662 Type[] t = this.getField(5);
663 return t.length;
664 } catch (ClassCastException cce) {
665 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
666 throw new RuntimeException(cce);
667 } catch (HL7Exception he) {
668 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
669 throw new RuntimeException(he);
670 }
671 }
672
673
674
675 /**
676 * Inserts a repetition of
677 * CTD-5: "Contact Communication Information" at a specific index
678 *
679 * @param rep The repetition index (0-indexed)
680 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
681 */
682 public XTN insertContactCommunicationInformation(int rep) throws HL7Exception {
683 return (XTN) super.insertRepetition(5, rep);
684 }
685
686
687
688 /**
689 * Inserts a repetition of
690 * CTD-5: "Contact Communication Information" at a specific index
691 *
692 * @param rep The repetition index (0-indexed)
693 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
694 */
695 public XTN insertCtd5_ContactCommunicationInformation(int rep) throws HL7Exception {
696 return (XTN) super.insertRepetition(5, rep);
697 }
698
699
700 /**
701 * Removes a repetition of
702 * CTD-5: "Contact Communication Information" at a specific index
703 *
704 * @param rep The repetition index (0-indexed)
705 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
706 */
707 public XTN removeContactCommunicationInformation(int rep) throws HL7Exception {
708 return (XTN) super.removeRepetition(5, rep);
709 }
710
711
712 /**
713 * Removes a repetition of
714 * CTD-5: "Contact Communication Information" at a specific index
715 *
716 * @param rep The repetition index (0-indexed)
717 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
718 */
719 public XTN removeCtd5_ContactCommunicationInformation(int rep) throws HL7Exception {
720 return (XTN) super.removeRepetition(5, rep);
721 }
722
723
724
725
726 /**
727 * Returns
728 * CTD-6: "Preferred Method of Contact" - creates it if necessary
729 */
730 public CE getPreferredMethodOfContact() {
731 CE ret = null;
732 try {
733 Type t = this.getField(6, 0);
734 ret = (CE)t;
735 } catch (ClassCastException cce) {
736 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
737 throw new RuntimeException(cce);
738 } catch (HL7Exception he) {
739 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
740 throw new RuntimeException(he);
741 }
742 return ret;
743 }
744
745
746 /**
747 * Returns
748 * CTD-6: "Preferred Method of Contact" - creates it if necessary
749 */
750 public CE getCtd6_PreferredMethodOfContact() {
751 CE ret = null;
752 try {
753 Type t = this.getField(6, 0);
754 ret = (CE)t;
755 } catch (ClassCastException cce) {
756 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
757 throw new RuntimeException(cce);
758 } catch (HL7Exception he) {
759 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
760 throw new RuntimeException(he);
761 }
762 return ret;
763 }
764
765
766 /**
767 * Returns all repetitions of Contact Identifiers (CTD-7).
768 */
769 public PI[] getContactIdentifiers() {
770 PI[] ret = null;
771 try {
772 Type[] t = this.getField(7);
773 ret = new PI[t.length];
774 for (int i = 0; i < ret.length; i++) {
775 ret[i] = (PI)t[i];
776 }
777 } catch (ClassCastException cce) {
778 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
779 throw new RuntimeException(cce);
780 } catch (HL7Exception he) {
781 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
782 throw new RuntimeException(he);
783 }
784 return ret;
785 }
786
787
788 /**
789 * Returns a count of the current number of repetitions of Contact Identifiers (CTD-7).
790 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
791 * it will return zero.
792 */
793 public int getContactIdentifiersReps() {
794 PI[] ret = null;
795 try {
796 Type[] t = this.getField(7);
797 return t.length;
798 } catch (ClassCastException cce) {
799 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
800 throw new RuntimeException(cce);
801 } catch (HL7Exception he) {
802 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
803 throw new RuntimeException(he);
804 }
805 }
806
807
808 /**
809 * Returns a specific repetition of
810 * CTD-7: "Contact Identifiers" - creates it if necessary
811 *
812 * @param rep The repetition index (0-indexed)
813 */
814 public PI getContactIdentifiers(int rep) {
815 PI ret = null;
816 try {
817 Type t = this.getField(7, rep);
818 ret = (PI)t;
819 } catch (ClassCastException cce) {
820 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
821 throw new RuntimeException(cce);
822 } catch (HL7Exception he) {
823 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
824 throw new RuntimeException(he);
825 }
826 return ret;
827 }
828
829 /**
830 * Returns a specific repetition of
831 * CTD-7: "Contact Identifiers" - creates it if necessary
832 *
833 * @param rep The repetition index (0-indexed)
834 */
835 public PI getCtd7_ContactIdentifiers(int rep) {
836 PI ret = null;
837 try {
838 Type t = this.getField(7, rep);
839 ret = (PI)t;
840 } catch (ClassCastException cce) {
841 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
842 throw new RuntimeException(cce);
843 } catch (HL7Exception he) {
844 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
845 throw new RuntimeException(he);
846 }
847 return ret;
848 }
849
850
851 /**
852 * Returns a count of the current number of repetitions of Contact Identifiers (CTD-7).
853 * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
854 * it will return zero.
855 */
856 public int getCtd7_ContactIdentifiersReps() {
857 PI[] ret = null;
858 try {
859 Type[] t = this.getField(7);
860 return t.length;
861 } catch (ClassCastException cce) {
862 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", cce);
863 throw new RuntimeException(cce);
864 } catch (HL7Exception he) {
865 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value. This is a bug.", he);
866 throw new RuntimeException(he);
867 }
868 }
869
870
871
872 /**
873 * Inserts a repetition of
874 * CTD-7: "Contact Identifiers" at a specific index
875 *
876 * @param rep The repetition index (0-indexed)
877 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
878 */
879 public PI insertContactIdentifiers(int rep) throws HL7Exception {
880 return (PI) super.insertRepetition(7, rep);
881 }
882
883
884
885 /**
886 * Inserts a repetition of
887 * CTD-7: "Contact Identifiers" at a specific index
888 *
889 * @param rep The repetition index (0-indexed)
890 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
891 */
892 public PI insertCtd7_ContactIdentifiers(int rep) throws HL7Exception {
893 return (PI) super.insertRepetition(7, rep);
894 }
895
896
897 /**
898 * Removes a repetition of
899 * CTD-7: "Contact Identifiers" at a specific index
900 *
901 * @param rep The repetition index (0-indexed)
902 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
903 */
904 public PI removeContactIdentifiers(int rep) throws HL7Exception {
905 return (PI) super.removeRepetition(7, rep);
906 }
907
908
909 /**
910 * Removes a repetition of
911 * CTD-7: "Contact Identifiers" at a specific index
912 *
913 * @param rep The repetition index (0-indexed)
914 * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
915 */
916 public PI removeCtd7_ContactIdentifiers(int rep) throws HL7Exception {
917 return (PI) super.removeRepetition(7, rep);
918 }
919
920
921
922
923
924
925 /** {@inheritDoc} */
926 protected Type createNewTypeWithoutReflection(int field) {
927 switch (field) {
928 case 0: return new CE(getMessage());
929 case 1: return new XPN(getMessage());
930 case 2: return new XAD(getMessage());
931 case 3: return new PL(getMessage());
932 case 4: return new XTN(getMessage());
933 case 5: return new CE(getMessage());
934 case 6: return new PI(getMessage());
935 default: return null;
936 }
937 }
938
939
940 }
941