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