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