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