001package org.hl7.fhir.r4.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.r4 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 Copyright (c) 2011+, HL7, Inc. 025 All rights reserved. 026 027 Redistribution and use in source and binary forms, with or without modification, 028 are permitted provided that the following conditions are met: 029 030 * Redistributions of source code must retain the above copyright notice, this 031 list of conditions and the following disclaimer. 032 * Redistributions in binary form must reproduce the above copyright notice, 033 this list of conditions and the following disclaimer in the documentation 034 and/or other materials provided with the distribution. 035 * Neither the name of HL7 nor the names of its contributors may be used to 036 endorse or promote products derived from this software without specific 037 prior written permission. 038 039 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 040 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 041 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 042 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 043 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 044 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 045 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 046 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 047 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 048 POSSIBILITY OF SUCH DAMAGE. 049 050*/ 051 052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0 053import java.util.ArrayList; 054import java.util.List; 055 056import org.hl7.fhir.exceptions.FHIRException; 057import org.hl7.fhir.instance.model.api.ICompositeType; 058import org.hl7.fhir.instance.model.api.IPrimitiveType; 059import org.hl7.fhir.utilities.Utilities; 060 061import ca.uhn.fhir.model.api.annotation.Child; 062import ca.uhn.fhir.model.api.annotation.DatatypeDef; 063import ca.uhn.fhir.model.api.annotation.Description; 064import ca.uhn.fhir.util.DatatypeUtil; 065/** 066 * A human's name with the ability to identify parts and usage. 067 */ 068@DatatypeDef(name="HumanName") 069public class HumanName extends Type implements ICompositeType { 070 071 public enum NameUse { 072 /** 073 * Known as/conventional/the one you normally use. 074 */ 075 USUAL, 076 /** 077 * The formal name as registered in an official (government) registry, but which name might not be commonly used. May be called "legal name". 078 */ 079 OFFICIAL, 080 /** 081 * 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. 082 */ 083 TEMP, 084 /** 085 * A name that is used to address the person in an informal manner, but is not part of their formal or usual name. 086 */ 087 NICKNAME, 088 /** 089 * Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons). 090 */ 091 ANONYMOUS, 092 /** 093 * This name is no longer in use (or was never correct, but retained for records). 094 */ 095 OLD, 096 /** 097 * A name used prior to changing name because of marriage. This name use is for use by applications that collect and store names that were used prior to a marriage. Marriage naming customs vary greatly around the world, and are constantly changing. This term is not gender specific. The use of this term does not imply any particular history for a person's name. 098 */ 099 MAIDEN, 100 /** 101 * added to help the parsers with the generic types 102 */ 103 NULL; 104 public static NameUse fromCode(String codeString) throws FHIRException { 105 if (codeString == null || "".equals(codeString)) 106 return null; 107 if ("usual".equals(codeString)) 108 return USUAL; 109 if ("official".equals(codeString)) 110 return OFFICIAL; 111 if ("temp".equals(codeString)) 112 return TEMP; 113 if ("nickname".equals(codeString)) 114 return NICKNAME; 115 if ("anonymous".equals(codeString)) 116 return ANONYMOUS; 117 if ("old".equals(codeString)) 118 return OLD; 119 if ("maiden".equals(codeString)) 120 return MAIDEN; 121 if (Configuration.isAcceptInvalidEnums()) 122 return null; 123 else 124 throw new FHIRException("Unknown NameUse code '"+codeString+"'"); 125 } 126 public String toCode() { 127 switch (this) { 128 case USUAL: return "usual"; 129 case OFFICIAL: return "official"; 130 case TEMP: return "temp"; 131 case NICKNAME: return "nickname"; 132 case ANONYMOUS: return "anonymous"; 133 case OLD: return "old"; 134 case MAIDEN: return "maiden"; 135 default: return "?"; 136 } 137 } 138 public String getSystem() { 139 switch (this) { 140 case USUAL: return "http://hl7.org/fhir/name-use"; 141 case OFFICIAL: return "http://hl7.org/fhir/name-use"; 142 case TEMP: return "http://hl7.org/fhir/name-use"; 143 case NICKNAME: return "http://hl7.org/fhir/name-use"; 144 case ANONYMOUS: return "http://hl7.org/fhir/name-use"; 145 case OLD: return "http://hl7.org/fhir/name-use"; 146 case MAIDEN: return "http://hl7.org/fhir/name-use"; 147 default: return "?"; 148 } 149 } 150 public String getDefinition() { 151 switch (this) { 152 case USUAL: return "Known as/conventional/the one you normally use."; 153 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\"."; 154 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."; 155 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."; 156 case ANONYMOUS: return "Anonymous assigned name, alias, or pseudonym (used to protect a person's identity for privacy reasons)."; 157 case OLD: return "This name is no longer in use (or was never correct, but retained for records)."; 158 case MAIDEN: return "A name used prior to changing name because of marriage. This name use is for use by applications that collect and store names that were used prior to a marriage. Marriage naming customs vary greatly around the world, and are constantly changing. This term is not gender specific. The use of this term does not imply any particular history for a person's name."; 159 default: return "?"; 160 } 161 } 162 public String getDisplay() { 163 switch (this) { 164 case USUAL: return "Usual"; 165 case OFFICIAL: return "Official"; 166 case TEMP: return "Temp"; 167 case NICKNAME: return "Nickname"; 168 case ANONYMOUS: return "Anonymous"; 169 case OLD: return "Old"; 170 case MAIDEN: return "Name changed for Marriage"; 171 default: return "?"; 172 } 173 } 174 } 175 176 public static class NameUseEnumFactory implements EnumFactory<NameUse> { 177 public NameUse fromCode(String codeString) throws IllegalArgumentException { 178 if (codeString == null || "".equals(codeString)) 179 if (codeString == null || "".equals(codeString)) 180 return null; 181 if ("usual".equals(codeString)) 182 return NameUse.USUAL; 183 if ("official".equals(codeString)) 184 return NameUse.OFFICIAL; 185 if ("temp".equals(codeString)) 186 return NameUse.TEMP; 187 if ("nickname".equals(codeString)) 188 return NameUse.NICKNAME; 189 if ("anonymous".equals(codeString)) 190 return NameUse.ANONYMOUS; 191 if ("old".equals(codeString)) 192 return NameUse.OLD; 193 if ("maiden".equals(codeString)) 194 return NameUse.MAIDEN; 195 throw new IllegalArgumentException("Unknown NameUse code '"+codeString+"'"); 196 } 197 public Enumeration<NameUse> fromType(Base code) throws FHIRException { 198 if (code == null) 199 return null; 200 if (code.isEmpty()) 201 return new Enumeration<NameUse>(this); 202 String codeString = ((PrimitiveType) code).asStringValue(); 203 if (codeString == null || "".equals(codeString)) 204 return null; 205 if ("usual".equals(codeString)) 206 return new Enumeration<NameUse>(this, NameUse.USUAL); 207 if ("official".equals(codeString)) 208 return new Enumeration<NameUse>(this, NameUse.OFFICIAL); 209 if ("temp".equals(codeString)) 210 return new Enumeration<NameUse>(this, NameUse.TEMP); 211 if ("nickname".equals(codeString)) 212 return new Enumeration<NameUse>(this, NameUse.NICKNAME); 213 if ("anonymous".equals(codeString)) 214 return new Enumeration<NameUse>(this, NameUse.ANONYMOUS); 215 if ("old".equals(codeString)) 216 return new Enumeration<NameUse>(this, NameUse.OLD); 217 if ("maiden".equals(codeString)) 218 return new Enumeration<NameUse>(this, NameUse.MAIDEN); 219 throw new FHIRException("Unknown NameUse code '"+codeString+"'"); 220 } 221 public String toCode(NameUse code) { 222 if (code == NameUse.USUAL) 223 return "usual"; 224 if (code == NameUse.OFFICIAL) 225 return "official"; 226 if (code == NameUse.TEMP) 227 return "temp"; 228 if (code == NameUse.NICKNAME) 229 return "nickname"; 230 if (code == NameUse.ANONYMOUS) 231 return "anonymous"; 232 if (code == NameUse.OLD) 233 return "old"; 234 if (code == NameUse.MAIDEN) 235 return "maiden"; 236 return "?"; 237 } 238 public String toSystem(NameUse code) { 239 return code.getSystem(); 240 } 241 } 242 243 /** 244 * Identifies the purpose for this name. 245 */ 246 @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true) 247 @Description(shortDefinition="usual | official | temp | nickname | anonymous | old | maiden", formalDefinition="Identifies the purpose for this name." ) 248 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/name-use") 249 protected Enumeration<NameUse> use; 250 251 /** 252 * Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts. 253 */ 254 @Child(name = "text", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true) 255 @Description(shortDefinition="Text representation of the full name", formalDefinition="Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts." ) 256 protected StringType text; 257 258 /** 259 * 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. 260 */ 261 @Child(name = "family", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true) 262 @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." ) 263 protected StringType family; 264 265 /** 266 * Given name. 267 */ 268 @Child(name = "given", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 269 @Description(shortDefinition="Given names (not always 'first'). Includes middle names", formalDefinition="Given name." ) 270 protected List<StringType> given; 271 272 /** 273 * 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. 274 */ 275 @Child(name = "prefix", type = {StringType.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 276 @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." ) 277 protected List<StringType> prefix; 278 279 /** 280 * 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. 281 */ 282 @Child(name = "suffix", type = {StringType.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 283 @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." ) 284 protected List<StringType> suffix; 285 286 /** 287 * Indicates the period of time when this name was valid for the named person. 288 */ 289 @Child(name = "period", type = {Period.class}, order=6, min=0, max=1, modifier=false, summary=true) 290 @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." ) 291 protected Period period; 292 293 private static final long serialVersionUID = -507469160L; 294 295 /** 296 * Constructor 297 */ 298 public HumanName() { 299 super(); 300 } 301 302 /** 303 * @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 304 */ 305 public Enumeration<NameUse> getUseElement() { 306 if (this.use == null) 307 if (Configuration.errorOnAutoCreate()) 308 throw new Error("Attempt to auto-create HumanName.use"); 309 else if (Configuration.doAutoCreate()) 310 this.use = new Enumeration<NameUse>(new NameUseEnumFactory()); // bb 311 return this.use; 312 } 313 314 public boolean hasUseElement() { 315 return this.use != null && !this.use.isEmpty(); 316 } 317 318 public boolean hasUse() { 319 return this.use != null && !this.use.isEmpty(); 320 } 321 322 /** 323 * @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 324 */ 325 public HumanName setUseElement(Enumeration<NameUse> value) { 326 this.use = value; 327 return this; 328 } 329 330 /** 331 * @return Identifies the purpose for this name. 332 */ 333 public NameUse getUse() { 334 return this.use == null ? null : this.use.getValue(); 335 } 336 337 /** 338 * @param value Identifies the purpose for this name. 339 */ 340 public HumanName setUse(NameUse value) { 341 if (value == null) 342 this.use = null; 343 else { 344 if (this.use == null) 345 this.use = new Enumeration<NameUse>(new NameUseEnumFactory()); 346 this.use.setValue(value); 347 } 348 return this; 349 } 350 351 /** 352 * @return {@link #text} (Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 353 */ 354 public StringType getTextElement() { 355 if (this.text == null) 356 if (Configuration.errorOnAutoCreate()) 357 throw new Error("Attempt to auto-create HumanName.text"); 358 else if (Configuration.doAutoCreate()) 359 this.text = new StringType(); // bb 360 return this.text; 361 } 362 363 public boolean hasTextElement() { 364 return this.text != null && !this.text.isEmpty(); 365 } 366 367 public boolean hasText() { 368 return this.text != null && !this.text.isEmpty(); 369 } 370 371 /** 372 * @param value {@link #text} (Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value 373 */ 374 public HumanName setTextElement(StringType value) { 375 this.text = value; 376 return this; 377 } 378 379 /** 380 * @return Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts. 381 */ 382 public String getText() { 383 return this.text == null ? null : this.text.getValue(); 384 } 385 386 /** 387 * @param value Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts. 388 */ 389 public HumanName setText(String value) { 390 if (Utilities.noString(value)) 391 this.text = null; 392 else { 393 if (this.text == null) 394 this.text = new StringType(); 395 this.text.setValue(value); 396 } 397 return this; 398 } 399 400 /** 401 * @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.). This is the underlying object with id, value and extensions. The accessor "getFamily" gives direct access to the value 402 */ 403 public StringType getFamilyElement() { 404 if (this.family == null) 405 if (Configuration.errorOnAutoCreate()) 406 throw new Error("Attempt to auto-create HumanName.family"); 407 else if (Configuration.doAutoCreate()) 408 this.family = new StringType(); // bb 409 return this.family; 410 } 411 412 public boolean hasFamilyElement() { 413 return this.family != null && !this.family.isEmpty(); 414 } 415 416 public boolean hasFamily() { 417 return this.family != null && !this.family.isEmpty(); 418 } 419 420 /** 421 * @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.). This is the underlying object with id, value and extensions. The accessor "getFamily" gives direct access to the value 422 */ 423 public HumanName setFamilyElement(StringType value) { 424 this.family = value; 425 return this; 426 } 427 428 /** 429 * @return 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. 430 */ 431 public String getFamily() { 432 return this.family == null ? null : this.family.getValue(); 433 } 434 435 /** 436 * @param value 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. 437 */ 438 public HumanName setFamily(String value) { 439 if (Utilities.noString(value)) 440 this.family = null; 441 else { 442 if (this.family == null) 443 this.family = new StringType(); 444 this.family.setValue(value); 445 } 446 return this; 447 } 448 449 /** 450 * @return {@link #given} (Given name.) 451 */ 452 public List<StringType> getGiven() { 453 if (this.given == null) 454 this.given = new ArrayList<StringType>(); 455 return this.given; 456 } 457 458 /** 459 * @return Returns a reference to <code>this</code> for easy method chaining 460 */ 461 public HumanName setGiven(List<StringType> theGiven) { 462 this.given = theGiven; 463 return this; 464 } 465 466 public boolean hasGiven() { 467 if (this.given == null) 468 return false; 469 for (StringType item : this.given) 470 if (!item.isEmpty()) 471 return true; 472 return false; 473 } 474 475 /** 476 * @return {@link #given} (Given name.) 477 */ 478 public StringType addGivenElement() {//2 479 StringType t = new StringType(); 480 if (this.given == null) 481 this.given = new ArrayList<StringType>(); 482 this.given.add(t); 483 return t; 484 } 485 486 /** 487 * @param value {@link #given} (Given name.) 488 */ 489 public HumanName addGiven(String value) { //1 490 StringType t = new StringType(); 491 t.setValue(value); 492 if (this.given == null) 493 this.given = new ArrayList<StringType>(); 494 this.given.add(t); 495 return this; 496 } 497 498 /** 499 * @param value {@link #given} (Given name.) 500 */ 501 public boolean hasGiven(String value) { 502 if (this.given == null) 503 return false; 504 for (StringType v : this.given) 505 if (v.getValue().equals(value)) // string 506 return true; 507 return false; 508 } 509 510 /** 511 * @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.) 512 */ 513 public List<StringType> getPrefix() { 514 if (this.prefix == null) 515 this.prefix = new ArrayList<StringType>(); 516 return this.prefix; 517 } 518 519 /** 520 * @return Returns a reference to <code>this</code> for easy method chaining 521 */ 522 public HumanName setPrefix(List<StringType> thePrefix) { 523 this.prefix = thePrefix; 524 return this; 525 } 526 527 public boolean hasPrefix() { 528 if (this.prefix == null) 529 return false; 530 for (StringType item : this.prefix) 531 if (!item.isEmpty()) 532 return true; 533 return false; 534 } 535 536 /** 537 * @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.) 538 */ 539 public StringType addPrefixElement() {//2 540 StringType t = new StringType(); 541 if (this.prefix == null) 542 this.prefix = new ArrayList<StringType>(); 543 this.prefix.add(t); 544 return t; 545 } 546 547 /** 548 * @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.) 549 */ 550 public HumanName addPrefix(String value) { //1 551 StringType t = new StringType(); 552 t.setValue(value); 553 if (this.prefix == null) 554 this.prefix = new ArrayList<StringType>(); 555 this.prefix.add(t); 556 return this; 557 } 558 559 /** 560 * @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.) 561 */ 562 public boolean hasPrefix(String value) { 563 if (this.prefix == null) 564 return false; 565 for (StringType v : this.prefix) 566 if (v.getValue().equals(value)) // string 567 return true; 568 return false; 569 } 570 571 /** 572 * @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.) 573 */ 574 public List<StringType> getSuffix() { 575 if (this.suffix == null) 576 this.suffix = new ArrayList<StringType>(); 577 return this.suffix; 578 } 579 580 /** 581 * @return Returns a reference to <code>this</code> for easy method chaining 582 */ 583 public HumanName setSuffix(List<StringType> theSuffix) { 584 this.suffix = theSuffix; 585 return this; 586 } 587 588 public boolean hasSuffix() { 589 if (this.suffix == null) 590 return false; 591 for (StringType item : this.suffix) 592 if (!item.isEmpty()) 593 return true; 594 return false; 595 } 596 597 /** 598 * @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.) 599 */ 600 public StringType addSuffixElement() {//2 601 StringType t = new StringType(); 602 if (this.suffix == null) 603 this.suffix = new ArrayList<StringType>(); 604 this.suffix.add(t); 605 return t; 606 } 607 608 /** 609 * @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.) 610 */ 611 public HumanName addSuffix(String value) { //1 612 StringType t = new StringType(); 613 t.setValue(value); 614 if (this.suffix == null) 615 this.suffix = new ArrayList<StringType>(); 616 this.suffix.add(t); 617 return this; 618 } 619 620 /** 621 * @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.) 622 */ 623 public boolean hasSuffix(String value) { 624 if (this.suffix == null) 625 return false; 626 for (StringType v : this.suffix) 627 if (v.getValue().equals(value)) // string 628 return true; 629 return false; 630 } 631 632 /** 633 * @return {@link #period} (Indicates the period of time when this name was valid for the named person.) 634 */ 635 public Period getPeriod() { 636 if (this.period == null) 637 if (Configuration.errorOnAutoCreate()) 638 throw new Error("Attempt to auto-create HumanName.period"); 639 else if (Configuration.doAutoCreate()) 640 this.period = new Period(); // cc 641 return this.period; 642 } 643 644 public boolean hasPeriod() { 645 return this.period != null && !this.period.isEmpty(); 646 } 647 648 /** 649 * @param value {@link #period} (Indicates the period of time when this name was valid for the named person.) 650 */ 651 public HumanName setPeriod(Period value) { 652 this.period = value; 653 return this; 654 } 655 656 /** 657 /** 658 * Returns all repetitions of {@link #getGiven() given name} as a space separated string 659 * 660 * @see DatatypeUtil#joinStringsSpaceSeparated(List) 661 */ 662 public String getGivenAsSingleString() { 663 return joinStringsSpaceSeparated(getGiven()); 664 } 665 666 /** 667 * Returns all repetitions of {@link #getPrefix() prefix name} as a space separated string 668 * 669 * @see DatatypeUtil#joinStringsSpaceSeparated(List) 670 */ 671 public String getPrefixAsSingleString() { 672 return joinStringsSpaceSeparated(getPrefix()); 673 } 674 675 /** 676 * Returns all repetitions of {@link #getSuffix() suffix} as a space separated string 677 * 678 * @see DatatypeUtil#joinStringsSpaceSeparated(List) 679 */ 680 public String getSuffixAsSingleString() { 681 return joinStringsSpaceSeparated(getSuffix()); 682 } 683 684 /** 685 * Returns all of the components of the name (prefix, given, family, suffix) as a single string with a single spaced 686 * string separating each part. 687 * <p> 688 * If none of the parts are populated, returns the {@link #getTextElement() text} element value instead. 689 * </p> 690 */ 691 public String getNameAsSingleString() { 692 List<StringType> nameParts = new ArrayList<StringType>(); 693 nameParts.addAll(getPrefix()); 694 nameParts.addAll(getGiven()); 695 nameParts.add(getFamilyElement()); 696 nameParts.addAll(getSuffix()); 697 if (nameParts.size() > 0) { 698 return joinStringsSpaceSeparated(nameParts); 699 } else { 700 return getTextElement().getValue(); 701 } 702 } 703 704 /** 705 * Joins a list of strings with a single space (' ') between each string 706 * 707 * TODO: replace with call to ca.uhn.fhir.util.DatatypeUtil.joinStringsSpaceSeparated when HAPI upgrades to 1.4 708 */ 709 private static String joinStringsSpaceSeparated(List<? extends IPrimitiveType<String>> theStrings) { 710 StringBuilder b = new StringBuilder(); 711 for (IPrimitiveType<String> next : theStrings) { 712 if (next.isEmpty()) { 713 continue; 714 } 715 if (b.length() > 0) { 716 b.append(' '); 717 } 718 b.append(next.getValue()); 719 } 720 return b.toString(); 721 } 722 protected void listChildren(List<Property> children) { 723 super.listChildren(children); 724 children.add(new Property("use", "code", "Identifies the purpose for this name.", 0, 1, use)); 725 children.add(new Property("text", "string", "Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.", 0, 1, text)); 726 children.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, 1, family)); 727 children.add(new Property("given", "string", "Given name.", 0, java.lang.Integer.MAX_VALUE, given)); 728 children.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)); 729 children.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)); 730 children.add(new Property("period", "Period", "Indicates the period of time when this name was valid for the named person.", 0, 1, period)); 731 } 732 733 @Override 734 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 735 switch (_hash) { 736 case 116103: /*use*/ return new Property("use", "code", "Identifies the purpose for this name.", 0, 1, use); 737 case 3556653: /*text*/ return new Property("text", "string", "Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.", 0, 1, text); 738 case -1281860764: /*family*/ return 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, 1, family); 739 case 98367357: /*given*/ return new Property("given", "string", "Given name.", 0, java.lang.Integer.MAX_VALUE, given); 740 case -980110702: /*prefix*/ return 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); 741 case -891422895: /*suffix*/ return 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); 742 case -991726143: /*period*/ return new Property("period", "Period", "Indicates the period of time when this name was valid for the named person.", 0, 1, period); 743 default: return super.getNamedProperty(_hash, _name, _checkValid); 744 } 745 746 } 747 748 @Override 749 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 750 switch (hash) { 751 case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // Enumeration<NameUse> 752 case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType 753 case -1281860764: /*family*/ return this.family == null ? new Base[0] : new Base[] {this.family}; // StringType 754 case 98367357: /*given*/ return this.given == null ? new Base[0] : this.given.toArray(new Base[this.given.size()]); // StringType 755 case -980110702: /*prefix*/ return this.prefix == null ? new Base[0] : this.prefix.toArray(new Base[this.prefix.size()]); // StringType 756 case -891422895: /*suffix*/ return this.suffix == null ? new Base[0] : this.suffix.toArray(new Base[this.suffix.size()]); // StringType 757 case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period 758 default: return super.getProperty(hash, name, checkValid); 759 } 760 761 } 762 763 @Override 764 public Base setProperty(int hash, String name, Base value) throws FHIRException { 765 switch (hash) { 766 case 116103: // use 767 value = new NameUseEnumFactory().fromType(castToCode(value)); 768 this.use = (Enumeration) value; // Enumeration<NameUse> 769 return value; 770 case 3556653: // text 771 this.text = castToString(value); // StringType 772 return value; 773 case -1281860764: // family 774 this.family = castToString(value); // StringType 775 return value; 776 case 98367357: // given 777 this.getGiven().add(castToString(value)); // StringType 778 return value; 779 case -980110702: // prefix 780 this.getPrefix().add(castToString(value)); // StringType 781 return value; 782 case -891422895: // suffix 783 this.getSuffix().add(castToString(value)); // StringType 784 return value; 785 case -991726143: // period 786 this.period = castToPeriod(value); // Period 787 return value; 788 default: return super.setProperty(hash, name, value); 789 } 790 791 } 792 793 @Override 794 public Base setProperty(String name, Base value) throws FHIRException { 795 if (name.equals("use")) { 796 value = new NameUseEnumFactory().fromType(castToCode(value)); 797 this.use = (Enumeration) value; // Enumeration<NameUse> 798 } else if (name.equals("text")) { 799 this.text = castToString(value); // StringType 800 } else if (name.equals("family")) { 801 this.family = castToString(value); // StringType 802 } else if (name.equals("given")) { 803 this.getGiven().add(castToString(value)); 804 } else if (name.equals("prefix")) { 805 this.getPrefix().add(castToString(value)); 806 } else if (name.equals("suffix")) { 807 this.getSuffix().add(castToString(value)); 808 } else if (name.equals("period")) { 809 this.period = castToPeriod(value); // Period 810 } else 811 return super.setProperty(name, value); 812 return value; 813 } 814 815 @Override 816 public Base makeProperty(int hash, String name) throws FHIRException { 817 switch (hash) { 818 case 116103: return getUseElement(); 819 case 3556653: return getTextElement(); 820 case -1281860764: return getFamilyElement(); 821 case 98367357: return addGivenElement(); 822 case -980110702: return addPrefixElement(); 823 case -891422895: return addSuffixElement(); 824 case -991726143: return getPeriod(); 825 default: return super.makeProperty(hash, name); 826 } 827 828 } 829 830 @Override 831 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 832 switch (hash) { 833 case 116103: /*use*/ return new String[] {"code"}; 834 case 3556653: /*text*/ return new String[] {"string"}; 835 case -1281860764: /*family*/ return new String[] {"string"}; 836 case 98367357: /*given*/ return new String[] {"string"}; 837 case -980110702: /*prefix*/ return new String[] {"string"}; 838 case -891422895: /*suffix*/ return new String[] {"string"}; 839 case -991726143: /*period*/ return new String[] {"Period"}; 840 default: return super.getTypesForProperty(hash, name); 841 } 842 843 } 844 845 @Override 846 public Base addChild(String name) throws FHIRException { 847 if (name.equals("use")) { 848 throw new FHIRException("Cannot call addChild on a primitive type HumanName.use"); 849 } 850 else if (name.equals("text")) { 851 throw new FHIRException("Cannot call addChild on a primitive type HumanName.text"); 852 } 853 else if (name.equals("family")) { 854 throw new FHIRException("Cannot call addChild on a primitive type HumanName.family"); 855 } 856 else if (name.equals("given")) { 857 throw new FHIRException("Cannot call addChild on a primitive type HumanName.given"); 858 } 859 else if (name.equals("prefix")) { 860 throw new FHIRException("Cannot call addChild on a primitive type HumanName.prefix"); 861 } 862 else if (name.equals("suffix")) { 863 throw new FHIRException("Cannot call addChild on a primitive type HumanName.suffix"); 864 } 865 else if (name.equals("period")) { 866 this.period = new Period(); 867 return this.period; 868 } 869 else 870 return super.addChild(name); 871 } 872 873 public String fhirType() { 874 return "HumanName"; 875 876 } 877 878 public HumanName copy() { 879 HumanName dst = new HumanName(); 880 copyValues(dst); 881 dst.use = use == null ? null : use.copy(); 882 dst.text = text == null ? null : text.copy(); 883 dst.family = family == null ? null : family.copy(); 884 if (given != null) { 885 dst.given = new ArrayList<StringType>(); 886 for (StringType i : given) 887 dst.given.add(i.copy()); 888 }; 889 if (prefix != null) { 890 dst.prefix = new ArrayList<StringType>(); 891 for (StringType i : prefix) 892 dst.prefix.add(i.copy()); 893 }; 894 if (suffix != null) { 895 dst.suffix = new ArrayList<StringType>(); 896 for (StringType i : suffix) 897 dst.suffix.add(i.copy()); 898 }; 899 dst.period = period == null ? null : period.copy(); 900 return dst; 901 } 902 903 protected HumanName typedCopy() { 904 return copy(); 905 } 906 907 @Override 908 public boolean equalsDeep(Base other_) { 909 if (!super.equalsDeep(other_)) 910 return false; 911 if (!(other_ instanceof HumanName)) 912 return false; 913 HumanName o = (HumanName) other_; 914 return compareDeep(use, o.use, true) && compareDeep(text, o.text, true) && compareDeep(family, o.family, true) 915 && compareDeep(given, o.given, true) && compareDeep(prefix, o.prefix, true) && compareDeep(suffix, o.suffix, true) 916 && compareDeep(period, o.period, true); 917 } 918 919 @Override 920 public boolean equalsShallow(Base other_) { 921 if (!super.equalsShallow(other_)) 922 return false; 923 if (!(other_ instanceof HumanName)) 924 return false; 925 HumanName o = (HumanName) other_; 926 return compareValues(use, o.use, true) && compareValues(text, o.text, true) && compareValues(family, o.family, true) 927 && compareValues(given, o.given, true) && compareValues(prefix, o.prefix, true) && compareValues(suffix, o.suffix, true) 928 ; 929 } 930 931 public boolean isEmpty() { 932 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(use, text, family, given 933 , prefix, suffix, period); 934 } 935 936 937} 938