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