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