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