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.ResourceDef; 037import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 038import ca.uhn.fhir.model.api.annotation.Child; 039import ca.uhn.fhir.model.api.annotation.ChildOrder; 040import ca.uhn.fhir.model.api.annotation.Description; 041import ca.uhn.fhir.model.api.annotation.Block; 042import org.hl7.fhir.instance.model.api.*; 043import org.hl7.fhir.exceptions.FHIRException; 044/** 045 * Describe the undesirable effects of the medicinal product. 046 */ 047@ResourceDef(name="MedicinalProductUndesirableEffect", profile="http://hl7.org/fhir/StructureDefinition/MedicinalProductUndesirableEffect") 048public class MedicinalProductUndesirableEffect extends DomainResource { 049 050 /** 051 * The medication for which this is an indication. 052 */ 053 @Child(name = "subject", type = {MedicinalProduct.class, Medication.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 054 @Description(shortDefinition="The medication for which this is an indication", formalDefinition="The medication for which this is an indication." ) 055 protected List<Reference> subject; 056 /** 057 * The actual objects that are the target of the reference (The medication for which this is an indication.) 058 */ 059 protected List<Resource> subjectTarget; 060 061 062 /** 063 * The symptom, condition or undesirable effect. 064 */ 065 @Child(name = "symptomConditionEffect", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true) 066 @Description(shortDefinition="The symptom, condition or undesirable effect", formalDefinition="The symptom, condition or undesirable effect." ) 067 protected CodeableConcept symptomConditionEffect; 068 069 /** 070 * Classification of the effect. 071 */ 072 @Child(name = "classification", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true) 073 @Description(shortDefinition="Classification of the effect", formalDefinition="Classification of the effect." ) 074 protected CodeableConcept classification; 075 076 /** 077 * The frequency of occurrence of the effect. 078 */ 079 @Child(name = "frequencyOfOccurrence", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true) 080 @Description(shortDefinition="The frequency of occurrence of the effect", formalDefinition="The frequency of occurrence of the effect." ) 081 protected CodeableConcept frequencyOfOccurrence; 082 083 /** 084 * The population group to which this applies. 085 */ 086 @Child(name = "population", type = {Population.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 087 @Description(shortDefinition="The population group to which this applies", formalDefinition="The population group to which this applies." ) 088 protected List<Population> population; 089 090 private static final long serialVersionUID = -1960253956L; 091 092 /** 093 * Constructor 094 */ 095 public MedicinalProductUndesirableEffect() { 096 super(); 097 } 098 099 /** 100 * @return {@link #subject} (The medication for which this is an indication.) 101 */ 102 public List<Reference> getSubject() { 103 if (this.subject == null) 104 this.subject = new ArrayList<Reference>(); 105 return this.subject; 106 } 107 108 /** 109 * @return Returns a reference to <code>this</code> for easy method chaining 110 */ 111 public MedicinalProductUndesirableEffect setSubject(List<Reference> theSubject) { 112 this.subject = theSubject; 113 return this; 114 } 115 116 public boolean hasSubject() { 117 if (this.subject == null) 118 return false; 119 for (Reference item : this.subject) 120 if (!item.isEmpty()) 121 return true; 122 return false; 123 } 124 125 public Reference addSubject() { //3 126 Reference t = new Reference(); 127 if (this.subject == null) 128 this.subject = new ArrayList<Reference>(); 129 this.subject.add(t); 130 return t; 131 } 132 133 public MedicinalProductUndesirableEffect addSubject(Reference t) { //3 134 if (t == null) 135 return this; 136 if (this.subject == null) 137 this.subject = new ArrayList<Reference>(); 138 this.subject.add(t); 139 return this; 140 } 141 142 /** 143 * @return The first repetition of repeating field {@link #subject}, creating it if it does not already exist 144 */ 145 public Reference getSubjectFirstRep() { 146 if (getSubject().isEmpty()) { 147 addSubject(); 148 } 149 return getSubject().get(0); 150 } 151 152 /** 153 * @deprecated Use Reference#setResource(IBaseResource) instead 154 */ 155 @Deprecated 156 public List<Resource> getSubjectTarget() { 157 if (this.subjectTarget == null) 158 this.subjectTarget = new ArrayList<Resource>(); 159 return this.subjectTarget; 160 } 161 162 /** 163 * @return {@link #symptomConditionEffect} (The symptom, condition or undesirable effect.) 164 */ 165 public CodeableConcept getSymptomConditionEffect() { 166 if (this.symptomConditionEffect == null) 167 if (Configuration.errorOnAutoCreate()) 168 throw new Error("Attempt to auto-create MedicinalProductUndesirableEffect.symptomConditionEffect"); 169 else if (Configuration.doAutoCreate()) 170 this.symptomConditionEffect = new CodeableConcept(); // cc 171 return this.symptomConditionEffect; 172 } 173 174 public boolean hasSymptomConditionEffect() { 175 return this.symptomConditionEffect != null && !this.symptomConditionEffect.isEmpty(); 176 } 177 178 /** 179 * @param value {@link #symptomConditionEffect} (The symptom, condition or undesirable effect.) 180 */ 181 public MedicinalProductUndesirableEffect setSymptomConditionEffect(CodeableConcept value) { 182 this.symptomConditionEffect = value; 183 return this; 184 } 185 186 /** 187 * @return {@link #classification} (Classification of the effect.) 188 */ 189 public CodeableConcept getClassification() { 190 if (this.classification == null) 191 if (Configuration.errorOnAutoCreate()) 192 throw new Error("Attempt to auto-create MedicinalProductUndesirableEffect.classification"); 193 else if (Configuration.doAutoCreate()) 194 this.classification = new CodeableConcept(); // cc 195 return this.classification; 196 } 197 198 public boolean hasClassification() { 199 return this.classification != null && !this.classification.isEmpty(); 200 } 201 202 /** 203 * @param value {@link #classification} (Classification of the effect.) 204 */ 205 public MedicinalProductUndesirableEffect setClassification(CodeableConcept value) { 206 this.classification = value; 207 return this; 208 } 209 210 /** 211 * @return {@link #frequencyOfOccurrence} (The frequency of occurrence of the effect.) 212 */ 213 public CodeableConcept getFrequencyOfOccurrence() { 214 if (this.frequencyOfOccurrence == null) 215 if (Configuration.errorOnAutoCreate()) 216 throw new Error("Attempt to auto-create MedicinalProductUndesirableEffect.frequencyOfOccurrence"); 217 else if (Configuration.doAutoCreate()) 218 this.frequencyOfOccurrence = new CodeableConcept(); // cc 219 return this.frequencyOfOccurrence; 220 } 221 222 public boolean hasFrequencyOfOccurrence() { 223 return this.frequencyOfOccurrence != null && !this.frequencyOfOccurrence.isEmpty(); 224 } 225 226 /** 227 * @param value {@link #frequencyOfOccurrence} (The frequency of occurrence of the effect.) 228 */ 229 public MedicinalProductUndesirableEffect setFrequencyOfOccurrence(CodeableConcept value) { 230 this.frequencyOfOccurrence = value; 231 return this; 232 } 233 234 /** 235 * @return {@link #population} (The population group to which this applies.) 236 */ 237 public List<Population> getPopulation() { 238 if (this.population == null) 239 this.population = new ArrayList<Population>(); 240 return this.population; 241 } 242 243 /** 244 * @return Returns a reference to <code>this</code> for easy method chaining 245 */ 246 public MedicinalProductUndesirableEffect setPopulation(List<Population> thePopulation) { 247 this.population = thePopulation; 248 return this; 249 } 250 251 public boolean hasPopulation() { 252 if (this.population == null) 253 return false; 254 for (Population item : this.population) 255 if (!item.isEmpty()) 256 return true; 257 return false; 258 } 259 260 public Population addPopulation() { //3 261 Population t = new Population(); 262 if (this.population == null) 263 this.population = new ArrayList<Population>(); 264 this.population.add(t); 265 return t; 266 } 267 268 public MedicinalProductUndesirableEffect addPopulation(Population t) { //3 269 if (t == null) 270 return this; 271 if (this.population == null) 272 this.population = new ArrayList<Population>(); 273 this.population.add(t); 274 return this; 275 } 276 277 /** 278 * @return The first repetition of repeating field {@link #population}, creating it if it does not already exist 279 */ 280 public Population getPopulationFirstRep() { 281 if (getPopulation().isEmpty()) { 282 addPopulation(); 283 } 284 return getPopulation().get(0); 285 } 286 287 protected void listChildren(List<Property> children) { 288 super.listChildren(children); 289 children.add(new Property("subject", "Reference(MedicinalProduct|Medication)", "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject)); 290 children.add(new Property("symptomConditionEffect", "CodeableConcept", "The symptom, condition or undesirable effect.", 0, 1, symptomConditionEffect)); 291 children.add(new Property("classification", "CodeableConcept", "Classification of the effect.", 0, 1, classification)); 292 children.add(new Property("frequencyOfOccurrence", "CodeableConcept", "The frequency of occurrence of the effect.", 0, 1, frequencyOfOccurrence)); 293 children.add(new Property("population", "Population", "The population group to which this applies.", 0, java.lang.Integer.MAX_VALUE, population)); 294 } 295 296 @Override 297 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 298 switch (_hash) { 299 case -1867885268: /*subject*/ return new Property("subject", "Reference(MedicinalProduct|Medication)", "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject); 300 case -650549981: /*symptomConditionEffect*/ return new Property("symptomConditionEffect", "CodeableConcept", "The symptom, condition or undesirable effect.", 0, 1, symptomConditionEffect); 301 case 382350310: /*classification*/ return new Property("classification", "CodeableConcept", "Classification of the effect.", 0, 1, classification); 302 case 791175812: /*frequencyOfOccurrence*/ return new Property("frequencyOfOccurrence", "CodeableConcept", "The frequency of occurrence of the effect.", 0, 1, frequencyOfOccurrence); 303 case -2023558323: /*population*/ return new Property("population", "Population", "The population group to which this applies.", 0, java.lang.Integer.MAX_VALUE, population); 304 default: return super.getNamedProperty(_hash, _name, _checkValid); 305 } 306 307 } 308 309 @Override 310 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 311 switch (hash) { 312 case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : this.subject.toArray(new Base[this.subject.size()]); // Reference 313 case -650549981: /*symptomConditionEffect*/ return this.symptomConditionEffect == null ? new Base[0] : new Base[] {this.symptomConditionEffect}; // CodeableConcept 314 case 382350310: /*classification*/ return this.classification == null ? new Base[0] : new Base[] {this.classification}; // CodeableConcept 315 case 791175812: /*frequencyOfOccurrence*/ return this.frequencyOfOccurrence == null ? new Base[0] : new Base[] {this.frequencyOfOccurrence}; // CodeableConcept 316 case -2023558323: /*population*/ return this.population == null ? new Base[0] : this.population.toArray(new Base[this.population.size()]); // Population 317 default: return super.getProperty(hash, name, checkValid); 318 } 319 320 } 321 322 @Override 323 public Base setProperty(int hash, String name, Base value) throws FHIRException { 324 switch (hash) { 325 case -1867885268: // subject 326 this.getSubject().add(castToReference(value)); // Reference 327 return value; 328 case -650549981: // symptomConditionEffect 329 this.symptomConditionEffect = castToCodeableConcept(value); // CodeableConcept 330 return value; 331 case 382350310: // classification 332 this.classification = castToCodeableConcept(value); // CodeableConcept 333 return value; 334 case 791175812: // frequencyOfOccurrence 335 this.frequencyOfOccurrence = castToCodeableConcept(value); // CodeableConcept 336 return value; 337 case -2023558323: // population 338 this.getPopulation().add(castToPopulation(value)); // Population 339 return value; 340 default: return super.setProperty(hash, name, value); 341 } 342 343 } 344 345 @Override 346 public Base setProperty(String name, Base value) throws FHIRException { 347 if (name.equals("subject")) { 348 this.getSubject().add(castToReference(value)); 349 } else if (name.equals("symptomConditionEffect")) { 350 this.symptomConditionEffect = castToCodeableConcept(value); // CodeableConcept 351 } else if (name.equals("classification")) { 352 this.classification = castToCodeableConcept(value); // CodeableConcept 353 } else if (name.equals("frequencyOfOccurrence")) { 354 this.frequencyOfOccurrence = castToCodeableConcept(value); // CodeableConcept 355 } else if (name.equals("population")) { 356 this.getPopulation().add(castToPopulation(value)); 357 } else 358 return super.setProperty(name, value); 359 return value; 360 } 361 362 @Override 363 public Base makeProperty(int hash, String name) throws FHIRException { 364 switch (hash) { 365 case -1867885268: return addSubject(); 366 case -650549981: return getSymptomConditionEffect(); 367 case 382350310: return getClassification(); 368 case 791175812: return getFrequencyOfOccurrence(); 369 case -2023558323: return addPopulation(); 370 default: return super.makeProperty(hash, name); 371 } 372 373 } 374 375 @Override 376 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 377 switch (hash) { 378 case -1867885268: /*subject*/ return new String[] {"Reference"}; 379 case -650549981: /*symptomConditionEffect*/ return new String[] {"CodeableConcept"}; 380 case 382350310: /*classification*/ return new String[] {"CodeableConcept"}; 381 case 791175812: /*frequencyOfOccurrence*/ return new String[] {"CodeableConcept"}; 382 case -2023558323: /*population*/ return new String[] {"Population"}; 383 default: return super.getTypesForProperty(hash, name); 384 } 385 386 } 387 388 @Override 389 public Base addChild(String name) throws FHIRException { 390 if (name.equals("subject")) { 391 return addSubject(); 392 } 393 else if (name.equals("symptomConditionEffect")) { 394 this.symptomConditionEffect = new CodeableConcept(); 395 return this.symptomConditionEffect; 396 } 397 else if (name.equals("classification")) { 398 this.classification = new CodeableConcept(); 399 return this.classification; 400 } 401 else if (name.equals("frequencyOfOccurrence")) { 402 this.frequencyOfOccurrence = new CodeableConcept(); 403 return this.frequencyOfOccurrence; 404 } 405 else if (name.equals("population")) { 406 return addPopulation(); 407 } 408 else 409 return super.addChild(name); 410 } 411 412 public String fhirType() { 413 return "MedicinalProductUndesirableEffect"; 414 415 } 416 417 public MedicinalProductUndesirableEffect copy() { 418 MedicinalProductUndesirableEffect dst = new MedicinalProductUndesirableEffect(); 419 copyValues(dst); 420 if (subject != null) { 421 dst.subject = new ArrayList<Reference>(); 422 for (Reference i : subject) 423 dst.subject.add(i.copy()); 424 }; 425 dst.symptomConditionEffect = symptomConditionEffect == null ? null : symptomConditionEffect.copy(); 426 dst.classification = classification == null ? null : classification.copy(); 427 dst.frequencyOfOccurrence = frequencyOfOccurrence == null ? null : frequencyOfOccurrence.copy(); 428 if (population != null) { 429 dst.population = new ArrayList<Population>(); 430 for (Population i : population) 431 dst.population.add(i.copy()); 432 }; 433 return dst; 434 } 435 436 protected MedicinalProductUndesirableEffect typedCopy() { 437 return copy(); 438 } 439 440 @Override 441 public boolean equalsDeep(Base other_) { 442 if (!super.equalsDeep(other_)) 443 return false; 444 if (!(other_ instanceof MedicinalProductUndesirableEffect)) 445 return false; 446 MedicinalProductUndesirableEffect o = (MedicinalProductUndesirableEffect) other_; 447 return compareDeep(subject, o.subject, true) && compareDeep(symptomConditionEffect, o.symptomConditionEffect, true) 448 && compareDeep(classification, o.classification, true) && compareDeep(frequencyOfOccurrence, o.frequencyOfOccurrence, true) 449 && compareDeep(population, o.population, true); 450 } 451 452 @Override 453 public boolean equalsShallow(Base other_) { 454 if (!super.equalsShallow(other_)) 455 return false; 456 if (!(other_ instanceof MedicinalProductUndesirableEffect)) 457 return false; 458 MedicinalProductUndesirableEffect o = (MedicinalProductUndesirableEffect) other_; 459 return true; 460 } 461 462 public boolean isEmpty() { 463 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(subject, symptomConditionEffect 464 , classification, frequencyOfOccurrence, population); 465 } 466 467 @Override 468 public ResourceType getResourceType() { 469 return ResourceType.MedicinalProductUndesirableEffect; 470 } 471 472 /** 473 * Search parameter: <b>subject</b> 474 * <p> 475 * Description: <b>The medication for which this is an undesirable effect</b><br> 476 * Type: <b>reference</b><br> 477 * Path: <b>MedicinalProductUndesirableEffect.subject</b><br> 478 * </p> 479 */ 480 @SearchParamDefinition(name="subject", path="MedicinalProductUndesirableEffect.subject", description="The medication for which this is an undesirable effect", type="reference", target={Medication.class, MedicinalProduct.class } ) 481 public static final String SP_SUBJECT = "subject"; 482 /** 483 * <b>Fluent Client</b> search parameter constant for <b>subject</b> 484 * <p> 485 * Description: <b>The medication for which this is an undesirable effect</b><br> 486 * Type: <b>reference</b><br> 487 * Path: <b>MedicinalProductUndesirableEffect.subject</b><br> 488 * </p> 489 */ 490 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT); 491 492/** 493 * Constant for fluent queries to be used to add include statements. Specifies 494 * the path value of "<b>MedicinalProductUndesirableEffect:subject</b>". 495 */ 496 public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicinalProductUndesirableEffect:subject").toLocked(); 497 498 499} 500