001package org.hl7.fhir.instance.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 033import java.util.ArrayList; 034import java.util.List; 035 036import org.hl7.fhir.exceptions.FHIRException; 037import org.hl7.fhir.instance.model.api.ICompositeType; 038import org.hl7.fhir.utilities.Utilities; 039 040import ca.uhn.fhir.model.api.annotation.*; 041/** 042 * A human's name with the ability to identify parts and usage. 043 */ 044@DatatypeDef(name="HumanName") 045public class HumanName extends Type implements ICompositeType { 046 047 public enum NameUse { 048 /** 049 * Known as/conventional/the one you normally use 050 */ 051 USUAL, 052 /** 053 * The formal name as registered in an official (government) registry, but which name might not be commonly used. May be called "legal name". 054 */ 055 OFFICIAL, 056 /** 057 * A temporary name. Name.period can provide more detailed information. This may also be used for temporary names assigned at birth or in emergency situations. 058 */ 059 TEMP, 060 /** 061 * A name that is used to address the person in an informal manner, but is not part of their formal or usual name 062 */ 063 NICKNAME, 064 /** 065 * Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons) 066 */ 067 ANONYMOUS, 068 /** 069 * This name is no longer in use (or was never correct, but retained for records) 070 */ 071 OLD, 072 /** 073 * A name used prior to marriage. Marriage naming customs vary greatly around the world. This name use is for use by applications that collect and store "maiden" names. Though the concept of maiden name is often gender specific, the use of this term is not gender specific. The use of this term does not imply any particular history for a person's name, nor should the maiden name be determined algorithmically. 074 */ 075 MAIDEN, 076 /** 077 * added to help the parsers 078 */ 079 NULL; 080 public static NameUse fromCode(String codeString) throws FHIRException { 081 if (codeString == null || "".equals(codeString)) 082 return null; 083 if ("usual".equals(codeString)) 084 return USUAL; 085 if ("official".equals(codeString)) 086 return OFFICIAL; 087 if ("temp".equals(codeString)) 088 return TEMP; 089 if ("nickname".equals(codeString)) 090 return NICKNAME; 091 if ("anonymous".equals(codeString)) 092 return ANONYMOUS; 093 if ("old".equals(codeString)) 094 return OLD; 095 if ("maiden".equals(codeString)) 096 return MAIDEN; 097 throw new FHIRException("Unknown NameUse code '"+codeString+"'"); 098 } 099 public String toCode() { 100 switch (this) { 101 case USUAL: return "usual"; 102 case OFFICIAL: return "official"; 103 case TEMP: return "temp"; 104 case NICKNAME: return "nickname"; 105 case ANONYMOUS: return "anonymous"; 106 case OLD: return "old"; 107 case MAIDEN: return "maiden"; 108 default: return "?"; 109 } 110 } 111 public String getSystem() { 112 switch (this) { 113 case USUAL: return "http://hl7.org/fhir/name-use"; 114 case OFFICIAL: return "http://hl7.org/fhir/name-use"; 115 case TEMP: return "http://hl7.org/fhir/name-use"; 116 case NICKNAME: return "http://hl7.org/fhir/name-use"; 117 case ANONYMOUS: return "http://hl7.org/fhir/name-use"; 118 case OLD: return "http://hl7.org/fhir/name-use"; 119 case MAIDEN: return "http://hl7.org/fhir/name-use"; 120 default: return "?"; 121 } 122 } 123 public String getDefinition() { 124 switch (this) { 125 case USUAL: return "Known as/conventional/the one you normally use"; 126 case OFFICIAL: return "The formal name as registered in an official (government) registry, but which name might not be commonly used. May be called \"legal name\"."; 127 case TEMP: return "A temporary name. Name.period can provide more detailed information. This may also be used for temporary names assigned at birth or in emergency situations."; 128 case NICKNAME: return "A name that is used to address the person in an informal manner, but is not part of their formal or usual name"; 129 case ANONYMOUS: return "Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons)"; 130 case OLD: return "This name is no longer in use (or was never correct, but retained for records)"; 131 case MAIDEN: return "A name used prior to marriage. Marriage naming customs vary greatly around the world. This name use is for use by applications that collect and store \"maiden\" names. Though the concept of maiden name is often gender specific, the use of this term is not gender specific. The use of this term does not imply any particular history for a person's name, nor should the maiden name be determined algorithmically."; 132 default: return "?"; 133 } 134 } 135 public String getDisplay() { 136 switch (this) { 137 case USUAL: return "Usual"; 138 case OFFICIAL: return "Official"; 139 case TEMP: return "Temp"; 140 case NICKNAME: return "Nickname"; 141 case ANONYMOUS: return "Anonymous"; 142 case OLD: return "Old"; 143 case MAIDEN: return "Maiden"; 144 default: return "?"; 145 } 146 } 147 } 148 149 public static class NameUseEnumFactory implements EnumFactory<NameUse> { 150 public NameUse fromCode(String codeString) throws IllegalArgumentException { 151 if (codeString == null || "".equals(codeString)) 152 if (codeString == null || "".equals(codeString)) 153 return null; 154 if ("usual".equals(codeString)) 155 return NameUse.USUAL; 156 if ("official".equals(codeString)) 157 return NameUse.OFFICIAL; 158 if ("temp".equals(codeString)) 159 return NameUse.TEMP; 160 if ("nickname".equals(codeString)) 161 return NameUse.NICKNAME; 162 if ("anonymous".equals(codeString)) 163 return NameUse.ANONYMOUS; 164 if ("old".equals(codeString)) 165 return NameUse.OLD; 166 if ("maiden".equals(codeString)) 167 return NameUse.MAIDEN; 168 throw new IllegalArgumentException("Unknown NameUse code '"+codeString+"'"); 169 } 170 public Enumeration<NameUse> fromType(Base code) throws FHIRException { 171 if (code == null || code.isEmpty()) 172 return null; 173 String codeString = ((PrimitiveType) code).asStringValue(); 174 if (codeString == null || "".equals(codeString)) 175 return null; 176 if ("usual".equals(codeString)) 177 return new Enumeration<NameUse>(this, NameUse.USUAL); 178 if ("official".equals(codeString)) 179 return new Enumeration<NameUse>(this, NameUse.OFFICIAL); 180 if ("temp".equals(codeString)) 181 return new Enumeration<NameUse>(this, NameUse.TEMP); 182 if ("nickname".equals(codeString)) 183 return new Enumeration<NameUse>(this, NameUse.NICKNAME); 184 if ("anonymous".equals(codeString)) 185 return new Enumeration<NameUse>(this, NameUse.ANONYMOUS); 186 if ("old".equals(codeString)) 187 return new Enumeration<NameUse>(this, NameUse.OLD); 188 if ("maiden".equals(codeString)) 189 return new Enumeration<NameUse>(this, NameUse.MAIDEN); 190 throw new FHIRException("Unknown NameUse code '"+codeString+"'"); 191 } 192 public String toCode(NameUse code) { 193 if (code == NameUse.USUAL) 194 return "usual"; 195 if (code == NameUse.OFFICIAL) 196 return "official"; 197 if (code == NameUse.TEMP) 198 return "temp"; 199 if (code == NameUse.NICKNAME) 200 return "nickname"; 201 if (code == NameUse.ANONYMOUS) 202 return "anonymous"; 203 if (code == NameUse.OLD) 204 return "old"; 205 if (code == NameUse.MAIDEN) 206 return "maiden"; 207 return "?"; 208 } 209 } 210 211 /** 212 * Identifies the purpose for this name. 213 */ 214 @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true) 215 @Description(shortDefinition="usual | official | temp | nickname | anonymous | old | maiden", formalDefinition="Identifies the purpose for this name." ) 216 protected Enumeration<NameUse> use; 217 218 /** 219 * A full text representation of the name. 220 */ 221 @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true) 222 @Description(shortDefinition="Text representation of the full name", formalDefinition="A full text representation of the name." ) 223 protected StringType text; 224 225 /** 226 * The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father. 227 */ 228 @Child(name = "family", type = {StringType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 229 @Description(shortDefinition="Family name (often called 'Surname')", formalDefinition="The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father." ) 230 protected List<StringType> family; 231 232 /** 233 * Given name. 234 */ 235 @Child(name = "given", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 236 @Description(shortDefinition="Given names (not always 'first'). Includes middle names", formalDefinition="Given name." ) 237 protected List<StringType> given; 238 239 /** 240 * Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name. 241 */ 242 @Child(name = "prefix", type = {StringType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 243 @Description(shortDefinition="Parts that come before the name", formalDefinition="Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name." ) 244 protected List<StringType> prefix; 245 246 /** 247 * Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name. 248 */ 249 @Child(name = "suffix", type = {StringType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 250 @Description(shortDefinition="Parts that come after the name", formalDefinition="Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name." ) 251 protected List<StringType> suffix; 252 253 /** 254 * Indicates the period of time when this name was valid for the named person. 255 */ 256 @Child(name = "period", type = {Period.class}, order=6, min=0, max=1, modifier=false, summary=true) 257 @Description(shortDefinition="Time period when name was/is in use", formalDefinition="Indicates the period of time when this name was valid for the named person." ) 258 protected Period period; 259 260 private static final long serialVersionUID = -210174642L; 261 262 /* 263 * Constructor 264 */ 265 public HumanName() { 266 super(); 267 } 268 269 /** 270 * @return {@link #use} (Identifies the purpose for this name.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value 271 */ 272 public Enumeration<NameUse> getUseElement() { 273 if (this.use == null) 274 if (Configuration.errorOnAutoCreate()) 275 throw new Error("Attempt to auto-create HumanName.use"); 276 else if (Configuration.doAutoCreate()) 277 this.use = new Enumeration<NameUse>(new NameUseEnumFactory()); // bb 278 return this.use; 279 } 280 281 public boolean hasUseElement() { 282 return this.use != null && !this.use.isEmpty(); 283 } 284 285 public boolean hasUse() { 286 return this.use != null && !this.use.isEmpty(); 287 } 288 289 /** 290 * @param value {@link #use} (Identifies the purpose for this name.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value 291 */ 292 public HumanName setUseElement(Enumeration<NameUse> value) { 293 this.use = value; 294 return this; 295 } 296 297 /** 298 * @return Identifies the purpose for this name. 299 */ 300 public NameUse getUse() { 301 return this.use == null ? null : this.use.getValue(); 302 } 303 304 /** 305 * @param value Identifies the purpose for this name. 306 */ 307 public HumanName setUse(NameUse value) { 308 if (value == null) 309 this.use = null; 310 else { 311 if (this.use == null) 312 this.use = new Enumeration<NameUse>(new NameUseEnumFactory()); 313 this.use.setValue(value); 314 } 315 return this; 316 } 317 318 /** 319 * @return {@link #text} (A full text representation of the name.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 320 */ 321 public StringType getTextElement() { 322 if (this.text == null) 323 if (Configuration.errorOnAutoCreate()) 324 throw new Error("Attempt to auto-create HumanName.text"); 325 else if (Configuration.doAutoCreate()) 326 this.text = new StringType(); // bb 327 return this.text; 328 } 329 330 public boolean hasTextElement() { 331 return this.text != null && !this.text.isEmpty(); 332 } 333 334 public boolean hasText() { 335 return this.text != null && !this.text.isEmpty(); 336 } 337 338 /** 339 * @param value {@link #text} (A full text representation of the name.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 340 */ 341 public HumanName setTextElement(StringType value) { 342 this.text = value; 343 return this; 344 } 345 346 /** 347 * @return A full text representation of the name. 348 */ 349 public String getText() { 350 return this.text == null ? null : this.text.getValue(); 351 } 352 353 /** 354 * @param value A full text representation of the name. 355 */ 356 public HumanName setText(String value) { 357 if (Utilities.noString(value)) 358 this.text = null; 359 else { 360 if (this.text == null) 361 this.text = new StringType(); 362 this.text.setValue(value); 363 } 364 return this; 365 } 366 367 /** 368 * @return {@link #family} (The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.) 369 */ 370 public List<StringType> getFamily() { 371 if (this.family == null) 372 this.family = new ArrayList<StringType>(); 373 return this.family; 374 } 375 376 public boolean hasFamily() { 377 if (this.family == null) 378 return false; 379 for (StringType item : this.family) 380 if (!item.isEmpty()) 381 return true; 382 return false; 383 } 384 385 /** 386 * @return {@link #family} (The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.) 387 */ 388 // syntactic sugar 389 public StringType addFamilyElement() {//2 390 StringType t = new StringType(); 391 if (this.family == null) 392 this.family = new ArrayList<StringType>(); 393 this.family.add(t); 394 return t; 395 } 396 397 /** 398 * @param value {@link #family} (The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.) 399 */ 400 public HumanName addFamily(String value) { //1 401 StringType t = new StringType(); 402 t.setValue(value); 403 if (this.family == null) 404 this.family = new ArrayList<StringType>(); 405 this.family.add(t); 406 return this; 407 } 408 409 /** 410 * @param value {@link #family} (The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.) 411 */ 412 public boolean hasFamily(String value) { 413 if (this.family == null) 414 return false; 415 for (StringType v : this.family) 416 if (v.equals(value)) // string 417 return true; 418 return false; 419 } 420 421 /** 422 * @return {@link #given} (Given name.) 423 */ 424 public List<StringType> getGiven() { 425 if (this.given == null) 426 this.given = new ArrayList<StringType>(); 427 return this.given; 428 } 429 430 public boolean hasGiven() { 431 if (this.given == null) 432 return false; 433 for (StringType item : this.given) 434 if (!item.isEmpty()) 435 return true; 436 return false; 437 } 438 439 /** 440 * @return {@link #given} (Given name.) 441 */ 442 // syntactic sugar 443 public StringType addGivenElement() {//2 444 StringType t = new StringType(); 445 if (this.given == null) 446 this.given = new ArrayList<StringType>(); 447 this.given.add(t); 448 return t; 449 } 450 451 /** 452 * @param value {@link #given} (Given name.) 453 */ 454 public HumanName addGiven(String value) { //1 455 StringType t = new StringType(); 456 t.setValue(value); 457 if (this.given == null) 458 this.given = new ArrayList<StringType>(); 459 this.given.add(t); 460 return this; 461 } 462 463 /** 464 * @param value {@link #given} (Given name.) 465 */ 466 public boolean hasGiven(String value) { 467 if (this.given == null) 468 return false; 469 for (StringType v : this.given) 470 if (v.equals(value)) // string 471 return true; 472 return false; 473 } 474 475 /** 476 * @return {@link #prefix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.) 477 */ 478 public List<StringType> getPrefix() { 479 if (this.prefix == null) 480 this.prefix = new ArrayList<StringType>(); 481 return this.prefix; 482 } 483 484 public boolean hasPrefix() { 485 if (this.prefix == null) 486 return false; 487 for (StringType item : this.prefix) 488 if (!item.isEmpty()) 489 return true; 490 return false; 491 } 492 493 /** 494 * @return {@link #prefix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.) 495 */ 496 // syntactic sugar 497 public StringType addPrefixElement() {//2 498 StringType t = new StringType(); 499 if (this.prefix == null) 500 this.prefix = new ArrayList<StringType>(); 501 this.prefix.add(t); 502 return t; 503 } 504 505 /** 506 * @param value {@link #prefix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.) 507 */ 508 public HumanName addPrefix(String value) { //1 509 StringType t = new StringType(); 510 t.setValue(value); 511 if (this.prefix == null) 512 this.prefix = new ArrayList<StringType>(); 513 this.prefix.add(t); 514 return this; 515 } 516 517 /** 518 * @param value {@link #prefix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.) 519 */ 520 public boolean hasPrefix(String value) { 521 if (this.prefix == null) 522 return false; 523 for (StringType v : this.prefix) 524 if (v.equals(value)) // string 525 return true; 526 return false; 527 } 528 529 /** 530 * @return {@link #suffix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.) 531 */ 532 public List<StringType> getSuffix() { 533 if (this.suffix == null) 534 this.suffix = new ArrayList<StringType>(); 535 return this.suffix; 536 } 537 538 public boolean hasSuffix() { 539 if (this.suffix == null) 540 return false; 541 for (StringType item : this.suffix) 542 if (!item.isEmpty()) 543 return true; 544 return false; 545 } 546 547 /** 548 * @return {@link #suffix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.) 549 */ 550 // syntactic sugar 551 public StringType addSuffixElement() {//2 552 StringType t = new StringType(); 553 if (this.suffix == null) 554 this.suffix = new ArrayList<StringType>(); 555 this.suffix.add(t); 556 return t; 557 } 558 559 /** 560 * @param value {@link #suffix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.) 561 */ 562 public HumanName addSuffix(String value) { //1 563 StringType t = new StringType(); 564 t.setValue(value); 565 if (this.suffix == null) 566 this.suffix = new ArrayList<StringType>(); 567 this.suffix.add(t); 568 return this; 569 } 570 571 /** 572 * @param value {@link #suffix} (Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.) 573 */ 574 public boolean hasSuffix(String value) { 575 if (this.suffix == null) 576 return false; 577 for (StringType v : this.suffix) 578 if (v.equals(value)) // string 579 return true; 580 return false; 581 } 582 583 /** 584 * @return {@link #period} (Indicates the period of time when this name was valid for the named person.) 585 */ 586 public Period getPeriod() { 587 if (this.period == null) 588 if (Configuration.errorOnAutoCreate()) 589 throw new Error("Attempt to auto-create HumanName.period"); 590 else if (Configuration.doAutoCreate()) 591 this.period = new Period(); // cc 592 return this.period; 593 } 594 595 public boolean hasPeriod() { 596 return this.period != null && !this.period.isEmpty(); 597 } 598 599 /** 600 * @param value {@link #period} (Indicates the period of time when this name was valid for the named person.) 601 */ 602 public HumanName setPeriod(Period value) { 603 this.period = value; 604 return this; 605 } 606 607 protected void listChildren(List<Property> childrenList) { 608 super.listChildren(childrenList); 609 childrenList.add(new Property("use", "code", "Identifies the purpose for this name.", 0, java.lang.Integer.MAX_VALUE, use)); 610 childrenList.add(new Property("text", "string", "A full text representation of the name.", 0, java.lang.Integer.MAX_VALUE, text)); 611 childrenList.add(new Property("family", "string", "The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.", 0, java.lang.Integer.MAX_VALUE, family)); 612 childrenList.add(new Property("given", "string", "Given name.", 0, java.lang.Integer.MAX_VALUE, given)); 613 childrenList.add(new Property("prefix", "string", "Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.", 0, java.lang.Integer.MAX_VALUE, prefix)); 614 childrenList.add(new Property("suffix", "string", "Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.", 0, java.lang.Integer.MAX_VALUE, suffix)); 615 childrenList.add(new Property("period", "Period", "Indicates the period of time when this name was valid for the named person.", 0, java.lang.Integer.MAX_VALUE, period)); 616 } 617 618 @Override 619 public void setProperty(String name, Base value) throws FHIRException { 620 if (name.equals("use")) 621 this.use = new NameUseEnumFactory().fromType(value); // Enumeration<NameUse> 622 else if (name.equals("text")) 623 this.text = castToString(value); // StringType 624 else if (name.equals("family")) 625 this.getFamily().add(castToString(value)); 626 else if (name.equals("given")) 627 this.getGiven().add(castToString(value)); 628 else if (name.equals("prefix")) 629 this.getPrefix().add(castToString(value)); 630 else if (name.equals("suffix")) 631 this.getSuffix().add(castToString(value)); 632 else if (name.equals("period")) 633 this.period = castToPeriod(value); // Period 634 else 635 super.setProperty(name, value); 636 } 637 638 @Override 639 public Base addChild(String name) throws FHIRException { 640 if (name.equals("use")) { 641 throw new FHIRException("Cannot call addChild on a primitive type HumanName.use"); 642 } 643 else if (name.equals("text")) { 644 throw new FHIRException("Cannot call addChild on a primitive type HumanName.text"); 645 } 646 else if (name.equals("family")) { 647 throw new FHIRException("Cannot call addChild on a primitive type HumanName.family"); 648 } 649 else if (name.equals("given")) { 650 throw new FHIRException("Cannot call addChild on a primitive type HumanName.given"); 651 } 652 else if (name.equals("prefix")) { 653 throw new FHIRException("Cannot call addChild on a primitive type HumanName.prefix"); 654 } 655 else if (name.equals("suffix")) { 656 throw new FHIRException("Cannot call addChild on a primitive type HumanName.suffix"); 657 } 658 else if (name.equals("period")) { 659 this.period = new Period(); 660 return this.period; 661 } 662 else 663 return super.addChild(name); 664 } 665 666 public String fhirType() { 667 return "HumanName"; 668 669 } 670 671 public HumanName copy() { 672 HumanName dst = new HumanName(); 673 copyValues(dst); 674 dst.use = use == null ? null : use.copy(); 675 dst.text = text == null ? null : text.copy(); 676 if (family != null) { 677 dst.family = new ArrayList<StringType>(); 678 for (StringType i : family) 679 dst.family.add(i.copy()); 680 }; 681 if (given != null) { 682 dst.given = new ArrayList<StringType>(); 683 for (StringType i : given) 684 dst.given.add(i.copy()); 685 }; 686 if (prefix != null) { 687 dst.prefix = new ArrayList<StringType>(); 688 for (StringType i : prefix) 689 dst.prefix.add(i.copy()); 690 }; 691 if (suffix != null) { 692 dst.suffix = new ArrayList<StringType>(); 693 for (StringType i : suffix) 694 dst.suffix.add(i.copy()); 695 }; 696 dst.period = period == null ? null : period.copy(); 697 return dst; 698 } 699 700 protected HumanName typedCopy() { 701 return copy(); 702 } 703 704 @Override 705 public boolean equalsDeep(Base other) { 706 if (!super.equalsDeep(other)) 707 return false; 708 if (!(other instanceof HumanName)) 709 return false; 710 HumanName o = (HumanName) other; 711 return compareDeep(use, o.use, true) && compareDeep(text, o.text, true) && compareDeep(family, o.family, true) 712 && compareDeep(given, o.given, true) && compareDeep(prefix, o.prefix, true) && compareDeep(suffix, o.suffix, true) 713 && compareDeep(period, o.period, true); 714 } 715 716 @Override 717 public boolean equalsShallow(Base other) { 718 if (!super.equalsShallow(other)) 719 return false; 720 if (!(other instanceof HumanName)) 721 return false; 722 HumanName o = (HumanName) other; 723 return compareValues(use, o.use, true) && compareValues(text, o.text, true) && compareValues(family, o.family, true) 724 && compareValues(given, o.given, true) && compareValues(prefix, o.prefix, true) && compareValues(suffix, o.suffix, true) 725 ; 726 } 727 728 public boolean isEmpty() { 729 return super.isEmpty() && (use == null || use.isEmpty()) && (text == null || text.isEmpty()) 730 && (family == null || family.isEmpty()) && (given == null || given.isEmpty()) && (prefix == null || prefix.isEmpty()) 731 && (suffix == null || suffix.isEmpty()) && (period == null || period.isEmpty()); 732 } 733 734 735} 736