001package org.hl7.fhir.r5.model;
002
003
004/*
005 * #%L
006 * org.hl7.fhir.r5
007 * %%
008 * Copyright (C) 2014 - 2019 Health Level 7
009 * %%
010 * Licensed under the Apache License, Version 2.0 (the \"License\");
011 * you may not use this file except in compliance with the License.
012 * You may obtain a copy of the License at
013 * 
014 *      http://www.apache.org/licenses/LICENSE-2.0
015 * 
016 * Unless required by applicable law or agreed to in writing, software
017 * distributed under the License is distributed on an \"AS IS\" BASIS,
018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
019 * See the License for the specific language governing permissions and
020 * limitations under the License.
021 * #L%
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// Generated on Tue, Dec 31, 2019 12:12+1100 for FHIR vcurrent
053
054import java.util.ArrayList;
055import java.util.Date;
056import java.util.List;
057import org.hl7.fhir.r5.model.Enumerations.*;
058import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
059import org.hl7.fhir.exceptions.FHIRException;
060import org.hl7.fhir.instance.model.api.ICompositeType;
061import ca.uhn.fhir.model.api.annotation.Child;
062import ca.uhn.fhir.model.api.annotation.ChildOrder;
063import ca.uhn.fhir.model.api.annotation.DatatypeDef;
064import ca.uhn.fhir.model.api.annotation.Description;
065import ca.uhn.fhir.model.api.annotation.Block;
066
067/**
068 * Base StructureDefinition for Population Type: A populatioof people with some set of grouping criteria.
069 */
070@DatatypeDef(name="Population")
071public class Population extends BackboneType implements ICompositeType {
072
073    /**
074     * The age of the specific population.
075     */
076    @Child(name = "age", type = {Range.class, CodeableConcept.class}, order=0, min=0, max=1, modifier=false, summary=true)
077    @Description(shortDefinition="The age of the specific population", formalDefinition="The age of the specific population." )
078    protected DataType age;
079
080    /**
081     * The gender of the specific population.
082     */
083    @Child(name = "gender", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
084    @Description(shortDefinition="The gender of the specific population", formalDefinition="The gender of the specific population." )
085    protected CodeableConcept gender;
086
087    /**
088     * Race of the specific population.
089     */
090    @Child(name = "race", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
091    @Description(shortDefinition="Race of the specific population", formalDefinition="Race of the specific population." )
092    protected CodeableConcept race;
093
094    /**
095     * The existing physiological conditions of the specific population to which this applies.
096     */
097    @Child(name = "physiologicalCondition", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
098    @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." )
099    protected CodeableConcept physiologicalCondition;
100
101    private static final long serialVersionUID = -707090134L;
102
103  /**
104   * Constructor
105   */
106    public Population() {
107      super();
108    }
109
110    /**
111     * @return {@link #age} (The age of the specific population.)
112     */
113    public DataType getAge() { 
114      return this.age;
115    }
116
117    /**
118     * @return {@link #age} (The age of the specific population.)
119     */
120    public Range getAgeRange() throws FHIRException { 
121      if (this.age == null)
122        this.age = new Range();
123      if (!(this.age instanceof Range))
124        throw new FHIRException("Type mismatch: the type Range was expected, but "+this.age.getClass().getName()+" was encountered");
125      return (Range) this.age;
126    }
127
128    public boolean hasAgeRange() { 
129      return this != null && this.age instanceof Range;
130    }
131
132    /**
133     * @return {@link #age} (The age of the specific population.)
134     */
135    public CodeableConcept getAgeCodeableConcept() throws FHIRException { 
136      if (this.age == null)
137        this.age = new CodeableConcept();
138      if (!(this.age instanceof CodeableConcept))
139        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.age.getClass().getName()+" was encountered");
140      return (CodeableConcept) this.age;
141    }
142
143    public boolean hasAgeCodeableConcept() { 
144      return this != null && this.age instanceof CodeableConcept;
145    }
146
147    public boolean hasAge() { 
148      return this.age != null && !this.age.isEmpty();
149    }
150
151    /**
152     * @param value {@link #age} (The age of the specific population.)
153     */
154    public Population setAge(DataType value) { 
155      if (value != null && !(value instanceof Range || value instanceof CodeableConcept))
156        throw new Error("Not the right type for Population.age[x]: "+value.fhirType());
157      this.age = value;
158      return this;
159    }
160
161    /**
162     * @return {@link #gender} (The gender of the specific population.)
163     */
164    public CodeableConcept getGender() { 
165      if (this.gender == null)
166        if (Configuration.errorOnAutoCreate())
167          throw new Error("Attempt to auto-create Population.gender");
168        else if (Configuration.doAutoCreate())
169          this.gender = new CodeableConcept(); // cc
170      return this.gender;
171    }
172
173    public boolean hasGender() { 
174      return this.gender != null && !this.gender.isEmpty();
175    }
176
177    /**
178     * @param value {@link #gender} (The gender of the specific population.)
179     */
180    public Population setGender(CodeableConcept value) { 
181      this.gender = value;
182      return this;
183    }
184
185    /**
186     * @return {@link #race} (Race of the specific population.)
187     */
188    public CodeableConcept getRace() { 
189      if (this.race == null)
190        if (Configuration.errorOnAutoCreate())
191          throw new Error("Attempt to auto-create Population.race");
192        else if (Configuration.doAutoCreate())
193          this.race = new CodeableConcept(); // cc
194      return this.race;
195    }
196
197    public boolean hasRace() { 
198      return this.race != null && !this.race.isEmpty();
199    }
200
201    /**
202     * @param value {@link #race} (Race of the specific population.)
203     */
204    public Population setRace(CodeableConcept value) { 
205      this.race = value;
206      return this;
207    }
208
209    /**
210     * @return {@link #physiologicalCondition} (The existing physiological conditions of the specific population to which this applies.)
211     */
212    public CodeableConcept getPhysiologicalCondition() { 
213      if (this.physiologicalCondition == null)
214        if (Configuration.errorOnAutoCreate())
215          throw new Error("Attempt to auto-create Population.physiologicalCondition");
216        else if (Configuration.doAutoCreate())
217          this.physiologicalCondition = new CodeableConcept(); // cc
218      return this.physiologicalCondition;
219    }
220
221    public boolean hasPhysiologicalCondition() { 
222      return this.physiologicalCondition != null && !this.physiologicalCondition.isEmpty();
223    }
224
225    /**
226     * @param value {@link #physiologicalCondition} (The existing physiological conditions of the specific population to which this applies.)
227     */
228    public Population setPhysiologicalCondition(CodeableConcept value) { 
229      this.physiologicalCondition = value;
230      return this;
231    }
232
233      protected void listChildren(List<Property> children) {
234        super.listChildren(children);
235        children.add(new Property("age[x]", "Range|CodeableConcept", "The age of the specific population.", 0, 1, age));
236        children.add(new Property("gender", "CodeableConcept", "The gender of the specific population.", 0, 1, gender));
237        children.add(new Property("race", "CodeableConcept", "Race of the specific population.", 0, 1, race));
238        children.add(new Property("physiologicalCondition", "CodeableConcept", "The existing physiological conditions of the specific population to which this applies.", 0, 1, physiologicalCondition));
239      }
240
241      @Override
242      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
243        switch (_hash) {
244        case -1419716831: /*age[x]*/  return new Property("age[x]", "Range|CodeableConcept", "The age of the specific population.", 0, 1, age);
245        case 96511: /*age*/  return new Property("age[x]", "Range|CodeableConcept", "The age of the specific population.", 0, 1, age);
246        case 1442748286: /*ageRange*/  return new Property("age[x]", "Range", "The age of the specific population.", 0, 1, age);
247        case -1452658526: /*ageCodeableConcept*/  return new Property("age[x]", "CodeableConcept", "The age of the specific population.", 0, 1, age);
248        case -1249512767: /*gender*/  return new Property("gender", "CodeableConcept", "The gender of the specific population.", 0, 1, gender);
249        case 3492561: /*race*/  return new Property("race", "CodeableConcept", "Race of the specific population.", 0, 1, race);
250        case -62715190: /*physiologicalCondition*/  return new Property("physiologicalCondition", "CodeableConcept", "The existing physiological conditions of the specific population to which this applies.", 0, 1, physiologicalCondition);
251        default: return super.getNamedProperty(_hash, _name, _checkValid);
252        }
253
254      }
255
256      @Override
257      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
258        switch (hash) {
259        case 96511: /*age*/ return this.age == null ? new Base[0] : new Base[] {this.age}; // DataType
260        case -1249512767: /*gender*/ return this.gender == null ? new Base[0] : new Base[] {this.gender}; // CodeableConcept
261        case 3492561: /*race*/ return this.race == null ? new Base[0] : new Base[] {this.race}; // CodeableConcept
262        case -62715190: /*physiologicalCondition*/ return this.physiologicalCondition == null ? new Base[0] : new Base[] {this.physiologicalCondition}; // CodeableConcept
263        default: return super.getProperty(hash, name, checkValid);
264        }
265
266      }
267
268      @Override
269      public Base setProperty(int hash, String name, Base value) throws FHIRException {
270        switch (hash) {
271        case 96511: // age
272          this.age = TypeConvertor.castToType(value); // DataType
273          return value;
274        case -1249512767: // gender
275          this.gender = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
276          return value;
277        case 3492561: // race
278          this.race = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
279          return value;
280        case -62715190: // physiologicalCondition
281          this.physiologicalCondition = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
282          return value;
283        default: return super.setProperty(hash, name, value);
284        }
285
286      }
287
288      @Override
289      public Base setProperty(String name, Base value) throws FHIRException {
290        if (name.equals("age[x]")) {
291          this.age = TypeConvertor.castToType(value); // DataType
292        } else if (name.equals("gender")) {
293          this.gender = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
294        } else if (name.equals("race")) {
295          this.race = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
296        } else if (name.equals("physiologicalCondition")) {
297          this.physiologicalCondition = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
298        } else
299          return super.setProperty(name, value);
300        return value;
301      }
302
303      @Override
304      public Base makeProperty(int hash, String name) throws FHIRException {
305        switch (hash) {
306        case -1419716831:  return getAge();
307        case 96511:  return getAge();
308        case -1249512767:  return getGender();
309        case 3492561:  return getRace();
310        case -62715190:  return getPhysiologicalCondition();
311        default: return super.makeProperty(hash, name);
312        }
313
314      }
315
316      @Override
317      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
318        switch (hash) {
319        case 96511: /*age*/ return new String[] {"Range", "CodeableConcept"};
320        case -1249512767: /*gender*/ return new String[] {"CodeableConcept"};
321        case 3492561: /*race*/ return new String[] {"CodeableConcept"};
322        case -62715190: /*physiologicalCondition*/ return new String[] {"CodeableConcept"};
323        default: return super.getTypesForProperty(hash, name);
324        }
325
326      }
327
328      @Override
329      public Base addChild(String name) throws FHIRException {
330        if (name.equals("ageRange")) {
331          this.age = new Range();
332          return this.age;
333        }
334        else if (name.equals("ageCodeableConcept")) {
335          this.age = new CodeableConcept();
336          return this.age;
337        }
338        else if (name.equals("gender")) {
339          this.gender = new CodeableConcept();
340          return this.gender;
341        }
342        else if (name.equals("race")) {
343          this.race = new CodeableConcept();
344          return this.race;
345        }
346        else if (name.equals("physiologicalCondition")) {
347          this.physiologicalCondition = new CodeableConcept();
348          return this.physiologicalCondition;
349        }
350        else
351          return super.addChild(name);
352      }
353
354  public String fhirType() {
355    return "Population";
356
357  }
358
359      public Population copy() {
360        Population dst = new Population();
361        copyValues(dst);
362        return dst;
363      }
364
365      public void copyValues(Population dst) {
366        super.copyValues(dst);
367        dst.age = age == null ? null : age.copy();
368        dst.gender = gender == null ? null : gender.copy();
369        dst.race = race == null ? null : race.copy();
370        dst.physiologicalCondition = physiologicalCondition == null ? null : physiologicalCondition.copy();
371      }
372
373      protected Population typedCopy() {
374        return copy();
375      }
376
377      @Override
378      public boolean equalsDeep(Base other_) {
379        if (!super.equalsDeep(other_))
380          return false;
381        if (!(other_ instanceof Population))
382          return false;
383        Population o = (Population) other_;
384        return compareDeep(age, o.age, true) && compareDeep(gender, o.gender, true) && compareDeep(race, o.race, true)
385           && compareDeep(physiologicalCondition, o.physiologicalCondition, true);
386      }
387
388      @Override
389      public boolean equalsShallow(Base other_) {
390        if (!super.equalsShallow(other_))
391          return false;
392        if (!(other_ instanceof Population))
393          return false;
394        Population o = (Population) other_;
395        return true;
396      }
397
398      public boolean isEmpty() {
399        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(age, gender, race, physiologicalCondition
400          );
401      }
402
403
404}
405