![](/hapi-fhir/images/logos/raccoon-forwards.png)
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 Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1 033import java.util.ArrayList; 034import java.util.Date; 035import java.util.List; 036 037import org.hl7.fhir.exceptions.FHIRException; 038import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 039import org.hl7.fhir.utilities.Utilities; 040 041import ca.uhn.fhir.model.api.annotation.Block; 042import ca.uhn.fhir.model.api.annotation.Child; 043import ca.uhn.fhir.model.api.annotation.Description; 044import ca.uhn.fhir.model.api.annotation.ResourceDef; 045import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 046 047/** 048 * This resource is primarily used for the identification and definition of a 049 * medication for the purposes of prescribing, dispensing, and administering a 050 * medication as well as for making statements about medication use. 051 */ 052@ResourceDef(name = "Medication", profile = "http://hl7.org/fhir/StructureDefinition/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 073 public static MedicationStatus fromCode(String codeString) throws FHIRException { 074 if (codeString == null || "".equals(codeString)) 075 return null; 076 if ("active".equals(codeString)) 077 return ACTIVE; 078 if ("inactive".equals(codeString)) 079 return INACTIVE; 080 if ("entered-in-error".equals(codeString)) 081 return ENTEREDINERROR; 082 if (Configuration.isAcceptInvalidEnums()) 083 return null; 084 else 085 throw new FHIRException("Unknown MedicationStatus code '" + codeString + "'"); 086 } 087 088 public String toCode() { 089 switch (this) { 090 case ACTIVE: 091 return "active"; 092 case INACTIVE: 093 return "inactive"; 094 case ENTEREDINERROR: 095 return "entered-in-error"; 096 case NULL: 097 return null; 098 default: 099 return "?"; 100 } 101 } 102 103 public String getSystem() { 104 switch (this) { 105 case ACTIVE: 106 return "http://hl7.org/fhir/CodeSystem/medication-status"; 107 case INACTIVE: 108 return "http://hl7.org/fhir/CodeSystem/medication-status"; 109 case ENTEREDINERROR: 110 return "http://hl7.org/fhir/CodeSystem/medication-status"; 111 case NULL: 112 return null; 113 default: 114 return "?"; 115 } 116 } 117 118 public String getDefinition() { 119 switch (this) { 120 case ACTIVE: 121 return "The medication is available for use."; 122 case INACTIVE: 123 return "The medication is not available for use."; 124 case ENTEREDINERROR: 125 return "The medication was entered in error."; 126 case NULL: 127 return null; 128 default: 129 return "?"; 130 } 131 } 132 133 public String getDisplay() { 134 switch (this) { 135 case ACTIVE: 136 return "Active"; 137 case INACTIVE: 138 return "Inactive"; 139 case ENTEREDINERROR: 140 return "Entered in Error"; 141 case NULL: 142 return null; 143 default: 144 return "?"; 145 } 146 } 147 } 148 149 public static class MedicationStatusEnumFactory implements EnumFactory<MedicationStatus> { 150 public MedicationStatus fromCode(String codeString) throws IllegalArgumentException { 151 if (codeString == null || "".equals(codeString)) 152 if (codeString == null || "".equals(codeString)) 153 return null; 154 if ("active".equals(codeString)) 155 return MedicationStatus.ACTIVE; 156 if ("inactive".equals(codeString)) 157 return MedicationStatus.INACTIVE; 158 if ("entered-in-error".equals(codeString)) 159 return MedicationStatus.ENTEREDINERROR; 160 throw new IllegalArgumentException("Unknown MedicationStatus code '" + codeString + "'"); 161 } 162 163 public Enumeration<MedicationStatus> fromType(PrimitiveType<?> code) throws FHIRException { 164 if (code == null) 165 return null; 166 if (code.isEmpty()) 167 return new Enumeration<MedicationStatus>(this, MedicationStatus.NULL, code); 168 String codeString = code.asStringValue(); 169 if (codeString == null || "".equals(codeString)) 170 return new Enumeration<MedicationStatus>(this, MedicationStatus.NULL, code); 171 if ("active".equals(codeString)) 172 return new Enumeration<MedicationStatus>(this, MedicationStatus.ACTIVE, code); 173 if ("inactive".equals(codeString)) 174 return new Enumeration<MedicationStatus>(this, MedicationStatus.INACTIVE, code); 175 if ("entered-in-error".equals(codeString)) 176 return new Enumeration<MedicationStatus>(this, MedicationStatus.ENTEREDINERROR, code); 177 throw new FHIRException("Unknown MedicationStatus code '" + codeString + "'"); 178 } 179 180 public String toCode(MedicationStatus code) { 181 if (code == MedicationStatus.ACTIVE) 182 return "active"; 183 if (code == MedicationStatus.INACTIVE) 184 return "inactive"; 185 if (code == MedicationStatus.ENTEREDINERROR) 186 return "entered-in-error"; 187 return "?"; 188 } 189 190 public String toSystem(MedicationStatus code) { 191 return code.getSystem(); 192 } 193 } 194 195 @Block() 196 public static class MedicationIngredientComponent extends BackboneElement implements IBaseBackboneElement { 197 /** 198 * The actual ingredient - either a substance (simple ingredient) or another 199 * medication of a medication. 200 */ 201 @Child(name = "item", type = { CodeableConcept.class, Substance.class, 202 Medication.class }, order = 1, min = 1, max = 1, modifier = false, summary = false) 203 @Description(shortDefinition = "The actual ingredient or content", formalDefinition = "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.") 204 protected Type item; 205 206 /** 207 * Indication of whether this ingredient affects the therapeutic action of the 208 * drug. 209 */ 210 @Child(name = "isActive", type = { 211 BooleanType.class }, order = 2, min = 0, max = 1, modifier = false, summary = false) 212 @Description(shortDefinition = "Active ingredient indicator", formalDefinition = "Indication of whether this ingredient affects the therapeutic action of the drug.") 213 protected BooleanType isActive; 214 215 /** 216 * Specifies how many (or how much) of the items there are in this Medication. 217 * For example, 250 mg per tablet. This is expressed as a ratio where the 218 * numerator is 250mg and the denominator is 1 tablet. 219 */ 220 @Child(name = "strength", type = { Ratio.class }, order = 3, min = 0, max = 1, modifier = false, summary = false) 221 @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.") 222 protected Ratio strength; 223 224 private static final long serialVersionUID = 1365103497L; 225 226 /** 227 * Constructor 228 */ 229 public MedicationIngredientComponent() { 230 super(); 231 } 232 233 /** 234 * Constructor 235 */ 236 public MedicationIngredientComponent(Type item) { 237 super(); 238 this.item = item; 239 } 240 241 /** 242 * @return {@link #item} (The actual ingredient - either a substance (simple 243 * ingredient) or another medication of a medication.) 244 */ 245 public Type getItem() { 246 return this.item; 247 } 248 249 /** 250 * @return {@link #item} (The actual ingredient - either a substance (simple 251 * ingredient) or another medication of a medication.) 252 */ 253 public CodeableConcept getItemCodeableConcept() throws FHIRException { 254 if (this.item == null) 255 this.item = new CodeableConcept(); 256 if (!(this.item instanceof CodeableConcept)) 257 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but " 258 + this.item.getClass().getName() + " was encountered"); 259 return (CodeableConcept) this.item; 260 } 261 262 public boolean hasItemCodeableConcept() { 263 return this != null && this.item instanceof CodeableConcept; 264 } 265 266 /** 267 * @return {@link #item} (The actual ingredient - either a substance (simple 268 * ingredient) or another medication of a medication.) 269 */ 270 public Reference getItemReference() throws FHIRException { 271 if (this.item == null) 272 this.item = new Reference(); 273 if (!(this.item instanceof Reference)) 274 throw new FHIRException("Type mismatch: the type Reference was expected, but " + this.item.getClass().getName() 275 + " was encountered"); 276 return (Reference) this.item; 277 } 278 279 public boolean hasItemReference() { 280 return this != null && this.item instanceof Reference; 281 } 282 283 public boolean hasItem() { 284 return this.item != null && !this.item.isEmpty(); 285 } 286 287 /** 288 * @param value {@link #item} (The actual ingredient - either a substance 289 * (simple ingredient) or another medication of a medication.) 290 */ 291 public MedicationIngredientComponent setItem(Type value) { 292 if (value != null && !(value instanceof CodeableConcept || value instanceof Reference)) 293 throw new Error("Not the right type for Medication.ingredient.item[x]: " + value.fhirType()); 294 this.item = value; 295 return this; 296 } 297 298 /** 299 * @return {@link #isActive} (Indication of whether this ingredient affects the 300 * therapeutic action of the drug.). This is the underlying object with 301 * id, value and extensions. The accessor "getIsActive" gives direct 302 * access to the value 303 */ 304 public BooleanType getIsActiveElement() { 305 if (this.isActive == null) 306 if (Configuration.errorOnAutoCreate()) 307 throw new Error("Attempt to auto-create MedicationIngredientComponent.isActive"); 308 else if (Configuration.doAutoCreate()) 309 this.isActive = new BooleanType(); // bb 310 return this.isActive; 311 } 312 313 public boolean hasIsActiveElement() { 314 return this.isActive != null && !this.isActive.isEmpty(); 315 } 316 317 public boolean hasIsActive() { 318 return this.isActive != null && !this.isActive.isEmpty(); 319 } 320 321 /** 322 * @param value {@link #isActive} (Indication of whether this ingredient affects 323 * the therapeutic action of the drug.). This is the underlying 324 * object with id, value and extensions. The accessor "getIsActive" 325 * gives direct access to the value 326 */ 327 public MedicationIngredientComponent setIsActiveElement(BooleanType value) { 328 this.isActive = value; 329 return this; 330 } 331 332 /** 333 * @return Indication of whether this ingredient affects the therapeutic action 334 * of the drug. 335 */ 336 public boolean getIsActive() { 337 return this.isActive == null || this.isActive.isEmpty() ? false : this.isActive.getValue(); 338 } 339 340 /** 341 * @param value Indication of whether this ingredient affects the therapeutic 342 * action of the drug. 343 */ 344 public MedicationIngredientComponent setIsActive(boolean value) { 345 if (this.isActive == null) 346 this.isActive = new BooleanType(); 347 this.isActive.setValue(value); 348 return this; 349 } 350 351 /** 352 * @return {@link #strength} (Specifies how many (or how much) of the items 353 * there are in this Medication. For example, 250 mg per tablet. This is 354 * expressed as a ratio where the numerator is 250mg and the denominator 355 * is 1 tablet.) 356 */ 357 public Ratio getStrength() { 358 if (this.strength == null) 359 if (Configuration.errorOnAutoCreate()) 360 throw new Error("Attempt to auto-create MedicationIngredientComponent.strength"); 361 else if (Configuration.doAutoCreate()) 362 this.strength = new Ratio(); // cc 363 return this.strength; 364 } 365 366 public boolean hasStrength() { 367 return this.strength != null && !this.strength.isEmpty(); 368 } 369 370 /** 371 * @param value {@link #strength} (Specifies how many (or how much) of the items 372 * there are in this Medication. For example, 250 mg per tablet. 373 * This is expressed as a ratio where the numerator is 250mg and 374 * the denominator is 1 tablet.) 375 */ 376 public MedicationIngredientComponent setStrength(Ratio value) { 377 this.strength = value; 378 return this; 379 } 380 381 protected void listChildren(List<Property> children) { 382 super.listChildren(children); 383 children.add(new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", 384 "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 1, 385 item)); 386 children.add(new Property("isActive", "boolean", 387 "Indication of whether this ingredient affects the therapeutic action of the drug.", 0, 1, isActive)); 388 children.add(new Property("strength", "Ratio", 389 "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.", 390 0, 1, strength)); 391 } 392 393 @Override 394 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 395 switch (_hash) { 396 case 2116201613: 397 /* item[x] */ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", 398 "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 399 1, item); 400 case 3242771: 401 /* item */ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", 402 "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 403 1, item); 404 case 106644494: 405 /* itemCodeableConcept */ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", 406 "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 407 1, item); 408 case 1376364920: 409 /* itemReference */ return new Property("item[x]", "CodeableConcept|Reference(Substance|Medication)", 410 "The actual ingredient - either a substance (simple ingredient) or another medication of a medication.", 0, 411 1, item); 412 case -748916528: 413 /* isActive */ return new Property("isActive", "boolean", 414 "Indication of whether this ingredient affects the therapeutic action of the drug.", 0, 1, isActive); 415 case 1791316033: 416 /* strength */ return new Property("strength", "Ratio", 417 "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.", 418 0, 1, strength); 419 default: 420 return super.getNamedProperty(_hash, _name, _checkValid); 421 } 422 423 } 424 425 @Override 426 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 427 switch (hash) { 428 case 3242771: 429 /* item */ return this.item == null ? new Base[0] : new Base[] { this.item }; // Type 430 case -748916528: 431 /* isActive */ return this.isActive == null ? new Base[0] : new Base[] { this.isActive }; // BooleanType 432 case 1791316033: 433 /* strength */ return this.strength == null ? new Base[0] : new Base[] { this.strength }; // Ratio 434 default: 435 return super.getProperty(hash, name, checkValid); 436 } 437 438 } 439 440 @Override 441 public Base setProperty(int hash, String name, Base value) throws FHIRException { 442 switch (hash) { 443 case 3242771: // item 444 this.item = castToType(value); // Type 445 return value; 446 case -748916528: // isActive 447 this.isActive = castToBoolean(value); // BooleanType 448 return value; 449 case 1791316033: // strength 450 this.strength = castToRatio(value); // Ratio 451 return value; 452 default: 453 return super.setProperty(hash, name, value); 454 } 455 456 } 457 458 @Override 459 public Base setProperty(String name, Base value) throws FHIRException { 460 if (name.equals("item[x]")) { 461 this.item = castToType(value); // Type 462 } else if (name.equals("isActive")) { 463 this.isActive = castToBoolean(value); // BooleanType 464 } else if (name.equals("strength")) { 465 this.strength = castToRatio(value); // Ratio 466 } else 467 return super.setProperty(name, value); 468 return value; 469 } 470 471 @Override 472 public void removeChild(String name, Base value) throws FHIRException { 473 if (name.equals("item[x]")) { 474 this.item = null; 475 } else if (name.equals("isActive")) { 476 this.isActive = null; 477 } else if (name.equals("strength")) { 478 this.strength = null; 479 } else 480 super.removeChild(name, value); 481 482 } 483 484 @Override 485 public Base makeProperty(int hash, String name) throws FHIRException { 486 switch (hash) { 487 case 2116201613: 488 return getItem(); 489 case 3242771: 490 return getItem(); 491 case -748916528: 492 return getIsActiveElement(); 493 case 1791316033: 494 return getStrength(); 495 default: 496 return super.makeProperty(hash, name); 497 } 498 499 } 500 501 @Override 502 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 503 switch (hash) { 504 case 3242771: 505 /* item */ return new String[] { "CodeableConcept", "Reference" }; 506 case -748916528: 507 /* isActive */ return new String[] { "boolean" }; 508 case 1791316033: 509 /* strength */ return new String[] { "Ratio" }; 510 default: 511 return super.getTypesForProperty(hash, name); 512 } 513 514 } 515 516 @Override 517 public Base addChild(String name) throws FHIRException { 518 if (name.equals("itemCodeableConcept")) { 519 this.item = new CodeableConcept(); 520 return this.item; 521 } else if (name.equals("itemReference")) { 522 this.item = new Reference(); 523 return this.item; 524 } else if (name.equals("isActive")) { 525 throw new FHIRException("Cannot call addChild on a singleton property Medication.isActive"); 526 } else if (name.equals("strength")) { 527 this.strength = new Ratio(); 528 return this.strength; 529 } else 530 return super.addChild(name); 531 } 532 533 public MedicationIngredientComponent copy() { 534 MedicationIngredientComponent dst = new MedicationIngredientComponent(); 535 copyValues(dst); 536 return dst; 537 } 538 539 public void copyValues(MedicationIngredientComponent dst) { 540 super.copyValues(dst); 541 dst.item = item == null ? null : item.copy(); 542 dst.isActive = isActive == null ? null : isActive.copy(); 543 dst.strength = strength == null ? null : strength.copy(); 544 } 545 546 @Override 547 public boolean equalsDeep(Base other_) { 548 if (!super.equalsDeep(other_)) 549 return false; 550 if (!(other_ instanceof MedicationIngredientComponent)) 551 return false; 552 MedicationIngredientComponent o = (MedicationIngredientComponent) other_; 553 return compareDeep(item, o.item, true) && compareDeep(isActive, o.isActive, true) 554 && compareDeep(strength, o.strength, true); 555 } 556 557 @Override 558 public boolean equalsShallow(Base other_) { 559 if (!super.equalsShallow(other_)) 560 return false; 561 if (!(other_ instanceof MedicationIngredientComponent)) 562 return false; 563 MedicationIngredientComponent o = (MedicationIngredientComponent) other_; 564 return compareValues(isActive, o.isActive, true); 565 } 566 567 public boolean isEmpty() { 568 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, isActive, strength); 569 } 570 571 public String fhirType() { 572 return "Medication.ingredient"; 573 574 } 575 576 } 577 578 @Block() 579 public static class MedicationBatchComponent extends BackboneElement implements IBaseBackboneElement { 580 /** 581 * The assigned lot number of a batch of the specified product. 582 */ 583 @Child(name = "lotNumber", type = { 584 StringType.class }, order = 1, min = 0, max = 1, modifier = false, summary = false) 585 @Description(shortDefinition = "Identifier assigned to batch", formalDefinition = "The assigned lot number of a batch of the specified product.") 586 protected StringType lotNumber; 587 588 /** 589 * When this specific batch of product will expire. 590 */ 591 @Child(name = "expirationDate", type = { 592 DateTimeType.class }, order = 2, min = 0, max = 1, modifier = false, summary = false) 593 @Description(shortDefinition = "When batch will expire", formalDefinition = "When this specific batch of product will expire.") 594 protected DateTimeType expirationDate; 595 596 private static final long serialVersionUID = 1982738755L; 597 598 /** 599 * Constructor 600 */ 601 public MedicationBatchComponent() { 602 super(); 603 } 604 605 /** 606 * @return {@link #lotNumber} (The assigned lot number of a batch of the 607 * specified product.). This is the underlying object with id, value and 608 * extensions. The accessor "getLotNumber" gives direct access to the 609 * value 610 */ 611 public StringType getLotNumberElement() { 612 if (this.lotNumber == null) 613 if (Configuration.errorOnAutoCreate()) 614 throw new Error("Attempt to auto-create MedicationBatchComponent.lotNumber"); 615 else if (Configuration.doAutoCreate()) 616 this.lotNumber = new StringType(); // bb 617 return this.lotNumber; 618 } 619 620 public boolean hasLotNumberElement() { 621 return this.lotNumber != null && !this.lotNumber.isEmpty(); 622 } 623 624 public boolean hasLotNumber() { 625 return this.lotNumber != null && !this.lotNumber.isEmpty(); 626 } 627 628 /** 629 * @param value {@link #lotNumber} (The assigned lot number of a batch of the 630 * specified product.). This is the underlying object with id, 631 * value and extensions. The accessor "getLotNumber" gives direct 632 * access to the value 633 */ 634 public MedicationBatchComponent setLotNumberElement(StringType value) { 635 this.lotNumber = value; 636 return this; 637 } 638 639 /** 640 * @return The assigned lot number of a batch of the specified product. 641 */ 642 public String getLotNumber() { 643 return this.lotNumber == null ? null : this.lotNumber.getValue(); 644 } 645 646 /** 647 * @param value The assigned lot number of a batch of the specified product. 648 */ 649 public MedicationBatchComponent setLotNumber(String value) { 650 if (Utilities.noString(value)) 651 this.lotNumber = null; 652 else { 653 if (this.lotNumber == null) 654 this.lotNumber = new StringType(); 655 this.lotNumber.setValue(value); 656 } 657 return this; 658 } 659 660 /** 661 * @return {@link #expirationDate} (When this specific batch of product will 662 * expire.). This is the underlying object with id, value and 663 * extensions. The accessor "getExpirationDate" gives direct access to 664 * the value 665 */ 666 public DateTimeType getExpirationDateElement() { 667 if (this.expirationDate == null) 668 if (Configuration.errorOnAutoCreate()) 669 throw new Error("Attempt to auto-create MedicationBatchComponent.expirationDate"); 670 else if (Configuration.doAutoCreate()) 671 this.expirationDate = new DateTimeType(); // bb 672 return this.expirationDate; 673 } 674 675 public boolean hasExpirationDateElement() { 676 return this.expirationDate != null && !this.expirationDate.isEmpty(); 677 } 678 679 public boolean hasExpirationDate() { 680 return this.expirationDate != null && !this.expirationDate.isEmpty(); 681 } 682 683 /** 684 * @param value {@link #expirationDate} (When this specific batch of product 685 * will expire.). This is the underlying object with id, value and 686 * extensions. The accessor "getExpirationDate" gives direct access 687 * to the value 688 */ 689 public MedicationBatchComponent setExpirationDateElement(DateTimeType value) { 690 this.expirationDate = value; 691 return this; 692 } 693 694 /** 695 * @return When this specific batch of product will expire. 696 */ 697 public Date getExpirationDate() { 698 return this.expirationDate == null ? null : this.expirationDate.getValue(); 699 } 700 701 /** 702 * @param value When this specific batch of product will expire. 703 */ 704 public MedicationBatchComponent setExpirationDate(Date value) { 705 if (value == null) 706 this.expirationDate = null; 707 else { 708 if (this.expirationDate == null) 709 this.expirationDate = new DateTimeType(); 710 this.expirationDate.setValue(value); 711 } 712 return this; 713 } 714 715 protected void listChildren(List<Property> children) { 716 super.listChildren(children); 717 children.add(new Property("lotNumber", "string", "The assigned lot number of a batch of the specified product.", 718 0, 1, lotNumber)); 719 children.add(new Property("expirationDate", "dateTime", "When this specific batch of product will expire.", 0, 1, 720 expirationDate)); 721 } 722 723 @Override 724 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 725 switch (_hash) { 726 case 462547450: 727 /* lotNumber */ return new Property("lotNumber", "string", 728 "The assigned lot number of a batch of the specified product.", 0, 1, lotNumber); 729 case -668811523: 730 /* expirationDate */ return new Property("expirationDate", "dateTime", 731 "When this specific batch of product will expire.", 0, 1, expirationDate); 732 default: 733 return super.getNamedProperty(_hash, _name, _checkValid); 734 } 735 736 } 737 738 @Override 739 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 740 switch (hash) { 741 case 462547450: 742 /* lotNumber */ return this.lotNumber == null ? new Base[0] : new Base[] { this.lotNumber }; // StringType 743 case -668811523: 744 /* expirationDate */ return this.expirationDate == null ? new Base[0] : new Base[] { this.expirationDate }; // DateTimeType 745 default: 746 return super.getProperty(hash, name, checkValid); 747 } 748 749 } 750 751 @Override 752 public Base setProperty(int hash, String name, Base value) throws FHIRException { 753 switch (hash) { 754 case 462547450: // lotNumber 755 this.lotNumber = castToString(value); // StringType 756 return value; 757 case -668811523: // expirationDate 758 this.expirationDate = castToDateTime(value); // DateTimeType 759 return value; 760 default: 761 return super.setProperty(hash, name, value); 762 } 763 764 } 765 766 @Override 767 public Base setProperty(String name, Base value) throws FHIRException { 768 if (name.equals("lotNumber")) { 769 this.lotNumber = castToString(value); // StringType 770 } else if (name.equals("expirationDate")) { 771 this.expirationDate = castToDateTime(value); // DateTimeType 772 } else 773 return super.setProperty(name, value); 774 return value; 775 } 776 777 @Override 778 public void removeChild(String name, Base value) throws FHIRException { 779 if (name.equals("lotNumber")) { 780 this.lotNumber = null; 781 } else if (name.equals("expirationDate")) { 782 this.expirationDate = null; 783 } else 784 super.removeChild(name, value); 785 786 } 787 788 @Override 789 public Base makeProperty(int hash, String name) throws FHIRException { 790 switch (hash) { 791 case 462547450: 792 return getLotNumberElement(); 793 case -668811523: 794 return getExpirationDateElement(); 795 default: 796 return super.makeProperty(hash, name); 797 } 798 799 } 800 801 @Override 802 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 803 switch (hash) { 804 case 462547450: 805 /* lotNumber */ return new String[] { "string" }; 806 case -668811523: 807 /* expirationDate */ return new String[] { "dateTime" }; 808 default: 809 return super.getTypesForProperty(hash, name); 810 } 811 812 } 813 814 @Override 815 public Base addChild(String name) throws FHIRException { 816 if (name.equals("lotNumber")) { 817 throw new FHIRException("Cannot call addChild on a singleton property Medication.lotNumber"); 818 } else if (name.equals("expirationDate")) { 819 throw new FHIRException("Cannot call addChild on a singleton property Medication.expirationDate"); 820 } else 821 return super.addChild(name); 822 } 823 824 public MedicationBatchComponent copy() { 825 MedicationBatchComponent dst = new MedicationBatchComponent(); 826 copyValues(dst); 827 return dst; 828 } 829 830 public void copyValues(MedicationBatchComponent dst) { 831 super.copyValues(dst); 832 dst.lotNumber = lotNumber == null ? null : lotNumber.copy(); 833 dst.expirationDate = expirationDate == null ? null : expirationDate.copy(); 834 } 835 836 @Override 837 public boolean equalsDeep(Base other_) { 838 if (!super.equalsDeep(other_)) 839 return false; 840 if (!(other_ instanceof MedicationBatchComponent)) 841 return false; 842 MedicationBatchComponent o = (MedicationBatchComponent) other_; 843 return compareDeep(lotNumber, o.lotNumber, true) && compareDeep(expirationDate, o.expirationDate, true); 844 } 845 846 @Override 847 public boolean equalsShallow(Base other_) { 848 if (!super.equalsShallow(other_)) 849 return false; 850 if (!(other_ instanceof MedicationBatchComponent)) 851 return false; 852 MedicationBatchComponent o = (MedicationBatchComponent) other_; 853 return compareValues(lotNumber, o.lotNumber, true) && compareValues(expirationDate, o.expirationDate, true); 854 } 855 856 public boolean isEmpty() { 857 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(lotNumber, expirationDate); 858 } 859 860 public String fhirType() { 861 return "Medication.batch"; 862 863 } 864 865 } 866 867 /** 868 * Business identifier for this medication. 869 */ 870 @Child(name = "identifier", type = { 871 Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true) 872 @Description(shortDefinition = "Business identifier for this medication", formalDefinition = "Business identifier for this medication.") 873 protected List<Identifier> identifier; 874 875 /** 876 * A code (or set of codes) that specify this medication, or a textual 877 * description if no code is available. Usage note: This could be a standard 878 * medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could 879 * also be a national or local formulary code, optionally with translations to 880 * other code systems. 881 */ 882 @Child(name = "code", type = { CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true) 883 @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.") 884 @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medication-codes") 885 protected CodeableConcept code; 886 887 /** 888 * A code to indicate if the medication is in active use. 889 */ 890 @Child(name = "status", type = { CodeType.class }, order = 2, min = 0, max = 1, modifier = true, summary = true) 891 @Description(shortDefinition = "active | inactive | entered-in-error", formalDefinition = "A code to indicate if the medication is in active use.") 892 @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medication-status") 893 protected Enumeration<MedicationStatus> status; 894 895 /** 896 * Describes the details of the manufacturer of the medication product. This is 897 * not intended to represent the distributor of a medication product. 898 */ 899 @Child(name = "manufacturer", type = { 900 Organization.class }, order = 3, min = 0, max = 1, modifier = false, summary = true) 901 @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.") 902 protected Reference manufacturer; 903 904 /** 905 * The actual object that is the target of the reference (Describes the details 906 * of the manufacturer of the medication product. This is not intended to 907 * represent the distributor of a medication product.) 908 */ 909 protected Organization manufacturerTarget; 910 911 /** 912 * Describes the form of the item. Powder; tablets; capsule. 913 */ 914 @Child(name = "form", type = { 915 CodeableConcept.class }, order = 4, min = 0, max = 1, modifier = false, summary = false) 916 @Description(shortDefinition = "powder | tablets | capsule +", formalDefinition = "Describes the form of the item. Powder; tablets; capsule.") 917 @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medication-form-codes") 918 protected CodeableConcept form; 919 920 /** 921 * Specific amount of the drug in the packaged product. For example, when 922 * specifying a product that has the same strength (For example, Insulin 923 * glargine 100 unit per mL solution for injection), this attribute provides 924 * additional clarification of the package amount (For example, 3 mL, 10mL, 925 * etc.). 926 */ 927 @Child(name = "amount", type = { Ratio.class }, order = 5, min = 0, max = 1, modifier = false, summary = true) 928 @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.).") 929 protected Ratio amount; 930 931 /** 932 * Identifies a particular constituent of interest in the product. 933 */ 934 @Child(name = "ingredient", type = {}, order = 6, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false) 935 @Description(shortDefinition = "Active or inactive ingredient", formalDefinition = "Identifies a particular constituent of interest in the product.") 936 protected List<MedicationIngredientComponent> ingredient; 937 938 /** 939 * Information that only applies to packages (not products). 940 */ 941 @Child(name = "batch", type = {}, order = 7, min = 0, max = 1, modifier = false, summary = false) 942 @Description(shortDefinition = "Details about packaged medications", formalDefinition = "Information that only applies to packages (not products).") 943 protected MedicationBatchComponent batch; 944 945 private static final long serialVersionUID = 781229373L; 946 947 /** 948 * Constructor 949 */ 950 public Medication() { 951 super(); 952 } 953 954 /** 955 * @return {@link #identifier} (Business identifier for this medication.) 956 */ 957 public List<Identifier> getIdentifier() { 958 if (this.identifier == null) 959 this.identifier = new ArrayList<Identifier>(); 960 return this.identifier; 961 } 962 963 /** 964 * @return Returns a reference to <code>this</code> for easy method chaining 965 */ 966 public Medication setIdentifier(List<Identifier> theIdentifier) { 967 this.identifier = theIdentifier; 968 return this; 969 } 970 971 public boolean hasIdentifier() { 972 if (this.identifier == null) 973 return false; 974 for (Identifier item : this.identifier) 975 if (!item.isEmpty()) 976 return true; 977 return false; 978 } 979 980 public Identifier addIdentifier() { // 3 981 Identifier t = new Identifier(); 982 if (this.identifier == null) 983 this.identifier = new ArrayList<Identifier>(); 984 this.identifier.add(t); 985 return t; 986 } 987 988 public Medication addIdentifier(Identifier t) { // 3 989 if (t == null) 990 return this; 991 if (this.identifier == null) 992 this.identifier = new ArrayList<Identifier>(); 993 this.identifier.add(t); 994 return this; 995 } 996 997 /** 998 * @return The first repetition of repeating field {@link #identifier}, creating 999 * it if it does not already exist 1000 */ 1001 public Identifier getIdentifierFirstRep() { 1002 if (getIdentifier().isEmpty()) { 1003 addIdentifier(); 1004 } 1005 return getIdentifier().get(0); 1006 } 1007 1008 /** 1009 * @return {@link #code} (A code (or set of codes) that specify this medication, 1010 * or a textual description if no code is available. Usage note: This 1011 * could be a standard medication code such as a code from RxNorm, 1012 * SNOMED CT, IDMP etc. It could also be a national or local formulary 1013 * code, optionally with translations to other code systems.) 1014 */ 1015 public CodeableConcept getCode() { 1016 if (this.code == null) 1017 if (Configuration.errorOnAutoCreate()) 1018 throw new Error("Attempt to auto-create Medication.code"); 1019 else if (Configuration.doAutoCreate()) 1020 this.code = new CodeableConcept(); // cc 1021 return this.code; 1022 } 1023 1024 public boolean hasCode() { 1025 return this.code != null && !this.code.isEmpty(); 1026 } 1027 1028 /** 1029 * @param value {@link #code} (A code (or set of codes) that specify this 1030 * medication, or a textual description if no code is available. 1031 * Usage note: This could be a standard medication code such as a 1032 * code from RxNorm, SNOMED CT, IDMP etc. It could also be a 1033 * national or local formulary code, optionally with translations 1034 * to other code systems.) 1035 */ 1036 public Medication setCode(CodeableConcept value) { 1037 this.code = value; 1038 return this; 1039 } 1040 1041 /** 1042 * @return {@link #status} (A code to indicate if the medication is in active 1043 * use.). This is the underlying object with id, value and extensions. 1044 * The accessor "getStatus" gives direct access to the value 1045 */ 1046 public Enumeration<MedicationStatus> getStatusElement() { 1047 if (this.status == null) 1048 if (Configuration.errorOnAutoCreate()) 1049 throw new Error("Attempt to auto-create Medication.status"); 1050 else if (Configuration.doAutoCreate()) 1051 this.status = new Enumeration<MedicationStatus>(new MedicationStatusEnumFactory()); // bb 1052 return this.status; 1053 } 1054 1055 public boolean hasStatusElement() { 1056 return this.status != null && !this.status.isEmpty(); 1057 } 1058 1059 public boolean hasStatus() { 1060 return this.status != null && !this.status.isEmpty(); 1061 } 1062 1063 /** 1064 * @param value {@link #status} (A code to indicate if the medication is in 1065 * active use.). This is the underlying object with id, value and 1066 * extensions. The accessor "getStatus" gives direct access to the 1067 * value 1068 */ 1069 public Medication setStatusElement(Enumeration<MedicationStatus> value) { 1070 this.status = value; 1071 return this; 1072 } 1073 1074 /** 1075 * @return A code to indicate if the medication is in active use. 1076 */ 1077 public MedicationStatus getStatus() { 1078 return this.status == null ? null : this.status.getValue(); 1079 } 1080 1081 /** 1082 * @param value A code to indicate if the medication is in active use. 1083 */ 1084 public Medication setStatus(MedicationStatus value) { 1085 if (value == null) 1086 this.status = null; 1087 else { 1088 if (this.status == null) 1089 this.status = new Enumeration<MedicationStatus>(new MedicationStatusEnumFactory()); 1090 this.status.setValue(value); 1091 } 1092 return this; 1093 } 1094 1095 /** 1096 * @return {@link #manufacturer} (Describes the details of the manufacturer of 1097 * the medication product. This is not intended to represent the 1098 * distributor of a medication product.) 1099 */ 1100 public Reference getManufacturer() { 1101 if (this.manufacturer == null) 1102 if (Configuration.errorOnAutoCreate()) 1103 throw new Error("Attempt to auto-create Medication.manufacturer"); 1104 else if (Configuration.doAutoCreate()) 1105 this.manufacturer = new Reference(); // cc 1106 return this.manufacturer; 1107 } 1108 1109 public boolean hasManufacturer() { 1110 return this.manufacturer != null && !this.manufacturer.isEmpty(); 1111 } 1112 1113 /** 1114 * @param value {@link #manufacturer} (Describes the details of the manufacturer 1115 * of the medication product. This is not intended to represent the 1116 * distributor of a medication product.) 1117 */ 1118 public Medication setManufacturer(Reference value) { 1119 this.manufacturer = value; 1120 return this; 1121 } 1122 1123 /** 1124 * @return {@link #manufacturer} The actual object that is the target of the 1125 * reference. The reference library doesn't populate this, but you can 1126 * use it to hold the resource if you resolve it. (Describes the details 1127 * of the manufacturer of the medication product. This is not intended 1128 * to represent the distributor of a medication product.) 1129 */ 1130 public Organization getManufacturerTarget() { 1131 if (this.manufacturerTarget == null) 1132 if (Configuration.errorOnAutoCreate()) 1133 throw new Error("Attempt to auto-create Medication.manufacturer"); 1134 else if (Configuration.doAutoCreate()) 1135 this.manufacturerTarget = new Organization(); // aa 1136 return this.manufacturerTarget; 1137 } 1138 1139 /** 1140 * @param value {@link #manufacturer} The actual object that is the target of 1141 * the reference. The reference library doesn't use these, but you 1142 * can use it to hold the resource if you resolve it. (Describes 1143 * the details of the manufacturer of the medication product. This 1144 * is not intended to represent the distributor of a medication 1145 * product.) 1146 */ 1147 public Medication setManufacturerTarget(Organization value) { 1148 this.manufacturerTarget = value; 1149 return this; 1150 } 1151 1152 /** 1153 * @return {@link #form} (Describes the form of the item. Powder; tablets; 1154 * capsule.) 1155 */ 1156 public CodeableConcept getForm() { 1157 if (this.form == null) 1158 if (Configuration.errorOnAutoCreate()) 1159 throw new Error("Attempt to auto-create Medication.form"); 1160 else if (Configuration.doAutoCreate()) 1161 this.form = new CodeableConcept(); // cc 1162 return this.form; 1163 } 1164 1165 public boolean hasForm() { 1166 return this.form != null && !this.form.isEmpty(); 1167 } 1168 1169 /** 1170 * @param value {@link #form} (Describes the form of the item. Powder; tablets; 1171 * capsule.) 1172 */ 1173 public Medication setForm(CodeableConcept value) { 1174 this.form = value; 1175 return this; 1176 } 1177 1178 /** 1179 * @return {@link #amount} (Specific amount of the drug in the packaged product. 1180 * For example, when specifying a product that has the same strength 1181 * (For example, Insulin glargine 100 unit per mL solution for 1182 * injection), this attribute provides additional clarification of the 1183 * package amount (For example, 3 mL, 10mL, etc.).) 1184 */ 1185 public Ratio getAmount() { 1186 if (this.amount == null) 1187 if (Configuration.errorOnAutoCreate()) 1188 throw new Error("Attempt to auto-create Medication.amount"); 1189 else if (Configuration.doAutoCreate()) 1190 this.amount = new Ratio(); // cc 1191 return this.amount; 1192 } 1193 1194 public boolean hasAmount() { 1195 return this.amount != null && !this.amount.isEmpty(); 1196 } 1197 1198 /** 1199 * @param value {@link #amount} (Specific amount of the drug in the packaged 1200 * product. For example, when specifying a product that has the 1201 * same strength (For example, Insulin glargine 100 unit per mL 1202 * solution for injection), this attribute provides additional 1203 * clarification of the package amount (For example, 3 mL, 10mL, 1204 * etc.).) 1205 */ 1206 public Medication setAmount(Ratio value) { 1207 this.amount = value; 1208 return this; 1209 } 1210 1211 /** 1212 * @return {@link #ingredient} (Identifies a particular constituent of interest 1213 * in the product.) 1214 */ 1215 public List<MedicationIngredientComponent> getIngredient() { 1216 if (this.ingredient == null) 1217 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1218 return this.ingredient; 1219 } 1220 1221 /** 1222 * @return Returns a reference to <code>this</code> for easy method chaining 1223 */ 1224 public Medication setIngredient(List<MedicationIngredientComponent> theIngredient) { 1225 this.ingredient = theIngredient; 1226 return this; 1227 } 1228 1229 public boolean hasIngredient() { 1230 if (this.ingredient == null) 1231 return false; 1232 for (MedicationIngredientComponent item : this.ingredient) 1233 if (!item.isEmpty()) 1234 return true; 1235 return false; 1236 } 1237 1238 public MedicationIngredientComponent addIngredient() { // 3 1239 MedicationIngredientComponent t = new MedicationIngredientComponent(); 1240 if (this.ingredient == null) 1241 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1242 this.ingredient.add(t); 1243 return t; 1244 } 1245 1246 public Medication addIngredient(MedicationIngredientComponent t) { // 3 1247 if (t == null) 1248 return this; 1249 if (this.ingredient == null) 1250 this.ingredient = new ArrayList<MedicationIngredientComponent>(); 1251 this.ingredient.add(t); 1252 return this; 1253 } 1254 1255 /** 1256 * @return The first repetition of repeating field {@link #ingredient}, creating 1257 * it if it does not already exist 1258 */ 1259 public MedicationIngredientComponent getIngredientFirstRep() { 1260 if (getIngredient().isEmpty()) { 1261 addIngredient(); 1262 } 1263 return getIngredient().get(0); 1264 } 1265 1266 /** 1267 * @return {@link #batch} (Information that only applies to packages (not 1268 * products).) 1269 */ 1270 public MedicationBatchComponent getBatch() { 1271 if (this.batch == null) 1272 if (Configuration.errorOnAutoCreate()) 1273 throw new Error("Attempt to auto-create Medication.batch"); 1274 else if (Configuration.doAutoCreate()) 1275 this.batch = new MedicationBatchComponent(); // cc 1276 return this.batch; 1277 } 1278 1279 public boolean hasBatch() { 1280 return this.batch != null && !this.batch.isEmpty(); 1281 } 1282 1283 /** 1284 * @param value {@link #batch} (Information that only applies to packages (not 1285 * products).) 1286 */ 1287 public Medication setBatch(MedicationBatchComponent value) { 1288 this.batch = value; 1289 return this; 1290 } 1291 1292 protected void listChildren(List<Property> children) { 1293 super.listChildren(children); 1294 children.add(new Property("identifier", "Identifier", "Business identifier for this medication.", 0, 1295 java.lang.Integer.MAX_VALUE, identifier)); 1296 children.add(new Property("code", "CodeableConcept", 1297 "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.", 1298 0, 1, code)); 1299 children 1300 .add(new Property("status", "code", "A code to indicate if the medication is in active use.", 0, 1, status)); 1301 children.add(new Property("manufacturer", "Reference(Organization)", 1302 "Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.", 1303 0, 1, manufacturer)); 1304 children.add(new Property("form", "CodeableConcept", "Describes the form of the item. Powder; tablets; capsule.", 1305 0, 1, form)); 1306 children.add(new Property("amount", "Ratio", 1307 "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.).", 1308 0, 1, amount)); 1309 children.add(new Property("ingredient", "", "Identifies a particular constituent of interest in the product.", 0, 1310 java.lang.Integer.MAX_VALUE, ingredient)); 1311 children.add(new Property("batch", "", "Information that only applies to packages (not products).", 0, 1, batch)); 1312 } 1313 1314 @Override 1315 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 1316 switch (_hash) { 1317 case -1618432855: 1318 /* identifier */ return new Property("identifier", "Identifier", "Business identifier for this medication.", 0, 1319 java.lang.Integer.MAX_VALUE, identifier); 1320 case 3059181: 1321 /* code */ return new Property("code", "CodeableConcept", 1322 "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.", 1323 0, 1, code); 1324 case -892481550: 1325 /* status */ return new Property("status", "code", "A code to indicate if the medication is in active use.", 0, 1, 1326 status); 1327 case -1969347631: 1328 /* manufacturer */ return new Property("manufacturer", "Reference(Organization)", 1329 "Describes the details of the manufacturer of the medication product. This is not intended to represent the distributor of a medication product.", 1330 0, 1, manufacturer); 1331 case 3148996: 1332 /* form */ return new Property("form", "CodeableConcept", 1333 "Describes the form of the item. Powder; tablets; capsule.", 0, 1, form); 1334 case -1413853096: 1335 /* amount */ return new Property("amount", "Ratio", 1336 "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.).", 1337 0, 1, amount); 1338 case -206409263: 1339 /* ingredient */ return new Property("ingredient", "", 1340 "Identifies a particular constituent of interest in the product.", 0, java.lang.Integer.MAX_VALUE, 1341 ingredient); 1342 case 93509434: 1343 /* batch */ return new Property("batch", "", "Information that only applies to packages (not products).", 0, 1, 1344 batch); 1345 default: 1346 return super.getNamedProperty(_hash, _name, _checkValid); 1347 } 1348 1349 } 1350 1351 @Override 1352 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 1353 switch (hash) { 1354 case -1618432855: 1355 /* identifier */ return this.identifier == null ? new Base[0] 1356 : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier 1357 case 3059181: 1358 /* code */ return this.code == null ? new Base[0] : new Base[] { this.code }; // CodeableConcept 1359 case -892481550: 1360 /* status */ return this.status == null ? new Base[0] : new Base[] { this.status }; // Enumeration<MedicationStatus> 1361 case -1969347631: 1362 /* manufacturer */ return this.manufacturer == null ? new Base[0] : new Base[] { this.manufacturer }; // Reference 1363 case 3148996: 1364 /* form */ return this.form == null ? new Base[0] : new Base[] { this.form }; // CodeableConcept 1365 case -1413853096: 1366 /* amount */ return this.amount == null ? new Base[0] : new Base[] { this.amount }; // Ratio 1367 case -206409263: 1368 /* ingredient */ return this.ingredient == null ? new Base[0] 1369 : this.ingredient.toArray(new Base[this.ingredient.size()]); // MedicationIngredientComponent 1370 case 93509434: 1371 /* batch */ return this.batch == null ? new Base[0] : new Base[] { this.batch }; // MedicationBatchComponent 1372 default: 1373 return super.getProperty(hash, name, checkValid); 1374 } 1375 1376 } 1377 1378 @Override 1379 public Base setProperty(int hash, String name, Base value) throws FHIRException { 1380 switch (hash) { 1381 case -1618432855: // identifier 1382 this.getIdentifier().add(castToIdentifier(value)); // Identifier 1383 return value; 1384 case 3059181: // code 1385 this.code = castToCodeableConcept(value); // CodeableConcept 1386 return value; 1387 case -892481550: // status 1388 value = new MedicationStatusEnumFactory().fromType(castToCode(value)); 1389 this.status = (Enumeration) value; // Enumeration<MedicationStatus> 1390 return value; 1391 case -1969347631: // manufacturer 1392 this.manufacturer = castToReference(value); // Reference 1393 return value; 1394 case 3148996: // form 1395 this.form = castToCodeableConcept(value); // CodeableConcept 1396 return value; 1397 case -1413853096: // amount 1398 this.amount = castToRatio(value); // Ratio 1399 return value; 1400 case -206409263: // ingredient 1401 this.getIngredient().add((MedicationIngredientComponent) value); // MedicationIngredientComponent 1402 return value; 1403 case 93509434: // batch 1404 this.batch = (MedicationBatchComponent) value; // MedicationBatchComponent 1405 return value; 1406 default: 1407 return super.setProperty(hash, name, value); 1408 } 1409 1410 } 1411 1412 @Override 1413 public Base setProperty(String name, Base value) throws FHIRException { 1414 if (name.equals("identifier")) { 1415 this.getIdentifier().add(castToIdentifier(value)); 1416 } else if (name.equals("code")) { 1417 this.code = castToCodeableConcept(value); // CodeableConcept 1418 } else if (name.equals("status")) { 1419 value = new MedicationStatusEnumFactory().fromType(castToCode(value)); 1420 this.status = (Enumeration) value; // Enumeration<MedicationStatus> 1421 } else if (name.equals("manufacturer")) { 1422 this.manufacturer = castToReference(value); // Reference 1423 } else if (name.equals("form")) { 1424 this.form = castToCodeableConcept(value); // CodeableConcept 1425 } else if (name.equals("amount")) { 1426 this.amount = castToRatio(value); // Ratio 1427 } else if (name.equals("ingredient")) { 1428 this.getIngredient().add((MedicationIngredientComponent) value); 1429 } else if (name.equals("batch")) { 1430 this.batch = (MedicationBatchComponent) value; // MedicationBatchComponent 1431 } else 1432 return super.setProperty(name, value); 1433 return value; 1434 } 1435 1436 @Override 1437 public void removeChild(String name, Base value) throws FHIRException { 1438 if (name.equals("identifier")) { 1439 this.getIdentifier().remove(castToIdentifier(value)); 1440 } else if (name.equals("code")) { 1441 this.code = null; 1442 } else if (name.equals("status")) { 1443 this.status = null; 1444 } else if (name.equals("manufacturer")) { 1445 this.manufacturer = null; 1446 } else if (name.equals("form")) { 1447 this.form = null; 1448 } else if (name.equals("amount")) { 1449 this.amount = null; 1450 } else if (name.equals("ingredient")) { 1451 this.getIngredient().remove((MedicationIngredientComponent) value); 1452 } else if (name.equals("batch")) { 1453 this.batch = (MedicationBatchComponent) value; // MedicationBatchComponent 1454 } else 1455 super.removeChild(name, value); 1456 1457 } 1458 1459 @Override 1460 public Base makeProperty(int hash, String name) throws FHIRException { 1461 switch (hash) { 1462 case -1618432855: 1463 return addIdentifier(); 1464 case 3059181: 1465 return getCode(); 1466 case -892481550: 1467 return getStatusElement(); 1468 case -1969347631: 1469 return getManufacturer(); 1470 case 3148996: 1471 return getForm(); 1472 case -1413853096: 1473 return getAmount(); 1474 case -206409263: 1475 return addIngredient(); 1476 case 93509434: 1477 return getBatch(); 1478 default: 1479 return super.makeProperty(hash, name); 1480 } 1481 1482 } 1483 1484 @Override 1485 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 1486 switch (hash) { 1487 case -1618432855: 1488 /* identifier */ return new String[] { "Identifier" }; 1489 case 3059181: 1490 /* code */ return new String[] { "CodeableConcept" }; 1491 case -892481550: 1492 /* status */ return new String[] { "code" }; 1493 case -1969347631: 1494 /* manufacturer */ return new String[] { "Reference" }; 1495 case 3148996: 1496 /* form */ return new String[] { "CodeableConcept" }; 1497 case -1413853096: 1498 /* amount */ return new String[] { "Ratio" }; 1499 case -206409263: 1500 /* ingredient */ return new String[] {}; 1501 case 93509434: 1502 /* batch */ return new String[] {}; 1503 default: 1504 return super.getTypesForProperty(hash, name); 1505 } 1506 1507 } 1508 1509 @Override 1510 public Base addChild(String name) throws FHIRException { 1511 if (name.equals("identifier")) { 1512 return addIdentifier(); 1513 } else if (name.equals("code")) { 1514 this.code = new CodeableConcept(); 1515 return this.code; 1516 } else if (name.equals("status")) { 1517 throw new FHIRException("Cannot call addChild on a singleton property Medication.status"); 1518 } else if (name.equals("manufacturer")) { 1519 this.manufacturer = new Reference(); 1520 return this.manufacturer; 1521 } else if (name.equals("form")) { 1522 this.form = new CodeableConcept(); 1523 return this.form; 1524 } else if (name.equals("amount")) { 1525 this.amount = new Ratio(); 1526 return this.amount; 1527 } else if (name.equals("ingredient")) { 1528 return addIngredient(); 1529 } else if (name.equals("batch")) { 1530 this.batch = new MedicationBatchComponent(); 1531 return this.batch; 1532 } else 1533 return super.addChild(name); 1534 } 1535 1536 public String fhirType() { 1537 return "Medication"; 1538 1539 } 1540 1541 public Medication copy() { 1542 Medication dst = new Medication(); 1543 copyValues(dst); 1544 return dst; 1545 } 1546 1547 public void copyValues(Medication dst) { 1548 super.copyValues(dst); 1549 if (identifier != null) { 1550 dst.identifier = new ArrayList<Identifier>(); 1551 for (Identifier i : identifier) 1552 dst.identifier.add(i.copy()); 1553 } 1554 ; 1555 dst.code = code == null ? null : code.copy(); 1556 dst.status = status == null ? null : status.copy(); 1557 dst.manufacturer = manufacturer == null ? null : manufacturer.copy(); 1558 dst.form = form == null ? null : form.copy(); 1559 dst.amount = amount == null ? null : amount.copy(); 1560 if (ingredient != null) { 1561 dst.ingredient = new ArrayList<MedicationIngredientComponent>(); 1562 for (MedicationIngredientComponent i : ingredient) 1563 dst.ingredient.add(i.copy()); 1564 } 1565 ; 1566 dst.batch = batch == null ? null : batch.copy(); 1567 } 1568 1569 protected Medication typedCopy() { 1570 return copy(); 1571 } 1572 1573 @Override 1574 public boolean equalsDeep(Base other_) { 1575 if (!super.equalsDeep(other_)) 1576 return false; 1577 if (!(other_ instanceof Medication)) 1578 return false; 1579 Medication o = (Medication) other_; 1580 return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) 1581 && compareDeep(status, o.status, true) && compareDeep(manufacturer, o.manufacturer, true) 1582 && compareDeep(form, o.form, true) && compareDeep(amount, o.amount, true) 1583 && compareDeep(ingredient, o.ingredient, true) && compareDeep(batch, o.batch, true); 1584 } 1585 1586 @Override 1587 public boolean equalsShallow(Base other_) { 1588 if (!super.equalsShallow(other_)) 1589 return false; 1590 if (!(other_ instanceof Medication)) 1591 return false; 1592 Medication o = (Medication) other_; 1593 return compareValues(status, o.status, true); 1594 } 1595 1596 public boolean isEmpty() { 1597 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, code, status, manufacturer, form, amount, 1598 ingredient, batch); 1599 } 1600 1601 @Override 1602 public ResourceType getResourceType() { 1603 return ResourceType.Medication; 1604 } 1605 1606 /** 1607 * Search parameter: <b>ingredient-code</b> 1608 * <p> 1609 * Description: <b>Returns medications for this ingredient code</b><br> 1610 * Type: <b>token</b><br> 1611 * Path: <b>Medication.ingredient.itemCodeableConcept</b><br> 1612 * </p> 1613 */ 1614 @SearchParamDefinition(name = "ingredient-code", path = "(Medication.ingredient.item as CodeableConcept)", description = "Returns medications for this ingredient code", type = "token") 1615 public static final String SP_INGREDIENT_CODE = "ingredient-code"; 1616 /** 1617 * <b>Fluent Client</b> search parameter constant for <b>ingredient-code</b> 1618 * <p> 1619 * Description: <b>Returns medications for this ingredient code</b><br> 1620 * Type: <b>token</b><br> 1621 * Path: <b>Medication.ingredient.itemCodeableConcept</b><br> 1622 * </p> 1623 */ 1624 public static final ca.uhn.fhir.rest.gclient.TokenClientParam INGREDIENT_CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam( 1625 SP_INGREDIENT_CODE); 1626 1627 /** 1628 * Search parameter: <b>identifier</b> 1629 * <p> 1630 * Description: <b>Returns medications with this external identifier</b><br> 1631 * Type: <b>token</b><br> 1632 * Path: <b>Medication.identifier</b><br> 1633 * </p> 1634 */ 1635 @SearchParamDefinition(name = "identifier", path = "Medication.identifier", description = "Returns medications with this external identifier", type = "token") 1636 public static final String SP_IDENTIFIER = "identifier"; 1637 /** 1638 * <b>Fluent Client</b> search parameter constant for <b>identifier</b> 1639 * <p> 1640 * Description: <b>Returns medications with this external identifier</b><br> 1641 * Type: <b>token</b><br> 1642 * Path: <b>Medication.identifier</b><br> 1643 * </p> 1644 */ 1645 public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam( 1646 SP_IDENTIFIER); 1647 1648 /** 1649 * Search parameter: <b>code</b> 1650 * <p> 1651 * Description: <b>Returns medications for a specific code</b><br> 1652 * Type: <b>token</b><br> 1653 * Path: <b>Medication.code</b><br> 1654 * </p> 1655 */ 1656 @SearchParamDefinition(name = "code", path = "Medication.code", description = "Returns medications for a specific code", type = "token") 1657 public static final String SP_CODE = "code"; 1658 /** 1659 * <b>Fluent Client</b> search parameter constant for <b>code</b> 1660 * <p> 1661 * Description: <b>Returns medications for a specific code</b><br> 1662 * Type: <b>token</b><br> 1663 * Path: <b>Medication.code</b><br> 1664 * </p> 1665 */ 1666 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam( 1667 SP_CODE); 1668 1669 /** 1670 * Search parameter: <b>ingredient</b> 1671 * <p> 1672 * Description: <b>Returns medications for this ingredient reference</b><br> 1673 * Type: <b>reference</b><br> 1674 * Path: <b>Medication.ingredient.itemReference</b><br> 1675 * </p> 1676 */ 1677 @SearchParamDefinition(name = "ingredient", path = "(Medication.ingredient.item as Reference)", description = "Returns medications for this ingredient reference", type = "reference", target = { 1678 Medication.class, Substance.class }) 1679 public static final String SP_INGREDIENT = "ingredient"; 1680 /** 1681 * <b>Fluent Client</b> search parameter constant for <b>ingredient</b> 1682 * <p> 1683 * Description: <b>Returns medications for this ingredient reference</b><br> 1684 * Type: <b>reference</b><br> 1685 * Path: <b>Medication.ingredient.itemReference</b><br> 1686 * </p> 1687 */ 1688 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INGREDIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam( 1689 SP_INGREDIENT); 1690 1691 /** 1692 * Constant for fluent queries to be used to add include statements. Specifies 1693 * the path value of "<b>Medication:ingredient</b>". 1694 */ 1695 public static final ca.uhn.fhir.model.api.Include INCLUDE_INGREDIENT = new ca.uhn.fhir.model.api.Include( 1696 "Medication:ingredient").toLocked(); 1697 1698 /** 1699 * Search parameter: <b>form</b> 1700 * <p> 1701 * Description: <b>Returns medications for a specific dose form</b><br> 1702 * Type: <b>token</b><br> 1703 * Path: <b>Medication.form</b><br> 1704 * </p> 1705 */ 1706 @SearchParamDefinition(name = "form", path = "Medication.form", description = "Returns medications for a specific dose form", type = "token") 1707 public static final String SP_FORM = "form"; 1708 /** 1709 * <b>Fluent Client</b> search parameter constant for <b>form</b> 1710 * <p> 1711 * Description: <b>Returns medications for a specific dose form</b><br> 1712 * Type: <b>token</b><br> 1713 * Path: <b>Medication.form</b><br> 1714 * </p> 1715 */ 1716 public static final ca.uhn.fhir.rest.gclient.TokenClientParam FORM = new ca.uhn.fhir.rest.gclient.TokenClientParam( 1717 SP_FORM); 1718 1719 /** 1720 * Search parameter: <b>lot-number</b> 1721 * <p> 1722 * Description: <b>Returns medications in a batch with this lot number</b><br> 1723 * Type: <b>token</b><br> 1724 * Path: <b>Medication.batch.lotNumber</b><br> 1725 * </p> 1726 */ 1727 @SearchParamDefinition(name = "lot-number", path = "Medication.batch.lotNumber", description = "Returns medications in a batch with this lot number", type = "token") 1728 public static final String SP_LOT_NUMBER = "lot-number"; 1729 /** 1730 * <b>Fluent Client</b> search parameter constant for <b>lot-number</b> 1731 * <p> 1732 * Description: <b>Returns medications in a batch with this lot number</b><br> 1733 * Type: <b>token</b><br> 1734 * Path: <b>Medication.batch.lotNumber</b><br> 1735 * </p> 1736 */ 1737 public static final ca.uhn.fhir.rest.gclient.TokenClientParam LOT_NUMBER = new ca.uhn.fhir.rest.gclient.TokenClientParam( 1738 SP_LOT_NUMBER); 1739 1740 /** 1741 * Search parameter: <b>expiration-date</b> 1742 * <p> 1743 * Description: <b>Returns medications in a batch with this expiration 1744 * date</b><br> 1745 * Type: <b>date</b><br> 1746 * Path: <b>Medication.batch.expirationDate</b><br> 1747 * </p> 1748 */ 1749 @SearchParamDefinition(name = "expiration-date", path = "Medication.batch.expirationDate", description = "Returns medications in a batch with this expiration date", type = "date") 1750 public static final String SP_EXPIRATION_DATE = "expiration-date"; 1751 /** 1752 * <b>Fluent Client</b> search parameter constant for <b>expiration-date</b> 1753 * <p> 1754 * Description: <b>Returns medications in a batch with this expiration 1755 * date</b><br> 1756 * Type: <b>date</b><br> 1757 * Path: <b>Medication.batch.expirationDate</b><br> 1758 * </p> 1759 */ 1760 public static final ca.uhn.fhir.rest.gclient.DateClientParam EXPIRATION_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam( 1761 SP_EXPIRATION_DATE); 1762 1763 /** 1764 * Search parameter: <b>manufacturer</b> 1765 * <p> 1766 * Description: <b>Returns medications made or sold for this 1767 * manufacturer</b><br> 1768 * Type: <b>reference</b><br> 1769 * Path: <b>Medication.manufacturer</b><br> 1770 * </p> 1771 */ 1772 @SearchParamDefinition(name = "manufacturer", path = "Medication.manufacturer", description = "Returns medications made or sold for this manufacturer", type = "reference", target = { 1773 Organization.class }) 1774 public static final String SP_MANUFACTURER = "manufacturer"; 1775 /** 1776 * <b>Fluent Client</b> search parameter constant for <b>manufacturer</b> 1777 * <p> 1778 * Description: <b>Returns medications made or sold for this 1779 * manufacturer</b><br> 1780 * Type: <b>reference</b><br> 1781 * Path: <b>Medication.manufacturer</b><br> 1782 * </p> 1783 */ 1784 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MANUFACTURER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam( 1785 SP_MANUFACTURER); 1786 1787 /** 1788 * Constant for fluent queries to be used to add include statements. Specifies 1789 * the path value of "<b>Medication:manufacturer</b>". 1790 */ 1791 public static final ca.uhn.fhir.model.api.Include INCLUDE_MANUFACTURER = new ca.uhn.fhir.model.api.Include( 1792 "Medication:manufacturer").toLocked(); 1793 1794 /** 1795 * Search parameter: <b>status</b> 1796 * <p> 1797 * Description: <b>Returns medications for this status</b><br> 1798 * Type: <b>token</b><br> 1799 * Path: <b>Medication.status</b><br> 1800 * </p> 1801 */ 1802 @SearchParamDefinition(name = "status", path = "Medication.status", description = "Returns medications for this status", type = "token") 1803 public static final String SP_STATUS = "status"; 1804 /** 1805 * <b>Fluent Client</b> search parameter constant for <b>status</b> 1806 * <p> 1807 * Description: <b>Returns medications for this status</b><br> 1808 * Type: <b>token</b><br> 1809 * Path: <b>Medication.status</b><br> 1810 * </p> 1811 */ 1812 public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam( 1813 SP_STATUS); 1814 1815}