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