001package org.hl7.fhir.instance.model; 002 003/* 004 Copyright (c) 2011+, HL7, Inc. 005 All rights reserved. 006 007 Redistribution and use in source and binary forms, with or without modification, 008 are permitted provided that the following conditions are met: 009 010 * Redistributions of source code must retain the above copyright notice, this 011 list of conditions and the following disclaimer. 012 * Redistributions in binary form must reproduce the above copyright notice, 013 this list of conditions and the following disclaimer in the documentation 014 and/or other materials provided with the distribution. 015 * Neither the name of HL7 nor the names of its contributors may be used to 016 endorse or promote products derived from this software without specific 017 prior written permission. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 022 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 024 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 026 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 028 POSSIBILITY OF SUCH DAMAGE. 029 030*/ 031 032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 033import java.util.*; 034 035import org.hl7.fhir.exceptions.FHIRException; 036import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 037import org.hl7.fhir.utilities.Utilities; 038 039import ca.uhn.fhir.model.api.annotation.*; 040/** 041 * This resource is primarily used for the identification and definition of a medication. It covers the ingredients and the packaging for a medication. 042 */ 043@ResourceDef(name="Medication", profile="http://hl7.org/fhir/Profile/Medication") 044public class Medication extends DomainResource { 045 046 @Block() 047 public static class MedicationProductComponent extends BackboneElement implements IBaseBackboneElement { 048 /** 049 * Describes the form of the item. Powder; tablets; carton. 050 */ 051 @Child(name = "form", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false) 052 @Description(shortDefinition="powder | tablets | carton +", formalDefinition="Describes the form of the item. Powder; tablets; carton." ) 053 protected CodeableConcept form; 054 055 /** 056 * Identifies a particular constituent of interest in the product. 057 */ 058 @Child(name = "ingredient", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 059 @Description(shortDefinition="Active or inactive ingredient", formalDefinition="Identifies a particular constituent of interest in the product." ) 060 protected List<MedicationProductIngredientComponent> ingredient; 061 062 /** 063 * Information about a group of medication produced or packaged from one production run. 064 */ 065 @Child(name = "batch", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 066 @Description(shortDefinition="", formalDefinition="Information about a group of medication produced or packaged from one production run." ) 067 protected List<MedicationProductBatchComponent> batch; 068 069 private static final long serialVersionUID = 1132853671L; 070 071 /* 072 * Constructor 073 */ 074 public MedicationProductComponent() { 075 super(); 076 } 077 078 /** 079 * @return {@link #form} (Describes the form of the item. Powder; tablets; carton.) 080 */ 081 public CodeableConcept getForm() { 082 if (this.form == null) 083 if (Configuration.errorOnAutoCreate()) 084 throw new Error("Attempt to auto-create MedicationProductComponent.form"); 085 else if (Configuration.doAutoCreate()) 086 this.form = new CodeableConcept(); // cc 087 return this.form; 088 } 089 090 public boolean hasForm() { 091 return this.form != null && !this.form.isEmpty(); 092 } 093 094 /** 095 * @param value {@link #form} (Describes the form of the item. Powder; tablets; carton.) 096 */ 097 public MedicationProductComponent setForm(CodeableConcept value) { 098 this.form = value; 099 return this; 100 } 101 102 /** 103 * @return {@link #ingredient} (Identifies a particular constituent of interest in the product.) 104 */ 105 public List<MedicationProductIngredientComponent> getIngredient() { 106 if (this.ingredient == null) 107 this.ingredient = new ArrayList<MedicationProductIngredientComponent>(); 108 return this.ingredient; 109 } 110 111 public boolean hasIngredient() { 112 if (this.ingredient == null) 113 return false; 114 for (MedicationProductIngredientComponent item : this.ingredient) 115 if (!item.isEmpty()) 116 return true; 117 return false; 118 } 119 120 /** 121 * @return {@link #ingredient} (Identifies a particular constituent of interest in the product.) 122 */ 123 // syntactic sugar 124 public MedicationProductIngredientComponent addIngredient() { //3 125 MedicationProductIngredientComponent t = new MedicationProductIngredientComponent(); 126 if (this.ingredient == null) 127 this.ingredient = new ArrayList<MedicationProductIngredientComponent>(); 128 this.ingredient.add(t); 129 return t; 130 } 131 132 // syntactic sugar 133 public MedicationProductComponent addIngredient(MedicationProductIngredientComponent t) { //3 134 if (t == null) 135 return this; 136 if (this.ingredient == null) 137 this.ingredient = new ArrayList<MedicationProductIngredientComponent>(); 138 this.ingredient.add(t); 139 return this; 140 } 141 142 /** 143 * @return {@link #batch} (Information about a group of medication produced or packaged from one production run.) 144 */ 145 public List<MedicationProductBatchComponent> getBatch() { 146 if (this.batch == null) 147 this.batch = new ArrayList<MedicationProductBatchComponent>(); 148 return this.batch; 149 } 150 151 public boolean hasBatch() { 152 if (this.batch == null) 153 return false; 154 for (MedicationProductBatchComponent item : this.batch) 155 if (!item.isEmpty()) 156 return true; 157 return false; 158 } 159 160 /** 161 * @return {@link #batch} (Information about a group of medication produced or packaged from one production run.) 162 */ 163 // syntactic sugar 164 public MedicationProductBatchComponent addBatch() { //3 165 MedicationProductBatchComponent t = new MedicationProductBatchComponent(); 166 if (this.batch == null) 167 this.batch = new ArrayList<MedicationProductBatchComponent>(); 168 this.batch.add(t); 169 return t; 170 } 171 172 // syntactic sugar 173 public MedicationProductComponent addBatch(MedicationProductBatchComponent t) { //3 174 if (t == null) 175 return this; 176 if (this.batch == null) 177 this.batch = new ArrayList<MedicationProductBatchComponent>(); 178 this.batch.add(t); 179 return this; 180 } 181 182 protected void listChildren(List<Property> childrenList) { 183 super.listChildren(childrenList); 184 childrenList.add(new Property("form", "CodeableConcept", "Describes the form of the item. Powder; tablets; carton.", 0, java.lang.Integer.MAX_VALUE, form)); 185 childrenList.add(new Property("ingredient", "", "Identifies a particular constituent of interest in the product.", 0, java.lang.Integer.MAX_VALUE, ingredient)); 186 childrenList.add(new Property("batch", "", "Information about a group of medication produced or packaged from one production run.", 0, java.lang.Integer.MAX_VALUE, batch)); 187 } 188 189 @Override 190 public void setProperty(String name, Base value) throws FHIRException { 191 if (name.equals("form")) 192 this.form = castToCodeableConcept(value); // CodeableConcept 193 else if (name.equals("ingredient")) 194 this.getIngredient().add((MedicationProductIngredientComponent) value); 195 else if (name.equals("batch")) 196 this.getBatch().add((MedicationProductBatchComponent) value); 197 else 198 super.setProperty(name, value); 199 } 200 201 @Override 202 public Base addChild(String name) throws FHIRException { 203 if (name.equals("form")) { 204 this.form = new CodeableConcept(); 205 return this.form; 206 } 207 else if (name.equals("ingredient")) { 208 return addIngredient(); 209 } 210 else if (name.equals("batch")) { 211 return addBatch(); 212 } 213 else 214 return super.addChild(name); 215 } 216 217 public MedicationProductComponent copy() { 218 MedicationProductComponent dst = new MedicationProductComponent(); 219 copyValues(dst); 220 dst.form = form == null ? null : form.copy(); 221 if (ingredient != null) { 222 dst.ingredient = new ArrayList<MedicationProductIngredientComponent>(); 223 for (MedicationProductIngredientComponent i : ingredient) 224 dst.ingredient.add(i.copy()); 225 }; 226 if (batch != null) { 227 dst.batch = new ArrayList<MedicationProductBatchComponent>(); 228 for (MedicationProductBatchComponent i : batch) 229 dst.batch.add(i.copy()); 230 }; 231 return dst; 232 } 233 234 @Override 235 public boolean equalsDeep(Base other) { 236 if (!super.equalsDeep(other)) 237 return false; 238 if (!(other instanceof MedicationProductComponent)) 239 return false; 240 MedicationProductComponent o = (MedicationProductComponent) other; 241 return compareDeep(form, o.form, true) && compareDeep(ingredient, o.ingredient, true) && compareDeep(batch, o.batch, true) 242 ; 243 } 244 245 @Override 246 public boolean equalsShallow(Base other) { 247 if (!super.equalsShallow(other)) 248 return false; 249 if (!(other instanceof MedicationProductComponent)) 250 return false; 251 MedicationProductComponent o = (MedicationProductComponent) other; 252 return true; 253 } 254 255 public boolean isEmpty() { 256 return super.isEmpty() && (form == null || form.isEmpty()) && (ingredient == null || ingredient.isEmpty()) 257 && (batch == null || batch.isEmpty()); 258 } 259 260 public String fhirType() { 261 return "Medication.product"; 262 263 } 264 265 } 266 267 @Block() 268 public static class MedicationProductIngredientComponent extends BackboneElement implements IBaseBackboneElement { 269 /** 270 * The actual ingredient - either a substance (simple ingredient) or another medication. 271 */ 272 @Child(name = "item", type = {Substance.class, Medication.class}, order=1, min=1, max=1, modifier=false, summary=false) 273 @Description(shortDefinition="The product contained", formalDefinition="The actual ingredient - either a substance (simple ingredient) or another medication." ) 274 protected Reference item; 275 276 /** 277 * The actual object that is the target of the reference (The actual ingredient - either a substance (simple ingredient) or another medication.) 278 */ 279 protected Resource itemTarget; 280 281 /** 282 * Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet. 283 */ 284 @Child(name = "amount", type = {Ratio.class}, order=2, min=0, max=1, modifier=false, summary=false) 285 @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." ) 286 protected Ratio amount; 287 288 private static final long serialVersionUID = -1217232889L; 289 290 /* 291 * Constructor 292 */ 293 public MedicationProductIngredientComponent() { 294 super(); 295 } 296 297 /* 298 * Constructor 299 */ 300 public MedicationProductIngredientComponent(Reference item) { 301 super(); 302 this.item = item; 303 } 304 305 /** 306 * @return {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication.) 307 */ 308 public Reference getItem() { 309 if (this.item == null) 310 if (Configuration.errorOnAutoCreate()) 311 throw new Error("Attempt to auto-create MedicationProductIngredientComponent.item"); 312 else if (Configuration.doAutoCreate()) 313 this.item = new Reference(); // cc 314 return this.item; 315 } 316 317 public boolean hasItem() { 318 return this.item != null && !this.item.isEmpty(); 319 } 320 321 /** 322 * @param value {@link #item} (The actual ingredient - either a substance (simple ingredient) or another medication.) 323 */ 324 public MedicationProductIngredientComponent setItem(Reference value) { 325 this.item = value; 326 return this; 327 } 328 329 /** 330 * @return {@link #item} 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. (The actual ingredient - either a substance (simple ingredient) or another medication.) 331 */ 332 public Resource getItemTarget() { 333 return this.itemTarget; 334 } 335 336 /** 337 * @param value {@link #item} 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. (The actual ingredient - either a substance (simple ingredient) or another medication.) 338 */ 339 public MedicationProductIngredientComponent setItemTarget(Resource value) { 340 this.itemTarget = value; 341 return this; 342 } 343 344 /** 345 * @return {@link #amount} (Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet.) 346 */ 347 public Ratio getAmount() { 348 if (this.amount == null) 349 if (Configuration.errorOnAutoCreate()) 350 throw new Error("Attempt to auto-create MedicationProductIngredientComponent.amount"); 351 else if (Configuration.doAutoCreate()) 352 this.amount = new Ratio(); // cc 353 return this.amount; 354 } 355 356 public boolean hasAmount() { 357 return this.amount != null && !this.amount.isEmpty(); 358 } 359 360 /** 361 * @param value {@link #amount} (Specifies how many (or how much) of the items there are in this Medication. For example, 250 mg per tablet.) 362 */ 363 public MedicationProductIngredientComponent setAmount(Ratio value) { 364 this.amount = value; 365 return this; 366 } 367 368 protected void listChildren(List<Property> childrenList) { 369 super.listChildren(childrenList); 370 childrenList.add(new Property("item", "Reference(Substance|Medication)", "The actual ingredient - either a substance (simple ingredient) or another medication.", 0, java.lang.Integer.MAX_VALUE, item)); 371 childrenList.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.", 0, java.lang.Integer.MAX_VALUE, amount)); 372 } 373 374 @Override 375 public void setProperty(String name, Base value) throws FHIRException { 376 if (name.equals("item")) 377 this.item = castToReference(value); // Reference 378 else if (name.equals("amount")) 379 this.amount = castToRatio(value); // Ratio 380 else 381 super.setProperty(name, value); 382 } 383 384 @Override 385 public Base addChild(String name) throws FHIRException { 386 if (name.equals("item")) { 387 this.item = new Reference(); 388 return this.item; 389 } 390 else if (name.equals("amount")) { 391 this.amount = new Ratio(); 392 return this.amount; 393 } 394 else 395 return super.addChild(name); 396 } 397 398 public MedicationProductIngredientComponent copy() { 399 MedicationProductIngredientComponent dst = new MedicationProductIngredientComponent(); 400 copyValues(dst); 401 dst.item = item == null ? null : item.copy(); 402 dst.amount = amount == null ? null : amount.copy(); 403 return dst; 404 } 405 406 @Override 407 public boolean equalsDeep(Base other) { 408 if (!super.equalsDeep(other)) 409 return false; 410 if (!(other instanceof MedicationProductIngredientComponent)) 411 return false; 412 MedicationProductIngredientComponent o = (MedicationProductIngredientComponent) other; 413 return compareDeep(item, o.item, true) && compareDeep(amount, o.amount, true); 414 } 415 416 @Override 417 public boolean equalsShallow(Base other) { 418 if (!super.equalsShallow(other)) 419 return false; 420 if (!(other instanceof MedicationProductIngredientComponent)) 421 return false; 422 MedicationProductIngredientComponent o = (MedicationProductIngredientComponent) other; 423 return true; 424 } 425 426 public boolean isEmpty() { 427 return super.isEmpty() && (item == null || item.isEmpty()) && (amount == null || amount.isEmpty()) 428 ; 429 } 430 431 public String fhirType() { 432 return "Medication.product.ingredient"; 433 434 } 435 436 } 437 438 @Block() 439 public static class MedicationProductBatchComponent extends BackboneElement implements IBaseBackboneElement { 440 /** 441 * The assigned lot number of a batch of the specified product. 442 */ 443 @Child(name = "lotNumber", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false) 444 @Description(shortDefinition="", formalDefinition="The assigned lot number of a batch of the specified product." ) 445 protected StringType lotNumber; 446 447 /** 448 * When this specific batch of product will expire. 449 */ 450 @Child(name = "expirationDate", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false) 451 @Description(shortDefinition="", formalDefinition="When this specific batch of product will expire." ) 452 protected DateTimeType expirationDate; 453 454 private static final long serialVersionUID = 1982738755L; 455 456 /* 457 * Constructor 458 */ 459 public MedicationProductBatchComponent() { 460 super(); 461 } 462 463 /** 464 * @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 465 */ 466 public StringType getLotNumberElement() { 467 if (this.lotNumber == null) 468 if (Configuration.errorOnAutoCreate()) 469 throw new Error("Attempt to auto-create MedicationProductBatchComponent.lotNumber"); 470 else if (Configuration.doAutoCreate()) 471 this.lotNumber = new StringType(); // bb 472 return this.lotNumber; 473 } 474 475 public boolean hasLotNumberElement() { 476 return this.lotNumber != null && !this.lotNumber.isEmpty(); 477 } 478 479 public boolean hasLotNumber() { 480 return this.lotNumber != null && !this.lotNumber.isEmpty(); 481 } 482 483 /** 484 * @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 485 */ 486 public MedicationProductBatchComponent setLotNumberElement(StringType value) { 487 this.lotNumber = value; 488 return this; 489 } 490 491 /** 492 * @return The assigned lot number of a batch of the specified product. 493 */ 494 public String getLotNumber() { 495 return this.lotNumber == null ? null : this.lotNumber.getValue(); 496 } 497 498 /** 499 * @param value The assigned lot number of a batch of the specified product. 500 */ 501 public MedicationProductBatchComponent setLotNumber(String value) { 502 if (Utilities.noString(value)) 503 this.lotNumber = null; 504 else { 505 if (this.lotNumber == null) 506 this.lotNumber = new StringType(); 507 this.lotNumber.setValue(value); 508 } 509 return this; 510 } 511 512 /** 513 * @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 514 */ 515 public DateTimeType getExpirationDateElement() { 516 if (this.expirationDate == null) 517 if (Configuration.errorOnAutoCreate()) 518 throw new Error("Attempt to auto-create MedicationProductBatchComponent.expirationDate"); 519 else if (Configuration.doAutoCreate()) 520 this.expirationDate = new DateTimeType(); // bb 521 return this.expirationDate; 522 } 523 524 public boolean hasExpirationDateElement() { 525 return this.expirationDate != null && !this.expirationDate.isEmpty(); 526 } 527 528 public boolean hasExpirationDate() { 529 return this.expirationDate != null && !this.expirationDate.isEmpty(); 530 } 531 532 /** 533 * @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 534 */ 535 public MedicationProductBatchComponent setExpirationDateElement(DateTimeType value) { 536 this.expirationDate = value; 537 return this; 538 } 539 540 /** 541 * @return When this specific batch of product will expire. 542 */ 543 public Date getExpirationDate() { 544 return this.expirationDate == null ? null : this.expirationDate.getValue(); 545 } 546 547 /** 548 * @param value When this specific batch of product will expire. 549 */ 550 public MedicationProductBatchComponent setExpirationDate(Date value) { 551 if (value == null) 552 this.expirationDate = null; 553 else { 554 if (this.expirationDate == null) 555 this.expirationDate = new DateTimeType(); 556 this.expirationDate.setValue(value); 557 } 558 return this; 559 } 560 561 protected void listChildren(List<Property> childrenList) { 562 super.listChildren(childrenList); 563 childrenList.add(new Property("lotNumber", "string", "The assigned lot number of a batch of the specified product.", 0, java.lang.Integer.MAX_VALUE, lotNumber)); 564 childrenList.add(new Property("expirationDate", "dateTime", "When this specific batch of product will expire.", 0, java.lang.Integer.MAX_VALUE, expirationDate)); 565 } 566 567 @Override 568 public void setProperty(String name, Base value) throws FHIRException { 569 if (name.equals("lotNumber")) 570 this.lotNumber = castToString(value); // StringType 571 else if (name.equals("expirationDate")) 572 this.expirationDate = castToDateTime(value); // DateTimeType 573 else 574 super.setProperty(name, value); 575 } 576 577 @Override 578 public Base addChild(String name) throws FHIRException { 579 if (name.equals("lotNumber")) { 580 throw new FHIRException("Cannot call addChild on a primitive type Medication.lotNumber"); 581 } 582 else if (name.equals("expirationDate")) { 583 throw new FHIRException("Cannot call addChild on a primitive type Medication.expirationDate"); 584 } 585 else 586 return super.addChild(name); 587 } 588 589 public MedicationProductBatchComponent copy() { 590 MedicationProductBatchComponent dst = new MedicationProductBatchComponent(); 591 copyValues(dst); 592 dst.lotNumber = lotNumber == null ? null : lotNumber.copy(); 593 dst.expirationDate = expirationDate == null ? null : expirationDate.copy(); 594 return dst; 595 } 596 597 @Override 598 public boolean equalsDeep(Base other) { 599 if (!super.equalsDeep(other)) 600 return false; 601 if (!(other instanceof MedicationProductBatchComponent)) 602 return false; 603 MedicationProductBatchComponent o = (MedicationProductBatchComponent) other; 604 return compareDeep(lotNumber, o.lotNumber, true) && compareDeep(expirationDate, o.expirationDate, true) 605 ; 606 } 607 608 @Override 609 public boolean equalsShallow(Base other) { 610 if (!super.equalsShallow(other)) 611 return false; 612 if (!(other instanceof MedicationProductBatchComponent)) 613 return false; 614 MedicationProductBatchComponent o = (MedicationProductBatchComponent) other; 615 return compareValues(lotNumber, o.lotNumber, true) && compareValues(expirationDate, o.expirationDate, true) 616 ; 617 } 618 619 public boolean isEmpty() { 620 return super.isEmpty() && (lotNumber == null || lotNumber.isEmpty()) && (expirationDate == null || expirationDate.isEmpty()) 621 ; 622 } 623 624 public String fhirType() { 625 return "Medication.product.batch"; 626 627 } 628 629 } 630 631 @Block() 632 public static class MedicationPackageComponent extends BackboneElement implements IBaseBackboneElement { 633 /** 634 * The kind of container that this package comes as. 635 */ 636 @Child(name = "container", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false) 637 @Description(shortDefinition="E.g. box, vial, blister-pack", formalDefinition="The kind of container that this package comes as." ) 638 protected CodeableConcept container; 639 640 /** 641 * A set of components that go to make up the described item. 642 */ 643 @Child(name = "content", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 644 @Description(shortDefinition="What is in the package", formalDefinition="A set of components that go to make up the described item." ) 645 protected List<MedicationPackageContentComponent> content; 646 647 private static final long serialVersionUID = 503772472L; 648 649 /* 650 * Constructor 651 */ 652 public MedicationPackageComponent() { 653 super(); 654 } 655 656 /** 657 * @return {@link #container} (The kind of container that this package comes as.) 658 */ 659 public CodeableConcept getContainer() { 660 if (this.container == null) 661 if (Configuration.errorOnAutoCreate()) 662 throw new Error("Attempt to auto-create MedicationPackageComponent.container"); 663 else if (Configuration.doAutoCreate()) 664 this.container = new CodeableConcept(); // cc 665 return this.container; 666 } 667 668 public boolean hasContainer() { 669 return this.container != null && !this.container.isEmpty(); 670 } 671 672 /** 673 * @param value {@link #container} (The kind of container that this package comes as.) 674 */ 675 public MedicationPackageComponent setContainer(CodeableConcept value) { 676 this.container = value; 677 return this; 678 } 679 680 /** 681 * @return {@link #content} (A set of components that go to make up the described item.) 682 */ 683 public List<MedicationPackageContentComponent> getContent() { 684 if (this.content == null) 685 this.content = new ArrayList<MedicationPackageContentComponent>(); 686 return this.content; 687 } 688 689 public boolean hasContent() { 690 if (this.content == null) 691 return false; 692 for (MedicationPackageContentComponent item : this.content) 693 if (!item.isEmpty()) 694 return true; 695 return false; 696 } 697 698 /** 699 * @return {@link #content} (A set of components that go to make up the described item.) 700 */ 701 // syntactic sugar 702 public MedicationPackageContentComponent addContent() { //3 703 MedicationPackageContentComponent t = new MedicationPackageContentComponent(); 704 if (this.content == null) 705 this.content = new ArrayList<MedicationPackageContentComponent>(); 706 this.content.add(t); 707 return t; 708 } 709 710 // syntactic sugar 711 public MedicationPackageComponent addContent(MedicationPackageContentComponent t) { //3 712 if (t == null) 713 return this; 714 if (this.content == null) 715 this.content = new ArrayList<MedicationPackageContentComponent>(); 716 this.content.add(t); 717 return this; 718 } 719 720 protected void listChildren(List<Property> childrenList) { 721 super.listChildren(childrenList); 722 childrenList.add(new Property("container", "CodeableConcept", "The kind of container that this package comes as.", 0, java.lang.Integer.MAX_VALUE, container)); 723 childrenList.add(new Property("content", "", "A set of components that go to make up the described item.", 0, java.lang.Integer.MAX_VALUE, content)); 724 } 725 726 @Override 727 public void setProperty(String name, Base value) throws FHIRException { 728 if (name.equals("container")) 729 this.container = castToCodeableConcept(value); // CodeableConcept 730 else if (name.equals("content")) 731 this.getContent().add((MedicationPackageContentComponent) value); 732 else 733 super.setProperty(name, value); 734 } 735 736 @Override 737 public Base addChild(String name) throws FHIRException { 738 if (name.equals("container")) { 739 this.container = new CodeableConcept(); 740 return this.container; 741 } 742 else if (name.equals("content")) { 743 return addContent(); 744 } 745 else 746 return super.addChild(name); 747 } 748 749 public MedicationPackageComponent copy() { 750 MedicationPackageComponent dst = new MedicationPackageComponent(); 751 copyValues(dst); 752 dst.container = container == null ? null : container.copy(); 753 if (content != null) { 754 dst.content = new ArrayList<MedicationPackageContentComponent>(); 755 for (MedicationPackageContentComponent i : content) 756 dst.content.add(i.copy()); 757 }; 758 return dst; 759 } 760 761 @Override 762 public boolean equalsDeep(Base other) { 763 if (!super.equalsDeep(other)) 764 return false; 765 if (!(other instanceof MedicationPackageComponent)) 766 return false; 767 MedicationPackageComponent o = (MedicationPackageComponent) other; 768 return compareDeep(container, o.container, true) && compareDeep(content, o.content, true); 769 } 770 771 @Override 772 public boolean equalsShallow(Base other) { 773 if (!super.equalsShallow(other)) 774 return false; 775 if (!(other instanceof MedicationPackageComponent)) 776 return false; 777 MedicationPackageComponent o = (MedicationPackageComponent) other; 778 return true; 779 } 780 781 public boolean isEmpty() { 782 return super.isEmpty() && (container == null || container.isEmpty()) && (content == null || content.isEmpty()) 783 ; 784 } 785 786 public String fhirType() { 787 return "Medication.package"; 788 789 } 790 791 } 792 793 @Block() 794 public static class MedicationPackageContentComponent extends BackboneElement implements IBaseBackboneElement { 795 /** 796 * Identifies one of the items in the package. 797 */ 798 @Child(name = "item", type = {Medication.class}, order=1, min=1, max=1, modifier=false, summary=false) 799 @Description(shortDefinition="A product in the package", formalDefinition="Identifies one of the items in the package." ) 800 protected Reference item; 801 802 /** 803 * The actual object that is the target of the reference (Identifies one of the items in the package.) 804 */ 805 protected Medication itemTarget; 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 = -1150048030L; 815 816 /* 817 * Constructor 818 */ 819 public MedicationPackageContentComponent() { 820 super(); 821 } 822 823 /* 824 * Constructor 825 */ 826 public MedicationPackageContentComponent(Reference 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 Reference getItem() { 835 if (this.item == null) 836 if (Configuration.errorOnAutoCreate()) 837 throw new Error("Attempt to auto-create MedicationPackageContentComponent.item"); 838 else if (Configuration.doAutoCreate()) 839 this.item = new Reference(); // cc 840 return this.item; 841 } 842 843 public boolean hasItem() { 844 return this.item != null && !this.item.isEmpty(); 845 } 846 847 /** 848 * @param value {@link #item} (Identifies one of the items in the package.) 849 */ 850 public MedicationPackageContentComponent setItem(Reference value) { 851 this.item = value; 852 return this; 853 } 854 855 /** 856 * @return {@link #item} 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. (Identifies one of the items in the package.) 857 */ 858 public Medication getItemTarget() { 859 if (this.itemTarget == null) 860 if (Configuration.errorOnAutoCreate()) 861 throw new Error("Attempt to auto-create MedicationPackageContentComponent.item"); 862 else if (Configuration.doAutoCreate()) 863 this.itemTarget = new Medication(); // aa 864 return this.itemTarget; 865 } 866 867 /** 868 * @param value {@link #item} 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. (Identifies one of the items in the package.) 869 */ 870 public MedicationPackageContentComponent setItemTarget(Medication value) { 871 this.itemTarget = value; 872 return this; 873 } 874 875 /** 876 * @return {@link #amount} (The amount of the product that is in the package.) 877 */ 878 public SimpleQuantity getAmount() { 879 if (this.amount == null) 880 if (Configuration.errorOnAutoCreate()) 881 throw new Error("Attempt to auto-create MedicationPackageContentComponent.amount"); 882 else if (Configuration.doAutoCreate()) 883 this.amount = new SimpleQuantity(); // cc 884 return this.amount; 885 } 886 887 public boolean hasAmount() { 888 return this.amount != null && !this.amount.isEmpty(); 889 } 890 891 /** 892 * @param value {@link #amount} (The amount of the product that is in the package.) 893 */ 894 public MedicationPackageContentComponent setAmount(SimpleQuantity value) { 895 this.amount = value; 896 return this; 897 } 898 899 protected void listChildren(List<Property> childrenList) { 900 super.listChildren(childrenList); 901 childrenList.add(new Property("item", "Reference(Medication)", "Identifies one of the items in the package.", 0, java.lang.Integer.MAX_VALUE, item)); 902 childrenList.add(new Property("amount", "SimpleQuantity", "The amount of the product that is in the package.", 0, java.lang.Integer.MAX_VALUE, amount)); 903 } 904 905 @Override 906 public void setProperty(String name, Base value) throws FHIRException { 907 if (name.equals("item")) 908 this.item = castToReference(value); // Reference 909 else if (name.equals("amount")) 910 this.amount = castToSimpleQuantity(value); // SimpleQuantity 911 else 912 super.setProperty(name, value); 913 } 914 915 @Override 916 public Base addChild(String name) throws FHIRException { 917 if (name.equals("item")) { 918 this.item = new Reference(); 919 return this.item; 920 } 921 else if (name.equals("amount")) { 922 this.amount = new SimpleQuantity(); 923 return this.amount; 924 } 925 else 926 return super.addChild(name); 927 } 928 929 public MedicationPackageContentComponent copy() { 930 MedicationPackageContentComponent dst = new MedicationPackageContentComponent(); 931 copyValues(dst); 932 dst.item = item == null ? null : item.copy(); 933 dst.amount = amount == null ? null : amount.copy(); 934 return dst; 935 } 936 937 @Override 938 public boolean equalsDeep(Base other) { 939 if (!super.equalsDeep(other)) 940 return false; 941 if (!(other instanceof MedicationPackageContentComponent)) 942 return false; 943 MedicationPackageContentComponent o = (MedicationPackageContentComponent) other; 944 return compareDeep(item, o.item, true) && compareDeep(amount, o.amount, true); 945 } 946 947 @Override 948 public boolean equalsShallow(Base other) { 949 if (!super.equalsShallow(other)) 950 return false; 951 if (!(other instanceof MedicationPackageContentComponent)) 952 return false; 953 MedicationPackageContentComponent o = (MedicationPackageContentComponent) other; 954 return true; 955 } 956 957 public boolean isEmpty() { 958 return super.isEmpty() && (item == null || item.isEmpty()) && (amount == null || amount.isEmpty()) 959 ; 960 } 961 962 public String fhirType() { 963 return "Medication.package.content"; 964 965 } 966 967 } 968 969 /** 970 * 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. 971 */ 972 @Child(name = "code", type = {CodeableConcept.class}, order=0, min=0, max=1, modifier=false, summary=true) 973 @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." ) 974 protected CodeableConcept code; 975 976 /** 977 * Set to true if the item is attributable to a specific manufacturer. 978 */ 979 @Child(name = "isBrand", type = {BooleanType.class}, order=1, min=0, max=1, modifier=false, summary=true) 980 @Description(shortDefinition="True if a brand", formalDefinition="Set to true if the item is attributable to a specific manufacturer." ) 981 protected BooleanType isBrand; 982 983 /** 984 * Describes the details of the manufacturer. 985 */ 986 @Child(name = "manufacturer", type = {Organization.class}, order=2, min=0, max=1, modifier=false, summary=true) 987 @Description(shortDefinition="Manufacturer of the item", formalDefinition="Describes the details of the manufacturer." ) 988 protected Reference manufacturer; 989 990 /** 991 * The actual object that is the target of the reference (Describes the details of the manufacturer.) 992 */ 993 protected Organization manufacturerTarget; 994 995 /** 996 * Information that only applies to products (not packages). 997 */ 998 @Child(name = "product", type = {}, order=3, min=0, max=1, modifier=false, summary=false) 999 @Description(shortDefinition="Administrable medication details", formalDefinition="Information that only applies to products (not packages)." ) 1000 protected MedicationProductComponent product; 1001 1002 /** 1003 * Information that only applies to packages (not products). 1004 */ 1005 @Child(name = "package", type = {}, order=4, min=0, max=1, modifier=false, summary=false) 1006 @Description(shortDefinition="Details about packaged medications", formalDefinition="Information that only applies to packages (not products)." ) 1007 protected MedicationPackageComponent package_; 1008 1009 private static final long serialVersionUID = 859308699L; 1010 1011 /* 1012 * Constructor 1013 */ 1014 public Medication() { 1015 super(); 1016 } 1017 1018 /** 1019 * @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.) 1020 */ 1021 public CodeableConcept getCode() { 1022 if (this.code == null) 1023 if (Configuration.errorOnAutoCreate()) 1024 throw new Error("Attempt to auto-create Medication.code"); 1025 else if (Configuration.doAutoCreate()) 1026 this.code = new CodeableConcept(); // cc 1027 return this.code; 1028 } 1029 1030 public boolean hasCode() { 1031 return this.code != null && !this.code.isEmpty(); 1032 } 1033 1034 /** 1035 * @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.) 1036 */ 1037 public Medication setCode(CodeableConcept value) { 1038 this.code = value; 1039 return this; 1040 } 1041 1042 /** 1043 * @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 1044 */ 1045 public BooleanType getIsBrandElement() { 1046 if (this.isBrand == null) 1047 if (Configuration.errorOnAutoCreate()) 1048 throw new Error("Attempt to auto-create Medication.isBrand"); 1049 else if (Configuration.doAutoCreate()) 1050 this.isBrand = new BooleanType(); // bb 1051 return this.isBrand; 1052 } 1053 1054 public boolean hasIsBrandElement() { 1055 return this.isBrand != null && !this.isBrand.isEmpty(); 1056 } 1057 1058 public boolean hasIsBrand() { 1059 return this.isBrand != null && !this.isBrand.isEmpty(); 1060 } 1061 1062 /** 1063 * @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 1064 */ 1065 public Medication setIsBrandElement(BooleanType value) { 1066 this.isBrand = value; 1067 return this; 1068 } 1069 1070 /** 1071 * @return Set to true if the item is attributable to a specific manufacturer. 1072 */ 1073 public boolean getIsBrand() { 1074 return this.isBrand == null || this.isBrand.isEmpty() ? false : this.isBrand.getValue(); 1075 } 1076 1077 /** 1078 * @param value Set to true if the item is attributable to a specific manufacturer. 1079 */ 1080 public Medication setIsBrand(boolean value) { 1081 if (this.isBrand == null) 1082 this.isBrand = new BooleanType(); 1083 this.isBrand.setValue(value); 1084 return this; 1085 } 1086 1087 /** 1088 * @return {@link #manufacturer} (Describes the details of the manufacturer.) 1089 */ 1090 public Reference getManufacturer() { 1091 if (this.manufacturer == null) 1092 if (Configuration.errorOnAutoCreate()) 1093 throw new Error("Attempt to auto-create Medication.manufacturer"); 1094 else if (Configuration.doAutoCreate()) 1095 this.manufacturer = new Reference(); // cc 1096 return this.manufacturer; 1097 } 1098 1099 public boolean hasManufacturer() { 1100 return this.manufacturer != null && !this.manufacturer.isEmpty(); 1101 } 1102 1103 /** 1104 * @param value {@link #manufacturer} (Describes the details of the manufacturer.) 1105 */ 1106 public Medication setManufacturer(Reference value) { 1107 this.manufacturer = value; 1108 return this; 1109 } 1110 1111 /** 1112 * @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.) 1113 */ 1114 public Organization getManufacturerTarget() { 1115 if (this.manufacturerTarget == null) 1116 if (Configuration.errorOnAutoCreate()) 1117 throw new Error("Attempt to auto-create Medication.manufacturer"); 1118 else if (Configuration.doAutoCreate()) 1119 this.manufacturerTarget = new Organization(); // aa 1120 return this.manufacturerTarget; 1121 } 1122 1123 /** 1124 * @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.) 1125 */ 1126 public Medication setManufacturerTarget(Organization value) { 1127 this.manufacturerTarget = value; 1128 return this; 1129 } 1130 1131 /** 1132 * @return {@link #product} (Information that only applies to products (not packages).) 1133 */ 1134 public MedicationProductComponent getProduct() { 1135 if (this.product == null) 1136 if (Configuration.errorOnAutoCreate()) 1137 throw new Error("Attempt to auto-create Medication.product"); 1138 else if (Configuration.doAutoCreate()) 1139 this.product = new MedicationProductComponent(); // cc 1140 return this.product; 1141 } 1142 1143 public boolean hasProduct() { 1144 return this.product != null && !this.product.isEmpty(); 1145 } 1146 1147 /** 1148 * @param value {@link #product} (Information that only applies to products (not packages).) 1149 */ 1150 public Medication setProduct(MedicationProductComponent value) { 1151 this.product = value; 1152 return this; 1153 } 1154 1155 /** 1156 * @return {@link #package_} (Information that only applies to packages (not products).) 1157 */ 1158 public MedicationPackageComponent getPackage() { 1159 if (this.package_ == null) 1160 if (Configuration.errorOnAutoCreate()) 1161 throw new Error("Attempt to auto-create Medication.package_"); 1162 else if (Configuration.doAutoCreate()) 1163 this.package_ = new MedicationPackageComponent(); // cc 1164 return this.package_; 1165 } 1166 1167 public boolean hasPackage() { 1168 return this.package_ != null && !this.package_.isEmpty(); 1169 } 1170 1171 /** 1172 * @param value {@link #package_} (Information that only applies to packages (not products).) 1173 */ 1174 public Medication setPackage(MedicationPackageComponent value) { 1175 this.package_ = value; 1176 return this; 1177 } 1178 1179 protected void listChildren(List<Property> childrenList) { 1180 super.listChildren(childrenList); 1181 childrenList.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, java.lang.Integer.MAX_VALUE, code)); 1182 childrenList.add(new Property("isBrand", "boolean", "Set to true if the item is attributable to a specific manufacturer.", 0, java.lang.Integer.MAX_VALUE, isBrand)); 1183 childrenList.add(new Property("manufacturer", "Reference(Organization)", "Describes the details of the manufacturer.", 0, java.lang.Integer.MAX_VALUE, manufacturer)); 1184 childrenList.add(new Property("product", "", "Information that only applies to products (not packages).", 0, java.lang.Integer.MAX_VALUE, product)); 1185 childrenList.add(new Property("package", "", "Information that only applies to packages (not products).", 0, java.lang.Integer.MAX_VALUE, package_)); 1186 } 1187 1188 @Override 1189 public void setProperty(String name, Base value) throws FHIRException { 1190 if (name.equals("code")) 1191 this.code = castToCodeableConcept(value); // CodeableConcept 1192 else if (name.equals("isBrand")) 1193 this.isBrand = castToBoolean(value); // BooleanType 1194 else if (name.equals("manufacturer")) 1195 this.manufacturer = castToReference(value); // Reference 1196 else if (name.equals("product")) 1197 this.product = (MedicationProductComponent) value; // MedicationProductComponent 1198 else if (name.equals("package")) 1199 this.package_ = (MedicationPackageComponent) value; // MedicationPackageComponent 1200 else 1201 super.setProperty(name, value); 1202 } 1203 1204 @Override 1205 public Base addChild(String name) throws FHIRException { 1206 if (name.equals("code")) { 1207 this.code = new CodeableConcept(); 1208 return this.code; 1209 } 1210 else if (name.equals("isBrand")) { 1211 throw new FHIRException("Cannot call addChild on a primitive type Medication.isBrand"); 1212 } 1213 else if (name.equals("manufacturer")) { 1214 this.manufacturer = new Reference(); 1215 return this.manufacturer; 1216 } 1217 else if (name.equals("product")) { 1218 this.product = new MedicationProductComponent(); 1219 return this.product; 1220 } 1221 else if (name.equals("package")) { 1222 this.package_ = new MedicationPackageComponent(); 1223 return this.package_; 1224 } 1225 else 1226 return super.addChild(name); 1227 } 1228 1229 public String fhirType() { 1230 return "Medication"; 1231 1232 } 1233 1234 public Medication copy() { 1235 Medication dst = new Medication(); 1236 copyValues(dst); 1237 dst.code = code == null ? null : code.copy(); 1238 dst.isBrand = isBrand == null ? null : isBrand.copy(); 1239 dst.manufacturer = manufacturer == null ? null : manufacturer.copy(); 1240 dst.product = product == null ? null : product.copy(); 1241 dst.package_ = package_ == null ? null : package_.copy(); 1242 return dst; 1243 } 1244 1245 protected Medication typedCopy() { 1246 return copy(); 1247 } 1248 1249 @Override 1250 public boolean equalsDeep(Base other) { 1251 if (!super.equalsDeep(other)) 1252 return false; 1253 if (!(other instanceof Medication)) 1254 return false; 1255 Medication o = (Medication) other; 1256 return compareDeep(code, o.code, true) && compareDeep(isBrand, o.isBrand, true) && compareDeep(manufacturer, o.manufacturer, true) 1257 && compareDeep(product, o.product, true) && compareDeep(package_, o.package_, true); 1258 } 1259 1260 @Override 1261 public boolean equalsShallow(Base other) { 1262 if (!super.equalsShallow(other)) 1263 return false; 1264 if (!(other instanceof Medication)) 1265 return false; 1266 Medication o = (Medication) other; 1267 return compareValues(isBrand, o.isBrand, true); 1268 } 1269 1270 public boolean isEmpty() { 1271 return super.isEmpty() && (code == null || code.isEmpty()) && (isBrand == null || isBrand.isEmpty()) 1272 && (manufacturer == null || manufacturer.isEmpty()) && (product == null || product.isEmpty()) 1273 && (package_ == null || package_.isEmpty()); 1274 } 1275 1276 @Override 1277 public ResourceType getResourceType() { 1278 return ResourceType.Medication; 1279 } 1280 1281 @SearchParamDefinition(name="container", path="Medication.package.container", description="E.g. box, vial, blister-pack", type="token" ) 1282 public static final String SP_CONTAINER = "container"; 1283 @SearchParamDefinition(name="code", path="Medication.code", description="Codes that identify this medication", type="token" ) 1284 public static final String SP_CODE = "code"; 1285 @SearchParamDefinition(name="ingredient", path="Medication.product.ingredient.item", description="The product contained", type="reference" ) 1286 public static final String SP_INGREDIENT = "ingredient"; 1287 @SearchParamDefinition(name="form", path="Medication.product.form", description="powder | tablets | carton +", type="token" ) 1288 public static final String SP_FORM = "form"; 1289 @SearchParamDefinition(name="content", path="Medication.package.content.item", description="A product in the package", type="reference" ) 1290 public static final String SP_CONTENT = "content"; 1291 @SearchParamDefinition(name="manufacturer", path="Medication.manufacturer", description="Manufacturer of the item", type="reference" ) 1292 public static final String SP_MANUFACTURER = "manufacturer"; 1293 1294} 1295