001package org.hl7.fhir.r4.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0 033 034import java.util.*; 035 036import org.hl7.fhir.utilities.Utilities; 037import ca.uhn.fhir.model.api.annotation.ResourceDef; 038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 039import ca.uhn.fhir.model.api.annotation.Child; 040import ca.uhn.fhir.model.api.annotation.ChildOrder; 041import ca.uhn.fhir.model.api.annotation.Description; 042import ca.uhn.fhir.model.api.annotation.Block; 043import org.hl7.fhir.instance.model.api.*; 044import org.hl7.fhir.exceptions.FHIRException; 045/** 046 * This resource is primarily used for the identification and definition of a medication for the purposes of prescribing, dispensing, and administering a medication as well as for making statements about medication use. 047 */ 048@ResourceDef(name="Medication", profile="http://hl7.org/fhir/StructureDefinition/Medication") 049public class Medication extends DomainResource { 050 051 public enum MedicationStatus { 052 /** 053 * The medication is available for use. 054 */ 055 ACTIVE, 056 /** 057 * The medication is not available for use. 058 */ 059 INACTIVE, 060 /** 061 * The medication was entered in error. 062 */ 063 ENTEREDINERROR, 064 /** 065 * added to help the parsers with the generic types 066 */ 067 NULL; 068 public static MedicationStatus fromCode(String codeString) throws FHIRException { 069 if (codeString == null || "".equals(codeString)) 070 return null; 071 if ("active".equals(codeString)) 072 return ACTIVE; 073 if ("inactive".equals(codeString)) 074 return INACTIVE; 075 if ("entered-in-error".equals(codeString)) 076 return ENTEREDINERROR; 077 if (Configuration.isAcceptInvalidEnums()) 078 return null; 079 else 080 throw new FHIRException("Unknown MedicationStatus code '"+codeString+"'"); 081 } 082 public String toCode() { 083 switch (this) { 084 case ACTIVE: return "active"; 085 case INACTIVE: return "inactive"; 086 case ENTEREDINERROR: return "entered-in-error"; 087 default: return "?"; 088 } 089 } 090 public String getSystem() { 091 switch (this) { 092 case ACTIVE: return "http://hl7.org/fhir/medication-status"; 093 case INACTIVE: return "http://hl7.org/fhir/medication-status"; 094 case ENTEREDINERROR: return "http://hl7.org/fhir/medication-status"; 095 default: return "?"; 096 } 097 } 098 public String getDefinition() { 099 switch (this) { 100 case ACTIVE: return "The medication is available for use."; 101 case INACTIVE: return "The medication is not available for use."; 102 case ENTEREDINERROR: return "The medication was entered in error."; 103 default: return "?"; 104 } 105 } 106 public String getDisplay() { 107 switch (this) { 108 case ACTIVE: return "Active"; 109 case INACTIVE: return "Inactive"; 110 case ENTEREDINERROR: return "Entered in Error"; 111 default: return "?"; 112 } 113 } 114 } 115 116 public static class MedicationStatusEnumFactory implements EnumFactory<MedicationStatus> { 117 public MedicationStatus fromCode(String codeString) throws IllegalArgumentException { 118 if (codeString == null || "".equals(codeString)) 119 if (codeString == null || "".equals(codeString)) 120 return null; 121 if ("active".equals(codeString)) 122 return MedicationStatus.ACTIVE; 123 if ("inactive".equals(codeString)) 124 return MedicationStatus.INACTIVE; 125 if ("entered-in-error".equals(codeString)) 126 return MedicationStatus.ENTEREDINERROR; 127 throw new IllegalArgumentException("Unknown MedicationStatus code '"+codeString+"'"); 128 } 129 public Enumeration<MedicationStatus> fromType(Base code) throws FHIRException { 130 if (code == null) 131 return null; 132 if (code.isEmpty()) 133 return new Enumeration<MedicationStatus>(this); 134 String codeString = ((PrimitiveType) code).asStringValue(); 135 if (codeString == null || "".equals(codeString)) 136 return null; 137 if ("active".equals(codeString)) 138 return new Enumeration<MedicationStatus>(this, MedicationStatus.ACTIVE); 139 if ("inactive".equals(codeString)) 140 return new Enumeration<MedicationStatus>(this, MedicationStatus.INACTIVE); 141 if ("entered-in-error".equals(codeString)) 142 return new Enumeration<MedicationStatus>(this, MedicationStatus.ENTEREDINERROR); 143 throw new FHIRException("Unknown MedicationStatus code '"+codeString+"'"); 144 } 145 public String toCode(MedicationStatus code) { 146 if (code == MedicationStatus.ACTIVE) 147 return "active"; 148 if (code == MedicationStatus.INACTIVE) 149 return "inactive"; 150 if (code == MedicationStatus.ENTEREDINERROR) 151 return "entered-in-error"; 152 return "?"; 153 } 154 public String toSystem(MedicationStatus code) { 155 return code.getSystem(); 156 } 157 } 158 159 @Block() 160 public static class MedicationIngredientComponent extends BackboneElement implements IBaseBackboneElement { 161 /** 162 * The actual ingredient - either a substance (simple ingredient) or another medication of a medication. 163 */ 164 @Child(name = "item", type = {CodeableConcept.class, Substance.class, Medication.class}, order=1, min=1, max=1, modifier=false, summary=false) 165 @Description(shortDefinition="The actual ingredient or content", formalDefinition="The actual ingredient - either a substance (simple ingredient) or another medication of a medication." ) 166 protected Type item; 167 168 /** 169 * Indication of whether this ingredient affects the therapeutic action of the drug. 170 */ 171 @Child(name = "isActive", type = {BooleanType.class}, order=2, min=0, max=1, modifier=false, summary=false) 172 @Description(shortDefinition="Active ingredient indicator", formalDefinition="Indication of whether this ingredient affects the therapeutic action of the drug." ) 173 protected BooleanType isActive; 174 175 /** 176 * 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. 177 */ 178 @Child(name = "amount", type = {Ratio.class}, order=3, min=0, max=1, modifier=false, summary=false) 179 @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." ) 180 protected Ratio amount; 181 182 private static final long serialVersionUID = -1796655982L; 183 184 /** 185 * Constructor 186 */ 187 public MedicationIngredientComponent() { 188 super(); 189 } 190 191 /** 192 * Constructor 193 */ 194 public MedicationIngredientComponent(Type item) { 195 super(); 196 this.item = item; 197 } 198 199 /** 200 * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication of a medication.) 201 */ 202 public Type getItem() { 203 return this.item; 204 } 205 206 /** 207 * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication of a medication.) 208 */ 209 public CodeableConcept getItemCodeableConcept() throws FHIRException { 210 if (this.item == null) 211 return null; 212 if (!(this.item instanceof CodeableConcept)) 213 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.item.getClass().getName()+" was encountered"); 214 return (CodeableConcept) this.item; 215 } 216 217 public boolean hasItemCodeableConcept() { 218 return this != null && this.item instanceof CodeableConcept; 219 } 220 221 /** 222 * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication of a medication.) 223 */ 224 public Reference getItemReference() throws FHIRException { 225 if (this.item == null) 226 return null; 227 if (!(this.item instanceof Reference)) 228 throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.item.getClass().getName()+" was encountered"); 229 return (Reference) this.item; 230 } 231 232 public boolean hasItemReference() { 233 return this != null && this.item instanceof Reference; 234 } 235 236 public boolean hasItem() { 237 return this.item != null && !this.item.isEmpty(); 238 } 239 240 /** 241 * @param value {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication of a medication.) 242 */ 243 public MedicationIngredientComponent setItem(Type value) { 244 if (value != null && !(value instanceof CodeableConcept || value instanceof Reference)) 245 throw new Error("Not the right type for Medication.ingredient.item[x]: "+value.fhirType()); 246 this.item = value; 247 return this; 248 } 249 250 /** 251 * @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 252 */ 253 public BooleanType getIsActiveElement() { 254 if (this.isActive == null) 255 if (Configuration.errorOnAutoCreate()) 256 throw new Error("Attempt to auto-create MedicationIngredientComponent.isActive"); 257 else if (Configuration.doAutoCreate()) 258 this.isActive = new BooleanType(); // bb 259 return this.isActive; 260 } 261 262 public boolean hasIsActiveElement() { 263 return this.isActive != null && !this.isActive.isEmpty(); 264 } 265 266 public boolean hasIsActive() { 267 return this.isActive != null && !this.isActive.isEmpty(); 268 } 269 270 /** 271 * @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 272 */ 273 public MedicationIngredientComponent setIsActiveElement(BooleanType value) { 274 this.isActive = value; 275 return this; 276 } 277 278 /** 279 * @return Indication of whether this ingredient affects the therapeutic action of the drug. 280 */ 281 public boolean getIsActive() { 282 return this.isActive == null || this.isActive.isEmpty() ? false : this.isActive.getValue(); 283 } 284 285 /** 286 * @param value Indication of whether this ingredient affects the therapeutic action of the drug. 287 */ 288 public MedicationIngredientComponent setIsActive(boolean value) { 289 if (this.isActive == null) 290 this.isActive = new BooleanType(); 291 this.isActive.setValue(value); 292 return this; 293 } 294 295 /** 296 * @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.) 297 */ 298 public Ratio getAmount() { 299 if (this.amount == null) 300 if (Configuration.errorOnAutoCreate()) 301 throw new Error("Attempt to auto-create MedicationIngredientComponent.amount"); 302 else if (Configuration.doAutoCreate()) 303 this.amount = new Ratio(); // cc 304 return this.amount; 305 } 306 307 public boolean hasAmount() { 308 return this.amount != null && !this.amount.isEmpty(); 309 } 310 311 /** 312 * @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.) 313 */ 314 public MedicationIngredientComponent setAmount(Ratio value) { 315 this.amount = value; 316 return this; 317 } 318 319 protected void listChildren(List<Property> children) { 320 super.listChildren(children); 321 children.add(new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item)); 322 children.add(new Property("isActive", "boolean", "Indication of whether this ingredient affects the therapeutic action of the drug.", 0, 1, isActive)); 323 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)); 324 } 325 326 @Override 327 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 328 switch (_hash) { 329 case 2116201613: /*item[x]*/ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item); 330 case 3242771: /*item*/ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item); 331 case 106644494: /*itemCodeableConcept*/ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item); 332 case 1376364920: /*itemReference*/ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, item); 333 case -748916528: /*isActive*/ return new Property("isActive", "boolean", "Indication of whether this ingredient affects the therapeutic action of the drug.", 0, 1, isActive); 334 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); 335 default: return super.getNamedProperty(_hash, _name, _checkValid); 336 } 337 338 } 339 340 @Override 341 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 342 switch (hash) { 343 case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // Type 344 case -748916528: /*isActive*/ return this.isActive == null ? new Base[0] : new Base[] {this.isActive}; // BooleanType 345 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Ratio 346 default: return super.getProperty(hash, name, checkValid); 347 } 348 349 } 350 351 @Override 352 public Base setProperty(int hash, String name, Base value) throws FHIRException { 353 switch (hash) { 354 case 3242771: // item 355 this.item = castToType(value); // Type 356 return value; 357 case -748916528: // isActive 358 this.isActive = castToBoolean(value); // BooleanType 359 return value; 360 case -1413853096: // amount 361 this.amount = castToRatio(value); // Ratio 362 return value; 363 default: return super.setProperty(hash, name, value); 364 } 365 366 } 367 368 @Override 369 public Base setProperty(String name, Base value) throws FHIRException { 370 if (name.equals("item[x]")) { 371 this.item = castToType(value); // Type 372 } else if (name.equals("isActive")) { 373 this.isActive = castToBoolean(value); // BooleanType 374 } else if (name.equals("amount")) { 375 this.amount = castToRatio(value); // Ratio 376 } else 377 return super.setProperty(name, value); 378 return value; 379 } 380 381 @Override 382 public Base makeProperty(int hash, String name) throws FHIRException { 383 switch (hash) { 384 case 2116201613: return getItem(); 385 case 3242771: return getItem(); 386 case -748916528: return getIsActiveElement(); 387 case -1413853096: return getAmount(); 388 default: return super.makeProperty(hash, name); 389 } 390 391 } 392 393 @Override 394 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 395 switch (hash) { 396 case 3242771: /*item*/ return new String[] {"CodeableConcept", "Reference"}; 397 case -748916528: /*isActive*/ return new String[] {"boolean"}; 398 case -1413853096: /*amount*/ return new String[] {"Ratio"}; 399 default: return super.getTypesForProperty(hash, name); 400 } 401 402 } 403 404 @Override 405 public Base addChild(String name) throws FHIRException { 406 if (name.equals("itemCodeableConcept")) { 407 this.item = new CodeableConcept(); 408 return this.item; 409 } 410 else if (name.equals("itemReference")) { 411 this.item = new Reference(); 412 return this.item; 413 } 414 else if (name.equals("isActive")) { 415 throw new FHIRException("Cannot call addChild on a primitive type Medication.isActive"); 416 } 417 else if (name.equals("amount")) { 418 this.amount = new Ratio(); 419 return this.amount; 420 } 421 else 422 return super.addChild(name); 423 } 424 425 public MedicationIngredientComponent copy() { 426 MedicationIngredientComponent dst = new MedicationIngredientComponent(); 427 copyValues(dst); 428 dst.item = item == null ? null : item.copy(); 429 dst.isActive = isActive == null ? null : isActive.copy(); 430 dst.amount = amount == null ? null : amount.copy(); 431 return dst; 432 } 433 434 @Override 435 public boolean equalsDeep(Base other_) { 436 if (!super.equalsDeep(other_)) 437 return false; 438 if (!(other_ instanceof MedicationIngredientComponent)) 439 return false; 440 MedicationIngredientComponent o = (MedicationIngredientComponent) other_; 441 return compareDeep(item, o.item, true) && compareDeep(isActive, o.isActive, true) && compareDeep(amount, o.amount, true) 442 ; 443 } 444 445 @Override 446 public boolean equalsShallow(Base other_) { 447 if (!super.equalsShallow(other_)) 448 return false; 449 if (!(other_ instanceof MedicationIngredientComponent)) 450 return false; 451 MedicationIngredientComponent o = (MedicationIngredientComponent) other_; 452 return compareValues(isActive, o.isActive, true); 453 } 454 455 public boolean isEmpty() { 456 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, isActive, amount); 457 } 458 459 public String fhirType() { 460 return "Medication.ingredient"; 461 462 } 463 464 } 465 466 @Block() 467 public static class MedicationBatchComponent extends BackboneElement implements IBaseBackboneElement { 468 /** 469 * The assigned lot number of a batch of the specified product. 470 */ 471 @Child(name = "lotNumber", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false) 472 @Description(shortDefinition="Identifier assigned to batch", formalDefinition="The assigned lot number of a batch of the specified product." ) 473 protected StringType lotNumber; 474 475 /** 476 * When this specific batch of product will expire. 477 */ 478 @Child(name = "expirationDate", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false) 479 @Description(shortDefinition="When batch will expire", formalDefinition="When this specific batch of product will expire." ) 480 protected DateTimeType expirationDate; 481 482 /** 483 * An identifier assigned to a drug at the point of manufacturing and repackaging (at the package or pallet level), sufficient to facilitate the identification, validation, authentication, and tracking and tracking of drugs. 484 */ 485 @Child(name = "serialNumber", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false) 486 @Description(shortDefinition="Identifier assigned to a drug at the time of manufacture", formalDefinition="An identifier assigned to a drug at the point of manufacturing and repackaging (at the package or pallet level), sufficient to facilitate the identification, validation, authentication, and tracking and tracking of drugs." ) 487 protected StringType serialNumber; 488 489 private static final long serialVersionUID = 321549563L; 490 491 /** 492 * Constructor 493 */ 494 public MedicationBatchComponent() { 495 super(); 496 } 497 498 /** 499 * @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 500 */ 501 public StringType getLotNumberElement() { 502 if (this.lotNumber == null) 503 if (Configuration.errorOnAutoCreate()) 504 throw new Error("Attempt to auto-create MedicationBatchComponent.lotNumber"); 505 else if (Configuration.doAutoCreate()) 506 this.lotNumber = new StringType(); // bb 507 return this.lotNumber; 508 } 509 510 public boolean hasLotNumberElement() { 511 return this.lotNumber != null && !this.lotNumber.isEmpty(); 512 } 513 514 public boolean hasLotNumber() { 515 return this.lotNumber != null && !this.lotNumber.isEmpty(); 516 } 517 518 /** 519 * @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 520 */ 521 public MedicationBatchComponent setLotNumberElement(StringType value) { 522 this.lotNumber = value; 523 return this; 524 } 525 526 /** 527 * @return The assigned lot number of a batch of the specified product. 528 */ 529 public String getLotNumber() { 530 return this.lotNumber == null ? null : this.lotNumber.getValue(); 531 } 532 533 /** 534 * @param value The assigned lot number of a batch of the specified product. 535 */ 536 public MedicationBatchComponent setLotNumber(String value) { 537 if (Utilities.noString(value)) 538 this.lotNumber = null; 539 else { 540 if (this.lotNumber == null) 541 this.lotNumber = new StringType(); 542 this.lotNumber.setValue(value); 543 } 544 return this; 545 } 546 547 /** 548 * @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 549 */ 550 public DateTimeType getExpirationDateElement() { 551 if (this.expirationDate == null) 552 if (Configuration.errorOnAutoCreate()) 553 throw new Error("Attempt to auto-create MedicationBatchComponent.expirationDate"); 554 else if (Configuration.doAutoCreate()) 555 this.expirationDate = new DateTimeType(); // bb 556 return this.expirationDate; 557 } 558 559 public boolean hasExpirationDateElement() { 560 return this.expirationDate != null && !this.expirationDate.isEmpty(); 561 } 562 563 public boolean hasExpirationDate() { 564 return this.expirationDate != null && !this.expirationDate.isEmpty(); 565 } 566 567 /** 568 * @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 569 */ 570 public MedicationBatchComponent setExpirationDateElement(DateTimeType value) { 571 this.expirationDate = value; 572 return this; 573 } 574 575 /** 576 * @return When this specific batch of product will expire. 577 */ 578 public Date getExpirationDate() { 579 return this.expirationDate == null ? null : this.expirationDate.getValue(); 580 } 581 582 /** 583 * @param value When this specific batch of product will expire. 584 */ 585 public MedicationBatchComponent setExpirationDate(Date value) { 586 if (value == null) 587 this.expirationDate = null; 588 else { 589 if (this.expirationDate == null) 590 this.expirationDate = new DateTimeType(); 591 this.expirationDate.setValue(value); 592 } 593 return this; 594 } 595 596 /** 597 * @return {@link #serialNumber} (An identifier assigned to a drug at the point of manufacturing and repackaging (at the package or pallet level), sufficient to facilitate the identification, validation, authentication, and tracking and tracking of drugs.). This is the underlying object with id, value and extensions. The accessor "getSerialNumber" gives direct access to the value 598 */ 599 public StringType getSerialNumberElement() { 600 if (this.serialNumber == null) 601 if (Configuration.errorOnAutoCreate()) 602 throw new Error("Attempt to auto-create MedicationBatchComponent.serialNumber"); 603 else if (Configuration.doAutoCreate()) 604 this.serialNumber = new StringType(); // bb 605 return this.serialNumber; 606 } 607 608 public boolean hasSerialNumberElement() { 609 return this.serialNumber != null && !this.serialNumber.isEmpty(); 610 } 611 612 public boolean hasSerialNumber() { 613 return this.serialNumber != null && !this.serialNumber.isEmpty(); 614 } 615 616 /** 617 * @param value {@link #serialNumber} (An identifier assigned to a drug at the point of manufacturing and repackaging (at the package or pallet level), sufficient to facilitate the identification, validation, authentication, and tracking and tracking of drugs.). This is the underlying object with id, value and extensions. The accessor "getSerialNumber" gives direct access to the value 618 */ 619 public MedicationBatchComponent setSerialNumberElement(StringType value) { 620 this.serialNumber = value; 621 return this; 622 } 623 624 /** 625 * @return An identifier assigned to a drug at the point of manufacturing and repackaging (at the package or pallet level), sufficient to facilitate the identification, validation, authentication, and tracking and tracking of drugs. 626 */ 627 public String getSerialNumber() { 628 return this.serialNumber == null ? null : this.serialNumber.getValue(); 629 } 630 631 /** 632 * @param value An identifier assigned to a drug at the point of manufacturing and repackaging (at the package or pallet level), sufficient to facilitate the identification, validation, authentication, and tracking and tracking of drugs. 633 */ 634 public MedicationBatchComponent setSerialNumber(String value) { 635 if (Utilities.noString(value)) 636 this.serialNumber = null; 637 else { 638 if (this.serialNumber == null) 639 this.serialNumber = new StringType(); 640 this.serialNumber.setValue(value); 641 } 642 return this; 643 } 644 645 protected void listChildren(List<Property> children) { 646 super.listChildren(children); 647 children.add(new Property("lotNumber", "string", "The assigned lot number of a batch of the specified product.", 0, 1, lotNumber)); 648 children.add(new Property("expirationDate", "dateTime", "When this specific batch of product will expire.", 0, 1, expirationDate)); 649 children.add(new Property("serialNumber", "string", "An identifier assigned to a drug at the point of manufacturing and repackaging (at the package or pallet level), sufficient to facilitate the identification, validation, authentication, and tracking and tracking of drugs.", 0, 1, serialNumber)); 650 } 651 652 @Override 653 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 654 switch (_hash) { 655 case 462547450: /*lotNumber*/ return new Property("lotNumber", "string", "The assigned lot number of a batch of the specified product.", 0, 1, lotNumber); 656 case -668811523: /*expirationDate*/ return new Property("expirationDate", "dateTime", "When this specific batch of product will expire.", 0, 1, expirationDate); 657 case 83787357: /*serialNumber*/ return new Property("serialNumber", "string", "An identifier assigned to a drug at the point of manufacturing and repackaging (at the package or pallet level), sufficient to facilitate the identification, validation, authentication, and tracking and tracking of drugs.", 0, 1, serialNumber); 658 default: return super.getNamedProperty(_hash, _name, _checkValid); 659 } 660 661 } 662 663 @Override 664 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 665 switch (hash) { 666 case 462547450: /*lotNumber*/ return this.lotNumber == null ? new Base[0] : new Base[] {this.lotNumber}; // StringType 667 case -668811523: /*expirationDate*/ return this.expirationDate == null ? new Base[0] : new Base[] {this.expirationDate}; // DateTimeType 668 case 83787357: /*serialNumber*/ return this.serialNumber == null ? new Base[0] : new Base[] {this.serialNumber}; // StringType 669 default: return super.getProperty(hash, name, checkValid); 670 } 671 672 } 673 674 @Override 675 public Base setProperty(int hash, String name, Base value) throws FHIRException { 676 switch (hash) { 677 case 462547450: // lotNumber 678 this.lotNumber = castToString(value); // StringType 679 return value; 680 case -668811523: // expirationDate 681 this.expirationDate = castToDateTime(value); // DateTimeType 682 return value; 683 case 83787357: // serialNumber 684 this.serialNumber = castToString(value); // StringType 685 return value; 686 default: return super.setProperty(hash, name, value); 687 } 688 689 } 690 691 @Override 692 public Base setProperty(String name, Base value) throws FHIRException { 693 if (name.equals("lotNumber")) { 694 this.lotNumber = castToString(value); // StringType 695 } else if (name.equals("expirationDate")) { 696 this.expirationDate = castToDateTime(value); // DateTimeType 697 } else if (name.equals("serialNumber")) { 698 this.serialNumber = castToString(value); // StringType 699 } else 700 return super.setProperty(name, value); 701 return value; 702 } 703 704 @Override 705 public Base makeProperty(int hash, String name) throws FHIRException { 706 switch (hash) { 707 case 462547450: return getLotNumberElement(); 708 case -668811523: return getExpirationDateElement(); 709 case 83787357: return getSerialNumberElement(); 710 default: return super.makeProperty(hash, name); 711 } 712 713 } 714 715 @Override 716 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 717 switch (hash) { 718 case 462547450: /*lotNumber*/ return new String[] {"string"}; 719 case -668811523: /*expirationDate*/ return new String[] {"dateTime"}; 720 case 83787357: /*serialNumber*/ return new String[] {"string"}; 721 default: return super.getTypesForProperty(hash, name); 722 } 723 724 } 725 726 @Override 727 public Base addChild(String name) throws FHIRException { 728 if (name.equals("lotNumber")) { 729 throw new FHIRException("Cannot call addChild on a primitive type Medication.lotNumber"); 730 } 731 else if (name.equals("expirationDate")) { 732 throw new FHIRException("Cannot call addChild on a primitive type Medication.expirationDate"); 733 } 734 else if (name.equals("serialNumber")) { 735 throw new FHIRException("Cannot call addChild on a primitive type Medication.serialNumber"); 736 } 737 else 738 return super.addChild(name); 739 } 740 741 public MedicationBatchComponent copy() { 742 MedicationBatchComponent dst = new MedicationBatchComponent(); 743 copyValues(dst); 744 dst.lotNumber = lotNumber == null ? null : lotNumber.copy(); 745 dst.expirationDate = expirationDate == null ? null : expirationDate.copy(); 746 dst.serialNumber = serialNumber == null ? null : serialNumber.copy(); 747 return dst; 748 } 749 750 @Override 751 public boolean equalsDeep(Base other_) { 752 if (!super.equalsDeep(other_)) 753 return false; 754 if (!(other_ instanceof MedicationBatchComponent)) 755 return false; 756 MedicationBatchComponent o = (MedicationBatchComponent) other_; 757 return compareDeep(lotNumber, o.lotNumber, true) && compareDeep(expirationDate, o.expirationDate, true) 758 && compareDeep(serialNumber, o.serialNumber, true); 759 } 760 761 @Override 762 public boolean equalsShallow(Base other_) { 763 if (!super.equalsShallow(other_)) 764 return false; 765 if (!(other_ instanceof MedicationBatchComponent)) 766 return false; 767 MedicationBatchComponent o = (MedicationBatchComponent) other_; 768 return compareValues(lotNumber, o.lotNumber, true) && compareValues(expirationDate, o.expirationDate, true) 769 && compareValues(serialNumber, o.serialNumber, true); 770 } 771 772 public boolean isEmpty() { 773 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(lotNumber, expirationDate 774 , serialNumber); 775 } 776 777 public String fhirType() { 778 return "Medication.batch"; 779 780 } 781 782 } 783 784 /** 785 * 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. 786 */ 787 @Child(name = "code", type = {CodeableConcept.class}, order=0, min=0, max=1, modifier=false, summary=true) 788 @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." ) 789 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes") 790 protected CodeableConcept code; 791 792 /** 793 * A code to indicate if the medication is in active use. 794 */ 795 @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true) 796 @Description(shortDefinition="active | inactive | entered-in-error", formalDefinition="A code to indicate if the medication is in active use." ) 797 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-status") 798 protected Enumeration<MedicationStatus> status; 799 800 /** 801 * Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product. 802 */ 803 @Child(name = "manufacturer", type = {Organization.class}, order=2, min=0, max=1, modifier=false, summary=true) 804 @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." ) 805 protected Reference manufacturer; 806 807 /** 808 * 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.) 809 */ 810 protected Organization manufacturerTarget; 811 812 /** 813 * Describes the form of the item. Powder; tablets; capsule. 814 */ 815 @Child(name = "form", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false) 816 @Description(shortDefinition="powder | tablets | capsule +", formalDefinition="Describes the form of the item. Powder; tablets; capsule." ) 817 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-form-codes") 818 protected CodeableConcept form; 819 820 /** 821 * Specific amount of the drug in the packaged product. For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.). 822 */ 823 @Child(name = "amount", type = {Quantity.class}, order=4, min=0, max=1, modifier=false, summary=true) 824 @Description(shortDefinition="Amount of drug in package", formalDefinition="Specific amount of the drug in the packaged product. For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.)." ) 825 protected Quantity amount; 826 827 /** 828 * Identifies a particular constituent of interest in the product. 829 */ 830 @Child(name = "ingredient", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 831 @Description(shortDefinition="Active or inactive ingredient", formalDefinition="Identifies a particular constituent of interest in the product." ) 832 protected List<MedicationIngredientComponent> ingredient; 833 834 /** 835 * Information that only applies to packages (not products). 836 */ 837 @Child(name = "batch", type = {}, order=6, min=0, max=1, modifier=false, summary=false) 838 @Description(shortDefinition="Details about packaged medications", formalDefinition="Information that only applies to packages (not products)." ) 839 protected MedicationBatchComponent batch; 840 841 private static final long serialVersionUID = -482408531L; 842 843 /** 844 * Constructor 845 */ 846 public Medication() { 847 super(); 848 } 849 850 /** 851 * @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.) 852 */ 853 public CodeableConcept getCode() { 854 if (this.code == null) 855 if (Configuration.errorOnAutoCreate()) 856 throw new Error("Attempt to auto-create Medication.code"); 857 else if (Configuration.doAutoCreate()) 858 this.code = new CodeableConcept(); // cc 859 return this.code; 860 } 861 862 public boolean hasCode() { 863 return this.code != null && !this.code.isEmpty(); 864 } 865 866 /** 867 * @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.) 868 */ 869 public Medication setCode(CodeableConcept value) { 870 this.code = value; 871 return this; 872 } 873 874 /** 875 * @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 876 */ 877 public Enumeration<MedicationStatus> getStatusElement() { 878 if (this.status == null) 879 if (Configuration.errorOnAutoCreate()) 880 throw new Error("Attempt to auto-create Medication.status"); 881 else if (Configuration.doAutoCreate()) 882 this.status = new Enumeration<MedicationStatus>(new MedicationStatusEnumFactory()); // bb 883 return this.status; 884 } 885 886 public boolean hasStatusElement() { 887 return this.status != null && !this.status.isEmpty(); 888 } 889 890 public boolean hasStatus() { 891 return this.status != null && !this.status.isEmpty(); 892 } 893 894 /** 895 * @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 896 */ 897 public Medication setStatusElement(Enumeration<MedicationStatus> value) { 898 this.status = value; 899 return this; 900 } 901 902 /** 903 * @return A code to indicate if the medication is in active use. 904 */ 905 public MedicationStatus getStatus() { 906 return this.status == null ? null : this.status.getValue(); 907 } 908 909 /** 910 * @param value A code to indicate if the medication is in active use. 911 */ 912 public Medication setStatus(MedicationStatus value) { 913 if (value == null) 914 this.status = null; 915 else { 916 if (this.status == null) 917 this.status = new Enumeration<MedicationStatus>(new MedicationStatusEnumFactory()); 918 this.status.setValue(value); 919 } 920 return this; 921 } 922 923 /** 924 * @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.) 925 */ 926 public Reference getManufacturer() { 927 if (this.manufacturer == null) 928 if (Configuration.errorOnAutoCreate()) 929 throw new Error("Attempt to auto-create Medication.manufacturer"); 930 else if (Configuration.doAutoCreate()) 931 this.manufacturer = new Reference(); // cc 932 return this.manufacturer; 933 } 934 935 public boolean hasManufacturer() { 936 return this.manufacturer != null && !this.manufacturer.isEmpty(); 937 } 938 939 /** 940 * @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.) 941 */ 942 public Medication setManufacturer(Reference value) { 943 this.manufacturer = value; 944 return this; 945 } 946 947 /** 948 * @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.) 949 */ 950 public Organization getManufacturerTarget() { 951 if (this.manufacturerTarget == null) 952 if (Configuration.errorOnAutoCreate()) 953 throw new Error("Attempt to auto-create Medication.manufacturer"); 954 else if (Configuration.doAutoCreate()) 955 this.manufacturerTarget = new Organization(); // aa 956 return this.manufacturerTarget; 957 } 958 959 /** 960 * @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.) 961 */ 962 public Medication setManufacturerTarget(Organization value) { 963 this.manufacturerTarget = value; 964 return this; 965 } 966 967 /** 968 * @return {@link #form} (Describes the form of the item. Powder; tablets; capsule.) 969 */ 970 public CodeableConcept getForm() { 971 if (this.form == null) 972 if (Configuration.errorOnAutoCreate()) 973 throw new Error("Attempt to auto-create Medication.form"); 974 else if (Configuration.doAutoCreate()) 975 this.form = new CodeableConcept(); // cc 976 return this.form; 977 } 978 979 public boolean hasForm() { 980 return this.form != null && !this.form.isEmpty(); 981 } 982 983 /** 984 * @param value {@link #form} (Describes the form of the item. Powder; tablets; capsule.) 985 */ 986 public Medication setForm(CodeableConcept value) { 987 this.form = value; 988 return this; 989 } 990 991 /** 992 * @return {@link #amount} (Specific amount of the drug in the packaged product. For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).) 993 */ 994 public Quantity getAmount() { 995 if (this.amount == null) 996 if (Configuration.errorOnAutoCreate()) 997 throw new Error("Attempt to auto-create Medication.amount"); 998 else if (Configuration.doAutoCreate()) 999 this.amount = new Quantity(); // cc 1000 return this.amount; 1001 } 1002 1003 public boolean hasAmount() { 1004 return this.amount != null && !this.amount.isEmpty(); 1005 } 1006 1007 /** 1008 * @param value {@link #amount} (Specific amount of the drug in the packaged product. For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).) 1009 */ 1010 public Medication setAmount(Quantity value) { 1011 this.amount = value; 1012 return this; 1013 } 1014 1015 /** 1016 * @return {@link #ingredient} (Identifies a particular constituent of interest in the product.) 1017 */ 1018 public List<MedicationIngredientComponent> getIngredient() { 1019 if (this.ingredient == null) 1020 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1021 return this.ingredient; 1022 } 1023 1024 /** 1025 * @return Returns a reference to <code>this</code> for easy method chaining 1026 */ 1027 public Medication setIngredient(List<MedicationIngredientComponent> theIngredient) { 1028 this.ingredient = theIngredient; 1029 return this; 1030 } 1031 1032 public boolean hasIngredient() { 1033 if (this.ingredient == null) 1034 return false; 1035 for (MedicationIngredientComponent item : this.ingredient) 1036 if (!item.isEmpty()) 1037 return true; 1038 return false; 1039 } 1040 1041 public MedicationIngredientComponent addIngredient() { //3 1042 MedicationIngredientComponent t = new MedicationIngredientComponent(); 1043 if (this.ingredient == null) 1044 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1045 this.ingredient.add(t); 1046 return t; 1047 } 1048 1049 public Medication addIngredient(MedicationIngredientComponent t) { //3 1050 if (t == null) 1051 return this; 1052 if (this.ingredient == null) 1053 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1054 this.ingredient.add(t); 1055 return this; 1056 } 1057 1058 /** 1059 * @return The first repetition of repeating field {@link #ingredient}, creating it if it does not already exist 1060 */ 1061 public MedicationIngredientComponent getIngredientFirstRep() { 1062 if (getIngredient().isEmpty()) { 1063 addIngredient(); 1064 } 1065 return getIngredient().get(0); 1066 } 1067 1068 /** 1069 * @return {@link #batch} (Information that only applies to packages (not products).) 1070 */ 1071 public MedicationBatchComponent getBatch() { 1072 if (this.batch == null) 1073 if (Configuration.errorOnAutoCreate()) 1074 throw new Error("Attempt to auto-create Medication.batch"); 1075 else if (Configuration.doAutoCreate()) 1076 this.batch = new MedicationBatchComponent(); // cc 1077 return this.batch; 1078 } 1079 1080 public boolean hasBatch() { 1081 return this.batch != null && !this.batch.isEmpty(); 1082 } 1083 1084 /** 1085 * @param value {@link #batch} (Information that only applies to packages (not products).) 1086 */ 1087 public Medication setBatch(MedicationBatchComponent value) { 1088 this.batch = value; 1089 return this; 1090 } 1091 1092 protected void listChildren(List<Property> children) { 1093 super.listChildren(children); 1094 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)); 1095 children.add(new Property("status", "code", "A code to indicate if the medication is in active use.", 0, 1, status)); 1096 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)); 1097 children.add(new Property("form", "CodeableConcept", "Describes the form of the item. Powder; tablets; capsule.", 0, 1, form)); 1098 children.add(new Property("amount", "SimpleQuantity", "Specific amount of the drug in the packaged product. For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).", 0, 1, amount)); 1099 children.add(new Property("ingredient", "", "Identifies a particular constituent of interest in the product.", 0, java.lang.Integer.MAX_VALUE, ingredient)); 1100 children.add(new Property("batch", "", "Information that only applies to packages (not products).", 0, 1, batch)); 1101 } 1102 1103 @Override 1104 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 1105 switch (_hash) { 1106 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); 1107 case -892481550: /*status*/ return new Property("status", "code", "A code to indicate if the medication is in active use.", 0, 1, status); 1108 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); 1109 case 3148996: /*form*/ return new Property("form", "CodeableConcept", "Describes the form of the item. Powder; tablets; capsule.", 0, 1, form); 1110 case -1413853096: /*amount*/ return new Property("amount", "SimpleQuantity", "Specific amount of the drug in the packaged product. For example, when specifying a product that has the same strength (For example, Insulin glargine 100 unit per mL solution for injection), this attribute provides additional clarification of the package amount (For example, 3 mL, 10mL, etc.).", 0, 1, amount); 1111 case -206409263: /*ingredient*/ return new Property("ingredient", "", "Identifies a particular constituent of interest in the product.", 0, java.lang.Integer.MAX_VALUE, ingredient); 1112 case 93509434: /*batch*/ return new Property("batch", "", "Information that only applies to packages (not products).", 0, 1, batch); 1113 default: return super.getNamedProperty(_hash, _name, _checkValid); 1114 } 1115 1116 } 1117 1118 @Override 1119 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 1120 switch (hash) { 1121 case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept 1122 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<MedicationStatus> 1123 case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : new Base[] {this.manufacturer}; // Reference 1124 case 3148996: /*form*/ return this.form == null ? new Base[0] : new Base[] {this.form}; // CodeableConcept 1125 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Quantity 1126 case -206409263: /*ingredient*/ return this.ingredient == null ? new Base[0] : this.ingredient.toArray(new Base[this.ingredient.size()]); // MedicationIngredientComponent 1127 case 93509434: /*batch*/ return this.batch == null ? new Base[0] : new Base[] {this.batch}; // MedicationBatchComponent 1128 default: return super.getProperty(hash, name, checkValid); 1129 } 1130 1131 } 1132 1133 @Override 1134 public Base setProperty(int hash, String name, Base value) throws FHIRException { 1135 switch (hash) { 1136 case 3059181: // code 1137 this.code = castToCodeableConcept(value); // CodeableConcept 1138 return value; 1139 case -892481550: // status 1140 value = new MedicationStatusEnumFactory().fromType(castToCode(value)); 1141 this.status = (Enumeration) value; // Enumeration<MedicationStatus> 1142 return value; 1143 case -1969347631: // manufacturer 1144 this.manufacturer = castToReference(value); // Reference 1145 return value; 1146 case 3148996: // form 1147 this.form = castToCodeableConcept(value); // CodeableConcept 1148 return value; 1149 case -1413853096: // amount 1150 this.amount = castToQuantity(value); // Quantity 1151 return value; 1152 case -206409263: // ingredient 1153 this.getIngredient().add((MedicationIngredientComponent) value); // MedicationIngredientComponent 1154 return value; 1155 case 93509434: // batch 1156 this.batch = (MedicationBatchComponent) value; // MedicationBatchComponent 1157 return value; 1158 default: return super.setProperty(hash, name, value); 1159 } 1160 1161 } 1162 1163 @Override 1164 public Base setProperty(String name, Base value) throws FHIRException { 1165 if (name.equals("code")) { 1166 this.code = castToCodeableConcept(value); // CodeableConcept 1167 } else if (name.equals("status")) { 1168 value = new MedicationStatusEnumFactory().fromType(castToCode(value)); 1169 this.status = (Enumeration) value; // Enumeration<MedicationStatus> 1170 } else if (name.equals("manufacturer")) { 1171 this.manufacturer = castToReference(value); // Reference 1172 } else if (name.equals("form")) { 1173 this.form = castToCodeableConcept(value); // CodeableConcept 1174 } else if (name.equals("amount")) { 1175 this.amount = castToQuantity(value); // Quantity 1176 } else if (name.equals("ingredient")) { 1177 this.getIngredient().add((MedicationIngredientComponent) value); 1178 } else if (name.equals("batch")) { 1179 this.batch = (MedicationBatchComponent) value; // MedicationBatchComponent 1180 } else 1181 return super.setProperty(name, value); 1182 return value; 1183 } 1184 1185 @Override 1186 public Base makeProperty(int hash, String name) throws FHIRException { 1187 switch (hash) { 1188 case 3059181: return getCode(); 1189 case -892481550: return getStatusElement(); 1190 case -1969347631: return getManufacturer(); 1191 case 3148996: return getForm(); 1192 case -1413853096: return getAmount(); 1193 case -206409263: return addIngredient(); 1194 case 93509434: return getBatch(); 1195 default: return super.makeProperty(hash, name); 1196 } 1197 1198 } 1199 1200 @Override 1201 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 1202 switch (hash) { 1203 case 3059181: /*code*/ return new String[] {"CodeableConcept"}; 1204 case -892481550: /*status*/ return new String[] {"code"}; 1205 case -1969347631: /*manufacturer*/ return new String[] {"Reference"}; 1206 case 3148996: /*form*/ return new String[] {"CodeableConcept"}; 1207 case -1413853096: /*amount*/ return new String[] {"SimpleQuantity"}; 1208 case -206409263: /*ingredient*/ return new String[] {}; 1209 case 93509434: /*batch*/ return new String[] {}; 1210 default: return super.getTypesForProperty(hash, name); 1211 } 1212 1213 } 1214 1215 @Override 1216 public Base addChild(String name) throws FHIRException { 1217 if (name.equals("code")) { 1218 this.code = new CodeableConcept(); 1219 return this.code; 1220 } 1221 else if (name.equals("status")) { 1222 throw new FHIRException("Cannot call addChild on a primitive type Medication.status"); 1223 } 1224 else if (name.equals("manufacturer")) { 1225 this.manufacturer = new Reference(); 1226 return this.manufacturer; 1227 } 1228 else if (name.equals("form")) { 1229 this.form = new CodeableConcept(); 1230 return this.form; 1231 } 1232 else if (name.equals("amount")) { 1233 this.amount = new Quantity(); 1234 return this.amount; 1235 } 1236 else if (name.equals("ingredient")) { 1237 return addIngredient(); 1238 } 1239 else if (name.equals("batch")) { 1240 this.batch = new MedicationBatchComponent(); 1241 return this.batch; 1242 } 1243 else 1244 return super.addChild(name); 1245 } 1246 1247 public String fhirType() { 1248 return "Medication"; 1249 1250 } 1251 1252 public Medication copy() { 1253 Medication dst = new Medication(); 1254 copyValues(dst); 1255 dst.code = code == null ? null : code.copy(); 1256 dst.status = status == null ? null : status.copy(); 1257 dst.manufacturer = manufacturer == null ? null : manufacturer.copy(); 1258 dst.form = form == null ? null : form.copy(); 1259 dst.amount = amount == null ? null : amount.copy(); 1260 if (ingredient != null) { 1261 dst.ingredient = new ArrayList<MedicationIngredientComponent>(); 1262 for (MedicationIngredientComponent i : ingredient) 1263 dst.ingredient.add(i.copy()); 1264 }; 1265 dst.batch = batch == null ? null : batch.copy(); 1266 return dst; 1267 } 1268 1269 protected Medication typedCopy() { 1270 return copy(); 1271 } 1272 1273 @Override 1274 public boolean equalsDeep(Base other_) { 1275 if (!super.equalsDeep(other_)) 1276 return false; 1277 if (!(other_ instanceof Medication)) 1278 return false; 1279 Medication o = (Medication) other_; 1280 return compareDeep(code, o.code, true) && compareDeep(status, o.status, true) && compareDeep(manufacturer, o.manufacturer, true) 1281 && compareDeep(form, o.form, true) && compareDeep(amount, o.amount, true) && compareDeep(ingredient, o.ingredient, true) 1282 && compareDeep(batch, o.batch, true); 1283 } 1284 1285 @Override 1286 public boolean equalsShallow(Base other_) { 1287 if (!super.equalsShallow(other_)) 1288 return false; 1289 if (!(other_ instanceof Medication)) 1290 return false; 1291 Medication o = (Medication) other_; 1292 return compareValues(status, o.status, true); 1293 } 1294 1295 public boolean isEmpty() { 1296 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, status, manufacturer 1297 , form, amount, ingredient, batch); 1298 } 1299 1300 @Override 1301 public ResourceType getResourceType() { 1302 return ResourceType.Medication; 1303 } 1304 1305 /** 1306 * Search parameter: <b>ingredient-code</b> 1307 * <p> 1308 * Description: <b>The actual ingredient or content</b><br> 1309 * Type: <b>token</b><br> 1310 * Path: <b>Medication.ingredient.itemCodeableConcept</b><br> 1311 * </p> 1312 */ 1313 @SearchParamDefinition(name="ingredient-code", path="(Medication.ingredient.item as CodeableConcept)", description="The actual ingredient or content", type="token" ) 1314 public static final String SP_INGREDIENT_CODE = "ingredient-code"; 1315 /** 1316 * <b>Fluent Client</b> search parameter constant for <b>ingredient-code</b> 1317 * <p> 1318 * Description: <b>The actual ingredient or content</b><br> 1319 * Type: <b>token</b><br> 1320 * Path: <b>Medication.ingredient.itemCodeableConcept</b><br> 1321 * </p> 1322 */ 1323 public static final ca.uhn.fhir.rest.gclient.TokenClientParam INGREDIENT_CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INGREDIENT_CODE); 1324 1325 /** 1326 * Search parameter: <b>code</b> 1327 * <p> 1328 * Description: <b>Codes that identify this medication</b><br> 1329 * Type: <b>token</b><br> 1330 * Path: <b>Medication.code</b><br> 1331 * </p> 1332 */ 1333 @SearchParamDefinition(name="code", path="Medication.code", description="Codes that identify this medication", type="token" ) 1334 public static final String SP_CODE = "code"; 1335 /** 1336 * <b>Fluent Client</b> search parameter constant for <b>code</b> 1337 * <p> 1338 * Description: <b>Codes that identify this medication</b><br> 1339 * Type: <b>token</b><br> 1340 * Path: <b>Medication.code</b><br> 1341 * </p> 1342 */ 1343 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE); 1344 1345 /** 1346 * Search parameter: <b>ingredient</b> 1347 * <p> 1348 * Description: <b>The actual ingredient or content</b><br> 1349 * Type: <b>reference</b><br> 1350 * Path: <b>Medication.ingredient.itemReference</b><br> 1351 * </p> 1352 */ 1353 @SearchParamDefinition(name="ingredient", path="(Medication.ingredient.item as Reference)", description="The actual ingredient or content", type="reference", target={Medication.class, Substance.class } ) 1354 public static final String SP_INGREDIENT = "ingredient"; 1355 /** 1356 * <b>Fluent Client</b> search parameter constant for <b>ingredient</b> 1357 * <p> 1358 * Description: <b>The actual ingredient or content</b><br> 1359 * Type: <b>reference</b><br> 1360 * Path: <b>Medication.ingredient.itemReference</b><br> 1361 * </p> 1362 */ 1363 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INGREDIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INGREDIENT); 1364 1365/** 1366 * Constant for fluent queries to be used to add include statements. Specifies 1367 * the path value of "<b>Medication:ingredient</b>". 1368 */ 1369 public static final ca.uhn.fhir.model.api.Include INCLUDE_INGREDIENT = new ca.uhn.fhir.model.api.Include("Medication:ingredient").toLocked(); 1370 1371 /** 1372 * Search parameter: <b>form</b> 1373 * <p> 1374 * Description: <b>powder | tablets | capsule +</b><br> 1375 * Type: <b>token</b><br> 1376 * Path: <b>Medication.form</b><br> 1377 * </p> 1378 */ 1379 @SearchParamDefinition(name="form", path="Medication.form", description="powder | tablets | capsule +", type="token" ) 1380 public static final String SP_FORM = "form"; 1381 /** 1382 * <b>Fluent Client</b> search parameter constant for <b>form</b> 1383 * <p> 1384 * Description: <b>powder | tablets | capsule +</b><br> 1385 * Type: <b>token</b><br> 1386 * Path: <b>Medication.form</b><br> 1387 * </p> 1388 */ 1389 public static final ca.uhn.fhir.rest.gclient.TokenClientParam FORM = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_FORM); 1390 1391 /** 1392 * Search parameter: <b>lot-number</b> 1393 * <p> 1394 * Description: <b>Identifier assigned to batch</b><br> 1395 * Type: <b>token</b><br> 1396 * Path: <b>Medication.batch.lotNumber</b><br> 1397 * </p> 1398 */ 1399 @SearchParamDefinition(name="lot-number", path="Medication.batch.lotNumber", description="Identifier assigned to batch", type="token" ) 1400 public static final String SP_LOT_NUMBER = "lot-number"; 1401 /** 1402 * <b>Fluent Client</b> search parameter constant for <b>lot-number</b> 1403 * <p> 1404 * Description: <b>Identifier assigned to batch</b><br> 1405 * Type: <b>token</b><br> 1406 * Path: <b>Medication.batch.lotNumber</b><br> 1407 * </p> 1408 */ 1409 public static final ca.uhn.fhir.rest.gclient.TokenClientParam LOT_NUMBER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_LOT_NUMBER); 1410 1411 /** 1412 * Search parameter: <b>serial-number</b> 1413 * <p> 1414 * Description: <b>Identifier assigned to a drug at the time of manufacture</b><br> 1415 * Type: <b>token</b><br> 1416 * Path: <b>Medication.batch.serialNumber</b><br> 1417 * </p> 1418 */ 1419 @SearchParamDefinition(name="serial-number", path="Medication.batch.serialNumber", description="Identifier assigned to a drug at the time of manufacture", type="token" ) 1420 public static final String SP_SERIAL_NUMBER = "serial-number"; 1421 /** 1422 * <b>Fluent Client</b> search parameter constant for <b>serial-number</b> 1423 * <p> 1424 * Description: <b>Identifier assigned to a drug at the time of manufacture</b><br> 1425 * Type: <b>token</b><br> 1426 * Path: <b>Medication.batch.serialNumber</b><br> 1427 * </p> 1428 */ 1429 public static final ca.uhn.fhir.rest.gclient.TokenClientParam SERIAL_NUMBER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SERIAL_NUMBER); 1430 1431 /** 1432 * Search parameter: <b>expiration-date</b> 1433 * <p> 1434 * Description: <b>When batch will expire</b><br> 1435 * Type: <b>date</b><br> 1436 * Path: <b>Medication.batch.expirationDate</b><br> 1437 * </p> 1438 */ 1439 @SearchParamDefinition(name="expiration-date", path="Medication.batch.expirationDate", description="When batch will expire", type="date" ) 1440 public static final String SP_EXPIRATION_DATE = "expiration-date"; 1441 /** 1442 * <b>Fluent Client</b> search parameter constant for <b>expiration-date</b> 1443 * <p> 1444 * Description: <b>When batch will expire</b><br> 1445 * Type: <b>date</b><br> 1446 * Path: <b>Medication.batch.expirationDate</b><br> 1447 * </p> 1448 */ 1449 public static final ca.uhn.fhir.rest.gclient.DateClientParam EXPIRATION_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_EXPIRATION_DATE); 1450 1451 /** 1452 * Search parameter: <b>manufacturer</b> 1453 * <p> 1454 * Description: <b>Manufacturer of the item</b><br> 1455 * Type: <b>reference</b><br> 1456 * Path: <b>Medication.manufacturer</b><br> 1457 * </p> 1458 */ 1459 @SearchParamDefinition(name="manufacturer", path="Medication.manufacturer", description="Manufacturer of the item", type="reference", target={Organization.class } ) 1460 public static final String SP_MANUFACTURER = "manufacturer"; 1461 /** 1462 * <b>Fluent Client</b> search parameter constant for <b>manufacturer</b> 1463 * <p> 1464 * Description: <b>Manufacturer of the item</b><br> 1465 * Type: <b>reference</b><br> 1466 * Path: <b>Medication.manufacturer</b><br> 1467 * </p> 1468 */ 1469 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MANUFACTURER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MANUFACTURER); 1470 1471/** 1472 * Constant for fluent queries to be used to add include statements. Specifies 1473 * the path value of "<b>Medication:manufacturer</b>". 1474 */ 1475 public static final ca.uhn.fhir.model.api.Include INCLUDE_MANUFACTURER = new ca.uhn.fhir.model.api.Include("Medication:manufacturer").toLocked(); 1476 1477 /** 1478 * Search parameter: <b>status</b> 1479 * <p> 1480 * Description: <b>active | inactive | entered-in-error</b><br> 1481 * Type: <b>token</b><br> 1482 * Path: <b>Medication.status</b><br> 1483 * </p> 1484 */ 1485 @SearchParamDefinition(name="status", path="Medication.status", description="active | inactive | entered-in-error", type="token" ) 1486 public static final String SP_STATUS = "status"; 1487 /** 1488 * <b>Fluent Client</b> search parameter constant for <b>status</b> 1489 * <p> 1490 * Description: <b>active | inactive | entered-in-error</b><br> 1491 * Type: <b>token</b><br> 1492 * Path: <b>Medication.status</b><br> 1493 * </p> 1494 */ 1495 public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS); 1496 1497 1498} 1499