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