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