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