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