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