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