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