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