001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.DatatypeDef;
043import ca.uhn.fhir.model.api.annotation.Block;
044import org.hl7.fhir.instance.model.api.*;
045import org.hl7.fhir.exceptions.FHIRException;
046/**
047 * A populatioof people with some set of grouping criteria.
048 */
049@DatatypeDef(name="Population")
050public class Population extends BackboneType implements ICompositeType {
051
052    /**
053     * The age of the specific population.
054     */
055    @Child(name = "age", type = {Range.class, CodeableConcept.class}, order=0, min=0, max=1, modifier=false, summary=true)
056    @Description(shortDefinition="The age of the specific population", formalDefinition="The age of the specific population." )
057    protected Type age;
058
059    /**
060     * The gender of the specific population.
061     */
062    @Child(name = "gender", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
063    @Description(shortDefinition="The gender of the specific population", formalDefinition="The gender of the specific population." )
064    protected CodeableConcept gender;
065
066    /**
067     * Race of the specific population.
068     */
069    @Child(name = "race", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
070    @Description(shortDefinition="Race of the specific population", formalDefinition="Race of the specific population." )
071    protected CodeableConcept race;
072
073    /**
074     * The existing physiological conditions of the specific population to which this applies.
075     */
076    @Child(name = "physiologicalCondition", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
077    @Description(shortDefinition="The existing physiological conditions of the specific population to which this applies", formalDefinition="The existing physiological conditions of the specific population to which this applies." )
078    protected CodeableConcept physiologicalCondition;
079
080    private static final long serialVersionUID = 495777760L;
081
082  /**
083   * Constructor
084   */
085    public Population() {
086      super();
087    }
088
089    /**
090     * @return {@link #age} (The age of the specific population.)
091     */
092    public Type getAge() { 
093      return this.age;
094    }
095
096    /**
097     * @return {@link #age} (The age of the specific population.)
098     */
099    public Range getAgeRange() throws FHIRException { 
100      if (this.age == null)
101        this.age = new Range();
102      if (!(this.age instanceof Range))
103        throw new FHIRException("Type mismatch: the type Range was expected, but "+this.age.getClass().getName()+" was encountered");
104      return (Range) this.age;
105    }
106
107    public boolean hasAgeRange() { 
108      return this != null && this.age instanceof Range;
109    }
110
111    /**
112     * @return {@link #age} (The age of the specific population.)
113     */
114    public CodeableConcept getAgeCodeableConcept() throws FHIRException { 
115      if (this.age == null)
116        this.age = new CodeableConcept();
117      if (!(this.age instanceof CodeableConcept))
118        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.age.getClass().getName()+" was encountered");
119      return (CodeableConcept) this.age;
120    }
121
122    public boolean hasAgeCodeableConcept() { 
123      return this != null && this.age instanceof CodeableConcept;
124    }
125
126    public boolean hasAge() { 
127      return this.age != null && !this.age.isEmpty();
128    }
129
130    /**
131     * @param value {@link #age} (The age of the specific population.)
132     */
133    public Population setAge(Type value) { 
134      if (value != null && !(value instanceof Range || value instanceof CodeableConcept))
135        throw new Error("Not the right type for Population.age[x]: "+value.fhirType());
136      this.age = value;
137      return this;
138    }
139
140    /**
141     * @return {@link #gender} (The gender of the specific population.)
142     */
143    public CodeableConcept getGender() { 
144      if (this.gender == null)
145        if (Configuration.errorOnAutoCreate())
146          throw new Error("Attempt to auto-create Population.gender");
147        else if (Configuration.doAutoCreate())
148          this.gender = new CodeableConcept(); // cc
149      return this.gender;
150    }
151
152    public boolean hasGender() { 
153      return this.gender != null && !this.gender.isEmpty();
154    }
155
156    /**
157     * @param value {@link #gender} (The gender of the specific population.)
158     */
159    public Population setGender(CodeableConcept value) { 
160      this.gender = value;
161      return this;
162    }
163
164    /**
165     * @return {@link #race} (Race of the specific population.)
166     */
167    public CodeableConcept getRace() { 
168      if (this.race == null)
169        if (Configuration.errorOnAutoCreate())
170          throw new Error("Attempt to auto-create Population.race");
171        else if (Configuration.doAutoCreate())
172          this.race = new CodeableConcept(); // cc
173      return this.race;
174    }
175
176    public boolean hasRace() { 
177      return this.race != null && !this.race.isEmpty();
178    }
179
180    /**
181     * @param value {@link #race} (Race of the specific population.)
182     */
183    public Population setRace(CodeableConcept value) { 
184      this.race = value;
185      return this;
186    }
187
188    /**
189     * @return {@link #physiologicalCondition} (The existing physiological conditions of the specific population to which this applies.)
190     */
191    public CodeableConcept getPhysiologicalCondition() { 
192      if (this.physiologicalCondition == null)
193        if (Configuration.errorOnAutoCreate())
194          throw new Error("Attempt to auto-create Population.physiologicalCondition");
195        else if (Configuration.doAutoCreate())
196          this.physiologicalCondition = new CodeableConcept(); // cc
197      return this.physiologicalCondition;
198    }
199
200    public boolean hasPhysiologicalCondition() { 
201      return this.physiologicalCondition != null && !this.physiologicalCondition.isEmpty();
202    }
203
204    /**
205     * @param value {@link #physiologicalCondition} (The existing physiological conditions of the specific population to which this applies.)
206     */
207    public Population setPhysiologicalCondition(CodeableConcept value) { 
208      this.physiologicalCondition = value;
209      return this;
210    }
211
212      protected void listChildren(List<Property> children) {
213        super.listChildren(children);
214        children.add(new Property("age[x]", "Range|CodeableConcept", "The age of the specific population.", 0, 1, age));
215        children.add(new Property("gender", "CodeableConcept", "The gender of the specific population.", 0, 1, gender));
216        children.add(new Property("race", "CodeableConcept", "Race of the specific population.", 0, 1, race));
217        children.add(new Property("physiologicalCondition", "CodeableConcept", "The existing physiological conditions of the specific population to which this applies.", 0, 1, physiologicalCondition));
218      }
219
220      @Override
221      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
222        switch (_hash) {
223        case -1419716831: /*age[x]*/  return new Property("age[x]", "Range|CodeableConcept", "The age of the specific population.", 0, 1, age);
224        case 96511: /*age*/  return new Property("age[x]", "Range|CodeableConcept", "The age of the specific population.", 0, 1, age);
225        case 1442748286: /*ageRange*/  return new Property("age[x]", "Range|CodeableConcept", "The age of the specific population.", 0, 1, age);
226        case -1452658526: /*ageCodeableConcept*/  return new Property("age[x]", "Range|CodeableConcept", "The age of the specific population.", 0, 1, age);
227        case -1249512767: /*gender*/  return new Property("gender", "CodeableConcept", "The gender of the specific population.", 0, 1, gender);
228        case 3492561: /*race*/  return new Property("race", "CodeableConcept", "Race of the specific population.", 0, 1, race);
229        case -62715190: /*physiologicalCondition*/  return new Property("physiologicalCondition", "CodeableConcept", "The existing physiological conditions of the specific population to which this applies.", 0, 1, physiologicalCondition);
230        default: return super.getNamedProperty(_hash, _name, _checkValid);
231        }
232
233      }
234
235      @Override
236      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
237        switch (hash) {
238        case 96511: /*age*/ return this.age == null ? new Base[0] : new Base[] {this.age}; // Type
239        case -1249512767: /*gender*/ return this.gender == null ? new Base[0] : new Base[] {this.gender}; // CodeableConcept
240        case 3492561: /*race*/ return this.race == null ? new Base[0] : new Base[] {this.race}; // CodeableConcept
241        case -62715190: /*physiologicalCondition*/ return this.physiologicalCondition == null ? new Base[0] : new Base[] {this.physiologicalCondition}; // CodeableConcept
242        default: return super.getProperty(hash, name, checkValid);
243        }
244
245      }
246
247      @Override
248      public Base setProperty(int hash, String name, Base value) throws FHIRException {
249        switch (hash) {
250        case 96511: // age
251          this.age = castToType(value); // Type
252          return value;
253        case -1249512767: // gender
254          this.gender = castToCodeableConcept(value); // CodeableConcept
255          return value;
256        case 3492561: // race
257          this.race = castToCodeableConcept(value); // CodeableConcept
258          return value;
259        case -62715190: // physiologicalCondition
260          this.physiologicalCondition = castToCodeableConcept(value); // CodeableConcept
261          return value;
262        default: return super.setProperty(hash, name, value);
263        }
264
265      }
266
267      @Override
268      public Base setProperty(String name, Base value) throws FHIRException {
269        if (name.equals("age[x]")) {
270          this.age = castToType(value); // Type
271        } else if (name.equals("gender")) {
272          this.gender = castToCodeableConcept(value); // CodeableConcept
273        } else if (name.equals("race")) {
274          this.race = castToCodeableConcept(value); // CodeableConcept
275        } else if (name.equals("physiologicalCondition")) {
276          this.physiologicalCondition = castToCodeableConcept(value); // CodeableConcept
277        } else
278          return super.setProperty(name, value);
279        return value;
280      }
281
282      @Override
283      public Base makeProperty(int hash, String name) throws FHIRException {
284        switch (hash) {
285        case -1419716831:  return getAge(); 
286        case 96511:  return getAge(); 
287        case -1249512767:  return getGender(); 
288        case 3492561:  return getRace(); 
289        case -62715190:  return getPhysiologicalCondition(); 
290        default: return super.makeProperty(hash, name);
291        }
292
293      }
294
295      @Override
296      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
297        switch (hash) {
298        case 96511: /*age*/ return new String[] {"Range", "CodeableConcept"};
299        case -1249512767: /*gender*/ return new String[] {"CodeableConcept"};
300        case 3492561: /*race*/ return new String[] {"CodeableConcept"};
301        case -62715190: /*physiologicalCondition*/ return new String[] {"CodeableConcept"};
302        default: return super.getTypesForProperty(hash, name);
303        }
304
305      }
306
307      @Override
308      public Base addChild(String name) throws FHIRException {
309        if (name.equals("ageRange")) {
310          this.age = new Range();
311          return this.age;
312        }
313        else if (name.equals("ageCodeableConcept")) {
314          this.age = new CodeableConcept();
315          return this.age;
316        }
317        else if (name.equals("gender")) {
318          this.gender = new CodeableConcept();
319          return this.gender;
320        }
321        else if (name.equals("race")) {
322          this.race = new CodeableConcept();
323          return this.race;
324        }
325        else if (name.equals("physiologicalCondition")) {
326          this.physiologicalCondition = new CodeableConcept();
327          return this.physiologicalCondition;
328        }
329        else
330          return super.addChild(name);
331      }
332
333  public String fhirType() {
334    return "Population";
335
336  }
337
338      public Population copy() {
339        Population dst = new Population();
340        copyValues(dst);
341        return dst;
342      }
343
344      public void copyValues(Population dst) {
345        super.copyValues(dst);
346        dst.age = age == null ? null : age.copy();
347        dst.gender = gender == null ? null : gender.copy();
348        dst.race = race == null ? null : race.copy();
349        dst.physiologicalCondition = physiologicalCondition == null ? null : physiologicalCondition.copy();
350      }
351
352      protected Population typedCopy() {
353        return copy();
354      }
355
356      @Override
357      public boolean equalsDeep(Base other_) {
358        if (!super.equalsDeep(other_))
359          return false;
360        if (!(other_ instanceof Population))
361          return false;
362        Population o = (Population) other_;
363        return compareDeep(age, o.age, true) && compareDeep(gender, o.gender, true) && compareDeep(race, o.race, true)
364           && compareDeep(physiologicalCondition, o.physiologicalCondition, true);
365      }
366
367      @Override
368      public boolean equalsShallow(Base other_) {
369        if (!super.equalsShallow(other_))
370          return false;
371        if (!(other_ instanceof Population))
372          return false;
373        Population o = (Population) other_;
374        return true;
375      }
376
377      public boolean isEmpty() {
378        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(age, gender, race, physiologicalCondition
379          );
380      }
381
382
383}