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