001package org.hl7.fhir.dstu3.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034// Generated on Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.x
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038import org.hl7.fhir.instance.model.api.ICompositeType;
039import org.hl7.fhir.utilities.Utilities;
040
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.DatatypeDef;
043import ca.uhn.fhir.model.api.annotation.Description;
044/**
045 * Details for all kinds of technology mediated contact points for a person or organization, including telephone, email, etc.
046 */
047@DatatypeDef(name="ContactPoint")
048public class ContactPoint extends Type implements ICompositeType {
049
050    public enum ContactPointSystem {
051        /**
052         * The value is a telephone number used for voice calls. Use of full international numbers starting with + is recommended to enable automatic dialing support but not required.
053         */
054        PHONE, 
055        /**
056         * The value is a fax machine. Use of full international numbers starting with + is recommended to enable automatic dialing support but not required.
057         */
058        FAX, 
059        /**
060         * The value is an email address.
061         */
062        EMAIL, 
063        /**
064         * The value is a pager number. These may be local pager numbers that are only usable on a particular pager system.
065         */
066        PAGER, 
067        /**
068         * A contact that is not a phone, fax, pager or email address and is expressed as a URL.  This is intended for various personal contacts including blogs, Skype, Twitter, Facebook, etc. Do not use for email addresses.
069         */
070        URL, 
071        /**
072         * A contact that can be used for sending an sms message (e.g. mobide phones, some landlines)
073         */
074        SMS, 
075        /**
076         * A contact that is not a phone, fax, page or email address and is not expressible as a URL.  E.g. Internal mail address.  This SHOULD NOT be used for contacts that are expressible as a URL (e.g. Skype, Twitter, Facebook, etc.)  Extensions may be used to distinguish "other" contact types.
077         */
078        OTHER, 
079        /**
080         * added to help the parsers with the generic types
081         */
082        NULL;
083        public static ContactPointSystem fromCode(String codeString) throws FHIRException {
084            if (codeString == null || "".equals(codeString))
085                return null;
086        if ("phone".equals(codeString))
087          return PHONE;
088        if ("fax".equals(codeString))
089          return FAX;
090        if ("email".equals(codeString))
091          return EMAIL;
092        if ("pager".equals(codeString))
093          return PAGER;
094        if ("url".equals(codeString))
095          return URL;
096        if ("sms".equals(codeString))
097          return SMS;
098        if ("other".equals(codeString))
099          return OTHER;
100        if (Configuration.isAcceptInvalidEnums())
101          return null;
102        else
103          throw new FHIRException("Unknown ContactPointSystem code '"+codeString+"'");
104        }
105        public String toCode() {
106          switch (this) {
107            case PHONE: return "phone";
108            case FAX: return "fax";
109            case EMAIL: return "email";
110            case PAGER: return "pager";
111            case URL: return "url";
112            case SMS: return "sms";
113            case OTHER: return "other";
114            case NULL: return null;
115            default: return "?";
116          }
117        }
118        public String getSystem() {
119          switch (this) {
120            case PHONE: return "http://hl7.org/fhir/contact-point-system";
121            case FAX: return "http://hl7.org/fhir/contact-point-system";
122            case EMAIL: return "http://hl7.org/fhir/contact-point-system";
123            case PAGER: return "http://hl7.org/fhir/contact-point-system";
124            case URL: return "http://hl7.org/fhir/contact-point-system";
125            case SMS: return "http://hl7.org/fhir/contact-point-system";
126            case OTHER: return "http://hl7.org/fhir/contact-point-system";
127            case NULL: return null;
128            default: return "?";
129          }
130        }
131        public String getDefinition() {
132          switch (this) {
133            case PHONE: return "The value is a telephone number used for voice calls. Use of full international numbers starting with + is recommended to enable automatic dialing support but not required.";
134            case FAX: return "The value is a fax machine. Use of full international numbers starting with + is recommended to enable automatic dialing support but not required.";
135            case EMAIL: return "The value is an email address.";
136            case PAGER: return "The value is a pager number. These may be local pager numbers that are only usable on a particular pager system.";
137            case URL: return "A contact that is not a phone, fax, pager or email address and is expressed as a URL.  This is intended for various personal contacts including blogs, Skype, Twitter, Facebook, etc. Do not use for email addresses.";
138            case SMS: return "A contact that can be used for sending an sms message (e.g. mobide phones, some landlines)";
139            case OTHER: return "A contact that is not a phone, fax, page or email address and is not expressible as a URL.  E.g. Internal mail address.  This SHOULD NOT be used for contacts that are expressible as a URL (e.g. Skype, Twitter, Facebook, etc.)  Extensions may be used to distinguish \"other\" contact types.";
140            case NULL: return null;
141            default: return "?";
142          }
143        }
144        public String getDisplay() {
145          switch (this) {
146            case PHONE: return "Phone";
147            case FAX: return "Fax";
148            case EMAIL: return "Email";
149            case PAGER: return "Pager";
150            case URL: return "URL";
151            case SMS: return "SMS";
152            case OTHER: return "Other";
153            case NULL: return null;
154            default: return "?";
155          }
156        }
157    }
158
159  public static class ContactPointSystemEnumFactory implements EnumFactory<ContactPointSystem> {
160    public ContactPointSystem fromCode(String codeString) throws IllegalArgumentException {
161      if (codeString == null || "".equals(codeString))
162            if (codeString == null || "".equals(codeString))
163                return null;
164        if ("phone".equals(codeString))
165          return ContactPointSystem.PHONE;
166        if ("fax".equals(codeString))
167          return ContactPointSystem.FAX;
168        if ("email".equals(codeString))
169          return ContactPointSystem.EMAIL;
170        if ("pager".equals(codeString))
171          return ContactPointSystem.PAGER;
172        if ("url".equals(codeString))
173          return ContactPointSystem.URL;
174        if ("sms".equals(codeString))
175          return ContactPointSystem.SMS;
176        if ("other".equals(codeString))
177          return ContactPointSystem.OTHER;
178        throw new IllegalArgumentException("Unknown ContactPointSystem code '"+codeString+"'");
179        }
180        public Enumeration<ContactPointSystem> fromType(Base code) throws FHIRException {
181          if (code == null)
182            return null;
183          if (code.isEmpty())
184            return new Enumeration<ContactPointSystem>(this);
185          String codeString = ((PrimitiveType) code).asStringValue();
186          if (codeString == null || "".equals(codeString))
187            return null;
188        if ("phone".equals(codeString))
189          return new Enumeration<ContactPointSystem>(this, ContactPointSystem.PHONE);
190        if ("fax".equals(codeString))
191          return new Enumeration<ContactPointSystem>(this, ContactPointSystem.FAX);
192        if ("email".equals(codeString))
193          return new Enumeration<ContactPointSystem>(this, ContactPointSystem.EMAIL);
194        if ("pager".equals(codeString))
195          return new Enumeration<ContactPointSystem>(this, ContactPointSystem.PAGER);
196        if ("url".equals(codeString))
197          return new Enumeration<ContactPointSystem>(this, ContactPointSystem.URL);
198        if ("sms".equals(codeString))
199          return new Enumeration<ContactPointSystem>(this, ContactPointSystem.SMS);
200        if ("other".equals(codeString))
201          return new Enumeration<ContactPointSystem>(this, ContactPointSystem.OTHER);
202        throw new FHIRException("Unknown ContactPointSystem code '"+codeString+"'");
203        }
204    public String toCode(ContactPointSystem code) {
205      if (code == ContactPointSystem.PHONE)
206        return "phone";
207      if (code == ContactPointSystem.FAX)
208        return "fax";
209      if (code == ContactPointSystem.EMAIL)
210        return "email";
211      if (code == ContactPointSystem.PAGER)
212        return "pager";
213      if (code == ContactPointSystem.URL)
214        return "url";
215      if (code == ContactPointSystem.SMS)
216        return "sms";
217      if (code == ContactPointSystem.OTHER)
218        return "other";
219      return "?";
220      }
221    public String toSystem(ContactPointSystem code) {
222      return code.getSystem();
223      }
224    }
225
226    public enum ContactPointUse {
227        /**
228         * A communication contact point at a home; attempted contacts for business purposes might intrude privacy and chances are one will contact family or other household members instead of the person one wishes to call. Typically used with urgent cases, or if no other contacts are available.
229         */
230        HOME, 
231        /**
232         * An office contact point. First choice for business related contacts during business hours.
233         */
234        WORK, 
235        /**
236         * A temporary contact point. The period can provide more detailed information.
237         */
238        TEMP, 
239        /**
240         * This contact point is no longer in use (or was never correct, but retained for records).
241         */
242        OLD, 
243        /**
244         * A telecommunication device that moves and stays with its owner. May have characteristics of all other use codes, suitable for urgent matters, not the first choice for routine business.
245         */
246        MOBILE, 
247        /**
248         * added to help the parsers with the generic types
249         */
250        NULL;
251        public static ContactPointUse fromCode(String codeString) throws FHIRException {
252            if (codeString == null || "".equals(codeString))
253                return null;
254        if ("home".equals(codeString))
255          return HOME;
256        if ("work".equals(codeString))
257          return WORK;
258        if ("temp".equals(codeString))
259          return TEMP;
260        if ("old".equals(codeString))
261          return OLD;
262        if ("mobile".equals(codeString))
263          return MOBILE;
264        if (Configuration.isAcceptInvalidEnums())
265          return null;
266        else
267          throw new FHIRException("Unknown ContactPointUse code '"+codeString+"'");
268        }
269        public String toCode() {
270          switch (this) {
271            case HOME: return "home";
272            case WORK: return "work";
273            case TEMP: return "temp";
274            case OLD: return "old";
275            case MOBILE: return "mobile";
276            case NULL: return null;
277            default: return "?";
278          }
279        }
280        public String getSystem() {
281          switch (this) {
282            case HOME: return "http://hl7.org/fhir/contact-point-use";
283            case WORK: return "http://hl7.org/fhir/contact-point-use";
284            case TEMP: return "http://hl7.org/fhir/contact-point-use";
285            case OLD: return "http://hl7.org/fhir/contact-point-use";
286            case MOBILE: return "http://hl7.org/fhir/contact-point-use";
287            case NULL: return null;
288            default: return "?";
289          }
290        }
291        public String getDefinition() {
292          switch (this) {
293            case HOME: return "A communication contact point at a home; attempted contacts for business purposes might intrude privacy and chances are one will contact family or other household members instead of the person one wishes to call. Typically used with urgent cases, or if no other contacts are available.";
294            case WORK: return "An office contact point. First choice for business related contacts during business hours.";
295            case TEMP: return "A temporary contact point. The period can provide more detailed information.";
296            case OLD: return "This contact point is no longer in use (or was never correct, but retained for records).";
297            case MOBILE: return "A telecommunication device that moves and stays with its owner. May have characteristics of all other use codes, suitable for urgent matters, not the first choice for routine business.";
298            case NULL: return null;
299            default: return "?";
300          }
301        }
302        public String getDisplay() {
303          switch (this) {
304            case HOME: return "Home";
305            case WORK: return "Work";
306            case TEMP: return "Temp";
307            case OLD: return "Old";
308            case MOBILE: return "Mobile";
309            case NULL: return null;
310            default: return "?";
311          }
312        }
313    }
314
315  public static class ContactPointUseEnumFactory implements EnumFactory<ContactPointUse> {
316    public ContactPointUse fromCode(String codeString) throws IllegalArgumentException {
317      if (codeString == null || "".equals(codeString))
318            if (codeString == null || "".equals(codeString))
319                return null;
320        if ("home".equals(codeString))
321          return ContactPointUse.HOME;
322        if ("work".equals(codeString))
323          return ContactPointUse.WORK;
324        if ("temp".equals(codeString))
325          return ContactPointUse.TEMP;
326        if ("old".equals(codeString))
327          return ContactPointUse.OLD;
328        if ("mobile".equals(codeString))
329          return ContactPointUse.MOBILE;
330        throw new IllegalArgumentException("Unknown ContactPointUse code '"+codeString+"'");
331        }
332        public Enumeration<ContactPointUse> fromType(Base code) throws FHIRException {
333          if (code == null)
334            return null;
335          if (code.isEmpty())
336            return new Enumeration<ContactPointUse>(this);
337          String codeString = ((PrimitiveType) code).asStringValue();
338          if (codeString == null || "".equals(codeString))
339            return null;
340        if ("home".equals(codeString))
341          return new Enumeration<ContactPointUse>(this, ContactPointUse.HOME);
342        if ("work".equals(codeString))
343          return new Enumeration<ContactPointUse>(this, ContactPointUse.WORK);
344        if ("temp".equals(codeString))
345          return new Enumeration<ContactPointUse>(this, ContactPointUse.TEMP);
346        if ("old".equals(codeString))
347          return new Enumeration<ContactPointUse>(this, ContactPointUse.OLD);
348        if ("mobile".equals(codeString))
349          return new Enumeration<ContactPointUse>(this, ContactPointUse.MOBILE);
350        throw new FHIRException("Unknown ContactPointUse code '"+codeString+"'");
351        }
352    public String toCode(ContactPointUse code) {
353      if (code == ContactPointUse.HOME)
354        return "home";
355      if (code == ContactPointUse.WORK)
356        return "work";
357      if (code == ContactPointUse.TEMP)
358        return "temp";
359      if (code == ContactPointUse.OLD)
360        return "old";
361      if (code == ContactPointUse.MOBILE)
362        return "mobile";
363      return "?";
364      }
365    public String toSystem(ContactPointUse code) {
366      return code.getSystem();
367      }
368    }
369
370    /**
371     * Telecommunications form for contact point - what communications system is required to make use of the contact.
372     */
373    @Child(name = "system", type = {CodeType.class}, order=0, min=0, max=1, modifier=false, summary=true)
374    @Description(shortDefinition="phone | fax | email | pager | url | sms | other", formalDefinition="Telecommunications form for contact point - what communications system is required to make use of the contact." )
375    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/contact-point-system")
376    protected Enumeration<ContactPointSystem> system;
377
378    /**
379     * The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address).
380     */
381    @Child(name = "value", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true)
382    @Description(shortDefinition="The actual contact point details", formalDefinition="The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address)." )
383    protected StringType value;
384
385    /**
386     * Identifies the purpose for the contact point.
387     */
388    @Child(name = "use", type = {CodeType.class}, order=2, min=0, max=1, modifier=true, summary=true)
389    @Description(shortDefinition="home | work | temp | old | mobile - purpose of this contact point", formalDefinition="Identifies the purpose for the contact point." )
390    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/contact-point-use")
391    protected Enumeration<ContactPointUse> use;
392
393    /**
394     * Specifies a preferred order in which to use a set of contacts. Contacts are ranked with lower values coming before higher values.
395     */
396    @Child(name = "rank", type = {PositiveIntType.class}, order=3, min=0, max=1, modifier=false, summary=true)
397    @Description(shortDefinition="Specify preferred order of use (1 = highest)", formalDefinition="Specifies a preferred order in which to use a set of contacts. Contacts are ranked with lower values coming before higher values." )
398    protected PositiveIntType rank;
399
400    /**
401     * Time period when the contact point was/is in use.
402     */
403    @Child(name = "period", type = {Period.class}, order=4, min=0, max=1, modifier=false, summary=true)
404    @Description(shortDefinition="Time period when the contact point was/is in use", formalDefinition="Time period when the contact point was/is in use." )
405    protected Period period;
406
407    private static final long serialVersionUID = 1509610874L;
408
409  /**
410   * Constructor
411   */
412    public ContactPoint() {
413      super();
414    }
415
416    /**
417     * @return {@link #system} (Telecommunications form for contact point - what communications system is required to make use of the contact.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value
418     */
419    public Enumeration<ContactPointSystem> getSystemElement() { 
420      if (this.system == null)
421        if (Configuration.errorOnAutoCreate())
422          throw new Error("Attempt to auto-create ContactPoint.system");
423        else if (Configuration.doAutoCreate())
424          this.system = new Enumeration<ContactPointSystem>(new ContactPointSystemEnumFactory()); // bb
425      return this.system;
426    }
427
428    public boolean hasSystemElement() { 
429      return this.system != null && !this.system.isEmpty();
430    }
431
432    public boolean hasSystem() { 
433      return this.system != null && !this.system.isEmpty();
434    }
435
436    /**
437     * @param value {@link #system} (Telecommunications form for contact point - what communications system is required to make use of the contact.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value
438     */
439    public ContactPoint setSystemElement(Enumeration<ContactPointSystem> value) { 
440      this.system = value;
441      return this;
442    }
443
444    /**
445     * @return Telecommunications form for contact point - what communications system is required to make use of the contact.
446     */
447    public ContactPointSystem getSystem() { 
448      return this.system == null ? null : this.system.getValue();
449    }
450
451    /**
452     * @param value Telecommunications form for contact point - what communications system is required to make use of the contact.
453     */
454    public ContactPoint setSystem(ContactPointSystem value) { 
455      if (value == null)
456        this.system = null;
457      else {
458        if (this.system == null)
459          this.system = new Enumeration<ContactPointSystem>(new ContactPointSystemEnumFactory());
460        this.system.setValue(value);
461      }
462      return this;
463    }
464
465    /**
466     * @return {@link #value} (The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address).). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
467     */
468    public StringType getValueElement() { 
469      if (this.value == null)
470        if (Configuration.errorOnAutoCreate())
471          throw new Error("Attempt to auto-create ContactPoint.value");
472        else if (Configuration.doAutoCreate())
473          this.value = new StringType(); // bb
474      return this.value;
475    }
476
477    public boolean hasValueElement() { 
478      return this.value != null && !this.value.isEmpty();
479    }
480
481    public boolean hasValue() { 
482      return this.value != null && !this.value.isEmpty();
483    }
484
485    /**
486     * @param value {@link #value} (The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address).). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
487     */
488    public ContactPoint setValueElement(StringType value) { 
489      this.value = value;
490      return this;
491    }
492
493    /**
494     * @return The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address).
495     */
496    public String getValue() { 
497      return this.value == null ? null : this.value.getValue();
498    }
499
500    /**
501     * @param value The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address).
502     */
503    public ContactPoint setValue(String value) { 
504      if (Utilities.noString(value))
505        this.value = null;
506      else {
507        if (this.value == null)
508          this.value = new StringType();
509        this.value.setValue(value);
510      }
511      return this;
512    }
513
514    /**
515     * @return {@link #use} (Identifies the purpose for the contact point.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value
516     */
517    public Enumeration<ContactPointUse> getUseElement() { 
518      if (this.use == null)
519        if (Configuration.errorOnAutoCreate())
520          throw new Error("Attempt to auto-create ContactPoint.use");
521        else if (Configuration.doAutoCreate())
522          this.use = new Enumeration<ContactPointUse>(new ContactPointUseEnumFactory()); // bb
523      return this.use;
524    }
525
526    public boolean hasUseElement() { 
527      return this.use != null && !this.use.isEmpty();
528    }
529
530    public boolean hasUse() { 
531      return this.use != null && !this.use.isEmpty();
532    }
533
534    /**
535     * @param value {@link #use} (Identifies the purpose for the contact point.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value
536     */
537    public ContactPoint setUseElement(Enumeration<ContactPointUse> value) { 
538      this.use = value;
539      return this;
540    }
541
542    /**
543     * @return Identifies the purpose for the contact point.
544     */
545    public ContactPointUse getUse() { 
546      return this.use == null ? null : this.use.getValue();
547    }
548
549    /**
550     * @param value Identifies the purpose for the contact point.
551     */
552    public ContactPoint setUse(ContactPointUse value) { 
553      if (value == null)
554        this.use = null;
555      else {
556        if (this.use == null)
557          this.use = new Enumeration<ContactPointUse>(new ContactPointUseEnumFactory());
558        this.use.setValue(value);
559      }
560      return this;
561    }
562
563    /**
564     * @return {@link #rank} (Specifies a preferred order in which to use a set of contacts. Contacts are ranked with lower values coming before higher values.). This is the underlying object with id, value and extensions. The accessor "getRank" gives direct access to the value
565     */
566    public PositiveIntType getRankElement() { 
567      if (this.rank == null)
568        if (Configuration.errorOnAutoCreate())
569          throw new Error("Attempt to auto-create ContactPoint.rank");
570        else if (Configuration.doAutoCreate())
571          this.rank = new PositiveIntType(); // bb
572      return this.rank;
573    }
574
575    public boolean hasRankElement() { 
576      return this.rank != null && !this.rank.isEmpty();
577    }
578
579    public boolean hasRank() { 
580      return this.rank != null && !this.rank.isEmpty();
581    }
582
583    /**
584     * @param value {@link #rank} (Specifies a preferred order in which to use a set of contacts. Contacts are ranked with lower values coming before higher values.). This is the underlying object with id, value and extensions. The accessor "getRank" gives direct access to the value
585     */
586    public ContactPoint setRankElement(PositiveIntType value) { 
587      this.rank = value;
588      return this;
589    }
590
591    /**
592     * @return Specifies a preferred order in which to use a set of contacts. Contacts are ranked with lower values coming before higher values.
593     */
594    public int getRank() { 
595      return this.rank == null || this.rank.isEmpty() ? 0 : this.rank.getValue();
596    }
597
598    /**
599     * @param value Specifies a preferred order in which to use a set of contacts. Contacts are ranked with lower values coming before higher values.
600     */
601    public ContactPoint setRank(int value) { 
602        if (this.rank == null)
603          this.rank = new PositiveIntType();
604        this.rank.setValue(value);
605      return this;
606    }
607
608    /**
609     * @return {@link #period} (Time period when the contact point was/is in use.)
610     */
611    public Period getPeriod() { 
612      if (this.period == null)
613        if (Configuration.errorOnAutoCreate())
614          throw new Error("Attempt to auto-create ContactPoint.period");
615        else if (Configuration.doAutoCreate())
616          this.period = new Period(); // cc
617      return this.period;
618    }
619
620    public boolean hasPeriod() { 
621      return this.period != null && !this.period.isEmpty();
622    }
623
624    /**
625     * @param value {@link #period} (Time period when the contact point was/is in use.)
626     */
627    public ContactPoint setPeriod(Period value)  { 
628      this.period = value;
629      return this;
630    }
631
632      protected void listChildren(List<Property> children) {
633        super.listChildren(children);
634        children.add(new Property("system", "code", "Telecommunications form for contact point - what communications system is required to make use of the contact.", 0, 1, system));
635        children.add(new Property("value", "string", "The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address).", 0, 1, value));
636        children.add(new Property("use", "code", "Identifies the purpose for the contact point.", 0, 1, use));
637        children.add(new Property("rank", "positiveInt", "Specifies a preferred order in which to use a set of contacts. Contacts are ranked with lower values coming before higher values.", 0, 1, rank));
638        children.add(new Property("period", "Period", "Time period when the contact point was/is in use.", 0, 1, period));
639      }
640
641      @Override
642      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
643        switch (_hash) {
644        case -887328209: /*system*/  return new Property("system", "code", "Telecommunications form for contact point - what communications system is required to make use of the contact.", 0, 1, system);
645        case 111972721: /*value*/  return new Property("value", "string", "The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address).", 0, 1, value);
646        case 116103: /*use*/  return new Property("use", "code", "Identifies the purpose for the contact point.", 0, 1, use);
647        case 3492908: /*rank*/  return new Property("rank", "positiveInt", "Specifies a preferred order in which to use a set of contacts. Contacts are ranked with lower values coming before higher values.", 0, 1, rank);
648        case -991726143: /*period*/  return new Property("period", "Period", "Time period when the contact point was/is in use.", 0, 1, period);
649        default: return super.getNamedProperty(_hash, _name, _checkValid);
650        }
651
652      }
653
654      @Override
655      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
656        switch (hash) {
657        case -887328209: /*system*/ return this.system == null ? new Base[0] : new Base[] {this.system}; // Enumeration<ContactPointSystem>
658        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // StringType
659        case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // Enumeration<ContactPointUse>
660        case 3492908: /*rank*/ return this.rank == null ? new Base[0] : new Base[] {this.rank}; // PositiveIntType
661        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
662        default: return super.getProperty(hash, name, checkValid);
663        }
664
665      }
666
667      @Override
668      public Base setProperty(int hash, String name, Base value) throws FHIRException {
669        switch (hash) {
670        case -887328209: // system
671          value = new ContactPointSystemEnumFactory().fromType(castToCode(value));
672          this.system = (Enumeration) value; // Enumeration<ContactPointSystem>
673          return value;
674        case 111972721: // value
675          this.value = castToString(value); // StringType
676          return value;
677        case 116103: // use
678          value = new ContactPointUseEnumFactory().fromType(castToCode(value));
679          this.use = (Enumeration) value; // Enumeration<ContactPointUse>
680          return value;
681        case 3492908: // rank
682          this.rank = castToPositiveInt(value); // PositiveIntType
683          return value;
684        case -991726143: // period
685          this.period = castToPeriod(value); // Period
686          return value;
687        default: return super.setProperty(hash, name, value);
688        }
689
690      }
691
692      @Override
693      public Base setProperty(String name, Base value) throws FHIRException {
694        if (name.equals("system")) {
695          value = new ContactPointSystemEnumFactory().fromType(castToCode(value));
696          this.system = (Enumeration) value; // Enumeration<ContactPointSystem>
697        } else if (name.equals("value")) {
698          this.value = castToString(value); // StringType
699        } else if (name.equals("use")) {
700          value = new ContactPointUseEnumFactory().fromType(castToCode(value));
701          this.use = (Enumeration) value; // Enumeration<ContactPointUse>
702        } else if (name.equals("rank")) {
703          this.rank = castToPositiveInt(value); // PositiveIntType
704        } else if (name.equals("period")) {
705          this.period = castToPeriod(value); // Period
706        } else
707          return super.setProperty(name, value);
708        return value;
709      }
710
711      @Override
712      public Base makeProperty(int hash, String name) throws FHIRException {
713        switch (hash) {
714        case -887328209:  return getSystemElement();
715        case 111972721:  return getValueElement();
716        case 116103:  return getUseElement();
717        case 3492908:  return getRankElement();
718        case -991726143:  return getPeriod(); 
719        default: return super.makeProperty(hash, name);
720        }
721
722      }
723
724      @Override
725      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
726        switch (hash) {
727        case -887328209: /*system*/ return new String[] {"code"};
728        case 111972721: /*value*/ return new String[] {"string"};
729        case 116103: /*use*/ return new String[] {"code"};
730        case 3492908: /*rank*/ return new String[] {"positiveInt"};
731        case -991726143: /*period*/ return new String[] {"Period"};
732        default: return super.getTypesForProperty(hash, name);
733        }
734
735      }
736
737      @Override
738      public Base addChild(String name) throws FHIRException {
739        if (name.equals("system")) {
740          throw new FHIRException("Cannot call addChild on a primitive type ContactPoint.system");
741        }
742        else if (name.equals("value")) {
743          throw new FHIRException("Cannot call addChild on a primitive type ContactPoint.value");
744        }
745        else if (name.equals("use")) {
746          throw new FHIRException("Cannot call addChild on a primitive type ContactPoint.use");
747        }
748        else if (name.equals("rank")) {
749          throw new FHIRException("Cannot call addChild on a primitive type ContactPoint.rank");
750        }
751        else if (name.equals("period")) {
752          this.period = new Period();
753          return this.period;
754        }
755        else
756          return super.addChild(name);
757      }
758
759  public String fhirType() {
760    return "ContactPoint";
761
762  }
763
764      public ContactPoint copy() {
765        ContactPoint dst = new ContactPoint();
766        copyValues(dst);
767        dst.system = system == null ? null : system.copy();
768        dst.value = value == null ? null : value.copy();
769        dst.use = use == null ? null : use.copy();
770        dst.rank = rank == null ? null : rank.copy();
771        dst.period = period == null ? null : period.copy();
772        return dst;
773      }
774
775      protected ContactPoint typedCopy() {
776        return copy();
777      }
778
779      @Override
780      public boolean equalsDeep(Base other_) {
781        if (!super.equalsDeep(other_))
782          return false;
783        if (!(other_ instanceof ContactPoint))
784          return false;
785        ContactPoint o = (ContactPoint) other_;
786        return compareDeep(system, o.system, true) && compareDeep(value, o.value, true) && compareDeep(use, o.use, true)
787           && compareDeep(rank, o.rank, true) && compareDeep(period, o.period, true);
788      }
789
790      @Override
791      public boolean equalsShallow(Base other_) {
792        if (!super.equalsShallow(other_))
793          return false;
794        if (!(other_ instanceof ContactPoint))
795          return false;
796        ContactPoint o = (ContactPoint) other_;
797        return compareValues(system, o.system, true) && compareValues(value, o.value, true) && compareValues(use, o.use, true)
798           && compareValues(rank, o.rank, true);
799      }
800
801      public boolean isEmpty() {
802        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(system, value, use, rank
803          , period);
804      }
805
806
807}