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 administrative information about a person independent of a specific health-related context. 051 */ 052@ResourceDef(name="Person", profile="http://hl7.org/fhir/Profile/Person") 053public class Person extends DomainResource { 054 055 public enum IdentityAssuranceLevel { 056 /** 057 * Little or no confidence in the asserted identity's accuracy. 058 */ 059 LEVEL1, 060 /** 061 * Some confidence in the asserted identity's accuracy. 062 */ 063 LEVEL2, 064 /** 065 * High confidence in the asserted identity's accuracy. 066 */ 067 LEVEL3, 068 /** 069 * Very high confidence in the asserted identity's accuracy. 070 */ 071 LEVEL4, 072 /** 073 * added to help the parsers 074 */ 075 NULL; 076 public static IdentityAssuranceLevel fromCode(String codeString) throws FHIRException { 077 if (codeString == null || "".equals(codeString)) 078 return null; 079 if ("level1".equals(codeString)) 080 return LEVEL1; 081 if ("level2".equals(codeString)) 082 return LEVEL2; 083 if ("level3".equals(codeString)) 084 return LEVEL3; 085 if ("level4".equals(codeString)) 086 return LEVEL4; 087 throw new FHIRException("Unknown IdentityAssuranceLevel code '"+codeString+"'"); 088 } 089 public String toCode() { 090 switch (this) { 091 case LEVEL1: return "level1"; 092 case LEVEL2: return "level2"; 093 case LEVEL3: return "level3"; 094 case LEVEL4: return "level4"; 095 default: return "?"; 096 } 097 } 098 public String getSystem() { 099 switch (this) { 100 case LEVEL1: return "http://hl7.org/fhir/identity-assuranceLevel"; 101 case LEVEL2: return "http://hl7.org/fhir/identity-assuranceLevel"; 102 case LEVEL3: return "http://hl7.org/fhir/identity-assuranceLevel"; 103 case LEVEL4: return "http://hl7.org/fhir/identity-assuranceLevel"; 104 default: return "?"; 105 } 106 } 107 public String getDefinition() { 108 switch (this) { 109 case LEVEL1: return "Little or no confidence in the asserted identity's accuracy."; 110 case LEVEL2: return "Some confidence in the asserted identity's accuracy."; 111 case LEVEL3: return "High confidence in the asserted identity's accuracy."; 112 case LEVEL4: return "Very high confidence in the asserted identity's accuracy."; 113 default: return "?"; 114 } 115 } 116 public String getDisplay() { 117 switch (this) { 118 case LEVEL1: return "Level 1"; 119 case LEVEL2: return "Level 2"; 120 case LEVEL3: return "Level 3"; 121 case LEVEL4: return "Level 4"; 122 default: return "?"; 123 } 124 } 125 } 126 127 public static class IdentityAssuranceLevelEnumFactory implements EnumFactory<IdentityAssuranceLevel> { 128 public IdentityAssuranceLevel fromCode(String codeString) throws IllegalArgumentException { 129 if (codeString == null || "".equals(codeString)) 130 if (codeString == null || "".equals(codeString)) 131 return null; 132 if ("level1".equals(codeString)) 133 return IdentityAssuranceLevel.LEVEL1; 134 if ("level2".equals(codeString)) 135 return IdentityAssuranceLevel.LEVEL2; 136 if ("level3".equals(codeString)) 137 return IdentityAssuranceLevel.LEVEL3; 138 if ("level4".equals(codeString)) 139 return IdentityAssuranceLevel.LEVEL4; 140 throw new IllegalArgumentException("Unknown IdentityAssuranceLevel code '"+codeString+"'"); 141 } 142 public Enumeration<IdentityAssuranceLevel> fromType(Base code) throws FHIRException { 143 if (code == null || code.isEmpty()) 144 return null; 145 String codeString = ((PrimitiveType) code).asStringValue(); 146 if (codeString == null || "".equals(codeString)) 147 return null; 148 if ("level1".equals(codeString)) 149 return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.LEVEL1); 150 if ("level2".equals(codeString)) 151 return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.LEVEL2); 152 if ("level3".equals(codeString)) 153 return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.LEVEL3); 154 if ("level4".equals(codeString)) 155 return new Enumeration<IdentityAssuranceLevel>(this, IdentityAssuranceLevel.LEVEL4); 156 throw new FHIRException("Unknown IdentityAssuranceLevel code '"+codeString+"'"); 157 } 158 public String toCode(IdentityAssuranceLevel code) { 159 if (code == IdentityAssuranceLevel.LEVEL1) 160 return "level1"; 161 if (code == IdentityAssuranceLevel.LEVEL2) 162 return "level2"; 163 if (code == IdentityAssuranceLevel.LEVEL3) 164 return "level3"; 165 if (code == IdentityAssuranceLevel.LEVEL4) 166 return "level4"; 167 return "?"; 168 } 169 } 170 171 @Block() 172 public static class PersonLinkComponent extends BackboneElement implements IBaseBackboneElement { 173 /** 174 * The resource to which this actual person is associated. 175 */ 176 @Child(name = "target", type = {Patient.class, Practitioner.class, RelatedPerson.class, Person.class}, order=1, min=1, max=1, modifier=false, summary=false) 177 @Description(shortDefinition="The resource to which this actual person is associated", formalDefinition="The resource to which this actual person is associated." ) 178 protected Reference target; 179 180 /** 181 * The actual object that is the target of the reference (The resource to which this actual person is associated.) 182 */ 183 protected Resource targetTarget; 184 185 /** 186 * Level of assurance that this link is actually associated with the target resource. 187 */ 188 @Child(name = "assurance", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=false) 189 @Description(shortDefinition="level1 | level2 | level3 | level4", formalDefinition="Level of assurance that this link is actually associated with the target resource." ) 190 protected Enumeration<IdentityAssuranceLevel> assurance; 191 192 private static final long serialVersionUID = 508763647L; 193 194 /* 195 * Constructor 196 */ 197 public PersonLinkComponent() { 198 super(); 199 } 200 201 /* 202 * Constructor 203 */ 204 public PersonLinkComponent(Reference target) { 205 super(); 206 this.target = target; 207 } 208 209 /** 210 * @return {@link #target} (The resource to which this actual person is associated.) 211 */ 212 public Reference getTarget() { 213 if (this.target == null) 214 if (Configuration.errorOnAutoCreate()) 215 throw new Error("Attempt to auto-create PersonLinkComponent.target"); 216 else if (Configuration.doAutoCreate()) 217 this.target = new Reference(); // cc 218 return this.target; 219 } 220 221 public boolean hasTarget() { 222 return this.target != null && !this.target.isEmpty(); 223 } 224 225 /** 226 * @param value {@link #target} (The resource to which this actual person is associated.) 227 */ 228 public PersonLinkComponent setTarget(Reference value) { 229 this.target = value; 230 return this; 231 } 232 233 /** 234 * @return {@link #target} 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 resource to which this actual person is associated.) 235 */ 236 public Resource getTargetTarget() { 237 return this.targetTarget; 238 } 239 240 /** 241 * @param value {@link #target} 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 resource to which this actual person is associated.) 242 */ 243 public PersonLinkComponent setTargetTarget(Resource value) { 244 this.targetTarget = value; 245 return this; 246 } 247 248 /** 249 * @return {@link #assurance} (Level of assurance that this link is actually associated with the target resource.). This is the underlying object with id, value and extensions. The accessor "getAssurance" gives direct access to the value 250 */ 251 public Enumeration<IdentityAssuranceLevel> getAssuranceElement() { 252 if (this.assurance == null) 253 if (Configuration.errorOnAutoCreate()) 254 throw new Error("Attempt to auto-create PersonLinkComponent.assurance"); 255 else if (Configuration.doAutoCreate()) 256 this.assurance = new Enumeration<IdentityAssuranceLevel>(new IdentityAssuranceLevelEnumFactory()); // bb 257 return this.assurance; 258 } 259 260 public boolean hasAssuranceElement() { 261 return this.assurance != null && !this.assurance.isEmpty(); 262 } 263 264 public boolean hasAssurance() { 265 return this.assurance != null && !this.assurance.isEmpty(); 266 } 267 268 /** 269 * @param value {@link #assurance} (Level of assurance that this link is actually associated with the target resource.). This is the underlying object with id, value and extensions. The accessor "getAssurance" gives direct access to the value 270 */ 271 public PersonLinkComponent setAssuranceElement(Enumeration<IdentityAssuranceLevel> value) { 272 this.assurance = value; 273 return this; 274 } 275 276 /** 277 * @return Level of assurance that this link is actually associated with the target resource. 278 */ 279 public IdentityAssuranceLevel getAssurance() { 280 return this.assurance == null ? null : this.assurance.getValue(); 281 } 282 283 /** 284 * @param value Level of assurance that this link is actually associated with the target resource. 285 */ 286 public PersonLinkComponent setAssurance(IdentityAssuranceLevel value) { 287 if (value == null) 288 this.assurance = null; 289 else { 290 if (this.assurance == null) 291 this.assurance = new Enumeration<IdentityAssuranceLevel>(new IdentityAssuranceLevelEnumFactory()); 292 this.assurance.setValue(value); 293 } 294 return this; 295 } 296 297 protected void listChildren(List<Property> childrenList) { 298 super.listChildren(childrenList); 299 childrenList.add(new Property("target", "Reference(Patient|Practitioner|RelatedPerson|Person)", "The resource to which this actual person is associated.", 0, java.lang.Integer.MAX_VALUE, target)); 300 childrenList.add(new Property("assurance", "code", "Level of assurance that this link is actually associated with the target resource.", 0, java.lang.Integer.MAX_VALUE, assurance)); 301 } 302 303 @Override 304 public void setProperty(String name, Base value) throws FHIRException { 305 if (name.equals("target")) 306 this.target = castToReference(value); // Reference 307 else if (name.equals("assurance")) 308 this.assurance = new IdentityAssuranceLevelEnumFactory().fromType(value); // Enumeration<IdentityAssuranceLevel> 309 else 310 super.setProperty(name, value); 311 } 312 313 @Override 314 public Base addChild(String name) throws FHIRException { 315 if (name.equals("target")) { 316 this.target = new Reference(); 317 return this.target; 318 } 319 else if (name.equals("assurance")) { 320 throw new FHIRException("Cannot call addChild on a primitive type Person.assurance"); 321 } 322 else 323 return super.addChild(name); 324 } 325 326 public PersonLinkComponent copy() { 327 PersonLinkComponent dst = new PersonLinkComponent(); 328 copyValues(dst); 329 dst.target = target == null ? null : target.copy(); 330 dst.assurance = assurance == null ? null : assurance.copy(); 331 return dst; 332 } 333 334 @Override 335 public boolean equalsDeep(Base other) { 336 if (!super.equalsDeep(other)) 337 return false; 338 if (!(other instanceof PersonLinkComponent)) 339 return false; 340 PersonLinkComponent o = (PersonLinkComponent) other; 341 return compareDeep(target, o.target, true) && compareDeep(assurance, o.assurance, true); 342 } 343 344 @Override 345 public boolean equalsShallow(Base other) { 346 if (!super.equalsShallow(other)) 347 return false; 348 if (!(other instanceof PersonLinkComponent)) 349 return false; 350 PersonLinkComponent o = (PersonLinkComponent) other; 351 return compareValues(assurance, o.assurance, true); 352 } 353 354 public boolean isEmpty() { 355 return super.isEmpty() && (target == null || target.isEmpty()) && (assurance == null || assurance.isEmpty()) 356 ; 357 } 358 359 public String fhirType() { 360 return "Person.link"; 361 362 } 363 364 } 365 366 /** 367 * Identifier for a person within a particular scope. 368 */ 369 @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 370 @Description(shortDefinition="A human identifier for this person", formalDefinition="Identifier for a person within a particular scope." ) 371 protected List<Identifier> identifier; 372 373 /** 374 * A name associated with the person. 375 */ 376 @Child(name = "name", type = {HumanName.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 377 @Description(shortDefinition="A name associated with the person", formalDefinition="A name associated with the person." ) 378 protected List<HumanName> name; 379 380 /** 381 * A contact detail for the person, e.g. a telephone number or an email address. 382 */ 383 @Child(name = "telecom", type = {ContactPoint.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 384 @Description(shortDefinition="A contact detail for the person", formalDefinition="A contact detail for the person, e.g. a telephone number or an email address." ) 385 protected List<ContactPoint> telecom; 386 387 /** 388 * Administrative Gender. 389 */ 390 @Child(name = "gender", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true) 391 @Description(shortDefinition="male | female | other | unknown", formalDefinition="Administrative Gender." ) 392 protected Enumeration<AdministrativeGender> gender; 393 394 /** 395 * The birth date for the person. 396 */ 397 @Child(name = "birthDate", type = {DateType.class}, order=4, min=0, max=1, modifier=false, summary=true) 398 @Description(shortDefinition="The date on which the person was born", formalDefinition="The birth date for the person." ) 399 protected DateType birthDate; 400 401 /** 402 * One or more addresses for the person. 403 */ 404 @Child(name = "address", type = {Address.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 405 @Description(shortDefinition="One or more addresses for the person", formalDefinition="One or more addresses for the person." ) 406 protected List<Address> address; 407 408 /** 409 * An image that can be displayed as a thumbnail of the person to enhance the identification of the individual. 410 */ 411 @Child(name = "photo", type = {Attachment.class}, order=6, min=0, max=1, modifier=false, summary=false) 412 @Description(shortDefinition="Image of the person", formalDefinition="An image that can be displayed as a thumbnail of the person to enhance the identification of the individual." ) 413 protected Attachment photo; 414 415 /** 416 * The organization that is the custodian of the person record. 417 */ 418 @Child(name = "managingOrganization", type = {Organization.class}, order=7, min=0, max=1, modifier=false, summary=true) 419 @Description(shortDefinition="The organization that is the custodian of the person record", formalDefinition="The organization that is the custodian of the person record." ) 420 protected Reference managingOrganization; 421 422 /** 423 * The actual object that is the target of the reference (The organization that is the custodian of the person record.) 424 */ 425 protected Organization managingOrganizationTarget; 426 427 /** 428 * Whether this person's record is in active use. 429 */ 430 @Child(name = "active", type = {BooleanType.class}, order=8, min=0, max=1, modifier=true, summary=true) 431 @Description(shortDefinition="This person's record is in active use", formalDefinition="Whether this person's record is in active use." ) 432 protected BooleanType active; 433 434 /** 435 * Link to a resource that concerns the same actual person. 436 */ 437 @Child(name = "link", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 438 @Description(shortDefinition="Link to a resource that concerns the same actual person", formalDefinition="Link to a resource that concerns the same actual person." ) 439 protected List<PersonLinkComponent> link; 440 441 private static final long serialVersionUID = -117464654L; 442 443 /* 444 * Constructor 445 */ 446 public Person() { 447 super(); 448 } 449 450 /** 451 * @return {@link #identifier} (Identifier for a person within a particular scope.) 452 */ 453 public List<Identifier> getIdentifier() { 454 if (this.identifier == null) 455 this.identifier = new ArrayList<Identifier>(); 456 return this.identifier; 457 } 458 459 public boolean hasIdentifier() { 460 if (this.identifier == null) 461 return false; 462 for (Identifier item : this.identifier) 463 if (!item.isEmpty()) 464 return true; 465 return false; 466 } 467 468 /** 469 * @return {@link #identifier} (Identifier for a person within a particular scope.) 470 */ 471 // syntactic sugar 472 public Identifier addIdentifier() { //3 473 Identifier t = new Identifier(); 474 if (this.identifier == null) 475 this.identifier = new ArrayList<Identifier>(); 476 this.identifier.add(t); 477 return t; 478 } 479 480 // syntactic sugar 481 public Person addIdentifier(Identifier t) { //3 482 if (t == null) 483 return this; 484 if (this.identifier == null) 485 this.identifier = new ArrayList<Identifier>(); 486 this.identifier.add(t); 487 return this; 488 } 489 490 /** 491 * @return {@link #name} (A name associated with the person.) 492 */ 493 public List<HumanName> getName() { 494 if (this.name == null) 495 this.name = new ArrayList<HumanName>(); 496 return this.name; 497 } 498 499 public boolean hasName() { 500 if (this.name == null) 501 return false; 502 for (HumanName item : this.name) 503 if (!item.isEmpty()) 504 return true; 505 return false; 506 } 507 508 /** 509 * @return {@link #name} (A name associated with the person.) 510 */ 511 // syntactic sugar 512 public HumanName addName() { //3 513 HumanName t = new HumanName(); 514 if (this.name == null) 515 this.name = new ArrayList<HumanName>(); 516 this.name.add(t); 517 return t; 518 } 519 520 // syntactic sugar 521 public Person addName(HumanName t) { //3 522 if (t == null) 523 return this; 524 if (this.name == null) 525 this.name = new ArrayList<HumanName>(); 526 this.name.add(t); 527 return this; 528 } 529 530 /** 531 * @return {@link #telecom} (A contact detail for the person, e.g. a telephone number or an email address.) 532 */ 533 public List<ContactPoint> getTelecom() { 534 if (this.telecom == null) 535 this.telecom = new ArrayList<ContactPoint>(); 536 return this.telecom; 537 } 538 539 public boolean hasTelecom() { 540 if (this.telecom == null) 541 return false; 542 for (ContactPoint item : this.telecom) 543 if (!item.isEmpty()) 544 return true; 545 return false; 546 } 547 548 /** 549 * @return {@link #telecom} (A contact detail for the person, e.g. a telephone number or an email address.) 550 */ 551 // syntactic sugar 552 public ContactPoint addTelecom() { //3 553 ContactPoint t = new ContactPoint(); 554 if (this.telecom == null) 555 this.telecom = new ArrayList<ContactPoint>(); 556 this.telecom.add(t); 557 return t; 558 } 559 560 // syntactic sugar 561 public Person addTelecom(ContactPoint t) { //3 562 if (t == null) 563 return this; 564 if (this.telecom == null) 565 this.telecom = new ArrayList<ContactPoint>(); 566 this.telecom.add(t); 567 return this; 568 } 569 570 /** 571 * @return {@link #gender} (Administrative Gender.). This is the underlying object with id, value and extensions. The accessor "getGender" gives direct access to the value 572 */ 573 public Enumeration<AdministrativeGender> getGenderElement() { 574 if (this.gender == null) 575 if (Configuration.errorOnAutoCreate()) 576 throw new Error("Attempt to auto-create Person.gender"); 577 else if (Configuration.doAutoCreate()) 578 this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory()); // bb 579 return this.gender; 580 } 581 582 public boolean hasGenderElement() { 583 return this.gender != null && !this.gender.isEmpty(); 584 } 585 586 public boolean hasGender() { 587 return this.gender != null && !this.gender.isEmpty(); 588 } 589 590 /** 591 * @param value {@link #gender} (Administrative Gender.). This is the underlying object with id, value and extensions. The accessor "getGender" gives direct access to the value 592 */ 593 public Person setGenderElement(Enumeration<AdministrativeGender> value) { 594 this.gender = value; 595 return this; 596 } 597 598 /** 599 * @return Administrative Gender. 600 */ 601 public AdministrativeGender getGender() { 602 return this.gender == null ? null : this.gender.getValue(); 603 } 604 605 /** 606 * @param value Administrative Gender. 607 */ 608 public Person setGender(AdministrativeGender value) { 609 if (value == null) 610 this.gender = null; 611 else { 612 if (this.gender == null) 613 this.gender = new Enumeration<AdministrativeGender>(new AdministrativeGenderEnumFactory()); 614 this.gender.setValue(value); 615 } 616 return this; 617 } 618 619 /** 620 * @return {@link #birthDate} (The birth date for the person.). This is the underlying object with id, value and extensions. The accessor "getBirthDate" gives direct access to the value 621 */ 622 public DateType getBirthDateElement() { 623 if (this.birthDate == null) 624 if (Configuration.errorOnAutoCreate()) 625 throw new Error("Attempt to auto-create Person.birthDate"); 626 else if (Configuration.doAutoCreate()) 627 this.birthDate = new DateType(); // bb 628 return this.birthDate; 629 } 630 631 public boolean hasBirthDateElement() { 632 return this.birthDate != null && !this.birthDate.isEmpty(); 633 } 634 635 public boolean hasBirthDate() { 636 return this.birthDate != null && !this.birthDate.isEmpty(); 637 } 638 639 /** 640 * @param value {@link #birthDate} (The birth date for the person.). This is the underlying object with id, value and extensions. The accessor "getBirthDate" gives direct access to the value 641 */ 642 public Person setBirthDateElement(DateType value) { 643 this.birthDate = value; 644 return this; 645 } 646 647 /** 648 * @return The birth date for the person. 649 */ 650 public Date getBirthDate() { 651 return this.birthDate == null ? null : this.birthDate.getValue(); 652 } 653 654 /** 655 * @param value The birth date for the person. 656 */ 657 public Person setBirthDate(Date value) { 658 if (value == null) 659 this.birthDate = null; 660 else { 661 if (this.birthDate == null) 662 this.birthDate = new DateType(); 663 this.birthDate.setValue(value); 664 } 665 return this; 666 } 667 668 /** 669 * @return {@link #address} (One or more addresses for the person.) 670 */ 671 public List<Address> getAddress() { 672 if (this.address == null) 673 this.address = new ArrayList<Address>(); 674 return this.address; 675 } 676 677 public boolean hasAddress() { 678 if (this.address == null) 679 return false; 680 for (Address item : this.address) 681 if (!item.isEmpty()) 682 return true; 683 return false; 684 } 685 686 /** 687 * @return {@link #address} (One or more addresses for the person.) 688 */ 689 // syntactic sugar 690 public Address addAddress() { //3 691 Address t = new Address(); 692 if (this.address == null) 693 this.address = new ArrayList<Address>(); 694 this.address.add(t); 695 return t; 696 } 697 698 // syntactic sugar 699 public Person addAddress(Address t) { //3 700 if (t == null) 701 return this; 702 if (this.address == null) 703 this.address = new ArrayList<Address>(); 704 this.address.add(t); 705 return this; 706 } 707 708 /** 709 * @return {@link #photo} (An image that can be displayed as a thumbnail of the person to enhance the identification of the individual.) 710 */ 711 public Attachment getPhoto() { 712 if (this.photo == null) 713 if (Configuration.errorOnAutoCreate()) 714 throw new Error("Attempt to auto-create Person.photo"); 715 else if (Configuration.doAutoCreate()) 716 this.photo = new Attachment(); // cc 717 return this.photo; 718 } 719 720 public boolean hasPhoto() { 721 return this.photo != null && !this.photo.isEmpty(); 722 } 723 724 /** 725 * @param value {@link #photo} (An image that can be displayed as a thumbnail of the person to enhance the identification of the individual.) 726 */ 727 public Person setPhoto(Attachment value) { 728 this.photo = value; 729 return this; 730 } 731 732 /** 733 * @return {@link #managingOrganization} (The organization that is the custodian of the person record.) 734 */ 735 public Reference getManagingOrganization() { 736 if (this.managingOrganization == null) 737 if (Configuration.errorOnAutoCreate()) 738 throw new Error("Attempt to auto-create Person.managingOrganization"); 739 else if (Configuration.doAutoCreate()) 740 this.managingOrganization = new Reference(); // cc 741 return this.managingOrganization; 742 } 743 744 public boolean hasManagingOrganization() { 745 return this.managingOrganization != null && !this.managingOrganization.isEmpty(); 746 } 747 748 /** 749 * @param value {@link #managingOrganization} (The organization that is the custodian of the person record.) 750 */ 751 public Person setManagingOrganization(Reference value) { 752 this.managingOrganization = value; 753 return this; 754 } 755 756 /** 757 * @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. (The organization that is the custodian of the person record.) 758 */ 759 public Organization getManagingOrganizationTarget() { 760 if (this.managingOrganizationTarget == null) 761 if (Configuration.errorOnAutoCreate()) 762 throw new Error("Attempt to auto-create Person.managingOrganization"); 763 else if (Configuration.doAutoCreate()) 764 this.managingOrganizationTarget = new Organization(); // aa 765 return this.managingOrganizationTarget; 766 } 767 768 /** 769 * @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. (The organization that is the custodian of the person record.) 770 */ 771 public Person setManagingOrganizationTarget(Organization value) { 772 this.managingOrganizationTarget = value; 773 return this; 774 } 775 776 /** 777 * @return {@link #active} (Whether this person's record is in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value 778 */ 779 public BooleanType getActiveElement() { 780 if (this.active == null) 781 if (Configuration.errorOnAutoCreate()) 782 throw new Error("Attempt to auto-create Person.active"); 783 else if (Configuration.doAutoCreate()) 784 this.active = new BooleanType(); // bb 785 return this.active; 786 } 787 788 public boolean hasActiveElement() { 789 return this.active != null && !this.active.isEmpty(); 790 } 791 792 public boolean hasActive() { 793 return this.active != null && !this.active.isEmpty(); 794 } 795 796 /** 797 * @param value {@link #active} (Whether this person's record is in active use.). This is the underlying object with id, value and extensions. The accessor "getActive" gives direct access to the value 798 */ 799 public Person setActiveElement(BooleanType value) { 800 this.active = value; 801 return this; 802 } 803 804 /** 805 * @return Whether this person's record is in active use. 806 */ 807 public boolean getActive() { 808 return this.active == null || this.active.isEmpty() ? false : this.active.getValue(); 809 } 810 811 /** 812 * @param value Whether this person's record is in active use. 813 */ 814 public Person setActive(boolean value) { 815 if (this.active == null) 816 this.active = new BooleanType(); 817 this.active.setValue(value); 818 return this; 819 } 820 821 /** 822 * @return {@link #link} (Link to a resource that concerns the same actual person.) 823 */ 824 public List<PersonLinkComponent> getLink() { 825 if (this.link == null) 826 this.link = new ArrayList<PersonLinkComponent>(); 827 return this.link; 828 } 829 830 public boolean hasLink() { 831 if (this.link == null) 832 return false; 833 for (PersonLinkComponent item : this.link) 834 if (!item.isEmpty()) 835 return true; 836 return false; 837 } 838 839 /** 840 * @return {@link #link} (Link to a resource that concerns the same actual person.) 841 */ 842 // syntactic sugar 843 public PersonLinkComponent addLink() { //3 844 PersonLinkComponent t = new PersonLinkComponent(); 845 if (this.link == null) 846 this.link = new ArrayList<PersonLinkComponent>(); 847 this.link.add(t); 848 return t; 849 } 850 851 // syntactic sugar 852 public Person addLink(PersonLinkComponent t) { //3 853 if (t == null) 854 return this; 855 if (this.link == null) 856 this.link = new ArrayList<PersonLinkComponent>(); 857 this.link.add(t); 858 return this; 859 } 860 861 protected void listChildren(List<Property> childrenList) { 862 super.listChildren(childrenList); 863 childrenList.add(new Property("identifier", "Identifier", "Identifier for a person within a particular scope.", 0, java.lang.Integer.MAX_VALUE, identifier)); 864 childrenList.add(new Property("name", "HumanName", "A name associated with the person.", 0, java.lang.Integer.MAX_VALUE, name)); 865 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)); 866 childrenList.add(new Property("gender", "code", "Administrative Gender.", 0, java.lang.Integer.MAX_VALUE, gender)); 867 childrenList.add(new Property("birthDate", "date", "The birth date for the person.", 0, java.lang.Integer.MAX_VALUE, birthDate)); 868 childrenList.add(new Property("address", "Address", "One or more addresses for the person.", 0, java.lang.Integer.MAX_VALUE, address)); 869 childrenList.add(new Property("photo", "Attachment", "An image that can be displayed as a thumbnail of the person to enhance the identification of the individual.", 0, java.lang.Integer.MAX_VALUE, photo)); 870 childrenList.add(new Property("managingOrganization", "Reference(Organization)", "The organization that is the custodian of the person record.", 0, java.lang.Integer.MAX_VALUE, managingOrganization)); 871 childrenList.add(new Property("active", "boolean", "Whether this person's record is in active use.", 0, java.lang.Integer.MAX_VALUE, active)); 872 childrenList.add(new Property("link", "", "Link to a resource that concerns the same actual person.", 0, java.lang.Integer.MAX_VALUE, link)); 873 } 874 875 @Override 876 public void setProperty(String name, Base value) throws FHIRException { 877 if (name.equals("identifier")) 878 this.getIdentifier().add(castToIdentifier(value)); 879 else if (name.equals("name")) 880 this.getName().add(castToHumanName(value)); 881 else if (name.equals("telecom")) 882 this.getTelecom().add(castToContactPoint(value)); 883 else if (name.equals("gender")) 884 this.gender = new AdministrativeGenderEnumFactory().fromType(value); // Enumeration<AdministrativeGender> 885 else if (name.equals("birthDate")) 886 this.birthDate = castToDate(value); // DateType 887 else if (name.equals("address")) 888 this.getAddress().add(castToAddress(value)); 889 else if (name.equals("photo")) 890 this.photo = castToAttachment(value); // Attachment 891 else if (name.equals("managingOrganization")) 892 this.managingOrganization = castToReference(value); // Reference 893 else if (name.equals("active")) 894 this.active = castToBoolean(value); // BooleanType 895 else if (name.equals("link")) 896 this.getLink().add((PersonLinkComponent) value); 897 else 898 super.setProperty(name, value); 899 } 900 901 @Override 902 public Base addChild(String name) throws FHIRException { 903 if (name.equals("identifier")) { 904 return addIdentifier(); 905 } 906 else if (name.equals("name")) { 907 return addName(); 908 } 909 else if (name.equals("telecom")) { 910 return addTelecom(); 911 } 912 else if (name.equals("gender")) { 913 throw new FHIRException("Cannot call addChild on a primitive type Person.gender"); 914 } 915 else if (name.equals("birthDate")) { 916 throw new FHIRException("Cannot call addChild on a primitive type Person.birthDate"); 917 } 918 else if (name.equals("address")) { 919 return addAddress(); 920 } 921 else if (name.equals("photo")) { 922 this.photo = new Attachment(); 923 return this.photo; 924 } 925 else if (name.equals("managingOrganization")) { 926 this.managingOrganization = new Reference(); 927 return this.managingOrganization; 928 } 929 else if (name.equals("active")) { 930 throw new FHIRException("Cannot call addChild on a primitive type Person.active"); 931 } 932 else if (name.equals("link")) { 933 return addLink(); 934 } 935 else 936 return super.addChild(name); 937 } 938 939 public String fhirType() { 940 return "Person"; 941 942 } 943 944 public Person copy() { 945 Person dst = new Person(); 946 copyValues(dst); 947 if (identifier != null) { 948 dst.identifier = new ArrayList<Identifier>(); 949 for (Identifier i : identifier) 950 dst.identifier.add(i.copy()); 951 }; 952 if (name != null) { 953 dst.name = new ArrayList<HumanName>(); 954 for (HumanName i : name) 955 dst.name.add(i.copy()); 956 }; 957 if (telecom != null) { 958 dst.telecom = new ArrayList<ContactPoint>(); 959 for (ContactPoint i : telecom) 960 dst.telecom.add(i.copy()); 961 }; 962 dst.gender = gender == null ? null : gender.copy(); 963 dst.birthDate = birthDate == null ? null : birthDate.copy(); 964 if (address != null) { 965 dst.address = new ArrayList<Address>(); 966 for (Address i : address) 967 dst.address.add(i.copy()); 968 }; 969 dst.photo = photo == null ? null : photo.copy(); 970 dst.managingOrganization = managingOrganization == null ? null : managingOrganization.copy(); 971 dst.active = active == null ? null : active.copy(); 972 if (link != null) { 973 dst.link = new ArrayList<PersonLinkComponent>(); 974 for (PersonLinkComponent i : link) 975 dst.link.add(i.copy()); 976 }; 977 return dst; 978 } 979 980 protected Person typedCopy() { 981 return copy(); 982 } 983 984 @Override 985 public boolean equalsDeep(Base other) { 986 if (!super.equalsDeep(other)) 987 return false; 988 if (!(other instanceof Person)) 989 return false; 990 Person o = (Person) other; 991 return compareDeep(identifier, o.identifier, true) && compareDeep(name, o.name, true) && compareDeep(telecom, o.telecom, true) 992 && compareDeep(gender, o.gender, true) && compareDeep(birthDate, o.birthDate, true) && compareDeep(address, o.address, true) 993 && compareDeep(photo, o.photo, true) && compareDeep(managingOrganization, o.managingOrganization, true) 994 && compareDeep(active, o.active, true) && compareDeep(link, o.link, true); 995 } 996 997 @Override 998 public boolean equalsShallow(Base other) { 999 if (!super.equalsShallow(other)) 1000 return false; 1001 if (!(other instanceof Person)) 1002 return false; 1003 Person o = (Person) other; 1004 return compareValues(gender, o.gender, true) && compareValues(birthDate, o.birthDate, true) && compareValues(active, o.active, true) 1005 ; 1006 } 1007 1008 public boolean isEmpty() { 1009 return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (name == null || name.isEmpty()) 1010 && (telecom == null || telecom.isEmpty()) && (gender == null || gender.isEmpty()) && (birthDate == null || birthDate.isEmpty()) 1011 && (address == null || address.isEmpty()) && (photo == null || photo.isEmpty()) && (managingOrganization == null || managingOrganization.isEmpty()) 1012 && (active == null || active.isEmpty()) && (link == null || link.isEmpty()); 1013 } 1014 1015 @Override 1016 public ResourceType getResourceType() { 1017 return ResourceType.Person; 1018 } 1019 1020 @SearchParamDefinition(name="identifier", path="Person.identifier", description="A person Identifier", type="token" ) 1021 public static final String SP_IDENTIFIER = "identifier"; 1022 @SearchParamDefinition(name="address", path="Person.address", description="An address in any kind of address/part", type="string" ) 1023 public static final String SP_ADDRESS = "address"; 1024 @SearchParamDefinition(name="birthdate", path="Person.birthDate", description="The person's date of birth", type="date" ) 1025 public static final String SP_BIRTHDATE = "birthdate"; 1026 @SearchParamDefinition(name="address-state", path="Person.address.state", description="A state specified in an address", type="string" ) 1027 public static final String SP_ADDRESSSTATE = "address-state"; 1028 @SearchParamDefinition(name="gender", path="Person.gender", description="The gender of the person", type="token" ) 1029 public static final String SP_GENDER = "gender"; 1030 @SearchParamDefinition(name="practitioner", path="Person.link.target", description="The Person links to this Practitioner", type="reference" ) 1031 public static final String SP_PRACTITIONER = "practitioner"; 1032 @SearchParamDefinition(name="link", path="Person.link.target", description="Any link has this Patient, Person, RelatedPerson or Practitioner reference", type="reference" ) 1033 public static final String SP_LINK = "link"; 1034 @SearchParamDefinition(name="relatedperson", path="Person.link.target", description="The Person links to this RelatedPerson", type="reference" ) 1035 public static final String SP_RELATEDPERSON = "relatedperson"; 1036 @SearchParamDefinition(name="address-postalcode", path="Person.address.postalCode", description="A postal code specified in an address", type="string" ) 1037 public static final String SP_ADDRESSPOSTALCODE = "address-postalcode"; 1038 @SearchParamDefinition(name="address-country", path="Person.address.country", description="A country specified in an address", type="string" ) 1039 public static final String SP_ADDRESSCOUNTRY = "address-country"; 1040 @SearchParamDefinition(name="phonetic", path="Person.name", description="A portion of name using some kind of phonetic matching algorithm", type="string" ) 1041 public static final String SP_PHONETIC = "phonetic"; 1042 @SearchParamDefinition(name="phone", path="Person.telecom.where(system='phone')", description="A value in a phone contact", type="token" ) 1043 public static final String SP_PHONE = "phone"; 1044 @SearchParamDefinition(name="patient", path="Person.link.target", description="The Person links to this Patient", type="reference" ) 1045 public static final String SP_PATIENT = "patient"; 1046 @SearchParamDefinition(name="organization", path="Person.managingOrganization", description="The organization at which this person record is being managed", type="reference" ) 1047 public static final String SP_ORGANIZATION = "organization"; 1048 @SearchParamDefinition(name="name", path="Person.name", description="A portion of name in any name part", type="string" ) 1049 public static final String SP_NAME = "name"; 1050 @SearchParamDefinition(name="address-use", path="Person.address.use", description="A use code specified in an address", type="token" ) 1051 public static final String SP_ADDRESSUSE = "address-use"; 1052 @SearchParamDefinition(name="telecom", path="Person.telecom", description="The value in any kind of contact", type="token" ) 1053 public static final String SP_TELECOM = "telecom"; 1054 @SearchParamDefinition(name="address-city", path="Person.address.city", description="A city specified in an address", type="string" ) 1055 public static final String SP_ADDRESSCITY = "address-city"; 1056 @SearchParamDefinition(name="email", path="Person.telecom.where(system='email')", description="A value in an email contact", type="token" ) 1057 public static final String SP_EMAIL = "email"; 1058 1059}