View Javadoc
1   /*
2    * This class is an auto-generated source file for a HAPI
3    * HL7 v2.x standard structure class.
4    *
5    * For more information, visit: http://hl7api.sourceforge.net/
6    * 
7    * The contents of this file are subject to the Mozilla Public License Version 1.1 
8    * (the "License"); you may not use this file except in compliance with the License. 
9    * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
10   * Software distributed under the License is distributed on an "AS IS" basis, 
11   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
12   * specific language governing rights and limitations under the License. 
13   * 
14   * The Original Code is "[file_name]".  Description: 
15   * "[one_line_description]" 
16   * 
17   * The Initial Developer of the Original Code is University Health Network. Copyright (C) 
18   * 2012.  All Rights Reserved. 
19   * 
20   * Contributor(s): ______________________________________. 
21   * 
22   * Alternatively, the contents of this file may be used under the terms of the 
23   * GNU General Public License (the  "GPL"), in which case the provisions of the GPL are 
24   * applicable instead of those above.  If you wish to allow use of your version of this 
25   * file only under the terms of the GPL and not to allow others to use your version 
26   * of this file under the MPL, indicate your decision by deleting  the provisions above 
27   * and replace  them with the notice and other provisions required by the GPL License.  
28   * If you do not delete the provisions above, a recipient may use your version of 
29   * this file under either the MPL or the GPL. 
30   * 
31   */
32  
33  
34  package ca.uhn.hl7v2.model.v23.segment;
35  
36  // import ca.uhn.hl7v2.model.v23.group.*;
37  import ca.uhn.hl7v2.model.v23.datatype.*;
38  import ca.uhn.hl7v2.HL7Exception;
39  import ca.uhn.hl7v2.parser.ModelClassFactory;
40  import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
41  import ca.uhn.hl7v2.model.AbstractMessage;
42  import ca.uhn.hl7v2.model.Group;
43  import ca.uhn.hl7v2.model.Type;
44  import ca.uhn.hl7v2.model.AbstractSegment;
45  import ca.uhn.hl7v2.model.Varies;
46  
47  
48  /**
49   *<p>Represents an HL7 CTD message segment (Contact Data). 
50   * This segment has the following fields:</p>
51   * <ul>
52       * <li>CTD-1: Contact Role (CE) <b> </b>
53       * <li>CTD-2: Contact Name (XPN) <b>optional repeating</b>
54       * <li>CTD-3: Contact Address (XAD) <b>optional repeating</b>
55       * <li>CTD-4: Contact Location (PL) <b>optional </b>
56       * <li>CTD-5: Contact Communication Information (XTN) <b>optional repeating</b>
57       * <li>CTD-6: Preferred Method of Contact (CE) <b>optional </b>
58       * <li>CTD-7: Contact Identifiers (CM_PI) <b>optional repeating</b>
59   * </ul>
60   */
61  @SuppressWarnings("unused")
62  public class CTD extends AbstractSegment {
63  
64      /** 
65       * Creates a new CTD segment
66       */
67      public CTD(Group parent, ModelClassFactory factory) {
68         super(parent, factory);
69         init(factory);
70      }
71  
72      private void init(ModelClassFactory factory) {
73         try {
74                                    this.add(CE.class, true, 1, 60, new Object[]{ getMessage() }, "Contact Role");
75                                    this.add(XPN.class, false, 0, 106, new Object[]{ getMessage() }, "Contact Name");
76                                    this.add(XAD.class, false, 0, 60, new Object[]{ getMessage() }, "Contact Address");
77                                    this.add(PL.class, false, 1, 60, new Object[]{ getMessage() }, "Contact Location");
78                                    this.add(XTN.class, false, 0, 20, new Object[]{ getMessage() }, "Contact Communication Information");
79                                    this.add(CE.class, false, 1, 200, new Object[]{ getMessage() }, "Preferred Method of Contact");
80                                    this.add(CM_PI.class, false, 0, 100, new Object[]{ getMessage() }, "Contact Identifiers");
81         } catch(HL7Exception e) {
82            log.error("Unexpected error creating CTD - this is probably a bug in the source code generator.", e);
83         }
84      }
85  
86  
87  
88      /**
89       * Returns
90       * CTD-1: "Contact Role" - creates it if necessary
91       */
92      public CE getContactRole() { 
93  		CE retVal = this.getTypedField(1, 0);
94  		return retVal;
95      }
96      
97      /**
98       * Returns
99       * CTD-1: "Contact Role" - creates it if necessary
100      */
101     public CE getCtd1_ContactRole() { 
102 		CE retVal = this.getTypedField(1, 0);
103 		return retVal;
104     }
105 
106 
107     /**
108      * Returns all repetitions of Contact Name (CTD-2).
109      */
110     public XPN[] getContactName() {
111     	XPN[] retVal = this.getTypedField(2, new XPN[0]);
112     	return retVal;
113     }
114 
115 
116     /**
117      * Returns all repetitions of Contact Name (CTD-2).
118      */
119     public XPN[] getCtd2_ContactName() {
120     	XPN[] retVal = this.getTypedField(2, new XPN[0]);
121     	return retVal;
122     }
123 
124 
125     /**
126      * Returns a count of the current number of repetitions of Contact Name (CTD-2).
127      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
128      * it will return zero.
129      */
130     public int getContactNameReps() {
131     	return this.getReps(2);
132     }
133 
134 
135     /**
136      * Returns a specific repetition of
137      * CTD-2: "Contact Name" - creates it if necessary
138      *
139      * @param rep The repetition index (0-indexed)
140      */
141     public XPN getContactName(int rep) { 
142 		XPN retVal = this.getTypedField(2, rep);
143 		return retVal;
144     }
145 
146     /**
147      * Returns a specific repetition of
148      * CTD-2: "Contact Name" - creates it if necessary
149      *
150      * @param rep The repetition index (0-indexed)
151      */
152     public XPN getCtd2_ContactName(int rep) { 
153 		XPN retVal = this.getTypedField(2, rep);
154 		return retVal;
155     }
156 
157     /**
158      * Returns a count of the current number of repetitions of Contact Name (CTD-2).
159      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
160      * it will return zero.
161      */
162     public int getCtd2_ContactNameReps() {
163     	return this.getReps(2);
164     }
165 
166 
167     /**
168      * Inserts a repetition of
169      * CTD-2: "Contact Name" at a specific index
170      *
171      * @param rep The repetition index (0-indexed)
172      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
173      */
174     public XPN insertContactName(int rep) throws HL7Exception { 
175         return (XPN) super.insertRepetition(2, rep);
176     }
177 
178 
179     /**
180      * Inserts a repetition of
181      * CTD-2: "Contact Name" 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 XPN insertCtd2_ContactName(int rep) throws HL7Exception { 
187         return (XPN) super.insertRepetition(2, rep);
188     }
189 
190 
191     /**
192      * Removes a repetition of
193      * CTD-2: "Contact Name" 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 XPN removeContactName(int rep) throws HL7Exception { 
199         return (XPN) super.removeRepetition(2, rep);
200     }
201 
202 
203     /**
204      * Removes a repetition of
205      * CTD-2: "Contact Name" 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 XPN removeCtd2_ContactName(int rep) throws HL7Exception { 
211         return (XPN) super.removeRepetition(2, rep);
212     }
213 
214 
215 
216     /**
217      * Returns all repetitions of Contact Address (CTD-3).
218      */
219     public XAD[] getContactAddress() {
220     	XAD[] retVal = this.getTypedField(3, new XAD[0]);
221     	return retVal;
222     }
223 
224 
225     /**
226      * Returns all repetitions of Contact Address (CTD-3).
227      */
228     public XAD[] getCtd3_ContactAddress() {
229     	XAD[] retVal = this.getTypedField(3, new XAD[0]);
230     	return retVal;
231     }
232 
233 
234     /**
235      * Returns a count of the current number of repetitions of Contact Address (CTD-3).
236      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
237      * it will return zero.
238      */
239     public int getContactAddressReps() {
240     	return this.getReps(3);
241     }
242 
243 
244     /**
245      * Returns a specific repetition of
246      * CTD-3: "Contact Address" - creates it if necessary
247      *
248      * @param rep The repetition index (0-indexed)
249      */
250     public XAD getContactAddress(int rep) { 
251 		XAD retVal = this.getTypedField(3, rep);
252 		return retVal;
253     }
254 
255     /**
256      * Returns a specific repetition of
257      * CTD-3: "Contact Address" - creates it if necessary
258      *
259      * @param rep The repetition index (0-indexed)
260      */
261     public XAD getCtd3_ContactAddress(int rep) { 
262 		XAD retVal = this.getTypedField(3, rep);
263 		return retVal;
264     }
265 
266     /**
267      * Returns a count of the current number of repetitions of Contact Address (CTD-3).
268      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
269      * it will return zero.
270      */
271     public int getCtd3_ContactAddressReps() {
272     	return this.getReps(3);
273     }
274 
275 
276     /**
277      * Inserts a repetition of
278      * CTD-3: "Contact Address" at a specific index
279      *
280      * @param rep The repetition index (0-indexed)
281      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
282      */
283     public XAD insertContactAddress(int rep) throws HL7Exception { 
284         return (XAD) super.insertRepetition(3, rep);
285     }
286 
287 
288     /**
289      * Inserts a repetition of
290      * CTD-3: "Contact Address" at a specific index
291      *
292      * @param rep The repetition index (0-indexed)
293      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
294      */
295     public XAD insertCtd3_ContactAddress(int rep) throws HL7Exception { 
296         return (XAD) super.insertRepetition(3, rep);
297     }
298 
299 
300     /**
301      * Removes a repetition of
302      * CTD-3: "Contact Address" at a specific index
303      *
304      * @param rep The repetition index (0-indexed)
305      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
306      */
307     public XAD removeContactAddress(int rep) throws HL7Exception { 
308         return (XAD) super.removeRepetition(3, rep);
309     }
310 
311 
312     /**
313      * Removes a repetition of
314      * CTD-3: "Contact Address" at a specific index
315      *
316      * @param rep The repetition index (0-indexed)
317      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
318      */
319     public XAD removeCtd3_ContactAddress(int rep) throws HL7Exception { 
320         return (XAD) super.removeRepetition(3, rep);
321     }
322 
323 
324 
325 
326     /**
327      * Returns
328      * CTD-4: "Contact Location" - creates it if necessary
329      */
330     public PL getContactLocation() { 
331 		PL retVal = this.getTypedField(4, 0);
332 		return retVal;
333     }
334     
335     /**
336      * Returns
337      * CTD-4: "Contact Location" - creates it if necessary
338      */
339     public PL getCtd4_ContactLocation() { 
340 		PL retVal = this.getTypedField(4, 0);
341 		return retVal;
342     }
343 
344 
345     /**
346      * Returns all repetitions of Contact Communication Information (CTD-5).
347      */
348     public XTN[] getContactCommunicationInformation() {
349     	XTN[] retVal = this.getTypedField(5, new XTN[0]);
350     	return retVal;
351     }
352 
353 
354     /**
355      * Returns all repetitions of Contact Communication Information (CTD-5).
356      */
357     public XTN[] getCtd5_ContactCommunicationInformation() {
358     	XTN[] retVal = this.getTypedField(5, new XTN[0]);
359     	return retVal;
360     }
361 
362 
363     /**
364      * Returns a count of the current number of repetitions of Contact Communication Information (CTD-5).
365      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
366      * it will return zero.
367      */
368     public int getContactCommunicationInformationReps() {
369     	return this.getReps(5);
370     }
371 
372 
373     /**
374      * Returns a specific repetition of
375      * CTD-5: "Contact Communication Information" - creates it if necessary
376      *
377      * @param rep The repetition index (0-indexed)
378      */
379     public XTN getContactCommunicationInformation(int rep) { 
380 		XTN retVal = this.getTypedField(5, rep);
381 		return retVal;
382     }
383 
384     /**
385      * Returns a specific repetition of
386      * CTD-5: "Contact Communication Information" - creates it if necessary
387      *
388      * @param rep The repetition index (0-indexed)
389      */
390     public XTN getCtd5_ContactCommunicationInformation(int rep) { 
391 		XTN retVal = this.getTypedField(5, rep);
392 		return retVal;
393     }
394 
395     /**
396      * Returns a count of the current number of repetitions of Contact Communication Information (CTD-5).
397      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
398      * it will return zero.
399      */
400     public int getCtd5_ContactCommunicationInformationReps() {
401     	return this.getReps(5);
402     }
403 
404 
405     /**
406      * Inserts a repetition of
407      * CTD-5: "Contact Communication Information" at a specific index
408      *
409      * @param rep The repetition index (0-indexed)
410      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
411      */
412     public XTN insertContactCommunicationInformation(int rep) throws HL7Exception { 
413         return (XTN) super.insertRepetition(5, rep);
414     }
415 
416 
417     /**
418      * Inserts a repetition of
419      * CTD-5: "Contact Communication Information" at a specific index
420      *
421      * @param rep The repetition index (0-indexed)
422      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
423      */
424     public XTN insertCtd5_ContactCommunicationInformation(int rep) throws HL7Exception { 
425         return (XTN) super.insertRepetition(5, rep);
426     }
427 
428 
429     /**
430      * Removes a repetition of
431      * CTD-5: "Contact Communication Information" at a specific index
432      *
433      * @param rep The repetition index (0-indexed)
434      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
435      */
436     public XTN removeContactCommunicationInformation(int rep) throws HL7Exception { 
437         return (XTN) super.removeRepetition(5, rep);
438     }
439 
440 
441     /**
442      * Removes a repetition of
443      * CTD-5: "Contact Communication Information" at a specific index
444      *
445      * @param rep The repetition index (0-indexed)
446      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
447      */
448     public XTN removeCtd5_ContactCommunicationInformation(int rep) throws HL7Exception { 
449         return (XTN) super.removeRepetition(5, rep);
450     }
451 
452 
453 
454 
455     /**
456      * Returns
457      * CTD-6: "Preferred Method of Contact" - creates it if necessary
458      */
459     public CE getPreferredMethodOfContact() { 
460 		CE retVal = this.getTypedField(6, 0);
461 		return retVal;
462     }
463     
464     /**
465      * Returns
466      * CTD-6: "Preferred Method of Contact" - creates it if necessary
467      */
468     public CE getCtd6_PreferredMethodOfContact() { 
469 		CE retVal = this.getTypedField(6, 0);
470 		return retVal;
471     }
472 
473 
474     /**
475      * Returns all repetitions of Contact Identifiers (CTD-7).
476      */
477     public CM_PI[] getContactIdentifiers() {
478     	CM_PI[] retVal = this.getTypedField(7, new CM_PI[0]);
479     	return retVal;
480     }
481 
482 
483     /**
484      * Returns all repetitions of Contact Identifiers (CTD-7).
485      */
486     public CM_PI[] getCtd7_ContactIdentifiers() {
487     	CM_PI[] retVal = this.getTypedField(7, new CM_PI[0]);
488     	return retVal;
489     }
490 
491 
492     /**
493      * Returns a count of the current number of repetitions of Contact Identifiers (CTD-7).
494      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
495      * it will return zero.
496      */
497     public int getContactIdentifiersReps() {
498     	return this.getReps(7);
499     }
500 
501 
502     /**
503      * Returns a specific repetition of
504      * CTD-7: "Contact Identifiers" - creates it if necessary
505      *
506      * @param rep The repetition index (0-indexed)
507      */
508     public CM_PI getContactIdentifiers(int rep) { 
509 		CM_PI retVal = this.getTypedField(7, rep);
510 		return retVal;
511     }
512 
513     /**
514      * Returns a specific repetition of
515      * CTD-7: "Contact Identifiers" - creates it if necessary
516      *
517      * @param rep The repetition index (0-indexed)
518      */
519     public CM_PI getCtd7_ContactIdentifiers(int rep) { 
520 		CM_PI retVal = this.getTypedField(7, rep);
521 		return retVal;
522     }
523 
524     /**
525      * Returns a count of the current number of repetitions of Contact Identifiers (CTD-7).
526      * This method does not create a repetition, so if no repetitions have currently been defined or accessed,
527      * it will return zero.
528      */
529     public int getCtd7_ContactIdentifiersReps() {
530     	return this.getReps(7);
531     }
532 
533 
534     /**
535      * Inserts a repetition of
536      * CTD-7: "Contact Identifiers" at a specific index
537      *
538      * @param rep The repetition index (0-indexed)
539      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
540      */
541     public CM_PI insertContactIdentifiers(int rep) throws HL7Exception { 
542         return (CM_PI) super.insertRepetition(7, rep);
543     }
544 
545 
546     /**
547      * Inserts a repetition of
548      * CTD-7: "Contact Identifiers" at a specific index
549      *
550      * @param rep The repetition index (0-indexed)
551      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
552      */
553     public CM_PI insertCtd7_ContactIdentifiers(int rep) throws HL7Exception { 
554         return (CM_PI) super.insertRepetition(7, rep);
555     }
556 
557 
558     /**
559      * Removes a repetition of
560      * CTD-7: "Contact Identifiers" at a specific index
561      *
562      * @param rep The repetition index (0-indexed)
563      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
564      */
565     public CM_PI removeContactIdentifiers(int rep) throws HL7Exception { 
566         return (CM_PI) super.removeRepetition(7, rep);
567     }
568 
569 
570     /**
571      * Removes a repetition of
572      * CTD-7: "Contact Identifiers" at a specific index
573      *
574      * @param rep The repetition index (0-indexed)
575      * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions)
576      */
577     public CM_PI removeCtd7_ContactIdentifiers(int rep) throws HL7Exception { 
578         return (CM_PI) super.removeRepetition(7, rep);
579     }
580 
581 
582 
583 
584 
585 
586     /** {@inheritDoc} */   
587     protected Type createNewTypeWithoutReflection(int field) {
588        switch (field) {
589           case 0: return new CE(getMessage());
590           case 1: return new XPN(getMessage());
591           case 2: return new XAD(getMessage());
592           case 3: return new PL(getMessage());
593           case 4: return new XTN(getMessage());
594           case 5: return new CE(getMessage());
595           case 6: return new CM_PI(getMessage());
596           default: return null;
597        }
598    }
599 
600 
601 }
602