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