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