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