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