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