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