001package org.hl7.fhir.r4.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 Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import org.hl7.fhir.exceptions.FHIRException;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039import org.hl7.fhir.r4.model.Enumerations.AdministrativeGender;
040import org.hl7.fhir.r4.model.Enumerations.AdministrativeGenderEnumFactory;
041
042import ca.uhn.fhir.model.api.annotation.Block;
043import ca.uhn.fhir.model.api.annotation.Child;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.ResourceDef;
046import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
047
048/**
049 * Demographics and administrative information about a person independent of a
050 * specific health-related context.
051 */
052@ResourceDef(name = "Person", profile = "http://hl7.org/fhir/StructureDefinition/Person")
053public class Person extends DomainResource {
054
055  public enum IdentityAssuranceLevel {
056    /**
057     * Little or no confidence in the asserted identity's accuracy.
058     */
059    LEVEL1,
060    /**
061     * Some confidence in the asserted identity's accuracy.
062     */
063    LEVEL2,
064    /**
065     * High confidence in the asserted identity's accuracy.
066     */
067    LEVEL3,
068    /**
069     * Very high confidence in the asserted identity's accuracy.
070     */
071    LEVEL4,
072    /**
073     * added to help the parsers with the generic types
074     */
075    NULL;
076
077    public static IdentityAssuranceLevel fromCode(String codeString) throws FHIRException {
078      if (codeString == null || "".equals(codeString))
079        return null;
080      if ("level1".equals(codeString))
081        return LEVEL1;
082      if ("level2".equals(codeString))
083        return LEVEL2;
084      if ("level3".equals(codeString))
085        return LEVEL3;
086      if ("level4".equals(codeString))
087        return LEVEL4;
088      if (Configuration.isAcceptInvalidEnums())
089        return null;
090      else
091        throw new FHIRException("Unknown IdentityAssuranceLevel code '" + codeString + "'");
092    }
093
094    public String toCode() {
095      switch (this) {
096      case LEVEL1:
097        return "level1";
098      case LEVEL2:
099        return "level2";
100      case LEVEL3:
101        return "level3";
102      case LEVEL4:
103        return "level4";
104      case NULL:
105        return null;
106      default:
107        return "?";
108      }
109    }
110
111    public String getSystem() {
112      switch (this) {
113      case LEVEL1:
114        return "http://hl7.org/fhir/identity-assuranceLevel";
115      case LEVEL2:
116        return "http://hl7.org/fhir/identity-assuranceLevel";
117      case LEVEL3:
118        return "http://hl7.org/fhir/identity-assuranceLevel";
119      case LEVEL4:
120        return "http://hl7.org/fhir/identity-assuranceLevel";
121      case NULL:
122        return null;
123      default:
124        return "?";
125      }
126    }
127
128    public String getDefinition() {
129      switch (this) {
130      case LEVEL1:
131        return "Little or no confidence in the asserted identity's accuracy.";
132      case LEVEL2:
133        return "Some confidence in the asserted identity's accuracy.";
134      case LEVEL3:
135        return "High confidence in the asserted identity's accuracy.";
136      case LEVEL4:
137        return "Very high confidence in the asserted identity's accuracy.";
138      case NULL:
139        return null;
140      default:
141        return "?";
142      }
143    }
144
145    public String getDisplay() {
146      switch (this) {
147      case LEVEL1:
148        return "Level 1";
149      case LEVEL2:
150        return "Level 2";
151      case LEVEL3:
152        return "Level 3";
153      case LEVEL4:
154        return "Level 4";
155      case NULL:
156        return null;
157      default:
158        return "?";
159      }
160    }
161  }
162
163  public static class IdentityAssuranceLevelEnumFactory implements EnumFactory<IdentityAssuranceLevel> {
164    public IdentityAssuranceLevel fromCode(String codeString) throws IllegalArgumentException {
165      if (codeString == null || "".equals(codeString))
166        if (codeString == null || "".equals(codeString))
167          return null;
168      if ("level1".equals(codeString))
169        return IdentityAssuranceLevel.LEVEL1;
170      if ("level2".equals(codeString))
171        return IdentityAssuranceLevel.LEVEL2;
172      if ("level3".equals(codeString))
173        return IdentityAssuranceLevel.LEVEL3;
174      if ("level4".equals(codeString))
175        return IdentityAssuranceLevel.LEVEL4;
176      throw new IllegalArgumentException("Unknown IdentityAssuranceLevel code '" + codeString + "'");
177    }
178
179    public Enumeration<IdentityAssuranceLevel> fromType(PrimitiveType<?> code) throws FHIRException {
180      if (code == null)
181        return null;
182      if (code.isEmpty())
183        return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.NULL, code);
184      String codeString = code.asStringValue();
185      if (codeString == null || "".equals(codeString))
186        return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.NULL, code);
187      if ("level1".equals(codeString))
188        return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.LEVEL1, code);
189      if ("level2".equals(codeString))
190        return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.LEVEL2, code);
191      if ("level3".equals(codeString))
192        return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.LEVEL3, code);
193      if ("level4".equals(codeString))
194        return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.LEVEL4, code);
195      throw new FHIRException("Unknown IdentityAssuranceLevel code '" + codeString + "'");
196    }
197
198    public String toCode(IdentityAssuranceLevel code) {
199      if (code == IdentityAssuranceLevel.LEVEL1)
200        return "level1";
201      if (code == IdentityAssuranceLevel.LEVEL2)
202        return "level2";
203      if (code == IdentityAssuranceLevel.LEVEL3)
204        return "level3";
205      if (code == IdentityAssuranceLevel.LEVEL4)
206        return "level4";
207      return "?";
208    }
209
210    public String toSystem(IdentityAssuranceLevel code) {
211      return code.getSystem();
212    }
213  }
214
215  @Block()
216  public static class PersonLinkComponent extends BackboneElement implements IBaseBackboneElement {
217    /**
218     * The resource to which this actual person is associated.
219     */
220    @Child(name = "target", type = { Patient.class, Practitioner.class, RelatedPerson.class,
221        Person.class }, order = 1, min = 1, max = 1, modifier = false, summary = false)
222    @Description(shortDefinition = "The resource to which this actual person is associated", formalDefinition = "The resource to which this actual person is associated.")
223    protected Reference target;
224
225    /**
226     * The actual object that is the target of the reference (The resource to which
227     * this actual person is associated.)
228     */
229    protected Resource targetTarget;
230
231    /**
232     * Level of assurance that this link is associated with the target resource.
233     */
234    @Child(name = "assurance", type = {
235        CodeType.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
236    @Description(shortDefinition = "level1 | level2 | level3 | level4", formalDefinition = "Level of assurance that this link is associated with the target resource.")
237    @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/identity-assuranceLevel")
238    protected Enumeration<IdentityAssuranceLevel> assurance;
239
240    private static final long serialVersionUID = 508763647L;
241
242    /**
243     * Constructor
244     */
245    public PersonLinkComponent() {
246      super();
247    }
248
249    /**
250     * Constructor
251     */
252    public PersonLinkComponent(Reference target) {
253      super();
254      this.target = target;
255    }
256
257    /**
258     * @return {@link #target} (The resource to which this actual person is
259     *         associated.)
260     */
261    public Reference getTarget() {
262      if (this.target == null)
263        if (Configuration.errorOnAutoCreate())
264          throw new Error("Attempt to auto-create PersonLinkComponent.target");
265        else if (Configuration.doAutoCreate())
266          this.target = new Reference(); // cc
267      return this.target;
268    }
269
270    public boolean hasTarget() {
271      return this.target != null && !this.target.isEmpty();
272    }
273
274    /**
275     * @param value {@link #target} (The resource to which this actual person is
276     *              associated.)
277     */
278    public PersonLinkComponent setTarget(Reference value) {
279      this.target = value;
280      return this;
281    }
282
283    /**
284     * @return {@link #target} The actual object that is the target of the
285     *         reference. The reference library doesn't populate this, but you can
286     *         use it to hold the resource if you resolve it. (The resource to which
287     *         this actual person is associated.)
288     */
289    public Resource getTargetTarget() {
290      return this.targetTarget;
291    }
292
293    /**
294     * @param value {@link #target} The actual object that is the target of the
295     *              reference. The reference library doesn't use these, but you can
296     *              use it to hold the resource if you resolve it. (The resource to
297     *              which this actual person is associated.)
298     */
299    public PersonLinkComponent setTargetTarget(Resource value) {
300      this.targetTarget = value;
301      return this;
302    }
303
304    /**
305     * @return {@link #assurance} (Level of assurance that this link is associated
306     *         with the target resource.). This is the underlying object with id,
307     *         value and extensions. The accessor "getAssurance" gives direct access
308     *         to the value
309     */
310    public Enumeration<IdentityAssuranceLevel> getAssuranceElement() {
311      if (this.assurance == null)
312        if (Configuration.errorOnAutoCreate())
313          throw new Error("Attempt to auto-create PersonLinkComponent.assurance");
314        else if (Configuration.doAutoCreate())
315          this.assurance = new Enumeration<IdentityAssuranceLevel>(new IdentityAssuranceLevelEnumFactory()); // bb
316      return this.assurance;
317    }
318
319    public boolean hasAssuranceElement() {
320      return this.assurance != null && !this.assurance.isEmpty();
321    }
322
323    public boolean hasAssurance() {
324      return this.assurance != null && !this.assurance.isEmpty();
325    }
326
327    /**
328     * @param value {@link #assurance} (Level of assurance that this link is
329     *              associated with the target resource.). This is the underlying
330     *              object with id, value and extensions. The accessor
331     *              "getAssurance" gives direct access to the value
332     */
333    public PersonLinkComponent setAssuranceElement(Enumeration<IdentityAssuranceLevel> value) {
334      this.assurance = value;
335      return this;
336    }
337
338    /**
339     * @return Level of assurance that this link is associated with the target
340     *         resource.
341     */
342    public IdentityAssuranceLevel getAssurance() {
343      return this.assurance == null ? null : this.assurance.getValue();
344    }
345
346    /**
347     * @param value Level of assurance that this link is associated with the target
348     *              resource.
349     */
350    public PersonLinkComponent setAssurance(IdentityAssuranceLevel value) {
351      if (value == null)
352        this.assurance = null;
353      else {
354        if (this.assurance == null)
355          this.assurance = new Enumeration<IdentityAssuranceLevel>(new IdentityAssuranceLevelEnumFactory());
356        this.assurance.setValue(value);
357      }
358      return this;
359    }
360
361    protected void listChildren(List<Property> children) {
362      super.listChildren(children);
363      children.add(new Property("target", "Reference(Patient|Practitioner|RelatedPerson|Person)",
364          "The resource to which this actual person is associated.", 0, 1, target));
365      children.add(new Property("assurance", "code",
366          "Level of assurance that this link is associated with the target resource.", 0, 1, assurance));
367    }
368
369    @Override
370    public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
371      switch (_hash) {
372      case -880905839:
373        /* target */ return new Property("target", "Reference(Patient|Practitioner|RelatedPerson|Person)",
374            "The resource to which this actual person is associated.", 0, 1, target);
375      case 1771900717:
376        /* assurance */ return new Property("assurance", "code",
377            "Level of assurance that this link is associated with the target resource.", 0, 1, assurance);
378      default:
379        return super.getNamedProperty(_hash, _name, _checkValid);
380      }
381
382    }
383
384    @Override
385    public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
386      switch (hash) {
387      case -880905839:
388        /* target */ return this.target == null ? new Base[0] : new Base[] { this.target }; // Reference
389      case 1771900717:
390        /* assurance */ return this.assurance == null ? new Base[0] : new Base[] { this.assurance }; // Enumeration<IdentityAssuranceLevel>
391      default:
392        return super.getProperty(hash, name, checkValid);
393      }
394
395    }
396
397    @Override
398    public Base setProperty(int hash, String name, Base value) throws FHIRException {
399      switch (hash) {
400      case -880905839: // target
401        this.target = castToReference(value); // Reference
402        return value;
403      case 1771900717: // assurance
404        value = new IdentityAssuranceLevelEnumFactory().fromType(castToCode(value));
405        this.assurance = (Enumeration) value; // Enumeration<IdentityAssuranceLevel>
406        return value;
407      default:
408        return super.setProperty(hash, name, value);
409      }
410
411    }
412
413    @Override
414    public Base setProperty(String name, Base value) throws FHIRException {
415      if (name.equals("target")) {
416        this.target = castToReference(value); // Reference
417      } else if (name.equals("assurance")) {
418        value = new IdentityAssuranceLevelEnumFactory().fromType(castToCode(value));
419        this.assurance = (Enumeration) value; // Enumeration<IdentityAssuranceLevel>
420      } else
421        return super.setProperty(name, value);
422      return value;
423    }
424
425  @Override
426  public void removeChild(String name, Base value) throws FHIRException {
427      if (name.equals("target")) {
428        this.target = null;
429      } else if (name.equals("assurance")) {
430        this.assurance = null;
431      } else
432        super.removeChild(name, value);
433      
434    }
435
436    @Override
437    public Base makeProperty(int hash, String name) throws FHIRException {
438      switch (hash) {
439      case -880905839:
440        return getTarget();
441      case 1771900717:
442        return getAssuranceElement();
443      default:
444        return super.makeProperty(hash, name);
445      }
446
447    }
448
449    @Override
450    public String[] getTypesForProperty(int hash, String name) throws FHIRException {
451      switch (hash) {
452      case -880905839:
453        /* target */ return new String[] { "Reference" };
454      case 1771900717:
455        /* assurance */ return new String[] { "code" };
456      default:
457        return super.getTypesForProperty(hash, name);
458      }
459
460    }
461
462    @Override
463    public Base addChild(String name) throws FHIRException {
464      if (name.equals("target")) {
465        this.target = new Reference();
466        return this.target;
467      } else if (name.equals("assurance")) {
468        throw new FHIRException("Cannot call addChild on a singleton property Person.assurance");
469      } else
470        return super.addChild(name);
471    }
472
473    public PersonLinkComponent copy() {
474      PersonLinkComponent dst = new PersonLinkComponent();
475      copyValues(dst);
476      return dst;
477    }
478
479    public void copyValues(PersonLinkComponent dst) {
480      super.copyValues(dst);
481      dst.target = target == null ? null : target.copy();
482      dst.assurance = assurance == null ? null : assurance.copy();
483    }
484
485    @Override
486    public boolean equalsDeep(Base other_) {
487      if (!super.equalsDeep(other_))
488        return false;
489      if (!(other_ instanceof PersonLinkComponent))
490        return false;
491      PersonLinkComponent o = (PersonLinkComponent) other_;
492      return compareDeep(target, o.target, true) && compareDeep(assurance, o.assurance, true);
493    }
494
495    @Override
496    public boolean equalsShallow(Base other_) {
497      if (!super.equalsShallow(other_))
498        return false;
499      if (!(other_ instanceof PersonLinkComponent))
500        return false;
501      PersonLinkComponent o = (PersonLinkComponent) other_;
502      return compareValues(assurance, o.assurance, true);
503    }
504
505    public boolean isEmpty() {
506      return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(target, assurance);
507    }
508
509    public String fhirType() {
510      return "Person.link";
511
512    }
513
514  }
515
516  /**
517   * Identifier for a person within a particular scope.
518   */
519  @Child(name = "identifier", type = {
520      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
521  @Description(shortDefinition = "A human identifier for this person", formalDefinition = "Identifier for a person within a particular scope.")
522  protected List<Identifier> identifier;
523
524  /**
525   * A name associated with the person.
526   */
527  @Child(name = "name", type = {
528      HumanName.class }, order = 1, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
529  @Description(shortDefinition = "A name associated with the person", formalDefinition = "A name associated with the person.")
530  protected List<HumanName> name;
531
532  /**
533   * A contact detail for the person, e.g. a telephone number or an email address.
534   */
535  @Child(name = "telecom", type = {
536      ContactPoint.class }, order = 2, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
537  @Description(shortDefinition = "A contact detail for the person", formalDefinition = "A contact detail for the person, e.g. a telephone number or an email address.")
538  protected List<ContactPoint> telecom;
539
540  /**
541   * Administrative Gender.
542   */
543  @Child(name = "gender", type = { CodeType.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
544  @Description(shortDefinition = "male | female | other | unknown", formalDefinition = "Administrative Gender.")
545  @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/administrative-gender")
546  protected Enumeration<AdministrativeGender> gender;
547
548  /**
549   * The birth date for the person.
550   */
551  @Child(name = "birthDate", type = { DateType.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
552  @Description(shortDefinition = "The date on which the person was born", formalDefinition = "The birth date for the person.")
553  protected DateType birthDate;
554
555  /**
556   * One or more addresses for the person.
557   */
558  @Child(name = "address", type = {
559      Address.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
560  @Description(shortDefinition = "One or more addresses for the person", formalDefinition = "One or more addresses for the person.")
561  protected List<Address> address;
562
563  /**
564   * An image that can be displayed as a thumbnail of the person to enhance the
565   * identification of the individual.
566   */
567  @Child(name = "photo", type = { Attachment.class }, order = 6, min = 0, max = 1, modifier = false, summary = false)
568  @Description(shortDefinition = "Image of the person", formalDefinition = "An image that can be displayed as a thumbnail of the person to enhance the identification of the individual.")
569  protected Attachment photo;
570
571  /**
572   * The organization that is the custodian of the person record.
573   */
574  @Child(name = "managingOrganization", type = {
575      Organization.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
576  @Description(shortDefinition = "The organization that is the custodian of the person record", formalDefinition = "The organization that is the custodian of the person record.")
577  protected Reference managingOrganization;
578
579  /**
580   * The actual object that is the target of the reference (The organization that
581   * is the custodian of the person record.)
582   */
583  protected Organization managingOrganizationTarget;
584
585  /**
586   * Whether this person's record is in active use.
587   */
588  @Child(name = "active", type = { BooleanType.class }, order = 8, min = 0, max = 1, modifier = true, summary = true)
589  @Description(shortDefinition = "This person's record is in active use", formalDefinition = "Whether this person's record is in active use.")
590  protected BooleanType active;
591
592  /**
593   * Link to a resource that concerns the same actual person.
594   */
595  @Child(name = "link", type = {}, order = 9, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
596  @Description(shortDefinition = "Link to a resource that concerns the same actual person", formalDefinition = "Link to a resource that concerns the same actual person.")
597  protected List<PersonLinkComponent> link;
598
599  private static final long serialVersionUID = -117464654L;
600
601  /**
602   * Constructor
603   */
604  public Person() {
605    super();
606  }
607
608  /**
609   * @return {@link #identifier} (Identifier for a person within a particular
610   *         scope.)
611   */
612  public List<Identifier> getIdentifier() {
613    if (this.identifier == null)
614      this.identifier = new ArrayList<Identifier>();
615    return this.identifier;
616  }
617
618  /**
619   * @return Returns a reference to <code>this</code> for easy method chaining
620   */
621  public Person setIdentifier(List<Identifier> theIdentifier) {
622    this.identifier = theIdentifier;
623    return this;
624  }
625
626  public boolean hasIdentifier() {
627    if (this.identifier == null)
628      return false;
629    for (Identifier item : this.identifier)
630      if (!item.isEmpty())
631        return true;
632    return false;
633  }
634
635  public Identifier addIdentifier() { // 3
636    Identifier t = new Identifier();
637    if (this.identifier == null)
638      this.identifier = new ArrayList<Identifier>();
639    this.identifier.add(t);
640    return t;
641  }
642
643  public Person addIdentifier(Identifier t) { // 3
644    if (t == null)
645      return this;
646    if (this.identifier == null)
647      this.identifier = new ArrayList<Identifier>();
648    this.identifier.add(t);
649    return this;
650  }
651
652  /**
653   * @return The first repetition of repeating field {@link #identifier}, creating
654   *         it if it does not already exist
655   */
656  public Identifier getIdentifierFirstRep() {
657    if (getIdentifier().isEmpty()) {
658      addIdentifier();
659    }
660    return getIdentifier().get(0);
661  }
662
663  /**
664   * @return {@link #name} (A name associated with the person.)
665   */
666  public List<HumanName> getName() {
667    if (this.name == null)
668      this.name = new ArrayList<HumanName>();
669    return this.name;
670  }
671
672  /**
673   * @return Returns a reference to <code>this</code> for easy method chaining
674   */
675  public Person setName(List<HumanName> theName) {
676    this.name = theName;
677    return this;
678  }
679
680  public boolean hasName() {
681    if (this.name == null)
682      return false;
683    for (HumanName item : this.name)
684      if (!item.isEmpty())
685        return true;
686    return false;
687  }
688
689  public HumanName addName() { // 3
690    HumanName t = new HumanName();
691    if (this.name == null)
692      this.name = new ArrayList<HumanName>();
693    this.name.add(t);
694    return t;
695  }
696
697  public Person addName(HumanName t) { // 3
698    if (t == null)
699      return this;
700    if (this.name == null)
701      this.name = new ArrayList<HumanName>();
702    this.name.add(t);
703    return this;
704  }
705
706  /**
707   * @return The first repetition of repeating field {@link #name}, creating it if
708   *         it does not already exist
709   */
710  public HumanName getNameFirstRep() {
711    if (getName().isEmpty()) {
712      addName();
713    }
714    return getName().get(0);
715  }
716
717  /**
718   * @return {@link #telecom} (A contact detail for the person, e.g. a telephone
719   *         number or an email address.)
720   */
721  public List<ContactPoint> getTelecom() {
722    if (this.telecom == null)
723      this.telecom = new ArrayList<ContactPoint>();
724    return this.telecom;
725  }
726
727  /**
728   * @return Returns a reference to <code>this</code> for easy method chaining
729   */
730  public Person setTelecom(List<ContactPoint> theTelecom) {
731    this.telecom = theTelecom;
732    return this;
733  }
734
735  public boolean hasTelecom() {
736    if (this.telecom == null)
737      return false;
738    for (ContactPoint item : this.telecom)
739      if (!item.isEmpty())
740        return true;
741    return false;
742  }
743
744  public ContactPoint addTelecom() { // 3
745    ContactPoint t = new ContactPoint();
746    if (this.telecom == null)
747      this.telecom = new ArrayList<ContactPoint>();
748    this.telecom.add(t);
749    return t;
750  }
751
752  public Person addTelecom(ContactPoint t) { // 3
753    if (t == null)
754      return this;
755    if (this.telecom == null)
756      this.telecom = new ArrayList<ContactPoint>();
757    this.telecom.add(t);
758    return this;
759  }
760
761  /**
762   * @return The first repetition of repeating field {@link #telecom}, creating it
763   *         if it does not already exist
764   */
765  public ContactPoint getTelecomFirstRep() {
766    if (getTelecom().isEmpty()) {
767      addTelecom();
768    }
769    return getTelecom().get(0);
770  }
771
772  /**
773   * @return {@link #gender} (Administrative Gender.). This is the underlying
774   *         object with id, value and extensions. The accessor "getGender" gives
775   *         direct access to the value
776   */
777  public Enumeration<AdministrativeGender> getGenderElement() {
778    if (this.gender == null)
779      if (Configuration.errorOnAutoCreate())
780        throw new Error("Attempt to auto-create Person.gender");
781      else if (Configuration.doAutoCreate())
782        this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory()); // bb
783    return this.gender;
784  }
785
786  public boolean hasGenderElement() {
787    return this.gender != null && !this.gender.isEmpty();
788  }
789
790  public boolean hasGender() {
791    return this.gender != null && !this.gender.isEmpty();
792  }
793
794  /**
795   * @param value {@link #gender} (Administrative Gender.). This is the underlying
796   *              object with id, value and extensions. The accessor "getGender"
797   *              gives direct access to the value
798   */
799  public Person setGenderElement(Enumeration<AdministrativeGender> value) {
800    this.gender = value;
801    return this;
802  }
803
804  /**
805   * @return Administrative Gender.
806   */
807  public AdministrativeGender getGender() {
808    return this.gender == null ? null : this.gender.getValue();
809  }
810
811  /**
812   * @param value Administrative Gender.
813   */
814  public Person setGender(AdministrativeGender value) {
815    if (value == null)
816      this.gender = null;
817    else {
818      if (this.gender == null)
819        this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory());
820      this.gender.setValue(value);
821    }
822    return this;
823  }
824
825  /**
826   * @return {@link #birthDate} (The birth date for the person.). This is the
827   *         underlying object with id, value and extensions. The accessor
828   *         "getBirthDate" gives direct access to the value
829   */
830  public DateType getBirthDateElement() {
831    if (this.birthDate == null)
832      if (Configuration.errorOnAutoCreate())
833        throw new Error("Attempt to auto-create Person.birthDate");
834      else if (Configuration.doAutoCreate())
835        this.birthDate = new DateType(); // bb
836    return this.birthDate;
837  }
838
839  public boolean hasBirthDateElement() {
840    return this.birthDate != null && !this.birthDate.isEmpty();
841  }
842
843  public boolean hasBirthDate() {
844    return this.birthDate != null && !this.birthDate.isEmpty();
845  }
846
847  /**
848   * @param value {@link #birthDate} (The birth date for the person.). This is the
849   *              underlying object with id, value and extensions. The accessor
850   *              "getBirthDate" gives direct access to the value
851   */
852  public Person setBirthDateElement(DateType value) {
853    this.birthDate = value;
854    return this;
855  }
856
857  /**
858   * @return The birth date for the person.
859   */
860  public Date getBirthDate() {
861    return this.birthDate == null ? null : this.birthDate.getValue();
862  }
863
864  /**
865   * @param value The birth date for the person.
866   */
867  public Person setBirthDate(Date value) {
868    if (value == null)
869      this.birthDate = null;
870    else {
871      if (this.birthDate == null)
872        this.birthDate = new DateType();
873      this.birthDate.setValue(value);
874    }
875    return this;
876  }
877
878  /**
879   * @return {@link #address} (One or more addresses for the person.)
880   */
881  public List<Address> getAddress() {
882    if (this.address == null)
883      this.address = new ArrayList<Address>();
884    return this.address;
885  }
886
887  /**
888   * @return Returns a reference to <code>this</code> for easy method chaining
889   */
890  public Person setAddress(List<Address> theAddress) {
891    this.address = theAddress;
892    return this;
893  }
894
895  public boolean hasAddress() {
896    if (this.address == null)
897      return false;
898    for (Address item : this.address)
899      if (!item.isEmpty())
900        return true;
901    return false;
902  }
903
904  public Address addAddress() { // 3
905    Address t = new Address();
906    if (this.address == null)
907      this.address = new ArrayList<Address>();
908    this.address.add(t);
909    return t;
910  }
911
912  public Person addAddress(Address t) { // 3
913    if (t == null)
914      return this;
915    if (this.address == null)
916      this.address = new ArrayList<Address>();
917    this.address.add(t);
918    return this;
919  }
920
921  /**
922   * @return The first repetition of repeating field {@link #address}, creating it
923   *         if it does not already exist
924   */
925  public Address getAddressFirstRep() {
926    if (getAddress().isEmpty()) {
927      addAddress();
928    }
929    return getAddress().get(0);
930  }
931
932  /**
933   * @return {@link #photo} (An image that can be displayed as a thumbnail of the
934   *         person to enhance the identification of the individual.)
935   */
936  public Attachment getPhoto() {
937    if (this.photo == null)
938      if (Configuration.errorOnAutoCreate())
939        throw new Error("Attempt to auto-create Person.photo");
940      else if (Configuration.doAutoCreate())
941        this.photo = new Attachment(); // cc
942    return this.photo;
943  }
944
945  public boolean hasPhoto() {
946    return this.photo != null && !this.photo.isEmpty();
947  }
948
949  /**
950   * @param value {@link #photo} (An image that can be displayed as a thumbnail of
951   *              the person to enhance the identification of the individual.)
952   */
953  public Person setPhoto(Attachment value) {
954    this.photo = value;
955    return this;
956  }
957
958  /**
959   * @return {@link #managingOrganization} (The organization that is the custodian
960   *         of the person record.)
961   */
962  public Reference getManagingOrganization() {
963    if (this.managingOrganization == null)
964      if (Configuration.errorOnAutoCreate())
965        throw new Error("Attempt to auto-create Person.managingOrganization");
966      else if (Configuration.doAutoCreate())
967        this.managingOrganization = new Reference(); // cc
968    return this.managingOrganization;
969  }
970
971  public boolean hasManagingOrganization() {
972    return this.managingOrganization != null && !this.managingOrganization.isEmpty();
973  }
974
975  /**
976   * @param value {@link #managingOrganization} (The organization that is the
977   *              custodian of the person record.)
978   */
979  public Person setManagingOrganization(Reference value) {
980    this.managingOrganization = value;
981    return this;
982  }
983
984  /**
985   * @return {@link #managingOrganization} The actual object that is the target of
986   *         the reference. The reference library doesn't populate this, but you
987   *         can use it to hold the resource if you resolve it. (The organization
988   *         that is the custodian of the person record.)
989   */
990  public Organization getManagingOrganizationTarget() {
991    if (this.managingOrganizationTarget == null)
992      if (Configuration.errorOnAutoCreate())
993        throw new Error("Attempt to auto-create Person.managingOrganization");
994      else if (Configuration.doAutoCreate())
995        this.managingOrganizationTarget = new Organization(); // aa
996    return this.managingOrganizationTarget;
997  }
998
999  /**
1000   * @param value {@link #managingOrganization} The actual object that is the
1001   *              target of the reference. The reference library doesn't use
1002   *              these, but you can use it to hold the resource if you resolve
1003   *              it. (The organization that is the custodian of the person
1004   *              record.)
1005   */
1006  public Person setManagingOrganizationTarget(Organization value) {
1007    this.managingOrganizationTarget = value;
1008    return this;
1009  }
1010
1011  /**
1012   * @return {@link #active} (Whether this person's record is in active use.).
1013   *         This is the underlying object with id, value and extensions. The
1014   *         accessor "getActive" gives direct access to the value
1015   */
1016  public BooleanType getActiveElement() {
1017    if (this.active == null)
1018      if (Configuration.errorOnAutoCreate())
1019        throw new Error("Attempt to auto-create Person.active");
1020      else if (Configuration.doAutoCreate())
1021        this.active = new BooleanType(); // bb
1022    return this.active;
1023  }
1024
1025  public boolean hasActiveElement() {
1026    return this.active != null && !this.active.isEmpty();
1027  }
1028
1029  public boolean hasActive() {
1030    return this.active != null && !this.active.isEmpty();
1031  }
1032
1033  /**
1034   * @param value {@link #active} (Whether this person's record is in active
1035   *              use.). This is the underlying object with id, value and
1036   *              extensions. The accessor "getActive" gives direct access to the
1037   *              value
1038   */
1039  public Person setActiveElement(BooleanType value) {
1040    this.active = value;
1041    return this;
1042  }
1043
1044  /**
1045   * @return Whether this person's record is in active use.
1046   */
1047  public boolean getActive() {
1048    return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
1049  }
1050
1051  /**
1052   * @param value Whether this person's record is in active use.
1053   */
1054  public Person setActive(boolean value) {
1055    if (this.active == null)
1056      this.active = new BooleanType();
1057    this.active.setValue(value);
1058    return this;
1059  }
1060
1061  /**
1062   * @return {@link #link} (Link to a resource that concerns the same actual
1063   *         person.)
1064   */
1065  public List<PersonLinkComponent> getLink() {
1066    if (this.link == null)
1067      this.link = new ArrayList<PersonLinkComponent>();
1068    return this.link;
1069  }
1070
1071  /**
1072   * @return Returns a reference to <code>this</code> for easy method chaining
1073   */
1074  public Person setLink(List<PersonLinkComponent> theLink) {
1075    this.link = theLink;
1076    return this;
1077  }
1078
1079  public boolean hasLink() {
1080    if (this.link == null)
1081      return false;
1082    for (PersonLinkComponent item : this.link)
1083      if (!item.isEmpty())
1084        return true;
1085    return false;
1086  }
1087
1088  public PersonLinkComponent addLink() { // 3
1089    PersonLinkComponent t = new PersonLinkComponent();
1090    if (this.link == null)
1091      this.link = new ArrayList<PersonLinkComponent>();
1092    this.link.add(t);
1093    return t;
1094  }
1095
1096  public Person addLink(PersonLinkComponent t) { // 3
1097    if (t == null)
1098      return this;
1099    if (this.link == null)
1100      this.link = new ArrayList<PersonLinkComponent>();
1101    this.link.add(t);
1102    return this;
1103  }
1104
1105  /**
1106   * @return The first repetition of repeating field {@link #link}, creating it if
1107   *         it does not already exist
1108   */
1109  public PersonLinkComponent getLinkFirstRep() {
1110    if (getLink().isEmpty()) {
1111      addLink();
1112    }
1113    return getLink().get(0);
1114  }
1115
1116  protected void listChildren(List<Property> children) {
1117    super.listChildren(children);
1118    children.add(new Property("identifier", "Identifier", "Identifier for a person within a particular scope.", 0,
1119        java.lang.Integer.MAX_VALUE, identifier));
1120    children.add(
1121        new Property("name", "HumanName", "A name associated with the person.", 0, java.lang.Integer.MAX_VALUE, name));
1122    children.add(new Property("telecom", "ContactPoint",
1123        "A contact detail for the person, e.g. a telephone number or an email address.", 0, java.lang.Integer.MAX_VALUE,
1124        telecom));
1125    children.add(new Property("gender", "code", "Administrative Gender.", 0, 1, gender));
1126    children.add(new Property("birthDate", "date", "The birth date for the person.", 0, 1, birthDate));
1127    children.add(new Property("address", "Address", "One or more addresses for the person.", 0,
1128        java.lang.Integer.MAX_VALUE, address));
1129    children.add(new Property("photo", "Attachment",
1130        "An image that can be displayed as a thumbnail of the person to enhance the identification of the individual.",
1131        0, 1, photo));
1132    children.add(new Property("managingOrganization", "Reference(Organization)",
1133        "The organization that is the custodian of the person record.", 0, 1, managingOrganization));
1134    children.add(new Property("active", "boolean", "Whether this person's record is in active use.", 0, 1, active));
1135    children.add(new Property("link", "", "Link to a resource that concerns the same actual person.", 0,
1136        java.lang.Integer.MAX_VALUE, link));
1137  }
1138
1139  @Override
1140  public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1141    switch (_hash) {
1142    case -1618432855:
1143      /* identifier */ return new Property("identifier", "Identifier",
1144          "Identifier for a person within a particular scope.", 0, java.lang.Integer.MAX_VALUE, identifier);
1145    case 3373707:
1146      /* name */ return new Property("name", "HumanName", "A name associated with the person.", 0,
1147          java.lang.Integer.MAX_VALUE, name);
1148    case -1429363305:
1149      /* telecom */ return new Property("telecom", "ContactPoint",
1150          "A contact detail for the person, e.g. a telephone number or an email address.", 0,
1151          java.lang.Integer.MAX_VALUE, telecom);
1152    case -1249512767:
1153      /* gender */ return new Property("gender", "code", "Administrative Gender.", 0, 1, gender);
1154    case -1210031859:
1155      /* birthDate */ return new Property("birthDate", "date", "The birth date for the person.", 0, 1, birthDate);
1156    case -1147692044:
1157      /* address */ return new Property("address", "Address", "One or more addresses for the person.", 0,
1158          java.lang.Integer.MAX_VALUE, address);
1159    case 106642994:
1160      /* photo */ return new Property("photo", "Attachment",
1161          "An image that can be displayed as a thumbnail of the person to enhance the identification of the individual.",
1162          0, 1, photo);
1163    case -2058947787:
1164      /* managingOrganization */ return new Property("managingOrganization", "Reference(Organization)",
1165          "The organization that is the custodian of the person record.", 0, 1, managingOrganization);
1166    case -1422950650:
1167      /* active */ return new Property("active", "boolean", "Whether this person's record is in active use.", 0, 1,
1168          active);
1169    case 3321850:
1170      /* link */ return new Property("link", "", "Link to a resource that concerns the same actual person.", 0,
1171          java.lang.Integer.MAX_VALUE, link);
1172    default:
1173      return super.getNamedProperty(_hash, _name, _checkValid);
1174    }
1175
1176  }
1177
1178  @Override
1179  public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1180    switch (hash) {
1181    case -1618432855:
1182      /* identifier */ return this.identifier == null ? new Base[0]
1183          : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1184    case 3373707:
1185      /* name */ return this.name == null ? new Base[0] : this.name.toArray(new Base[this.name.size()]); // HumanName
1186    case -1429363305:
1187      /* telecom */ return this.telecom == null ? new Base[0] : this.telecom.toArray(new Base[this.telecom.size()]); // ContactPoint
1188    case -1249512767:
1189      /* gender */ return this.gender == null ? new Base[0] : new Base[] { this.gender }; // Enumeration<AdministrativeGender>
1190    case -1210031859:
1191      /* birthDate */ return this.birthDate == null ? new Base[0] : new Base[] { this.birthDate }; // DateType
1192    case -1147692044:
1193      /* address */ return this.address == null ? new Base[0] : this.address.toArray(new Base[this.address.size()]); // Address
1194    case 106642994:
1195      /* photo */ return this.photo == null ? new Base[0] : new Base[] { this.photo }; // Attachment
1196    case -2058947787:
1197      /* managingOrganization */ return this.managingOrganization == null ? new Base[0]
1198          : new Base[] { this.managingOrganization }; // Reference
1199    case -1422950650:
1200      /* active */ return this.active == null ? new Base[0] : new Base[] { this.active }; // BooleanType
1201    case 3321850:
1202      /* link */ return this.link == null ? new Base[0] : this.link.toArray(new Base[this.link.size()]); // PersonLinkComponent
1203    default:
1204      return super.getProperty(hash, name, checkValid);
1205    }
1206
1207  }
1208
1209  @Override
1210  public Base setProperty(int hash, String name, Base value) throws FHIRException {
1211    switch (hash) {
1212    case -1618432855: // identifier
1213      this.getIdentifier().add(castToIdentifier(value)); // Identifier
1214      return value;
1215    case 3373707: // name
1216      this.getName().add(castToHumanName(value)); // HumanName
1217      return value;
1218    case -1429363305: // telecom
1219      this.getTelecom().add(castToContactPoint(value)); // ContactPoint
1220      return value;
1221    case -1249512767: // gender
1222      value = new AdministrativeGenderEnumFactory().fromType(castToCode(value));
1223      this.gender = (Enumeration) value; // Enumeration<AdministrativeGender>
1224      return value;
1225    case -1210031859: // birthDate
1226      this.birthDate = castToDate(value); // DateType
1227      return value;
1228    case -1147692044: // address
1229      this.getAddress().add(castToAddress(value)); // Address
1230      return value;
1231    case 106642994: // photo
1232      this.photo = castToAttachment(value); // Attachment
1233      return value;
1234    case -2058947787: // managingOrganization
1235      this.managingOrganization = castToReference(value); // Reference
1236      return value;
1237    case -1422950650: // active
1238      this.active = castToBoolean(value); // BooleanType
1239      return value;
1240    case 3321850: // link
1241      this.getLink().add((PersonLinkComponent) value); // PersonLinkComponent
1242      return value;
1243    default:
1244      return super.setProperty(hash, name, value);
1245    }
1246
1247  }
1248
1249  @Override
1250  public Base setProperty(String name, Base value) throws FHIRException {
1251    if (name.equals("identifier")) {
1252      this.getIdentifier().add(castToIdentifier(value));
1253    } else if (name.equals("name")) {
1254      this.getName().add(castToHumanName(value));
1255    } else if (name.equals("telecom")) {
1256      this.getTelecom().add(castToContactPoint(value));
1257    } else if (name.equals("gender")) {
1258      value = new AdministrativeGenderEnumFactory().fromType(castToCode(value));
1259      this.gender = (Enumeration) value; // Enumeration<AdministrativeGender>
1260    } else if (name.equals("birthDate")) {
1261      this.birthDate = castToDate(value); // DateType
1262    } else if (name.equals("address")) {
1263      this.getAddress().add(castToAddress(value));
1264    } else if (name.equals("photo")) {
1265      this.photo = castToAttachment(value); // Attachment
1266    } else if (name.equals("managingOrganization")) {
1267      this.managingOrganization = castToReference(value); // Reference
1268    } else if (name.equals("active")) {
1269      this.active = castToBoolean(value); // BooleanType
1270    } else if (name.equals("link")) {
1271      this.getLink().add((PersonLinkComponent) value);
1272    } else
1273      return super.setProperty(name, value);
1274    return value;
1275  }
1276
1277  @Override
1278  public void removeChild(String name, Base value) throws FHIRException {
1279    if (name.equals("identifier")) {
1280      this.getIdentifier().remove(castToIdentifier(value));
1281    } else if (name.equals("name")) {
1282      this.getName().remove(castToHumanName(value));
1283    } else if (name.equals("telecom")) {
1284      this.getTelecom().remove(castToContactPoint(value));
1285    } else if (name.equals("gender")) {
1286      this.gender = null;
1287    } else if (name.equals("birthDate")) {
1288      this.birthDate = null;
1289    } else if (name.equals("address")) {
1290      this.getAddress().remove(castToAddress(value));
1291    } else if (name.equals("photo")) {
1292      this.photo = null;
1293    } else if (name.equals("managingOrganization")) {
1294      this.managingOrganization = null;
1295    } else if (name.equals("active")) {
1296      this.active = null;
1297    } else if (name.equals("link")) {
1298      this.getLink().remove((PersonLinkComponent) value);
1299    } else
1300      super.removeChild(name, value);
1301    
1302  }
1303
1304  @Override
1305  public Base makeProperty(int hash, String name) throws FHIRException {
1306    switch (hash) {
1307    case -1618432855:
1308      return addIdentifier();
1309    case 3373707:
1310      return addName();
1311    case -1429363305:
1312      return addTelecom();
1313    case -1249512767:
1314      return getGenderElement();
1315    case -1210031859:
1316      return getBirthDateElement();
1317    case -1147692044:
1318      return addAddress();
1319    case 106642994:
1320      return getPhoto();
1321    case -2058947787:
1322      return getManagingOrganization();
1323    case -1422950650:
1324      return getActiveElement();
1325    case 3321850:
1326      return addLink();
1327    default:
1328      return super.makeProperty(hash, name);
1329    }
1330
1331  }
1332
1333  @Override
1334  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1335    switch (hash) {
1336    case -1618432855:
1337      /* identifier */ return new String[] { "Identifier" };
1338    case 3373707:
1339      /* name */ return new String[] { "HumanName" };
1340    case -1429363305:
1341      /* telecom */ return new String[] { "ContactPoint" };
1342    case -1249512767:
1343      /* gender */ return new String[] { "code" };
1344    case -1210031859:
1345      /* birthDate */ return new String[] { "date" };
1346    case -1147692044:
1347      /* address */ return new String[] { "Address" };
1348    case 106642994:
1349      /* photo */ return new String[] { "Attachment" };
1350    case -2058947787:
1351      /* managingOrganization */ return new String[] { "Reference" };
1352    case -1422950650:
1353      /* active */ return new String[] { "boolean" };
1354    case 3321850:
1355      /* link */ return new String[] {};
1356    default:
1357      return super.getTypesForProperty(hash, name);
1358    }
1359
1360  }
1361
1362  @Override
1363  public Base addChild(String name) throws FHIRException {
1364    if (name.equals("identifier")) {
1365      return addIdentifier();
1366    } else if (name.equals("name")) {
1367      return addName();
1368    } else if (name.equals("telecom")) {
1369      return addTelecom();
1370    } else if (name.equals("gender")) {
1371      throw new FHIRException("Cannot call addChild on a singleton property Person.gender");
1372    } else if (name.equals("birthDate")) {
1373      throw new FHIRException("Cannot call addChild on a singleton property Person.birthDate");
1374    } else if (name.equals("address")) {
1375      return addAddress();
1376    } else if (name.equals("photo")) {
1377      this.photo = new Attachment();
1378      return this.photo;
1379    } else if (name.equals("managingOrganization")) {
1380      this.managingOrganization = new Reference();
1381      return this.managingOrganization;
1382    } else if (name.equals("active")) {
1383      throw new FHIRException("Cannot call addChild on a singleton property Person.active");
1384    } else if (name.equals("link")) {
1385      return addLink();
1386    } else
1387      return super.addChild(name);
1388  }
1389
1390  public String fhirType() {
1391    return "Person";
1392
1393  }
1394
1395  public Person copy() {
1396    Person dst = new Person();
1397    copyValues(dst);
1398    return dst;
1399  }
1400
1401  public void copyValues(Person dst) {
1402    super.copyValues(dst);
1403    if (identifier != null) {
1404      dst.identifier = new ArrayList<Identifier>();
1405      for (Identifier i : identifier)
1406        dst.identifier.add(i.copy());
1407    }
1408    ;
1409    if (name != null) {
1410      dst.name = new ArrayList<HumanName>();
1411      for (HumanName i : name)
1412        dst.name.add(i.copy());
1413    }
1414    ;
1415    if (telecom != null) {
1416      dst.telecom = new ArrayList<ContactPoint>();
1417      for (ContactPoint i : telecom)
1418        dst.telecom.add(i.copy());
1419    }
1420    ;
1421    dst.gender = gender == null ? null : gender.copy();
1422    dst.birthDate = birthDate == null ? null : birthDate.copy();
1423    if (address != null) {
1424      dst.address = new ArrayList<Address>();
1425      for (Address i : address)
1426        dst.address.add(i.copy());
1427    }
1428    ;
1429    dst.photo = photo == null ? null : photo.copy();
1430    dst.managingOrganization = managingOrganization == null ? null : managingOrganization.copy();
1431    dst.active = active == null ? null : active.copy();
1432    if (link != null) {
1433      dst.link = new ArrayList<PersonLinkComponent>();
1434      for (PersonLinkComponent i : link)
1435        dst.link.add(i.copy());
1436    }
1437    ;
1438  }
1439
1440  protected Person typedCopy() {
1441    return copy();
1442  }
1443
1444  @Override
1445  public boolean equalsDeep(Base other_) {
1446    if (!super.equalsDeep(other_))
1447      return false;
1448    if (!(other_ instanceof Person))
1449      return false;
1450    Person o = (Person) other_;
1451    return compareDeep(identifier, o.identifier, true) && compareDeep(name, o.name, true)
1452        && compareDeep(telecom, o.telecom, true) && compareDeep(gender, o.gender, true)
1453        && compareDeep(birthDate, o.birthDate, true) && compareDeep(address, o.address, true)
1454        && compareDeep(photo, o.photo, true) && compareDeep(managingOrganization, o.managingOrganization, true)
1455        && compareDeep(active, o.active, true) && compareDeep(link, o.link, true);
1456  }
1457
1458  @Override
1459  public boolean equalsShallow(Base other_) {
1460    if (!super.equalsShallow(other_))
1461      return false;
1462    if (!(other_ instanceof Person))
1463      return false;
1464    Person o = (Person) other_;
1465    return compareValues(gender, o.gender, true) && compareValues(birthDate, o.birthDate, true)
1466        && compareValues(active, o.active, true);
1467  }
1468
1469  public boolean isEmpty() {
1470    return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, name, telecom, gender, birthDate,
1471        address, photo, managingOrganization, active, link);
1472  }
1473
1474  @Override
1475  public ResourceType getResourceType() {
1476    return ResourceType.Person;
1477  }
1478
1479  /**
1480   * Search parameter: <b>identifier</b>
1481   * <p>
1482   * Description: <b>A person Identifier</b><br>
1483   * Type: <b>token</b><br>
1484   * Path: <b>Person.identifier</b><br>
1485   * </p>
1486   */
1487  @SearchParamDefinition(name = "identifier", path = "Person.identifier", description = "A person Identifier", type = "token")
1488  public static final String SP_IDENTIFIER = "identifier";
1489  /**
1490   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1491   * <p>
1492   * Description: <b>A person Identifier</b><br>
1493   * Type: <b>token</b><br>
1494   * Path: <b>Person.identifier</b><br>
1495   * </p>
1496   */
1497  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1498      SP_IDENTIFIER);
1499
1500  /**
1501   * Search parameter: <b>address</b>
1502   * <p>
1503   * Description: <b>A server defined search that may match any of the string
1504   * fields in the Address, including line, city, district, state, country,
1505   * postalCode, and/or text</b><br>
1506   * Type: <b>string</b><br>
1507   * Path: <b>Person.address</b><br>
1508   * </p>
1509   */
1510  @SearchParamDefinition(name = "address", path = "Person.address", description = "A server defined search that may match any of the string fields in the Address, including line, city, district, state, country, postalCode, and/or text", type = "string")
1511  public static final String SP_ADDRESS = "address";
1512  /**
1513   * <b>Fluent Client</b> search parameter constant for <b>address</b>
1514   * <p>
1515   * Description: <b>A server defined search that may match any of the string
1516   * fields in the Address, including line, city, district, state, country,
1517   * postalCode, and/or text</b><br>
1518   * Type: <b>string</b><br>
1519   * Path: <b>Person.address</b><br>
1520   * </p>
1521   */
1522  public static final ca.uhn.fhir.rest.gclient.StringClientParam ADDRESS = new ca.uhn.fhir.rest.gclient.StringClientParam(
1523      SP_ADDRESS);
1524
1525  /**
1526   * Search parameter: <b>birthdate</b>
1527   * <p>
1528   * Description: <b>The person's date of birth</b><br>
1529   * Type: <b>date</b><br>
1530   * Path: <b>Person.birthDate</b><br>
1531   * </p>
1532   */
1533  @SearchParamDefinition(name = "birthdate", path = "Person.birthDate", description = "The person's date of birth", type = "date")
1534  public static final String SP_BIRTHDATE = "birthdate";
1535  /**
1536   * <b>Fluent Client</b> search parameter constant for <b>birthdate</b>
1537   * <p>
1538   * Description: <b>The person's date of birth</b><br>
1539   * Type: <b>date</b><br>
1540   * Path: <b>Person.birthDate</b><br>
1541   * </p>
1542   */
1543  public static final ca.uhn.fhir.rest.gclient.DateClientParam BIRTHDATE = new ca.uhn.fhir.rest.gclient.DateClientParam(
1544      SP_BIRTHDATE);
1545
1546  /**
1547   * Search parameter: <b>address-state</b>
1548   * <p>
1549   * Description: <b>A state specified in an address</b><br>
1550   * Type: <b>string</b><br>
1551   * Path: <b>Person.address.state</b><br>
1552   * </p>
1553   */
1554  @SearchParamDefinition(name = "address-state", path = "Person.address.state", description = "A state specified in an address", type = "string")
1555  public static final String SP_ADDRESS_STATE = "address-state";
1556  /**
1557   * <b>Fluent Client</b> search parameter constant for <b>address-state</b>
1558   * <p>
1559   * Description: <b>A state specified in an address</b><br>
1560   * Type: <b>string</b><br>
1561   * Path: <b>Person.address.state</b><br>
1562   * </p>
1563   */
1564  public static final ca.uhn.fhir.rest.gclient.StringClientParam ADDRESS_STATE = new ca.uhn.fhir.rest.gclient.StringClientParam(
1565      SP_ADDRESS_STATE);
1566
1567  /**
1568   * Search parameter: <b>gender</b>
1569   * <p>
1570   * Description: <b>The gender of the person</b><br>
1571   * Type: <b>token</b><br>
1572   * Path: <b>Person.gender</b><br>
1573   * </p>
1574   */
1575  @SearchParamDefinition(name = "gender", path = "Person.gender", description = "The gender of the person", type = "token")
1576  public static final String SP_GENDER = "gender";
1577  /**
1578   * <b>Fluent Client</b> search parameter constant for <b>gender</b>
1579   * <p>
1580   * Description: <b>The gender of the person</b><br>
1581   * Type: <b>token</b><br>
1582   * Path: <b>Person.gender</b><br>
1583   * </p>
1584   */
1585  public static final ca.uhn.fhir.rest.gclient.TokenClientParam GENDER = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1586      SP_GENDER);
1587
1588  /**
1589   * Search parameter: <b>practitioner</b>
1590   * <p>
1591   * Description: <b>The Person links to this Practitioner</b><br>
1592   * Type: <b>reference</b><br>
1593   * Path: <b>Person.link.target</b><br>
1594   * </p>
1595   */
1596  @SearchParamDefinition(name = "practitioner", path = "Person.link.target.where(resolve() is Practitioner)", description = "The Person links to this Practitioner", type = "reference", providesMembershipIn = {
1597      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Practitioner") }, target = { Practitioner.class })
1598  public static final String SP_PRACTITIONER = "practitioner";
1599  /**
1600   * <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
1601   * <p>
1602   * Description: <b>The Person links to this Practitioner</b><br>
1603   * Type: <b>reference</b><br>
1604   * Path: <b>Person.link.target</b><br>
1605   * </p>
1606   */
1607  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
1608      SP_PRACTITIONER);
1609
1610  /**
1611   * Constant for fluent queries to be used to add include statements. Specifies
1612   * the path value of "<b>Person:practitioner</b>".
1613   */
1614  public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include(
1615      "Person:practitioner").toLocked();
1616
1617  /**
1618   * Search parameter: <b>link</b>
1619   * <p>
1620   * Description: <b>Any link has this Patient, Person, RelatedPerson or
1621   * Practitioner reference</b><br>
1622   * Type: <b>reference</b><br>
1623   * Path: <b>Person.link.target</b><br>
1624   * </p>
1625   */
1626  @SearchParamDefinition(name = "link", path = "Person.link.target", description = "Any link has this Patient, Person, RelatedPerson or Practitioner reference", type = "reference", providesMembershipIn = {
1627      @ca.uhn.fhir.model.api.annotation.Compartment(name = "RelatedPerson") }, target = { Patient.class, Person.class,
1628          Practitioner.class, RelatedPerson.class })
1629  public static final String SP_LINK = "link";
1630  /**
1631   * <b>Fluent Client</b> search parameter constant for <b>link</b>
1632   * <p>
1633   * Description: <b>Any link has this Patient, Person, RelatedPerson or
1634   * Practitioner reference</b><br>
1635   * Type: <b>reference</b><br>
1636   * Path: <b>Person.link.target</b><br>
1637   * </p>
1638   */
1639  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LINK = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
1640      SP_LINK);
1641
1642  /**
1643   * Constant for fluent queries to be used to add include statements. Specifies
1644   * the path value of "<b>Person:link</b>".
1645   */
1646  public static final ca.uhn.fhir.model.api.Include INCLUDE_LINK = new ca.uhn.fhir.model.api.Include("Person:link")
1647      .toLocked();
1648
1649  /**
1650   * Search parameter: <b>relatedperson</b>
1651   * <p>
1652   * Description: <b>The Person links to this RelatedPerson</b><br>
1653   * Type: <b>reference</b><br>
1654   * Path: <b>Person.link.target</b><br>
1655   * </p>
1656   */
1657  @SearchParamDefinition(name = "relatedperson", path = "Person.link.target.where(resolve() is RelatedPerson)", description = "The Person links to this RelatedPerson", type = "reference", target = {
1658      RelatedPerson.class })
1659  public static final String SP_RELATEDPERSON = "relatedperson";
1660  /**
1661   * <b>Fluent Client</b> search parameter constant for <b>relatedperson</b>
1662   * <p>
1663   * Description: <b>The Person links to this RelatedPerson</b><br>
1664   * Type: <b>reference</b><br>
1665   * Path: <b>Person.link.target</b><br>
1666   * </p>
1667   */
1668  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam RELATEDPERSON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
1669      SP_RELATEDPERSON);
1670
1671  /**
1672   * Constant for fluent queries to be used to add include statements. Specifies
1673   * the path value of "<b>Person:relatedperson</b>".
1674   */
1675  public static final ca.uhn.fhir.model.api.Include INCLUDE_RELATEDPERSON = new ca.uhn.fhir.model.api.Include(
1676      "Person:relatedperson").toLocked();
1677
1678  /**
1679   * Search parameter: <b>address-postalcode</b>
1680   * <p>
1681   * Description: <b>A postal code specified in an address</b><br>
1682   * Type: <b>string</b><br>
1683   * Path: <b>Person.address.postalCode</b><br>
1684   * </p>
1685   */
1686  @SearchParamDefinition(name = "address-postalcode", path = "Person.address.postalCode", description = "A postal code specified in an address", type = "string")
1687  public static final String SP_ADDRESS_POSTALCODE = "address-postalcode";
1688  /**
1689   * <b>Fluent Client</b> search parameter constant for <b>address-postalcode</b>
1690   * <p>
1691   * Description: <b>A postal code specified in an address</b><br>
1692   * Type: <b>string</b><br>
1693   * Path: <b>Person.address.postalCode</b><br>
1694   * </p>
1695   */
1696  public static final ca.uhn.fhir.rest.gclient.StringClientParam ADDRESS_POSTALCODE = new ca.uhn.fhir.rest.gclient.StringClientParam(
1697      SP_ADDRESS_POSTALCODE);
1698
1699  /**
1700   * Search parameter: <b>address-country</b>
1701   * <p>
1702   * Description: <b>A country specified in an address</b><br>
1703   * Type: <b>string</b><br>
1704   * Path: <b>Person.address.country</b><br>
1705   * </p>
1706   */
1707  @SearchParamDefinition(name = "address-country", path = "Person.address.country", description = "A country specified in an address", type = "string")
1708  public static final String SP_ADDRESS_COUNTRY = "address-country";
1709  /**
1710   * <b>Fluent Client</b> search parameter constant for <b>address-country</b>
1711   * <p>
1712   * Description: <b>A country specified in an address</b><br>
1713   * Type: <b>string</b><br>
1714   * Path: <b>Person.address.country</b><br>
1715   * </p>
1716   */
1717  public static final ca.uhn.fhir.rest.gclient.StringClientParam ADDRESS_COUNTRY = new ca.uhn.fhir.rest.gclient.StringClientParam(
1718      SP_ADDRESS_COUNTRY);
1719
1720  /**
1721   * Search parameter: <b>phonetic</b>
1722   * <p>
1723   * Description: <b>A portion of name using some kind of phonetic matching
1724   * algorithm</b><br>
1725   * Type: <b>string</b><br>
1726   * Path: <b>Person.name</b><br>
1727   * </p>
1728   */
1729  @SearchParamDefinition(name = "phonetic", path = "Person.name", description = "A portion of name using some kind of phonetic matching algorithm", type = "string")
1730  public static final String SP_PHONETIC = "phonetic";
1731  /**
1732   * <b>Fluent Client</b> search parameter constant for <b>phonetic</b>
1733   * <p>
1734   * Description: <b>A portion of name using some kind of phonetic matching
1735   * algorithm</b><br>
1736   * Type: <b>string</b><br>
1737   * Path: <b>Person.name</b><br>
1738   * </p>
1739   */
1740  public static final ca.uhn.fhir.rest.gclient.StringClientParam PHONETIC = new ca.uhn.fhir.rest.gclient.StringClientParam(
1741      SP_PHONETIC);
1742
1743  /**
1744   * Search parameter: <b>phone</b>
1745   * <p>
1746   * Description: <b>A value in a phone contact</b><br>
1747   * Type: <b>token</b><br>
1748   * Path: <b>Person.telecom(system=phone)</b><br>
1749   * </p>
1750   */
1751  @SearchParamDefinition(name = "phone", path = "Person.telecom.where(system='phone')", description = "A value in a phone contact", type = "token")
1752  public static final String SP_PHONE = "phone";
1753  /**
1754   * <b>Fluent Client</b> search parameter constant for <b>phone</b>
1755   * <p>
1756   * Description: <b>A value in a phone contact</b><br>
1757   * Type: <b>token</b><br>
1758   * Path: <b>Person.telecom(system=phone)</b><br>
1759   * </p>
1760   */
1761  public static final ca.uhn.fhir.rest.gclient.TokenClientParam PHONE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1762      SP_PHONE);
1763
1764  /**
1765   * Search parameter: <b>patient</b>
1766   * <p>
1767   * Description: <b>The Person links to this Patient</b><br>
1768   * Type: <b>reference</b><br>
1769   * Path: <b>Person.link.target</b><br>
1770   * </p>
1771   */
1772  @SearchParamDefinition(name = "patient", path = "Person.link.target.where(resolve() is Patient)", description = "The Person links to this Patient", type = "reference", providesMembershipIn = {
1773      @ca.uhn.fhir.model.api.annotation.Compartment(name = "Patient") }, target = { Patient.class })
1774  public static final String SP_PATIENT = "patient";
1775  /**
1776   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1777   * <p>
1778   * Description: <b>The Person links to this Patient</b><br>
1779   * Type: <b>reference</b><br>
1780   * Path: <b>Person.link.target</b><br>
1781   * </p>
1782   */
1783  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
1784      SP_PATIENT);
1785
1786  /**
1787   * Constant for fluent queries to be used to add include statements. Specifies
1788   * the path value of "<b>Person:patient</b>".
1789   */
1790  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include(
1791      "Person:patient").toLocked();
1792
1793  /**
1794   * Search parameter: <b>organization</b>
1795   * <p>
1796   * Description: <b>The organization at which this person record is being
1797   * managed</b><br>
1798   * Type: <b>reference</b><br>
1799   * Path: <b>Person.managingOrganization</b><br>
1800   * </p>
1801   */
1802  @SearchParamDefinition(name = "organization", path = "Person.managingOrganization", description = "The organization at which this person record is being managed", type = "reference", target = {
1803      Organization.class })
1804  public static final String SP_ORGANIZATION = "organization";
1805  /**
1806   * <b>Fluent Client</b> search parameter constant for <b>organization</b>
1807   * <p>
1808   * Description: <b>The organization at which this person record is being
1809   * managed</b><br>
1810   * Type: <b>reference</b><br>
1811   * Path: <b>Person.managingOrganization</b><br>
1812   * </p>
1813   */
1814  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ORGANIZATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(
1815      SP_ORGANIZATION);
1816
1817  /**
1818   * Constant for fluent queries to be used to add include statements. Specifies
1819   * the path value of "<b>Person:organization</b>".
1820   */
1821  public static final ca.uhn.fhir.model.api.Include INCLUDE_ORGANIZATION = new ca.uhn.fhir.model.api.Include(
1822      "Person:organization").toLocked();
1823
1824  /**
1825   * Search parameter: <b>name</b>
1826   * <p>
1827   * Description: <b>A server defined search that may match any of the string
1828   * fields in the HumanName, including family, give, prefix, suffix, suffix,
1829   * and/or text</b><br>
1830   * Type: <b>string</b><br>
1831   * Path: <b>Person.name</b><br>
1832   * </p>
1833   */
1834  @SearchParamDefinition(name = "name", path = "Person.name", description = "A server defined search that may match any of the string fields in the HumanName, including family, give, prefix, suffix, suffix, and/or text", type = "string")
1835  public static final String SP_NAME = "name";
1836  /**
1837   * <b>Fluent Client</b> search parameter constant for <b>name</b>
1838   * <p>
1839   * Description: <b>A server defined search that may match any of the string
1840   * fields in the HumanName, including family, give, prefix, suffix, suffix,
1841   * and/or text</b><br>
1842   * Type: <b>string</b><br>
1843   * Path: <b>Person.name</b><br>
1844   * </p>
1845   */
1846  public static final ca.uhn.fhir.rest.gclient.StringClientParam NAME = new ca.uhn.fhir.rest.gclient.StringClientParam(
1847      SP_NAME);
1848
1849  /**
1850   * Search parameter: <b>address-use</b>
1851   * <p>
1852   * Description: <b>A use code specified in an address</b><br>
1853   * Type: <b>token</b><br>
1854   * Path: <b>Person.address.use</b><br>
1855   * </p>
1856   */
1857  @SearchParamDefinition(name = "address-use", path = "Person.address.use", description = "A use code specified in an address", type = "token")
1858  public static final String SP_ADDRESS_USE = "address-use";
1859  /**
1860   * <b>Fluent Client</b> search parameter constant for <b>address-use</b>
1861   * <p>
1862   * Description: <b>A use code specified in an address</b><br>
1863   * Type: <b>token</b><br>
1864   * Path: <b>Person.address.use</b><br>
1865   * </p>
1866   */
1867  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ADDRESS_USE = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1868      SP_ADDRESS_USE);
1869
1870  /**
1871   * Search parameter: <b>telecom</b>
1872   * <p>
1873   * Description: <b>The value in any kind of contact</b><br>
1874   * Type: <b>token</b><br>
1875   * Path: <b>Person.telecom</b><br>
1876   * </p>
1877   */
1878  @SearchParamDefinition(name = "telecom", path = "Person.telecom", description = "The value in any kind of contact", type = "token")
1879  public static final String SP_TELECOM = "telecom";
1880  /**
1881   * <b>Fluent Client</b> search parameter constant for <b>telecom</b>
1882   * <p>
1883   * Description: <b>The value in any kind of contact</b><br>
1884   * Type: <b>token</b><br>
1885   * Path: <b>Person.telecom</b><br>
1886   * </p>
1887   */
1888  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TELECOM = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1889      SP_TELECOM);
1890
1891  /**
1892   * Search parameter: <b>address-city</b>
1893   * <p>
1894   * Description: <b>A city specified in an address</b><br>
1895   * Type: <b>string</b><br>
1896   * Path: <b>Person.address.city</b><br>
1897   * </p>
1898   */
1899  @SearchParamDefinition(name = "address-city", path = "Person.address.city", description = "A city specified in an address", type = "string")
1900  public static final String SP_ADDRESS_CITY = "address-city";
1901  /**
1902   * <b>Fluent Client</b> search parameter constant for <b>address-city</b>
1903   * <p>
1904   * Description: <b>A city specified in an address</b><br>
1905   * Type: <b>string</b><br>
1906   * Path: <b>Person.address.city</b><br>
1907   * </p>
1908   */
1909  public static final ca.uhn.fhir.rest.gclient.StringClientParam ADDRESS_CITY = new ca.uhn.fhir.rest.gclient.StringClientParam(
1910      SP_ADDRESS_CITY);
1911
1912  /**
1913   * Search parameter: <b>email</b>
1914   * <p>
1915   * Description: <b>A value in an email contact</b><br>
1916   * Type: <b>token</b><br>
1917   * Path: <b>Person.telecom(system=email)</b><br>
1918   * </p>
1919   */
1920  @SearchParamDefinition(name = "email", path = "Person.telecom.where(system='email')", description = "A value in an email contact", type = "token")
1921  public static final String SP_EMAIL = "email";
1922  /**
1923   * <b>Fluent Client</b> search parameter constant for <b>email</b>
1924   * <p>
1925   * Description: <b>A value in an email contact</b><br>
1926   * Type: <b>token</b><br>
1927   * Path: <b>Person.telecom(system=email)</b><br>
1928   * </p>
1929   */
1930  public static final ca.uhn.fhir.rest.gclient.TokenClientParam EMAIL = new ca.uhn.fhir.rest.gclient.TokenClientParam(
1931      SP_EMAIL);
1932
1933}