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.List; 038 039import ca.uhn.fhir.model.api.annotation.Child; 040import ca.uhn.fhir.model.api.annotation.DatatypeDef; 041import ca.uhn.fhir.model.api.annotation.Description; 042import org.hl7.fhir.instance.model.api.ICompositeType; 043import org.hl7.fhir.exceptions.FHIRException; 044import org.hl7.fhir.utilities.Utilities; 045/** 046 * A human's name with the ability to identify parts and usage. 047 */ 048@DatatypeDef(name="HumanName") 049public class HumanName extends Type implements ICompositeType { 050 051 public enum NameUse { 052 /** 053 * Known as/conventional/the one you normally use 054 */ 055 USUAL, 056 /** 057 * The formal name as registered in an official (government) registry, but which name might not be commonly used. May be called "legal name". 058 */ 059 OFFICIAL, 060 /** 061 * 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. 062 */ 063 TEMP, 064 /** 065 * A name that is used to address the person in an informal manner, but is not part of their formal or usual name 066 */ 067 NICKNAME, 068 /** 069 * Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons) 070 */ 071 ANONYMOUS, 072 /** 073 * This name is no longer in use (or was never correct, but retained for records) 074 */ 075 OLD, 076 /** 077 * 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. 078 */ 079 MAIDEN, 080 /** 081 * added to help the parsers 082 */ 083 NULL; 084 public static NameUse fromCode(String codeString) throws FHIRException { 085 if (codeString == null || "".equals(codeString)) 086 return null; 087 if ("usual".equals(codeString)) 088 return USUAL; 089 if ("official".equals(codeString)) 090 return OFFICIAL; 091 if ("temp".equals(codeString)) 092 return TEMP; 093 if ("nickname".equals(codeString)) 094 return NICKNAME; 095 if ("anonymous".equals(codeString)) 096 return ANONYMOUS; 097 if ("old".equals(codeString)) 098 return OLD; 099 if ("maiden".equals(codeString)) 100 return MAIDEN; 101 throw new FHIRException("Unknown NameUse code '"+codeString+"'"); 102 } 103 public String toCode() { 104 switch (this) { 105 case USUAL: return "usual"; 106 case OFFICIAL: return "official"; 107 case TEMP: return "temp"; 108 case NICKNAME: return "nickname"; 109 case ANONYMOUS: return "anonymous"; 110 case OLD: return "old"; 111 case MAIDEN: return "maiden"; 112 default: return "?"; 113 } 114 } 115 public String getSystem() { 116 switch (this) { 117 case USUAL: return "http://hl7.org/fhir/name-use"; 118 case OFFICIAL: return "http://hl7.org/fhir/name-use"; 119 case TEMP: return "http://hl7.org/fhir/name-use"; 120 case NICKNAME: return "http://hl7.org/fhir/name-use"; 121 case ANONYMOUS: return "http://hl7.org/fhir/name-use"; 122 case OLD: return "http://hl7.org/fhir/name-use"; 123 case MAIDEN: return "http://hl7.org/fhir/name-use"; 124 default: return "?"; 125 } 126 } 127 public String getDefinition() { 128 switch (this) { 129 case USUAL: return "Known as/conventional/the one you normally use"; 130 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\"."; 131 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."; 132 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"; 133 case ANONYMOUS: return "Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons)"; 134 case OLD: return "This name is no longer in use (or was never correct, but retained for records)"; 135 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."; 136 default: return "?"; 137 } 138 } 139 public String getDisplay() { 140 switch (this) { 141 case USUAL: return "Usual"; 142 case OFFICIAL: return "Official"; 143 case TEMP: return "Temp"; 144 case NICKNAME: return "Nickname"; 145 case ANONYMOUS: return "Anonymous"; 146 case OLD: return "Old"; 147 case MAIDEN: return "Maiden"; 148 default: return "?"; 149 } 150 } 151 } 152 153 public static class NameUseEnumFactory implements EnumFactory<NameUse> { 154 public NameUse fromCode(String codeString) throws IllegalArgumentException { 155 if (codeString == null || "".equals(codeString)) 156 if (codeString == null || "".equals(codeString)) 157 return null; 158 if ("usual".equals(codeString)) 159 return NameUse.USUAL; 160 if ("official".equals(codeString)) 161 return NameUse.OFFICIAL; 162 if ("temp".equals(codeString)) 163 return NameUse.TEMP; 164 if ("nickname".equals(codeString)) 165 return NameUse.NICKNAME; 166 if ("anonymous".equals(codeString)) 167 return NameUse.ANONYMOUS; 168 if ("old".equals(codeString)) 169 return NameUse.OLD; 170 if ("maiden".equals(codeString)) 171 return NameUse.MAIDEN; 172 throw new IllegalArgumentException("Unknown NameUse code '"+codeString+"'"); 173 } 174 public Enumeration<NameUse> fromType(Base code) throws FHIRException { 175 if (code == null || code.isEmpty()) 176 return null; 177 String codeString = ((PrimitiveType) code).asStringValue(); 178 if (codeString == null || "".equals(codeString)) 179 return null; 180 if ("usual".equals(codeString)) 181 return new Enumeration<NameUse>(this, NameUse.USUAL); 182 if ("official".equals(codeString)) 183 return new Enumeration<NameUse>(this, NameUse.OFFICIAL); 184 if ("temp".equals(codeString)) 185 return new Enumeration<NameUse>(this, NameUse.TEMP); 186 if ("nickname".equals(codeString)) 187 return new Enumeration<NameUse>(this, NameUse.NICKNAME); 188 if ("anonymous".equals(codeString)) 189 return new Enumeration<NameUse>(this, NameUse.ANONYMOUS); 190 if ("old".equals(codeString)) 191 return new Enumeration<NameUse>(this, NameUse.OLD); 192 if ("maiden".equals(codeString)) 193 return new Enumeration<NameUse>(this, NameUse.MAIDEN); 194 throw new FHIRException("Unknown NameUse code '"+codeString+"'"); 195 } 196 public String toCode(NameUse code) { 197 if (code == NameUse.USUAL) 198 return "usual"; 199 if (code == NameUse.OFFICIAL) 200 return "official"; 201 if (code == NameUse.TEMP) 202 return "temp"; 203 if (code == NameUse.NICKNAME) 204 return "nickname"; 205 if (code == NameUse.ANONYMOUS) 206 return "anonymous"; 207 if (code == NameUse.OLD) 208 return "old"; 209 if (code == NameUse.MAIDEN) 210 return "maiden"; 211 return "?"; 212 } 213 } 214 215 /** 216 * Identifies the purpose for this name. 217 */ 218 @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true) 219 @Description(shortDefinition="usual | official | temp | nickname | anonymous | old | maiden", formalDefinition="Identifies the purpose for this name." ) 220 protected Enumeration<NameUse> use; 221 222 /** 223 * A full text representation of the name. 224 */ 225 @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true) 226 @Description(shortDefinition="Text representation of the full name", formalDefinition="A full text representation of the name." ) 227 protected StringType text; 228 229 /** 230 * 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. 231 */ 232 @Child(name = "family", type = {StringType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 233 @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." ) 234 protected List<StringType> family; 235 236 /** 237 * Given name. 238 */ 239 @Child(name = "given", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 240 @Description(shortDefinition="Given names (not always 'first'). Includes middle names", formalDefinition="Given name." ) 241 protected List<StringType> given; 242 243 /** 244 * 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. 245 */ 246 @Child(name = "prefix", type = {StringType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 247 @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." ) 248 protected List<StringType> prefix; 249 250 /** 251 * 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. 252 */ 253 @Child(name = "suffix", type = {StringType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 254 @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." ) 255 protected List<StringType> suffix; 256 257 /** 258 * Indicates the period of time when this name was valid for the named person. 259 */ 260 @Child(name = "period", type = {Period.class}, order=6, min=0, max=1, modifier=false, summary=true) 261 @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." ) 262 protected Period period; 263 264 private static final long serialVersionUID = -210174642L; 265 266 /* 267 * Constructor 268 */ 269 public HumanName() { 270 super(); 271 } 272 273 /** 274 * @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 275 */ 276 public Enumeration<NameUse> getUseElement() { 277 if (this.use == null) 278 if (Configuration.errorOnAutoCreate()) 279 throw new Error("Attempt to auto-create HumanName.use"); 280 else if (Configuration.doAutoCreate()) 281 this.use = new Enumeration<NameUse>(new NameUseEnumFactory()); // bb 282 return this.use; 283 } 284 285 public boolean hasUseElement() { 286 return this.use != null && !this.use.isEmpty(); 287 } 288 289 public boolean hasUse() { 290 return this.use != null && !this.use.isEmpty(); 291 } 292 293 /** 294 * @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 295 */ 296 public HumanName setUseElement(Enumeration<NameUse> value) { 297 this.use = value; 298 return this; 299 } 300 301 /** 302 * @return Identifies the purpose for this name. 303 */ 304 public NameUse getUse() { 305 return this.use == null ? null : this.use.getValue(); 306 } 307 308 /** 309 * @param value Identifies the purpose for this name. 310 */ 311 public HumanName setUse(NameUse value) { 312 if (value == null) 313 this.use = null; 314 else { 315 if (this.use == null) 316 this.use = new Enumeration<NameUse>(new NameUseEnumFactory()); 317 this.use.setValue(value); 318 } 319 return this; 320 } 321 322 /** 323 * @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 324 */ 325 public StringType getTextElement() { 326 if (this.text == null) 327 if (Configuration.errorOnAutoCreate()) 328 throw new Error("Attempt to auto-create HumanName.text"); 329 else if (Configuration.doAutoCreate()) 330 this.text = new StringType(); // bb 331 return this.text; 332 } 333 334 public boolean hasTextElement() { 335 return this.text != null && !this.text.isEmpty(); 336 } 337 338 public boolean hasText() { 339 return this.text != null && !this.text.isEmpty(); 340 } 341 342 /** 343 * @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 344 */ 345 public HumanName setTextElement(StringType value) { 346 this.text = value; 347 return this; 348 } 349 350 /** 351 * @return A full text representation of the name. 352 */ 353 public String getText() { 354 return this.text == null ? null : this.text.getValue(); 355 } 356 357 /** 358 * @param value A full text representation of the name. 359 */ 360 public HumanName setText(String value) { 361 if (Utilities.noString(value)) 362 this.text = null; 363 else { 364 if (this.text == null) 365 this.text = new StringType(); 366 this.text.setValue(value); 367 } 368 return this; 369 } 370 371 /** 372 * @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.) 373 */ 374 public List<StringType> getFamily() { 375 if (this.family == null) 376 this.family = new ArrayList<StringType>(); 377 return this.family; 378 } 379 380 public boolean hasFamily() { 381 if (this.family == null) 382 return false; 383 for (StringType item : this.family) 384 if (!item.isEmpty()) 385 return true; 386 return false; 387 } 388 389 /** 390 * @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.) 391 */ 392 // syntactic sugar 393 public StringType addFamilyElement() {//2 394 StringType t = new StringType(); 395 if (this.family == null) 396 this.family = new ArrayList<StringType>(); 397 this.family.add(t); 398 return t; 399 } 400 401 /** 402 * @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.) 403 */ 404 public HumanName addFamily(String value) { //1 405 StringType t = new StringType(); 406 t.setValue(value); 407 if (this.family == null) 408 this.family = new ArrayList<StringType>(); 409 this.family.add(t); 410 return this; 411 } 412 413 /** 414 * @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.) 415 */ 416 public boolean hasFamily(String value) { 417 if (this.family == null) 418 return false; 419 for (StringType v : this.family) 420 if (v.equals(value)) // string 421 return true; 422 return false; 423 } 424 425 /** 426 * @return {@link #given} (Given name.) 427 */ 428 public List<StringType> getGiven() { 429 if (this.given == null) 430 this.given = new ArrayList<StringType>(); 431 return this.given; 432 } 433 434 public boolean hasGiven() { 435 if (this.given == null) 436 return false; 437 for (StringType item : this.given) 438 if (!item.isEmpty()) 439 return true; 440 return false; 441 } 442 443 /** 444 * @return {@link #given} (Given name.) 445 */ 446 // syntactic sugar 447 public StringType addGivenElement() {//2 448 StringType t = new StringType(); 449 if (this.given == null) 450 this.given = new ArrayList<StringType>(); 451 this.given.add(t); 452 return t; 453 } 454 455 /** 456 * @param value {@link #given} (Given name.) 457 */ 458 public HumanName addGiven(String value) { //1 459 StringType t = new StringType(); 460 t.setValue(value); 461 if (this.given == null) 462 this.given = new ArrayList<StringType>(); 463 this.given.add(t); 464 return this; 465 } 466 467 /** 468 * @param value {@link #given} (Given name.) 469 */ 470 public boolean hasGiven(String value) { 471 if (this.given == null) 472 return false; 473 for (StringType v : this.given) 474 if (v.equals(value)) // string 475 return true; 476 return false; 477 } 478 479 /** 480 * @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.) 481 */ 482 public List<StringType> getPrefix() { 483 if (this.prefix == null) 484 this.prefix = new ArrayList<StringType>(); 485 return this.prefix; 486 } 487 488 public boolean hasPrefix() { 489 if (this.prefix == null) 490 return false; 491 for (StringType item : this.prefix) 492 if (!item.isEmpty()) 493 return true; 494 return false; 495 } 496 497 /** 498 * @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.) 499 */ 500 // syntactic sugar 501 public StringType addPrefixElement() {//2 502 StringType t = new StringType(); 503 if (this.prefix == null) 504 this.prefix = new ArrayList<StringType>(); 505 this.prefix.add(t); 506 return t; 507 } 508 509 /** 510 * @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.) 511 */ 512 public HumanName addPrefix(String value) { //1 513 StringType t = new StringType(); 514 t.setValue(value); 515 if (this.prefix == null) 516 this.prefix = new ArrayList<StringType>(); 517 this.prefix.add(t); 518 return this; 519 } 520 521 /** 522 * @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.) 523 */ 524 public boolean hasPrefix(String value) { 525 if (this.prefix == null) 526 return false; 527 for (StringType v : this.prefix) 528 if (v.equals(value)) // string 529 return true; 530 return false; 531 } 532 533 /** 534 * @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.) 535 */ 536 public List<StringType> getSuffix() { 537 if (this.suffix == null) 538 this.suffix = new ArrayList<StringType>(); 539 return this.suffix; 540 } 541 542 public boolean hasSuffix() { 543 if (this.suffix == null) 544 return false; 545 for (StringType item : this.suffix) 546 if (!item.isEmpty()) 547 return true; 548 return false; 549 } 550 551 /** 552 * @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.) 553 */ 554 // syntactic sugar 555 public StringType addSuffixElement() {//2 556 StringType t = new StringType(); 557 if (this.suffix == null) 558 this.suffix = new ArrayList<StringType>(); 559 this.suffix.add(t); 560 return t; 561 } 562 563 /** 564 * @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.) 565 */ 566 public HumanName addSuffix(String value) { //1 567 StringType t = new StringType(); 568 t.setValue(value); 569 if (this.suffix == null) 570 this.suffix = new ArrayList<StringType>(); 571 this.suffix.add(t); 572 return this; 573 } 574 575 /** 576 * @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.) 577 */ 578 public boolean hasSuffix(String value) { 579 if (this.suffix == null) 580 return false; 581 for (StringType v : this.suffix) 582 if (v.equals(value)) // string 583 return true; 584 return false; 585 } 586 587 /** 588 * @return {@link #period} (Indicates the period of time when this name was valid for the named person.) 589 */ 590 public Period getPeriod() { 591 if (this.period == null) 592 if (Configuration.errorOnAutoCreate()) 593 throw new Error("Attempt to auto-create HumanName.period"); 594 else if (Configuration.doAutoCreate()) 595 this.period = new Period(); // cc 596 return this.period; 597 } 598 599 public boolean hasPeriod() { 600 return this.period != null && !this.period.isEmpty(); 601 } 602 603 /** 604 * @param value {@link #period} (Indicates the period of time when this name was valid for the named person.) 605 */ 606 public HumanName setPeriod(Period value) { 607 this.period = value; 608 return this; 609 } 610 611 protected void listChildren(List<Property> childrenList) { 612 super.listChildren(childrenList); 613 childrenList.add(new Property("use", "code", "Identifies the purpose for this name.", 0, java.lang.Integer.MAX_VALUE, use)); 614 childrenList.add(new Property("text", "string", "A full text representation of the name.", 0, java.lang.Integer.MAX_VALUE, text)); 615 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)); 616 childrenList.add(new Property("given", "string", "Given name.", 0, java.lang.Integer.MAX_VALUE, given)); 617 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)); 618 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)); 619 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)); 620 } 621 622 @Override 623 public void setProperty(String name, Base value) throws FHIRException { 624 if (name.equals("use")) 625 this.use = new NameUseEnumFactory().fromType(value); // Enumeration<NameUse> 626 else if (name.equals("text")) 627 this.text = castToString(value); // StringType 628 else if (name.equals("family")) 629 this.getFamily().add(castToString(value)); 630 else if (name.equals("given")) 631 this.getGiven().add(castToString(value)); 632 else if (name.equals("prefix")) 633 this.getPrefix().add(castToString(value)); 634 else if (name.equals("suffix")) 635 this.getSuffix().add(castToString(value)); 636 else if (name.equals("period")) 637 this.period = castToPeriod(value); // Period 638 else 639 super.setProperty(name, value); 640 } 641 642 @Override 643 public Base addChild(String name) throws FHIRException { 644 if (name.equals("use")) { 645 throw new FHIRException("Cannot call addChild on a primitive type HumanName.use"); 646 } 647 else if (name.equals("text")) { 648 throw new FHIRException("Cannot call addChild on a primitive type HumanName.text"); 649 } 650 else if (name.equals("family")) { 651 throw new FHIRException("Cannot call addChild on a primitive type HumanName.family"); 652 } 653 else if (name.equals("given")) { 654 throw new FHIRException("Cannot call addChild on a primitive type HumanName.given"); 655 } 656 else if (name.equals("prefix")) { 657 throw new FHIRException("Cannot call addChild on a primitive type HumanName.prefix"); 658 } 659 else if (name.equals("suffix")) { 660 throw new FHIRException("Cannot call addChild on a primitive type HumanName.suffix"); 661 } 662 else if (name.equals("period")) { 663 this.period = new Period(); 664 return this.period; 665 } 666 else 667 return super.addChild(name); 668 } 669 670 public String fhirType() { 671 return "HumanName"; 672 673 } 674 675 public HumanName copy() { 676 HumanName dst = new HumanName(); 677 copyValues(dst); 678 dst.use = use == null ? null : use.copy(); 679 dst.text = text == null ? null : text.copy(); 680 if (family != null) { 681 dst.family = new ArrayList<StringType>(); 682 for (StringType i : family) 683 dst.family.add(i.copy()); 684 }; 685 if (given != null) { 686 dst.given = new ArrayList<StringType>(); 687 for (StringType i : given) 688 dst.given.add(i.copy()); 689 }; 690 if (prefix != null) { 691 dst.prefix = new ArrayList<StringType>(); 692 for (StringType i : prefix) 693 dst.prefix.add(i.copy()); 694 }; 695 if (suffix != null) { 696 dst.suffix = new ArrayList<StringType>(); 697 for (StringType i : suffix) 698 dst.suffix.add(i.copy()); 699 }; 700 dst.period = period == null ? null : period.copy(); 701 return dst; 702 } 703 704 protected HumanName typedCopy() { 705 return copy(); 706 } 707 708 @Override 709 public boolean equalsDeep(Base other) { 710 if (!super.equalsDeep(other)) 711 return false; 712 if (!(other instanceof HumanName)) 713 return false; 714 HumanName o = (HumanName) other; 715 return compareDeep(use, o.use, true) && compareDeep(text, o.text, true) && compareDeep(family, o.family, true) 716 && compareDeep(given, o.given, true) && compareDeep(prefix, o.prefix, true) && compareDeep(suffix, o.suffix, true) 717 && compareDeep(period, o.period, true); 718 } 719 720 @Override 721 public boolean equalsShallow(Base other) { 722 if (!super.equalsShallow(other)) 723 return false; 724 if (!(other instanceof HumanName)) 725 return false; 726 HumanName o = (HumanName) other; 727 return compareValues(use, o.use, true) && compareValues(text, o.text, true) && compareValues(family, o.family, true) 728 && compareValues(given, o.given, true) && compareValues(prefix, o.prefix, true) && compareValues(suffix, o.suffix, true) 729 ; 730 } 731 732 public boolean isEmpty() { 733 return super.isEmpty() && (use == null || use.isEmpty()) && (text == null || text.isEmpty()) 734 && (family == null || family.isEmpty()) && (given == null || given.isEmpty()) && (prefix == null || prefix.isEmpty()) 735 && (suffix == null || suffix.isEmpty()) && (period == null || period.isEmpty()); 736 } 737 738 739}