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