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