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