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