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