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