001package org.hl7.fhir.dstu3.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 Fri, Mar 16, 2018 15:21+1100 for FHIR v3.0.1 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; 045import org.hl7.fhir.exceptions.FHIRFormatError; 046/** 047 * This resource is primarily used for the identification and definition of a medication. It covers the ingredients and the packaging for a medication. 048 */ 049@ResourceDef(name="Medication", profile="http://hl7.org/fhir/StructureDefinition/Medication") 050public class Medication extends DomainResource { 051 052 public enum MedicationStatus { 053 /** 054 * The medication is available for use 055 */ 056 ACTIVE, 057 /** 058 * The medication is not available for use 059 */ 060 INACTIVE, 061 /** 062 * The medication was entered in error 063 */ 064 ENTEREDINERROR, 065 /** 066 * added to help the parsers with the generic types 067 */ 068 NULL; 069 public static MedicationStatus fromCode(String codeString) throws FHIRException { 070 if (codeString == null || "".equals(codeString)) 071 return null; 072 if ("active".equals(codeString)) 073 return ACTIVE; 074 if ("inactive".equals(codeString)) 075 return INACTIVE; 076 if ("entered-in-error".equals(codeString)) 077 return ENTEREDINERROR; 078 if (Configuration.isAcceptInvalidEnums()) 079 return null; 080 else 081 throw new FHIRException("Unknown MedicationStatus code '"+codeString+"'"); 082 } 083 public String toCode() { 084 switch (this) { 085 case ACTIVE: return "active"; 086 case INACTIVE: return "inactive"; 087 case ENTEREDINERROR: return "entered-in-error"; 088 default: return "?"; 089 } 090 } 091 public String getSystem() { 092 switch (this) { 093 case ACTIVE: return "http://hl7.org/fhir/medication-status"; 094 case INACTIVE: return "http://hl7.org/fhir/medication-status"; 095 case ENTEREDINERROR: return "http://hl7.org/fhir/medication-status"; 096 default: return "?"; 097 } 098 } 099 public String getDefinition() { 100 switch (this) { 101 case ACTIVE: return "The medication is available for use"; 102 case INACTIVE: return "The medication is not available for use"; 103 case ENTEREDINERROR: return "The medication was entered in error"; 104 default: return "?"; 105 } 106 } 107 public String getDisplay() { 108 switch (this) { 109 case ACTIVE: return "Active"; 110 case INACTIVE: return "Inactive"; 111 case ENTEREDINERROR: return "Entered in Error"; 112 default: return "?"; 113 } 114 } 115 } 116 117 public static class MedicationStatusEnumFactory implements EnumFactory<MedicationStatus> { 118 public MedicationStatus fromCode(String codeString) throws IllegalArgumentException { 119 if (codeString == null || "".equals(codeString)) 120 if (codeString == null || "".equals(codeString)) 121 return null; 122 if ("active".equals(codeString)) 123 return MedicationStatus.ACTIVE; 124 if ("inactive".equals(codeString)) 125 return MedicationStatus.INACTIVE; 126 if ("entered-in-error".equals(codeString)) 127 return MedicationStatus.ENTEREDINERROR; 128 throw new IllegalArgumentException("Unknown MedicationStatus code '"+codeString+"'"); 129 } 130 public Enumeration<MedicationStatus> fromType(Base code) throws FHIRException { 131 if (code == null) 132 return null; 133 if (code.isEmpty()) 134 return new Enumeration<MedicationStatus>(this); 135 String codeString = ((PrimitiveType) code).asStringValue(); 136 if (codeString == null || "".equals(codeString)) 137 return null; 138 if ("active".equals(codeString)) 139 return new Enumeration<MedicationStatus>(this, MedicationStatus.ACTIVE); 140 if ("inactive".equals(codeString)) 141 return new Enumeration<MedicationStatus>(this, MedicationStatus.INACTIVE); 142 if ("entered-in-error".equals(codeString)) 143 return new Enumeration<MedicationStatus>(this, MedicationStatus.ENTEREDINERROR); 144 throw new FHIRException("Unknown MedicationStatus code '"+codeString+"'"); 145 } 146 public String toCode(MedicationStatus code) { 147 if (code == MedicationStatus.ACTIVE) 148 return "active"; 149 if (code == MedicationStatus.INACTIVE) 150 return "inactive"; 151 if (code == MedicationStatus.ENTEREDINERROR) 152 return "entered-in-error"; 153 return "?"; 154 } 155 public String toSystem(MedicationStatus code) { 156 return code.getSystem(); 157 } 158 } 159 160 @Block() 161 public static class MedicationIngredientComponent extends BackboneElement implements IBaseBackboneElement { 162 /** 163 * The actual ingredient - either a substance (simple ingredient) or another medication. 164 */ 165 @Child(name = "item", type = {CodeableConcept.class, Substance.class, Medication.class}, order=1, min=1, max=1, modifier=false, summary=false) 166 @Description(shortDefinition="The product contained", formalDefinition="The actual ingredient - either a substance (simple ingredient) or another medication." ) 167 protected Type item; 168 169 /** 170 * Indication of whether this ingredient affects the therapeutic action of the drug. 171 */ 172 @Child(name = "isActive", type = {BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=false) 173 @Description(shortDefinition="Active ingredient indicator", formalDefinition="Indication of whether this ingredient affects the therapeutic action of the drug." ) 174 protected BooleanType isActive; 175 176 /** 177 * Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet. This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet. 178 */ 179 @Child(name = "amount", type = {Ratio.class}, order=3, min=0, max=1, modifier=false, summary=false) 180 @Description(shortDefinition="Quantity of ingredient present", formalDefinition="Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet. This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet." ) 181 protected Ratio amount; 182 183 private static final long serialVersionUID = -1796655982L; 184 185 /** 186 * Constructor 187 */ 188 public MedicationIngredientComponent() { 189 super(); 190 } 191 192 /** 193 * Constructor 194 */ 195 public MedicationIngredientComponent(Type item) { 196 super(); 197 this.item = item; 198 } 199 200 /** 201 * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication.) 202 */ 203 public Type getItem() { 204 return this.item; 205 } 206 207 /** 208 * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication.) 209 */ 210 public CodeableConcept getItemCodeableConcept() throws FHIRException { 211 if (this.item == null) 212 return null; 213 if (!(this.item instanceof CodeableConcept)) 214 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.item.getClass().getName()+" was encountered"); 215 return (CodeableConcept) this.item; 216 } 217 218 public boolean hasItemCodeableConcept() { 219 return this != null && this.item instanceof CodeableConcept; 220 } 221 222 /** 223 * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication.) 224 */ 225 public Reference getItemReference() throws FHIRException { 226 if (this.item == null) 227 return null; 228 if (!(this.item instanceof Reference)) 229 throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.item.getClass().getName()+" was encountered"); 230 return (Reference) this.item; 231 } 232 233 public boolean hasItemReference() { 234 return this != null && this.item instanceof Reference; 235 } 236 237 public boolean hasItem() { 238 return this.item != null && !this.item.isEmpty(); 239 } 240 241 /** 242 * @param value {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication.) 243 */ 244 public MedicationIngredientComponent setItem(Type value) throws FHIRFormatError { 245 if (value != null && !(value instanceof CodeableConcept || value instanceof Reference)) 246 throw new FHIRFormatError("Not the right type for Medication.ingredient.item[x]: "+value.fhirType()); 247 this.item = value; 248 return this; 249 } 250 251 /** 252 * @return {@link #isActive} (Indication of whether this ingredient affects the therapeutic action of the drug.). This is the underlying object with id, value and extensions. The accessor "getIsActive" gives direct access to the value 253 */ 254 public BooleanType getIsActiveElement() { 255 if (this.isActive == null) 256 if (Configuration.errorOnAutoCreate()) 257 throw new Error("Attempt to auto-create MedicationIngredientComponent.isActive"); 258 else if (Configuration.doAutoCreate()) 259 this.isActive = new BooleanType(); // bb 260 return this.isActive; 261 } 262 263 public boolean hasIsActiveElement() { 264 return this.isActive != null && !this.isActive.isEmpty(); 265 } 266 267 public boolean hasIsActive() { 268 return this.isActive != null && !this.isActive.isEmpty(); 269 } 270 271 /** 272 * @param value {@link #isActive} (Indication of whether this ingredient affects the therapeutic action of the drug.). This is the underlying object with id, value and extensions. The accessor "getIsActive" gives direct access to the value 273 */ 274 public MedicationIngredientComponent setIsActiveElement(BooleanType value) { 275 this.isActive = value; 276 return this; 277 } 278 279 /** 280 * @return Indication of whether this ingredient affects the therapeutic action of the drug. 281 */ 282 public boolean getIsActive() { 283 return this.isActive == null || this.isActive.isEmpty() ? false : this.isActive.getValue(); 284 } 285 286 /** 287 * @param value Indication of whether this ingredient affects the therapeutic action of the drug. 288 */ 289 public MedicationIngredientComponent setIsActive(boolean value) { 290 if (this.isActive == null) 291 this.isActive = new BooleanType(); 292 this.isActive.setValue(value); 293 return this; 294 } 295 296 /** 297 * @return {@link #amount} (Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet. This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.) 298 */ 299 public Ratio getAmount() { 300 if (this.amount == null) 301 if (Configuration.errorOnAutoCreate()) 302 throw new Error("Attempt to auto-create MedicationIngredientComponent.amount"); 303 else if (Configuration.doAutoCreate()) 304 this.amount = new Ratio(); // cc 305 return this.amount; 306 } 307 308 public boolean hasAmount() { 309 return this.amount != null && !this.amount.isEmpty(); 310 } 311 312 /** 313 * @param value {@link #amount} (Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet. This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.) 314 */ 315 public MedicationIngredientComponent setAmount(Ratio value) { 316 this.amount = value; 317 return this; 318 } 319 320 protected void listChildren(List<Property> children) { 321 super.listChildren(children); 322 children.add(new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication.", 0, 1, item)); 323 children.add(new Property("isActive", "boolean", "Indication of whether this ingredient affects the therapeutic action of the drug.", 0, 1, isActive)); 324 children.add(new Property("amount", "Ratio", "Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet. This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.", 0, 1, amount)); 325 } 326 327 @Override 328 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 329 switch (_hash) { 330 case 2116201613: /*item[x]*/ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication.", 0, 1, item); 331 case 3242771: /*item*/ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication.", 0, 1, item); 332 case 106644494: /*itemCodeableConcept*/ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication.", 0, 1, item); 333 case 1376364920: /*itemReference*/ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication.", 0, 1, item); 334 case -748916528: /*isActive*/ return new Property("isActive", "boolean", "Indication of whether this ingredient affects the therapeutic action of the drug.", 0, 1, isActive); 335 case -1413853096: /*amount*/ return new Property("amount", "Ratio", "Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet. This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.", 0, 1, amount); 336 default: return super.getNamedProperty(_hash, _name, _checkValid); 337 } 338 339 } 340 341 @Override 342 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 343 switch (hash) { 344 case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // Type 345 case -748916528: /*isActive*/ return this.isActive == null ? new Base[0] : new Base[] {this.isActive}; // BooleanType 346 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Ratio 347 default: return super.getProperty(hash, name, checkValid); 348 } 349 350 } 351 352 @Override 353 public Base setProperty(int hash, String name, Base value) throws FHIRException { 354 switch (hash) { 355 case 3242771: // item 356 this.item = castToType(value); // Type 357 return value; 358 case -748916528: // isActive 359 this.isActive = castToBoolean(value); // BooleanType 360 return value; 361 case -1413853096: // amount 362 this.amount = castToRatio(value); // Ratio 363 return value; 364 default: return super.setProperty(hash, name, value); 365 } 366 367 } 368 369 @Override 370 public Base setProperty(String name, Base value) throws FHIRException { 371 if (name.equals("item[x]")) { 372 this.item = castToType(value); // Type 373 } else if (name.equals("isActive")) { 374 this.isActive = castToBoolean(value); // BooleanType 375 } else if (name.equals("amount")) { 376 this.amount = castToRatio(value); // Ratio 377 } else 378 return super.setProperty(name, value); 379 return value; 380 } 381 382 @Override 383 public Base makeProperty(int hash, String name) throws FHIRException { 384 switch (hash) { 385 case 2116201613: return getItem(); 386 case 3242771: return getItem(); 387 case -748916528: return getIsActiveElement(); 388 case -1413853096: return getAmount(); 389 default: return super.makeProperty(hash, name); 390 } 391 392 } 393 394 @Override 395 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 396 switch (hash) { 397 case 3242771: /*item*/ return new String[] {"CodeableConcept", "Reference"}; 398 case -748916528: /*isActive*/ return new String[] {"boolean"}; 399 case -1413853096: /*amount*/ return new String[] {"Ratio"}; 400 default: return super.getTypesForProperty(hash, name); 401 } 402 403 } 404 405 @Override 406 public Base addChild(String name) throws FHIRException { 407 if (name.equals("itemCodeableConcept")) { 408 this.item = new CodeableConcept(); 409 return this.item; 410 } 411 else if (name.equals("itemReference")) { 412 this.item = new Reference(); 413 return this.item; 414 } 415 else if (name.equals("isActive")) { 416 throw new FHIRException("Cannot call addChild on a primitive type Medication.isActive"); 417 } 418 else if (name.equals("amount")) { 419 this.amount = new Ratio(); 420 return this.amount; 421 } 422 else 423 return super.addChild(name); 424 } 425 426 public MedicationIngredientComponent copy() { 427 MedicationIngredientComponent dst = new MedicationIngredientComponent(); 428 copyValues(dst); 429 dst.item = item == null ? null : item.copy(); 430 dst.isActive = isActive == null ? null : isActive.copy(); 431 dst.amount = amount == null ? null : amount.copy(); 432 return dst; 433 } 434 435 @Override 436 public boolean equalsDeep(Base other_) { 437 if (!super.equalsDeep(other_)) 438 return false; 439 if (!(other_ instanceof MedicationIngredientComponent)) 440 return false; 441 MedicationIngredientComponent o = (MedicationIngredientComponent) other_; 442 return compareDeep(item, o.item, true) && compareDeep(isActive, o.isActive, true) && compareDeep(amount, o.amount, true) 443 ; 444 } 445 446 @Override 447 public boolean equalsShallow(Base other_) { 448 if (!super.equalsShallow(other_)) 449 return false; 450 if (!(other_ instanceof MedicationIngredientComponent)) 451 return false; 452 MedicationIngredientComponent o = (MedicationIngredientComponent) other_; 453 return compareValues(isActive, o.isActive, true); 454 } 455 456 public boolean isEmpty() { 457 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, isActive, amount); 458 } 459 460 public String fhirType() { 461 return "Medication.ingredient"; 462 463 } 464 465 } 466 467 @Block() 468 public static class MedicationPackageComponent extends BackboneElement implements IBaseBackboneElement { 469 /** 470 * The kind of container that this package comes as. 471 */ 472 @Child(name = "container", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false) 473 @Description(shortDefinition="E.g. box, vial, blister-pack", formalDefinition="The kind of container that this package comes as." ) 474 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-package-form") 475 protected CodeableConcept container; 476 477 /** 478 * A set of components that go to make up the described item. 479 */ 480 @Child(name = "content", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 481 @Description(shortDefinition="What is in the package", formalDefinition="A set of components that go to make up the described item." ) 482 protected List<MedicationPackageContentComponent> content; 483 484 /** 485 * Information about a group of medication produced or packaged from one production run. 486 */ 487 @Child(name = "batch", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 488 @Description(shortDefinition="Identifies a single production run", formalDefinition="Information about a group of medication produced or packaged from one production run." ) 489 protected List<MedicationPackageBatchComponent> batch; 490 491 private static final long serialVersionUID = -255992250L; 492 493 /** 494 * Constructor 495 */ 496 public MedicationPackageComponent() { 497 super(); 498 } 499 500 /** 501 * @return {@link #container} (The kind of container that this package comes as.) 502 */ 503 public CodeableConcept getContainer() { 504 if (this.container == null) 505 if (Configuration.errorOnAutoCreate()) 506 throw new Error("Attempt to auto-create MedicationPackageComponent.container"); 507 else if (Configuration.doAutoCreate()) 508 this.container = new CodeableConcept(); // cc 509 return this.container; 510 } 511 512 public boolean hasContainer() { 513 return this.container != null && !this.container.isEmpty(); 514 } 515 516 /** 517 * @param value {@link #container} (The kind of container that this package comes as.) 518 */ 519 public MedicationPackageComponent setContainer(CodeableConcept value) { 520 this.container = value; 521 return this; 522 } 523 524 /** 525 * @return {@link #content} (A set of components that go to make up the described item.) 526 */ 527 public List<MedicationPackageContentComponent> getContent() { 528 if (this.content == null) 529 this.content = new ArrayList<MedicationPackageContentComponent>(); 530 return this.content; 531 } 532 533 /** 534 * @return Returns a reference to <code>this</code> for easy method chaining 535 */ 536 public MedicationPackageComponent setContent(List<MedicationPackageContentComponent> theContent) { 537 this.content = theContent; 538 return this; 539 } 540 541 public boolean hasContent() { 542 if (this.content == null) 543 return false; 544 for (MedicationPackageContentComponent item : this.content) 545 if (!item.isEmpty()) 546 return true; 547 return false; 548 } 549 550 public MedicationPackageContentComponent addContent() { //3 551 MedicationPackageContentComponent t = new MedicationPackageContentComponent(); 552 if (this.content == null) 553 this.content = new ArrayList<MedicationPackageContentComponent>(); 554 this.content.add(t); 555 return t; 556 } 557 558 public MedicationPackageComponent addContent(MedicationPackageContentComponent t) { //3 559 if (t == null) 560 return this; 561 if (this.content == null) 562 this.content = new ArrayList<MedicationPackageContentComponent>(); 563 this.content.add(t); 564 return this; 565 } 566 567 /** 568 * @return The first repetition of repeating field {@link #content}, creating it if it does not already exist 569 */ 570 public MedicationPackageContentComponent getContentFirstRep() { 571 if (getContent().isEmpty()) { 572 addContent(); 573 } 574 return getContent().get(0); 575 } 576 577 /** 578 * @return {@link #batch} (Information about a group of medication produced or packaged from one production run.) 579 */ 580 public List<MedicationPackageBatchComponent> getBatch() { 581 if (this.batch == null) 582 this.batch = new ArrayList<MedicationPackageBatchComponent>(); 583 return this.batch; 584 } 585 586 /** 587 * @return Returns a reference to <code>this</code> for easy method chaining 588 */ 589 public MedicationPackageComponent setBatch(List<MedicationPackageBatchComponent> theBatch) { 590 this.batch = theBatch; 591 return this; 592 } 593 594 public boolean hasBatch() { 595 if (this.batch == null) 596 return false; 597 for (MedicationPackageBatchComponent item : this.batch) 598 if (!item.isEmpty()) 599 return true; 600 return false; 601 } 602 603 public MedicationPackageBatchComponent addBatch() { //3 604 MedicationPackageBatchComponent t = new MedicationPackageBatchComponent(); 605 if (this.batch == null) 606 this.batch = new ArrayList<MedicationPackageBatchComponent>(); 607 this.batch.add(t); 608 return t; 609 } 610 611 public MedicationPackageComponent addBatch(MedicationPackageBatchComponent t) { //3 612 if (t == null) 613 return this; 614 if (this.batch == null) 615 this.batch = new ArrayList<MedicationPackageBatchComponent>(); 616 this.batch.add(t); 617 return this; 618 } 619 620 /** 621 * @return The first repetition of repeating field {@link #batch}, creating it if it does not already exist 622 */ 623 public MedicationPackageBatchComponent getBatchFirstRep() { 624 if (getBatch().isEmpty()) { 625 addBatch(); 626 } 627 return getBatch().get(0); 628 } 629 630 protected void listChildren(List<Property> children) { 631 super.listChildren(children); 632 children.add(new Property("container", "CodeableConcept", "The kind of container that this package comes as.", 0, 1, container)); 633 children.add(new Property("content", "", "A set of components that go to make up the described item.", 0, java.lang.Integer.MAX_VALUE, content)); 634 children.add(new Property("batch", "", "Information about a group of medication produced or packaged from one production run.", 0, java.lang.Integer.MAX_VALUE, batch)); 635 } 636 637 @Override 638 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 639 switch (_hash) { 640 case -410956671: /*container*/ return new Property("container", "CodeableConcept", "The kind of container that this package comes as.", 0, 1, container); 641 case 951530617: /*content*/ return new Property("content", "", "A set of components that go to make up the described item.", 0, java.lang.Integer.MAX_VALUE, content); 642 case 93509434: /*batch*/ return new Property("batch", "", "Information about a group of medication produced or packaged from one production run.", 0, java.lang.Integer.MAX_VALUE, batch); 643 default: return super.getNamedProperty(_hash, _name, _checkValid); 644 } 645 646 } 647 648 @Override 649 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 650 switch (hash) { 651 case -410956671: /*container*/ return this.container == null ? new Base[0] : new Base[] {this.container}; // CodeableConcept 652 case 951530617: /*content*/ return this.content == null ? new Base[0] : this.content.toArray(new Base[this.content.size()]); // MedicationPackageContentComponent 653 case 93509434: /*batch*/ return this.batch == null ? new Base[0] : this.batch.toArray(new Base[this.batch.size()]); // MedicationPackageBatchComponent 654 default: return super.getProperty(hash, name, checkValid); 655 } 656 657 } 658 659 @Override 660 public Base setProperty(int hash, String name, Base value) throws FHIRException { 661 switch (hash) { 662 case -410956671: // container 663 this.container = castToCodeableConcept(value); // CodeableConcept 664 return value; 665 case 951530617: // content 666 this.getContent().add((MedicationPackageContentComponent) value); // MedicationPackageContentComponent 667 return value; 668 case 93509434: // batch 669 this.getBatch().add((MedicationPackageBatchComponent) value); // MedicationPackageBatchComponent 670 return value; 671 default: return super.setProperty(hash, name, value); 672 } 673 674 } 675 676 @Override 677 public Base setProperty(String name, Base value) throws FHIRException { 678 if (name.equals("container")) { 679 this.container = castToCodeableConcept(value); // CodeableConcept 680 } else if (name.equals("content")) { 681 this.getContent().add((MedicationPackageContentComponent) value); 682 } else if (name.equals("batch")) { 683 this.getBatch().add((MedicationPackageBatchComponent) value); 684 } else 685 return super.setProperty(name, value); 686 return value; 687 } 688 689 @Override 690 public Base makeProperty(int hash, String name) throws FHIRException { 691 switch (hash) { 692 case -410956671: return getContainer(); 693 case 951530617: return addContent(); 694 case 93509434: return addBatch(); 695 default: return super.makeProperty(hash, name); 696 } 697 698 } 699 700 @Override 701 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 702 switch (hash) { 703 case -410956671: /*container*/ return new String[] {"CodeableConcept"}; 704 case 951530617: /*content*/ return new String[] {}; 705 case 93509434: /*batch*/ return new String[] {}; 706 default: return super.getTypesForProperty(hash, name); 707 } 708 709 } 710 711 @Override 712 public Base addChild(String name) throws FHIRException { 713 if (name.equals("container")) { 714 this.container = new CodeableConcept(); 715 return this.container; 716 } 717 else if (name.equals("content")) { 718 return addContent(); 719 } 720 else if (name.equals("batch")) { 721 return addBatch(); 722 } 723 else 724 return super.addChild(name); 725 } 726 727 public MedicationPackageComponent copy() { 728 MedicationPackageComponent dst = new MedicationPackageComponent(); 729 copyValues(dst); 730 dst.container = container == null ? null : container.copy(); 731 if (content != null) { 732 dst.content = new ArrayList<MedicationPackageContentComponent>(); 733 for (MedicationPackageContentComponent i : content) 734 dst.content.add(i.copy()); 735 }; 736 if (batch != null) { 737 dst.batch = new ArrayList<MedicationPackageBatchComponent>(); 738 for (MedicationPackageBatchComponent i : batch) 739 dst.batch.add(i.copy()); 740 }; 741 return dst; 742 } 743 744 @Override 745 public boolean equalsDeep(Base other_) { 746 if (!super.equalsDeep(other_)) 747 return false; 748 if (!(other_ instanceof MedicationPackageComponent)) 749 return false; 750 MedicationPackageComponent o = (MedicationPackageComponent) other_; 751 return compareDeep(container, o.container, true) && compareDeep(content, o.content, true) && compareDeep(batch, o.batch, true) 752 ; 753 } 754 755 @Override 756 public boolean equalsShallow(Base other_) { 757 if (!super.equalsShallow(other_)) 758 return false; 759 if (!(other_ instanceof MedicationPackageComponent)) 760 return false; 761 MedicationPackageComponent o = (MedicationPackageComponent) other_; 762 return true; 763 } 764 765 public boolean isEmpty() { 766 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(container, content, batch 767 ); 768 } 769 770 public String fhirType() { 771 return "Medication.package"; 772 773 } 774 775 } 776 777 @Block() 778 public static class MedicationPackageContentComponent extends BackboneElement implements IBaseBackboneElement { 779 /** 780 * Identifies one of the items in the package. 781 */ 782 @Child(name = "item", type = {CodeableConcept.class, Medication.class}, order=1, min=1, max=1, modifier=false, summary=false) 783 @Description(shortDefinition="The item in the package", formalDefinition="Identifies one of the items in the package." ) 784 protected Type item; 785 786 /** 787 * The amount of the product that is in the package. 788 */ 789 @Child(name = "amount", type = {SimpleQuantity.class}, order=2, min=0, max=1, modifier=false, summary=false) 790 @Description(shortDefinition="Quantity present in the package", formalDefinition="The amount of the product that is in the package." ) 791 protected SimpleQuantity amount; 792 793 private static final long serialVersionUID = 1669610080L; 794 795 /** 796 * Constructor 797 */ 798 public MedicationPackageContentComponent() { 799 super(); 800 } 801 802 /** 803 * Constructor 804 */ 805 public MedicationPackageContentComponent(Type item) { 806 super(); 807 this.item = item; 808 } 809 810 /** 811 * @return {@link #item} (Identifies one of the items in the package.) 812 */ 813 public Type getItem() { 814 return this.item; 815 } 816 817 /** 818 * @return {@link #item} (Identifies one of the items in the package.) 819 */ 820 public CodeableConcept getItemCodeableConcept() throws FHIRException { 821 if (this.item == null) 822 return null; 823 if (!(this.item instanceof CodeableConcept)) 824 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.item.getClass().getName()+" was encountered"); 825 return (CodeableConcept) this.item; 826 } 827 828 public boolean hasItemCodeableConcept() { 829 return this != null && this.item instanceof CodeableConcept; 830 } 831 832 /** 833 * @return {@link #item} (Identifies one of the items in the package.) 834 */ 835 public Reference getItemReference() throws FHIRException { 836 if (this.item == null) 837 return null; 838 if (!(this.item instanceof Reference)) 839 throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.item.getClass().getName()+" was encountered"); 840 return (Reference) this.item; 841 } 842 843 public boolean hasItemReference() { 844 return this != null && this.item instanceof Reference; 845 } 846 847 public boolean hasItem() { 848 return this.item != null && !this.item.isEmpty(); 849 } 850 851 /** 852 * @param value {@link #item} (Identifies one of the items in the package.) 853 */ 854 public MedicationPackageContentComponent setItem(Type value) throws FHIRFormatError { 855 if (value != null && !(value instanceof CodeableConcept || value instanceof Reference)) 856 throw new FHIRFormatError("Not the right type for Medication.package.content.item[x]: "+value.fhirType()); 857 this.item = value; 858 return this; 859 } 860 861 /** 862 * @return {@link #amount} (The amount of the product that is in the package.) 863 */ 864 public SimpleQuantity getAmount() { 865 if (this.amount == null) 866 if (Configuration.errorOnAutoCreate()) 867 throw new Error("Attempt to auto-create MedicationPackageContentComponent.amount"); 868 else if (Configuration.doAutoCreate()) 869 this.amount = new SimpleQuantity(); // cc 870 return this.amount; 871 } 872 873 public boolean hasAmount() { 874 return this.amount != null && !this.amount.isEmpty(); 875 } 876 877 /** 878 * @param value {@link #amount} (The amount of the product that is in the package.) 879 */ 880 public MedicationPackageContentComponent setAmount(SimpleQuantity value) { 881 this.amount = value; 882 return this; 883 } 884 885 protected void listChildren(List<Property> children) { 886 super.listChildren(children); 887 children.add(new Property("item[x]", "CodeableConcept|Reference(Medication)", "Identifies one of the items in the package.", 0, 1, item)); 888 children.add(new Property("amount", "SimpleQuantity", "The amount of the product that is in the package.", 0, 1, amount)); 889 } 890 891 @Override 892 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 893 switch (_hash) { 894 case 2116201613: /*item[x]*/ return new Property("item[x]", "CodeableConcept|Reference(Medication)", "Identifies one of the items in the package.", 0, 1, item); 895 case 3242771: /*item*/ return new Property("item[x]", "CodeableConcept|Reference(Medication)", "Identifies one of the items in the package.", 0, 1, item); 896 case 106644494: /*itemCodeableConcept*/ return new Property("item[x]", "CodeableConcept|Reference(Medication)", "Identifies one of the items in the package.", 0, 1, item); 897 case 1376364920: /*itemReference*/ return new Property("item[x]", "CodeableConcept|Reference(Medication)", "Identifies one of the items in the package.", 0, 1, item); 898 case -1413853096: /*amount*/ return new Property("amount", "SimpleQuantity", "The amount of the product that is in the package.", 0, 1, amount); 899 default: return super.getNamedProperty(_hash, _name, _checkValid); 900 } 901 902 } 903 904 @Override 905 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 906 switch (hash) { 907 case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // Type 908 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // SimpleQuantity 909 default: return super.getProperty(hash, name, checkValid); 910 } 911 912 } 913 914 @Override 915 public Base setProperty(int hash, String name, Base value) throws FHIRException { 916 switch (hash) { 917 case 3242771: // item 918 this.item = castToType(value); // Type 919 return value; 920 case -1413853096: // amount 921 this.amount = castToSimpleQuantity(value); // SimpleQuantity 922 return value; 923 default: return super.setProperty(hash, name, value); 924 } 925 926 } 927 928 @Override 929 public Base setProperty(String name, Base value) throws FHIRException { 930 if (name.equals("item[x]")) { 931 this.item = castToType(value); // Type 932 } else if (name.equals("amount")) { 933 this.amount = castToSimpleQuantity(value); // SimpleQuantity 934 } else 935 return super.setProperty(name, value); 936 return value; 937 } 938 939 @Override 940 public Base makeProperty(int hash, String name) throws FHIRException { 941 switch (hash) { 942 case 2116201613: return getItem(); 943 case 3242771: return getItem(); 944 case -1413853096: return getAmount(); 945 default: return super.makeProperty(hash, name); 946 } 947 948 } 949 950 @Override 951 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 952 switch (hash) { 953 case 3242771: /*item*/ return new String[] {"CodeableConcept", "Reference"}; 954 case -1413853096: /*amount*/ return new String[] {"SimpleQuantity"}; 955 default: return super.getTypesForProperty(hash, name); 956 } 957 958 } 959 960 @Override 961 public Base addChild(String name) throws FHIRException { 962 if (name.equals("itemCodeableConcept")) { 963 this.item = new CodeableConcept(); 964 return this.item; 965 } 966 else if (name.equals("itemReference")) { 967 this.item = new Reference(); 968 return this.item; 969 } 970 else if (name.equals("amount")) { 971 this.amount = new SimpleQuantity(); 972 return this.amount; 973 } 974 else 975 return super.addChild(name); 976 } 977 978 public MedicationPackageContentComponent copy() { 979 MedicationPackageContentComponent dst = new MedicationPackageContentComponent(); 980 copyValues(dst); 981 dst.item = item == null ? null : item.copy(); 982 dst.amount = amount == null ? null : amount.copy(); 983 return dst; 984 } 985 986 @Override 987 public boolean equalsDeep(Base other_) { 988 if (!super.equalsDeep(other_)) 989 return false; 990 if (!(other_ instanceof MedicationPackageContentComponent)) 991 return false; 992 MedicationPackageContentComponent o = (MedicationPackageContentComponent) other_; 993 return compareDeep(item, o.item, true) && compareDeep(amount, o.amount, true); 994 } 995 996 @Override 997 public boolean equalsShallow(Base other_) { 998 if (!super.equalsShallow(other_)) 999 return false; 1000 if (!(other_ instanceof MedicationPackageContentComponent)) 1001 return false; 1002 MedicationPackageContentComponent o = (MedicationPackageContentComponent) other_; 1003 return true; 1004 } 1005 1006 public boolean isEmpty() { 1007 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, amount); 1008 } 1009 1010 public String fhirType() { 1011 return "Medication.package.content"; 1012 1013 } 1014 1015 } 1016 1017 @Block() 1018 public static class MedicationPackageBatchComponent extends BackboneElement implements IBaseBackboneElement { 1019 /** 1020 * The assigned lot number of a batch of the specified product. 1021 */ 1022 @Child(name = "lotNumber", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false) 1023 @Description(shortDefinition="Identifier assigned to batch", formalDefinition="The assigned lot number of a batch of the specified product." ) 1024 protected StringType lotNumber; 1025 1026 /** 1027 * When this specific batch of product will expire. 1028 */ 1029 @Child(name = "expirationDate", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false) 1030 @Description(shortDefinition="When batch will expire", formalDefinition="When this specific batch of product will expire." ) 1031 protected DateTimeType expirationDate; 1032 1033 private static final long serialVersionUID = 1982738755L; 1034 1035 /** 1036 * Constructor 1037 */ 1038 public MedicationPackageBatchComponent() { 1039 super(); 1040 } 1041 1042 /** 1043 * @return {@link #lotNumber} (The assigned lot number of a batch of the specified product.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value 1044 */ 1045 public StringType getLotNumberElement() { 1046 if (this.lotNumber == null) 1047 if (Configuration.errorOnAutoCreate()) 1048 throw new Error("Attempt to auto-create MedicationPackageBatchComponent.lotNumber"); 1049 else if (Configuration.doAutoCreate()) 1050 this.lotNumber = new StringType(); // bb 1051 return this.lotNumber; 1052 } 1053 1054 public boolean hasLotNumberElement() { 1055 return this.lotNumber != null && !this.lotNumber.isEmpty(); 1056 } 1057 1058 public boolean hasLotNumber() { 1059 return this.lotNumber != null && !this.lotNumber.isEmpty(); 1060 } 1061 1062 /** 1063 * @param value {@link #lotNumber} (The assigned lot number of a batch of the specified product.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value 1064 */ 1065 public MedicationPackageBatchComponent setLotNumberElement(StringType value) { 1066 this.lotNumber = value; 1067 return this; 1068 } 1069 1070 /** 1071 * @return The assigned lot number of a batch of the specified product. 1072 */ 1073 public String getLotNumber() { 1074 return this.lotNumber == null ? null : this.lotNumber.getValue(); 1075 } 1076 1077 /** 1078 * @param value The assigned lot number of a batch of the specified product. 1079 */ 1080 public MedicationPackageBatchComponent setLotNumber(String value) { 1081 if (Utilities.noString(value)) 1082 this.lotNumber = null; 1083 else { 1084 if (this.lotNumber == null) 1085 this.lotNumber = new StringType(); 1086 this.lotNumber.setValue(value); 1087 } 1088 return this; 1089 } 1090 1091 /** 1092 * @return {@link #expirationDate} (When this specific batch of product will expire.). This is the underlying object with id, value and extensions. The accessor "getExpirationDate" gives direct access to the value 1093 */ 1094 public DateTimeType getExpirationDateElement() { 1095 if (this.expirationDate == null) 1096 if (Configuration.errorOnAutoCreate()) 1097 throw new Error("Attempt to auto-create MedicationPackageBatchComponent.expirationDate"); 1098 else if (Configuration.doAutoCreate()) 1099 this.expirationDate = new DateTimeType(); // bb 1100 return this.expirationDate; 1101 } 1102 1103 public boolean hasExpirationDateElement() { 1104 return this.expirationDate != null && !this.expirationDate.isEmpty(); 1105 } 1106 1107 public boolean hasExpirationDate() { 1108 return this.expirationDate != null && !this.expirationDate.isEmpty(); 1109 } 1110 1111 /** 1112 * @param value {@link #expirationDate} (When this specific batch of product will expire.). This is the underlying object with id, value and extensions. The accessor "getExpirationDate" gives direct access to the value 1113 */ 1114 public MedicationPackageBatchComponent setExpirationDateElement(DateTimeType value) { 1115 this.expirationDate = value; 1116 return this; 1117 } 1118 1119 /** 1120 * @return When this specific batch of product will expire. 1121 */ 1122 public Date getExpirationDate() { 1123 return this.expirationDate == null ? null : this.expirationDate.getValue(); 1124 } 1125 1126 /** 1127 * @param value When this specific batch of product will expire. 1128 */ 1129 public MedicationPackageBatchComponent setExpirationDate(Date value) { 1130 if (value == null) 1131 this.expirationDate = null; 1132 else { 1133 if (this.expirationDate == null) 1134 this.expirationDate = new DateTimeType(); 1135 this.expirationDate.setValue(value); 1136 } 1137 return this; 1138 } 1139 1140 protected void listChildren(List<Property> children) { 1141 super.listChildren(children); 1142 children.add(new Property("lotNumber", "string", "The assigned lot number of a batch of the specified product.", 0, 1, lotNumber)); 1143 children.add(new Property("expirationDate", "dateTime", "When this specific batch of product will expire.", 0, 1, expirationDate)); 1144 } 1145 1146 @Override 1147 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 1148 switch (_hash) { 1149 case 462547450: /*lotNumber*/ return new Property("lotNumber", "string", "The assigned lot number of a batch of the specified product.", 0, 1, lotNumber); 1150 case -668811523: /*expirationDate*/ return new Property("expirationDate", "dateTime", "When this specific batch of product will expire.", 0, 1, expirationDate); 1151 default: return super.getNamedProperty(_hash, _name, _checkValid); 1152 } 1153 1154 } 1155 1156 @Override 1157 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 1158 switch (hash) { 1159 case 462547450: /*lotNumber*/ return this.lotNumber == null ? new Base[0] : new Base[] {this.lotNumber}; // StringType 1160 case -668811523: /*expirationDate*/ return this.expirationDate == null ? new Base[0] : new Base[] {this.expirationDate}; // DateTimeType 1161 default: return super.getProperty(hash, name, checkValid); 1162 } 1163 1164 } 1165 1166 @Override 1167 public Base setProperty(int hash, String name, Base value) throws FHIRException { 1168 switch (hash) { 1169 case 462547450: // lotNumber 1170 this.lotNumber = castToString(value); // StringType 1171 return value; 1172 case -668811523: // expirationDate 1173 this.expirationDate = castToDateTime(value); // DateTimeType 1174 return value; 1175 default: return super.setProperty(hash, name, value); 1176 } 1177 1178 } 1179 1180 @Override 1181 public Base setProperty(String name, Base value) throws FHIRException { 1182 if (name.equals("lotNumber")) { 1183 this.lotNumber = castToString(value); // StringType 1184 } else if (name.equals("expirationDate")) { 1185 this.expirationDate = castToDateTime(value); // DateTimeType 1186 } else 1187 return super.setProperty(name, value); 1188 return value; 1189 } 1190 1191 @Override 1192 public Base makeProperty(int hash, String name) throws FHIRException { 1193 switch (hash) { 1194 case 462547450: return getLotNumberElement(); 1195 case -668811523: return getExpirationDateElement(); 1196 default: return super.makeProperty(hash, name); 1197 } 1198 1199 } 1200 1201 @Override 1202 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 1203 switch (hash) { 1204 case 462547450: /*lotNumber*/ return new String[] {"string"}; 1205 case -668811523: /*expirationDate*/ return new String[] {"dateTime"}; 1206 default: return super.getTypesForProperty(hash, name); 1207 } 1208 1209 } 1210 1211 @Override 1212 public Base addChild(String name) throws FHIRException { 1213 if (name.equals("lotNumber")) { 1214 throw new FHIRException("Cannot call addChild on a primitive type Medication.lotNumber"); 1215 } 1216 else if (name.equals("expirationDate")) { 1217 throw new FHIRException("Cannot call addChild on a primitive type Medication.expirationDate"); 1218 } 1219 else 1220 return super.addChild(name); 1221 } 1222 1223 public MedicationPackageBatchComponent copy() { 1224 MedicationPackageBatchComponent dst = new MedicationPackageBatchComponent(); 1225 copyValues(dst); 1226 dst.lotNumber = lotNumber == null ? null : lotNumber.copy(); 1227 dst.expirationDate = expirationDate == null ? null : expirationDate.copy(); 1228 return dst; 1229 } 1230 1231 @Override 1232 public boolean equalsDeep(Base other_) { 1233 if (!super.equalsDeep(other_)) 1234 return false; 1235 if (!(other_ instanceof MedicationPackageBatchComponent)) 1236 return false; 1237 MedicationPackageBatchComponent o = (MedicationPackageBatchComponent) other_; 1238 return compareDeep(lotNumber, o.lotNumber, true) && compareDeep(expirationDate, o.expirationDate, true) 1239 ; 1240 } 1241 1242 @Override 1243 public boolean equalsShallow(Base other_) { 1244 if (!super.equalsShallow(other_)) 1245 return false; 1246 if (!(other_ instanceof MedicationPackageBatchComponent)) 1247 return false; 1248 MedicationPackageBatchComponent o = (MedicationPackageBatchComponent) other_; 1249 return compareValues(lotNumber, o.lotNumber, true) && compareValues(expirationDate, o.expirationDate, true) 1250 ; 1251 } 1252 1253 public boolean isEmpty() { 1254 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(lotNumber, expirationDate 1255 ); 1256 } 1257 1258 public String fhirType() { 1259 return "Medication.package.batch"; 1260 1261 } 1262 1263 } 1264 1265 /** 1266 * A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems. 1267 */ 1268 @Child(name = "code", type = {CodeableConcept.class}, order=0, min=0, max=1, modifier=false, summary=true) 1269 @Description(shortDefinition="Codes that identify this medication", formalDefinition="A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems." ) 1270 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes") 1271 protected CodeableConcept code; 1272 1273 /** 1274 * A code to indicate if the medication is in active use. 1275 */ 1276 @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true) 1277 @Description(shortDefinition="active | inactive | entered-in-error", formalDefinition="A code to indicate if the medication is in active use." ) 1278 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-status") 1279 protected Enumeration<MedicationStatus> status; 1280 1281 /** 1282 * Set to true if the item is attributable to a specific manufacturer. 1283 */ 1284 @Child(name = "isBrand", type = {BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=true) 1285 @Description(shortDefinition="True if a brand", formalDefinition="Set to true if the item is attributable to a specific manufacturer." ) 1286 protected BooleanType isBrand; 1287 1288 /** 1289 * Set to true if the medication can be obtained without an order from a prescriber. 1290 */ 1291 @Child(name = "isOverTheCounter", type = {BooleanType.class}, order=3, min=0, max=1, modifier=false, summary=true) 1292 @Description(shortDefinition="True if medication does not require a prescription", formalDefinition="Set to true if the medication can be obtained without an order from a prescriber." ) 1293 protected BooleanType isOverTheCounter; 1294 1295 /** 1296 * Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product. 1297 */ 1298 @Child(name = "manufacturer", type = {Organization.class}, order=4, min=0, max=1, modifier=false, summary=true) 1299 @Description(shortDefinition="Manufacturer of the item", formalDefinition="Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product." ) 1300 protected Reference manufacturer; 1301 1302 /** 1303 * The actual object that is the target of the reference (Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.) 1304 */ 1305 protected Organization manufacturerTarget; 1306 1307 /** 1308 * Describes the form of the item. Powder; tablets; capsule. 1309 */ 1310 @Child(name = "form", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=false) 1311 @Description(shortDefinition="powder | tablets | capsule +", formalDefinition="Describes the form of the item. Powder; tablets; capsule." ) 1312 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-form-codes") 1313 protected CodeableConcept form; 1314 1315 /** 1316 * Identifies a particular constituent of interest in the product. 1317 */ 1318 @Child(name = "ingredient", type = {}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 1319 @Description(shortDefinition="Active or inactive ingredient", formalDefinition="Identifies a particular constituent of interest in the product." ) 1320 protected List<MedicationIngredientComponent> ingredient; 1321 1322 /** 1323 * Information that only applies to packages (not products). 1324 */ 1325 @Child(name = "package", type = {}, order=7, min=0, max=1, modifier=false, summary=false) 1326 @Description(shortDefinition="Details about packaged medications", formalDefinition="Information that only applies to packages (not products)." ) 1327 protected MedicationPackageComponent package_; 1328 1329 /** 1330 * Photo(s) or graphic representation(s) of the medication. 1331 */ 1332 @Child(name = "image", type = {Attachment.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 1333 @Description(shortDefinition="Picture of the medication", formalDefinition="Photo(s) or graphic representation(s) of the medication." ) 1334 protected List<Attachment> image; 1335 1336 private static final long serialVersionUID = 860383645L; 1337 1338 /** 1339 * Constructor 1340 */ 1341 public Medication() { 1342 super(); 1343 } 1344 1345 /** 1346 * @return {@link #code} (A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.) 1347 */ 1348 public CodeableConcept getCode() { 1349 if (this.code == null) 1350 if (Configuration.errorOnAutoCreate()) 1351 throw new Error("Attempt to auto-create Medication.code"); 1352 else if (Configuration.doAutoCreate()) 1353 this.code = new CodeableConcept(); // cc 1354 return this.code; 1355 } 1356 1357 public boolean hasCode() { 1358 return this.code != null && !this.code.isEmpty(); 1359 } 1360 1361 /** 1362 * @param value {@link #code} (A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.) 1363 */ 1364 public Medication setCode(CodeableConcept value) { 1365 this.code = value; 1366 return this; 1367 } 1368 1369 /** 1370 * @return {@link #status} (A code to indicate if the medication is in active use.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 1371 */ 1372 public Enumeration<MedicationStatus> getStatusElement() { 1373 if (this.status == null) 1374 if (Configuration.errorOnAutoCreate()) 1375 throw new Error("Attempt to auto-create Medication.status"); 1376 else if (Configuration.doAutoCreate()) 1377 this.status = new Enumeration<MedicationStatus>(new MedicationStatusEnumFactory()); // bb 1378 return this.status; 1379 } 1380 1381 public boolean hasStatusElement() { 1382 return this.status != null && !this.status.isEmpty(); 1383 } 1384 1385 public boolean hasStatus() { 1386 return this.status != null && !this.status.isEmpty(); 1387 } 1388 1389 /** 1390 * @param value {@link #status} (A code to indicate if the medication is in active use.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 1391 */ 1392 public Medication setStatusElement(Enumeration<MedicationStatus> value) { 1393 this.status = value; 1394 return this; 1395 } 1396 1397 /** 1398 * @return A code to indicate if the medication is in active use. 1399 */ 1400 public MedicationStatus getStatus() { 1401 return this.status == null ? null : this.status.getValue(); 1402 } 1403 1404 /** 1405 * @param value A code to indicate if the medication is in active use. 1406 */ 1407 public Medication setStatus(MedicationStatus value) { 1408 if (value == null) 1409 this.status = null; 1410 else { 1411 if (this.status == null) 1412 this.status = new Enumeration<MedicationStatus>(new MedicationStatusEnumFactory()); 1413 this.status.setValue(value); 1414 } 1415 return this; 1416 } 1417 1418 /** 1419 * @return {@link #isBrand} (Set to true if the item is attributable to a specific manufacturer.). This is the underlying object with id, value and extensions. The accessor "getIsBrand" gives direct access to the value 1420 */ 1421 public BooleanType getIsBrandElement() { 1422 if (this.isBrand == null) 1423 if (Configuration.errorOnAutoCreate()) 1424 throw new Error("Attempt to auto-create Medication.isBrand"); 1425 else if (Configuration.doAutoCreate()) 1426 this.isBrand = new BooleanType(); // bb 1427 return this.isBrand; 1428 } 1429 1430 public boolean hasIsBrandElement() { 1431 return this.isBrand != null && !this.isBrand.isEmpty(); 1432 } 1433 1434 public boolean hasIsBrand() { 1435 return this.isBrand != null && !this.isBrand.isEmpty(); 1436 } 1437 1438 /** 1439 * @param value {@link #isBrand} (Set to true if the item is attributable to a specific manufacturer.). This is the underlying object with id, value and extensions. The accessor "getIsBrand" gives direct access to the value 1440 */ 1441 public Medication setIsBrandElement(BooleanType value) { 1442 this.isBrand = value; 1443 return this; 1444 } 1445 1446 /** 1447 * @return Set to true if the item is attributable to a specific manufacturer. 1448 */ 1449 public boolean getIsBrand() { 1450 return this.isBrand == null || this.isBrand.isEmpty() ? false : this.isBrand.getValue(); 1451 } 1452 1453 /** 1454 * @param value Set to true if the item is attributable to a specific manufacturer. 1455 */ 1456 public Medication setIsBrand(boolean value) { 1457 if (this.isBrand == null) 1458 this.isBrand = new BooleanType(); 1459 this.isBrand.setValue(value); 1460 return this; 1461 } 1462 1463 /** 1464 * @return {@link #isOverTheCounter} (Set to true if the medication can be obtained without an order from a prescriber.). This is the underlying object with id, value and extensions. The accessor "getIsOverTheCounter" gives direct access to the value 1465 */ 1466 public BooleanType getIsOverTheCounterElement() { 1467 if (this.isOverTheCounter == null) 1468 if (Configuration.errorOnAutoCreate()) 1469 throw new Error("Attempt to auto-create Medication.isOverTheCounter"); 1470 else if (Configuration.doAutoCreate()) 1471 this.isOverTheCounter = new BooleanType(); // bb 1472 return this.isOverTheCounter; 1473 } 1474 1475 public boolean hasIsOverTheCounterElement() { 1476 return this.isOverTheCounter != null && !this.isOverTheCounter.isEmpty(); 1477 } 1478 1479 public boolean hasIsOverTheCounter() { 1480 return this.isOverTheCounter != null && !this.isOverTheCounter.isEmpty(); 1481 } 1482 1483 /** 1484 * @param value {@link #isOverTheCounter} (Set to true if the medication can be obtained without an order from a prescriber.). This is the underlying object with id, value and extensions. The accessor "getIsOverTheCounter" gives direct access to the value 1485 */ 1486 public Medication setIsOverTheCounterElement(BooleanType value) { 1487 this.isOverTheCounter = value; 1488 return this; 1489 } 1490 1491 /** 1492 * @return Set to true if the medication can be obtained without an order from a prescriber. 1493 */ 1494 public boolean getIsOverTheCounter() { 1495 return this.isOverTheCounter == null || this.isOverTheCounter.isEmpty() ? false : this.isOverTheCounter.getValue(); 1496 } 1497 1498 /** 1499 * @param value Set to true if the medication can be obtained without an order from a prescriber. 1500 */ 1501 public Medication setIsOverTheCounter(boolean value) { 1502 if (this.isOverTheCounter == null) 1503 this.isOverTheCounter = new BooleanType(); 1504 this.isOverTheCounter.setValue(value); 1505 return this; 1506 } 1507 1508 /** 1509 * @return {@link #manufacturer} (Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.) 1510 */ 1511 public Reference getManufacturer() { 1512 if (this.manufacturer == null) 1513 if (Configuration.errorOnAutoCreate()) 1514 throw new Error("Attempt to auto-create Medication.manufacturer"); 1515 else if (Configuration.doAutoCreate()) 1516 this.manufacturer = new Reference(); // cc 1517 return this.manufacturer; 1518 } 1519 1520 public boolean hasManufacturer() { 1521 return this.manufacturer != null && !this.manufacturer.isEmpty(); 1522 } 1523 1524 /** 1525 * @param value {@link #manufacturer} (Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.) 1526 */ 1527 public Medication setManufacturer(Reference value) { 1528 this.manufacturer = value; 1529 return this; 1530 } 1531 1532 /** 1533 * @return {@link #manufacturer} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.) 1534 */ 1535 public Organization getManufacturerTarget() { 1536 if (this.manufacturerTarget == null) 1537 if (Configuration.errorOnAutoCreate()) 1538 throw new Error("Attempt to auto-create Medication.manufacturer"); 1539 else if (Configuration.doAutoCreate()) 1540 this.manufacturerTarget = new Organization(); // aa 1541 return this.manufacturerTarget; 1542 } 1543 1544 /** 1545 * @param value {@link #manufacturer} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.) 1546 */ 1547 public Medication setManufacturerTarget(Organization value) { 1548 this.manufacturerTarget = value; 1549 return this; 1550 } 1551 1552 /** 1553 * @return {@link #form} (Describes the form of the item. Powder; tablets; capsule.) 1554 */ 1555 public CodeableConcept getForm() { 1556 if (this.form == null) 1557 if (Configuration.errorOnAutoCreate()) 1558 throw new Error("Attempt to auto-create Medication.form"); 1559 else if (Configuration.doAutoCreate()) 1560 this.form = new CodeableConcept(); // cc 1561 return this.form; 1562 } 1563 1564 public boolean hasForm() { 1565 return this.form != null && !this.form.isEmpty(); 1566 } 1567 1568 /** 1569 * @param value {@link #form} (Describes the form of the item. Powder; tablets; capsule.) 1570 */ 1571 public Medication setForm(CodeableConcept value) { 1572 this.form = value; 1573 return this; 1574 } 1575 1576 /** 1577 * @return {@link #ingredient} (Identifies a particular constituent of interest in the product.) 1578 */ 1579 public List<MedicationIngredientComponent> getIngredient() { 1580 if (this.ingredient == null) 1581 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1582 return this.ingredient; 1583 } 1584 1585 /** 1586 * @return Returns a reference to <code>this</code> for easy method chaining 1587 */ 1588 public Medication setIngredient(List<MedicationIngredientComponent> theIngredient) { 1589 this.ingredient = theIngredient; 1590 return this; 1591 } 1592 1593 public boolean hasIngredient() { 1594 if (this.ingredient == null) 1595 return false; 1596 for (MedicationIngredientComponent item : this.ingredient) 1597 if (!item.isEmpty()) 1598 return true; 1599 return false; 1600 } 1601 1602 public MedicationIngredientComponent addIngredient() { //3 1603 MedicationIngredientComponent t = new MedicationIngredientComponent(); 1604 if (this.ingredient == null) 1605 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1606 this.ingredient.add(t); 1607 return t; 1608 } 1609 1610 public Medication addIngredient(MedicationIngredientComponent t) { //3 1611 if (t == null) 1612 return this; 1613 if (this.ingredient == null) 1614 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1615 this.ingredient.add(t); 1616 return this; 1617 } 1618 1619 /** 1620 * @return The first repetition of repeating field {@link #ingredient}, creating it if it does not already exist 1621 */ 1622 public MedicationIngredientComponent getIngredientFirstRep() { 1623 if (getIngredient().isEmpty()) { 1624 addIngredient(); 1625 } 1626 return getIngredient().get(0); 1627 } 1628 1629 /** 1630 * @return {@link #package_} (Information that only applies to packages (not products).) 1631 */ 1632 public MedicationPackageComponent getPackage() { 1633 if (this.package_ == null) 1634 if (Configuration.errorOnAutoCreate()) 1635 throw new Error("Attempt to auto-create Medication.package_"); 1636 else if (Configuration.doAutoCreate()) 1637 this.package_ = new MedicationPackageComponent(); // cc 1638 return this.package_; 1639 } 1640 1641 public boolean hasPackage() { 1642 return this.package_ != null && !this.package_.isEmpty(); 1643 } 1644 1645 /** 1646 * @param value {@link #package_} (Information that only applies to packages (not products).) 1647 */ 1648 public Medication setPackage(MedicationPackageComponent value) { 1649 this.package_ = value; 1650 return this; 1651 } 1652 1653 /** 1654 * @return {@link #image} (Photo(s) or graphic representation(s) of the medication.) 1655 */ 1656 public List<Attachment> getImage() { 1657 if (this.image == null) 1658 this.image = new ArrayList<Attachment>(); 1659 return this.image; 1660 } 1661 1662 /** 1663 * @return Returns a reference to <code>this</code> for easy method chaining 1664 */ 1665 public Medication setImage(List<Attachment> theImage) { 1666 this.image = theImage; 1667 return this; 1668 } 1669 1670 public boolean hasImage() { 1671 if (this.image == null) 1672 return false; 1673 for (Attachment item : this.image) 1674 if (!item.isEmpty()) 1675 return true; 1676 return false; 1677 } 1678 1679 public Attachment addImage() { //3 1680 Attachment t = new Attachment(); 1681 if (this.image == null) 1682 this.image = new ArrayList<Attachment>(); 1683 this.image.add(t); 1684 return t; 1685 } 1686 1687 public Medication addImage(Attachment t) { //3 1688 if (t == null) 1689 return this; 1690 if (this.image == null) 1691 this.image = new ArrayList<Attachment>(); 1692 this.image.add(t); 1693 return this; 1694 } 1695 1696 /** 1697 * @return The first repetition of repeating field {@link #image}, creating it if it does not already exist 1698 */ 1699 public Attachment getImageFirstRep() { 1700 if (getImage().isEmpty()) { 1701 addImage(); 1702 } 1703 return getImage().get(0); 1704 } 1705 1706 protected void listChildren(List<Property> children) { 1707 super.listChildren(children); 1708 children.add(new Property("code", "CodeableConcept", "A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.", 0, 1, code)); 1709 children.add(new Property("status", "code", "A code to indicate if the medication is in active use.", 0, 1, status)); 1710 children.add(new Property("isBrand", "boolean", "Set to true if the item is attributable to a specific manufacturer.", 0, 1, isBrand)); 1711 children.add(new Property("isOverTheCounter", "boolean", "Set to true if the medication can be obtained without an order from a prescriber.", 0, 1, isOverTheCounter)); 1712 children.add(new Property("manufacturer", "Reference(Organization)", "Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.", 0, 1, manufacturer)); 1713 children.add(new Property("form", "CodeableConcept", "Describes the form of the item. Powder; tablets; capsule.", 0, 1, form)); 1714 children.add(new Property("ingredient", "", "Identifies a particular constituent of interest in the product.", 0, java.lang.Integer.MAX_VALUE, ingredient)); 1715 children.add(new Property("package", "", "Information that only applies to packages (not products).", 0, 1, package_)); 1716 children.add(new Property("image", "Attachment", "Photo(s) or graphic representation(s) of the medication.", 0, java.lang.Integer.MAX_VALUE, image)); 1717 } 1718 1719 @Override 1720 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 1721 switch (_hash) { 1722 case 3059181: /*code*/ return new Property("code", "CodeableConcept", "A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.", 0, 1, code); 1723 case -892481550: /*status*/ return new Property("status", "code", "A code to indicate if the medication is in active use.", 0, 1, status); 1724 case 2055403645: /*isBrand*/ return new Property("isBrand", "boolean", "Set to true if the item is attributable to a specific manufacturer.", 0, 1, isBrand); 1725 case -650796023: /*isOverTheCounter*/ return new Property("isOverTheCounter", "boolean", "Set to true if the medication can be obtained without an order from a prescriber.", 0, 1, isOverTheCounter); 1726 case -1969347631: /*manufacturer*/ return new Property("manufacturer", "Reference(Organization)", "Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.", 0, 1, manufacturer); 1727 case 3148996: /*form*/ return new Property("form", "CodeableConcept", "Describes the form of the item. Powder; tablets; capsule.", 0, 1, form); 1728 case -206409263: /*ingredient*/ return new Property("ingredient", "", "Identifies a particular constituent of interest in the product.", 0, java.lang.Integer.MAX_VALUE, ingredient); 1729 case -807062458: /*package*/ return new Property("package", "", "Information that only applies to packages (not products).", 0, 1, package_); 1730 case 100313435: /*image*/ return new Property("image", "Attachment", "Photo(s) or graphic representation(s) of the medication.", 0, java.lang.Integer.MAX_VALUE, image); 1731 default: return super.getNamedProperty(_hash, _name, _checkValid); 1732 } 1733 1734 } 1735 1736 @Override 1737 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 1738 switch (hash) { 1739 case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept 1740 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationStatus> 1741 case 2055403645: /*isBrand*/ return this.isBrand == null ? new Base[0] : new Base[] {this.isBrand}; // BooleanType 1742 case -650796023: /*isOverTheCounter*/ return this.isOverTheCounter == null ? new Base[0] : new Base[] {this.isOverTheCounter}; // BooleanType 1743 case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : new Base[] {this.manufacturer}; // Reference 1744 case 3148996: /*form*/ return this.form == null ? new Base[0] : new Base[] {this.form}; // CodeableConcept 1745 case -206409263: /*ingredient*/ return this.ingredient == null ? new Base[0] : this.ingredient.toArray(new Base[this.ingredient.size()]); // MedicationIngredientComponent 1746 case -807062458: /*package*/ return this.package_ == null ? new Base[0] : new Base[] {this.package_}; // MedicationPackageComponent 1747 case 100313435: /*image*/ return this.image == null ? new Base[0] : this.image.toArray(new Base[this.image.size()]); // Attachment 1748 default: return super.getProperty(hash, name, checkValid); 1749 } 1750 1751 } 1752 1753 @Override 1754 public Base setProperty(int hash, String name, Base value) throws FHIRException { 1755 switch (hash) { 1756 case 3059181: // code 1757 this.code = castToCodeableConcept(value); // CodeableConcept 1758 return value; 1759 case -892481550: // status 1760 value = new MedicationStatusEnumFactory().fromType(castToCode(value)); 1761 this.status = (Enumeration) value; // Enumeration<MedicationStatus> 1762 return value; 1763 case 2055403645: // isBrand 1764 this.isBrand = castToBoolean(value); // BooleanType 1765 return value; 1766 case -650796023: // isOverTheCounter 1767 this.isOverTheCounter = castToBoolean(value); // BooleanType 1768 return value; 1769 case -1969347631: // manufacturer 1770 this.manufacturer = castToReference(value); // Reference 1771 return value; 1772 case 3148996: // form 1773 this.form = castToCodeableConcept(value); // CodeableConcept 1774 return value; 1775 case -206409263: // ingredient 1776 this.getIngredient().add((MedicationIngredientComponent) value); // MedicationIngredientComponent 1777 return value; 1778 case -807062458: // package 1779 this.package_ = (MedicationPackageComponent) value; // MedicationPackageComponent 1780 return value; 1781 case 100313435: // image 1782 this.getImage().add(castToAttachment(value)); // Attachment 1783 return value; 1784 default: return super.setProperty(hash, name, value); 1785 } 1786 1787 } 1788 1789 @Override 1790 public Base setProperty(String name, Base value) throws FHIRException { 1791 if (name.equals("code")) { 1792 this.code = castToCodeableConcept(value); // CodeableConcept 1793 } else if (name.equals("status")) { 1794 value = new MedicationStatusEnumFactory().fromType(castToCode(value)); 1795 this.status = (Enumeration) value; // Enumeration<MedicationStatus> 1796 } else if (name.equals("isBrand")) { 1797 this.isBrand = castToBoolean(value); // BooleanType 1798 } else if (name.equals("isOverTheCounter")) { 1799 this.isOverTheCounter = castToBoolean(value); // BooleanType 1800 } else if (name.equals("manufacturer")) { 1801 this.manufacturer = castToReference(value); // Reference 1802 } else if (name.equals("form")) { 1803 this.form = castToCodeableConcept(value); // CodeableConcept 1804 } else if (name.equals("ingredient")) { 1805 this.getIngredient().add((MedicationIngredientComponent) value); 1806 } else if (name.equals("package")) { 1807 this.package_ = (MedicationPackageComponent) value; // MedicationPackageComponent 1808 } else if (name.equals("image")) { 1809 this.getImage().add(castToAttachment(value)); 1810 } else 1811 return super.setProperty(name, value); 1812 return value; 1813 } 1814 1815 @Override 1816 public Base makeProperty(int hash, String name) throws FHIRException { 1817 switch (hash) { 1818 case 3059181: return getCode(); 1819 case -892481550: return getStatusElement(); 1820 case 2055403645: return getIsBrandElement(); 1821 case -650796023: return getIsOverTheCounterElement(); 1822 case -1969347631: return getManufacturer(); 1823 case 3148996: return getForm(); 1824 case -206409263: return addIngredient(); 1825 case -807062458: return getPackage(); 1826 case 100313435: return addImage(); 1827 default: return super.makeProperty(hash, name); 1828 } 1829 1830 } 1831 1832 @Override 1833 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 1834 switch (hash) { 1835 case 3059181: /*code*/ return new String[] {"CodeableConcept"}; 1836 case -892481550: /*status*/ return new String[] {"code"}; 1837 case 2055403645: /*isBrand*/ return new String[] {"boolean"}; 1838 case -650796023: /*isOverTheCounter*/ return new String[] {"boolean"}; 1839 case -1969347631: /*manufacturer*/ return new String[] {"Reference"}; 1840 case 3148996: /*form*/ return new String[] {"CodeableConcept"}; 1841 case -206409263: /*ingredient*/ return new String[] {}; 1842 case -807062458: /*package*/ return new String[] {}; 1843 case 100313435: /*image*/ return new String[] {"Attachment"}; 1844 default: return super.getTypesForProperty(hash, name); 1845 } 1846 1847 } 1848 1849 @Override 1850 public Base addChild(String name) throws FHIRException { 1851 if (name.equals("code")) { 1852 this.code = new CodeableConcept(); 1853 return this.code; 1854 } 1855 else if (name.equals("status")) { 1856 throw new FHIRException("Cannot call addChild on a primitive type Medication.status"); 1857 } 1858 else if (name.equals("isBrand")) { 1859 throw new FHIRException("Cannot call addChild on a primitive type Medication.isBrand"); 1860 } 1861 else if (name.equals("isOverTheCounter")) { 1862 throw new FHIRException("Cannot call addChild on a primitive type Medication.isOverTheCounter"); 1863 } 1864 else if (name.equals("manufacturer")) { 1865 this.manufacturer = new Reference(); 1866 return this.manufacturer; 1867 } 1868 else if (name.equals("form")) { 1869 this.form = new CodeableConcept(); 1870 return this.form; 1871 } 1872 else if (name.equals("ingredient")) { 1873 return addIngredient(); 1874 } 1875 else if (name.equals("package")) { 1876 this.package_ = new MedicationPackageComponent(); 1877 return this.package_; 1878 } 1879 else if (name.equals("image")) { 1880 return addImage(); 1881 } 1882 else 1883 return super.addChild(name); 1884 } 1885 1886 public String fhirType() { 1887 return "Medication"; 1888 1889 } 1890 1891 public Medication copy() { 1892 Medication dst = new Medication(); 1893 copyValues(dst); 1894 dst.code = code == null ? null : code.copy(); 1895 dst.status = status == null ? null : status.copy(); 1896 dst.isBrand = isBrand == null ? null : isBrand.copy(); 1897 dst.isOverTheCounter = isOverTheCounter == null ? null : isOverTheCounter.copy(); 1898 dst.manufacturer = manufacturer == null ? null : manufacturer.copy(); 1899 dst.form = form == null ? null : form.copy(); 1900 if (ingredient != null) { 1901 dst.ingredient = new ArrayList<MedicationIngredientComponent>(); 1902 for (MedicationIngredientComponent i : ingredient) 1903 dst.ingredient.add(i.copy()); 1904 }; 1905 dst.package_ = package_ == null ? null : package_.copy(); 1906 if (image != null) { 1907 dst.image = new ArrayList<Attachment>(); 1908 for (Attachment i : image) 1909 dst.image.add(i.copy()); 1910 }; 1911 return dst; 1912 } 1913 1914 protected Medication typedCopy() { 1915 return copy(); 1916 } 1917 1918 @Override 1919 public boolean equalsDeep(Base other_) { 1920 if (!super.equalsDeep(other_)) 1921 return false; 1922 if (!(other_ instanceof Medication)) 1923 return false; 1924 Medication o = (Medication) other_; 1925 return compareDeep(code, o.code, true) && compareDeep(status, o.status, true) && compareDeep(isBrand, o.isBrand, true) 1926 && compareDeep(isOverTheCounter, o.isOverTheCounter, true) && compareDeep(manufacturer, o.manufacturer, true) 1927 && compareDeep(form, o.form, true) && compareDeep(ingredient, o.ingredient, true) && compareDeep(package_, o.package_, true) 1928 && compareDeep(image, o.image, true); 1929 } 1930 1931 @Override 1932 public boolean equalsShallow(Base other_) { 1933 if (!super.equalsShallow(other_)) 1934 return false; 1935 if (!(other_ instanceof Medication)) 1936 return false; 1937 Medication o = (Medication) other_; 1938 return compareValues(status, o.status, true) && compareValues(isBrand, o.isBrand, true) && compareValues(isOverTheCounter, o.isOverTheCounter, true) 1939 ; 1940 } 1941 1942 public boolean isEmpty() { 1943 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, status, isBrand, isOverTheCounter 1944 , manufacturer, form, ingredient, package_, image); 1945 } 1946 1947 @Override 1948 public ResourceType getResourceType() { 1949 return ResourceType.Medication; 1950 } 1951 1952 /** 1953 * Search parameter: <b>ingredient-code</b> 1954 * <p> 1955 * Description: <b>The product contained</b><br> 1956 * Type: <b>token</b><br> 1957 * Path: <b>Medication.ingredient.itemCodeableConcept</b><br> 1958 * </p> 1959 */ 1960 @SearchParamDefinition(name="ingredient-code", path="Medication.ingredient.item.as(CodeableConcept)", description="The product contained", type="token" ) 1961 public static final String SP_INGREDIENT_CODE = "ingredient-code"; 1962 /** 1963 * <b>Fluent Client</b> search parameter constant for <b>ingredient-code</b> 1964 * <p> 1965 * Description: <b>The product contained</b><br> 1966 * Type: <b>token</b><br> 1967 * Path: <b>Medication.ingredient.itemCodeableConcept</b><br> 1968 * </p> 1969 */ 1970 public static final ca.uhn.fhir.rest.gclient.TokenClientParam INGREDIENT_CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INGREDIENT_CODE); 1971 1972 /** 1973 * Search parameter: <b>container</b> 1974 * <p> 1975 * Description: <b>E.g. box, vial, blister-pack</b><br> 1976 * Type: <b>token</b><br> 1977 * Path: <b>Medication.package.container</b><br> 1978 * </p> 1979 */ 1980 @SearchParamDefinition(name="container", path="Medication.package.container", description="E.g. box, vial, blister-pack", type="token" ) 1981 public static final String SP_CONTAINER = "container"; 1982 /** 1983 * <b>Fluent Client</b> search parameter constant for <b>container</b> 1984 * <p> 1985 * Description: <b>E.g. box, vial, blister-pack</b><br> 1986 * Type: <b>token</b><br> 1987 * Path: <b>Medication.package.container</b><br> 1988 * </p> 1989 */ 1990 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTAINER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTAINER); 1991 1992 /** 1993 * Search parameter: <b>package-item</b> 1994 * <p> 1995 * Description: <b>The item in the package</b><br> 1996 * Type: <b>reference</b><br> 1997 * Path: <b>Medication.package.content.itemReference</b><br> 1998 * </p> 1999 */ 2000 @SearchParamDefinition(name="package-item", path="Medication.package.content.item.as(Reference)", description="The item in the package", type="reference", target={Medication.class } ) 2001 public static final String SP_PACKAGE_ITEM = "package-item"; 2002 /** 2003 * <b>Fluent Client</b> search parameter constant for <b>package-item</b> 2004 * <p> 2005 * Description: <b>The item in the package</b><br> 2006 * Type: <b>reference</b><br> 2007 * Path: <b>Medication.package.content.itemReference</b><br> 2008 * </p> 2009 */ 2010 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PACKAGE_ITEM = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PACKAGE_ITEM); 2011 2012/** 2013 * Constant for fluent queries to be used to add include statements. Specifies 2014 * the path value of "<b>Medication:package-item</b>". 2015 */ 2016 public static final ca.uhn.fhir.model.api.Include INCLUDE_PACKAGE_ITEM = new ca.uhn.fhir.model.api.Include("Medication:package-item").toLocked(); 2017 2018 /** 2019 * Search parameter: <b>code</b> 2020 * <p> 2021 * Description: <b>Codes that identify this medication</b><br> 2022 * Type: <b>token</b><br> 2023 * Path: <b>Medication.code</b><br> 2024 * </p> 2025 */ 2026 @SearchParamDefinition(name="code", path="Medication.code", description="Codes that identify this medication", type="token" ) 2027 public static final String SP_CODE = "code"; 2028 /** 2029 * <b>Fluent Client</b> search parameter constant for <b>code</b> 2030 * <p> 2031 * Description: <b>Codes that identify this medication</b><br> 2032 * Type: <b>token</b><br> 2033 * Path: <b>Medication.code</b><br> 2034 * </p> 2035 */ 2036 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE); 2037 2038 /** 2039 * Search parameter: <b>ingredient</b> 2040 * <p> 2041 * Description: <b>The product contained</b><br> 2042 * Type: <b>reference</b><br> 2043 * Path: <b>Medication.ingredient.itemReference</b><br> 2044 * </p> 2045 */ 2046 @SearchParamDefinition(name="ingredient", path="Medication.ingredient.item.as(Reference)", description="The product contained", type="reference", target={Medication.class, Substance.class } ) 2047 public static final String SP_INGREDIENT = "ingredient"; 2048 /** 2049 * <b>Fluent Client</b> search parameter constant for <b>ingredient</b> 2050 * <p> 2051 * Description: <b>The product contained</b><br> 2052 * Type: <b>reference</b><br> 2053 * Path: <b>Medication.ingredient.itemReference</b><br> 2054 * </p> 2055 */ 2056 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INGREDIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INGREDIENT); 2057 2058/** 2059 * Constant for fluent queries to be used to add include statements. Specifies 2060 * the path value of "<b>Medication:ingredient</b>". 2061 */ 2062 public static final ca.uhn.fhir.model.api.Include INCLUDE_INGREDIENT = new ca.uhn.fhir.model.api.Include("Medication:ingredient").toLocked(); 2063 2064 /** 2065 * Search parameter: <b>form</b> 2066 * <p> 2067 * Description: <b>powder | tablets | capsule +</b><br> 2068 * Type: <b>token</b><br> 2069 * Path: <b>Medication.form</b><br> 2070 * </p> 2071 */ 2072 @SearchParamDefinition(name="form", path="Medication.form", description="powder | tablets | capsule +", type="token" ) 2073 public static final String SP_FORM = "form"; 2074 /** 2075 * <b>Fluent Client</b> search parameter constant for <b>form</b> 2076 * <p> 2077 * Description: <b>powder | tablets | capsule +</b><br> 2078 * Type: <b>token</b><br> 2079 * Path: <b>Medication.form</b><br> 2080 * </p> 2081 */ 2082 public static final ca.uhn.fhir.rest.gclient.TokenClientParam FORM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_FORM); 2083 2084 /** 2085 * Search parameter: <b>package-item-code</b> 2086 * <p> 2087 * Description: <b>The item in the package</b><br> 2088 * Type: <b>token</b><br> 2089 * Path: <b>Medication.package.content.itemCodeableConcept</b><br> 2090 * </p> 2091 */ 2092 @SearchParamDefinition(name="package-item-code", path="Medication.package.content.item.as(CodeableConcept)", description="The item in the package", type="token" ) 2093 public static final String SP_PACKAGE_ITEM_CODE = "package-item-code"; 2094 /** 2095 * <b>Fluent Client</b> search parameter constant for <b>package-item-code</b> 2096 * <p> 2097 * Description: <b>The item in the package</b><br> 2098 * Type: <b>token</b><br> 2099 * Path: <b>Medication.package.content.itemCodeableConcept</b><br> 2100 * </p> 2101 */ 2102 public static final ca.uhn.fhir.rest.gclient.TokenClientParam PACKAGE_ITEM_CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PACKAGE_ITEM_CODE); 2103 2104 /** 2105 * Search parameter: <b>manufacturer</b> 2106 * <p> 2107 * Description: <b>Manufacturer of the item</b><br> 2108 * Type: <b>reference</b><br> 2109 * Path: <b>Medication.manufacturer</b><br> 2110 * </p> 2111 */ 2112 @SearchParamDefinition(name="manufacturer", path="Medication.manufacturer", description="Manufacturer of the item", type="reference", target={Organization.class } ) 2113 public static final String SP_MANUFACTURER = "manufacturer"; 2114 /** 2115 * <b>Fluent Client</b> search parameter constant for <b>manufacturer</b> 2116 * <p> 2117 * Description: <b>Manufacturer of the item</b><br> 2118 * Type: <b>reference</b><br> 2119 * Path: <b>Medication.manufacturer</b><br> 2120 * </p> 2121 */ 2122 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MANUFACTURER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MANUFACTURER); 2123 2124/** 2125 * Constant for fluent queries to be used to add include statements. Specifies 2126 * the path value of "<b>Medication:manufacturer</b>". 2127 */ 2128 public static final ca.uhn.fhir.model.api.Include INCLUDE_MANUFACTURER = new ca.uhn.fhir.model.api.Include("Medication:manufacturer").toLocked(); 2129 2130 /** 2131 * Search parameter: <b>over-the-counter</b> 2132 * <p> 2133 * Description: <b>True if medication does not require a prescription</b><br> 2134 * Type: <b>token</b><br> 2135 * Path: <b>Medication.isOverTheCounter</b><br> 2136 * </p> 2137 */ 2138 @SearchParamDefinition(name="over-the-counter", path="Medication.isOverTheCounter", description="True if medication does not require a prescription", type="token" ) 2139 public static final String SP_OVER_THE_COUNTER = "over-the-counter"; 2140 /** 2141 * <b>Fluent Client</b> search parameter constant for <b>over-the-counter</b> 2142 * <p> 2143 * Description: <b>True if medication does not require a prescription</b><br> 2144 * Type: <b>token</b><br> 2145 * Path: <b>Medication.isOverTheCounter</b><br> 2146 * </p> 2147 */ 2148 public static final ca.uhn.fhir.rest.gclient.TokenClientParam OVER_THE_COUNTER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_OVER_THE_COUNTER); 2149 2150 /** 2151 * Search parameter: <b>status</b> 2152 * <p> 2153 * Description: <b>active | inactive | entered-in-error</b><br> 2154 * Type: <b>token</b><br> 2155 * Path: <b>Medication.status</b><br> 2156 * </p> 2157 */ 2158 @SearchParamDefinition(name="status", path="Medication.status", description="active | inactive | entered-in-error", type="token" ) 2159 public static final String SP_STATUS = "status"; 2160 /** 2161 * <b>Fluent Client</b> search parameter constant for <b>status</b> 2162 * <p> 2163 * Description: <b>active | inactive | entered-in-error</b><br> 2164 * Type: <b>token</b><br> 2165 * Path: <b>Medication.status</b><br> 2166 * </p> 2167 */ 2168 public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS); 2169 2170 2171} 2172