001package org.hl7.fhir.r4.model; 002 003 004 005/* 006 Copyright (c) 2011+, HL7, Inc. 007 All rights reserved. 008 009 Redistribution and use in source and binary forms, with or without modification, 010 are permitted provided that the following conditions are met: 011 012 * Redistributions of source code must retain the above copyright notice, this 013 list of conditions and the following disclaimer. 014 * Redistributions in binary form must reproduce the above copyright notice, 015 this list of conditions and the following disclaimer in the documentation 016 and/or other materials provided with the distribution. 017 * Neither the name of HL7 nor the names of its contributors may be used to 018 endorse or promote products derived from this software without specific 019 prior written permission. 020 021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 024 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 025 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 026 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 027 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 029 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 030 POSSIBILITY OF SUCH DAMAGE. 031 032*/ 033 034 035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 036 037import java.util.*; 038 039import org.hl7.fhir.utilities.Utilities; 040import ca.uhn.fhir.model.api.annotation.Child; 041import ca.uhn.fhir.model.api.annotation.ChildOrder; 042import ca.uhn.fhir.model.api.annotation.Description; 043import ca.uhn.fhir.model.api.annotation.DatatypeDef; 044import ca.uhn.fhir.model.api.annotation.Block; 045import org.hl7.fhir.instance.model.api.*; 046import org.hl7.fhir.exceptions.FHIRException; 047/** 048 * An address expressed using postal conventions (as opposed to GPS or other location definition formats). This data type may be used to convey addresses for use in delivering mail as well as for visiting locations which might not be valid for mail delivery. There are a variety of postal address formats defined around the world. 049 */ 050@DatatypeDef(name="Address") 051public class Address extends Type implements ICompositeType { 052 053 public enum AddressUse { 054 /** 055 * A communication address at a home. 056 */ 057 HOME, 058 /** 059 * An office address. First choice for business related contacts during business hours. 060 */ 061 WORK, 062 /** 063 * A temporary address. The period can provide more detailed information. 064 */ 065 TEMP, 066 /** 067 * This address is no longer in use (or was never correct but retained for records). 068 */ 069 OLD, 070 /** 071 * An address to be used to send bills, invoices, receipts etc. 072 */ 073 BILLING, 074 /** 075 * added to help the parsers with the generic types 076 */ 077 NULL; 078 public static AddressUse fromCode(String codeString) throws FHIRException { 079 if (codeString == null || "".equals(codeString)) 080 return null; 081 if ("home".equals(codeString)) 082 return HOME; 083 if ("work".equals(codeString)) 084 return WORK; 085 if ("temp".equals(codeString)) 086 return TEMP; 087 if ("old".equals(codeString)) 088 return OLD; 089 if ("billing".equals(codeString)) 090 return BILLING; 091 if (Configuration.isAcceptInvalidEnums()) 092 return null; 093 else 094 throw new FHIRException("Unknown AddressUse code '"+codeString+"'"); 095 } 096 public String toCode() { 097 switch (this) { 098 case HOME: return "home"; 099 case WORK: return "work"; 100 case TEMP: return "temp"; 101 case OLD: return "old"; 102 case BILLING: return "billing"; 103 case NULL: return null; 104 default: return "?"; 105 } 106 } 107 public String getSystem() { 108 switch (this) { 109 case HOME: return "http://hl7.org/fhir/address-use"; 110 case WORK: return "http://hl7.org/fhir/address-use"; 111 case TEMP: return "http://hl7.org/fhir/address-use"; 112 case OLD: return "http://hl7.org/fhir/address-use"; 113 case BILLING: return "http://hl7.org/fhir/address-use"; 114 case NULL: return null; 115 default: return "?"; 116 } 117 } 118 public String getDefinition() { 119 switch (this) { 120 case HOME: return "A communication address at a home."; 121 case WORK: return "An office address. First choice for business related contacts during business hours."; 122 case TEMP: return "A temporary address. The period can provide more detailed information."; 123 case OLD: return "This address is no longer in use (or was never correct but retained for records)."; 124 case BILLING: return "An address to be used to send bills, invoices, receipts etc."; 125 case NULL: return null; 126 default: return "?"; 127 } 128 } 129 public String getDisplay() { 130 switch (this) { 131 case HOME: return "Home"; 132 case WORK: return "Work"; 133 case TEMP: return "Temporary"; 134 case OLD: return "Old / Incorrect"; 135 case BILLING: return "Billing"; 136 case NULL: return null; 137 default: return "?"; 138 } 139 } 140 } 141 142 public static class AddressUseEnumFactory implements EnumFactory<AddressUse> { 143 public AddressUse fromCode(String codeString) throws IllegalArgumentException { 144 if (codeString == null || "".equals(codeString)) 145 if (codeString == null || "".equals(codeString)) 146 return null; 147 if ("home".equals(codeString)) 148 return AddressUse.HOME; 149 if ("work".equals(codeString)) 150 return AddressUse.WORK; 151 if ("temp".equals(codeString)) 152 return AddressUse.TEMP; 153 if ("old".equals(codeString)) 154 return AddressUse.OLD; 155 if ("billing".equals(codeString)) 156 return AddressUse.BILLING; 157 throw new IllegalArgumentException("Unknown AddressUse code '"+codeString+"'"); 158 } 159 public Enumeration<AddressUse> fromType(Base code) throws FHIRException { 160 if (code == null) 161 return null; 162 if (code.isEmpty()) 163 return new Enumeration<AddressUse>(this); 164 String codeString = ((PrimitiveType) code).asStringValue(); 165 if (codeString == null || "".equals(codeString)) 166 return null; 167 if ("home".equals(codeString)) 168 return new Enumeration<AddressUse>(this, AddressUse.HOME); 169 if ("work".equals(codeString)) 170 return new Enumeration<AddressUse>(this, AddressUse.WORK); 171 if ("temp".equals(codeString)) 172 return new Enumeration<AddressUse>(this, AddressUse.TEMP); 173 if ("old".equals(codeString)) 174 return new Enumeration<AddressUse>(this, AddressUse.OLD); 175 if ("billing".equals(codeString)) 176 return new Enumeration<AddressUse>(this, AddressUse.BILLING); 177 throw new FHIRException("Unknown AddressUse code '"+codeString+"'"); 178 } 179 public String toCode(AddressUse code) { 180 if (code == AddressUse.HOME) 181 return "home"; 182 if (code == AddressUse.WORK) 183 return "work"; 184 if (code == AddressUse.TEMP) 185 return "temp"; 186 if (code == AddressUse.OLD) 187 return "old"; 188 if (code == AddressUse.BILLING) 189 return "billing"; 190 return "?"; 191 } 192 public String toSystem(AddressUse code) { 193 return code.getSystem(); 194 } 195 } 196 197 public enum AddressType { 198 /** 199 * Mailing addresses - PO Boxes and care-of addresses. 200 */ 201 POSTAL, 202 /** 203 * A physical address that can be visited. 204 */ 205 PHYSICAL, 206 /** 207 * An address that is both physical and postal. 208 */ 209 BOTH, 210 /** 211 * added to help the parsers with the generic types 212 */ 213 NULL; 214 public static AddressType fromCode(String codeString) throws FHIRException { 215 if (codeString == null || "".equals(codeString)) 216 return null; 217 if ("postal".equals(codeString)) 218 return POSTAL; 219 if ("physical".equals(codeString)) 220 return PHYSICAL; 221 if ("both".equals(codeString)) 222 return BOTH; 223 if (Configuration.isAcceptInvalidEnums()) 224 return null; 225 else 226 throw new FHIRException("Unknown AddressType code '"+codeString+"'"); 227 } 228 public String toCode() { 229 switch (this) { 230 case POSTAL: return "postal"; 231 case PHYSICAL: return "physical"; 232 case BOTH: return "both"; 233 case NULL: return null; 234 default: return "?"; 235 } 236 } 237 public String getSystem() { 238 switch (this) { 239 case POSTAL: return "http://hl7.org/fhir/address-type"; 240 case PHYSICAL: return "http://hl7.org/fhir/address-type"; 241 case BOTH: return "http://hl7.org/fhir/address-type"; 242 case NULL: return null; 243 default: return "?"; 244 } 245 } 246 public String getDefinition() { 247 switch (this) { 248 case POSTAL: return "Mailing addresses - PO Boxes and care-of addresses."; 249 case PHYSICAL: return "A physical address that can be visited."; 250 case BOTH: return "An address that is both physical and postal."; 251 case NULL: return null; 252 default: return "?"; 253 } 254 } 255 public String getDisplay() { 256 switch (this) { 257 case POSTAL: return "Postal"; 258 case PHYSICAL: return "Physical"; 259 case BOTH: return "Postal & Physical"; 260 case NULL: return null; 261 default: return "?"; 262 } 263 } 264 } 265 266 public static class AddressTypeEnumFactory implements EnumFactory<AddressType> { 267 public AddressType fromCode(String codeString) throws IllegalArgumentException { 268 if (codeString == null || "".equals(codeString)) 269 if (codeString == null || "".equals(codeString)) 270 return null; 271 if ("postal".equals(codeString)) 272 return AddressType.POSTAL; 273 if ("physical".equals(codeString)) 274 return AddressType.PHYSICAL; 275 if ("both".equals(codeString)) 276 return AddressType.BOTH; 277 throw new IllegalArgumentException("Unknown AddressType code '"+codeString+"'"); 278 } 279 public Enumeration<AddressType> fromType(Base code) throws FHIRException { 280 if (code == null) 281 return null; 282 if (code.isEmpty()) 283 return new Enumeration<AddressType>(this); 284 String codeString = ((PrimitiveType) code).asStringValue(); 285 if (codeString == null || "".equals(codeString)) 286 return null; 287 if ("postal".equals(codeString)) 288 return new Enumeration<AddressType>(this, AddressType.POSTAL); 289 if ("physical".equals(codeString)) 290 return new Enumeration<AddressType>(this, AddressType.PHYSICAL); 291 if ("both".equals(codeString)) 292 return new Enumeration<AddressType>(this, AddressType.BOTH); 293 throw new FHIRException("Unknown AddressType code '"+codeString+"'"); 294 } 295 public String toCode(AddressType code) { 296 if (code == AddressType.POSTAL) 297 return "postal"; 298 if (code == AddressType.PHYSICAL) 299 return "physical"; 300 if (code == AddressType.BOTH) 301 return "both"; 302 return "?"; 303 } 304 public String toSystem(AddressType code) { 305 return code.getSystem(); 306 } 307 } 308 309 /** 310 * The purpose of this address. 311 */ 312 @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true) 313 @Description(shortDefinition="home | work | temp | old | billing - purpose of this address", formalDefinition="The purpose of this address." ) 314 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/address-use") 315 protected Enumeration<AddressUse> use; 316 317 /** 318 * Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both. 319 */ 320 @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true) 321 @Description(shortDefinition="postal | physical | both", formalDefinition="Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both." ) 322 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/address-type") 323 protected Enumeration<AddressType> type; 324 325 /** 326 * Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts. 327 */ 328 @Child(name = "text", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true) 329 @Description(shortDefinition="Text representation of the address", formalDefinition="Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts." ) 330 protected StringType text; 331 332 /** 333 * This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information. 334 */ 335 @Child(name = "line", type = {StringType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 336 @Description(shortDefinition="Street name, number, direction & P.O. Box etc.", formalDefinition="This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information." ) 337 protected List<StringType> line; 338 339 /** 340 * The name of the city, town, suburb, village or other community or delivery center. 341 */ 342 @Child(name = "city", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true) 343 @Description(shortDefinition="Name of city, town etc.", formalDefinition="The name of the city, town, suburb, village or other community or delivery center." ) 344 protected StringType city; 345 346 /** 347 * The name of the administrative area (county). 348 */ 349 @Child(name = "district", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true) 350 @Description(shortDefinition="District name (aka county)", formalDefinition="The name of the administrative area (county)." ) 351 protected StringType district; 352 353 /** 354 * Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes). 355 */ 356 @Child(name = "state", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true) 357 @Description(shortDefinition="Sub-unit of country (abbreviations ok)", formalDefinition="Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes)." ) 358 protected StringType state; 359 360 /** 361 * A postal code designating a region defined by the postal service. 362 */ 363 @Child(name = "postalCode", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=true) 364 @Description(shortDefinition="Postal code for area", formalDefinition="A postal code designating a region defined by the postal service." ) 365 protected StringType postalCode; 366 367 /** 368 * Country - a nation as commonly understood or generally accepted. 369 */ 370 @Child(name = "country", type = {StringType.class}, order=8, min=0, max=1, modifier=false, summary=true) 371 @Description(shortDefinition="Country (e.g. can be ISO 3166 2 or 3 letter code)", formalDefinition="Country - a nation as commonly understood or generally accepted." ) 372 protected StringType country; 373 374 /** 375 * Time period when address was/is in use. 376 */ 377 @Child(name = "period", type = {Period.class}, order=9, min=0, max=1, modifier=false, summary=true) 378 @Description(shortDefinition="Time period when address was/is in use", formalDefinition="Time period when address was/is in use." ) 379 protected Period period; 380 381 private static final long serialVersionUID = 561490318L; 382 383 /** 384 * Constructor 385 */ 386 public Address() { 387 super(); 388 } 389 390 /** 391 * @return {@link #use} (The purpose of this address.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value 392 */ 393 public Enumeration<AddressUse> getUseElement() { 394 if (this.use == null) 395 if (Configuration.errorOnAutoCreate()) 396 throw new Error("Attempt to auto-create Address.use"); 397 else if (Configuration.doAutoCreate()) 398 this.use = new Enumeration<AddressUse>(new AddressUseEnumFactory()); // bb 399 return this.use; 400 } 401 402 public boolean hasUseElement() { 403 return this.use != null && !this.use.isEmpty(); 404 } 405 406 public boolean hasUse() { 407 return this.use != null && !this.use.isEmpty(); 408 } 409 410 /** 411 * @param value {@link #use} (The purpose of this address.). This is the underlying object with id, value and extensions. The accessor "getUse" gives direct access to the value 412 */ 413 public Address setUseElement(Enumeration<AddressUse> value) { 414 this.use = value; 415 return this; 416 } 417 418 /** 419 * @return The purpose of this address. 420 */ 421 public AddressUse getUse() { 422 return this.use == null ? null : this.use.getValue(); 423 } 424 425 /** 426 * @param value The purpose of this address. 427 */ 428 public Address setUse(AddressUse value) { 429 if (value == null) 430 this.use = null; 431 else { 432 if (this.use == null) 433 this.use = new Enumeration<AddressUse>(new AddressUseEnumFactory()); 434 this.use.setValue(value); 435 } 436 return this; 437 } 438 439 /** 440 * @return {@link #type} (Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 441 */ 442 public Enumeration<AddressType> getTypeElement() { 443 if (this.type == null) 444 if (Configuration.errorOnAutoCreate()) 445 throw new Error("Attempt to auto-create Address.type"); 446 else if (Configuration.doAutoCreate()) 447 this.type = new Enumeration<AddressType>(new AddressTypeEnumFactory()); // bb 448 return this.type; 449 } 450 451 public boolean hasTypeElement() { 452 return this.type != null && !this.type.isEmpty(); 453 } 454 455 public boolean hasType() { 456 return this.type != null && !this.type.isEmpty(); 457 } 458 459 /** 460 * @param value {@link #type} (Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.). This is the underlying object with id, value and extensions. The accessor "getType" gives direct access to the value 461 */ 462 public Address setTypeElement(Enumeration<AddressType> value) { 463 this.type = value; 464 return this; 465 } 466 467 /** 468 * @return Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both. 469 */ 470 public AddressType getType() { 471 return this.type == null ? null : this.type.getValue(); 472 } 473 474 /** 475 * @param value Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both. 476 */ 477 public Address setType(AddressType value) { 478 if (value == null) 479 this.type = null; 480 else { 481 if (this.type == null) 482 this.type = new Enumeration<AddressType>(new AddressTypeEnumFactory()); 483 this.type.setValue(value); 484 } 485 return this; 486 } 487 488 /** 489 * @return {@link #text} (Specifies the entire address as it should be displayed e.g. on a postal label. 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 490 */ 491 public StringType getTextElement() { 492 if (this.text == null) 493 if (Configuration.errorOnAutoCreate()) 494 throw new Error("Attempt to auto-create Address.text"); 495 else if (Configuration.doAutoCreate()) 496 this.text = new StringType(); // bb 497 return this.text; 498 } 499 500 public boolean hasTextElement() { 501 return this.text != null && !this.text.isEmpty(); 502 } 503 504 public boolean hasText() { 505 return this.text != null && !this.text.isEmpty(); 506 } 507 508 /** 509 * @param value {@link #text} (Specifies the entire address as it should be displayed e.g. on a postal label. 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 510 */ 511 public Address setTextElement(StringType value) { 512 this.text = value; 513 return this; 514 } 515 516 /** 517 * @return Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts. 518 */ 519 public String getText() { 520 return this.text == null ? null : this.text.getValue(); 521 } 522 523 /** 524 * @param value Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts. 525 */ 526 public Address setText(String value) { 527 if (Utilities.noString(value)) 528 this.text = null; 529 else { 530 if (this.text == null) 531 this.text = new StringType(); 532 this.text.setValue(value); 533 } 534 return this; 535 } 536 537 /** 538 * @return {@link #line} (This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.) 539 */ 540 public List<StringType> getLine() { 541 if (this.line == null) 542 this.line = new ArrayList<StringType>(); 543 return this.line; 544 } 545 546 /** 547 * @return Returns a reference to <code>this</code> for easy method chaining 548 */ 549 public Address setLine(List<StringType> theLine) { 550 this.line = theLine; 551 return this; 552 } 553 554 public boolean hasLine() { 555 if (this.line == null) 556 return false; 557 for (StringType item : this.line) 558 if (!item.isEmpty()) 559 return true; 560 return false; 561 } 562 563 /** 564 * @return {@link #line} (This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.) 565 */ 566 public StringType addLineElement() {//2 567 StringType t = new StringType(); 568 if (this.line == null) 569 this.line = new ArrayList<StringType>(); 570 this.line.add(t); 571 return t; 572 } 573 574 /** 575 * @param value {@link #line} (This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.) 576 */ 577 public Address addLine(String value) { //1 578 StringType t = new StringType(); 579 t.setValue(value); 580 if (this.line == null) 581 this.line = new ArrayList<StringType>(); 582 this.line.add(t); 583 return this; 584 } 585 586 /** 587 * @param value {@link #line} (This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.) 588 */ 589 public boolean hasLine(String value) { 590 if (this.line == null) 591 return false; 592 for (StringType v : this.line) 593 if (v.getValue().equals(value)) // string 594 return true; 595 return false; 596 } 597 598 /** 599 * @return {@link #city} (The name of the city, town, suburb, village or other community or delivery center.). This is the underlying object with id, value and extensions. The accessor "getCity" gives direct access to the value 600 */ 601 public StringType getCityElement() { 602 if (this.city == null) 603 if (Configuration.errorOnAutoCreate()) 604 throw new Error("Attempt to auto-create Address.city"); 605 else if (Configuration.doAutoCreate()) 606 this.city = new StringType(); // bb 607 return this.city; 608 } 609 610 public boolean hasCityElement() { 611 return this.city != null && !this.city.isEmpty(); 612 } 613 614 public boolean hasCity() { 615 return this.city != null && !this.city.isEmpty(); 616 } 617 618 /** 619 * @param value {@link #city} (The name of the city, town, suburb, village or other community or delivery center.). This is the underlying object with id, value and extensions. The accessor "getCity" gives direct access to the value 620 */ 621 public Address setCityElement(StringType value) { 622 this.city = value; 623 return this; 624 } 625 626 /** 627 * @return The name of the city, town, suburb, village or other community or delivery center. 628 */ 629 public String getCity() { 630 return this.city == null ? null : this.city.getValue(); 631 } 632 633 /** 634 * @param value The name of the city, town, suburb, village or other community or delivery center. 635 */ 636 public Address setCity(String value) { 637 if (Utilities.noString(value)) 638 this.city = null; 639 else { 640 if (this.city == null) 641 this.city = new StringType(); 642 this.city.setValue(value); 643 } 644 return this; 645 } 646 647 /** 648 * @return {@link #district} (The name of the administrative area (county).). This is the underlying object with id, value and extensions. The accessor "getDistrict" gives direct access to the value 649 */ 650 public StringType getDistrictElement() { 651 if (this.district == null) 652 if (Configuration.errorOnAutoCreate()) 653 throw new Error("Attempt to auto-create Address.district"); 654 else if (Configuration.doAutoCreate()) 655 this.district = new StringType(); // bb 656 return this.district; 657 } 658 659 public boolean hasDistrictElement() { 660 return this.district != null && !this.district.isEmpty(); 661 } 662 663 public boolean hasDistrict() { 664 return this.district != null && !this.district.isEmpty(); 665 } 666 667 /** 668 * @param value {@link #district} (The name of the administrative area (county).). This is the underlying object with id, value and extensions. The accessor "getDistrict" gives direct access to the value 669 */ 670 public Address setDistrictElement(StringType value) { 671 this.district = value; 672 return this; 673 } 674 675 /** 676 * @return The name of the administrative area (county). 677 */ 678 public String getDistrict() { 679 return this.district == null ? null : this.district.getValue(); 680 } 681 682 /** 683 * @param value The name of the administrative area (county). 684 */ 685 public Address setDistrict(String value) { 686 if (Utilities.noString(value)) 687 this.district = null; 688 else { 689 if (this.district == null) 690 this.district = new StringType(); 691 this.district.setValue(value); 692 } 693 return this; 694 } 695 696 /** 697 * @return {@link #state} (Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes).). This is the underlying object with id, value and extensions. The accessor "getState" gives direct access to the value 698 */ 699 public StringType getStateElement() { 700 if (this.state == null) 701 if (Configuration.errorOnAutoCreate()) 702 throw new Error("Attempt to auto-create Address.state"); 703 else if (Configuration.doAutoCreate()) 704 this.state = new StringType(); // bb 705 return this.state; 706 } 707 708 public boolean hasStateElement() { 709 return this.state != null && !this.state.isEmpty(); 710 } 711 712 public boolean hasState() { 713 return this.state != null && !this.state.isEmpty(); 714 } 715 716 /** 717 * @param value {@link #state} (Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes).). This is the underlying object with id, value and extensions. The accessor "getState" gives direct access to the value 718 */ 719 public Address setStateElement(StringType value) { 720 this.state = value; 721 return this; 722 } 723 724 /** 725 * @return Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes). 726 */ 727 public String getState() { 728 return this.state == null ? null : this.state.getValue(); 729 } 730 731 /** 732 * @param value Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes). 733 */ 734 public Address setState(String value) { 735 if (Utilities.noString(value)) 736 this.state = null; 737 else { 738 if (this.state == null) 739 this.state = new StringType(); 740 this.state.setValue(value); 741 } 742 return this; 743 } 744 745 /** 746 * @return {@link #postalCode} (A postal code designating a region defined by the postal service.). This is the underlying object with id, value and extensions. The accessor "getPostalCode" gives direct access to the value 747 */ 748 public StringType getPostalCodeElement() { 749 if (this.postalCode == null) 750 if (Configuration.errorOnAutoCreate()) 751 throw new Error("Attempt to auto-create Address.postalCode"); 752 else if (Configuration.doAutoCreate()) 753 this.postalCode = new StringType(); // bb 754 return this.postalCode; 755 } 756 757 public boolean hasPostalCodeElement() { 758 return this.postalCode != null && !this.postalCode.isEmpty(); 759 } 760 761 public boolean hasPostalCode() { 762 return this.postalCode != null && !this.postalCode.isEmpty(); 763 } 764 765 /** 766 * @param value {@link #postalCode} (A postal code designating a region defined by the postal service.). This is the underlying object with id, value and extensions. The accessor "getPostalCode" gives direct access to the value 767 */ 768 public Address setPostalCodeElement(StringType value) { 769 this.postalCode = value; 770 return this; 771 } 772 773 /** 774 * @return A postal code designating a region defined by the postal service. 775 */ 776 public String getPostalCode() { 777 return this.postalCode == null ? null : this.postalCode.getValue(); 778 } 779 780 /** 781 * @param value A postal code designating a region defined by the postal service. 782 */ 783 public Address setPostalCode(String value) { 784 if (Utilities.noString(value)) 785 this.postalCode = null; 786 else { 787 if (this.postalCode == null) 788 this.postalCode = new StringType(); 789 this.postalCode.setValue(value); 790 } 791 return this; 792 } 793 794 /** 795 * @return {@link #country} (Country - a nation as commonly understood or generally accepted.). This is the underlying object with id, value and extensions. The accessor "getCountry" gives direct access to the value 796 */ 797 public StringType getCountryElement() { 798 if (this.country == null) 799 if (Configuration.errorOnAutoCreate()) 800 throw new Error("Attempt to auto-create Address.country"); 801 else if (Configuration.doAutoCreate()) 802 this.country = new StringType(); // bb 803 return this.country; 804 } 805 806 public boolean hasCountryElement() { 807 return this.country != null && !this.country.isEmpty(); 808 } 809 810 public boolean hasCountry() { 811 return this.country != null && !this.country.isEmpty(); 812 } 813 814 /** 815 * @param value {@link #country} (Country - a nation as commonly understood or generally accepted.). This is the underlying object with id, value and extensions. The accessor "getCountry" gives direct access to the value 816 */ 817 public Address setCountryElement(StringType value) { 818 this.country = value; 819 return this; 820 } 821 822 /** 823 * @return Country - a nation as commonly understood or generally accepted. 824 */ 825 public String getCountry() { 826 return this.country == null ? null : this.country.getValue(); 827 } 828 829 /** 830 * @param value Country - a nation as commonly understood or generally accepted. 831 */ 832 public Address setCountry(String value) { 833 if (Utilities.noString(value)) 834 this.country = null; 835 else { 836 if (this.country == null) 837 this.country = new StringType(); 838 this.country.setValue(value); 839 } 840 return this; 841 } 842 843 /** 844 * @return {@link #period} (Time period when address was/is in use.) 845 */ 846 public Period getPeriod() { 847 if (this.period == null) 848 if (Configuration.errorOnAutoCreate()) 849 throw new Error("Attempt to auto-create Address.period"); 850 else if (Configuration.doAutoCreate()) 851 this.period = new Period(); // cc 852 return this.period; 853 } 854 855 public boolean hasPeriod() { 856 return this.period != null && !this.period.isEmpty(); 857 } 858 859 /** 860 * @param value {@link #period} (Time period when address was/is in use.) 861 */ 862 public Address setPeriod(Period value) { 863 this.period = value; 864 return this; 865 } 866 867 protected void listChildren(List<Property> children) { 868 super.listChildren(children); 869 children.add(new Property("use", "code", "The purpose of this address.", 0, 1, use)); 870 children.add(new Property("type", "code", "Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.", 0, 1, type)); 871 children.add(new Property("text", "string", "Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts.", 0, 1, text)); 872 children.add(new Property("line", "string", "This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.", 0, java.lang.Integer.MAX_VALUE, line)); 873 children.add(new Property("city", "string", "The name of the city, town, suburb, village or other community or delivery center.", 0, 1, city)); 874 children.add(new Property("district", "string", "The name of the administrative area (county).", 0, 1, district)); 875 children.add(new Property("state", "string", "Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes).", 0, 1, state)); 876 children.add(new Property("postalCode", "string", "A postal code designating a region defined by the postal service.", 0, 1, postalCode)); 877 children.add(new Property("country", "string", "Country - a nation as commonly understood or generally accepted.", 0, 1, country)); 878 children.add(new Property("period", "Period", "Time period when address was/is in use.", 0, 1, period)); 879 } 880 881 @Override 882 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 883 switch (_hash) { 884 case 116103: /*use*/ return new Property("use", "code", "The purpose of this address.", 0, 1, use); 885 case 3575610: /*type*/ return new Property("type", "code", "Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.", 0, 1, type); 886 case 3556653: /*text*/ return new Property("text", "string", "Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts.", 0, 1, text); 887 case 3321844: /*line*/ return new Property("line", "string", "This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.", 0, java.lang.Integer.MAX_VALUE, line); 888 case 3053931: /*city*/ return new Property("city", "string", "The name of the city, town, suburb, village or other community or delivery center.", 0, 1, city); 889 case 288961422: /*district*/ return new Property("district", "string", "The name of the administrative area (county).", 0, 1, district); 890 case 109757585: /*state*/ return new Property("state", "string", "Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes).", 0, 1, state); 891 case 2011152728: /*postalCode*/ return new Property("postalCode", "string", "A postal code designating a region defined by the postal service.", 0, 1, postalCode); 892 case 957831062: /*country*/ return new Property("country", "string", "Country - a nation as commonly understood or generally accepted.", 0, 1, country); 893 case -991726143: /*period*/ return new Property("period", "Period", "Time period when address was/is in use.", 0, 1, period); 894 default: return super.getNamedProperty(_hash, _name, _checkValid); 895 } 896 897 } 898 899 @Override 900 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 901 switch (hash) { 902 case 116103: /*use*/ return this.use == null ? new Base[0] : new Base[] {this.use}; // Enumeration<AddressUse> 903 case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // Enumeration<AddressType> 904 case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType 905 case 3321844: /*line*/ return this.line == null ? new Base[0] : this.line.toArray(new Base[this.line.size()]); // StringType 906 case 3053931: /*city*/ return this.city == null ? new Base[0] : new Base[] {this.city}; // StringType 907 case 288961422: /*district*/ return this.district == null ? new Base[0] : new Base[] {this.district}; // StringType 908 case 109757585: /*state*/ return this.state == null ? new Base[0] : new Base[] {this.state}; // StringType 909 case 2011152728: /*postalCode*/ return this.postalCode == null ? new Base[0] : new Base[] {this.postalCode}; // StringType 910 case 957831062: /*country*/ return this.country == null ? new Base[0] : new Base[] {this.country}; // StringType 911 case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period 912 default: return super.getProperty(hash, name, checkValid); 913 } 914 915 } 916 917 @Override 918 public Base setProperty(int hash, String name, Base value) throws FHIRException { 919 switch (hash) { 920 case 116103: // use 921 value = new AddressUseEnumFactory().fromType(castToCode(value)); 922 this.use = (Enumeration) value; // Enumeration<AddressUse> 923 return value; 924 case 3575610: // type 925 value = new AddressTypeEnumFactory().fromType(castToCode(value)); 926 this.type = (Enumeration) value; // Enumeration<AddressType> 927 return value; 928 case 3556653: // text 929 this.text = castToString(value); // StringType 930 return value; 931 case 3321844: // line 932 this.getLine().add(castToString(value)); // StringType 933 return value; 934 case 3053931: // city 935 this.city = castToString(value); // StringType 936 return value; 937 case 288961422: // district 938 this.district = castToString(value); // StringType 939 return value; 940 case 109757585: // state 941 this.state = castToString(value); // StringType 942 return value; 943 case 2011152728: // postalCode 944 this.postalCode = castToString(value); // StringType 945 return value; 946 case 957831062: // country 947 this.country = castToString(value); // StringType 948 return value; 949 case -991726143: // period 950 this.period = castToPeriod(value); // Period 951 return value; 952 default: return super.setProperty(hash, name, value); 953 } 954 955 } 956 957 @Override 958 public Base setProperty(String name, Base value) throws FHIRException { 959 if (name.equals("use")) { 960 value = new AddressUseEnumFactory().fromType(castToCode(value)); 961 this.use = (Enumeration) value; // Enumeration<AddressUse> 962 } else if (name.equals("type")) { 963 value = new AddressTypeEnumFactory().fromType(castToCode(value)); 964 this.type = (Enumeration) value; // Enumeration<AddressType> 965 } else if (name.equals("text")) { 966 this.text = castToString(value); // StringType 967 } else if (name.equals("line")) { 968 this.getLine().add(castToString(value)); 969 } else if (name.equals("city")) { 970 this.city = castToString(value); // StringType 971 } else if (name.equals("district")) { 972 this.district = castToString(value); // StringType 973 } else if (name.equals("state")) { 974 this.state = castToString(value); // StringType 975 } else if (name.equals("postalCode")) { 976 this.postalCode = castToString(value); // StringType 977 } else if (name.equals("country")) { 978 this.country = castToString(value); // StringType 979 } else if (name.equals("period")) { 980 this.period = castToPeriod(value); // Period 981 } else 982 return super.setProperty(name, value); 983 return value; 984 } 985 986 @Override 987 public Base makeProperty(int hash, String name) throws FHIRException { 988 switch (hash) { 989 case 116103: return getUseElement(); 990 case 3575610: return getTypeElement(); 991 case 3556653: return getTextElement(); 992 case 3321844: return addLineElement(); 993 case 3053931: return getCityElement(); 994 case 288961422: return getDistrictElement(); 995 case 109757585: return getStateElement(); 996 case 2011152728: return getPostalCodeElement(); 997 case 957831062: return getCountryElement(); 998 case -991726143: return getPeriod(); 999 default: return super.makeProperty(hash, name); 1000 } 1001 1002 } 1003 1004 @Override 1005 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 1006 switch (hash) { 1007 case 116103: /*use*/ return new String[] {"code"}; 1008 case 3575610: /*type*/ return new String[] {"code"}; 1009 case 3556653: /*text*/ return new String[] {"string"}; 1010 case 3321844: /*line*/ return new String[] {"string"}; 1011 case 3053931: /*city*/ return new String[] {"string"}; 1012 case 288961422: /*district*/ return new String[] {"string"}; 1013 case 109757585: /*state*/ return new String[] {"string"}; 1014 case 2011152728: /*postalCode*/ return new String[] {"string"}; 1015 case 957831062: /*country*/ return new String[] {"string"}; 1016 case -991726143: /*period*/ return new String[] {"Period"}; 1017 default: return super.getTypesForProperty(hash, name); 1018 } 1019 1020 } 1021 1022 @Override 1023 public Base addChild(String name) throws FHIRException { 1024 if (name.equals("use")) { 1025 throw new FHIRException("Cannot call addChild on a primitive type Address.use"); 1026 } 1027 else if (name.equals("type")) { 1028 throw new FHIRException("Cannot call addChild on a primitive type Address.type"); 1029 } 1030 else if (name.equals("text")) { 1031 throw new FHIRException("Cannot call addChild on a primitive type Address.text"); 1032 } 1033 else if (name.equals("line")) { 1034 throw new FHIRException("Cannot call addChild on a primitive type Address.line"); 1035 } 1036 else if (name.equals("city")) { 1037 throw new FHIRException("Cannot call addChild on a primitive type Address.city"); 1038 } 1039 else if (name.equals("district")) { 1040 throw new FHIRException("Cannot call addChild on a primitive type Address.district"); 1041 } 1042 else if (name.equals("state")) { 1043 throw new FHIRException("Cannot call addChild on a primitive type Address.state"); 1044 } 1045 else if (name.equals("postalCode")) { 1046 throw new FHIRException("Cannot call addChild on a primitive type Address.postalCode"); 1047 } 1048 else if (name.equals("country")) { 1049 throw new FHIRException("Cannot call addChild on a primitive type Address.country"); 1050 } 1051 else if (name.equals("period")) { 1052 this.period = new Period(); 1053 return this.period; 1054 } 1055 else 1056 return super.addChild(name); 1057 } 1058 1059 public String fhirType() { 1060 return "Address"; 1061 1062 } 1063 1064 public Address copy() { 1065 Address dst = new Address(); 1066 copyValues(dst); 1067 return dst; 1068 } 1069 1070 public void copyValues(Address dst) { 1071 super.copyValues(dst); 1072 dst.use = use == null ? null : use.copy(); 1073 dst.type = type == null ? null : type.copy(); 1074 dst.text = text == null ? null : text.copy(); 1075 if (line != null) { 1076 dst.line = new ArrayList<StringType>(); 1077 for (StringType i : line) 1078 dst.line.add(i.copy()); 1079 }; 1080 dst.city = city == null ? null : city.copy(); 1081 dst.district = district == null ? null : district.copy(); 1082 dst.state = state == null ? null : state.copy(); 1083 dst.postalCode = postalCode == null ? null : postalCode.copy(); 1084 dst.country = country == null ? null : country.copy(); 1085 dst.period = period == null ? null : period.copy(); 1086 } 1087 1088 protected Address typedCopy() { 1089 return copy(); 1090 } 1091 1092 @Override 1093 public boolean equalsDeep(Base other_) { 1094 if (!super.equalsDeep(other_)) 1095 return false; 1096 if (!(other_ instanceof Address)) 1097 return false; 1098 Address o = (Address) other_; 1099 return compareDeep(use, o.use, true) && compareDeep(type, o.type, true) && compareDeep(text, o.text, true) 1100 && compareDeep(line, o.line, true) && compareDeep(city, o.city, true) && compareDeep(district, o.district, true) 1101 && compareDeep(state, o.state, true) && compareDeep(postalCode, o.postalCode, true) && compareDeep(country, o.country, true) 1102 && compareDeep(period, o.period, true); 1103 } 1104 1105 @Override 1106 public boolean equalsShallow(Base other_) { 1107 if (!super.equalsShallow(other_)) 1108 return false; 1109 if (!(other_ instanceof Address)) 1110 return false; 1111 Address o = (Address) other_; 1112 return compareValues(use, o.use, true) && compareValues(type, o.type, true) && compareValues(text, o.text, true) 1113 && compareValues(line, o.line, true) && compareValues(city, o.city, true) && compareValues(district, o.district, true) 1114 && compareValues(state, o.state, true) && compareValues(postalCode, o.postalCode, true) && compareValues(country, o.country, true) 1115 ; 1116 } 1117 1118 public boolean isEmpty() { 1119 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(use, type, text, line 1120 , city, district, state, postalCode, country, period); 1121 } 1122 1123 1124}