001package org.hl7.fhir.dstu2016may.model; 002 003 004 005 006/* 007 Copyright (c) 2011+, HL7, Inc. 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without modification, 011 are permitted provided that the following conditions are met: 012 013 * Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 * Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 * Neither the name of HL7 nor the names of its contributors may be used to 019 endorse or promote products derived from this software without specific 020 prior written permission. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 025 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 026 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 028 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 029 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 030 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 031 POSSIBILITY OF SUCH DAMAGE. 032 033*/ 034 035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0 036import java.util.ArrayList; 037import java.util.Date; 038import java.util.List; 039 040import org.hl7.fhir.exceptions.FHIRException; 041import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 042import org.hl7.fhir.utilities.Utilities; 043 044import ca.uhn.fhir.model.api.annotation.Block; 045import ca.uhn.fhir.model.api.annotation.Child; 046import ca.uhn.fhir.model.api.annotation.Description; 047import ca.uhn.fhir.model.api.annotation.ResourceDef; 048import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 049/** 050 * A homogeneous material with a definite composition. 051 */ 052@ResourceDef(name="Substance", profile="http://hl7.org/fhir/Profile/Substance") 053public class Substance extends DomainResource { 054 055 @Block() 056 public static class SubstanceInstanceComponent extends BackboneElement implements IBaseBackboneElement { 057 /** 058 * Identifier associated with the package/container (usually a label affixed directly). 059 */ 060 @Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true) 061 @Description(shortDefinition="Identifier of the package/container", formalDefinition="Identifier associated with the package/container (usually a label affixed directly)." ) 062 protected Identifier identifier; 063 064 /** 065 * When the substance is no longer valid to use. For some substances, a single arbitrary date is used for expiry. 066 */ 067 @Child(name = "expiry", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=true) 068 @Description(shortDefinition="When no longer valid to use", formalDefinition="When the substance is no longer valid to use. For some substances, a single arbitrary date is used for expiry." ) 069 protected DateTimeType expiry; 070 071 /** 072 * The amount of the substance. 073 */ 074 @Child(name = "quantity", type = {SimpleQuantity.class}, order=3, min=0, max=1, modifier=false, summary=true) 075 @Description(shortDefinition="Amount of substance in the package", formalDefinition="The amount of the substance." ) 076 protected SimpleQuantity quantity; 077 078 private static final long serialVersionUID = -794314734L; 079 080 /** 081 * Constructor 082 */ 083 public SubstanceInstanceComponent() { 084 super(); 085 } 086 087 /** 088 * @return {@link #identifier} (Identifier associated with the package/container (usually a label affixed directly).) 089 */ 090 public Identifier getIdentifier() { 091 if (this.identifier == null) 092 if (Configuration.errorOnAutoCreate()) 093 throw new Error("Attempt to auto-create SubstanceInstanceComponent.identifier"); 094 else if (Configuration.doAutoCreate()) 095 this.identifier = new Identifier(); // cc 096 return this.identifier; 097 } 098 099 public boolean hasIdentifier() { 100 return this.identifier != null && !this.identifier.isEmpty(); 101 } 102 103 /** 104 * @param value {@link #identifier} (Identifier associated with the package/container (usually a label affixed directly).) 105 */ 106 public SubstanceInstanceComponent setIdentifier(Identifier value) { 107 this.identifier = value; 108 return this; 109 } 110 111 /** 112 * @return {@link #expiry} (When the substance is no longer valid to use. For some substances, a single arbitrary date is used for expiry.). This is the underlying object with id, value and extensions. The accessor "getExpiry" gives direct access to the value 113 */ 114 public DateTimeType getExpiryElement() { 115 if (this.expiry == null) 116 if (Configuration.errorOnAutoCreate()) 117 throw new Error("Attempt to auto-create SubstanceInstanceComponent.expiry"); 118 else if (Configuration.doAutoCreate()) 119 this.expiry = new DateTimeType(); // bb 120 return this.expiry; 121 } 122 123 public boolean hasExpiryElement() { 124 return this.expiry != null && !this.expiry.isEmpty(); 125 } 126 127 public boolean hasExpiry() { 128 return this.expiry != null && !this.expiry.isEmpty(); 129 } 130 131 /** 132 * @param value {@link #expiry} (When the substance is no longer valid to use. For some substances, a single arbitrary date is used for expiry.). This is the underlying object with id, value and extensions. The accessor "getExpiry" gives direct access to the value 133 */ 134 public SubstanceInstanceComponent setExpiryElement(DateTimeType value) { 135 this.expiry = value; 136 return this; 137 } 138 139 /** 140 * @return When the substance is no longer valid to use. For some substances, a single arbitrary date is used for expiry. 141 */ 142 public Date getExpiry() { 143 return this.expiry == null ? null : this.expiry.getValue(); 144 } 145 146 /** 147 * @param value When the substance is no longer valid to use. For some substances, a single arbitrary date is used for expiry. 148 */ 149 public SubstanceInstanceComponent setExpiry(Date value) { 150 if (value == null) 151 this.expiry = null; 152 else { 153 if (this.expiry == null) 154 this.expiry = new DateTimeType(); 155 this.expiry.setValue(value); 156 } 157 return this; 158 } 159 160 /** 161 * @return {@link #quantity} (The amount of the substance.) 162 */ 163 public SimpleQuantity getQuantity() { 164 if (this.quantity == null) 165 if (Configuration.errorOnAutoCreate()) 166 throw new Error("Attempt to auto-create SubstanceInstanceComponent.quantity"); 167 else if (Configuration.doAutoCreate()) 168 this.quantity = new SimpleQuantity(); // cc 169 return this.quantity; 170 } 171 172 public boolean hasQuantity() { 173 return this.quantity != null && !this.quantity.isEmpty(); 174 } 175 176 /** 177 * @param value {@link #quantity} (The amount of the substance.) 178 */ 179 public SubstanceInstanceComponent setQuantity(SimpleQuantity value) { 180 this.quantity = value; 181 return this; 182 } 183 184 protected void listChildren(List<Property> childrenList) { 185 super.listChildren(childrenList); 186 childrenList.add(new Property("identifier", "Identifier", "Identifier associated with the package/container (usually a label affixed directly).", 0, java.lang.Integer.MAX_VALUE, identifier)); 187 childrenList.add(new Property("expiry", "dateTime", "When the substance is no longer valid to use. For some substances, a single arbitrary date is used for expiry.", 0, java.lang.Integer.MAX_VALUE, expiry)); 188 childrenList.add(new Property("quantity", "SimpleQuantity", "The amount of the substance.", 0, java.lang.Integer.MAX_VALUE, quantity)); 189 } 190 191 @Override 192 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 193 switch (hash) { 194 case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier 195 case -1289159373: /*expiry*/ return this.expiry == null ? new Base[0] : new Base[] {this.expiry}; // DateTimeType 196 case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity 197 default: return super.getProperty(hash, name, checkValid); 198 } 199 200 } 201 202 @Override 203 public void setProperty(int hash, String name, Base value) throws FHIRException { 204 switch (hash) { 205 case -1618432855: // identifier 206 this.identifier = castToIdentifier(value); // Identifier 207 break; 208 case -1289159373: // expiry 209 this.expiry = castToDateTime(value); // DateTimeType 210 break; 211 case -1285004149: // quantity 212 this.quantity = castToSimpleQuantity(value); // SimpleQuantity 213 break; 214 default: super.setProperty(hash, name, value); 215 } 216 217 } 218 219 @Override 220 public void setProperty(String name, Base value) throws FHIRException { 221 if (name.equals("identifier")) 222 this.identifier = castToIdentifier(value); // Identifier 223 else if (name.equals("expiry")) 224 this.expiry = castToDateTime(value); // DateTimeType 225 else if (name.equals("quantity")) 226 this.quantity = castToSimpleQuantity(value); // SimpleQuantity 227 else 228 super.setProperty(name, value); 229 } 230 231 @Override 232 public Base makeProperty(int hash, String name) throws FHIRException { 233 switch (hash) { 234 case -1618432855: return getIdentifier(); // Identifier 235 case -1289159373: throw new FHIRException("Cannot make property expiry as it is not a complex type"); // DateTimeType 236 case -1285004149: return getQuantity(); // SimpleQuantity 237 default: return super.makeProperty(hash, name); 238 } 239 240 } 241 242 @Override 243 public Base addChild(String name) throws FHIRException { 244 if (name.equals("identifier")) { 245 this.identifier = new Identifier(); 246 return this.identifier; 247 } 248 else if (name.equals("expiry")) { 249 throw new FHIRException("Cannot call addChild on a primitive type Substance.expiry"); 250 } 251 else if (name.equals("quantity")) { 252 this.quantity = new SimpleQuantity(); 253 return this.quantity; 254 } 255 else 256 return super.addChild(name); 257 } 258 259 public SubstanceInstanceComponent copy() { 260 SubstanceInstanceComponent dst = new SubstanceInstanceComponent(); 261 copyValues(dst); 262 dst.identifier = identifier == null ? null : identifier.copy(); 263 dst.expiry = expiry == null ? null : expiry.copy(); 264 dst.quantity = quantity == null ? null : quantity.copy(); 265 return dst; 266 } 267 268 @Override 269 public boolean equalsDeep(Base other) { 270 if (!super.equalsDeep(other)) 271 return false; 272 if (!(other instanceof SubstanceInstanceComponent)) 273 return false; 274 SubstanceInstanceComponent o = (SubstanceInstanceComponent) other; 275 return compareDeep(identifier, o.identifier, true) && compareDeep(expiry, o.expiry, true) && compareDeep(quantity, o.quantity, true) 276 ; 277 } 278 279 @Override 280 public boolean equalsShallow(Base other) { 281 if (!super.equalsShallow(other)) 282 return false; 283 if (!(other instanceof SubstanceInstanceComponent)) 284 return false; 285 SubstanceInstanceComponent o = (SubstanceInstanceComponent) other; 286 return compareValues(expiry, o.expiry, true); 287 } 288 289 public boolean isEmpty() { 290 return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (expiry == null || expiry.isEmpty()) 291 && (quantity == null || quantity.isEmpty()); 292 } 293 294 public String fhirType() { 295 return "Substance.instance"; 296 297 } 298 299 } 300 301 @Block() 302 public static class SubstanceIngredientComponent extends BackboneElement implements IBaseBackboneElement { 303 /** 304 * The amount of the ingredient in the substance - a concentration ratio. 305 */ 306 @Child(name = "quantity", type = {Ratio.class}, order=1, min=0, max=1, modifier=false, summary=true) 307 @Description(shortDefinition="Optional amount (concentration)", formalDefinition="The amount of the ingredient in the substance - a concentration ratio." ) 308 protected Ratio quantity; 309 310 /** 311 * Another substance that is a component of this substance. 312 */ 313 @Child(name = "substance", type = {Substance.class}, order=2, min=1, max=1, modifier=false, summary=true) 314 @Description(shortDefinition="A component of the substance", formalDefinition="Another substance that is a component of this substance." ) 315 protected Reference substance; 316 317 /** 318 * The actual object that is the target of the reference (Another substance that is a component of this substance.) 319 */ 320 protected Substance substanceTarget; 321 322 private static final long serialVersionUID = -1783242034L; 323 324 /** 325 * Constructor 326 */ 327 public SubstanceIngredientComponent() { 328 super(); 329 } 330 331 /** 332 * Constructor 333 */ 334 public SubstanceIngredientComponent(Reference substance) { 335 super(); 336 this.substance = substance; 337 } 338 339 /** 340 * @return {@link #quantity} (The amount of the ingredient in the substance - a concentration ratio.) 341 */ 342 public Ratio getQuantity() { 343 if (this.quantity == null) 344 if (Configuration.errorOnAutoCreate()) 345 throw new Error("Attempt to auto-create SubstanceIngredientComponent.quantity"); 346 else if (Configuration.doAutoCreate()) 347 this.quantity = new Ratio(); // cc 348 return this.quantity; 349 } 350 351 public boolean hasQuantity() { 352 return this.quantity != null && !this.quantity.isEmpty(); 353 } 354 355 /** 356 * @param value {@link #quantity} (The amount of the ingredient in the substance - a concentration ratio.) 357 */ 358 public SubstanceIngredientComponent setQuantity(Ratio value) { 359 this.quantity = value; 360 return this; 361 } 362 363 /** 364 * @return {@link #substance} (Another substance that is a component of this substance.) 365 */ 366 public Reference getSubstance() { 367 if (this.substance == null) 368 if (Configuration.errorOnAutoCreate()) 369 throw new Error("Attempt to auto-create SubstanceIngredientComponent.substance"); 370 else if (Configuration.doAutoCreate()) 371 this.substance = new Reference(); // cc 372 return this.substance; 373 } 374 375 public boolean hasSubstance() { 376 return this.substance != null && !this.substance.isEmpty(); 377 } 378 379 /** 380 * @param value {@link #substance} (Another substance that is a component of this substance.) 381 */ 382 public SubstanceIngredientComponent setSubstance(Reference value) { 383 this.substance = value; 384 return this; 385 } 386 387 /** 388 * @return {@link #substance} 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. (Another substance that is a component of this substance.) 389 */ 390 public Substance getSubstanceTarget() { 391 if (this.substanceTarget == null) 392 if (Configuration.errorOnAutoCreate()) 393 throw new Error("Attempt to auto-create SubstanceIngredientComponent.substance"); 394 else if (Configuration.doAutoCreate()) 395 this.substanceTarget = new Substance(); // aa 396 return this.substanceTarget; 397 } 398 399 /** 400 * @param value {@link #substance} 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. (Another substance that is a component of this substance.) 401 */ 402 public SubstanceIngredientComponent setSubstanceTarget(Substance value) { 403 this.substanceTarget = value; 404 return this; 405 } 406 407 protected void listChildren(List<Property> childrenList) { 408 super.listChildren(childrenList); 409 childrenList.add(new Property("quantity", "Ratio", "The amount of the ingredient in the substance - a concentration ratio.", 0, java.lang.Integer.MAX_VALUE, quantity)); 410 childrenList.add(new Property("substance", "Reference(Substance)", "Another substance that is a component of this substance.", 0, java.lang.Integer.MAX_VALUE, substance)); 411 } 412 413 @Override 414 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 415 switch (hash) { 416 case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Ratio 417 case 530040176: /*substance*/ return this.substance == null ? new Base[0] : new Base[] {this.substance}; // Reference 418 default: return super.getProperty(hash, name, checkValid); 419 } 420 421 } 422 423 @Override 424 public void setProperty(int hash, String name, Base value) throws FHIRException { 425 switch (hash) { 426 case -1285004149: // quantity 427 this.quantity = castToRatio(value); // Ratio 428 break; 429 case 530040176: // substance 430 this.substance = castToReference(value); // Reference 431 break; 432 default: super.setProperty(hash, name, value); 433 } 434 435 } 436 437 @Override 438 public void setProperty(String name, Base value) throws FHIRException { 439 if (name.equals("quantity")) 440 this.quantity = castToRatio(value); // Ratio 441 else if (name.equals("substance")) 442 this.substance = castToReference(value); // Reference 443 else 444 super.setProperty(name, value); 445 } 446 447 @Override 448 public Base makeProperty(int hash, String name) throws FHIRException { 449 switch (hash) { 450 case -1285004149: return getQuantity(); // Ratio 451 case 530040176: return getSubstance(); // Reference 452 default: return super.makeProperty(hash, name); 453 } 454 455 } 456 457 @Override 458 public Base addChild(String name) throws FHIRException { 459 if (name.equals("quantity")) { 460 this.quantity = new Ratio(); 461 return this.quantity; 462 } 463 else if (name.equals("substance")) { 464 this.substance = new Reference(); 465 return this.substance; 466 } 467 else 468 return super.addChild(name); 469 } 470 471 public SubstanceIngredientComponent copy() { 472 SubstanceIngredientComponent dst = new SubstanceIngredientComponent(); 473 copyValues(dst); 474 dst.quantity = quantity == null ? null : quantity.copy(); 475 dst.substance = substance == null ? null : substance.copy(); 476 return dst; 477 } 478 479 @Override 480 public boolean equalsDeep(Base other) { 481 if (!super.equalsDeep(other)) 482 return false; 483 if (!(other instanceof SubstanceIngredientComponent)) 484 return false; 485 SubstanceIngredientComponent o = (SubstanceIngredientComponent) other; 486 return compareDeep(quantity, o.quantity, true) && compareDeep(substance, o.substance, true); 487 } 488 489 @Override 490 public boolean equalsShallow(Base other) { 491 if (!super.equalsShallow(other)) 492 return false; 493 if (!(other instanceof SubstanceIngredientComponent)) 494 return false; 495 SubstanceIngredientComponent o = (SubstanceIngredientComponent) other; 496 return true; 497 } 498 499 public boolean isEmpty() { 500 return super.isEmpty() && (quantity == null || quantity.isEmpty()) && (substance == null || substance.isEmpty()) 501 ; 502 } 503 504 public String fhirType() { 505 return "Substance.ingredient"; 506 507 } 508 509 } 510 511 /** 512 * Unique identifier for the substance. 513 */ 514 @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 515 @Description(shortDefinition="Unique identifier", formalDefinition="Unique identifier for the substance." ) 516 protected List<Identifier> identifier; 517 518 /** 519 * A code that classifies the general type of substance. This is used for searching, sorting and display purposes. 520 */ 521 @Child(name = "category", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 522 @Description(shortDefinition="What class/type of substance this is", formalDefinition="A code that classifies the general type of substance. This is used for searching, sorting and display purposes." ) 523 protected List<CodeableConcept> category; 524 525 /** 526 * A code (or set of codes) that identify this substance. 527 */ 528 @Child(name = "code", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true) 529 @Description(shortDefinition="What substance this is", formalDefinition="A code (or set of codes) that identify this substance." ) 530 protected CodeableConcept code; 531 532 /** 533 * A description of the substance - its appearance, handling requirements, and other usage notes. 534 */ 535 @Child(name = "description", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true) 536 @Description(shortDefinition="Textual description of the substance, comments", formalDefinition="A description of the substance - its appearance, handling requirements, and other usage notes." ) 537 protected StringType description; 538 539 /** 540 * Substance may be used to describe a kind of substance, or a specific package/container of the substance: an instance. 541 */ 542 @Child(name = "instance", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 543 @Description(shortDefinition="If this describes a specific package/container of the substance", formalDefinition="Substance may be used to describe a kind of substance, or a specific package/container of the substance: an instance." ) 544 protected List<SubstanceInstanceComponent> instance; 545 546 /** 547 * A substance can be composed of other substances. 548 */ 549 @Child(name = "ingredient", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 550 @Description(shortDefinition="Composition information about the substance", formalDefinition="A substance can be composed of other substances." ) 551 protected List<SubstanceIngredientComponent> ingredient; 552 553 private static final long serialVersionUID = -1653977206L; 554 555 /** 556 * Constructor 557 */ 558 public Substance() { 559 super(); 560 } 561 562 /** 563 * Constructor 564 */ 565 public Substance(CodeableConcept code) { 566 super(); 567 this.code = code; 568 } 569 570 /** 571 * @return {@link #identifier} (Unique identifier for the substance.) 572 */ 573 public List<Identifier> getIdentifier() { 574 if (this.identifier == null) 575 this.identifier = new ArrayList<Identifier>(); 576 return this.identifier; 577 } 578 579 public boolean hasIdentifier() { 580 if (this.identifier == null) 581 return false; 582 for (Identifier item : this.identifier) 583 if (!item.isEmpty()) 584 return true; 585 return false; 586 } 587 588 /** 589 * @return {@link #identifier} (Unique identifier for the substance.) 590 */ 591 // syntactic sugar 592 public Identifier addIdentifier() { //3 593 Identifier t = new Identifier(); 594 if (this.identifier == null) 595 this.identifier = new ArrayList<Identifier>(); 596 this.identifier.add(t); 597 return t; 598 } 599 600 // syntactic sugar 601 public Substance addIdentifier(Identifier t) { //3 602 if (t == null) 603 return this; 604 if (this.identifier == null) 605 this.identifier = new ArrayList<Identifier>(); 606 this.identifier.add(t); 607 return this; 608 } 609 610 /** 611 * @return {@link #category} (A code that classifies the general type of substance. This is used for searching, sorting and display purposes.) 612 */ 613 public List<CodeableConcept> getCategory() { 614 if (this.category == null) 615 this.category = new ArrayList<CodeableConcept>(); 616 return this.category; 617 } 618 619 public boolean hasCategory() { 620 if (this.category == null) 621 return false; 622 for (CodeableConcept item : this.category) 623 if (!item.isEmpty()) 624 return true; 625 return false; 626 } 627 628 /** 629 * @return {@link #category} (A code that classifies the general type of substance. This is used for searching, sorting and display purposes.) 630 */ 631 // syntactic sugar 632 public CodeableConcept addCategory() { //3 633 CodeableConcept t = new CodeableConcept(); 634 if (this.category == null) 635 this.category = new ArrayList<CodeableConcept>(); 636 this.category.add(t); 637 return t; 638 } 639 640 // syntactic sugar 641 public Substance addCategory(CodeableConcept t) { //3 642 if (t == null) 643 return this; 644 if (this.category == null) 645 this.category = new ArrayList<CodeableConcept>(); 646 this.category.add(t); 647 return this; 648 } 649 650 /** 651 * @return {@link #code} (A code (or set of codes) that identify this substance.) 652 */ 653 public CodeableConcept getCode() { 654 if (this.code == null) 655 if (Configuration.errorOnAutoCreate()) 656 throw new Error("Attempt to auto-create Substance.code"); 657 else if (Configuration.doAutoCreate()) 658 this.code = new CodeableConcept(); // cc 659 return this.code; 660 } 661 662 public boolean hasCode() { 663 return this.code != null && !this.code.isEmpty(); 664 } 665 666 /** 667 * @param value {@link #code} (A code (or set of codes) that identify this substance.) 668 */ 669 public Substance setCode(CodeableConcept value) { 670 this.code = value; 671 return this; 672 } 673 674 /** 675 * @return {@link #description} (A description of the substance - its appearance, handling requirements, and other usage notes.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value 676 */ 677 public StringType getDescriptionElement() { 678 if (this.description == null) 679 if (Configuration.errorOnAutoCreate()) 680 throw new Error("Attempt to auto-create Substance.description"); 681 else if (Configuration.doAutoCreate()) 682 this.description = new StringType(); // bb 683 return this.description; 684 } 685 686 public boolean hasDescriptionElement() { 687 return this.description != null && !this.description.isEmpty(); 688 } 689 690 public boolean hasDescription() { 691 return this.description != null && !this.description.isEmpty(); 692 } 693 694 /** 695 * @param value {@link #description} (A description of the substance - its appearance, handling requirements, and other usage notes.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value 696 */ 697 public Substance setDescriptionElement(StringType value) { 698 this.description = value; 699 return this; 700 } 701 702 /** 703 * @return A description of the substance - its appearance, handling requirements, and other usage notes. 704 */ 705 public String getDescription() { 706 return this.description == null ? null : this.description.getValue(); 707 } 708 709 /** 710 * @param value A description of the substance - its appearance, handling requirements, and other usage notes. 711 */ 712 public Substance setDescription(String value) { 713 if (Utilities.noString(value)) 714 this.description = null; 715 else { 716 if (this.description == null) 717 this.description = new StringType(); 718 this.description.setValue(value); 719 } 720 return this; 721 } 722 723 /** 724 * @return {@link #instance} (Substance may be used to describe a kind of substance, or a specific package/container of the substance: an instance.) 725 */ 726 public List<SubstanceInstanceComponent> getInstance() { 727 if (this.instance == null) 728 this.instance = new ArrayList<SubstanceInstanceComponent>(); 729 return this.instance; 730 } 731 732 public boolean hasInstance() { 733 if (this.instance == null) 734 return false; 735 for (SubstanceInstanceComponent item : this.instance) 736 if (!item.isEmpty()) 737 return true; 738 return false; 739 } 740 741 /** 742 * @return {@link #instance} (Substance may be used to describe a kind of substance, or a specific package/container of the substance: an instance.) 743 */ 744 // syntactic sugar 745 public SubstanceInstanceComponent addInstance() { //3 746 SubstanceInstanceComponent t = new SubstanceInstanceComponent(); 747 if (this.instance == null) 748 this.instance = new ArrayList<SubstanceInstanceComponent>(); 749 this.instance.add(t); 750 return t; 751 } 752 753 // syntactic sugar 754 public Substance addInstance(SubstanceInstanceComponent t) { //3 755 if (t == null) 756 return this; 757 if (this.instance == null) 758 this.instance = new ArrayList<SubstanceInstanceComponent>(); 759 this.instance.add(t); 760 return this; 761 } 762 763 /** 764 * @return {@link #ingredient} (A substance can be composed of other substances.) 765 */ 766 public List<SubstanceIngredientComponent> getIngredient() { 767 if (this.ingredient == null) 768 this.ingredient = new ArrayList<SubstanceIngredientComponent>(); 769 return this.ingredient; 770 } 771 772 public boolean hasIngredient() { 773 if (this.ingredient == null) 774 return false; 775 for (SubstanceIngredientComponent item : this.ingredient) 776 if (!item.isEmpty()) 777 return true; 778 return false; 779 } 780 781 /** 782 * @return {@link #ingredient} (A substance can be composed of other substances.) 783 */ 784 // syntactic sugar 785 public SubstanceIngredientComponent addIngredient() { //3 786 SubstanceIngredientComponent t = new SubstanceIngredientComponent(); 787 if (this.ingredient == null) 788 this.ingredient = new ArrayList<SubstanceIngredientComponent>(); 789 this.ingredient.add(t); 790 return t; 791 } 792 793 // syntactic sugar 794 public Substance addIngredient(SubstanceIngredientComponent t) { //3 795 if (t == null) 796 return this; 797 if (this.ingredient == null) 798 this.ingredient = new ArrayList<SubstanceIngredientComponent>(); 799 this.ingredient.add(t); 800 return this; 801 } 802 803 protected void listChildren(List<Property> childrenList) { 804 super.listChildren(childrenList); 805 childrenList.add(new Property("identifier", "Identifier", "Unique identifier for the substance.", 0, java.lang.Integer.MAX_VALUE, identifier)); 806 childrenList.add(new Property("category", "CodeableConcept", "A code that classifies the general type of substance. This is used for searching, sorting and display purposes.", 0, java.lang.Integer.MAX_VALUE, category)); 807 childrenList.add(new Property("code", "CodeableConcept", "A code (or set of codes) that identify this substance.", 0, java.lang.Integer.MAX_VALUE, code)); 808 childrenList.add(new Property("description", "string", "A description of the substance - its appearance, handling requirements, and other usage notes.", 0, java.lang.Integer.MAX_VALUE, description)); 809 childrenList.add(new Property("instance", "", "Substance may be used to describe a kind of substance, or a specific package/container of the substance: an instance.", 0, java.lang.Integer.MAX_VALUE, instance)); 810 childrenList.add(new Property("ingredient", "", "A substance can be composed of other substances.", 0, java.lang.Integer.MAX_VALUE, ingredient)); 811 } 812 813 @Override 814 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 815 switch (hash) { 816 case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier 817 case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept 818 case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept 819 case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType 820 case 555127957: /*instance*/ return this.instance == null ? new Base[0] : this.instance.toArray(new Base[this.instance.size()]); // SubstanceInstanceComponent 821 case -206409263: /*ingredient*/ return this.ingredient == null ? new Base[0] : this.ingredient.toArray(new Base[this.ingredient.size()]); // SubstanceIngredientComponent 822 default: return super.getProperty(hash, name, checkValid); 823 } 824 825 } 826 827 @Override 828 public void setProperty(int hash, String name, Base value) throws FHIRException { 829 switch (hash) { 830 case -1618432855: // identifier 831 this.getIdentifier().add(castToIdentifier(value)); // Identifier 832 break; 833 case 50511102: // category 834 this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept 835 break; 836 case 3059181: // code 837 this.code = castToCodeableConcept(value); // CodeableConcept 838 break; 839 case -1724546052: // description 840 this.description = castToString(value); // StringType 841 break; 842 case 555127957: // instance 843 this.getInstance().add((SubstanceInstanceComponent) value); // SubstanceInstanceComponent 844 break; 845 case -206409263: // ingredient 846 this.getIngredient().add((SubstanceIngredientComponent) value); // SubstanceIngredientComponent 847 break; 848 default: super.setProperty(hash, name, value); 849 } 850 851 } 852 853 @Override 854 public void setProperty(String name, Base value) throws FHIRException { 855 if (name.equals("identifier")) 856 this.getIdentifier().add(castToIdentifier(value)); 857 else if (name.equals("category")) 858 this.getCategory().add(castToCodeableConcept(value)); 859 else if (name.equals("code")) 860 this.code = castToCodeableConcept(value); // CodeableConcept 861 else if (name.equals("description")) 862 this.description = castToString(value); // StringType 863 else if (name.equals("instance")) 864 this.getInstance().add((SubstanceInstanceComponent) value); 865 else if (name.equals("ingredient")) 866 this.getIngredient().add((SubstanceIngredientComponent) value); 867 else 868 super.setProperty(name, value); 869 } 870 871 @Override 872 public Base makeProperty(int hash, String name) throws FHIRException { 873 switch (hash) { 874 case -1618432855: return addIdentifier(); // Identifier 875 case 50511102: return addCategory(); // CodeableConcept 876 case 3059181: return getCode(); // CodeableConcept 877 case -1724546052: throw new FHIRException("Cannot make property description as it is not a complex type"); // StringType 878 case 555127957: return addInstance(); // SubstanceInstanceComponent 879 case -206409263: return addIngredient(); // SubstanceIngredientComponent 880 default: return super.makeProperty(hash, name); 881 } 882 883 } 884 885 @Override 886 public Base addChild(String name) throws FHIRException { 887 if (name.equals("identifier")) { 888 return addIdentifier(); 889 } 890 else if (name.equals("category")) { 891 return addCategory(); 892 } 893 else if (name.equals("code")) { 894 this.code = new CodeableConcept(); 895 return this.code; 896 } 897 else if (name.equals("description")) { 898 throw new FHIRException("Cannot call addChild on a primitive type Substance.description"); 899 } 900 else if (name.equals("instance")) { 901 return addInstance(); 902 } 903 else if (name.equals("ingredient")) { 904 return addIngredient(); 905 } 906 else 907 return super.addChild(name); 908 } 909 910 public String fhirType() { 911 return "Substance"; 912 913 } 914 915 public Substance copy() { 916 Substance dst = new Substance(); 917 copyValues(dst); 918 if (identifier != null) { 919 dst.identifier = new ArrayList<Identifier>(); 920 for (Identifier i : identifier) 921 dst.identifier.add(i.copy()); 922 }; 923 if (category != null) { 924 dst.category = new ArrayList<CodeableConcept>(); 925 for (CodeableConcept i : category) 926 dst.category.add(i.copy()); 927 }; 928 dst.code = code == null ? null : code.copy(); 929 dst.description = description == null ? null : description.copy(); 930 if (instance != null) { 931 dst.instance = new ArrayList<SubstanceInstanceComponent>(); 932 for (SubstanceInstanceComponent i : instance) 933 dst.instance.add(i.copy()); 934 }; 935 if (ingredient != null) { 936 dst.ingredient = new ArrayList<SubstanceIngredientComponent>(); 937 for (SubstanceIngredientComponent i : ingredient) 938 dst.ingredient.add(i.copy()); 939 }; 940 return dst; 941 } 942 943 protected Substance typedCopy() { 944 return copy(); 945 } 946 947 @Override 948 public boolean equalsDeep(Base other) { 949 if (!super.equalsDeep(other)) 950 return false; 951 if (!(other instanceof Substance)) 952 return false; 953 Substance o = (Substance) other; 954 return compareDeep(identifier, o.identifier, true) && compareDeep(category, o.category, true) && compareDeep(code, o.code, true) 955 && compareDeep(description, o.description, true) && compareDeep(instance, o.instance, true) && compareDeep(ingredient, o.ingredient, true) 956 ; 957 } 958 959 @Override 960 public boolean equalsShallow(Base other) { 961 if (!super.equalsShallow(other)) 962 return false; 963 if (!(other instanceof Substance)) 964 return false; 965 Substance o = (Substance) other; 966 return compareValues(description, o.description, true); 967 } 968 969 public boolean isEmpty() { 970 return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (category == null || category.isEmpty()) 971 && (code == null || code.isEmpty()) && (description == null || description.isEmpty()) && (instance == null || instance.isEmpty()) 972 && (ingredient == null || ingredient.isEmpty()); 973 } 974 975 @Override 976 public ResourceType getResourceType() { 977 return ResourceType.Substance; 978 } 979 980 /** 981 * Search parameter: <b>substance</b> 982 * <p> 983 * Description: <b>A component of the substance</b><br> 984 * Type: <b>reference</b><br> 985 * Path: <b>Substance.ingredient.substance</b><br> 986 * </p> 987 */ 988 @SearchParamDefinition(name="substance", path="Substance.ingredient.substance", description="A component of the substance", type="reference" ) 989 public static final String SP_SUBSTANCE = "substance"; 990 /** 991 * <b>Fluent Client</b> search parameter constant for <b>substance</b> 992 * <p> 993 * Description: <b>A component of the substance</b><br> 994 * Type: <b>reference</b><br> 995 * Path: <b>Substance.ingredient.substance</b><br> 996 * </p> 997 */ 998 public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBSTANCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBSTANCE); 999 1000/** 1001 * Constant for fluent queries to be used to add include statements. Specifies 1002 * the path value of "<b>Substance:substance</b>". 1003 */ 1004 public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBSTANCE = new ca.uhn.fhir.model.api.Include("Substance:substance").toLocked(); 1005 1006 /** 1007 * Search parameter: <b>container-identifier</b> 1008 * <p> 1009 * Description: <b>Identifier of the package/container</b><br> 1010 * Type: <b>token</b><br> 1011 * Path: <b>Substance.instance.identifier</b><br> 1012 * </p> 1013 */ 1014 @SearchParamDefinition(name="container-identifier", path="Substance.instance.identifier", description="Identifier of the package/container", type="token" ) 1015 public static final String SP_CONTAINER_IDENTIFIER = "container-identifier"; 1016 /** 1017 * <b>Fluent Client</b> search parameter constant for <b>container-identifier</b> 1018 * <p> 1019 * Description: <b>Identifier of the package/container</b><br> 1020 * Type: <b>token</b><br> 1021 * Path: <b>Substance.instance.identifier</b><br> 1022 * </p> 1023 */ 1024 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTAINER_IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTAINER_IDENTIFIER); 1025 1026 /** 1027 * Search parameter: <b>category</b> 1028 * <p> 1029 * Description: <b>The category of the substance</b><br> 1030 * Type: <b>token</b><br> 1031 * Path: <b>Substance.category</b><br> 1032 * </p> 1033 */ 1034 @SearchParamDefinition(name="category", path="Substance.category", description="The category of the substance", type="token" ) 1035 public static final String SP_CATEGORY = "category"; 1036 /** 1037 * <b>Fluent Client</b> search parameter constant for <b>category</b> 1038 * <p> 1039 * Description: <b>The category of the substance</b><br> 1040 * Type: <b>token</b><br> 1041 * Path: <b>Substance.category</b><br> 1042 * </p> 1043 */ 1044 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY); 1045 1046 /** 1047 * Search parameter: <b>quantity</b> 1048 * <p> 1049 * Description: <b>Amount of substance in the package</b><br> 1050 * Type: <b>quantity</b><br> 1051 * Path: <b>Substance.instance.quantity</b><br> 1052 * </p> 1053 */ 1054 @SearchParamDefinition(name="quantity", path="Substance.instance.quantity", description="Amount of substance in the package", type="quantity" ) 1055 public static final String SP_QUANTITY = "quantity"; 1056 /** 1057 * <b>Fluent Client</b> search parameter constant for <b>quantity</b> 1058 * <p> 1059 * Description: <b>Amount of substance in the package</b><br> 1060 * Type: <b>quantity</b><br> 1061 * Path: <b>Substance.instance.quantity</b><br> 1062 * </p> 1063 */ 1064 public static final ca.uhn.fhir.rest.gclient.QuantityClientParam QUANTITY = new ca.uhn.fhir.rest.gclient.QuantityClientParam(SP_QUANTITY); 1065 1066 /** 1067 * Search parameter: <b>code</b> 1068 * <p> 1069 * Description: <b>The code of the substance</b><br> 1070 * Type: <b>token</b><br> 1071 * Path: <b>Substance.code</b><br> 1072 * </p> 1073 */ 1074 @SearchParamDefinition(name="code", path="Substance.code", description="The code of the substance", type="token" ) 1075 public static final String SP_CODE = "code"; 1076 /** 1077 * <b>Fluent Client</b> search parameter constant for <b>code</b> 1078 * <p> 1079 * Description: <b>The code of the substance</b><br> 1080 * Type: <b>token</b><br> 1081 * Path: <b>Substance.code</b><br> 1082 * </p> 1083 */ 1084 public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE); 1085 1086 /** 1087 * Search parameter: <b>identifier</b> 1088 * <p> 1089 * Description: <b>Unique identifier for the substance</b><br> 1090 * Type: <b>token</b><br> 1091 * Path: <b>Substance.identifier</b><br> 1092 * </p> 1093 */ 1094 @SearchParamDefinition(name="identifier", path="Substance.identifier", description="Unique identifier for the substance", type="token" ) 1095 public static final String SP_IDENTIFIER = "identifier"; 1096 /** 1097 * <b>Fluent Client</b> search parameter constant for <b>identifier</b> 1098 * <p> 1099 * Description: <b>Unique identifier for the substance</b><br> 1100 * Type: <b>token</b><br> 1101 * Path: <b>Substance.identifier</b><br> 1102 * </p> 1103 */ 1104 public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER); 1105 1106 /** 1107 * Search parameter: <b>expiry</b> 1108 * <p> 1109 * Description: <b>Expiry date of package or container of substance</b><br> 1110 * Type: <b>date</b><br> 1111 * Path: <b>Substance.instance.expiry</b><br> 1112 * </p> 1113 */ 1114 @SearchParamDefinition(name="expiry", path="Substance.instance.expiry", description="Expiry date of package or container of substance", type="date" ) 1115 public static final String SP_EXPIRY = "expiry"; 1116 /** 1117 * <b>Fluent Client</b> search parameter constant for <b>expiry</b> 1118 * <p> 1119 * Description: <b>Expiry date of package or container of substance</b><br> 1120 * Type: <b>date</b><br> 1121 * Path: <b>Substance.instance.expiry</b><br> 1122 * </p> 1123 */ 1124 public static final ca.uhn.fhir.rest.gclient.DateClientParam EXPIRY = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_EXPIRY); 1125 1126 1127}