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