001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.Enumerations.AdministrativeGender;
037import org.hl7.fhir.instance.model.Enumerations.AdministrativeGenderEnumFactory;
038import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
039
040import ca.uhn.fhir.model.api.annotation.*;
041/**
042 * Demographics and other administrative information about an individual or animal receiving care or other health-related services.
043 */
044@ResourceDef(name="Patient", profile="http://hl7.org/fhir/Profile/Patient")
045public class Patient extends DomainResource {
046
047    public enum LinkType {
048        /**
049         * The patient resource containing this link must no longer be used. The link points forward to another patient resource that must be used in lieu of the patient resource that contains this link.
050         */
051        REPLACE, 
052        /**
053         * The patient resource containing this link is in use and valid but not considered the main source of information about a patient. The link points forward to another patient resource that should be consulted to retrieve additional patient information.
054         */
055        REFER, 
056        /**
057         * The patient resource containing this link is in use and valid, but points to another patient resource that is known to contain data about the same person. Data in this resource might overlap or contradict information found in the other patient resource. This link does not indicate any relative importance of the resources concerned, and both should be regarded as equally valid.
058         */
059        SEEALSO, 
060        /**
061         * added to help the parsers
062         */
063        NULL;
064        public static LinkType fromCode(String codeString) throws FHIRException {
065            if (codeString == null || "".equals(codeString))
066                return null;
067        if ("replace".equals(codeString))
068          return REPLACE;
069        if ("refer".equals(codeString))
070          return REFER;
071        if ("seealso".equals(codeString))
072          return SEEALSO;
073        throw new FHIRException("Unknown LinkType code '"+codeString+"'");
074        }
075        public String toCode() {
076          switch (this) {
077            case REPLACE: return "replace";
078            case REFER: return "refer";
079            case SEEALSO: return "seealso";
080            default: return "?";
081          }
082        }
083        public String getSystem() {
084          switch (this) {
085            case REPLACE: return "http://hl7.org/fhir/link-type";
086            case REFER: return "http://hl7.org/fhir/link-type";
087            case SEEALSO: return "http://hl7.org/fhir/link-type";
088            default: return "?";
089          }
090        }
091        public String getDefinition() {
092          switch (this) {
093            case REPLACE: return "The patient resource containing this link must no longer be used. The link points forward to another patient resource that must be used in lieu of the patient resource that contains this link.";
094            case REFER: return "The patient resource containing this link is in use and valid but not considered the main source of information about a patient. The link points forward to another patient resource that should be consulted to retrieve additional patient information.";
095            case SEEALSO: return "The patient resource containing this link is in use and valid, but points to another patient resource that is known to contain data about the same person. Data in this resource might overlap or contradict information found in the other patient resource. This link does not indicate any relative importance of the resources concerned, and both should be regarded as equally valid.";
096            default: return "?";
097          }
098        }
099        public String getDisplay() {
100          switch (this) {
101            case REPLACE: return "Replace";
102            case REFER: return "Refer";
103            case SEEALSO: return "See also";
104            default: return "?";
105          }
106        }
107    }
108
109  public static class LinkTypeEnumFactory implements EnumFactory<LinkType> {
110    public LinkType fromCode(String codeString) throws IllegalArgumentException {
111      if (codeString == null || "".equals(codeString))
112            if (codeString == null || "".equals(codeString))
113                return null;
114        if ("replace".equals(codeString))
115          return LinkType.REPLACE;
116        if ("refer".equals(codeString))
117          return LinkType.REFER;
118        if ("seealso".equals(codeString))
119          return LinkType.SEEALSO;
120        throw new IllegalArgumentException("Unknown LinkType code '"+codeString+"'");
121        }
122        public Enumeration<LinkType> fromType(Base code) throws FHIRException {
123          if (code == null || code.isEmpty())
124            return null;
125          String codeString = ((PrimitiveType) code).asStringValue();
126          if (codeString == null || "".equals(codeString))
127            return null;
128        if ("replace".equals(codeString))
129          return new Enumeration<LinkType>(this, LinkType.REPLACE);
130        if ("refer".equals(codeString))
131          return new Enumeration<LinkType>(this, LinkType.REFER);
132        if ("seealso".equals(codeString))
133          return new Enumeration<LinkType>(this, LinkType.SEEALSO);
134        throw new FHIRException("Unknown LinkType code '"+codeString+"'");
135        }
136    public String toCode(LinkType code) {
137      if (code == LinkType.REPLACE)
138        return "replace";
139      if (code == LinkType.REFER)
140        return "refer";
141      if (code == LinkType.SEEALSO)
142        return "seealso";
143      return "?";
144      }
145    }
146
147    @Block()
148    public static class ContactComponent extends BackboneElement implements IBaseBackboneElement {
149        /**
150         * The nature of the relationship between the patient and the contact person.
151         */
152        @Child(name = "relationship", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
153        @Description(shortDefinition="The kind of relationship", formalDefinition="The nature of the relationship between the patient and the contact person." )
154        protected List<CodeableConcept> relationship;
155
156        /**
157         * A name associated with the contact person.
158         */
159        @Child(name = "name", type = {HumanName.class}, order=2, min=0, max=1, modifier=false, summary=false)
160        @Description(shortDefinition="A name associated with the contact person", formalDefinition="A name associated with the contact person." )
161        protected HumanName name;
162
163        /**
164         * A contact detail for the person, e.g. a telephone number or an email address.
165         */
166        @Child(name = "telecom", type = {ContactPoint.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
167        @Description(shortDefinition="A contact detail for the person", formalDefinition="A contact detail for the person, e.g. a telephone number or an email address." )
168        protected List<ContactPoint> telecom;
169
170        /**
171         * Address for the contact person.
172         */
173        @Child(name = "address", type = {Address.class}, order=4, min=0, max=1, modifier=false, summary=false)
174        @Description(shortDefinition="Address for the contact person", formalDefinition="Address for the contact person." )
175        protected Address address;
176
177        /**
178         * Administrative Gender - the gender that the contact person is considered to have for administration and record keeping purposes.
179         */
180        @Child(name = "gender", type = {CodeType.class}, order=5, min=0, max=1, modifier=false, summary=false)
181        @Description(shortDefinition="male | female | other | unknown", formalDefinition="Administrative Gender - the gender that the contact person is considered to have for administration and record keeping purposes." )
182        protected Enumeration<AdministrativeGender> gender;
183
184        /**
185         * Organization on behalf of which the contact is acting or for which the contact is working.
186         */
187        @Child(name = "organization", type = {Organization.class}, order=6, min=0, max=1, modifier=false, summary=false)
188        @Description(shortDefinition="Organization that is associated with the contact", formalDefinition="Organization on behalf of which the contact is acting or for which the contact is working." )
189        protected Reference organization;
190
191        /**
192         * The actual object that is the target of the reference (Organization on behalf of which the contact is acting or for which the contact is working.)
193         */
194        protected Organization organizationTarget;
195
196        /**
197         * The period during which this contact person or organization is valid to be contacted relating to this patient.
198         */
199        @Child(name = "period", type = {Period.class}, order=7, min=0, max=1, modifier=false, summary=false)
200        @Description(shortDefinition="The period during which this contact person or organization is valid to be contacted relating to this patient", formalDefinition="The period during which this contact person or organization is valid to be contacted relating to this patient." )
201        protected Period period;
202
203        private static final long serialVersionUID = 364269017L;
204
205    /*
206     * Constructor
207     */
208      public ContactComponent() {
209        super();
210      }
211
212        /**
213         * @return {@link #relationship} (The nature of the relationship between the patient and the contact person.)
214         */
215        public List<CodeableConcept> getRelationship() { 
216          if (this.relationship == null)
217            this.relationship = new ArrayList<CodeableConcept>();
218          return this.relationship;
219        }
220
221        public boolean hasRelationship() { 
222          if (this.relationship == null)
223            return false;
224          for (CodeableConcept item : this.relationship)
225            if (!item.isEmpty())
226              return true;
227          return false;
228        }
229
230        /**
231         * @return {@link #relationship} (The nature of the relationship between the patient and the contact person.)
232         */
233    // syntactic sugar
234        public CodeableConcept addRelationship() { //3
235          CodeableConcept t = new CodeableConcept();
236          if (this.relationship == null)
237            this.relationship = new ArrayList<CodeableConcept>();
238          this.relationship.add(t);
239          return t;
240        }
241
242    // syntactic sugar
243        public ContactComponent addRelationship(CodeableConcept t) { //3
244          if (t == null)
245            return this;
246          if (this.relationship == null)
247            this.relationship = new ArrayList<CodeableConcept>();
248          this.relationship.add(t);
249          return this;
250        }
251
252        /**
253         * @return {@link #name} (A name associated with the contact person.)
254         */
255        public HumanName getName() { 
256          if (this.name == null)
257            if (Configuration.errorOnAutoCreate())
258              throw new Error("Attempt to auto-create ContactComponent.name");
259            else if (Configuration.doAutoCreate())
260              this.name = new HumanName(); // cc
261          return this.name;
262        }
263
264        public boolean hasName() { 
265          return this.name != null && !this.name.isEmpty();
266        }
267
268        /**
269         * @param value {@link #name} (A name associated with the contact person.)
270         */
271        public ContactComponent setName(HumanName value) { 
272          this.name = value;
273          return this;
274        }
275
276        /**
277         * @return {@link #telecom} (A contact detail for the person, e.g. a telephone number or an email address.)
278         */
279        public List<ContactPoint> getTelecom() { 
280          if (this.telecom == null)
281            this.telecom = new ArrayList<ContactPoint>();
282          return this.telecom;
283        }
284
285        public boolean hasTelecom() { 
286          if (this.telecom == null)
287            return false;
288          for (ContactPoint item : this.telecom)
289            if (!item.isEmpty())
290              return true;
291          return false;
292        }
293
294        /**
295         * @return {@link #telecom} (A contact detail for the person, e.g. a telephone number or an email address.)
296         */
297    // syntactic sugar
298        public ContactPoint addTelecom() { //3
299          ContactPoint t = new ContactPoint();
300          if (this.telecom == null)
301            this.telecom = new ArrayList<ContactPoint>();
302          this.telecom.add(t);
303          return t;
304        }
305
306    // syntactic sugar
307        public ContactComponent addTelecom(ContactPoint t) { //3
308          if (t == null)
309            return this;
310          if (this.telecom == null)
311            this.telecom = new ArrayList<ContactPoint>();
312          this.telecom.add(t);
313          return this;
314        }
315
316        /**
317         * @return {@link #address} (Address for the contact person.)
318         */
319        public Address getAddress() { 
320          if (this.address == null)
321            if (Configuration.errorOnAutoCreate())
322              throw new Error("Attempt to auto-create ContactComponent.address");
323            else if (Configuration.doAutoCreate())
324              this.address = new Address(); // cc
325          return this.address;
326        }
327
328        public boolean hasAddress() { 
329          return this.address != null && !this.address.isEmpty();
330        }
331
332        /**
333         * @param value {@link #address} (Address for the contact person.)
334         */
335        public ContactComponent setAddress(Address value) { 
336          this.address = value;
337          return this;
338        }
339
340        /**
341         * @return {@link #gender} (Administrative Gender - the gender that the contact 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
342         */
343        public Enumeration<AdministrativeGender> getGenderElement() { 
344          if (this.gender == null)
345            if (Configuration.errorOnAutoCreate())
346              throw new Error("Attempt to auto-create ContactComponent.gender");
347            else if (Configuration.doAutoCreate())
348              this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory()); // bb
349          return this.gender;
350        }
351
352        public boolean hasGenderElement() { 
353          return this.gender != null && !this.gender.isEmpty();
354        }
355
356        public boolean hasGender() { 
357          return this.gender != null && !this.gender.isEmpty();
358        }
359
360        /**
361         * @param value {@link #gender} (Administrative Gender - the gender that the contact 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
362         */
363        public ContactComponent setGenderElement(Enumeration<AdministrativeGender> value) { 
364          this.gender = value;
365          return this;
366        }
367
368        /**
369         * @return Administrative Gender - the gender that the contact person is considered to have for administration and record keeping purposes.
370         */
371        public AdministrativeGender getGender() { 
372          return this.gender == null ? null : this.gender.getValue();
373        }
374
375        /**
376         * @param value Administrative Gender - the gender that the contact person is considered to have for administration and record keeping purposes.
377         */
378        public ContactComponent setGender(AdministrativeGender value) { 
379          if (value == null)
380            this.gender = null;
381          else {
382            if (this.gender == null)
383              this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory());
384            this.gender.setValue(value);
385          }
386          return this;
387        }
388
389        /**
390         * @return {@link #organization} (Organization on behalf of which the contact is acting or for which the contact is working.)
391         */
392        public Reference getOrganization() { 
393          if (this.organization == null)
394            if (Configuration.errorOnAutoCreate())
395              throw new Error("Attempt to auto-create ContactComponent.organization");
396            else if (Configuration.doAutoCreate())
397              this.organization = new Reference(); // cc
398          return this.organization;
399        }
400
401        public boolean hasOrganization() { 
402          return this.organization != null && !this.organization.isEmpty();
403        }
404
405        /**
406         * @param value {@link #organization} (Organization on behalf of which the contact is acting or for which the contact is working.)
407         */
408        public ContactComponent setOrganization(Reference value) { 
409          this.organization = value;
410          return this;
411        }
412
413        /**
414         * @return {@link #organization} 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. (Organization on behalf of which the contact is acting or for which the contact is working.)
415         */
416        public Organization getOrganizationTarget() { 
417          if (this.organizationTarget == null)
418            if (Configuration.errorOnAutoCreate())
419              throw new Error("Attempt to auto-create ContactComponent.organization");
420            else if (Configuration.doAutoCreate())
421              this.organizationTarget = new Organization(); // aa
422          return this.organizationTarget;
423        }
424
425        /**
426         * @param value {@link #organization} 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. (Organization on behalf of which the contact is acting or for which the contact is working.)
427         */
428        public ContactComponent setOrganizationTarget(Organization value) { 
429          this.organizationTarget = value;
430          return this;
431        }
432
433        /**
434         * @return {@link #period} (The period during which this contact person or organization is valid to be contacted relating to this patient.)
435         */
436        public Period getPeriod() { 
437          if (this.period == null)
438            if (Configuration.errorOnAutoCreate())
439              throw new Error("Attempt to auto-create ContactComponent.period");
440            else if (Configuration.doAutoCreate())
441              this.period = new Period(); // cc
442          return this.period;
443        }
444
445        public boolean hasPeriod() { 
446          return this.period != null && !this.period.isEmpty();
447        }
448
449        /**
450         * @param value {@link #period} (The period during which this contact person or organization is valid to be contacted relating to this patient.)
451         */
452        public ContactComponent setPeriod(Period value) { 
453          this.period = value;
454          return this;
455        }
456
457        protected void listChildren(List<Property> childrenList) {
458          super.listChildren(childrenList);
459          childrenList.add(new Property("relationship", "CodeableConcept", "The nature of the relationship between the patient and the contact person.", 0, java.lang.Integer.MAX_VALUE, relationship));
460          childrenList.add(new Property("name", "HumanName", "A name associated with the contact person.", 0, java.lang.Integer.MAX_VALUE, name));
461          childrenList.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));
462          childrenList.add(new Property("address", "Address", "Address for the contact person.", 0, java.lang.Integer.MAX_VALUE, address));
463          childrenList.add(new Property("gender", "code", "Administrative Gender - the gender that the contact person is considered to have for administration and record keeping purposes.", 0, java.lang.Integer.MAX_VALUE, gender));
464          childrenList.add(new Property("organization", "Reference(Organization)", "Organization on behalf of which the contact is acting or for which the contact is working.", 0, java.lang.Integer.MAX_VALUE, organization));
465          childrenList.add(new Property("period", "Period", "The period during which this contact person or organization is valid to be contacted relating to this patient.", 0, java.lang.Integer.MAX_VALUE, period));
466        }
467
468      @Override
469      public void setProperty(String name, Base value) throws FHIRException {
470        if (name.equals("relationship"))
471          this.getRelationship().add(castToCodeableConcept(value));
472        else if (name.equals("name"))
473          this.name = castToHumanName(value); // HumanName
474        else if (name.equals("telecom"))
475          this.getTelecom().add(castToContactPoint(value));
476        else if (name.equals("address"))
477          this.address = castToAddress(value); // Address
478        else if (name.equals("gender"))
479          this.gender = new AdministrativeGenderEnumFactory().fromType(value); // Enumeration<AdministrativeGender>
480        else if (name.equals("organization"))
481          this.organization = castToReference(value); // Reference
482        else if (name.equals("period"))
483          this.period = castToPeriod(value); // Period
484        else
485          super.setProperty(name, value);
486      }
487
488      @Override
489      public Base addChild(String name) throws FHIRException {
490        if (name.equals("relationship")) {
491          return addRelationship();
492        }
493        else if (name.equals("name")) {
494          this.name = new HumanName();
495          return this.name;
496        }
497        else if (name.equals("telecom")) {
498          return addTelecom();
499        }
500        else if (name.equals("address")) {
501          this.address = new Address();
502          return this.address;
503        }
504        else if (name.equals("gender")) {
505          throw new FHIRException("Cannot call addChild on a primitive type Patient.gender");
506        }
507        else if (name.equals("organization")) {
508          this.organization = new Reference();
509          return this.organization;
510        }
511        else if (name.equals("period")) {
512          this.period = new Period();
513          return this.period;
514        }
515        else
516          return super.addChild(name);
517      }
518
519      public ContactComponent copy() {
520        ContactComponent dst = new ContactComponent();
521        copyValues(dst);
522        if (relationship != null) {
523          dst.relationship = new ArrayList<CodeableConcept>();
524          for (CodeableConcept i : relationship)
525            dst.relationship.add(i.copy());
526        };
527        dst.name = name == null ? null : name.copy();
528        if (telecom != null) {
529          dst.telecom = new ArrayList<ContactPoint>();
530          for (ContactPoint i : telecom)
531            dst.telecom.add(i.copy());
532        };
533        dst.address = address == null ? null : address.copy();
534        dst.gender = gender == null ? null : gender.copy();
535        dst.organization = organization == null ? null : organization.copy();
536        dst.period = period == null ? null : period.copy();
537        return dst;
538      }
539
540      @Override
541      public boolean equalsDeep(Base other) {
542        if (!super.equalsDeep(other))
543          return false;
544        if (!(other instanceof ContactComponent))
545          return false;
546        ContactComponent o = (ContactComponent) other;
547        return compareDeep(relationship, o.relationship, true) && compareDeep(name, o.name, true) && compareDeep(telecom, o.telecom, true)
548           && compareDeep(address, o.address, true) && compareDeep(gender, o.gender, true) && compareDeep(organization, o.organization, true)
549           && compareDeep(period, o.period, true);
550      }
551
552      @Override
553      public boolean equalsShallow(Base other) {
554        if (!super.equalsShallow(other))
555          return false;
556        if (!(other instanceof ContactComponent))
557          return false;
558        ContactComponent o = (ContactComponent) other;
559        return compareValues(gender, o.gender, true);
560      }
561
562      public boolean isEmpty() {
563        return super.isEmpty() && (relationship == null || relationship.isEmpty()) && (name == null || name.isEmpty())
564           && (telecom == null || telecom.isEmpty()) && (address == null || address.isEmpty()) && (gender == null || gender.isEmpty())
565           && (organization == null || organization.isEmpty()) && (period == null || period.isEmpty())
566          ;
567      }
568
569  public String fhirType() {
570    return "Patient.contact";
571
572  }
573
574  }
575
576    @Block()
577    public static class AnimalComponent extends BackboneElement implements IBaseBackboneElement {
578        /**
579         * Identifies the high level taxonomic categorization of the kind of animal.
580         */
581        @Child(name = "species", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
582        @Description(shortDefinition="E.g. Dog, Cow", formalDefinition="Identifies the high level taxonomic categorization of the kind of animal." )
583        protected CodeableConcept species;
584
585        /**
586         * Identifies the detailed categorization of the kind of animal.
587         */
588        @Child(name = "breed", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
589        @Description(shortDefinition="E.g. Poodle, Angus", formalDefinition="Identifies the detailed categorization of the kind of animal." )
590        protected CodeableConcept breed;
591
592        /**
593         * Indicates the current state of the animal's reproductive organs.
594         */
595        @Child(name = "genderStatus", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
596        @Description(shortDefinition="E.g. Neutered, Intact", formalDefinition="Indicates the current state of the animal's reproductive organs." )
597        protected CodeableConcept genderStatus;
598
599        private static final long serialVersionUID = -549738382L;
600
601    /*
602     * Constructor
603     */
604      public AnimalComponent() {
605        super();
606      }
607
608    /*
609     * Constructor
610     */
611      public AnimalComponent(CodeableConcept species) {
612        super();
613        this.species = species;
614      }
615
616        /**
617         * @return {@link #species} (Identifies the high level taxonomic categorization of the kind of animal.)
618         */
619        public CodeableConcept getSpecies() { 
620          if (this.species == null)
621            if (Configuration.errorOnAutoCreate())
622              throw new Error("Attempt to auto-create AnimalComponent.species");
623            else if (Configuration.doAutoCreate())
624              this.species = new CodeableConcept(); // cc
625          return this.species;
626        }
627
628        public boolean hasSpecies() { 
629          return this.species != null && !this.species.isEmpty();
630        }
631
632        /**
633         * @param value {@link #species} (Identifies the high level taxonomic categorization of the kind of animal.)
634         */
635        public AnimalComponent setSpecies(CodeableConcept value) { 
636          this.species = value;
637          return this;
638        }
639
640        /**
641         * @return {@link #breed} (Identifies the detailed categorization of the kind of animal.)
642         */
643        public CodeableConcept getBreed() { 
644          if (this.breed == null)
645            if (Configuration.errorOnAutoCreate())
646              throw new Error("Attempt to auto-create AnimalComponent.breed");
647            else if (Configuration.doAutoCreate())
648              this.breed = new CodeableConcept(); // cc
649          return this.breed;
650        }
651
652        public boolean hasBreed() { 
653          return this.breed != null && !this.breed.isEmpty();
654        }
655
656        /**
657         * @param value {@link #breed} (Identifies the detailed categorization of the kind of animal.)
658         */
659        public AnimalComponent setBreed(CodeableConcept value) { 
660          this.breed = value;
661          return this;
662        }
663
664        /**
665         * @return {@link #genderStatus} (Indicates the current state of the animal's reproductive organs.)
666         */
667        public CodeableConcept getGenderStatus() { 
668          if (this.genderStatus == null)
669            if (Configuration.errorOnAutoCreate())
670              throw new Error("Attempt to auto-create AnimalComponent.genderStatus");
671            else if (Configuration.doAutoCreate())
672              this.genderStatus = new CodeableConcept(); // cc
673          return this.genderStatus;
674        }
675
676        public boolean hasGenderStatus() { 
677          return this.genderStatus != null && !this.genderStatus.isEmpty();
678        }
679
680        /**
681         * @param value {@link #genderStatus} (Indicates the current state of the animal's reproductive organs.)
682         */
683        public AnimalComponent setGenderStatus(CodeableConcept value) { 
684          this.genderStatus = value;
685          return this;
686        }
687
688        protected void listChildren(List<Property> childrenList) {
689          super.listChildren(childrenList);
690          childrenList.add(new Property("species", "CodeableConcept", "Identifies the high level taxonomic categorization of the kind of animal.", 0, java.lang.Integer.MAX_VALUE, species));
691          childrenList.add(new Property("breed", "CodeableConcept", "Identifies the detailed categorization of the kind of animal.", 0, java.lang.Integer.MAX_VALUE, breed));
692          childrenList.add(new Property("genderStatus", "CodeableConcept", "Indicates the current state of the animal's reproductive organs.", 0, java.lang.Integer.MAX_VALUE, genderStatus));
693        }
694
695      @Override
696      public void setProperty(String name, Base value) throws FHIRException {
697        if (name.equals("species"))
698          this.species = castToCodeableConcept(value); // CodeableConcept
699        else if (name.equals("breed"))
700          this.breed = castToCodeableConcept(value); // CodeableConcept
701        else if (name.equals("genderStatus"))
702          this.genderStatus = castToCodeableConcept(value); // CodeableConcept
703        else
704          super.setProperty(name, value);
705      }
706
707      @Override
708      public Base addChild(String name) throws FHIRException {
709        if (name.equals("species")) {
710          this.species = new CodeableConcept();
711          return this.species;
712        }
713        else if (name.equals("breed")) {
714          this.breed = new CodeableConcept();
715          return this.breed;
716        }
717        else if (name.equals("genderStatus")) {
718          this.genderStatus = new CodeableConcept();
719          return this.genderStatus;
720        }
721        else
722          return super.addChild(name);
723      }
724
725      public AnimalComponent copy() {
726        AnimalComponent dst = new AnimalComponent();
727        copyValues(dst);
728        dst.species = species == null ? null : species.copy();
729        dst.breed = breed == null ? null : breed.copy();
730        dst.genderStatus = genderStatus == null ? null : genderStatus.copy();
731        return dst;
732      }
733
734      @Override
735      public boolean equalsDeep(Base other) {
736        if (!super.equalsDeep(other))
737          return false;
738        if (!(other instanceof AnimalComponent))
739          return false;
740        AnimalComponent o = (AnimalComponent) other;
741        return compareDeep(species, o.species, true) && compareDeep(breed, o.breed, true) && compareDeep(genderStatus, o.genderStatus, true)
742          ;
743      }
744
745      @Override
746      public boolean equalsShallow(Base other) {
747        if (!super.equalsShallow(other))
748          return false;
749        if (!(other instanceof AnimalComponent))
750          return false;
751        AnimalComponent o = (AnimalComponent) other;
752        return true;
753      }
754
755      public boolean isEmpty() {
756        return super.isEmpty() && (species == null || species.isEmpty()) && (breed == null || breed.isEmpty())
757           && (genderStatus == null || genderStatus.isEmpty());
758      }
759
760  public String fhirType() {
761    return "Patient.animal";
762
763  }
764
765  }
766
767    @Block()
768    public static class PatientCommunicationComponent extends BackboneElement implements IBaseBackboneElement {
769        /**
770         * 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.
771         */
772        @Child(name = "language", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
773        @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." )
774        protected CodeableConcept language;
775
776        /**
777         * Indicates whether or not the patient prefers this language (over other languages he masters up a certain level).
778         */
779        @Child(name = "preferred", type = {BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=false)
780        @Description(shortDefinition="Language preference indicator", formalDefinition="Indicates whether or not the patient prefers this language (over other languages he masters up a certain level)." )
781        protected BooleanType preferred;
782
783        private static final long serialVersionUID = 633792918L;
784
785    /*
786     * Constructor
787     */
788      public PatientCommunicationComponent() {
789        super();
790      }
791
792    /*
793     * Constructor
794     */
795      public PatientCommunicationComponent(CodeableConcept language) {
796        super();
797        this.language = language;
798      }
799
800        /**
801         * @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.)
802         */
803        public CodeableConcept getLanguage() { 
804          if (this.language == null)
805            if (Configuration.errorOnAutoCreate())
806              throw new Error("Attempt to auto-create PatientCommunicationComponent.language");
807            else if (Configuration.doAutoCreate())
808              this.language = new CodeableConcept(); // cc
809          return this.language;
810        }
811
812        public boolean hasLanguage() { 
813          return this.language != null && !this.language.isEmpty();
814        }
815
816        /**
817         * @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.)
818         */
819        public PatientCommunicationComponent setLanguage(CodeableConcept value) { 
820          this.language = value;
821          return this;
822        }
823
824        /**
825         * @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
826         */
827        public BooleanType getPreferredElement() { 
828          if (this.preferred == null)
829            if (Configuration.errorOnAutoCreate())
830              throw new Error("Attempt to auto-create PatientCommunicationComponent.preferred");
831            else if (Configuration.doAutoCreate())
832              this.preferred = new BooleanType(); // bb
833          return this.preferred;
834        }
835
836        public boolean hasPreferredElement() { 
837          return this.preferred != null && !this.preferred.isEmpty();
838        }
839
840        public boolean hasPreferred() { 
841          return this.preferred != null && !this.preferred.isEmpty();
842        }
843
844        /**
845         * @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
846         */
847        public PatientCommunicationComponent setPreferredElement(BooleanType value) { 
848          this.preferred = value;
849          return this;
850        }
851
852        /**
853         * @return Indicates whether or not the patient prefers this language (over other languages he masters up a certain level).
854         */
855        public boolean getPreferred() { 
856          return this.preferred == null || this.preferred.isEmpty() ? false : this.preferred.getValue();
857        }
858
859        /**
860         * @param value Indicates whether or not the patient prefers this language (over other languages he masters up a certain level).
861         */
862        public PatientCommunicationComponent setPreferred(boolean value) { 
863            if (this.preferred == null)
864              this.preferred = new BooleanType();
865            this.preferred.setValue(value);
866          return this;
867        }
868
869        protected void listChildren(List<Property> childrenList) {
870          super.listChildren(childrenList);
871          childrenList.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, java.lang.Integer.MAX_VALUE, language));
872          childrenList.add(new Property("preferred", "boolean", "Indicates whether or not the patient prefers this language (over other languages he masters up a certain level).", 0, java.lang.Integer.MAX_VALUE, preferred));
873        }
874
875      @Override
876      public void setProperty(String name, Base value) throws FHIRException {
877        if (name.equals("language"))
878          this.language = castToCodeableConcept(value); // CodeableConcept
879        else if (name.equals("preferred"))
880          this.preferred = castToBoolean(value); // BooleanType
881        else
882          super.setProperty(name, value);
883      }
884
885      @Override
886      public Base addChild(String name) throws FHIRException {
887        if (name.equals("language")) {
888          this.language = new CodeableConcept();
889          return this.language;
890        }
891        else if (name.equals("preferred")) {
892          throw new FHIRException("Cannot call addChild on a primitive type Patient.preferred");
893        }
894        else
895          return super.addChild(name);
896      }
897
898      public PatientCommunicationComponent copy() {
899        PatientCommunicationComponent dst = new PatientCommunicationComponent();
900        copyValues(dst);
901        dst.language = language == null ? null : language.copy();
902        dst.preferred = preferred == null ? null : preferred.copy();
903        return dst;
904      }
905
906      @Override
907      public boolean equalsDeep(Base other) {
908        if (!super.equalsDeep(other))
909          return false;
910        if (!(other instanceof PatientCommunicationComponent))
911          return false;
912        PatientCommunicationComponent o = (PatientCommunicationComponent) other;
913        return compareDeep(language, o.language, true) && compareDeep(preferred, o.preferred, true);
914      }
915
916      @Override
917      public boolean equalsShallow(Base other) {
918        if (!super.equalsShallow(other))
919          return false;
920        if (!(other instanceof PatientCommunicationComponent))
921          return false;
922        PatientCommunicationComponent o = (PatientCommunicationComponent) other;
923        return compareValues(preferred, o.preferred, true);
924      }
925
926      public boolean isEmpty() {
927        return super.isEmpty() && (language == null || language.isEmpty()) && (preferred == null || preferred.isEmpty())
928          ;
929      }
930
931  public String fhirType() {
932    return "Patient.communication";
933
934  }
935
936  }
937
938    @Block()
939    public static class PatientLinkComponent extends BackboneElement implements IBaseBackboneElement {
940        /**
941         * The other patient resource that the link refers to.
942         */
943        @Child(name = "other", type = {Patient.class}, order=1, min=1, max=1, modifier=true, summary=false)
944        @Description(shortDefinition="The other patient resource that the link refers to", formalDefinition="The other patient resource that the link refers to." )
945        protected Reference other;
946
947        /**
948         * The actual object that is the target of the reference (The other patient resource that the link refers to.)
949         */
950        protected Patient otherTarget;
951
952        /**
953         * The type of link between this patient resource and another patient resource.
954         */
955        @Child(name = "type", type = {CodeType.class}, order=2, min=1, max=1, modifier=true, summary=false)
956        @Description(shortDefinition="replace | refer | seealso - type of link", formalDefinition="The type of link between this patient resource and another patient resource." )
957        protected Enumeration<LinkType> type;
958
959        private static final long serialVersionUID = -1942104050L;
960
961    /*
962     * Constructor
963     */
964      public PatientLinkComponent() {
965        super();
966      }
967
968    /*
969     * Constructor
970     */
971      public PatientLinkComponent(Reference other, Enumeration<LinkType> type) {
972        super();
973        this.other = other;
974        this.type = type;
975      }
976
977        /**
978         * @return {@link #other} (The other patient resource that the link refers to.)
979         */
980        public Reference getOther() { 
981          if (this.other == null)
982            if (Configuration.errorOnAutoCreate())
983              throw new Error("Attempt to auto-create PatientLinkComponent.other");
984            else if (Configuration.doAutoCreate())
985              this.other = new Reference(); // cc
986          return this.other;
987        }
988
989        public boolean hasOther() { 
990          return this.other != null && !this.other.isEmpty();
991        }
992
993        /**
994         * @param value {@link #other} (The other patient resource that the link refers to.)
995         */
996        public PatientLinkComponent setOther(Reference value) { 
997          this.other = value;
998          return this;
999        }
1000
1001        /**
1002         * @return {@link #other} 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 other patient resource that the link refers to.)
1003         */
1004        public Patient getOtherTarget() { 
1005          if (this.otherTarget == null)
1006            if (Configuration.errorOnAutoCreate())
1007              throw new Error("Attempt to auto-create PatientLinkComponent.other");
1008            else if (Configuration.doAutoCreate())
1009              this.otherTarget = new Patient(); // aa
1010          return this.otherTarget;
1011        }
1012
1013        /**
1014         * @param value {@link #other} 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 other patient resource that the link refers to.)
1015         */
1016        public PatientLinkComponent setOtherTarget(Patient value) { 
1017          this.otherTarget = value;
1018          return this;
1019        }
1020
1021        /**
1022         * @return {@link #type} (The type of link between this patient resource and another patient resource.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
1023         */
1024        public Enumeration<LinkType> getTypeElement() { 
1025          if (this.type == null)
1026            if (Configuration.errorOnAutoCreate())
1027              throw new Error("Attempt to auto-create PatientLinkComponent.type");
1028            else if (Configuration.doAutoCreate())
1029              this.type = new Enumeration<LinkType>(new LinkTypeEnumFactory()); // bb
1030          return this.type;
1031        }
1032
1033        public boolean hasTypeElement() { 
1034          return this.type != null && !this.type.isEmpty();
1035        }
1036
1037        public boolean hasType() { 
1038          return this.type != null && !this.type.isEmpty();
1039        }
1040
1041        /**
1042         * @param value {@link #type} (The type of link between this patient resource and another patient resource.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value
1043         */
1044        public PatientLinkComponent setTypeElement(Enumeration<LinkType> value) { 
1045          this.type = value;
1046          return this;
1047        }
1048
1049        /**
1050         * @return The type of link between this patient resource and another patient resource.
1051         */
1052        public LinkType getType() { 
1053          return this.type == null ? null : this.type.getValue();
1054        }
1055
1056        /**
1057         * @param value The type of link between this patient resource and another patient resource.
1058         */
1059        public PatientLinkComponent setType(LinkType value) { 
1060            if (this.type == null)
1061              this.type = new Enumeration<LinkType>(new LinkTypeEnumFactory());
1062            this.type.setValue(value);
1063          return this;
1064        }
1065
1066        protected void listChildren(List<Property> childrenList) {
1067          super.listChildren(childrenList);
1068          childrenList.add(new Property("other", "Reference(Patient)", "The other patient resource that the link refers to.", 0, java.lang.Integer.MAX_VALUE, other));
1069          childrenList.add(new Property("type", "code", "The type of link between this patient resource and another patient resource.", 0, java.lang.Integer.MAX_VALUE, type));
1070        }
1071
1072      @Override
1073      public void setProperty(String name, Base value) throws FHIRException {
1074        if (name.equals("other"))
1075          this.other = castToReference(value); // Reference
1076        else if (name.equals("type"))
1077          this.type = new LinkTypeEnumFactory().fromType(value); // Enumeration<LinkType>
1078        else
1079          super.setProperty(name, value);
1080      }
1081
1082      @Override
1083      public Base addChild(String name) throws FHIRException {
1084        if (name.equals("other")) {
1085          this.other = new Reference();
1086          return this.other;
1087        }
1088        else if (name.equals("type")) {
1089          throw new FHIRException("Cannot call addChild on a primitive type Patient.type");
1090        }
1091        else
1092          return super.addChild(name);
1093      }
1094
1095      public PatientLinkComponent copy() {
1096        PatientLinkComponent dst = new PatientLinkComponent();
1097        copyValues(dst);
1098        dst.other = other == null ? null : other.copy();
1099        dst.type = type == null ? null : type.copy();
1100        return dst;
1101      }
1102
1103      @Override
1104      public boolean equalsDeep(Base other) {
1105        if (!super.equalsDeep(other))
1106          return false;
1107        if (!(other instanceof PatientLinkComponent))
1108          return false;
1109        PatientLinkComponent o = (PatientLinkComponent) other;
1110        return compareDeep(other, o.other, true) && compareDeep(type, o.type, true);
1111      }
1112
1113      @Override
1114      public boolean equalsShallow(Base other) {
1115        if (!super.equalsShallow(other))
1116          return false;
1117        if (!(other instanceof PatientLinkComponent))
1118          return false;
1119        PatientLinkComponent o = (PatientLinkComponent) other;
1120        return compareValues(type, o.type, true);
1121      }
1122
1123      public boolean isEmpty() {
1124        return super.isEmpty() && (other == null || other.isEmpty()) && (type == null || type.isEmpty())
1125          ;
1126      }
1127
1128  public String fhirType() {
1129    return "Patient.link";
1130
1131  }
1132
1133  }
1134
1135    /**
1136     * An identifier for this patient.
1137     */
1138    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1139    @Description(shortDefinition="An identifier for this patient", formalDefinition="An identifier for this patient." )
1140    protected List<Identifier> identifier;
1141
1142    /**
1143     * Whether this patient record is in active use.
1144     */
1145    @Child(name = "active", type = {BooleanType.class}, order=1, min=0, max=1, modifier=true, summary=true)
1146    @Description(shortDefinition="Whether this patient's record is in active use", formalDefinition="Whether this patient record is in active use." )
1147    protected BooleanType active;
1148
1149    /**
1150     * A name associated with the individual.
1151     */
1152    @Child(name = "name", type = {HumanName.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1153    @Description(shortDefinition="A name associated with the patient", formalDefinition="A name associated with the individual." )
1154    protected List<HumanName> name;
1155
1156    /**
1157     * A contact detail (e.g. a telephone number or an email address) by which the individual may be contacted.
1158     */
1159    @Child(name = "telecom", type = {ContactPoint.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1160    @Description(shortDefinition="A contact detail for the individual", formalDefinition="A contact detail (e.g. a telephone number or an email address) by which the individual may be contacted." )
1161    protected List<ContactPoint> telecom;
1162
1163    /**
1164     * Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes.
1165     */
1166    @Child(name = "gender", type = {CodeType.class}, order=4, min=0, max=1, modifier=false, summary=true)
1167    @Description(shortDefinition="male | female | other | unknown", formalDefinition="Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes." )
1168    protected Enumeration<AdministrativeGender> gender;
1169
1170    /**
1171     * The date of birth for the individual.
1172     */
1173    @Child(name = "birthDate", type = {DateType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1174    @Description(shortDefinition="The date of birth for the individual", formalDefinition="The date of birth for the individual." )
1175    protected DateType birthDate;
1176
1177    /**
1178     * Indicates if the individual is deceased or not.
1179     */
1180    @Child(name = "deceased", type = {BooleanType.class, DateTimeType.class}, order=6, min=0, max=1, modifier=true, summary=true)
1181    @Description(shortDefinition="Indicates if the individual is deceased or not", formalDefinition="Indicates if the individual is deceased or not." )
1182    protected Type deceased;
1183
1184    /**
1185     * Addresses for the individual.
1186     */
1187    @Child(name = "address", type = {Address.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1188    @Description(shortDefinition="Addresses for the individual", formalDefinition="Addresses for the individual." )
1189    protected List<Address> address;
1190
1191    /**
1192     * This field contains a patient's most recent marital (civil) status.
1193     */
1194    @Child(name = "maritalStatus", type = {CodeableConcept.class}, order=8, min=0, max=1, modifier=false, summary=false)
1195    @Description(shortDefinition="Marital (civil) status of a patient", formalDefinition="This field contains a patient's most recent marital (civil) status." )
1196    protected CodeableConcept maritalStatus;
1197
1198    /**
1199     * Indicates whether the patient is part of a multiple or indicates the actual birth order.
1200     */
1201    @Child(name = "multipleBirth", type = {BooleanType.class, IntegerType.class}, order=9, min=0, max=1, modifier=false, summary=false)
1202    @Description(shortDefinition="Whether patient is part of a multiple birth", formalDefinition="Indicates whether the patient is part of a multiple or indicates the actual birth order." )
1203    protected Type multipleBirth;
1204
1205    /**
1206     * Image of the patient.
1207     */
1208    @Child(name = "photo", type = {Attachment.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1209    @Description(shortDefinition="Image of the patient", formalDefinition="Image of the patient." )
1210    protected List<Attachment> photo;
1211
1212    /**
1213     * A contact party (e.g. guardian, partner, friend) for the patient.
1214     */
1215    @Child(name = "contact", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1216    @Description(shortDefinition="A contact party (e.g. guardian, partner, friend) for the patient", formalDefinition="A contact party (e.g. guardian, partner, friend) for the patient." )
1217    protected List<ContactComponent> contact;
1218
1219    /**
1220     * This patient is known to be an animal.
1221     */
1222    @Child(name = "animal", type = {}, order=12, min=0, max=1, modifier=true, summary=true)
1223    @Description(shortDefinition="This patient is known to be an animal (non-human)", formalDefinition="This patient is known to be an animal." )
1224    protected AnimalComponent animal;
1225
1226    /**
1227     * Languages which may be used to communicate with the patient about his or her health.
1228     */
1229    @Child(name = "communication", type = {}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1230    @Description(shortDefinition="A list of Languages which may be used to communicate with the patient about his or her health", formalDefinition="Languages which may be used to communicate with the patient about his or her health." )
1231    protected List<PatientCommunicationComponent> communication;
1232
1233    /**
1234     * Patient's nominated care provider.
1235     */
1236    @Child(name = "careProvider", type = {Organization.class, Practitioner.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1237    @Description(shortDefinition="Patient's nominated primary care provider", formalDefinition="Patient's nominated care provider." )
1238    protected List<Reference> careProvider;
1239    /**
1240     * The actual objects that are the target of the reference (Patient's nominated care provider.)
1241     */
1242    protected List<Resource> careProviderTarget;
1243
1244
1245    /**
1246     * Organization that is the custodian of the patient record.
1247     */
1248    @Child(name = "managingOrganization", type = {Organization.class}, order=15, min=0, max=1, modifier=false, summary=true)
1249    @Description(shortDefinition="Organization that is the custodian of the patient record", formalDefinition="Organization that is the custodian of the patient record." )
1250    protected Reference managingOrganization;
1251
1252    /**
1253     * The actual object that is the target of the reference (Organization that is the custodian of the patient record.)
1254     */
1255    protected Organization managingOrganizationTarget;
1256
1257    /**
1258     * Link to another patient resource that concerns the same actual patient.
1259     */
1260    @Child(name = "link", type = {}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=false)
1261    @Description(shortDefinition="Link to another patient resource that concerns the same actual person", formalDefinition="Link to another patient resource that concerns the same actual patient." )
1262    protected List<PatientLinkComponent> link;
1263
1264    private static final long serialVersionUID = 2019992554L;
1265
1266  /*
1267   * Constructor
1268   */
1269    public Patient() {
1270      super();
1271    }
1272
1273    /**
1274     * @return {@link #identifier} (An identifier for this patient.)
1275     */
1276    public List<Identifier> getIdentifier() { 
1277      if (this.identifier == null)
1278        this.identifier = new ArrayList<Identifier>();
1279      return this.identifier;
1280    }
1281
1282    public boolean hasIdentifier() { 
1283      if (this.identifier == null)
1284        return false;
1285      for (Identifier item : this.identifier)
1286        if (!item.isEmpty())
1287          return true;
1288      return false;
1289    }
1290
1291    /**
1292     * @return {@link #identifier} (An identifier for this patient.)
1293     */
1294    // syntactic sugar
1295    public Identifier addIdentifier() { //3
1296      Identifier t = new Identifier();
1297      if (this.identifier == null)
1298        this.identifier = new ArrayList<Identifier>();
1299      this.identifier.add(t);
1300      return t;
1301    }
1302
1303    // syntactic sugar
1304    public Patient addIdentifier(Identifier t) { //3
1305      if (t == null)
1306        return this;
1307      if (this.identifier == null)
1308        this.identifier = new ArrayList<Identifier>();
1309      this.identifier.add(t);
1310      return this;
1311    }
1312
1313    /**
1314     * @return {@link #active} (Whether this patient record is in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
1315     */
1316    public BooleanType getActiveElement() { 
1317      if (this.active == null)
1318        if (Configuration.errorOnAutoCreate())
1319          throw new Error("Attempt to auto-create Patient.active");
1320        else if (Configuration.doAutoCreate())
1321          this.active = new BooleanType(); // bb
1322      return this.active;
1323    }
1324
1325    public boolean hasActiveElement() { 
1326      return this.active != null && !this.active.isEmpty();
1327    }
1328
1329    public boolean hasActive() { 
1330      return this.active != null && !this.active.isEmpty();
1331    }
1332
1333    /**
1334     * @param value {@link #active} (Whether this patient record is in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value
1335     */
1336    public Patient setActiveElement(BooleanType value) { 
1337      this.active = value;
1338      return this;
1339    }
1340
1341    /**
1342     * @return Whether this patient record is in active use.
1343     */
1344    public boolean getActive() { 
1345      return this.active == null || this.active.isEmpty() ? false : this.active.getValue();
1346    }
1347
1348    /**
1349     * @param value Whether this patient record is in active use.
1350     */
1351    public Patient setActive(boolean value) { 
1352        if (this.active == null)
1353          this.active = new BooleanType();
1354        this.active.setValue(value);
1355      return this;
1356    }
1357
1358    /**
1359     * @return {@link #name} (A name associated with the individual.)
1360     */
1361    public List<HumanName> getName() { 
1362      if (this.name == null)
1363        this.name = new ArrayList<HumanName>();
1364      return this.name;
1365    }
1366
1367    public boolean hasName() { 
1368      if (this.name == null)
1369        return false;
1370      for (HumanName item : this.name)
1371        if (!item.isEmpty())
1372          return true;
1373      return false;
1374    }
1375
1376    /**
1377     * @return {@link #name} (A name associated with the individual.)
1378     */
1379    // syntactic sugar
1380    public HumanName addName() { //3
1381      HumanName t = new HumanName();
1382      if (this.name == null)
1383        this.name = new ArrayList<HumanName>();
1384      this.name.add(t);
1385      return t;
1386    }
1387
1388    // syntactic sugar
1389    public Patient addName(HumanName t) { //3
1390      if (t == null)
1391        return this;
1392      if (this.name == null)
1393        this.name = new ArrayList<HumanName>();
1394      this.name.add(t);
1395      return this;
1396    }
1397
1398    /**
1399     * @return {@link #telecom} (A contact detail (e.g. a telephone number or an email address) by which the individual may be contacted.)
1400     */
1401    public List<ContactPoint> getTelecom() { 
1402      if (this.telecom == null)
1403        this.telecom = new ArrayList<ContactPoint>();
1404      return this.telecom;
1405    }
1406
1407    public boolean hasTelecom() { 
1408      if (this.telecom == null)
1409        return false;
1410      for (ContactPoint item : this.telecom)
1411        if (!item.isEmpty())
1412          return true;
1413      return false;
1414    }
1415
1416    /**
1417     * @return {@link #telecom} (A contact detail (e.g. a telephone number or an email address) by which the individual may be contacted.)
1418     */
1419    // syntactic sugar
1420    public ContactPoint addTelecom() { //3
1421      ContactPoint t = new ContactPoint();
1422      if (this.telecom == null)
1423        this.telecom = new ArrayList<ContactPoint>();
1424      this.telecom.add(t);
1425      return t;
1426    }
1427
1428    // syntactic sugar
1429    public Patient addTelecom(ContactPoint t) { //3
1430      if (t == null)
1431        return this;
1432      if (this.telecom == null)
1433        this.telecom = new ArrayList<ContactPoint>();
1434      this.telecom.add(t);
1435      return this;
1436    }
1437
1438    /**
1439     * @return {@link #gender} (Administrative Gender - the gender that the patient 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
1440     */
1441    public Enumeration<AdministrativeGender> getGenderElement() { 
1442      if (this.gender == null)
1443        if (Configuration.errorOnAutoCreate())
1444          throw new Error("Attempt to auto-create Patient.gender");
1445        else if (Configuration.doAutoCreate())
1446          this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory()); // bb
1447      return this.gender;
1448    }
1449
1450    public boolean hasGenderElement() { 
1451      return this.gender != null && !this.gender.isEmpty();
1452    }
1453
1454    public boolean hasGender() { 
1455      return this.gender != null && !this.gender.isEmpty();
1456    }
1457
1458    /**
1459     * @param value {@link #gender} (Administrative Gender - the gender that the patient 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
1460     */
1461    public Patient setGenderElement(Enumeration<AdministrativeGender> value) { 
1462      this.gender = value;
1463      return this;
1464    }
1465
1466    /**
1467     * @return Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes.
1468     */
1469    public AdministrativeGender getGender() { 
1470      return this.gender == null ? null : this.gender.getValue();
1471    }
1472
1473    /**
1474     * @param value Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes.
1475     */
1476    public Patient setGender(AdministrativeGender value) { 
1477      if (value == null)
1478        this.gender = null;
1479      else {
1480        if (this.gender == null)
1481          this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory());
1482        this.gender.setValue(value);
1483      }
1484      return this;
1485    }
1486
1487    /**
1488     * @return {@link #birthDate} (The date of birth for the individual.). This is the underlying object with id, value and extensions. The accessor "getBirthDate" gives direct access to the value
1489     */
1490    public DateType getBirthDateElement() { 
1491      if (this.birthDate == null)
1492        if (Configuration.errorOnAutoCreate())
1493          throw new Error("Attempt to auto-create Patient.birthDate");
1494        else if (Configuration.doAutoCreate())
1495          this.birthDate = new DateType(); // bb
1496      return this.birthDate;
1497    }
1498
1499    public boolean hasBirthDateElement() { 
1500      return this.birthDate != null && !this.birthDate.isEmpty();
1501    }
1502
1503    public boolean hasBirthDate() { 
1504      return this.birthDate != null && !this.birthDate.isEmpty();
1505    }
1506
1507    /**
1508     * @param value {@link #birthDate} (The date of birth for the individual.). This is the underlying object with id, value and extensions. The accessor "getBirthDate" gives direct access to the value
1509     */
1510    public Patient setBirthDateElement(DateType value) { 
1511      this.birthDate = value;
1512      return this;
1513    }
1514
1515    /**
1516     * @return The date of birth for the individual.
1517     */
1518    public Date getBirthDate() { 
1519      return this.birthDate == null ? null : this.birthDate.getValue();
1520    }
1521
1522    /**
1523     * @param value The date of birth for the individual.
1524     */
1525    public Patient setBirthDate(Date value) { 
1526      if (value == null)
1527        this.birthDate = null;
1528      else {
1529        if (this.birthDate == null)
1530          this.birthDate = new DateType();
1531        this.birthDate.setValue(value);
1532      }
1533      return this;
1534    }
1535
1536    /**
1537     * @return {@link #deceased} (Indicates if the individual is deceased or not.)
1538     */
1539    public Type getDeceased() { 
1540      return this.deceased;
1541    }
1542
1543    /**
1544     * @return {@link #deceased} (Indicates if the individual is deceased or not.)
1545     */
1546    public BooleanType getDeceasedBooleanType() throws FHIRException { 
1547      if (!(this.deceased instanceof BooleanType))
1548        throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.deceased.getClass().getName()+" was encountered");
1549      return (BooleanType) this.deceased;
1550    }
1551
1552    public boolean hasDeceasedBooleanType() { 
1553      return this.deceased instanceof BooleanType;
1554    }
1555
1556    /**
1557     * @return {@link #deceased} (Indicates if the individual is deceased or not.)
1558     */
1559    public DateTimeType getDeceasedDateTimeType() throws FHIRException { 
1560      if (!(this.deceased instanceof DateTimeType))
1561        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.deceased.getClass().getName()+" was encountered");
1562      return (DateTimeType) this.deceased;
1563    }
1564
1565    public boolean hasDeceasedDateTimeType() { 
1566      return this.deceased instanceof DateTimeType;
1567    }
1568
1569    public boolean hasDeceased() { 
1570      return this.deceased != null && !this.deceased.isEmpty();
1571    }
1572
1573    /**
1574     * @param value {@link #deceased} (Indicates if the individual is deceased or not.)
1575     */
1576    public Patient setDeceased(Type value) { 
1577      this.deceased = value;
1578      return this;
1579    }
1580
1581    /**
1582     * @return {@link #address} (Addresses for the individual.)
1583     */
1584    public List<Address> getAddress() { 
1585      if (this.address == null)
1586        this.address = new ArrayList<Address>();
1587      return this.address;
1588    }
1589
1590    public boolean hasAddress() { 
1591      if (this.address == null)
1592        return false;
1593      for (Address item : this.address)
1594        if (!item.isEmpty())
1595          return true;
1596      return false;
1597    }
1598
1599    /**
1600     * @return {@link #address} (Addresses for the individual.)
1601     */
1602    // syntactic sugar
1603    public Address addAddress() { //3
1604      Address t = new Address();
1605      if (this.address == null)
1606        this.address = new ArrayList<Address>();
1607      this.address.add(t);
1608      return t;
1609    }
1610
1611    // syntactic sugar
1612    public Patient addAddress(Address t) { //3
1613      if (t == null)
1614        return this;
1615      if (this.address == null)
1616        this.address = new ArrayList<Address>();
1617      this.address.add(t);
1618      return this;
1619    }
1620
1621    /**
1622     * @return {@link #maritalStatus} (This field contains a patient's most recent marital (civil) status.)
1623     */
1624    public CodeableConcept getMaritalStatus() { 
1625      if (this.maritalStatus == null)
1626        if (Configuration.errorOnAutoCreate())
1627          throw new Error("Attempt to auto-create Patient.maritalStatus");
1628        else if (Configuration.doAutoCreate())
1629          this.maritalStatus = new CodeableConcept(); // cc
1630      return this.maritalStatus;
1631    }
1632
1633    public boolean hasMaritalStatus() { 
1634      return this.maritalStatus != null && !this.maritalStatus.isEmpty();
1635    }
1636
1637    /**
1638     * @param value {@link #maritalStatus} (This field contains a patient's most recent marital (civil) status.)
1639     */
1640    public Patient setMaritalStatus(CodeableConcept value) { 
1641      this.maritalStatus = value;
1642      return this;
1643    }
1644
1645    /**
1646     * @return {@link #multipleBirth} (Indicates whether the patient is part of a multiple or indicates the actual birth order.)
1647     */
1648    public Type getMultipleBirth() { 
1649      return this.multipleBirth;
1650    }
1651
1652    /**
1653     * @return {@link #multipleBirth} (Indicates whether the patient is part of a multiple or indicates the actual birth order.)
1654     */
1655    public BooleanType getMultipleBirthBooleanType() throws FHIRException { 
1656      if (!(this.multipleBirth instanceof BooleanType))
1657        throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.multipleBirth.getClass().getName()+" was encountered");
1658      return (BooleanType) this.multipleBirth;
1659    }
1660
1661    public boolean hasMultipleBirthBooleanType() { 
1662      return this.multipleBirth instanceof BooleanType;
1663    }
1664
1665    /**
1666     * @return {@link #multipleBirth} (Indicates whether the patient is part of a multiple or indicates the actual birth order.)
1667     */
1668    public IntegerType getMultipleBirthIntegerType() throws FHIRException { 
1669      if (!(this.multipleBirth instanceof IntegerType))
1670        throw new FHIRException("Type mismatch: the type IntegerType was expected, but "+this.multipleBirth.getClass().getName()+" was encountered");
1671      return (IntegerType) this.multipleBirth;
1672    }
1673
1674    public boolean hasMultipleBirthIntegerType() { 
1675      return this.multipleBirth instanceof IntegerType;
1676    }
1677
1678    public boolean hasMultipleBirth() { 
1679      return this.multipleBirth != null && !this.multipleBirth.isEmpty();
1680    }
1681
1682    /**
1683     * @param value {@link #multipleBirth} (Indicates whether the patient is part of a multiple or indicates the actual birth order.)
1684     */
1685    public Patient setMultipleBirth(Type value) { 
1686      this.multipleBirth = value;
1687      return this;
1688    }
1689
1690    /**
1691     * @return {@link #photo} (Image of the patient.)
1692     */
1693    public List<Attachment> getPhoto() { 
1694      if (this.photo == null)
1695        this.photo = new ArrayList<Attachment>();
1696      return this.photo;
1697    }
1698
1699    public boolean hasPhoto() { 
1700      if (this.photo == null)
1701        return false;
1702      for (Attachment item : this.photo)
1703        if (!item.isEmpty())
1704          return true;
1705      return false;
1706    }
1707
1708    /**
1709     * @return {@link #photo} (Image of the patient.)
1710     */
1711    // syntactic sugar
1712    public Attachment addPhoto() { //3
1713      Attachment t = new Attachment();
1714      if (this.photo == null)
1715        this.photo = new ArrayList<Attachment>();
1716      this.photo.add(t);
1717      return t;
1718    }
1719
1720    // syntactic sugar
1721    public Patient addPhoto(Attachment t) { //3
1722      if (t == null)
1723        return this;
1724      if (this.photo == null)
1725        this.photo = new ArrayList<Attachment>();
1726      this.photo.add(t);
1727      return this;
1728    }
1729
1730    /**
1731     * @return {@link #contact} (A contact party (e.g. guardian, partner, friend) for the patient.)
1732     */
1733    public List<ContactComponent> getContact() { 
1734      if (this.contact == null)
1735        this.contact = new ArrayList<ContactComponent>();
1736      return this.contact;
1737    }
1738
1739    public boolean hasContact() { 
1740      if (this.contact == null)
1741        return false;
1742      for (ContactComponent item : this.contact)
1743        if (!item.isEmpty())
1744          return true;
1745      return false;
1746    }
1747
1748    /**
1749     * @return {@link #contact} (A contact party (e.g. guardian, partner, friend) for the patient.)
1750     */
1751    // syntactic sugar
1752    public ContactComponent addContact() { //3
1753      ContactComponent t = new ContactComponent();
1754      if (this.contact == null)
1755        this.contact = new ArrayList<ContactComponent>();
1756      this.contact.add(t);
1757      return t;
1758    }
1759
1760    // syntactic sugar
1761    public Patient addContact(ContactComponent t) { //3
1762      if (t == null)
1763        return this;
1764      if (this.contact == null)
1765        this.contact = new ArrayList<ContactComponent>();
1766      this.contact.add(t);
1767      return this;
1768    }
1769
1770    /**
1771     * @return {@link #animal} (This patient is known to be an animal.)
1772     */
1773    public AnimalComponent getAnimal() { 
1774      if (this.animal == null)
1775        if (Configuration.errorOnAutoCreate())
1776          throw new Error("Attempt to auto-create Patient.animal");
1777        else if (Configuration.doAutoCreate())
1778          this.animal = new AnimalComponent(); // cc
1779      return this.animal;
1780    }
1781
1782    public boolean hasAnimal() { 
1783      return this.animal != null && !this.animal.isEmpty();
1784    }
1785
1786    /**
1787     * @param value {@link #animal} (This patient is known to be an animal.)
1788     */
1789    public Patient setAnimal(AnimalComponent value) { 
1790      this.animal = value;
1791      return this;
1792    }
1793
1794    /**
1795     * @return {@link #communication} (Languages which may be used to communicate with the patient about his or her health.)
1796     */
1797    public List<PatientCommunicationComponent> getCommunication() { 
1798      if (this.communication == null)
1799        this.communication = new ArrayList<PatientCommunicationComponent>();
1800      return this.communication;
1801    }
1802
1803    public boolean hasCommunication() { 
1804      if (this.communication == null)
1805        return false;
1806      for (PatientCommunicationComponent item : this.communication)
1807        if (!item.isEmpty())
1808          return true;
1809      return false;
1810    }
1811
1812    /**
1813     * @return {@link #communication} (Languages which may be used to communicate with the patient about his or her health.)
1814     */
1815    // syntactic sugar
1816    public PatientCommunicationComponent addCommunication() { //3
1817      PatientCommunicationComponent t = new PatientCommunicationComponent();
1818      if (this.communication == null)
1819        this.communication = new ArrayList<PatientCommunicationComponent>();
1820      this.communication.add(t);
1821      return t;
1822    }
1823
1824    // syntactic sugar
1825    public Patient addCommunication(PatientCommunicationComponent t) { //3
1826      if (t == null)
1827        return this;
1828      if (this.communication == null)
1829        this.communication = new ArrayList<PatientCommunicationComponent>();
1830      this.communication.add(t);
1831      return this;
1832    }
1833
1834    /**
1835     * @return {@link #careProvider} (Patient's nominated care provider.)
1836     */
1837    public List<Reference> getCareProvider() { 
1838      if (this.careProvider == null)
1839        this.careProvider = new ArrayList<Reference>();
1840      return this.careProvider;
1841    }
1842
1843    public boolean hasCareProvider() { 
1844      if (this.careProvider == null)
1845        return false;
1846      for (Reference item : this.careProvider)
1847        if (!item.isEmpty())
1848          return true;
1849      return false;
1850    }
1851
1852    /**
1853     * @return {@link #careProvider} (Patient's nominated care provider.)
1854     */
1855    // syntactic sugar
1856    public Reference addCareProvider() { //3
1857      Reference t = new Reference();
1858      if (this.careProvider == null)
1859        this.careProvider = new ArrayList<Reference>();
1860      this.careProvider.add(t);
1861      return t;
1862    }
1863
1864    // syntactic sugar
1865    public Patient addCareProvider(Reference t) { //3
1866      if (t == null)
1867        return this;
1868      if (this.careProvider == null)
1869        this.careProvider = new ArrayList<Reference>();
1870      this.careProvider.add(t);
1871      return this;
1872    }
1873
1874    /**
1875     * @return {@link #careProvider} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Patient's nominated care provider.)
1876     */
1877    public List<Resource> getCareProviderTarget() { 
1878      if (this.careProviderTarget == null)
1879        this.careProviderTarget = new ArrayList<Resource>();
1880      return this.careProviderTarget;
1881    }
1882
1883    /**
1884     * @return {@link #managingOrganization} (Organization that is the custodian of the patient record.)
1885     */
1886    public Reference getManagingOrganization() { 
1887      if (this.managingOrganization == null)
1888        if (Configuration.errorOnAutoCreate())
1889          throw new Error("Attempt to auto-create Patient.managingOrganization");
1890        else if (Configuration.doAutoCreate())
1891          this.managingOrganization = new Reference(); // cc
1892      return this.managingOrganization;
1893    }
1894
1895    public boolean hasManagingOrganization() { 
1896      return this.managingOrganization != null && !this.managingOrganization.isEmpty();
1897    }
1898
1899    /**
1900     * @param value {@link #managingOrganization} (Organization that is the custodian of the patient record.)
1901     */
1902    public Patient setManagingOrganization(Reference value) { 
1903      this.managingOrganization = value;
1904      return this;
1905    }
1906
1907    /**
1908     * @return {@link #managingOrganization} 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. (Organization that is the custodian of the patient record.)
1909     */
1910    public Organization getManagingOrganizationTarget() { 
1911      if (this.managingOrganizationTarget == null)
1912        if (Configuration.errorOnAutoCreate())
1913          throw new Error("Attempt to auto-create Patient.managingOrganization");
1914        else if (Configuration.doAutoCreate())
1915          this.managingOrganizationTarget = new Organization(); // aa
1916      return this.managingOrganizationTarget;
1917    }
1918
1919    /**
1920     * @param value {@link #managingOrganization} 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. (Organization that is the custodian of the patient record.)
1921     */
1922    public Patient setManagingOrganizationTarget(Organization value) { 
1923      this.managingOrganizationTarget = value;
1924      return this;
1925    }
1926
1927    /**
1928     * @return {@link #link} (Link to another patient resource that concerns the same actual patient.)
1929     */
1930    public List<PatientLinkComponent> getLink() { 
1931      if (this.link == null)
1932        this.link = new ArrayList<PatientLinkComponent>();
1933      return this.link;
1934    }
1935
1936    public boolean hasLink() { 
1937      if (this.link == null)
1938        return false;
1939      for (PatientLinkComponent item : this.link)
1940        if (!item.isEmpty())
1941          return true;
1942      return false;
1943    }
1944
1945    /**
1946     * @return {@link #link} (Link to another patient resource that concerns the same actual patient.)
1947     */
1948    // syntactic sugar
1949    public PatientLinkComponent addLink() { //3
1950      PatientLinkComponent t = new PatientLinkComponent();
1951      if (this.link == null)
1952        this.link = new ArrayList<PatientLinkComponent>();
1953      this.link.add(t);
1954      return t;
1955    }
1956
1957    // syntactic sugar
1958    public Patient addLink(PatientLinkComponent t) { //3
1959      if (t == null)
1960        return this;
1961      if (this.link == null)
1962        this.link = new ArrayList<PatientLinkComponent>();
1963      this.link.add(t);
1964      return this;
1965    }
1966
1967      protected void listChildren(List<Property> childrenList) {
1968        super.listChildren(childrenList);
1969        childrenList.add(new Property("identifier", "Identifier", "An identifier for this patient.", 0, java.lang.Integer.MAX_VALUE, identifier));
1970        childrenList.add(new Property("active", "boolean", "Whether this patient record is in active use.", 0, java.lang.Integer.MAX_VALUE, active));
1971        childrenList.add(new Property("name", "HumanName", "A name associated with the individual.", 0, java.lang.Integer.MAX_VALUE, name));
1972        childrenList.add(new Property("telecom", "ContactPoint", "A contact detail (e.g. a telephone number or an email address) by which the individual may be contacted.", 0, java.lang.Integer.MAX_VALUE, telecom));
1973        childrenList.add(new Property("gender", "code", "Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes.", 0, java.lang.Integer.MAX_VALUE, gender));
1974        childrenList.add(new Property("birthDate", "date", "The date of birth for the individual.", 0, java.lang.Integer.MAX_VALUE, birthDate));
1975        childrenList.add(new Property("deceased[x]", "boolean|dateTime", "Indicates if the individual is deceased or not.", 0, java.lang.Integer.MAX_VALUE, deceased));
1976        childrenList.add(new Property("address", "Address", "Addresses for the individual.", 0, java.lang.Integer.MAX_VALUE, address));
1977        childrenList.add(new Property("maritalStatus", "CodeableConcept", "This field contains a patient's most recent marital (civil) status.", 0, java.lang.Integer.MAX_VALUE, maritalStatus));
1978        childrenList.add(new Property("multipleBirth[x]", "boolean|integer", "Indicates whether the patient is part of a multiple or indicates the actual birth order.", 0, java.lang.Integer.MAX_VALUE, multipleBirth));
1979        childrenList.add(new Property("photo", "Attachment", "Image of the patient.", 0, java.lang.Integer.MAX_VALUE, photo));
1980        childrenList.add(new Property("contact", "", "A contact party (e.g. guardian, partner, friend) for the patient.", 0, java.lang.Integer.MAX_VALUE, contact));
1981        childrenList.add(new Property("animal", "", "This patient is known to be an animal.", 0, java.lang.Integer.MAX_VALUE, animal));
1982        childrenList.add(new Property("communication", "", "Languages which may be used to communicate with the patient about his or her health.", 0, java.lang.Integer.MAX_VALUE, communication));
1983        childrenList.add(new Property("careProvider", "Reference(Organization|Practitioner)", "Patient's nominated care provider.", 0, java.lang.Integer.MAX_VALUE, careProvider));
1984        childrenList.add(new Property("managingOrganization", "Reference(Organization)", "Organization that is the custodian of the patient record.", 0, java.lang.Integer.MAX_VALUE, managingOrganization));
1985        childrenList.add(new Property("link", "", "Link to another patient resource that concerns the same actual patient.", 0, java.lang.Integer.MAX_VALUE, link));
1986      }
1987
1988      @Override
1989      public void setProperty(String name, Base value) throws FHIRException {
1990        if (name.equals("identifier"))
1991          this.getIdentifier().add(castToIdentifier(value));
1992        else if (name.equals("active"))
1993          this.active = castToBoolean(value); // BooleanType
1994        else if (name.equals("name"))
1995          this.getName().add(castToHumanName(value));
1996        else if (name.equals("telecom"))
1997          this.getTelecom().add(castToContactPoint(value));
1998        else if (name.equals("gender"))
1999          this.gender = new AdministrativeGenderEnumFactory().fromType(value); // Enumeration<AdministrativeGender>
2000        else if (name.equals("birthDate"))
2001          this.birthDate = castToDate(value); // DateType
2002        else if (name.equals("deceased[x]"))
2003          this.deceased = (Type) value; // Type
2004        else if (name.equals("address"))
2005          this.getAddress().add(castToAddress(value));
2006        else if (name.equals("maritalStatus"))
2007          this.maritalStatus = castToCodeableConcept(value); // CodeableConcept
2008        else if (name.equals("multipleBirth[x]"))
2009          this.multipleBirth = (Type) value; // Type
2010        else if (name.equals("photo"))
2011          this.getPhoto().add(castToAttachment(value));
2012        else if (name.equals("contact"))
2013          this.getContact().add((ContactComponent) value);
2014        else if (name.equals("animal"))
2015          this.animal = (AnimalComponent) value; // AnimalComponent
2016        else if (name.equals("communication"))
2017          this.getCommunication().add((PatientCommunicationComponent) value);
2018        else if (name.equals("careProvider"))
2019          this.getCareProvider().add(castToReference(value));
2020        else if (name.equals("managingOrganization"))
2021          this.managingOrganization = castToReference(value); // Reference
2022        else if (name.equals("link"))
2023          this.getLink().add((PatientLinkComponent) value);
2024        else
2025          super.setProperty(name, value);
2026      }
2027
2028      @Override
2029      public Base addChild(String name) throws FHIRException {
2030        if (name.equals("identifier")) {
2031          return addIdentifier();
2032        }
2033        else if (name.equals("active")) {
2034          throw new FHIRException("Cannot call addChild on a primitive type Patient.active");
2035        }
2036        else if (name.equals("name")) {
2037          return addName();
2038        }
2039        else if (name.equals("telecom")) {
2040          return addTelecom();
2041        }
2042        else if (name.equals("gender")) {
2043          throw new FHIRException("Cannot call addChild on a primitive type Patient.gender");
2044        }
2045        else if (name.equals("birthDate")) {
2046          throw new FHIRException("Cannot call addChild on a primitive type Patient.birthDate");
2047        }
2048        else if (name.equals("deceasedBoolean")) {
2049          this.deceased = new BooleanType();
2050          return this.deceased;
2051        }
2052        else if (name.equals("deceasedDateTime")) {
2053          this.deceased = new DateTimeType();
2054          return this.deceased;
2055        }
2056        else if (name.equals("address")) {
2057          return addAddress();
2058        }
2059        else if (name.equals("maritalStatus")) {
2060          this.maritalStatus = new CodeableConcept();
2061          return this.maritalStatus;
2062        }
2063        else if (name.equals("multipleBirthBoolean")) {
2064          this.multipleBirth = new BooleanType();
2065          return this.multipleBirth;
2066        }
2067        else if (name.equals("multipleBirthInteger")) {
2068          this.multipleBirth = new IntegerType();
2069          return this.multipleBirth;
2070        }
2071        else if (name.equals("photo")) {
2072          return addPhoto();
2073        }
2074        else if (name.equals("contact")) {
2075          return addContact();
2076        }
2077        else if (name.equals("animal")) {
2078          this.animal = new AnimalComponent();
2079          return this.animal;
2080        }
2081        else if (name.equals("communication")) {
2082          return addCommunication();
2083        }
2084        else if (name.equals("careProvider")) {
2085          return addCareProvider();
2086        }
2087        else if (name.equals("managingOrganization")) {
2088          this.managingOrganization = new Reference();
2089          return this.managingOrganization;
2090        }
2091        else if (name.equals("link")) {
2092          return addLink();
2093        }
2094        else
2095          return super.addChild(name);
2096      }
2097
2098  public String fhirType() {
2099    return "Patient";
2100
2101  }
2102
2103      public Patient copy() {
2104        Patient dst = new Patient();
2105        copyValues(dst);
2106        if (identifier != null) {
2107          dst.identifier = new ArrayList<Identifier>();
2108          for (Identifier i : identifier)
2109            dst.identifier.add(i.copy());
2110        };
2111        dst.active = active == null ? null : active.copy();
2112        if (name != null) {
2113          dst.name = new ArrayList<HumanName>();
2114          for (HumanName i : name)
2115            dst.name.add(i.copy());
2116        };
2117        if (telecom != null) {
2118          dst.telecom = new ArrayList<ContactPoint>();
2119          for (ContactPoint i : telecom)
2120            dst.telecom.add(i.copy());
2121        };
2122        dst.gender = gender == null ? null : gender.copy();
2123        dst.birthDate = birthDate == null ? null : birthDate.copy();
2124        dst.deceased = deceased == null ? null : deceased.copy();
2125        if (address != null) {
2126          dst.address = new ArrayList<Address>();
2127          for (Address i : address)
2128            dst.address.add(i.copy());
2129        };
2130        dst.maritalStatus = maritalStatus == null ? null : maritalStatus.copy();
2131        dst.multipleBirth = multipleBirth == null ? null : multipleBirth.copy();
2132        if (photo != null) {
2133          dst.photo = new ArrayList<Attachment>();
2134          for (Attachment i : photo)
2135            dst.photo.add(i.copy());
2136        };
2137        if (contact != null) {
2138          dst.contact = new ArrayList<ContactComponent>();
2139          for (ContactComponent i : contact)
2140            dst.contact.add(i.copy());
2141        };
2142        dst.animal = animal == null ? null : animal.copy();
2143        if (communication != null) {
2144          dst.communication = new ArrayList<PatientCommunicationComponent>();
2145          for (PatientCommunicationComponent i : communication)
2146            dst.communication.add(i.copy());
2147        };
2148        if (careProvider != null) {
2149          dst.careProvider = new ArrayList<Reference>();
2150          for (Reference i : careProvider)
2151            dst.careProvider.add(i.copy());
2152        };
2153        dst.managingOrganization = managingOrganization == null ? null : managingOrganization.copy();
2154        if (link != null) {
2155          dst.link = new ArrayList<PatientLinkComponent>();
2156          for (PatientLinkComponent i : link)
2157            dst.link.add(i.copy());
2158        };
2159        return dst;
2160      }
2161
2162      protected Patient typedCopy() {
2163        return copy();
2164      }
2165
2166      @Override
2167      public boolean equalsDeep(Base other) {
2168        if (!super.equalsDeep(other))
2169          return false;
2170        if (!(other instanceof Patient))
2171          return false;
2172        Patient o = (Patient) other;
2173        return compareDeep(identifier, o.identifier, true) && compareDeep(active, o.active, true) && compareDeep(name, o.name, true)
2174           && compareDeep(telecom, o.telecom, true) && compareDeep(gender, o.gender, true) && compareDeep(birthDate, o.birthDate, true)
2175           && compareDeep(deceased, o.deceased, true) && compareDeep(address, o.address, true) && compareDeep(maritalStatus, o.maritalStatus, true)
2176           && compareDeep(multipleBirth, o.multipleBirth, true) && compareDeep(photo, o.photo, true) && compareDeep(contact, o.contact, true)
2177           && compareDeep(animal, o.animal, true) && compareDeep(communication, o.communication, true) && compareDeep(careProvider, o.careProvider, true)
2178           && compareDeep(managingOrganization, o.managingOrganization, true) && compareDeep(link, o.link, true)
2179          ;
2180      }
2181
2182      @Override
2183      public boolean equalsShallow(Base other) {
2184        if (!super.equalsShallow(other))
2185          return false;
2186        if (!(other instanceof Patient))
2187          return false;
2188        Patient o = (Patient) other;
2189        return compareValues(active, o.active, true) && compareValues(gender, o.gender, true) && compareValues(birthDate, o.birthDate, true)
2190          ;
2191      }
2192
2193      public boolean isEmpty() {
2194        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (active == null || active.isEmpty())
2195           && (name == null || name.isEmpty()) && (telecom == null || telecom.isEmpty()) && (gender == null || gender.isEmpty())
2196           && (birthDate == null || birthDate.isEmpty()) && (deceased == null || deceased.isEmpty())
2197           && (address == null || address.isEmpty()) && (maritalStatus == null || maritalStatus.isEmpty())
2198           && (multipleBirth == null || multipleBirth.isEmpty()) && (photo == null || photo.isEmpty())
2199           && (contact == null || contact.isEmpty()) && (animal == null || animal.isEmpty()) && (communication == null || communication.isEmpty())
2200           && (careProvider == null || careProvider.isEmpty()) && (managingOrganization == null || managingOrganization.isEmpty())
2201           && (link == null || link.isEmpty());
2202      }
2203
2204  @Override
2205  public ResourceType getResourceType() {
2206    return ResourceType.Patient;
2207   }
2208
2209  @SearchParamDefinition(name="birthdate", path="Patient.birthDate", description="The patient's date of birth", type="date" )
2210  public static final String SP_BIRTHDATE = "birthdate";
2211  @SearchParamDefinition(name="deceased", path="Patient.deceased[x]", description="This patient has been marked as deceased, or as a death date entered", type="token" )
2212  public static final String SP_DECEASED = "deceased";
2213  @SearchParamDefinition(name="address-state", path="Patient.address.state", description="A state specified in an address", type="string" )
2214  public static final String SP_ADDRESSSTATE = "address-state";
2215  @SearchParamDefinition(name="gender", path="Patient.gender", description="Gender of the patient", type="token" )
2216  public static final String SP_GENDER = "gender";
2217  @SearchParamDefinition(name="animal-species", path="Patient.animal.species", description="The species for animal patients", type="token" )
2218  public static final String SP_ANIMALSPECIES = "animal-species";
2219  @SearchParamDefinition(name="link", path="Patient.link.other", description="All patients linked to the given patient", type="reference" )
2220  public static final String SP_LINK = "link";
2221  @SearchParamDefinition(name="language", path="Patient.communication.language", description="Language code (irrespective of use value)", type="token" )
2222  public static final String SP_LANGUAGE = "language";
2223  @SearchParamDefinition(name="deathdate", path="Patient.deceasedDateTime", description="The date of death has been provided and satisfies this search value", type="date" )
2224  public static final String SP_DEATHDATE = "deathdate";
2225  @SearchParamDefinition(name="animal-breed", path="Patient.animal.breed", description="The breed for animal patients", type="token" )
2226  public static final String SP_ANIMALBREED = "animal-breed";
2227  @SearchParamDefinition(name="address-country", path="Patient.address.country", description="A country specified in an address", type="string" )
2228  public static final String SP_ADDRESSCOUNTRY = "address-country";
2229  @SearchParamDefinition(name="phonetic", path="Patient.name", description="A portion of either family or given name using some kind of phonetic matching algorithm", type="string" )
2230  public static final String SP_PHONETIC = "phonetic";
2231  @SearchParamDefinition(name="telecom", path="Patient.telecom", description="The value in any kind of telecom details of the patient", type="token" )
2232  public static final String SP_TELECOM = "telecom";
2233  @SearchParamDefinition(name="address-city", path="Patient.address.city", description="A city specified in an address", type="string" )
2234  public static final String SP_ADDRESSCITY = "address-city";
2235  @SearchParamDefinition(name="email", path="Patient.telecom.where(system='email')", description="A value in an email contact", type="token" )
2236  public static final String SP_EMAIL = "email";
2237  @SearchParamDefinition(name="identifier", path="Patient.identifier", description="A patient identifier", type="token" )
2238  public static final String SP_IDENTIFIER = "identifier";
2239  @SearchParamDefinition(name="given", path="Patient.name.given", description="A portion of the given name of the patient", type="string" )
2240  public static final String SP_GIVEN = "given";
2241  @SearchParamDefinition(name="address", path="Patient.address", description="An address in any kind of address/part of the patient", type="string" )
2242  public static final String SP_ADDRESS = "address";
2243  @SearchParamDefinition(name="active", path="Patient.active", description="Whether the patient record is active", type="token" )
2244  public static final String SP_ACTIVE = "active";
2245  @SearchParamDefinition(name="address-postalcode", path="Patient.address.postalCode", description="A postalCode specified in an address", type="string" )
2246  public static final String SP_ADDRESSPOSTALCODE = "address-postalcode";
2247  @SearchParamDefinition(name="careprovider", path="Patient.careProvider", description="Patient's nominated care provider, could be a care manager, not the organization that manages the record", type="reference" )
2248  public static final String SP_CAREPROVIDER = "careprovider";
2249  @SearchParamDefinition(name="phone", path="Patient.telecom.where(system='phone')", description="A value in a phone contact", type="token" )
2250  public static final String SP_PHONE = "phone";
2251  @SearchParamDefinition(name="organization", path="Patient.managingOrganization", description="The organization at which this person is a patient", type="reference" )
2252  public static final String SP_ORGANIZATION = "organization";
2253  @SearchParamDefinition(name="name", path="Patient.name", description="A portion of either family or given name of the patient", type="string" )
2254  public static final String SP_NAME = "name";
2255  @SearchParamDefinition(name="address-use", path="Patient.address.use", description="A use code specified in an address", type="token" )
2256  public static final String SP_ADDRESSUSE = "address-use";
2257  @SearchParamDefinition(name="family", path="Patient.name.family", description="A portion of the family name of the patient", type="string" )
2258  public static final String SP_FAMILY = "family";
2259
2260}
2261