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