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