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