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, Sep 13, 2018 09:04-0400 for FHIR v3.5.0 033 034import java.util.*; 035 036import org.hl7.fhir.utilities.Utilities; 037import ca.uhn.fhir.model.api.annotation.ResourceDef; 038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 039import ca.uhn.fhir.model.api.annotation.Child; 040import ca.uhn.fhir.model.api.annotation.ChildOrder; 041import ca.uhn.fhir.model.api.annotation.Description; 042import ca.uhn.fhir.model.api.annotation.Block; 043import org.hl7.fhir.instance.model.api.*; 044import org.hl7.fhir.exceptions.FHIRException; 045/** 046 * The interactions of the medicinal product with other medicinal products, or other forms of interactions. 047 */ 048@ResourceDef(name="MedicinalProductInteraction", profile="http://hl7.org/fhir/StructureDefinition/MedicinalProductInteraction") 049public class MedicinalProductInteraction extends DomainResource { 050 051 /** 052 * The medication for which this is an indication. 053 */ 054 @Child(name = "subject", type = {MedicinalProduct.class, Medication.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 055 @Description(shortDefinition="The medication for which this is an indication", formalDefinition="The medication for which this is an indication." ) 056 protected List<Reference> subject; 057 /** 058 * The actual objects that are the target of the reference (The medication for which this is an indication.) 059 */ 060 protected List<Resource> subjectTarget; 061 062 063 /** 064 * The interaction described. 065 */ 066 @Child(name = "interaction", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=true) 067 @Description(shortDefinition="The interaction described", formalDefinition="The interaction described." ) 068 protected StringType interaction; 069 070 /** 071 * The specific medication, food or laboratory test that interacts. 072 */ 073 @Child(name = "interactant", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 074 @Description(shortDefinition="The specific medication, food or laboratory test that interacts", formalDefinition="The specific medication, food or laboratory test that interacts." ) 075 protected List<CodeableConcept> interactant; 076 077 /** 078 * The type of the interaction. 079 */ 080 @Child(name = "type", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true) 081 @Description(shortDefinition="The type of the interaction", formalDefinition="The type of the interaction." ) 082 protected CodeableConcept type; 083 084 /** 085 * The effect of the interaction. 086 */ 087 @Child(name = "effect", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=true) 088 @Description(shortDefinition="The effect of the interaction", formalDefinition="The effect of the interaction." ) 089 protected CodeableConcept effect; 090 091 /** 092 * The incidence of the interaction. 093 */ 094 @Child(name = "incidence", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true) 095 @Description(shortDefinition="The incidence of the interaction", formalDefinition="The incidence of the interaction." ) 096 protected CodeableConcept incidence; 097 098 /** 099 * Actions for managing the interaction. 100 */ 101 @Child(name = "management", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true) 102 @Description(shortDefinition="Actions for managing the interaction", formalDefinition="Actions for managing the interaction." ) 103 protected CodeableConcept management; 104 105 private static final long serialVersionUID = 1175278617L; 106 107 /** 108 * Constructor 109 */ 110 public MedicinalProductInteraction() { 111 super(); 112 } 113 114 /** 115 * @return {@link #subject} (The medication for which this is an indication.) 116 */ 117 public List<Reference> getSubject() { 118 if (this.subject == null) 119 this.subject = new ArrayList<Reference>(); 120 return this.subject; 121 } 122 123 /** 124 * @return Returns a reference to <code>this</code> for easy method chaining 125 */ 126 public MedicinalProductInteraction setSubject(List<Reference> theSubject) { 127 this.subject = theSubject; 128 return this; 129 } 130 131 public boolean hasSubject() { 132 if (this.subject == null) 133 return false; 134 for (Reference item : this.subject) 135 if (!item.isEmpty()) 136 return true; 137 return false; 138 } 139 140 public Reference addSubject() { //3 141 Reference t = new Reference(); 142 if (this.subject == null) 143 this.subject = new ArrayList<Reference>(); 144 this.subject.add(t); 145 return t; 146 } 147 148 public MedicinalProductInteraction addSubject(Reference t) { //3 149 if (t == null) 150 return this; 151 if (this.subject == null) 152 this.subject = new ArrayList<Reference>(); 153 this.subject.add(t); 154 return this; 155 } 156 157 /** 158 * @return The first repetition of repeating field {@link #subject}, creating it if it does not already exist 159 */ 160 public Reference getSubjectFirstRep() { 161 if (getSubject().isEmpty()) { 162 addSubject(); 163 } 164 return getSubject().get(0); 165 } 166 167 /** 168 * @deprecated Use Reference#setResource(IBaseResource) instead 169 */ 170 @Deprecated 171 public List<Resource> getSubjectTarget() { 172 if (this.subjectTarget == null) 173 this.subjectTarget = new ArrayList<Resource>(); 174 return this.subjectTarget; 175 } 176 177 /** 178 * @return {@link #interaction} (The interaction described.). This is the underlying object with id, value and extensions. The accessor "getInteraction" gives direct access to the value 179 */ 180 public StringType getInteractionElement() { 181 if (this.interaction == null) 182 if (Configuration.errorOnAutoCreate()) 183 throw new Error("Attempt to auto-create MedicinalProductInteraction.interaction"); 184 else if (Configuration.doAutoCreate()) 185 this.interaction = new StringType(); // bb 186 return this.interaction; 187 } 188 189 public boolean hasInteractionElement() { 190 return this.interaction != null && !this.interaction.isEmpty(); 191 } 192 193 public boolean hasInteraction() { 194 return this.interaction != null && !this.interaction.isEmpty(); 195 } 196 197 /** 198 * @param value {@link #interaction} (The interaction described.). This is the underlying object with id, value and extensions. The accessor "getInteraction" gives direct access to the value 199 */ 200 public MedicinalProductInteraction setInteractionElement(StringType value) { 201 this.interaction = value; 202 return this; 203 } 204 205 /** 206 * @return The interaction described. 207 */ 208 public String getInteraction() { 209 return this.interaction == null ? null : this.interaction.getValue(); 210 } 211 212 /** 213 * @param value The interaction described. 214 */ 215 public MedicinalProductInteraction setInteraction(String value) { 216 if (Utilities.noString(value)) 217 this.interaction = null; 218 else { 219 if (this.interaction == null) 220 this.interaction = new StringType(); 221 this.interaction.setValue(value); 222 } 223 return this; 224 } 225 226 /** 227 * @return {@link #interactant} (The specific medication, food or laboratory test that interacts.) 228 */ 229 public List<CodeableConcept> getInteractant() { 230 if (this.interactant == null) 231 this.interactant = new ArrayList<CodeableConcept>(); 232 return this.interactant; 233 } 234 235 /** 236 * @return Returns a reference to <code>this</code> for easy method chaining 237 */ 238 public MedicinalProductInteraction setInteractant(List<CodeableConcept> theInteractant) { 239 this.interactant = theInteractant; 240 return this; 241 } 242 243 public boolean hasInteractant() { 244 if (this.interactant == null) 245 return false; 246 for (CodeableConcept item : this.interactant) 247 if (!item.isEmpty()) 248 return true; 249 return false; 250 } 251 252 public CodeableConcept addInteractant() { //3 253 CodeableConcept t = new CodeableConcept(); 254 if (this.interactant == null) 255 this.interactant = new ArrayList<CodeableConcept>(); 256 this.interactant.add(t); 257 return t; 258 } 259 260 public MedicinalProductInteraction addInteractant(CodeableConcept t) { //3 261 if (t == null) 262 return this; 263 if (this.interactant == null) 264 this.interactant = new ArrayList<CodeableConcept>(); 265 this.interactant.add(t); 266 return this; 267 } 268 269 /** 270 * @return The first repetition of repeating field {@link #interactant}, creating it if it does not already exist 271 */ 272 public CodeableConcept getInteractantFirstRep() { 273 if (getInteractant().isEmpty()) { 274 addInteractant(); 275 } 276 return getInteractant().get(0); 277 } 278 279 /** 280 * @return {@link #type} (The type of the interaction.) 281 */ 282 public CodeableConcept getType() { 283 if (this.type == null) 284 if (Configuration.errorOnAutoCreate()) 285 throw new Error("Attempt to auto-create MedicinalProductInteraction.type"); 286 else if (Configuration.doAutoCreate()) 287 this.type = new CodeableConcept(); // cc 288 return this.type; 289 } 290 291 public boolean hasType() { 292 return this.type != null && !this.type.isEmpty(); 293 } 294 295 /** 296 * @param value {@link #type} (The type of the interaction.) 297 */ 298 public MedicinalProductInteraction setType(CodeableConcept value) { 299 this.type = value; 300 return this; 301 } 302 303 /** 304 * @return {@link #effect} (The effect of the interaction.) 305 */ 306 public CodeableConcept getEffect() { 307 if (this.effect == null) 308 if (Configuration.errorOnAutoCreate()) 309 throw new Error("Attempt to auto-create MedicinalProductInteraction.effect"); 310 else if (Configuration.doAutoCreate()) 311 this.effect = new CodeableConcept(); // cc 312 return this.effect; 313 } 314 315 public boolean hasEffect() { 316 return this.effect != null && !this.effect.isEmpty(); 317 } 318 319 /** 320 * @param value {@link #effect} (The effect of the interaction.) 321 */ 322 public MedicinalProductInteraction setEffect(CodeableConcept value) { 323 this.effect = value; 324 return this; 325 } 326 327 /** 328 * @return {@link #incidence} (The incidence of the interaction.) 329 */ 330 public CodeableConcept getIncidence() { 331 if (this.incidence == null) 332 if (Configuration.errorOnAutoCreate()) 333 throw new Error("Attempt to auto-create MedicinalProductInteraction.incidence"); 334 else if (Configuration.doAutoCreate()) 335 this.incidence = new CodeableConcept(); // cc 336 return this.incidence; 337 } 338 339 public boolean hasIncidence() { 340 return this.incidence != null && !this.incidence.isEmpty(); 341 } 342 343 /** 344 * @param value {@link #incidence} (The incidence of the interaction.) 345 */ 346 public MedicinalProductInteraction setIncidence(CodeableConcept value) { 347 this.incidence = value; 348 return this; 349 } 350 351 /** 352 * @return {@link #management} (Actions for managing the interaction.) 353 */ 354 public CodeableConcept getManagement() { 355 if (this.management == null) 356 if (Configuration.errorOnAutoCreate()) 357 throw new Error("Attempt to auto-create MedicinalProductInteraction.management"); 358 else if (Configuration.doAutoCreate()) 359 this.management = new CodeableConcept(); // cc 360 return this.management; 361 } 362 363 public boolean hasManagement() { 364 return this.management != null && !this.management.isEmpty(); 365 } 366 367 /** 368 * @param value {@link #management} (Actions for managing the interaction.) 369 */ 370 public MedicinalProductInteraction setManagement(CodeableConcept value) { 371 this.management = value; 372 return this; 373 } 374 375 protected void listChildren(List<Property> children) { 376 super.listChildren(children); 377 children.add(new Property("subject", "Reference(MedicinalProduct|Medication)", "The medication for which this is an indication.", 0, java.lang.Integer.MAX_VALUE, subject)); 378 children.add(new Property("interaction", "string", "The interaction described.", 0, 1, interaction)); 379 children.add(new Property("interactant", "CodeableConcept", "The specific medication, food or laboratory test that interacts.", 0, java.lang.Integer.MAX_VALUE, interactant)); 380 children.add(new Property("type", "CodeableConcept", "The type of the interaction.", 0, 1, type)); 381 children.add(new Property("effect", "CodeableConcept", "The effect of the interaction.", 0, 1, effect)); 382 children.add(new Property("incidence", "CodeableConcept", "The incidence of the interaction.", 0, 1, incidence)); 383 children.add(new Property("management", "CodeableConcept", "Actions for managing the interaction.", 0, 1, management)); 384 } 385 386 @Override 387 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 388 switch (_hash) { 389 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); 390 case 1844104722: /*interaction*/ return new Property("interaction", "string", "The interaction described.", 0, 1, interaction); 391 case 1844097009: /*interactant*/ return new Property("interactant", "CodeableConcept", "The specific medication, food or laboratory test that interacts.", 0, java.lang.Integer.MAX_VALUE, interactant); 392 case 3575610: /*type*/ return new Property("type", "CodeableConcept", "The type of the interaction.", 0, 1, type); 393 case -1306084975: /*effect*/ return new Property("effect", "CodeableConcept", "The effect of the interaction.", 0, 1, effect); 394 case -1598467132: /*incidence*/ return new Property("incidence", "CodeableConcept", "The incidence of the interaction.", 0, 1, incidence); 395 case -1799980989: /*management*/ return new Property("management", "CodeableConcept", "Actions for managing the interaction.", 0, 1, management); 396 default: return super.getNamedProperty(_hash, _name, _checkValid); 397 } 398 399 } 400 401 @Override 402 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 403 switch (hash) { 404 case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : this.subject.toArray(new Base[this.subject.size()]); // Reference 405 case 1844104722: /*interaction*/ return this.interaction == null ? new Base[0] : new Base[] {this.interaction}; // StringType 406 case 1844097009: /*interactant*/ return this.interactant == null ? new Base[0] : this.interactant.toArray(new Base[this.interactant.size()]); // CodeableConcept 407 case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept 408 case -1306084975: /*effect*/ return this.effect == null ? new Base[0] : new Base[] {this.effect}; // CodeableConcept 409 case -1598467132: /*incidence*/ return this.incidence == null ? new Base[0] : new Base[] {this.incidence}; // CodeableConcept 410 case -1799980989: /*management*/ return this.management == null ? new Base[0] : new Base[] {this.management}; // CodeableConcept 411 default: return super.getProperty(hash, name, checkValid); 412 } 413 414 } 415 416 @Override 417 public Base setProperty(int hash, String name, Base value) throws FHIRException { 418 switch (hash) { 419 case -1867885268: // subject 420 this.getSubject().add(castToReference(value)); // Reference 421 return value; 422 case 1844104722: // interaction 423 this.interaction = castToString(value); // StringType 424 return value; 425 case 1844097009: // interactant 426 this.getInteractant().add(castToCodeableConcept(value)); // CodeableConcept 427 return value; 428 case 3575610: // type 429 this.type = castToCodeableConcept(value); // CodeableConcept 430 return value; 431 case -1306084975: // effect 432 this.effect = castToCodeableConcept(value); // CodeableConcept 433 return value; 434 case -1598467132: // incidence 435 this.incidence = castToCodeableConcept(value); // CodeableConcept 436 return value; 437 case -1799980989: // management 438 this.management = castToCodeableConcept(value); // CodeableConcept 439 return value; 440 default: return super.setProperty(hash, name, value); 441 } 442 443 } 444 445 @Override 446 public Base setProperty(String name, Base value) throws FHIRException { 447 if (name.equals("subject")) { 448 this.getSubject().add(castToReference(value)); 449 } else if (name.equals("interaction")) { 450 this.interaction = castToString(value); // StringType 451 } else if (name.equals("interactant")) { 452 this.getInteractant().add(castToCodeableConcept(value)); 453 } else if (name.equals("type")) { 454 this.type = castToCodeableConcept(value); // CodeableConcept 455 } else if (name.equals("effect")) { 456 this.effect = castToCodeableConcept(value); // CodeableConcept 457 } else if (name.equals("incidence")) { 458 this.incidence = castToCodeableConcept(value); // CodeableConcept 459 } else if (name.equals("management")) { 460 this.management = castToCodeableConcept(value); // CodeableConcept 461 } else 462 return super.setProperty(name, value); 463 return value; 464 } 465 466 @Override 467 public Base makeProperty(int hash, String name) throws FHIRException { 468 switch (hash) { 469 case -1867885268: return addSubject(); 470 case 1844104722: return getInteractionElement(); 471 case 1844097009: return addInteractant(); 472 case 3575610: return getType(); 473 case -1306084975: return getEffect(); 474 case -1598467132: return getIncidence(); 475 case -1799980989: return getManagement(); 476 default: return super.makeProperty(hash, name); 477 } 478 479 } 480 481 @Override 482 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 483 switch (hash) { 484 case -1867885268: /*subject*/ return new String[] {"Reference"}; 485 case 1844104722: /*interaction*/ return new String[] {"string"}; 486 case 1844097009: /*interactant*/ return new String[] {"CodeableConcept"}; 487 case 3575610: /*type*/ return new String[] {"CodeableConcept"}; 488 case -1306084975: /*effect*/ return new String[] {"CodeableConcept"}; 489 case -1598467132: /*incidence*/ return new String[] {"CodeableConcept"}; 490 case -1799980989: /*management*/ return new String[] {"CodeableConcept"}; 491 default: return super.getTypesForProperty(hash, name); 492 } 493 494 } 495 496 @Override 497 public Base addChild(String name) throws FHIRException { 498 if (name.equals("subject")) { 499 return addSubject(); 500 } 501 else if (name.equals("interaction")) { 502 throw new FHIRException("Cannot call addChild on a primitive type MedicinalProductInteraction.interaction"); 503 } 504 else if (name.equals("interactant")) { 505 return addInteractant(); 506 } 507 else if (name.equals("type")) { 508 this.type = new CodeableConcept(); 509 return this.type; 510 } 511 else if (name.equals("effect")) { 512 this.effect = new CodeableConcept(); 513 return this.effect; 514 } 515 else if (name.equals("incidence")) { 516 this.incidence = new CodeableConcept(); 517 return this.incidence; 518 } 519 else if (name.equals("management")) { 520 this.management = new CodeableConcept(); 521 return this.management; 522 } 523 else 524 return super.addChild(name); 525 } 526 527 public String fhirType() { 528 return "MedicinalProductInteraction"; 529 530 } 531 532 public MedicinalProductInteraction copy() { 533 MedicinalProductInteraction dst = new MedicinalProductInteraction(); 534 copyValues(dst); 535 if (subject != null) { 536 dst.subject = new ArrayList<Reference>(); 537 for (Reference i : subject) 538 dst.subject.add(i.copy()); 539 }; 540 dst.interaction = interaction == null ? null : interaction.copy(); 541 if (interactant != null) { 542 dst.interactant = new ArrayList<CodeableConcept>(); 543 for (CodeableConcept i : interactant) 544 dst.interactant.add(i.copy()); 545 }; 546 dst.type = type == null ? null : type.copy(); 547 dst.effect = effect == null ? null : effect.copy(); 548 dst.incidence = incidence == null ? null : incidence.copy(); 549 dst.management = management == null ? null : management.copy(); 550 return dst; 551 } 552 553 protected MedicinalProductInteraction typedCopy() { 554 return copy(); 555 } 556 557 @Override 558 public boolean equalsDeep(Base other_) { 559 if (!super.equalsDeep(other_)) 560 return false; 561 if (!(other_ instanceof MedicinalProductInteraction)) 562 return false; 563 MedicinalProductInteraction o = (MedicinalProductInteraction) other_; 564 return compareDeep(subject, o.subject, true) && compareDeep(interaction, o.interaction, true) && compareDeep(interactant, o.interactant, true) 565 && compareDeep(type, o.type, true) && compareDeep(effect, o.effect, true) && compareDeep(incidence, o.incidence, true) 566 && compareDeep(management, o.management, true); 567 } 568 569 @Override 570 public boolean equalsShallow(Base other_) { 571 if (!super.equalsShallow(other_)) 572 return false; 573 if (!(other_ instanceof MedicinalProductInteraction)) 574 return false; 575 MedicinalProductInteraction o = (MedicinalProductInteraction) other_; 576 return compareValues(interaction, o.interaction, true); 577 } 578 579 public boolean isEmpty() { 580 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(subject, interaction, interactant 581 , type, effect, incidence, management); 582 } 583 584 @Override 585 public ResourceType getResourceType() { 586 return ResourceType.MedicinalProductInteraction; 587 } 588 589 /** 590 * Search parameter: <b>subject</b> 591 * <p> 592 * Description: <b>The medication for which this is an interaction</b><br> 593 * Type: <b>reference</b><br> 594 * Path: <b>MedicinalProductInteraction.subject</b><br> 595 * </p> 596 */ 597 @SearchParamDefinition(name="subject", path="MedicinalProductInteraction.subject", description="The medication for which this is an interaction", type="reference", target={Medication.class, MedicinalProduct.class } ) 598 public static final String SP_SUBJECT = "subject"; 599 /** 600 * <b>Fluent Client</b> search parameter constant for <b>subject</b> 601 * <p> 602 * Description: <b>The medication for which this is an interaction</b><br> 603 * Type: <b>reference</b><br> 604 * Path: <b>MedicinalProductInteraction.subject</b><br> 605 * </p> 606 */ 607 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT); 608 609/** 610 * Constant for fluent queries to be used to add include statements. Specifies 611 * the path value of "<b>MedicinalProductInteraction:subject</b>". 612 */ 613 public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("MedicinalProductInteraction:subject").toLocked(); 614 615 616} 617