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