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