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