001package org.hl7.fhir.dstu2.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu2 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023 024/* 025 Copyright (c) 2011+, HL7, Inc. 026 All rights reserved. 027 028 Redistribution and use in source and binary forms, with or without modification, 029 are permitted provided that the following conditions are met: 030 031 * Redistributions of source code must retain the above copyright notice, this 032 list of conditions and the following disclaimer. 033 * Redistributions in binary form must reproduce the above copyright notice, 034 this list of conditions and the following disclaimer in the documentation 035 and/or other materials provided with the distribution. 036 * Neither the name of HL7 nor the names of its contributors may be used to 037 endorse or promote products derived from this software without specific 038 prior written permission. 039 040 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 041 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 042 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 043 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 044 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 045 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 046 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 047 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 048 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 049 POSSIBILITY OF SUCH DAMAGE. 050 051*/ 052 053// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 054import java.util.ArrayList; 055import java.util.List; 056 057import ca.uhn.fhir.model.api.annotation.Child; 058import ca.uhn.fhir.model.api.annotation.DatatypeDef; 059import ca.uhn.fhir.model.api.annotation.Description; 060import org.hl7.fhir.instance.model.api.ICompositeType; 061import org.hl7.fhir.exceptions.FHIRException; 062import org.hl7.fhir.utilities.Utilities; 063/** 064 * There is a variety of postal address formats defined around the world. This format defines a superset that is the basis for all addresses around the world. 065 */ 066@DatatypeDef(name="Address") 067public class Address extends Type implements ICompositeType { 068 069 public enum AddressUse { 070 /** 071 * A communication address at a home. 072 */ 073 HOME, 074 /** 075 * An office address. First choice for business related contacts during business hours. 076 */ 077 WORK, 078 /** 079 * A temporary address. The period can provide more detailed information. 080 */ 081 TEMP, 082 /** 083 * This address is no longer in use (or was never correct, but retained for records). 084 */ 085 OLD, 086 /** 087 * added to help the parsers 088 */ 089 NULL; 090 public static AddressUse fromCode(String codeString) throws FHIRException { 091 if (codeString == null || "".equals(codeString)) 092 return null; 093 if ("home".equals(codeString)) 094 return HOME; 095 if ("work".equals(codeString)) 096 return WORK; 097 if ("temp".equals(codeString)) 098 return TEMP; 099 if ("old".equals(codeString)) 100 return OLD; 101 throw new FHIRException("Unknown AddressUse code '"+codeString+"'"); 102 } 103 public String toCode() { 104 switch (this) { 105 case HOME: return "home"; 106 case WORK: return "work"; 107 case TEMP: return "temp"; 108 case OLD: return "old"; 109 default: return "?"; 110 } 111 } 112 public String getSystem() { 113 switch (this) { 114 case HOME: return "http://hl7.org/fhir/address-use"; 115 case WORK: return "http://hl7.org/fhir/address-use"; 116 case TEMP: return "http://hl7.org/fhir/address-use"; 117 case OLD: return "http://hl7.org/fhir/address-use"; 118 default: return "?"; 119 } 120 } 121 public String getDefinition() { 122 switch (this) { 123 case HOME: return "A communication address at a home."; 124 case WORK: return "An office address. First choice for business related contacts during business hours."; 125 case TEMP: return "A temporary address. The period can provide more detailed information."; 126 case OLD: return "This address is no longer in use (or was never correct, but retained for records)."; 127 default: return "?"; 128 } 129 } 130 public String getDisplay() { 131 switch (this) { 132 case HOME: return "Home"; 133 case WORK: return "Work"; 134 case TEMP: return "Temporary"; 135 case OLD: return "Old / Incorrect"; 136 default: return "?"; 137 } 138 } 139 } 140 141 public static class AddressUseEnumFactory implements EnumFactory<AddressUse> { 142 public AddressUse fromCode(String codeString) throws IllegalArgumentException { 143 if (codeString == null || "".equals(codeString)) 144 if (codeString == null || "".equals(codeString)) 145 return null; 146 if ("home".equals(codeString)) 147 return AddressUse.HOME; 148 if ("work".equals(codeString)) 149 return AddressUse.WORK; 150 if ("temp".equals(codeString)) 151 return AddressUse.TEMP; 152 if ("old".equals(codeString)) 153 return AddressUse.OLD; 154 throw new IllegalArgumentException("Unknown AddressUse code '"+codeString+"'"); 155 } 156 public Enumeration<AddressUse> fromType(Base code) throws FHIRException { 157 if (code == null || code.isEmpty()) 158 return null; 159 String codeString = ((PrimitiveType) code).asStringValue(); 160 if (codeString == null || "".equals(codeString)) 161 return null; 162 if ("home".equals(codeString)) 163 return new Enumeration<AddressUse>(this, AddressUse.HOME); 164 if ("work".equals(codeString)) 165 return new Enumeration<AddressUse>(this, AddressUse.WORK); 166 if ("temp".equals(codeString)) 167 return new Enumeration<AddressUse>(this, AddressUse.TEMP); 168 if ("old".equals(codeString)) 169 return new Enumeration<AddressUse>(this, AddressUse.OLD); 170 throw new FHIRException("Unknown AddressUse code '"+codeString+"'"); 171 } 172 public String toCode(AddressUse code) { 173 if (code == AddressUse.HOME) 174 return "home"; 175 if (code == AddressUse.WORK) 176 return "work"; 177 if (code == AddressUse.TEMP) 178 return "temp"; 179 if (code == AddressUse.OLD) 180 return "old"; 181 return "?"; 182 } 183 } 184 185 public enum AddressType { 186 /** 187 * Mailing addresses - PO Boxes and care-of addresses. 188 */ 189 POSTAL, 190 /** 191 * A physical address that can be visited. 192 */ 193 PHYSICAL, 194 /** 195 * An address that is both physical and postal. 196 */ 197 BOTH, 198 /** 199 * added to help the parsers 200 */ 201 NULL; 202 public static AddressType fromCode(String codeString) throws FHIRException { 203 if (codeString == null || "".equals(codeString)) 204 return null; 205 if ("postal".equals(codeString)) 206 return POSTAL; 207 if ("physical".equals(codeString)) 208 return PHYSICAL; 209 if ("both".equals(codeString)) 210 return BOTH; 211 throw new FHIRException("Unknown AddressType code '"+codeString+"'"); 212 } 213 public String toCode() { 214 switch (this) { 215 case POSTAL: return "postal"; 216 case PHYSICAL: return "physical"; 217 case BOTH: return "both"; 218 default: return "?"; 219 } 220 } 221 public String getSystem() { 222 switch (this) { 223 case POSTAL: return "http://hl7.org/fhir/address-type"; 224 case PHYSICAL: return "http://hl7.org/fhir/address-type"; 225 case BOTH: return "http://hl7.org/fhir/address-type"; 226 default: return "?"; 227 } 228 } 229 public String getDefinition() { 230 switch (this) { 231 case POSTAL: return "Mailing addresses - PO Boxes and care-of addresses."; 232 case PHYSICAL: return "A physical address that can be visited."; 233 case BOTH: return "An address that is both physical and postal."; 234 default: return "?"; 235 } 236 } 237 public String getDisplay() { 238 switch (this) { 239 case POSTAL: return "Postal"; 240 case PHYSICAL: return "Physical"; 241 case BOTH: return "Postal & Physical"; 242 default: return "?"; 243 } 244 } 245 } 246 247 public static class AddressTypeEnumFactory implements EnumFactory<AddressType> { 248 public AddressType fromCode(String codeString) throws IllegalArgumentException { 249 if (codeString == null || "".equals(codeString)) 250 if (codeString == null || "".equals(codeString)) 251 return null; 252 if ("postal".equals(codeString)) 253 return AddressType.POSTAL; 254 if ("physical".equals(codeString)) 255 return AddressType.PHYSICAL; 256 if ("both".equals(codeString)) 257 return AddressType.BOTH; 258 throw new IllegalArgumentException("Unknown AddressType code '"+codeString+"'"); 259 } 260 public Enumeration<AddressType> fromType(Base code) throws FHIRException { 261 if (code == null || code.isEmpty()) 262 return null; 263 String codeString = ((PrimitiveType) code).asStringValue(); 264 if (codeString == null || "".equals(codeString)) 265 return null; 266 if ("postal".equals(codeString)) 267 return new Enumeration<AddressType>(this, AddressType.POSTAL); 268 if ("physical".equals(codeString)) 269 return new Enumeration<AddressType>(this, AddressType.PHYSICAL); 270 if ("both".equals(codeString)) 271 return new Enumeration<AddressType>(this, AddressType.BOTH); 272 throw new FHIRException("Unknown AddressType code '"+codeString+"'"); 273 } 274 public String toCode(AddressType code) { 275 if (code == AddressType.POSTAL) 276 return "postal"; 277 if (code == AddressType.PHYSICAL) 278 return "physical"; 279 if (code == AddressType.BOTH) 280 return "both"; 281 return "?"; 282 } 283 } 284 285 /** 286 * The purpose of this address. 287 */ 288 @Child(name = "use", type = {CodeType.class}, order=0, min=0, max=1, modifier=true, summary=true) 289 @Description(shortDefinition="home | work | temp | old - purpose of this address", formalDefinition="The purpose of this address." ) 290 protected Enumeration<AddressUse> use; 291 292 /** 293 * Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both. 294 */ 295 @Child(name = "type", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true) 296 @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." ) 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 (can be ISO 3166 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 public boolean hasLine() { 521 if (this.line == null) 522 return false; 523 for (StringType item : this.line) 524 if (!item.isEmpty()) 525 return true; 526 return false; 527 } 528 529 /** 530 * @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.) 531 */ 532 // syntactic sugar 533 public StringType addLineElement() {//2 534 StringType t = new StringType(); 535 if (this.line == null) 536 this.line = new ArrayList<StringType>(); 537 this.line.add(t); 538 return t; 539 } 540 541 /** 542 * @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.) 543 */ 544 public Address addLine(String value) { //1 545 StringType t = new StringType(); 546 t.setValue(value); 547 if (this.line == null) 548 this.line = new ArrayList<StringType>(); 549 this.line.add(t); 550 return this; 551 } 552 553 /** 554 * @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.) 555 */ 556 public boolean hasLine(String value) { 557 if (this.line == null) 558 return false; 559 for (StringType v : this.line) 560 if (v.equals(value)) // string 561 return true; 562 return false; 563 } 564 565 /** 566 * @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 567 */ 568 public StringType getCityElement() { 569 if (this.city == null) 570 if (Configuration.errorOnAutoCreate()) 571 throw new Error("Attempt to auto-create Address.city"); 572 else if (Configuration.doAutoCreate()) 573 this.city = new StringType(); // bb 574 return this.city; 575 } 576 577 public boolean hasCityElement() { 578 return this.city != null && !this.city.isEmpty(); 579 } 580 581 public boolean hasCity() { 582 return this.city != null && !this.city.isEmpty(); 583 } 584 585 /** 586 * @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 587 */ 588 public Address setCityElement(StringType value) { 589 this.city = value; 590 return this; 591 } 592 593 /** 594 * @return The name of the city, town, village or other community or delivery center. 595 */ 596 public String getCity() { 597 return this.city == null ? null : this.city.getValue(); 598 } 599 600 /** 601 * @param value The name of the city, town, village or other community or delivery center. 602 */ 603 public Address setCity(String value) { 604 if (Utilities.noString(value)) 605 this.city = null; 606 else { 607 if (this.city == null) 608 this.city = new StringType(); 609 this.city.setValue(value); 610 } 611 return this; 612 } 613 614 /** 615 * @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 616 */ 617 public StringType getDistrictElement() { 618 if (this.district == null) 619 if (Configuration.errorOnAutoCreate()) 620 throw new Error("Attempt to auto-create Address.district"); 621 else if (Configuration.doAutoCreate()) 622 this.district = new StringType(); // bb 623 return this.district; 624 } 625 626 public boolean hasDistrictElement() { 627 return this.district != null && !this.district.isEmpty(); 628 } 629 630 public boolean hasDistrict() { 631 return this.district != null && !this.district.isEmpty(); 632 } 633 634 /** 635 * @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 636 */ 637 public Address setDistrictElement(StringType value) { 638 this.district = value; 639 return this; 640 } 641 642 /** 643 * @return The name of the administrative area (county). 644 */ 645 public String getDistrict() { 646 return this.district == null ? null : this.district.getValue(); 647 } 648 649 /** 650 * @param value The name of the administrative area (county). 651 */ 652 public Address setDistrict(String value) { 653 if (Utilities.noString(value)) 654 this.district = null; 655 else { 656 if (this.district == null) 657 this.district = new StringType(); 658 this.district.setValue(value); 659 } 660 return this; 661 } 662 663 /** 664 * @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 665 */ 666 public StringType getStateElement() { 667 if (this.state == null) 668 if (Configuration.errorOnAutoCreate()) 669 throw new Error("Attempt to auto-create Address.state"); 670 else if (Configuration.doAutoCreate()) 671 this.state = new StringType(); // bb 672 return this.state; 673 } 674 675 public boolean hasStateElement() { 676 return this.state != null && !this.state.isEmpty(); 677 } 678 679 public boolean hasState() { 680 return this.state != null && !this.state.isEmpty(); 681 } 682 683 /** 684 * @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 685 */ 686 public Address setStateElement(StringType value) { 687 this.state = value; 688 return this; 689 } 690 691 /** 692 * @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). 693 */ 694 public String getState() { 695 return this.state == null ? null : this.state.getValue(); 696 } 697 698 /** 699 * @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). 700 */ 701 public Address setState(String value) { 702 if (Utilities.noString(value)) 703 this.state = null; 704 else { 705 if (this.state == null) 706 this.state = new StringType(); 707 this.state.setValue(value); 708 } 709 return this; 710 } 711 712 /** 713 * @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 714 */ 715 public StringType getPostalCodeElement() { 716 if (this.postalCode == null) 717 if (Configuration.errorOnAutoCreate()) 718 throw new Error("Attempt to auto-create Address.postalCode"); 719 else if (Configuration.doAutoCreate()) 720 this.postalCode = new StringType(); // bb 721 return this.postalCode; 722 } 723 724 public boolean hasPostalCodeElement() { 725 return this.postalCode != null && !this.postalCode.isEmpty(); 726 } 727 728 public boolean hasPostalCode() { 729 return this.postalCode != null && !this.postalCode.isEmpty(); 730 } 731 732 /** 733 * @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 734 */ 735 public Address setPostalCodeElement(StringType value) { 736 this.postalCode = value; 737 return this; 738 } 739 740 /** 741 * @return A postal code designating a region defined by the postal service. 742 */ 743 public String getPostalCode() { 744 return this.postalCode == null ? null : this.postalCode.getValue(); 745 } 746 747 /** 748 * @param value A postal code designating a region defined by the postal service. 749 */ 750 public Address setPostalCode(String value) { 751 if (Utilities.noString(value)) 752 this.postalCode = null; 753 else { 754 if (this.postalCode == null) 755 this.postalCode = new StringType(); 756 this.postalCode.setValue(value); 757 } 758 return this; 759 } 760 761 /** 762 * @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 763 */ 764 public StringType getCountryElement() { 765 if (this.country == null) 766 if (Configuration.errorOnAutoCreate()) 767 throw new Error("Attempt to auto-create Address.country"); 768 else if (Configuration.doAutoCreate()) 769 this.country = new StringType(); // bb 770 return this.country; 771 } 772 773 public boolean hasCountryElement() { 774 return this.country != null && !this.country.isEmpty(); 775 } 776 777 public boolean hasCountry() { 778 return this.country != null && !this.country.isEmpty(); 779 } 780 781 /** 782 * @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 783 */ 784 public Address setCountryElement(StringType value) { 785 this.country = value; 786 return this; 787 } 788 789 /** 790 * @return Country - a nation as commonly understood or generally accepted. 791 */ 792 public String getCountry() { 793 return this.country == null ? null : this.country.getValue(); 794 } 795 796 /** 797 * @param value Country - a nation as commonly understood or generally accepted. 798 */ 799 public Address setCountry(String value) { 800 if (Utilities.noString(value)) 801 this.country = null; 802 else { 803 if (this.country == null) 804 this.country = new StringType(); 805 this.country.setValue(value); 806 } 807 return this; 808 } 809 810 /** 811 * @return {@link #period} (Time period when address was/is in use.) 812 */ 813 public Period getPeriod() { 814 if (this.period == null) 815 if (Configuration.errorOnAutoCreate()) 816 throw new Error("Attempt to auto-create Address.period"); 817 else if (Configuration.doAutoCreate()) 818 this.period = new Period(); // cc 819 return this.period; 820 } 821 822 public boolean hasPeriod() { 823 return this.period != null && !this.period.isEmpty(); 824 } 825 826 /** 827 * @param value {@link #period} (Time period when address was/is in use.) 828 */ 829 public Address setPeriod(Period value) { 830 this.period = value; 831 return this; 832 } 833 834 protected void listChildren(List<Property> childrenList) { 835 super.listChildren(childrenList); 836 childrenList.add(new Property("use", "code", "The purpose of this address.", 0, java.lang.Integer.MAX_VALUE, use)); 837 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)); 838 childrenList.add(new Property("text", "string", "A full text representation of the address.", 0, java.lang.Integer.MAX_VALUE, text)); 839 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)); 840 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)); 841 childrenList.add(new Property("district", "string", "The name of the administrative area (county).", 0, java.lang.Integer.MAX_VALUE, district)); 842 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)); 843 childrenList.add(new Property("postalCode", "string", "A postal code designating a region defined by the postal service.", 0, java.lang.Integer.MAX_VALUE, postalCode)); 844 childrenList.add(new Property("country", "string", "Country - a nation as commonly understood or generally accepted.", 0, java.lang.Integer.MAX_VALUE, country)); 845 childrenList.add(new Property("period", "Period", "Time period when address was/is in use.", 0, java.lang.Integer.MAX_VALUE, period)); 846 } 847 848 @Override 849 public void setProperty(String name, Base value) throws FHIRException { 850 if (name.equals("use")) 851 this.use = new AddressUseEnumFactory().fromType(value); // Enumeration<AddressUse> 852 else if (name.equals("type")) 853 this.type = new AddressTypeEnumFactory().fromType(value); // Enumeration<AddressType> 854 else if (name.equals("text")) 855 this.text = castToString(value); // StringType 856 else if (name.equals("line")) 857 this.getLine().add(castToString(value)); 858 else if (name.equals("city")) 859 this.city = castToString(value); // StringType 860 else if (name.equals("district")) 861 this.district = castToString(value); // StringType 862 else if (name.equals("state")) 863 this.state = castToString(value); // StringType 864 else if (name.equals("postalCode")) 865 this.postalCode = castToString(value); // StringType 866 else if (name.equals("country")) 867 this.country = castToString(value); // StringType 868 else if (name.equals("period")) 869 this.period = castToPeriod(value); // Period 870 else 871 super.setProperty(name, value); 872 } 873 874 @Override 875 public Base addChild(String name) throws FHIRException { 876 if (name.equals("use")) { 877 throw new FHIRException("Cannot call addChild on a primitive type Address.use"); 878 } 879 else if (name.equals("type")) { 880 throw new FHIRException("Cannot call addChild on a primitive type Address.type"); 881 } 882 else if (name.equals("text")) { 883 throw new FHIRException("Cannot call addChild on a primitive type Address.text"); 884 } 885 else if (name.equals("line")) { 886 throw new FHIRException("Cannot call addChild on a primitive type Address.line"); 887 } 888 else if (name.equals("city")) { 889 throw new FHIRException("Cannot call addChild on a primitive type Address.city"); 890 } 891 else if (name.equals("district")) { 892 throw new FHIRException("Cannot call addChild on a primitive type Address.district"); 893 } 894 else if (name.equals("state")) { 895 throw new FHIRException("Cannot call addChild on a primitive type Address.state"); 896 } 897 else if (name.equals("postalCode")) { 898 throw new FHIRException("Cannot call addChild on a primitive type Address.postalCode"); 899 } 900 else if (name.equals("country")) { 901 throw new FHIRException("Cannot call addChild on a primitive type Address.country"); 902 } 903 else if (name.equals("period")) { 904 this.period = new Period(); 905 return this.period; 906 } 907 else 908 return super.addChild(name); 909 } 910 911 public String fhirType() { 912 return "Address"; 913 914 } 915 916 public Address copy() { 917 Address dst = new Address(); 918 copyValues(dst); 919 dst.use = use == null ? null : use.copy(); 920 dst.type = type == null ? null : type.copy(); 921 dst.text = text == null ? null : text.copy(); 922 if (line != null) { 923 dst.line = new ArrayList<StringType>(); 924 for (StringType i : line) 925 dst.line.add(i.copy()); 926 }; 927 dst.city = city == null ? null : city.copy(); 928 dst.district = district == null ? null : district.copy(); 929 dst.state = state == null ? null : state.copy(); 930 dst.postalCode = postalCode == null ? null : postalCode.copy(); 931 dst.country = country == null ? null : country.copy(); 932 dst.period = period == null ? null : period.copy(); 933 return dst; 934 } 935 936 protected Address typedCopy() { 937 return copy(); 938 } 939 940 @Override 941 public boolean equalsDeep(Base other) { 942 if (!super.equalsDeep(other)) 943 return false; 944 if (!(other instanceof Address)) 945 return false; 946 Address o = (Address) other; 947 return compareDeep(use, o.use, true) && compareDeep(type, o.type, true) && compareDeep(text, o.text, true) 948 && compareDeep(line, o.line, true) && compareDeep(city, o.city, true) && compareDeep(district, o.district, true) 949 && compareDeep(state, o.state, true) && compareDeep(postalCode, o.postalCode, true) && compareDeep(country, o.country, true) 950 && compareDeep(period, o.period, true); 951 } 952 953 @Override 954 public boolean equalsShallow(Base other) { 955 if (!super.equalsShallow(other)) 956 return false; 957 if (!(other instanceof Address)) 958 return false; 959 Address o = (Address) other; 960 return compareValues(use, o.use, true) && compareValues(type, o.type, true) && compareValues(text, o.text, true) 961 && compareValues(line, o.line, true) && compareValues(city, o.city, true) && compareValues(district, o.district, true) 962 && compareValues(state, o.state, true) && compareValues(postalCode, o.postalCode, true) && compareValues(country, o.country, true) 963 ; 964 } 965 966 public boolean isEmpty() { 967 return super.isEmpty() && (use == null || use.isEmpty()) && (type == null || type.isEmpty()) 968 && (text == null || text.isEmpty()) && (line == null || line.isEmpty()) && (city == null || city.isEmpty()) 969 && (district == null || district.isEmpty()) && (state == null || state.isEmpty()) && (postalCode == null || postalCode.isEmpty()) 970 && (country == null || country.isEmpty()) && (period == null || period.isEmpty()); 971 } 972 973 974} 975