001package org.hl7.fhir.r5.model; 002 003 004/* 005 Copyright (c) 2011+, HL7, Inc. 006 All rights reserved. 007 008 Redistribution and use in source and binary forms, with or without modification, \ 009 are permitted provided that the following conditions are met: 010 011 * Redistributions of source code must retain the above copyright notice, this \ 012 list of conditions and the following disclaimer. 013 * Redistributions in binary form must reproduce the above copyright notice, \ 014 this list of conditions and the following disclaimer in the documentation \ 015 and/or other materials provided with the distribution. 016 * Neither the name of HL7 nor the names of its contributors may be used to 017 endorse or promote products derived from this software without specific 018 prior written permission. 019 020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \ 021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \ 022 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \ 023 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \ 024 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \ 025 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \ 026 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \ 027 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \ 028 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \ 029 POSSIBILITY OF SUCH DAMAGE. 030 */ 031 032// Generated on Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1 033 034import java.util.ArrayList; 035import java.util.Date; 036import java.util.List; 037import org.hl7.fhir.utilities.Utilities; 038import org.hl7.fhir.r5.model.Enumerations.*; 039import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 040import org.hl7.fhir.exceptions.FHIRException; 041import org.hl7.fhir.instance.model.api.ICompositeType; 042import ca.uhn.fhir.model.api.annotation.ResourceDef; 043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition; 044import org.hl7.fhir.instance.model.api.IBaseBackboneElement; 045import ca.uhn.fhir.model.api.annotation.Child; 046import ca.uhn.fhir.model.api.annotation.ChildOrder; 047import ca.uhn.fhir.model.api.annotation.Description; 048import ca.uhn.fhir.model.api.annotation.Block; 049 050/** 051 * A food or fluid product that is consumed by patients. 052 */ 053@ResourceDef(name="NutritionProduct", profile="http://hl7.org/fhir/StructureDefinition/NutritionProduct") 054public class NutritionProduct extends DomainResource { 055 056 public enum NutritionProductStatus { 057 /** 058 * The product can be used. 059 */ 060 ACTIVE, 061 /** 062 * The product is not expected or allowed to be used. 063 */ 064 INACTIVE, 065 /** 066 * This electronic record should never have existed, though it is possible that real-world decisions were based on it. (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".). 067 */ 068 ENTEREDINERROR, 069 /** 070 * added to help the parsers with the generic types 071 */ 072 NULL; 073 public static NutritionProductStatus fromCode(String codeString) throws FHIRException { 074 if (codeString == null || "".equals(codeString)) 075 return null; 076 if ("active".equals(codeString)) 077 return ACTIVE; 078 if ("inactive".equals(codeString)) 079 return INACTIVE; 080 if ("entered-in-error".equals(codeString)) 081 return ENTEREDINERROR; 082 if (Configuration.isAcceptInvalidEnums()) 083 return null; 084 else 085 throw new FHIRException("Unknown NutritionProductStatus code '"+codeString+"'"); 086 } 087 public String toCode() { 088 switch (this) { 089 case ACTIVE: return "active"; 090 case INACTIVE: return "inactive"; 091 case ENTEREDINERROR: return "entered-in-error"; 092 default: return "?"; 093 } 094 } 095 public String getSystem() { 096 switch (this) { 097 case ACTIVE: return "http://hl7.org/fhir/nutritionproduct-status"; 098 case INACTIVE: return "http://hl7.org/fhir/nutritionproduct-status"; 099 case ENTEREDINERROR: return "http://hl7.org/fhir/nutritionproduct-status"; 100 default: return "?"; 101 } 102 } 103 public String getDefinition() { 104 switch (this) { 105 case ACTIVE: return "The product can be used."; 106 case INACTIVE: return "The product is not expected or allowed to be used."; 107 case ENTEREDINERROR: return "This electronic record should never have existed, though it is possible that real-world decisions were based on it. (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".)."; 108 default: return "?"; 109 } 110 } 111 public String getDisplay() { 112 switch (this) { 113 case ACTIVE: return "Active"; 114 case INACTIVE: return "Inactive"; 115 case ENTEREDINERROR: return "Entered in Error"; 116 default: return "?"; 117 } 118 } 119 } 120 121 public static class NutritionProductStatusEnumFactory implements EnumFactory<NutritionProductStatus> { 122 public NutritionProductStatus fromCode(String codeString) throws IllegalArgumentException { 123 if (codeString == null || "".equals(codeString)) 124 if (codeString == null || "".equals(codeString)) 125 return null; 126 if ("active".equals(codeString)) 127 return NutritionProductStatus.ACTIVE; 128 if ("inactive".equals(codeString)) 129 return NutritionProductStatus.INACTIVE; 130 if ("entered-in-error".equals(codeString)) 131 return NutritionProductStatus.ENTEREDINERROR; 132 throw new IllegalArgumentException("Unknown NutritionProductStatus code '"+codeString+"'"); 133 } 134 public Enumeration<NutritionProductStatus> fromType(Base code) throws FHIRException { 135 if (code == null) 136 return null; 137 if (code.isEmpty()) 138 return new Enumeration<NutritionProductStatus>(this); 139 String codeString = ((PrimitiveType) code).asStringValue(); 140 if (codeString == null || "".equals(codeString)) 141 return null; 142 if ("active".equals(codeString)) 143 return new Enumeration<NutritionProductStatus>(this, NutritionProductStatus.ACTIVE); 144 if ("inactive".equals(codeString)) 145 return new Enumeration<NutritionProductStatus>(this, NutritionProductStatus.INACTIVE); 146 if ("entered-in-error".equals(codeString)) 147 return new Enumeration<NutritionProductStatus>(this, NutritionProductStatus.ENTEREDINERROR); 148 throw new FHIRException("Unknown NutritionProductStatus code '"+codeString+"'"); 149 } 150 public String toCode(NutritionProductStatus code) { 151 if (code == NutritionProductStatus.ACTIVE) 152 return "active"; 153 if (code == NutritionProductStatus.INACTIVE) 154 return "inactive"; 155 if (code == NutritionProductStatus.ENTEREDINERROR) 156 return "entered-in-error"; 157 return "?"; 158 } 159 public String toSystem(NutritionProductStatus code) { 160 return code.getSystem(); 161 } 162 } 163 164 @Block() 165 public static class NutritionProductNutrientComponent extends BackboneElement implements IBaseBackboneElement { 166 /** 167 * The (relevant) nutrients in the product. 168 */ 169 @Child(name = "item", type = {CodeableReference.class}, order=1, min=0, max=1, modifier=false, summary=false) 170 @Description(shortDefinition="The (relevant) nutrients in the product", formalDefinition="The (relevant) nutrients in the product." ) 171 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/nutrition-product-nutrient") 172 protected CodeableReference item; 173 174 /** 175 * The amount of nutrient expressed in one or more units: X per pack / per serving / per dose. 176 */ 177 @Child(name = "amount", type = {Ratio.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 178 @Description(shortDefinition="The amount of nutrient expressed in one or more units: X per pack / per serving / per dose", formalDefinition="The amount of nutrient expressed in one or more units: X per pack / per serving / per dose." ) 179 protected List<Ratio> amount; 180 181 private static final long serialVersionUID = -776277304L; 182 183 /** 184 * Constructor 185 */ 186 public NutritionProductNutrientComponent() { 187 super(); 188 } 189 190 /** 191 * @return {@link #item} (The (relevant) nutrients in the product.) 192 */ 193 public CodeableReference getItem() { 194 if (this.item == null) 195 if (Configuration.errorOnAutoCreate()) 196 throw new Error("Attempt to auto-create NutritionProductNutrientComponent.item"); 197 else if (Configuration.doAutoCreate()) 198 this.item = new CodeableReference(); // cc 199 return this.item; 200 } 201 202 public boolean hasItem() { 203 return this.item != null && !this.item.isEmpty(); 204 } 205 206 /** 207 * @param value {@link #item} (The (relevant) nutrients in the product.) 208 */ 209 public NutritionProductNutrientComponent setItem(CodeableReference value) { 210 this.item = value; 211 return this; 212 } 213 214 /** 215 * @return {@link #amount} (The amount of nutrient expressed in one or more units: X per pack / per serving / per dose.) 216 */ 217 public List<Ratio> getAmount() { 218 if (this.amount == null) 219 this.amount = new ArrayList<Ratio>(); 220 return this.amount; 221 } 222 223 /** 224 * @return Returns a reference to <code>this</code> for easy method chaining 225 */ 226 public NutritionProductNutrientComponent setAmount(List<Ratio> theAmount) { 227 this.amount = theAmount; 228 return this; 229 } 230 231 public boolean hasAmount() { 232 if (this.amount == null) 233 return false; 234 for (Ratio item : this.amount) 235 if (!item.isEmpty()) 236 return true; 237 return false; 238 } 239 240 public Ratio addAmount() { //3 241 Ratio t = new Ratio(); 242 if (this.amount == null) 243 this.amount = new ArrayList<Ratio>(); 244 this.amount.add(t); 245 return t; 246 } 247 248 public NutritionProductNutrientComponent addAmount(Ratio t) { //3 249 if (t == null) 250 return this; 251 if (this.amount == null) 252 this.amount = new ArrayList<Ratio>(); 253 this.amount.add(t); 254 return this; 255 } 256 257 /** 258 * @return The first repetition of repeating field {@link #amount}, creating it if it does not already exist {3} 259 */ 260 public Ratio getAmountFirstRep() { 261 if (getAmount().isEmpty()) { 262 addAmount(); 263 } 264 return getAmount().get(0); 265 } 266 267 protected void listChildren(List<Property> children) { 268 super.listChildren(children); 269 children.add(new Property("item", "CodeableReference(Substance)", "The (relevant) nutrients in the product.", 0, 1, item)); 270 children.add(new Property("amount", "Ratio", "The amount of nutrient expressed in one or more units: X per pack / per serving / per dose.", 0, java.lang.Integer.MAX_VALUE, amount)); 271 } 272 273 @Override 274 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 275 switch (_hash) { 276 case 3242771: /*item*/ return new Property("item", "CodeableReference(Substance)", "The (relevant) nutrients in the product.", 0, 1, item); 277 case -1413853096: /*amount*/ return new Property("amount", "Ratio", "The amount of nutrient expressed in one or more units: X per pack / per serving / per dose.", 0, java.lang.Integer.MAX_VALUE, amount); 278 default: return super.getNamedProperty(_hash, _name, _checkValid); 279 } 280 281 } 282 283 @Override 284 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 285 switch (hash) { 286 case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // CodeableReference 287 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : this.amount.toArray(new Base[this.amount.size()]); // Ratio 288 default: return super.getProperty(hash, name, checkValid); 289 } 290 291 } 292 293 @Override 294 public Base setProperty(int hash, String name, Base value) throws FHIRException { 295 switch (hash) { 296 case 3242771: // item 297 this.item = TypeConvertor.castToCodeableReference(value); // CodeableReference 298 return value; 299 case -1413853096: // amount 300 this.getAmount().add(TypeConvertor.castToRatio(value)); // Ratio 301 return value; 302 default: return super.setProperty(hash, name, value); 303 } 304 305 } 306 307 @Override 308 public Base setProperty(String name, Base value) throws FHIRException { 309 if (name.equals("item")) { 310 this.item = TypeConvertor.castToCodeableReference(value); // CodeableReference 311 } else if (name.equals("amount")) { 312 this.getAmount().add(TypeConvertor.castToRatio(value)); 313 } else 314 return super.setProperty(name, value); 315 return value; 316 } 317 318 @Override 319 public Base makeProperty(int hash, String name) throws FHIRException { 320 switch (hash) { 321 case 3242771: return getItem(); 322 case -1413853096: return addAmount(); 323 default: return super.makeProperty(hash, name); 324 } 325 326 } 327 328 @Override 329 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 330 switch (hash) { 331 case 3242771: /*item*/ return new String[] {"CodeableReference"}; 332 case -1413853096: /*amount*/ return new String[] {"Ratio"}; 333 default: return super.getTypesForProperty(hash, name); 334 } 335 336 } 337 338 @Override 339 public Base addChild(String name) throws FHIRException { 340 if (name.equals("item")) { 341 this.item = new CodeableReference(); 342 return this.item; 343 } 344 else if (name.equals("amount")) { 345 return addAmount(); 346 } 347 else 348 return super.addChild(name); 349 } 350 351 public NutritionProductNutrientComponent copy() { 352 NutritionProductNutrientComponent dst = new NutritionProductNutrientComponent(); 353 copyValues(dst); 354 return dst; 355 } 356 357 public void copyValues(NutritionProductNutrientComponent dst) { 358 super.copyValues(dst); 359 dst.item = item == null ? null : item.copy(); 360 if (amount != null) { 361 dst.amount = new ArrayList<Ratio>(); 362 for (Ratio i : amount) 363 dst.amount.add(i.copy()); 364 }; 365 } 366 367 @Override 368 public boolean equalsDeep(Base other_) { 369 if (!super.equalsDeep(other_)) 370 return false; 371 if (!(other_ instanceof NutritionProductNutrientComponent)) 372 return false; 373 NutritionProductNutrientComponent o = (NutritionProductNutrientComponent) other_; 374 return compareDeep(item, o.item, true) && compareDeep(amount, o.amount, true); 375 } 376 377 @Override 378 public boolean equalsShallow(Base other_) { 379 if (!super.equalsShallow(other_)) 380 return false; 381 if (!(other_ instanceof NutritionProductNutrientComponent)) 382 return false; 383 NutritionProductNutrientComponent o = (NutritionProductNutrientComponent) other_; 384 return true; 385 } 386 387 public boolean isEmpty() { 388 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, amount); 389 } 390 391 public String fhirType() { 392 return "NutritionProduct.nutrient"; 393 394 } 395 396 } 397 398 @Block() 399 public static class NutritionProductIngredientComponent extends BackboneElement implements IBaseBackboneElement { 400 /** 401 * The ingredient contained in the product. 402 */ 403 @Child(name = "item", type = {CodeableReference.class}, order=1, min=1, max=1, modifier=false, summary=true) 404 @Description(shortDefinition="The ingredient contained in the product", formalDefinition="The ingredient contained in the product." ) 405 protected CodeableReference item; 406 407 /** 408 * The amount of ingredient that is in the product. 409 */ 410 @Child(name = "amount", type = {Ratio.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 411 @Description(shortDefinition="The amount of ingredient that is in the product", formalDefinition="The amount of ingredient that is in the product." ) 412 protected List<Ratio> amount; 413 414 private static final long serialVersionUID = -776277304L; 415 416 /** 417 * Constructor 418 */ 419 public NutritionProductIngredientComponent() { 420 super(); 421 } 422 423 /** 424 * Constructor 425 */ 426 public NutritionProductIngredientComponent(CodeableReference item) { 427 super(); 428 this.setItem(item); 429 } 430 431 /** 432 * @return {@link #item} (The ingredient contained in the product.) 433 */ 434 public CodeableReference getItem() { 435 if (this.item == null) 436 if (Configuration.errorOnAutoCreate()) 437 throw new Error("Attempt to auto-create NutritionProductIngredientComponent.item"); 438 else if (Configuration.doAutoCreate()) 439 this.item = new CodeableReference(); // cc 440 return this.item; 441 } 442 443 public boolean hasItem() { 444 return this.item != null && !this.item.isEmpty(); 445 } 446 447 /** 448 * @param value {@link #item} (The ingredient contained in the product.) 449 */ 450 public NutritionProductIngredientComponent setItem(CodeableReference value) { 451 this.item = value; 452 return this; 453 } 454 455 /** 456 * @return {@link #amount} (The amount of ingredient that is in the product.) 457 */ 458 public List<Ratio> getAmount() { 459 if (this.amount == null) 460 this.amount = new ArrayList<Ratio>(); 461 return this.amount; 462 } 463 464 /** 465 * @return Returns a reference to <code>this</code> for easy method chaining 466 */ 467 public NutritionProductIngredientComponent setAmount(List<Ratio> theAmount) { 468 this.amount = theAmount; 469 return this; 470 } 471 472 public boolean hasAmount() { 473 if (this.amount == null) 474 return false; 475 for (Ratio item : this.amount) 476 if (!item.isEmpty()) 477 return true; 478 return false; 479 } 480 481 public Ratio addAmount() { //3 482 Ratio t = new Ratio(); 483 if (this.amount == null) 484 this.amount = new ArrayList<Ratio>(); 485 this.amount.add(t); 486 return t; 487 } 488 489 public NutritionProductIngredientComponent addAmount(Ratio t) { //3 490 if (t == null) 491 return this; 492 if (this.amount == null) 493 this.amount = new ArrayList<Ratio>(); 494 this.amount.add(t); 495 return this; 496 } 497 498 /** 499 * @return The first repetition of repeating field {@link #amount}, creating it if it does not already exist {3} 500 */ 501 public Ratio getAmountFirstRep() { 502 if (getAmount().isEmpty()) { 503 addAmount(); 504 } 505 return getAmount().get(0); 506 } 507 508 protected void listChildren(List<Property> children) { 509 super.listChildren(children); 510 children.add(new Property("item", "CodeableReference(NutritionProduct)", "The ingredient contained in the product.", 0, 1, item)); 511 children.add(new Property("amount", "Ratio", "The amount of ingredient that is in the product.", 0, java.lang.Integer.MAX_VALUE, amount)); 512 } 513 514 @Override 515 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 516 switch (_hash) { 517 case 3242771: /*item*/ return new Property("item", "CodeableReference(NutritionProduct)", "The ingredient contained in the product.", 0, 1, item); 518 case -1413853096: /*amount*/ return new Property("amount", "Ratio", "The amount of ingredient that is in the product.", 0, java.lang.Integer.MAX_VALUE, amount); 519 default: return super.getNamedProperty(_hash, _name, _checkValid); 520 } 521 522 } 523 524 @Override 525 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 526 switch (hash) { 527 case 3242771: /*item*/ return this.item == null ? new Base[0] : new Base[] {this.item}; // CodeableReference 528 case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : this.amount.toArray(new Base[this.amount.size()]); // Ratio 529 default: return super.getProperty(hash, name, checkValid); 530 } 531 532 } 533 534 @Override 535 public Base setProperty(int hash, String name, Base value) throws FHIRException { 536 switch (hash) { 537 case 3242771: // item 538 this.item = TypeConvertor.castToCodeableReference(value); // CodeableReference 539 return value; 540 case -1413853096: // amount 541 this.getAmount().add(TypeConvertor.castToRatio(value)); // Ratio 542 return value; 543 default: return super.setProperty(hash, name, value); 544 } 545 546 } 547 548 @Override 549 public Base setProperty(String name, Base value) throws FHIRException { 550 if (name.equals("item")) { 551 this.item = TypeConvertor.castToCodeableReference(value); // CodeableReference 552 } else if (name.equals("amount")) { 553 this.getAmount().add(TypeConvertor.castToRatio(value)); 554 } else 555 return super.setProperty(name, value); 556 return value; 557 } 558 559 @Override 560 public Base makeProperty(int hash, String name) throws FHIRException { 561 switch (hash) { 562 case 3242771: return getItem(); 563 case -1413853096: return addAmount(); 564 default: return super.makeProperty(hash, name); 565 } 566 567 } 568 569 @Override 570 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 571 switch (hash) { 572 case 3242771: /*item*/ return new String[] {"CodeableReference"}; 573 case -1413853096: /*amount*/ return new String[] {"Ratio"}; 574 default: return super.getTypesForProperty(hash, name); 575 } 576 577 } 578 579 @Override 580 public Base addChild(String name) throws FHIRException { 581 if (name.equals("item")) { 582 this.item = new CodeableReference(); 583 return this.item; 584 } 585 else if (name.equals("amount")) { 586 return addAmount(); 587 } 588 else 589 return super.addChild(name); 590 } 591 592 public NutritionProductIngredientComponent copy() { 593 NutritionProductIngredientComponent dst = new NutritionProductIngredientComponent(); 594 copyValues(dst); 595 return dst; 596 } 597 598 public void copyValues(NutritionProductIngredientComponent dst) { 599 super.copyValues(dst); 600 dst.item = item == null ? null : item.copy(); 601 if (amount != null) { 602 dst.amount = new ArrayList<Ratio>(); 603 for (Ratio i : amount) 604 dst.amount.add(i.copy()); 605 }; 606 } 607 608 @Override 609 public boolean equalsDeep(Base other_) { 610 if (!super.equalsDeep(other_)) 611 return false; 612 if (!(other_ instanceof NutritionProductIngredientComponent)) 613 return false; 614 NutritionProductIngredientComponent o = (NutritionProductIngredientComponent) other_; 615 return compareDeep(item, o.item, true) && compareDeep(amount, o.amount, true); 616 } 617 618 @Override 619 public boolean equalsShallow(Base other_) { 620 if (!super.equalsShallow(other_)) 621 return false; 622 if (!(other_ instanceof NutritionProductIngredientComponent)) 623 return false; 624 NutritionProductIngredientComponent o = (NutritionProductIngredientComponent) other_; 625 return true; 626 } 627 628 public boolean isEmpty() { 629 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(item, amount); 630 } 631 632 public String fhirType() { 633 return "NutritionProduct.ingredient"; 634 635 } 636 637 } 638 639 @Block() 640 public static class NutritionProductProductCharacteristicComponent extends BackboneElement implements IBaseBackboneElement { 641 /** 642 * A code specifying which characteristic of the product is being described (for example, colour, shape). 643 */ 644 @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false) 645 @Description(shortDefinition="Code specifying the type of characteristic", formalDefinition="A code specifying which characteristic of the product is being described (for example, colour, shape)." ) 646 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/measurement-property") 647 protected CodeableConcept type; 648 649 /** 650 * The actual characteristic value corresponding to the type. 651 */ 652 @Child(name = "value", type = {CodeableConcept.class, StringType.class, Quantity.class, Base64BinaryType.class, Attachment.class, BooleanType.class}, order=2, min=1, max=1, modifier=false, summary=false) 653 @Description(shortDefinition="The value of the characteristic", formalDefinition="The actual characteristic value corresponding to the type." ) 654 protected DataType value; 655 656 private static final long serialVersionUID = -1659186716L; 657 658 /** 659 * Constructor 660 */ 661 public NutritionProductProductCharacteristicComponent() { 662 super(); 663 } 664 665 /** 666 * Constructor 667 */ 668 public NutritionProductProductCharacteristicComponent(CodeableConcept type, DataType value) { 669 super(); 670 this.setType(type); 671 this.setValue(value); 672 } 673 674 /** 675 * @return {@link #type} (A code specifying which characteristic of the product is being described (for example, colour, shape).) 676 */ 677 public CodeableConcept getType() { 678 if (this.type == null) 679 if (Configuration.errorOnAutoCreate()) 680 throw new Error("Attempt to auto-create NutritionProductProductCharacteristicComponent.type"); 681 else if (Configuration.doAutoCreate()) 682 this.type = new CodeableConcept(); // cc 683 return this.type; 684 } 685 686 public boolean hasType() { 687 return this.type != null && !this.type.isEmpty(); 688 } 689 690 /** 691 * @param value {@link #type} (A code specifying which characteristic of the product is being described (for example, colour, shape).) 692 */ 693 public NutritionProductProductCharacteristicComponent setType(CodeableConcept value) { 694 this.type = value; 695 return this; 696 } 697 698 /** 699 * @return {@link #value} (The actual characteristic value corresponding to the type.) 700 */ 701 public DataType getValue() { 702 return this.value; 703 } 704 705 /** 706 * @return {@link #value} (The actual characteristic value corresponding to the type.) 707 */ 708 public CodeableConcept getValueCodeableConcept() throws FHIRException { 709 if (this.value == null) 710 this.value = new CodeableConcept(); 711 if (!(this.value instanceof CodeableConcept)) 712 throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.value.getClass().getName()+" was encountered"); 713 return (CodeableConcept) this.value; 714 } 715 716 public boolean hasValueCodeableConcept() { 717 return this != null && this.value instanceof CodeableConcept; 718 } 719 720 /** 721 * @return {@link #value} (The actual characteristic value corresponding to the type.) 722 */ 723 public StringType getValueStringType() throws FHIRException { 724 if (this.value == null) 725 this.value = new StringType(); 726 if (!(this.value instanceof StringType)) 727 throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.value.getClass().getName()+" was encountered"); 728 return (StringType) this.value; 729 } 730 731 public boolean hasValueStringType() { 732 return this != null && this.value instanceof StringType; 733 } 734 735 /** 736 * @return {@link #value} (The actual characteristic value corresponding to the type.) 737 */ 738 public Quantity getValueQuantity() throws FHIRException { 739 if (this.value == null) 740 this.value = new Quantity(); 741 if (!(this.value instanceof Quantity)) 742 throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.value.getClass().getName()+" was encountered"); 743 return (Quantity) this.value; 744 } 745 746 public boolean hasValueQuantity() { 747 return this != null && this.value instanceof Quantity; 748 } 749 750 /** 751 * @return {@link #value} (The actual characteristic value corresponding to the type.) 752 */ 753 public Base64BinaryType getValueBase64BinaryType() throws FHIRException { 754 if (this.value == null) 755 this.value = new Base64BinaryType(); 756 if (!(this.value instanceof Base64BinaryType)) 757 throw new FHIRException("Type mismatch: the type Base64BinaryType was expected, but "+this.value.getClass().getName()+" was encountered"); 758 return (Base64BinaryType) this.value; 759 } 760 761 public boolean hasValueBase64BinaryType() { 762 return this != null && this.value instanceof Base64BinaryType; 763 } 764 765 /** 766 * @return {@link #value} (The actual characteristic value corresponding to the type.) 767 */ 768 public Attachment getValueAttachment() throws FHIRException { 769 if (this.value == null) 770 this.value = new Attachment(); 771 if (!(this.value instanceof Attachment)) 772 throw new FHIRException("Type mismatch: the type Attachment was expected, but "+this.value.getClass().getName()+" was encountered"); 773 return (Attachment) this.value; 774 } 775 776 public boolean hasValueAttachment() { 777 return this != null && this.value instanceof Attachment; 778 } 779 780 /** 781 * @return {@link #value} (The actual characteristic value corresponding to the type.) 782 */ 783 public BooleanType getValueBooleanType() throws FHIRException { 784 if (this.value == null) 785 this.value = new BooleanType(); 786 if (!(this.value instanceof BooleanType)) 787 throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.value.getClass().getName()+" was encountered"); 788 return (BooleanType) this.value; 789 } 790 791 public boolean hasValueBooleanType() { 792 return this != null && this.value instanceof BooleanType; 793 } 794 795 public boolean hasValue() { 796 return this.value != null && !this.value.isEmpty(); 797 } 798 799 /** 800 * @param value {@link #value} (The actual characteristic value corresponding to the type.) 801 */ 802 public NutritionProductProductCharacteristicComponent setValue(DataType value) { 803 if (value != null && !(value instanceof CodeableConcept || value instanceof StringType || value instanceof Quantity || value instanceof Base64BinaryType || value instanceof Attachment || value instanceof BooleanType)) 804 throw new Error("Not the right type for NutritionProduct.productCharacteristic.value[x]: "+value.fhirType()); 805 this.value = value; 806 return this; 807 } 808 809 protected void listChildren(List<Property> children) { 810 super.listChildren(children); 811 children.add(new Property("type", "CodeableConcept", "A code specifying which characteristic of the product is being described (for example, colour, shape).", 0, 1, type)); 812 children.add(new Property("value[x]", "CodeableConcept|string|Quantity|base64Binary|Attachment|boolean", "The actual characteristic value corresponding to the type.", 0, 1, value)); 813 } 814 815 @Override 816 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 817 switch (_hash) { 818 case 3575610: /*type*/ return new Property("type", "CodeableConcept", "A code specifying which characteristic of the product is being described (for example, colour, shape).", 0, 1, type); 819 case -1410166417: /*value[x]*/ return new Property("value[x]", "CodeableConcept|string|Quantity|base64Binary|Attachment|boolean", "The actual characteristic value corresponding to the type.", 0, 1, value); 820 case 111972721: /*value*/ return new Property("value[x]", "CodeableConcept|string|Quantity|base64Binary|Attachment|boolean", "The actual characteristic value corresponding to the type.", 0, 1, value); 821 case 924902896: /*valueCodeableConcept*/ return new Property("value[x]", "CodeableConcept", "The actual characteristic value corresponding to the type.", 0, 1, value); 822 case -1424603934: /*valueString*/ return new Property("value[x]", "string", "The actual characteristic value corresponding to the type.", 0, 1, value); 823 case -2029823716: /*valueQuantity*/ return new Property("value[x]", "Quantity", "The actual characteristic value corresponding to the type.", 0, 1, value); 824 case -1535024575: /*valueBase64Binary*/ return new Property("value[x]", "base64Binary", "The actual characteristic value corresponding to the type.", 0, 1, value); 825 case -475566732: /*valueAttachment*/ return new Property("value[x]", "Attachment", "The actual characteristic value corresponding to the type.", 0, 1, value); 826 case 733421943: /*valueBoolean*/ return new Property("value[x]", "boolean", "The actual characteristic value corresponding to the type.", 0, 1, value); 827 default: return super.getNamedProperty(_hash, _name, _checkValid); 828 } 829 830 } 831 832 @Override 833 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 834 switch (hash) { 835 case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept 836 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DataType 837 default: return super.getProperty(hash, name, checkValid); 838 } 839 840 } 841 842 @Override 843 public Base setProperty(int hash, String name, Base value) throws FHIRException { 844 switch (hash) { 845 case 3575610: // type 846 this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept 847 return value; 848 case 111972721: // value 849 this.value = TypeConvertor.castToType(value); // DataType 850 return value; 851 default: return super.setProperty(hash, name, value); 852 } 853 854 } 855 856 @Override 857 public Base setProperty(String name, Base value) throws FHIRException { 858 if (name.equals("type")) { 859 this.type = TypeConvertor.castToCodeableConcept(value); // CodeableConcept 860 } else if (name.equals("value[x]")) { 861 this.value = TypeConvertor.castToType(value); // DataType 862 } else 863 return super.setProperty(name, value); 864 return value; 865 } 866 867 @Override 868 public Base makeProperty(int hash, String name) throws FHIRException { 869 switch (hash) { 870 case 3575610: return getType(); 871 case -1410166417: return getValue(); 872 case 111972721: return getValue(); 873 default: return super.makeProperty(hash, name); 874 } 875 876 } 877 878 @Override 879 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 880 switch (hash) { 881 case 3575610: /*type*/ return new String[] {"CodeableConcept"}; 882 case 111972721: /*value*/ return new String[] {"CodeableConcept", "string", "Quantity", "base64Binary", "Attachment", "boolean"}; 883 default: return super.getTypesForProperty(hash, name); 884 } 885 886 } 887 888 @Override 889 public Base addChild(String name) throws FHIRException { 890 if (name.equals("type")) { 891 this.type = new CodeableConcept(); 892 return this.type; 893 } 894 else if (name.equals("valueCodeableConcept")) { 895 this.value = new CodeableConcept(); 896 return this.value; 897 } 898 else if (name.equals("valueString")) { 899 this.value = new StringType(); 900 return this.value; 901 } 902 else if (name.equals("valueQuantity")) { 903 this.value = new Quantity(); 904 return this.value; 905 } 906 else if (name.equals("valueBase64Binary")) { 907 this.value = new Base64BinaryType(); 908 return this.value; 909 } 910 else if (name.equals("valueAttachment")) { 911 this.value = new Attachment(); 912 return this.value; 913 } 914 else if (name.equals("valueBoolean")) { 915 this.value = new BooleanType(); 916 return this.value; 917 } 918 else 919 return super.addChild(name); 920 } 921 922 public NutritionProductProductCharacteristicComponent copy() { 923 NutritionProductProductCharacteristicComponent dst = new NutritionProductProductCharacteristicComponent(); 924 copyValues(dst); 925 return dst; 926 } 927 928 public void copyValues(NutritionProductProductCharacteristicComponent dst) { 929 super.copyValues(dst); 930 dst.type = type == null ? null : type.copy(); 931 dst.value = value == null ? null : value.copy(); 932 } 933 934 @Override 935 public boolean equalsDeep(Base other_) { 936 if (!super.equalsDeep(other_)) 937 return false; 938 if (!(other_ instanceof NutritionProductProductCharacteristicComponent)) 939 return false; 940 NutritionProductProductCharacteristicComponent o = (NutritionProductProductCharacteristicComponent) other_; 941 return compareDeep(type, o.type, true) && compareDeep(value, o.value, true); 942 } 943 944 @Override 945 public boolean equalsShallow(Base other_) { 946 if (!super.equalsShallow(other_)) 947 return false; 948 if (!(other_ instanceof NutritionProductProductCharacteristicComponent)) 949 return false; 950 NutritionProductProductCharacteristicComponent o = (NutritionProductProductCharacteristicComponent) other_; 951 return true; 952 } 953 954 public boolean isEmpty() { 955 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, value); 956 } 957 958 public String fhirType() { 959 return "NutritionProduct.productCharacteristic"; 960 961 } 962 963 } 964 965 @Block() 966 public static class NutritionProductInstanceComponent extends BackboneElement implements IBaseBackboneElement { 967 /** 968 * The amount of items or instances that the resource considers, for instance when referring to 2 identical units together. 969 */ 970 @Child(name = "quantity", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=false) 971 @Description(shortDefinition="The amount of items or instances", formalDefinition="The amount of items or instances that the resource considers, for instance when referring to 2 identical units together." ) 972 protected Quantity quantity; 973 974 /** 975 * The identifier for the physical instance, typically a serial number. 976 */ 977 @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 978 @Description(shortDefinition="The identifier for the physical instance, typically a serial number", formalDefinition="The identifier for the physical instance, typically a serial number." ) 979 protected List<Identifier> identifier; 980 981 /** 982 * The identification of the batch or lot of the product. 983 */ 984 @Child(name = "lotNumber", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=false) 985 @Description(shortDefinition="The identification of the batch or lot of the product", formalDefinition="The identification of the batch or lot of the product." ) 986 protected StringType lotNumber; 987 988 /** 989 * The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed. 990 */ 991 @Child(name = "expiry", type = {DateTimeType.class}, order=4, min=0, max=1, modifier=false, summary=false) 992 @Description(shortDefinition="The expiry date or date and time for the product", formalDefinition="The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed." ) 993 protected DateTimeType expiry; 994 995 /** 996 * The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed. 997 */ 998 @Child(name = "useBy", type = {DateTimeType.class}, order=5, min=0, max=1, modifier=false, summary=false) 999 @Description(shortDefinition="The date until which the product is expected to be good for consumption", formalDefinition="The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed." ) 1000 protected DateTimeType useBy; 1001 1002 /** 1003 * An identifier that supports traceability to the biological entity that is the source of biological material in the product. 1004 */ 1005 @Child(name = "biologicalSource", type = {Identifier.class}, order=6, min=0, max=1, modifier=false, summary=false) 1006 @Description(shortDefinition="An identifier that supports traceability to the biological entity that is the source of biological material in the product", formalDefinition="An identifier that supports traceability to the biological entity that is the source of biological material in the product." ) 1007 protected Identifier biologicalSource; 1008 1009 private static final long serialVersionUID = 1203492607L; 1010 1011 /** 1012 * Constructor 1013 */ 1014 public NutritionProductInstanceComponent() { 1015 super(); 1016 } 1017 1018 /** 1019 * @return {@link #quantity} (The amount of items or instances that the resource considers, for instance when referring to 2 identical units together.) 1020 */ 1021 public Quantity getQuantity() { 1022 if (this.quantity == null) 1023 if (Configuration.errorOnAutoCreate()) 1024 throw new Error("Attempt to auto-create NutritionProductInstanceComponent.quantity"); 1025 else if (Configuration.doAutoCreate()) 1026 this.quantity = new Quantity(); // cc 1027 return this.quantity; 1028 } 1029 1030 public boolean hasQuantity() { 1031 return this.quantity != null && !this.quantity.isEmpty(); 1032 } 1033 1034 /** 1035 * @param value {@link #quantity} (The amount of items or instances that the resource considers, for instance when referring to 2 identical units together.) 1036 */ 1037 public NutritionProductInstanceComponent setQuantity(Quantity value) { 1038 this.quantity = value; 1039 return this; 1040 } 1041 1042 /** 1043 * @return {@link #identifier} (The identifier for the physical instance, typically a serial number.) 1044 */ 1045 public List<Identifier> getIdentifier() { 1046 if (this.identifier == null) 1047 this.identifier = new ArrayList<Identifier>(); 1048 return this.identifier; 1049 } 1050 1051 /** 1052 * @return Returns a reference to <code>this</code> for easy method chaining 1053 */ 1054 public NutritionProductInstanceComponent setIdentifier(List<Identifier> theIdentifier) { 1055 this.identifier = theIdentifier; 1056 return this; 1057 } 1058 1059 public boolean hasIdentifier() { 1060 if (this.identifier == null) 1061 return false; 1062 for (Identifier item : this.identifier) 1063 if (!item.isEmpty()) 1064 return true; 1065 return false; 1066 } 1067 1068 public Identifier addIdentifier() { //3 1069 Identifier t = new Identifier(); 1070 if (this.identifier == null) 1071 this.identifier = new ArrayList<Identifier>(); 1072 this.identifier.add(t); 1073 return t; 1074 } 1075 1076 public NutritionProductInstanceComponent addIdentifier(Identifier t) { //3 1077 if (t == null) 1078 return this; 1079 if (this.identifier == null) 1080 this.identifier = new ArrayList<Identifier>(); 1081 this.identifier.add(t); 1082 return this; 1083 } 1084 1085 /** 1086 * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist {3} 1087 */ 1088 public Identifier getIdentifierFirstRep() { 1089 if (getIdentifier().isEmpty()) { 1090 addIdentifier(); 1091 } 1092 return getIdentifier().get(0); 1093 } 1094 1095 /** 1096 * @return {@link #lotNumber} (The identification of the batch or lot of the product.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value 1097 */ 1098 public StringType getLotNumberElement() { 1099 if (this.lotNumber == null) 1100 if (Configuration.errorOnAutoCreate()) 1101 throw new Error("Attempt to auto-create NutritionProductInstanceComponent.lotNumber"); 1102 else if (Configuration.doAutoCreate()) 1103 this.lotNumber = new StringType(); // bb 1104 return this.lotNumber; 1105 } 1106 1107 public boolean hasLotNumberElement() { 1108 return this.lotNumber != null && !this.lotNumber.isEmpty(); 1109 } 1110 1111 public boolean hasLotNumber() { 1112 return this.lotNumber != null && !this.lotNumber.isEmpty(); 1113 } 1114 1115 /** 1116 * @param value {@link #lotNumber} (The identification of the batch or lot of the product.). This is the underlying object with id, value and extensions. The accessor "getLotNumber" gives direct access to the value 1117 */ 1118 public NutritionProductInstanceComponent setLotNumberElement(StringType value) { 1119 this.lotNumber = value; 1120 return this; 1121 } 1122 1123 /** 1124 * @return The identification of the batch or lot of the product. 1125 */ 1126 public String getLotNumber() { 1127 return this.lotNumber == null ? null : this.lotNumber.getValue(); 1128 } 1129 1130 /** 1131 * @param value The identification of the batch or lot of the product. 1132 */ 1133 public NutritionProductInstanceComponent setLotNumber(String value) { 1134 if (Utilities.noString(value)) 1135 this.lotNumber = null; 1136 else { 1137 if (this.lotNumber == null) 1138 this.lotNumber = new StringType(); 1139 this.lotNumber.setValue(value); 1140 } 1141 return this; 1142 } 1143 1144 /** 1145 * @return {@link #expiry} (The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed.). This is the underlying object with id, value and extensions. The accessor "getExpiry" gives direct access to the value 1146 */ 1147 public DateTimeType getExpiryElement() { 1148 if (this.expiry == null) 1149 if (Configuration.errorOnAutoCreate()) 1150 throw new Error("Attempt to auto-create NutritionProductInstanceComponent.expiry"); 1151 else if (Configuration.doAutoCreate()) 1152 this.expiry = new DateTimeType(); // bb 1153 return this.expiry; 1154 } 1155 1156 public boolean hasExpiryElement() { 1157 return this.expiry != null && !this.expiry.isEmpty(); 1158 } 1159 1160 public boolean hasExpiry() { 1161 return this.expiry != null && !this.expiry.isEmpty(); 1162 } 1163 1164 /** 1165 * @param value {@link #expiry} (The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed.). This is the underlying object with id, value and extensions. The accessor "getExpiry" gives direct access to the value 1166 */ 1167 public NutritionProductInstanceComponent setExpiryElement(DateTimeType value) { 1168 this.expiry = value; 1169 return this; 1170 } 1171 1172 /** 1173 * @return The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed. 1174 */ 1175 public Date getExpiry() { 1176 return this.expiry == null ? null : this.expiry.getValue(); 1177 } 1178 1179 /** 1180 * @param value The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed. 1181 */ 1182 public NutritionProductInstanceComponent setExpiry(Date value) { 1183 if (value == null) 1184 this.expiry = null; 1185 else { 1186 if (this.expiry == null) 1187 this.expiry = new DateTimeType(); 1188 this.expiry.setValue(value); 1189 } 1190 return this; 1191 } 1192 1193 /** 1194 * @return {@link #useBy} (The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed.). This is the underlying object with id, value and extensions. The accessor "getUseBy" gives direct access to the value 1195 */ 1196 public DateTimeType getUseByElement() { 1197 if (this.useBy == null) 1198 if (Configuration.errorOnAutoCreate()) 1199 throw new Error("Attempt to auto-create NutritionProductInstanceComponent.useBy"); 1200 else if (Configuration.doAutoCreate()) 1201 this.useBy = new DateTimeType(); // bb 1202 return this.useBy; 1203 } 1204 1205 public boolean hasUseByElement() { 1206 return this.useBy != null && !this.useBy.isEmpty(); 1207 } 1208 1209 public boolean hasUseBy() { 1210 return this.useBy != null && !this.useBy.isEmpty(); 1211 } 1212 1213 /** 1214 * @param value {@link #useBy} (The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed.). This is the underlying object with id, value and extensions. The accessor "getUseBy" gives direct access to the value 1215 */ 1216 public NutritionProductInstanceComponent setUseByElement(DateTimeType value) { 1217 this.useBy = value; 1218 return this; 1219 } 1220 1221 /** 1222 * @return The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed. 1223 */ 1224 public Date getUseBy() { 1225 return this.useBy == null ? null : this.useBy.getValue(); 1226 } 1227 1228 /** 1229 * @param value The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed. 1230 */ 1231 public NutritionProductInstanceComponent setUseBy(Date value) { 1232 if (value == null) 1233 this.useBy = null; 1234 else { 1235 if (this.useBy == null) 1236 this.useBy = new DateTimeType(); 1237 this.useBy.setValue(value); 1238 } 1239 return this; 1240 } 1241 1242 /** 1243 * @return {@link #biologicalSource} (An identifier that supports traceability to the biological entity that is the source of biological material in the product.) 1244 */ 1245 public Identifier getBiologicalSource() { 1246 if (this.biologicalSource == null) 1247 if (Configuration.errorOnAutoCreate()) 1248 throw new Error("Attempt to auto-create NutritionProductInstanceComponent.biologicalSource"); 1249 else if (Configuration.doAutoCreate()) 1250 this.biologicalSource = new Identifier(); // cc 1251 return this.biologicalSource; 1252 } 1253 1254 public boolean hasBiologicalSource() { 1255 return this.biologicalSource != null && !this.biologicalSource.isEmpty(); 1256 } 1257 1258 /** 1259 * @param value {@link #biologicalSource} (An identifier that supports traceability to the biological entity that is the source of biological material in the product.) 1260 */ 1261 public NutritionProductInstanceComponent setBiologicalSource(Identifier value) { 1262 this.biologicalSource = value; 1263 return this; 1264 } 1265 1266 protected void listChildren(List<Property> children) { 1267 super.listChildren(children); 1268 children.add(new Property("quantity", "Quantity", "The amount of items or instances that the resource considers, for instance when referring to 2 identical units together.", 0, 1, quantity)); 1269 children.add(new Property("identifier", "Identifier", "The identifier for the physical instance, typically a serial number.", 0, java.lang.Integer.MAX_VALUE, identifier)); 1270 children.add(new Property("lotNumber", "string", "The identification of the batch or lot of the product.", 0, 1, lotNumber)); 1271 children.add(new Property("expiry", "dateTime", "The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed.", 0, 1, expiry)); 1272 children.add(new Property("useBy", "dateTime", "The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed.", 0, 1, useBy)); 1273 children.add(new Property("biologicalSource", "Identifier", "An identifier that supports traceability to the biological entity that is the source of biological material in the product.", 0, 1, biologicalSource)); 1274 } 1275 1276 @Override 1277 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 1278 switch (_hash) { 1279 case -1285004149: /*quantity*/ return new Property("quantity", "Quantity", "The amount of items or instances that the resource considers, for instance when referring to 2 identical units together.", 0, 1, quantity); 1280 case -1618432855: /*identifier*/ return new Property("identifier", "Identifier", "The identifier for the physical instance, typically a serial number.", 0, java.lang.Integer.MAX_VALUE, identifier); 1281 case 462547450: /*lotNumber*/ return new Property("lotNumber", "string", "The identification of the batch or lot of the product.", 0, 1, lotNumber); 1282 case -1289159373: /*expiry*/ return new Property("expiry", "dateTime", "The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed.", 0, 1, expiry); 1283 case 111577150: /*useBy*/ return new Property("useBy", "dateTime", "The time after which the product is no longer expected to be in proper condition, or its use is not advised or not allowed.", 0, 1, useBy); 1284 case -883952260: /*biologicalSource*/ return new Property("biologicalSource", "Identifier", "An identifier that supports traceability to the biological entity that is the source of biological material in the product.", 0, 1, biologicalSource); 1285 default: return super.getNamedProperty(_hash, _name, _checkValid); 1286 } 1287 1288 } 1289 1290 @Override 1291 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 1292 switch (hash) { 1293 case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity 1294 case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier 1295 case 462547450: /*lotNumber*/ return this.lotNumber == null ? new Base[0] : new Base[] {this.lotNumber}; // StringType 1296 case -1289159373: /*expiry*/ return this.expiry == null ? new Base[0] : new Base[] {this.expiry}; // DateTimeType 1297 case 111577150: /*useBy*/ return this.useBy == null ? new Base[0] : new Base[] {this.useBy}; // DateTimeType 1298 case -883952260: /*biologicalSource*/ return this.biologicalSource == null ? new Base[0] : new Base[] {this.biologicalSource}; // Identifier 1299 default: return super.getProperty(hash, name, checkValid); 1300 } 1301 1302 } 1303 1304 @Override 1305 public Base setProperty(int hash, String name, Base value) throws FHIRException { 1306 switch (hash) { 1307 case -1285004149: // quantity 1308 this.quantity = TypeConvertor.castToQuantity(value); // Quantity 1309 return value; 1310 case -1618432855: // identifier 1311 this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); // Identifier 1312 return value; 1313 case 462547450: // lotNumber 1314 this.lotNumber = TypeConvertor.castToString(value); // StringType 1315 return value; 1316 case -1289159373: // expiry 1317 this.expiry = TypeConvertor.castToDateTime(value); // DateTimeType 1318 return value; 1319 case 111577150: // useBy 1320 this.useBy = TypeConvertor.castToDateTime(value); // DateTimeType 1321 return value; 1322 case -883952260: // biologicalSource 1323 this.biologicalSource = TypeConvertor.castToIdentifier(value); // Identifier 1324 return value; 1325 default: return super.setProperty(hash, name, value); 1326 } 1327 1328 } 1329 1330 @Override 1331 public Base setProperty(String name, Base value) throws FHIRException { 1332 if (name.equals("quantity")) { 1333 this.quantity = TypeConvertor.castToQuantity(value); // Quantity 1334 } else if (name.equals("identifier")) { 1335 this.getIdentifier().add(TypeConvertor.castToIdentifier(value)); 1336 } else if (name.equals("lotNumber")) { 1337 this.lotNumber = TypeConvertor.castToString(value); // StringType 1338 } else if (name.equals("expiry")) { 1339 this.expiry = TypeConvertor.castToDateTime(value); // DateTimeType 1340 } else if (name.equals("useBy")) { 1341 this.useBy = TypeConvertor.castToDateTime(value); // DateTimeType 1342 } else if (name.equals("biologicalSource")) { 1343 this.biologicalSource = TypeConvertor.castToIdentifier(value); // Identifier 1344 } else 1345 return super.setProperty(name, value); 1346 return value; 1347 } 1348 1349 @Override 1350 public Base makeProperty(int hash, String name) throws FHIRException { 1351 switch (hash) { 1352 case -1285004149: return getQuantity(); 1353 case -1618432855: return addIdentifier(); 1354 case 462547450: return getLotNumberElement(); 1355 case -1289159373: return getExpiryElement(); 1356 case 111577150: return getUseByElement(); 1357 case -883952260: return getBiologicalSource(); 1358 default: return super.makeProperty(hash, name); 1359 } 1360 1361 } 1362 1363 @Override 1364 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 1365 switch (hash) { 1366 case -1285004149: /*quantity*/ return new String[] {"Quantity"}; 1367 case -1618432855: /*identifier*/ return new String[] {"Identifier"}; 1368 case 462547450: /*lotNumber*/ return new String[] {"string"}; 1369 case -1289159373: /*expiry*/ return new String[] {"dateTime"}; 1370 case 111577150: /*useBy*/ return new String[] {"dateTime"}; 1371 case -883952260: /*biologicalSource*/ return new String[] {"Identifier"}; 1372 default: return super.getTypesForProperty(hash, name); 1373 } 1374 1375 } 1376 1377 @Override 1378 public Base addChild(String name) throws FHIRException { 1379 if (name.equals("quantity")) { 1380 this.quantity = new Quantity(); 1381 return this.quantity; 1382 } 1383 else if (name.equals("identifier")) { 1384 return addIdentifier(); 1385 } 1386 else if (name.equals("lotNumber")) { 1387 throw new FHIRException("Cannot call addChild on a primitive type NutritionProduct.instance.lotNumber"); 1388 } 1389 else if (name.equals("expiry")) { 1390 throw new FHIRException("Cannot call addChild on a primitive type NutritionProduct.instance.expiry"); 1391 } 1392 else if (name.equals("useBy")) { 1393 throw new FHIRException("Cannot call addChild on a primitive type NutritionProduct.instance.useBy"); 1394 } 1395 else if (name.equals("biologicalSource")) { 1396 this.biologicalSource = new Identifier(); 1397 return this.biologicalSource; 1398 } 1399 else 1400 return super.addChild(name); 1401 } 1402 1403 public NutritionProductInstanceComponent copy() { 1404 NutritionProductInstanceComponent dst = new NutritionProductInstanceComponent(); 1405 copyValues(dst); 1406 return dst; 1407 } 1408 1409 public void copyValues(NutritionProductInstanceComponent dst) { 1410 super.copyValues(dst); 1411 dst.quantity = quantity == null ? null : quantity.copy(); 1412 if (identifier != null) { 1413 dst.identifier = new ArrayList<Identifier>(); 1414 for (Identifier i : identifier) 1415 dst.identifier.add(i.copy()); 1416 }; 1417 dst.lotNumber = lotNumber == null ? null : lotNumber.copy(); 1418 dst.expiry = expiry == null ? null : expiry.copy(); 1419 dst.useBy = useBy == null ? null : useBy.copy(); 1420 dst.biologicalSource = biologicalSource == null ? null : biologicalSource.copy(); 1421 } 1422 1423 @Override 1424 public boolean equalsDeep(Base other_) { 1425 if (!super.equalsDeep(other_)) 1426 return false; 1427 if (!(other_ instanceof NutritionProductInstanceComponent)) 1428 return false; 1429 NutritionProductInstanceComponent o = (NutritionProductInstanceComponent) other_; 1430 return compareDeep(quantity, o.quantity, true) && compareDeep(identifier, o.identifier, true) && compareDeep(lotNumber, o.lotNumber, true) 1431 && compareDeep(expiry, o.expiry, true) && compareDeep(useBy, o.useBy, true) && compareDeep(biologicalSource, o.biologicalSource, true) 1432 ; 1433 } 1434 1435 @Override 1436 public boolean equalsShallow(Base other_) { 1437 if (!super.equalsShallow(other_)) 1438 return false; 1439 if (!(other_ instanceof NutritionProductInstanceComponent)) 1440 return false; 1441 NutritionProductInstanceComponent o = (NutritionProductInstanceComponent) other_; 1442 return compareValues(lotNumber, o.lotNumber, true) && compareValues(expiry, o.expiry, true) && compareValues(useBy, o.useBy, true) 1443 ; 1444 } 1445 1446 public boolean isEmpty() { 1447 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(quantity, identifier, lotNumber 1448 , expiry, useBy, biologicalSource); 1449 } 1450 1451 public String fhirType() { 1452 return "NutritionProduct.instance"; 1453 1454 } 1455 1456 } 1457 1458 /** 1459 * The current state of the product. 1460 */ 1461 @Child(name = "status", type = {CodeType.class}, order=0, min=1, max=1, modifier=true, summary=true) 1462 @Description(shortDefinition="active | inactive | entered-in-error", formalDefinition="The current state of the product." ) 1463 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/nutritionproduct-status") 1464 protected Enumeration<NutritionProductStatus> status; 1465 1466 /** 1467 * Nutrition products can have different classifications - according to its nutritional properties, preparation methods, etc. 1468 */ 1469 @Child(name = "category", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 1470 @Description(shortDefinition="A category or class of the nutrition product (halal, kosher, gluten free, vegan, etc)", formalDefinition="Nutrition products can have different classifications - according to its nutritional properties, preparation methods, etc." ) 1471 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/nutrition-product-category") 1472 protected List<CodeableConcept> category; 1473 1474 /** 1475 * The code assigned to the product, for example a manufacturer number or other terminology. 1476 */ 1477 @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true) 1478 @Description(shortDefinition="A code designating a specific type of nutritional product", formalDefinition="The code assigned to the product, for example a manufacturer number or other terminology." ) 1479 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/edible-substance-type") 1480 protected CodeableConcept code; 1481 1482 /** 1483 * The organisation (manufacturer, representative or legal authorisation holder) that is responsible for the device. 1484 */ 1485 @Child(name = "manufacturer", type = {Organization.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 1486 @Description(shortDefinition="Manufacturer, representative or officially responsible for the product", formalDefinition="The organisation (manufacturer, representative or legal authorisation holder) that is responsible for the device." ) 1487 protected List<Reference> manufacturer; 1488 1489 /** 1490 * The product's nutritional information expressed by the nutrients. 1491 */ 1492 @Child(name = "nutrient", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true) 1493 @Description(shortDefinition="The product's nutritional information expressed by the nutrients", formalDefinition="The product's nutritional information expressed by the nutrients." ) 1494 protected List<NutritionProductNutrientComponent> nutrient; 1495 1496 /** 1497 * Ingredients contained in this product. 1498 */ 1499 @Child(name = "ingredient", type = {}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 1500 @Description(shortDefinition="Ingredients contained in this product", formalDefinition="Ingredients contained in this product." ) 1501 protected List<NutritionProductIngredientComponent> ingredient; 1502 1503 /** 1504 * Allergens that are known or suspected to be a part of this nutrition product. 1505 */ 1506 @Child(name = "knownAllergen", type = {CodeableReference.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 1507 @Description(shortDefinition="Known or suspected allergens that are a part of this product", formalDefinition="Allergens that are known or suspected to be a part of this nutrition product." ) 1508 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/allergen-class") 1509 protected List<CodeableReference> knownAllergen; 1510 1511 /** 1512 * Specifies descriptive properties of the nutrition product. 1513 */ 1514 @Child(name = "productCharacteristic", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 1515 @Description(shortDefinition="Specifies descriptive properties of the nutrition product", formalDefinition="Specifies descriptive properties of the nutrition product." ) 1516 protected List<NutritionProductProductCharacteristicComponent> productCharacteristic; 1517 1518 /** 1519 * Conveys instance-level information about this product item. One or several physical, countable instances or occurrences of the product. 1520 */ 1521 @Child(name = "instance", type = {}, order=8, min=0, max=1, modifier=false, summary=false) 1522 @Description(shortDefinition="One or several physical instances or occurrences of the nutrition product", formalDefinition="Conveys instance-level information about this product item. One or several physical, countable instances or occurrences of the product." ) 1523 protected NutritionProductInstanceComponent instance; 1524 1525 /** 1526 * Comments made about the product. 1527 */ 1528 @Child(name = "note", type = {Annotation.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 1529 @Description(shortDefinition="Comments made about the product", formalDefinition="Comments made about the product." ) 1530 protected List<Annotation> note; 1531 1532 private static final long serialVersionUID = -565022355L; 1533 1534 /** 1535 * Constructor 1536 */ 1537 public NutritionProduct() { 1538 super(); 1539 } 1540 1541 /** 1542 * Constructor 1543 */ 1544 public NutritionProduct(NutritionProductStatus status) { 1545 super(); 1546 this.setStatus(status); 1547 } 1548 1549 /** 1550 * @return {@link #status} (The current state of the product.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 1551 */ 1552 public Enumeration<NutritionProductStatus> getStatusElement() { 1553 if (this.status == null) 1554 if (Configuration.errorOnAutoCreate()) 1555 throw new Error("Attempt to auto-create NutritionProduct.status"); 1556 else if (Configuration.doAutoCreate()) 1557 this.status = new Enumeration<NutritionProductStatus>(new NutritionProductStatusEnumFactory()); // bb 1558 return this.status; 1559 } 1560 1561 public boolean hasStatusElement() { 1562 return this.status != null && !this.status.isEmpty(); 1563 } 1564 1565 public boolean hasStatus() { 1566 return this.status != null && !this.status.isEmpty(); 1567 } 1568 1569 /** 1570 * @param value {@link #status} (The current state of the product.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value 1571 */ 1572 public NutritionProduct setStatusElement(Enumeration<NutritionProductStatus> value) { 1573 this.status = value; 1574 return this; 1575 } 1576 1577 /** 1578 * @return The current state of the product. 1579 */ 1580 public NutritionProductStatus getStatus() { 1581 return this.status == null ? null : this.status.getValue(); 1582 } 1583 1584 /** 1585 * @param value The current state of the product. 1586 */ 1587 public NutritionProduct setStatus(NutritionProductStatus value) { 1588 if (this.status == null) 1589 this.status = new Enumeration<NutritionProductStatus>(new NutritionProductStatusEnumFactory()); 1590 this.status.setValue(value); 1591 return this; 1592 } 1593 1594 /** 1595 * @return {@link #category} (Nutrition products can have different classifications - according to its nutritional properties, preparation methods, etc.) 1596 */ 1597 public List<CodeableConcept> getCategory() { 1598 if (this.category == null) 1599 this.category = new ArrayList<CodeableConcept>(); 1600 return this.category; 1601 } 1602 1603 /** 1604 * @return Returns a reference to <code>this</code> for easy method chaining 1605 */ 1606 public NutritionProduct setCategory(List<CodeableConcept> theCategory) { 1607 this.category = theCategory; 1608 return this; 1609 } 1610 1611 public boolean hasCategory() { 1612 if (this.category == null) 1613 return false; 1614 for (CodeableConcept item : this.category) 1615 if (!item.isEmpty()) 1616 return true; 1617 return false; 1618 } 1619 1620 public CodeableConcept addCategory() { //3 1621 CodeableConcept t = new CodeableConcept(); 1622 if (this.category == null) 1623 this.category = new ArrayList<CodeableConcept>(); 1624 this.category.add(t); 1625 return t; 1626 } 1627 1628 public NutritionProduct addCategory(CodeableConcept t) { //3 1629 if (t == null) 1630 return this; 1631 if (this.category == null) 1632 this.category = new ArrayList<CodeableConcept>(); 1633 this.category.add(t); 1634 return this; 1635 } 1636 1637 /** 1638 * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist {3} 1639 */ 1640 public CodeableConcept getCategoryFirstRep() { 1641 if (getCategory().isEmpty()) { 1642 addCategory(); 1643 } 1644 return getCategory().get(0); 1645 } 1646 1647 /** 1648 * @return {@link #code} (The code assigned to the product, for example a manufacturer number or other terminology.) 1649 */ 1650 public CodeableConcept getCode() { 1651 if (this.code == null) 1652 if (Configuration.errorOnAutoCreate()) 1653 throw new Error("Attempt to auto-create NutritionProduct.code"); 1654 else if (Configuration.doAutoCreate()) 1655 this.code = new CodeableConcept(); // cc 1656 return this.code; 1657 } 1658 1659 public boolean hasCode() { 1660 return this.code != null && !this.code.isEmpty(); 1661 } 1662 1663 /** 1664 * @param value {@link #code} (The code assigned to the product, for example a manufacturer number or other terminology.) 1665 */ 1666 public NutritionProduct setCode(CodeableConcept value) { 1667 this.code = value; 1668 return this; 1669 } 1670 1671 /** 1672 * @return {@link #manufacturer} (The organisation (manufacturer, representative or legal authorisation holder) that is responsible for the device.) 1673 */ 1674 public List<Reference> getManufacturer() { 1675 if (this.manufacturer == null) 1676 this.manufacturer = new ArrayList<Reference>(); 1677 return this.manufacturer; 1678 } 1679 1680 /** 1681 * @return Returns a reference to <code>this</code> for easy method chaining 1682 */ 1683 public NutritionProduct setManufacturer(List<Reference> theManufacturer) { 1684 this.manufacturer = theManufacturer; 1685 return this; 1686 } 1687 1688 public boolean hasManufacturer() { 1689 if (this.manufacturer == null) 1690 return false; 1691 for (Reference item : this.manufacturer) 1692 if (!item.isEmpty()) 1693 return true; 1694 return false; 1695 } 1696 1697 public Reference addManufacturer() { //3 1698 Reference t = new Reference(); 1699 if (this.manufacturer == null) 1700 this.manufacturer = new ArrayList<Reference>(); 1701 this.manufacturer.add(t); 1702 return t; 1703 } 1704 1705 public NutritionProduct addManufacturer(Reference t) { //3 1706 if (t == null) 1707 return this; 1708 if (this.manufacturer == null) 1709 this.manufacturer = new ArrayList<Reference>(); 1710 this.manufacturer.add(t); 1711 return this; 1712 } 1713 1714 /** 1715 * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist {3} 1716 */ 1717 public Reference getManufacturerFirstRep() { 1718 if (getManufacturer().isEmpty()) { 1719 addManufacturer(); 1720 } 1721 return getManufacturer().get(0); 1722 } 1723 1724 /** 1725 * @return {@link #nutrient} (The product's nutritional information expressed by the nutrients.) 1726 */ 1727 public List<NutritionProductNutrientComponent> getNutrient() { 1728 if (this.nutrient == null) 1729 this.nutrient = new ArrayList<NutritionProductNutrientComponent>(); 1730 return this.nutrient; 1731 } 1732 1733 /** 1734 * @return Returns a reference to <code>this</code> for easy method chaining 1735 */ 1736 public NutritionProduct setNutrient(List<NutritionProductNutrientComponent> theNutrient) { 1737 this.nutrient = theNutrient; 1738 return this; 1739 } 1740 1741 public boolean hasNutrient() { 1742 if (this.nutrient == null) 1743 return false; 1744 for (NutritionProductNutrientComponent item : this.nutrient) 1745 if (!item.isEmpty()) 1746 return true; 1747 return false; 1748 } 1749 1750 public NutritionProductNutrientComponent addNutrient() { //3 1751 NutritionProductNutrientComponent t = new NutritionProductNutrientComponent(); 1752 if (this.nutrient == null) 1753 this.nutrient = new ArrayList<NutritionProductNutrientComponent>(); 1754 this.nutrient.add(t); 1755 return t; 1756 } 1757 1758 public NutritionProduct addNutrient(NutritionProductNutrientComponent t) { //3 1759 if (t == null) 1760 return this; 1761 if (this.nutrient == null) 1762 this.nutrient = new ArrayList<NutritionProductNutrientComponent>(); 1763 this.nutrient.add(t); 1764 return this; 1765 } 1766 1767 /** 1768 * @return The first repetition of repeating field {@link #nutrient}, creating it if it does not already exist {3} 1769 */ 1770 public NutritionProductNutrientComponent getNutrientFirstRep() { 1771 if (getNutrient().isEmpty()) { 1772 addNutrient(); 1773 } 1774 return getNutrient().get(0); 1775 } 1776 1777 /** 1778 * @return {@link #ingredient} (Ingredients contained in this product.) 1779 */ 1780 public List<NutritionProductIngredientComponent> getIngredient() { 1781 if (this.ingredient == null) 1782 this.ingredient = new ArrayList<NutritionProductIngredientComponent>(); 1783 return this.ingredient; 1784 } 1785 1786 /** 1787 * @return Returns a reference to <code>this</code> for easy method chaining 1788 */ 1789 public NutritionProduct setIngredient(List<NutritionProductIngredientComponent> theIngredient) { 1790 this.ingredient = theIngredient; 1791 return this; 1792 } 1793 1794 public boolean hasIngredient() { 1795 if (this.ingredient == null) 1796 return false; 1797 for (NutritionProductIngredientComponent item : this.ingredient) 1798 if (!item.isEmpty()) 1799 return true; 1800 return false; 1801 } 1802 1803 public NutritionProductIngredientComponent addIngredient() { //3 1804 NutritionProductIngredientComponent t = new NutritionProductIngredientComponent(); 1805 if (this.ingredient == null) 1806 this.ingredient = new ArrayList<NutritionProductIngredientComponent>(); 1807 this.ingredient.add(t); 1808 return t; 1809 } 1810 1811 public NutritionProduct addIngredient(NutritionProductIngredientComponent t) { //3 1812 if (t == null) 1813 return this; 1814 if (this.ingredient == null) 1815 this.ingredient = new ArrayList<NutritionProductIngredientComponent>(); 1816 this.ingredient.add(t); 1817 return this; 1818 } 1819 1820 /** 1821 * @return The first repetition of repeating field {@link #ingredient}, creating it if it does not already exist {3} 1822 */ 1823 public NutritionProductIngredientComponent getIngredientFirstRep() { 1824 if (getIngredient().isEmpty()) { 1825 addIngredient(); 1826 } 1827 return getIngredient().get(0); 1828 } 1829 1830 /** 1831 * @return {@link #knownAllergen} (Allergens that are known or suspected to be a part of this nutrition product.) 1832 */ 1833 public List<CodeableReference> getKnownAllergen() { 1834 if (this.knownAllergen == null) 1835 this.knownAllergen = new ArrayList<CodeableReference>(); 1836 return this.knownAllergen; 1837 } 1838 1839 /** 1840 * @return Returns a reference to <code>this</code> for easy method chaining 1841 */ 1842 public NutritionProduct setKnownAllergen(List<CodeableReference> theKnownAllergen) { 1843 this.knownAllergen = theKnownAllergen; 1844 return this; 1845 } 1846 1847 public boolean hasKnownAllergen() { 1848 if (this.knownAllergen == null) 1849 return false; 1850 for (CodeableReference item : this.knownAllergen) 1851 if (!item.isEmpty()) 1852 return true; 1853 return false; 1854 } 1855 1856 public CodeableReference addKnownAllergen() { //3 1857 CodeableReference t = new CodeableReference(); 1858 if (this.knownAllergen == null) 1859 this.knownAllergen = new ArrayList<CodeableReference>(); 1860 this.knownAllergen.add(t); 1861 return t; 1862 } 1863 1864 public NutritionProduct addKnownAllergen(CodeableReference t) { //3 1865 if (t == null) 1866 return this; 1867 if (this.knownAllergen == null) 1868 this.knownAllergen = new ArrayList<CodeableReference>(); 1869 this.knownAllergen.add(t); 1870 return this; 1871 } 1872 1873 /** 1874 * @return The first repetition of repeating field {@link #knownAllergen}, creating it if it does not already exist {3} 1875 */ 1876 public CodeableReference getKnownAllergenFirstRep() { 1877 if (getKnownAllergen().isEmpty()) { 1878 addKnownAllergen(); 1879 } 1880 return getKnownAllergen().get(0); 1881 } 1882 1883 /** 1884 * @return {@link #productCharacteristic} (Specifies descriptive properties of the nutrition product.) 1885 */ 1886 public List<NutritionProductProductCharacteristicComponent> getProductCharacteristic() { 1887 if (this.productCharacteristic == null) 1888 this.productCharacteristic = new ArrayList<NutritionProductProductCharacteristicComponent>(); 1889 return this.productCharacteristic; 1890 } 1891 1892 /** 1893 * @return Returns a reference to <code>this</code> for easy method chaining 1894 */ 1895 public NutritionProduct setProductCharacteristic(List<NutritionProductProductCharacteristicComponent> theProductCharacteristic) { 1896 this.productCharacteristic = theProductCharacteristic; 1897 return this; 1898 } 1899 1900 public boolean hasProductCharacteristic() { 1901 if (this.productCharacteristic == null) 1902 return false; 1903 for (NutritionProductProductCharacteristicComponent item : this.productCharacteristic) 1904 if (!item.isEmpty()) 1905 return true; 1906 return false; 1907 } 1908 1909 public NutritionProductProductCharacteristicComponent addProductCharacteristic() { //3 1910 NutritionProductProductCharacteristicComponent t = new NutritionProductProductCharacteristicComponent(); 1911 if (this.productCharacteristic == null) 1912 this.productCharacteristic = new ArrayList<NutritionProductProductCharacteristicComponent>(); 1913 this.productCharacteristic.add(t); 1914 return t; 1915 } 1916 1917 public NutritionProduct addProductCharacteristic(NutritionProductProductCharacteristicComponent t) { //3 1918 if (t == null) 1919 return this; 1920 if (this.productCharacteristic == null) 1921 this.productCharacteristic = new ArrayList<NutritionProductProductCharacteristicComponent>(); 1922 this.productCharacteristic.add(t); 1923 return this; 1924 } 1925 1926 /** 1927 * @return The first repetition of repeating field {@link #productCharacteristic}, creating it if it does not already exist {3} 1928 */ 1929 public NutritionProductProductCharacteristicComponent getProductCharacteristicFirstRep() { 1930 if (getProductCharacteristic().isEmpty()) { 1931 addProductCharacteristic(); 1932 } 1933 return getProductCharacteristic().get(0); 1934 } 1935 1936 /** 1937 * @return {@link #instance} (Conveys instance-level information about this product item. One or several physical, countable instances or occurrences of the product.) 1938 */ 1939 public NutritionProductInstanceComponent getInstance() { 1940 if (this.instance == null) 1941 if (Configuration.errorOnAutoCreate()) 1942 throw new Error("Attempt to auto-create NutritionProduct.instance"); 1943 else if (Configuration.doAutoCreate()) 1944 this.instance = new NutritionProductInstanceComponent(); // cc 1945 return this.instance; 1946 } 1947 1948 public boolean hasInstance() { 1949 return this.instance != null && !this.instance.isEmpty(); 1950 } 1951 1952 /** 1953 * @param value {@link #instance} (Conveys instance-level information about this product item. One or several physical, countable instances or occurrences of the product.) 1954 */ 1955 public NutritionProduct setInstance(NutritionProductInstanceComponent value) { 1956 this.instance = value; 1957 return this; 1958 } 1959 1960 /** 1961 * @return {@link #note} (Comments made about the product.) 1962 */ 1963 public List<Annotation> getNote() { 1964 if (this.note == null) 1965 this.note = new ArrayList<Annotation>(); 1966 return this.note; 1967 } 1968 1969 /** 1970 * @return Returns a reference to <code>this</code> for easy method chaining 1971 */ 1972 public NutritionProduct setNote(List<Annotation> theNote) { 1973 this.note = theNote; 1974 return this; 1975 } 1976 1977 public boolean hasNote() { 1978 if (this.note == null) 1979 return false; 1980 for (Annotation item : this.note) 1981 if (!item.isEmpty()) 1982 return true; 1983 return false; 1984 } 1985 1986 public Annotation addNote() { //3 1987 Annotation t = new Annotation(); 1988 if (this.note == null) 1989 this.note = new ArrayList<Annotation>(); 1990 this.note.add(t); 1991 return t; 1992 } 1993 1994 public NutritionProduct addNote(Annotation t) { //3 1995 if (t == null) 1996 return this; 1997 if (this.note == null) 1998 this.note = new ArrayList<Annotation>(); 1999 this.note.add(t); 2000 return this; 2001 } 2002 2003 /** 2004 * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist {3} 2005 */ 2006 public Annotation getNoteFirstRep() { 2007 if (getNote().isEmpty()) { 2008 addNote(); 2009 } 2010 return getNote().get(0); 2011 } 2012 2013 protected void listChildren(List<Property> children) { 2014 super.listChildren(children); 2015 children.add(new Property("status", "code", "The current state of the product.", 0, 1, status)); 2016 children.add(new Property("category", "CodeableConcept", "Nutrition products can have different classifications - according to its nutritional properties, preparation methods, etc.", 0, java.lang.Integer.MAX_VALUE, category)); 2017 children.add(new Property("code", "CodeableConcept", "The code assigned to the product, for example a manufacturer number or other terminology.", 0, 1, code)); 2018 children.add(new Property("manufacturer", "Reference(Organization)", "The organisation (manufacturer, representative or legal authorisation holder) that is responsible for the device.", 0, java.lang.Integer.MAX_VALUE, manufacturer)); 2019 children.add(new Property("nutrient", "", "The product's nutritional information expressed by the nutrients.", 0, java.lang.Integer.MAX_VALUE, nutrient)); 2020 children.add(new Property("ingredient", "", "Ingredients contained in this product.", 0, java.lang.Integer.MAX_VALUE, ingredient)); 2021 children.add(new Property("knownAllergen", "CodeableReference(Substance)", "Allergens that are known or suspected to be a part of this nutrition product.", 0, java.lang.Integer.MAX_VALUE, knownAllergen)); 2022 children.add(new Property("productCharacteristic", "", "Specifies descriptive properties of the nutrition product.", 0, java.lang.Integer.MAX_VALUE, productCharacteristic)); 2023 children.add(new Property("instance", "", "Conveys instance-level information about this product item. One or several physical, countable instances or occurrences of the product.", 0, 1, instance)); 2024 children.add(new Property("note", "Annotation", "Comments made about the product.", 0, java.lang.Integer.MAX_VALUE, note)); 2025 } 2026 2027 @Override 2028 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 2029 switch (_hash) { 2030 case -892481550: /*status*/ return new Property("status", "code", "The current state of the product.", 0, 1, status); 2031 case 50511102: /*category*/ return new Property("category", "CodeableConcept", "Nutrition products can have different classifications - according to its nutritional properties, preparation methods, etc.", 0, java.lang.Integer.MAX_VALUE, category); 2032 case 3059181: /*code*/ return new Property("code", "CodeableConcept", "The code assigned to the product, for example a manufacturer number or other terminology.", 0, 1, code); 2033 case -1969347631: /*manufacturer*/ return new Property("manufacturer", "Reference(Organization)", "The organisation (manufacturer, representative or legal authorisation holder) that is responsible for the device.", 0, java.lang.Integer.MAX_VALUE, manufacturer); 2034 case -1671151641: /*nutrient*/ return new Property("nutrient", "", "The product's nutritional information expressed by the nutrients.", 0, java.lang.Integer.MAX_VALUE, nutrient); 2035 case -206409263: /*ingredient*/ return new Property("ingredient", "", "Ingredients contained in this product.", 0, java.lang.Integer.MAX_VALUE, ingredient); 2036 case 1093336805: /*knownAllergen*/ return new Property("knownAllergen", "CodeableReference(Substance)", "Allergens that are known or suspected to be a part of this nutrition product.", 0, java.lang.Integer.MAX_VALUE, knownAllergen); 2037 case 1231899754: /*productCharacteristic*/ return new Property("productCharacteristic", "", "Specifies descriptive properties of the nutrition product.", 0, java.lang.Integer.MAX_VALUE, productCharacteristic); 2038 case 555127957: /*instance*/ return new Property("instance", "", "Conveys instance-level information about this product item. One or several physical, countable instances or occurrences of the product.", 0, 1, instance); 2039 case 3387378: /*note*/ return new Property("note", "Annotation", "Comments made about the product.", 0, java.lang.Integer.MAX_VALUE, note); 2040 default: return super.getNamedProperty(_hash, _name, _checkValid); 2041 } 2042 2043 } 2044 2045 @Override 2046 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 2047 switch (hash) { 2048 case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<NutritionProductStatus> 2049 case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept 2050 case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept 2051 case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // Reference 2052 case -1671151641: /*nutrient*/ return this.nutrient == null ? new Base[0] : this.nutrient.toArray(new Base[this.nutrient.size()]); // NutritionProductNutrientComponent 2053 case -206409263: /*ingredient*/ return this.ingredient == null ? new Base[0] : this.ingredient.toArray(new Base[this.ingredient.size()]); // NutritionProductIngredientComponent 2054 case 1093336805: /*knownAllergen*/ return this.knownAllergen == null ? new Base[0] : this.knownAllergen.toArray(new Base[this.knownAllergen.size()]); // CodeableReference 2055 case 1231899754: /*productCharacteristic*/ return this.productCharacteristic == null ? new Base[0] : this.productCharacteristic.toArray(new Base[this.productCharacteristic.size()]); // NutritionProductProductCharacteristicComponent 2056 case 555127957: /*instance*/ return this.instance == null ? new Base[0] : new Base[] {this.instance}; // NutritionProductInstanceComponent 2057 case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation 2058 default: return super.getProperty(hash, name, checkValid); 2059 } 2060 2061 } 2062 2063 @Override 2064 public Base setProperty(int hash, String name, Base value) throws FHIRException { 2065 switch (hash) { 2066 case -892481550: // status 2067 value = new NutritionProductStatusEnumFactory().fromType(TypeConvertor.castToCode(value)); 2068 this.status = (Enumeration) value; // Enumeration<NutritionProductStatus> 2069 return value; 2070 case 50511102: // category 2071 this.getCategory().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept 2072 return value; 2073 case 3059181: // code 2074 this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept 2075 return value; 2076 case -1969347631: // manufacturer 2077 this.getManufacturer().add(TypeConvertor.castToReference(value)); // Reference 2078 return value; 2079 case -1671151641: // nutrient 2080 this.getNutrient().add((NutritionProductNutrientComponent) value); // NutritionProductNutrientComponent 2081 return value; 2082 case -206409263: // ingredient 2083 this.getIngredient().add((NutritionProductIngredientComponent) value); // NutritionProductIngredientComponent 2084 return value; 2085 case 1093336805: // knownAllergen 2086 this.getKnownAllergen().add(TypeConvertor.castToCodeableReference(value)); // CodeableReference 2087 return value; 2088 case 1231899754: // productCharacteristic 2089 this.getProductCharacteristic().add((NutritionProductProductCharacteristicComponent) value); // NutritionProductProductCharacteristicComponent 2090 return value; 2091 case 555127957: // instance 2092 this.instance = (NutritionProductInstanceComponent) value; // NutritionProductInstanceComponent 2093 return value; 2094 case 3387378: // note 2095 this.getNote().add(TypeConvertor.castToAnnotation(value)); // Annotation 2096 return value; 2097 default: return super.setProperty(hash, name, value); 2098 } 2099 2100 } 2101 2102 @Override 2103 public Base setProperty(String name, Base value) throws FHIRException { 2104 if (name.equals("status")) { 2105 value = new NutritionProductStatusEnumFactory().fromType(TypeConvertor.castToCode(value)); 2106 this.status = (Enumeration) value; // Enumeration<NutritionProductStatus> 2107 } else if (name.equals("category")) { 2108 this.getCategory().add(TypeConvertor.castToCodeableConcept(value)); 2109 } else if (name.equals("code")) { 2110 this.code = TypeConvertor.castToCodeableConcept(value); // CodeableConcept 2111 } else if (name.equals("manufacturer")) { 2112 this.getManufacturer().add(TypeConvertor.castToReference(value)); 2113 } else if (name.equals("nutrient")) { 2114 this.getNutrient().add((NutritionProductNutrientComponent) value); 2115 } else if (name.equals("ingredient")) { 2116 this.getIngredient().add((NutritionProductIngredientComponent) value); 2117 } else if (name.equals("knownAllergen")) { 2118 this.getKnownAllergen().add(TypeConvertor.castToCodeableReference(value)); 2119 } else if (name.equals("productCharacteristic")) { 2120 this.getProductCharacteristic().add((NutritionProductProductCharacteristicComponent) value); 2121 } else if (name.equals("instance")) { 2122 this.instance = (NutritionProductInstanceComponent) value; // NutritionProductInstanceComponent 2123 } else if (name.equals("note")) { 2124 this.getNote().add(TypeConvertor.castToAnnotation(value)); 2125 } else 2126 return super.setProperty(name, value); 2127 return value; 2128 } 2129 2130 @Override 2131 public Base makeProperty(int hash, String name) throws FHIRException { 2132 switch (hash) { 2133 case -892481550: return getStatusElement(); 2134 case 50511102: return addCategory(); 2135 case 3059181: return getCode(); 2136 case -1969347631: return addManufacturer(); 2137 case -1671151641: return addNutrient(); 2138 case -206409263: return addIngredient(); 2139 case 1093336805: return addKnownAllergen(); 2140 case 1231899754: return addProductCharacteristic(); 2141 case 555127957: return getInstance(); 2142 case 3387378: return addNote(); 2143 default: return super.makeProperty(hash, name); 2144 } 2145 2146 } 2147 2148 @Override 2149 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 2150 switch (hash) { 2151 case -892481550: /*status*/ return new String[] {"code"}; 2152 case 50511102: /*category*/ return new String[] {"CodeableConcept"}; 2153 case 3059181: /*code*/ return new String[] {"CodeableConcept"}; 2154 case -1969347631: /*manufacturer*/ return new String[] {"Reference"}; 2155 case -1671151641: /*nutrient*/ return new String[] {}; 2156 case -206409263: /*ingredient*/ return new String[] {}; 2157 case 1093336805: /*knownAllergen*/ return new String[] {"CodeableReference"}; 2158 case 1231899754: /*productCharacteristic*/ return new String[] {}; 2159 case 555127957: /*instance*/ return new String[] {}; 2160 case 3387378: /*note*/ return new String[] {"Annotation"}; 2161 default: return super.getTypesForProperty(hash, name); 2162 } 2163 2164 } 2165 2166 @Override 2167 public Base addChild(String name) throws FHIRException { 2168 if (name.equals("status")) { 2169 throw new FHIRException("Cannot call addChild on a primitive type NutritionProduct.status"); 2170 } 2171 else if (name.equals("category")) { 2172 return addCategory(); 2173 } 2174 else if (name.equals("code")) { 2175 this.code = new CodeableConcept(); 2176 return this.code; 2177 } 2178 else if (name.equals("manufacturer")) { 2179 return addManufacturer(); 2180 } 2181 else if (name.equals("nutrient")) { 2182 return addNutrient(); 2183 } 2184 else if (name.equals("ingredient")) { 2185 return addIngredient(); 2186 } 2187 else if (name.equals("knownAllergen")) { 2188 return addKnownAllergen(); 2189 } 2190 else if (name.equals("productCharacteristic")) { 2191 return addProductCharacteristic(); 2192 } 2193 else if (name.equals("instance")) { 2194 this.instance = new NutritionProductInstanceComponent(); 2195 return this.instance; 2196 } 2197 else if (name.equals("note")) { 2198 return addNote(); 2199 } 2200 else 2201 return super.addChild(name); 2202 } 2203 2204 public String fhirType() { 2205 return "NutritionProduct"; 2206 2207 } 2208 2209 public NutritionProduct copy() { 2210 NutritionProduct dst = new NutritionProduct(); 2211 copyValues(dst); 2212 return dst; 2213 } 2214 2215 public void copyValues(NutritionProduct dst) { 2216 super.copyValues(dst); 2217 dst.status = status == null ? null : status.copy(); 2218 if (category != null) { 2219 dst.category = new ArrayList<CodeableConcept>(); 2220 for (CodeableConcept i : category) 2221 dst.category.add(i.copy()); 2222 }; 2223 dst.code = code == null ? null : code.copy(); 2224 if (manufacturer != null) { 2225 dst.manufacturer = new ArrayList<Reference>(); 2226 for (Reference i : manufacturer) 2227 dst.manufacturer.add(i.copy()); 2228 }; 2229 if (nutrient != null) { 2230 dst.nutrient = new ArrayList<NutritionProductNutrientComponent>(); 2231 for (NutritionProductNutrientComponent i : nutrient) 2232 dst.nutrient.add(i.copy()); 2233 }; 2234 if (ingredient != null) { 2235 dst.ingredient = new ArrayList<NutritionProductIngredientComponent>(); 2236 for (NutritionProductIngredientComponent i : ingredient) 2237 dst.ingredient.add(i.copy()); 2238 }; 2239 if (knownAllergen != null) { 2240 dst.knownAllergen = new ArrayList<CodeableReference>(); 2241 for (CodeableReference i : knownAllergen) 2242 dst.knownAllergen.add(i.copy()); 2243 }; 2244 if (productCharacteristic != null) { 2245 dst.productCharacteristic = new ArrayList<NutritionProductProductCharacteristicComponent>(); 2246 for (NutritionProductProductCharacteristicComponent i : productCharacteristic) 2247 dst.productCharacteristic.add(i.copy()); 2248 }; 2249 dst.instance = instance == null ? null : instance.copy(); 2250 if (note != null) { 2251 dst.note = new ArrayList<Annotation>(); 2252 for (Annotation i : note) 2253 dst.note.add(i.copy()); 2254 }; 2255 } 2256 2257 protected NutritionProduct typedCopy() { 2258 return copy(); 2259 } 2260 2261 @Override 2262 public boolean equalsDeep(Base other_) { 2263 if (!super.equalsDeep(other_)) 2264 return false; 2265 if (!(other_ instanceof NutritionProduct)) 2266 return false; 2267 NutritionProduct o = (NutritionProduct) other_; 2268 return compareDeep(status, o.status, true) && compareDeep(category, o.category, true) && compareDeep(code, o.code, true) 2269 && compareDeep(manufacturer, o.manufacturer, true) && compareDeep(nutrient, o.nutrient, true) && compareDeep(ingredient, o.ingredient, true) 2270 && compareDeep(knownAllergen, o.knownAllergen, true) && compareDeep(productCharacteristic, o.productCharacteristic, true) 2271 && compareDeep(instance, o.instance, true) && compareDeep(note, o.note, true); 2272 } 2273 2274 @Override 2275 public boolean equalsShallow(Base other_) { 2276 if (!super.equalsShallow(other_)) 2277 return false; 2278 if (!(other_ instanceof NutritionProduct)) 2279 return false; 2280 NutritionProduct o = (NutritionProduct) other_; 2281 return compareValues(status, o.status, true); 2282 } 2283 2284 public boolean isEmpty() { 2285 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(status, category, code, manufacturer 2286 , nutrient, ingredient, knownAllergen, productCharacteristic, instance, note); 2287 } 2288 2289 @Override 2290 public ResourceType getResourceType() { 2291 return ResourceType.NutritionProduct; 2292 } 2293 2294 /** 2295 * Search parameter: <b>biological-source</b> 2296 * <p> 2297 * Description: <b>The biological source for the nutrition product</b><br> 2298 * Type: <b>token</b><br> 2299 * Path: <b>NutritionProduct.instance.biologicalSource</b><br> 2300 * </p> 2301 */ 2302 @SearchParamDefinition(name="biological-source", path="NutritionProduct.instance.biologicalSource", description="The biological source for the nutrition product", type="token" ) 2303 public static final String SP_BIOLOGICAL_SOURCE = "biological-source"; 2304 /** 2305 * <b>Fluent Client</b> search parameter constant for <b>biological-source</b> 2306 * <p> 2307 * Description: <b>The biological source for the nutrition product</b><br> 2308 * Type: <b>token</b><br> 2309 * Path: <b>NutritionProduct.instance.biologicalSource</b><br> 2310 * </p> 2311 */ 2312 public static final ca.uhn.fhir.rest.gclient.TokenClientParam BIOLOGICAL_SOURCE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_BIOLOGICAL_SOURCE); 2313 2314 /** 2315 * Search parameter: <b>identifier</b> 2316 * <p> 2317 * Description: <b>The identifier for the physical instance, typically a serial number</b><br> 2318 * Type: <b>token</b><br> 2319 * Path: <b>NutritionProduct.instance.identifier</b><br> 2320 * </p> 2321 */ 2322 @SearchParamDefinition(name="identifier", path="NutritionProduct.instance.identifier", description="The identifier for the physical instance, typically a serial number", type="token" ) 2323 public static final String SP_IDENTIFIER = "identifier"; 2324 /** 2325 * <b>Fluent Client</b> search parameter constant for <b>identifier</b> 2326 * <p> 2327 * Description: <b>The identifier for the physical instance, typically a serial number</b><br> 2328 * Type: <b>token</b><br> 2329 * Path: <b>NutritionProduct.instance.identifier</b><br> 2330 * </p> 2331 */ 2332 public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER); 2333 2334 /** 2335 * Search parameter: <b>status</b> 2336 * <p> 2337 * Description: <b>active | inactive | entered-in-error</b><br> 2338 * Type: <b>token</b><br> 2339 * Path: <b>NutritionProduct.status</b><br> 2340 * </p> 2341 */ 2342 @SearchParamDefinition(name="status", path="NutritionProduct.status", description="active | inactive | entered-in-error", type="token" ) 2343 public static final String SP_STATUS = "status"; 2344 /** 2345 * <b>Fluent Client</b> search parameter constant for <b>status</b> 2346 * <p> 2347 * Description: <b>active | inactive | entered-in-error</b><br> 2348 * Type: <b>token</b><br> 2349 * Path: <b>NutritionProduct.status</b><br> 2350 * </p> 2351 */ 2352 public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS); 2353 2354 2355} 2356