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