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