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