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