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