001package org.hl7.fhir.r5.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.ArrayList;
054import java.util.Date;
055import java.util.List;
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058
059import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
060import org.hl7.fhir.utilities.Utilities;
061import ca.uhn.fhir.model.api.annotation.ResourceDef;
062import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
063import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
064import ca.uhn.fhir.model.api.annotation.Child;
065import ca.uhn.fhir.model.api.annotation.ChildOrder;
066import ca.uhn.fhir.model.api.annotation.Description;
067import ca.uhn.fhir.model.api.annotation.Block;
068/**
069 * A record of food or fluid that is being consumed by a patient.   A NutritionIntake may indicate that the patient may be consuming the food or fluid now or has consumed the food or fluid in the past.  The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician.  A common scenario where this information is captured is during the history taking process during a patient visit or stay or through an app that tracks food or fluids consumed.   The consumption information may come from sources such as the patient's memory, from a nutrition label,  or from a clinician documenting observed intake.
070 */
071@ResourceDef(name="NutritionIntake", profile="http://hl7.org/fhir/StructureDefinition/NutritionIntake")
072public class NutritionIntake extends DomainResource {
073
074    public enum NutritionIntakeStatus {
075        /**
076         * The nutrition is still being taken.
077         */
078        ACTIVE, 
079        /**
080         * The nutrition is no longer being taken.
081         */
082        COMPLETED, 
083        /**
084         * Some of the actions that are implied by the nutrition usage may have occurred.  For example, the patient may have taken some of the nutrition.  Clinical decision support systems should take this status into account.
085         */
086        ENTEREDINERROR, 
087        /**
088         * The nutrition may be taken at some time in the future.
089         */
090        INTENDED, 
091        /**
092         * Actions implied by the usage have been permanently halted, before all of them occurred. This should not be used if the statement was entered in error.
093         */
094        STOPPED, 
095        /**
096         * Actions implied by the usage have been temporarily halted, but are expected to continue later. May also be called 'suspended'.
097         */
098        ONHOLD, 
099        /**
100         * The state of the nutrition use is not currently known.
101         */
102        UNKNOWN, 
103        /**
104         * The nutrition was not consumed by the patient
105         */
106        NOTTAKEN, 
107        /**
108         * added to help the parsers with the generic types
109         */
110        NULL;
111        public static NutritionIntakeStatus fromCode(String codeString) throws FHIRException {
112            if (codeString == null || "".equals(codeString))
113                return null;
114        if ("active".equals(codeString))
115          return ACTIVE;
116        if ("completed".equals(codeString))
117          return COMPLETED;
118        if ("entered-in-error".equals(codeString))
119          return ENTEREDINERROR;
120        if ("intended".equals(codeString))
121          return INTENDED;
122        if ("stopped".equals(codeString))
123          return STOPPED;
124        if ("on-hold".equals(codeString))
125          return ONHOLD;
126        if ("unknown".equals(codeString))
127          return UNKNOWN;
128        if ("not-taken".equals(codeString))
129          return NOTTAKEN;
130        if (Configuration.isAcceptInvalidEnums())
131          return null;
132        else
133          throw new FHIRException("Unknown NutritionIntakeStatus code '"+codeString+"'");
134        }
135        public String toCode() {
136          switch (this) {
137            case ACTIVE: return "active";
138            case COMPLETED: return "completed";
139            case ENTEREDINERROR: return "entered-in-error";
140            case INTENDED: return "intended";
141            case STOPPED: return "stopped";
142            case ONHOLD: return "on-hold";
143            case UNKNOWN: return "unknown";
144            case NOTTAKEN: return "not-taken";
145            default: return "?";
146          }
147        }
148        public String getSystem() {
149          switch (this) {
150            case ACTIVE: return "http://hl7.org/fhir/CodeSystem/nutrition-intake-status";
151            case COMPLETED: return "http://hl7.org/fhir/CodeSystem/nutrition-intake-status";
152            case ENTEREDINERROR: return "http://hl7.org/fhir/CodeSystem/nutrition-intake-status";
153            case INTENDED: return "http://hl7.org/fhir/CodeSystem/nutrition-intake-status";
154            case STOPPED: return "http://hl7.org/fhir/CodeSystem/nutrition-intake-status";
155            case ONHOLD: return "http://hl7.org/fhir/CodeSystem/nutrition-intake-status";
156            case UNKNOWN: return "http://hl7.org/fhir/CodeSystem/nutrition-intake-status";
157            case NOTTAKEN: return "http://hl7.org/fhir/CodeSystem/nutrition-intake-status";
158            default: return "?";
159          }
160        }
161        public String getDefinition() {
162          switch (this) {
163            case ACTIVE: return "The nutrition is still being taken.";
164            case COMPLETED: return "The nutrition is no longer being taken.";
165            case ENTEREDINERROR: return "Some of the actions that are implied by the nutrition usage may have occurred.  For example, the patient may have taken some of the nutrition.  Clinical decision support systems should take this status into account.";
166            case INTENDED: return "The nutrition may be taken at some time in the future.";
167            case STOPPED: return "Actions implied by the usage have been permanently halted, before all of them occurred. This should not be used if the statement was entered in error.";
168            case ONHOLD: return "Actions implied by the usage have been temporarily halted, but are expected to continue later. May also be called 'suspended'.";
169            case UNKNOWN: return "The state of the nutrition use is not currently known.";
170            case NOTTAKEN: return "The nutrition was not consumed by the patient";
171            default: return "?";
172          }
173        }
174        public String getDisplay() {
175          switch (this) {
176            case ACTIVE: return "Active";
177            case COMPLETED: return "Completed";
178            case ENTEREDINERROR: return "Entered in Error";
179            case INTENDED: return "Intended";
180            case STOPPED: return "Stopped";
181            case ONHOLD: return "On Hold";
182            case UNKNOWN: return "Unknown";
183            case NOTTAKEN: return "Not Taken";
184            default: return "?";
185          }
186        }
187    }
188
189  public static class NutritionIntakeStatusEnumFactory implements EnumFactory<NutritionIntakeStatus> {
190    public NutritionIntakeStatus fromCode(String codeString) throws IllegalArgumentException {
191      if (codeString == null || "".equals(codeString))
192            if (codeString == null || "".equals(codeString))
193                return null;
194        if ("active".equals(codeString))
195          return NutritionIntakeStatus.ACTIVE;
196        if ("completed".equals(codeString))
197          return NutritionIntakeStatus.COMPLETED;
198        if ("entered-in-error".equals(codeString))
199          return NutritionIntakeStatus.ENTEREDINERROR;
200        if ("intended".equals(codeString))
201          return NutritionIntakeStatus.INTENDED;
202        if ("stopped".equals(codeString))
203          return NutritionIntakeStatus.STOPPED;
204        if ("on-hold".equals(codeString))
205          return NutritionIntakeStatus.ONHOLD;
206        if ("unknown".equals(codeString))
207          return NutritionIntakeStatus.UNKNOWN;
208        if ("not-taken".equals(codeString))
209          return NutritionIntakeStatus.NOTTAKEN;
210        throw new IllegalArgumentException("Unknown NutritionIntakeStatus code '"+codeString+"'");
211        }
212        public Enumeration<NutritionIntakeStatus> fromType(Base code) throws FHIRException {
213          if (code == null)
214            return null;
215          if (code.isEmpty())
216            return new Enumeration<NutritionIntakeStatus>(this);
217          String codeString = ((PrimitiveType) code).asStringValue();
218          if (codeString == null || "".equals(codeString))
219            return null;
220        if ("active".equals(codeString))
221          return new Enumeration<NutritionIntakeStatus>(this, NutritionIntakeStatus.ACTIVE);
222        if ("completed".equals(codeString))
223          return new Enumeration<NutritionIntakeStatus>(this, NutritionIntakeStatus.COMPLETED);
224        if ("entered-in-error".equals(codeString))
225          return new Enumeration<NutritionIntakeStatus>(this, NutritionIntakeStatus.ENTEREDINERROR);
226        if ("intended".equals(codeString))
227          return new Enumeration<NutritionIntakeStatus>(this, NutritionIntakeStatus.INTENDED);
228        if ("stopped".equals(codeString))
229          return new Enumeration<NutritionIntakeStatus>(this, NutritionIntakeStatus.STOPPED);
230        if ("on-hold".equals(codeString))
231          return new Enumeration<NutritionIntakeStatus>(this, NutritionIntakeStatus.ONHOLD);
232        if ("unknown".equals(codeString))
233          return new Enumeration<NutritionIntakeStatus>(this, NutritionIntakeStatus.UNKNOWN);
234        if ("not-taken".equals(codeString))
235          return new Enumeration<NutritionIntakeStatus>(this, NutritionIntakeStatus.NOTTAKEN);
236        throw new FHIRException("Unknown NutritionIntakeStatus code '"+codeString+"'");
237        }
238    public String toCode(NutritionIntakeStatus code) {
239      if (code == NutritionIntakeStatus.ACTIVE)
240        return "active";
241      if (code == NutritionIntakeStatus.COMPLETED)
242        return "completed";
243      if (code == NutritionIntakeStatus.ENTEREDINERROR)
244        return "entered-in-error";
245      if (code == NutritionIntakeStatus.INTENDED)
246        return "intended";
247      if (code == NutritionIntakeStatus.STOPPED)
248        return "stopped";
249      if (code == NutritionIntakeStatus.ONHOLD)
250        return "on-hold";
251      if (code == NutritionIntakeStatus.UNKNOWN)
252        return "unknown";
253      if (code == NutritionIntakeStatus.NOTTAKEN)
254        return "not-taken";
255      return "?";
256      }
257    public String toSystem(NutritionIntakeStatus code) {
258      return code.getSystem();
259      }
260    }
261
262    @Block()
263    public static class NutritionIntakeConsumedItemComponent extends BackboneElement implements IBaseBackboneElement {
264        /**
265         * Indicates what a category of item that was consumed: eg., food, fluid, enteral, etc.
266         */
267        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=true)
268        @Description(shortDefinition="The type of food or fluid product", formalDefinition="Indicates what a category of item that was consumed: eg., food, fluid, enteral, etc." )
269        protected CodeableConcept type;
270
271        /**
272         * Identifies the food or fluid product that was consumed. This is potentially a link to a resource representing the details of the food product (TBD) or a simple attribute carrying a code that identifies the food from a known list of foods.
273         */
274        @Child(name = "nutritionProduct", type = {CodeableConcept.class}, order=2, min=1, max=1, modifier=false, summary=true)
275        @Description(shortDefinition="Code that identifies the food or fluid product that was consumed", formalDefinition="Identifies the food or fluid product that was consumed. This is potentially a link to a resource representing the details of the food product (TBD) or a simple attribute carrying a code that identifies the food from a known list of foods." )
276        protected CodeableConcept nutritionProduct;
277
278        /**
279         * Scheduled frequency of consumption.
280         */
281        @Child(name = "schedule", type = {Timing.class}, order=3, min=0, max=1, modifier=false, summary=false)
282        @Description(shortDefinition="Scheduled frequency of consumption", formalDefinition="Scheduled frequency of consumption." )
283        protected Timing schedule;
284
285        /**
286         * Quantity of the specified food.
287         */
288        @Child(name = "amount", type = {Quantity.class}, order=4, min=0, max=1, modifier=false, summary=true)
289        @Description(shortDefinition="Quantity of the specified food", formalDefinition="Quantity of the specified food." )
290        protected Quantity amount;
291
292        /**
293         * Rate at which enteral feeding was administered.
294         */
295        @Child(name = "rate", type = {Quantity.class}, order=5, min=0, max=1, modifier=false, summary=true)
296        @Description(shortDefinition="Rate at which enteral feeding was administered", formalDefinition="Rate at which enteral feeding was administered." )
297        protected Quantity rate;
298
299        /**
300         * Indicator when a patient is in a setting where it is helpful to know if food was not consumed, such as it was refused, held (as in tube feedings), or otherwise not provided. If a consumption is being recorded from an app, such as MyFitnessPal, this indicator will likely not be used.
301         */
302        @Child(name = "notConsumed", type = {BooleanType.class}, order=6, min=0, max=1, modifier=false, summary=false)
303        @Description(shortDefinition="Flag to indicate if the food or fluid item was refused or otherwise not consumed", formalDefinition="Indicator when a patient is in a setting where it is helpful to know if food was not consumed, such as it was refused, held (as in tube feedings), or otherwise not provided. If a consumption is being recorded from an app, such as MyFitnessPal, this indicator will likely not be used." )
304        protected BooleanType notConsumed;
305
306        /**
307         * Document the reason the food or fluid was not consumed, such as refused, held, etc.
308         */
309        @Child(name = "notConsumedReason", type = {CodeableConcept.class}, order=7, min=0, max=1, modifier=false, summary=false)
310        @Description(shortDefinition="Reason food or fluid was not consumed", formalDefinition="Document the reason the food or fluid was not consumed, such as refused, held, etc." )
311        protected CodeableConcept notConsumedReason;
312
313        private static final long serialVersionUID = -608839799L;
314
315    /**
316     * Constructor
317     */
318      public NutritionIntakeConsumedItemComponent() {
319        super();
320      }
321
322    /**
323     * Constructor
324     */
325      public NutritionIntakeConsumedItemComponent(CodeableConcept type, CodeableConcept nutritionProduct) {
326        super();
327        this.type = type;
328        this.nutritionProduct = nutritionProduct;
329      }
330
331        /**
332         * @return {@link #type} (Indicates what a category of item that was consumed: eg., food, fluid, enteral, etc.)
333         */
334        public CodeableConcept getType() { 
335          if (this.type == null)
336            if (Configuration.errorOnAutoCreate())
337              throw new Error("Attempt to auto-create NutritionIntakeConsumedItemComponent.type");
338            else if (Configuration.doAutoCreate())
339              this.type = new CodeableConcept(); // cc
340          return this.type;
341        }
342
343        public boolean hasType() { 
344          return this.type != null && !this.type.isEmpty();
345        }
346
347        /**
348         * @param value {@link #type} (Indicates what a category of item that was consumed: eg., food, fluid, enteral, etc.)
349         */
350        public NutritionIntakeConsumedItemComponent setType(CodeableConcept value) { 
351          this.type = value;
352          return this;
353        }
354
355        /**
356         * @return {@link #nutritionProduct} (Identifies the food or fluid product that was consumed. This is potentially a link to a resource representing the details of the food product (TBD) or a simple attribute carrying a code that identifies the food from a known list of foods.)
357         */
358        public CodeableConcept getNutritionProduct() { 
359          if (this.nutritionProduct == null)
360            if (Configuration.errorOnAutoCreate())
361              throw new Error("Attempt to auto-create NutritionIntakeConsumedItemComponent.nutritionProduct");
362            else if (Configuration.doAutoCreate())
363              this.nutritionProduct = new CodeableConcept(); // cc
364          return this.nutritionProduct;
365        }
366
367        public boolean hasNutritionProduct() { 
368          return this.nutritionProduct != null && !this.nutritionProduct.isEmpty();
369        }
370
371        /**
372         * @param value {@link #nutritionProduct} (Identifies the food or fluid product that was consumed. This is potentially a link to a resource representing the details of the food product (TBD) or a simple attribute carrying a code that identifies the food from a known list of foods.)
373         */
374        public NutritionIntakeConsumedItemComponent setNutritionProduct(CodeableConcept value) { 
375          this.nutritionProduct = value;
376          return this;
377        }
378
379        /**
380         * @return {@link #schedule} (Scheduled frequency of consumption.)
381         */
382        public Timing getSchedule() { 
383          if (this.schedule == null)
384            if (Configuration.errorOnAutoCreate())
385              throw new Error("Attempt to auto-create NutritionIntakeConsumedItemComponent.schedule");
386            else if (Configuration.doAutoCreate())
387              this.schedule = new Timing(); // cc
388          return this.schedule;
389        }
390
391        public boolean hasSchedule() { 
392          return this.schedule != null && !this.schedule.isEmpty();
393        }
394
395        /**
396         * @param value {@link #schedule} (Scheduled frequency of consumption.)
397         */
398        public NutritionIntakeConsumedItemComponent setSchedule(Timing value) { 
399          this.schedule = value;
400          return this;
401        }
402
403        /**
404         * @return {@link #amount} (Quantity of the specified food.)
405         */
406        public Quantity getAmount() { 
407          if (this.amount == null)
408            if (Configuration.errorOnAutoCreate())
409              throw new Error("Attempt to auto-create NutritionIntakeConsumedItemComponent.amount");
410            else if (Configuration.doAutoCreate())
411              this.amount = new Quantity(); // cc
412          return this.amount;
413        }
414
415        public boolean hasAmount() { 
416          return this.amount != null && !this.amount.isEmpty();
417        }
418
419        /**
420         * @param value {@link #amount} (Quantity of the specified food.)
421         */
422        public NutritionIntakeConsumedItemComponent setAmount(Quantity value) { 
423          this.amount = value;
424          return this;
425        }
426
427        /**
428         * @return {@link #rate} (Rate at which enteral feeding was administered.)
429         */
430        public Quantity getRate() { 
431          if (this.rate == null)
432            if (Configuration.errorOnAutoCreate())
433              throw new Error("Attempt to auto-create NutritionIntakeConsumedItemComponent.rate");
434            else if (Configuration.doAutoCreate())
435              this.rate = new Quantity(); // cc
436          return this.rate;
437        }
438
439        public boolean hasRate() { 
440          return this.rate != null && !this.rate.isEmpty();
441        }
442
443        /**
444         * @param value {@link #rate} (Rate at which enteral feeding was administered.)
445         */
446        public NutritionIntakeConsumedItemComponent setRate(Quantity value) { 
447          this.rate = value;
448          return this;
449        }
450
451        /**
452         * @return {@link #notConsumed} (Indicator when a patient is in a setting where it is helpful to know if food was not consumed, such as it was refused, held (as in tube feedings), or otherwise not provided. If a consumption is being recorded from an app, such as MyFitnessPal, this indicator will likely not be used.). This is the underlying object with id, value and extensions. The accessor "getNotConsumed" gives direct access to the value
453         */
454        public BooleanType getNotConsumedElement() { 
455          if (this.notConsumed == null)
456            if (Configuration.errorOnAutoCreate())
457              throw new Error("Attempt to auto-create NutritionIntakeConsumedItemComponent.notConsumed");
458            else if (Configuration.doAutoCreate())
459              this.notConsumed = new BooleanType(); // bb
460          return this.notConsumed;
461        }
462
463        public boolean hasNotConsumedElement() { 
464          return this.notConsumed != null && !this.notConsumed.isEmpty();
465        }
466
467        public boolean hasNotConsumed() { 
468          return this.notConsumed != null && !this.notConsumed.isEmpty();
469        }
470
471        /**
472         * @param value {@link #notConsumed} (Indicator when a patient is in a setting where it is helpful to know if food was not consumed, such as it was refused, held (as in tube feedings), or otherwise not provided. If a consumption is being recorded from an app, such as MyFitnessPal, this indicator will likely not be used.). This is the underlying object with id, value and extensions. The accessor "getNotConsumed" gives direct access to the value
473         */
474        public NutritionIntakeConsumedItemComponent setNotConsumedElement(BooleanType value) { 
475          this.notConsumed = value;
476          return this;
477        }
478
479        /**
480         * @return Indicator when a patient is in a setting where it is helpful to know if food was not consumed, such as it was refused, held (as in tube feedings), or otherwise not provided. If a consumption is being recorded from an app, such as MyFitnessPal, this indicator will likely not be used.
481         */
482        public boolean getNotConsumed() { 
483          return this.notConsumed == null || this.notConsumed.isEmpty() ? false : this.notConsumed.getValue();
484        }
485
486        /**
487         * @param value Indicator when a patient is in a setting where it is helpful to know if food was not consumed, such as it was refused, held (as in tube feedings), or otherwise not provided. If a consumption is being recorded from an app, such as MyFitnessPal, this indicator will likely not be used.
488         */
489        public NutritionIntakeConsumedItemComponent setNotConsumed(boolean value) { 
490            if (this.notConsumed == null)
491              this.notConsumed = new BooleanType();
492            this.notConsumed.setValue(value);
493          return this;
494        }
495
496        /**
497         * @return {@link #notConsumedReason} (Document the reason the food or fluid was not consumed, such as refused, held, etc.)
498         */
499        public CodeableConcept getNotConsumedReason() { 
500          if (this.notConsumedReason == null)
501            if (Configuration.errorOnAutoCreate())
502              throw new Error("Attempt to auto-create NutritionIntakeConsumedItemComponent.notConsumedReason");
503            else if (Configuration.doAutoCreate())
504              this.notConsumedReason = new CodeableConcept(); // cc
505          return this.notConsumedReason;
506        }
507
508        public boolean hasNotConsumedReason() { 
509          return this.notConsumedReason != null && !this.notConsumedReason.isEmpty();
510        }
511
512        /**
513         * @param value {@link #notConsumedReason} (Document the reason the food or fluid was not consumed, such as refused, held, etc.)
514         */
515        public NutritionIntakeConsumedItemComponent setNotConsumedReason(CodeableConcept value) { 
516          this.notConsumedReason = value;
517          return this;
518        }
519
520        protected void listChildren(List<Property> children) {
521          super.listChildren(children);
522          children.add(new Property("type", "CodeableConcept", "Indicates what a category of item that was consumed: eg., food, fluid, enteral, etc.", 0, 1, type));
523          children.add(new Property("nutritionProduct", "CodeableConcept", "Identifies the food or fluid product that was consumed. This is potentially a link to a resource representing the details of the food product (TBD) or a simple attribute carrying a code that identifies the food from a known list of foods.", 0, 1, nutritionProduct));
524          children.add(new Property("schedule", "Timing", "Scheduled frequency of consumption.", 0, 1, schedule));
525          children.add(new Property("amount", "SimpleQuantity", "Quantity of the specified food.", 0, 1, amount));
526          children.add(new Property("rate", "SimpleQuantity", "Rate at which enteral feeding was administered.", 0, 1, rate));
527          children.add(new Property("notConsumed", "boolean", "Indicator when a patient is in a setting where it is helpful to know if food was not consumed, such as it was refused, held (as in tube feedings), or otherwise not provided. If a consumption is being recorded from an app, such as MyFitnessPal, this indicator will likely not be used.", 0, 1, notConsumed));
528          children.add(new Property("notConsumedReason", "CodeableConcept", "Document the reason the food or fluid was not consumed, such as refused, held, etc.", 0, 1, notConsumedReason));
529        }
530
531        @Override
532        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
533          switch (_hash) {
534          case 3575610: /*type*/  return new Property("type", "CodeableConcept", "Indicates what a category of item that was consumed: eg., food, fluid, enteral, etc.", 0, 1, type);
535          case -1684132297: /*nutritionProduct*/  return new Property("nutritionProduct", "CodeableConcept", "Identifies the food or fluid product that was consumed. This is potentially a link to a resource representing the details of the food product (TBD) or a simple attribute carrying a code that identifies the food from a known list of foods.", 0, 1, nutritionProduct);
536          case -697920873: /*schedule*/  return new Property("schedule", "Timing", "Scheduled frequency of consumption.", 0, 1, schedule);
537          case -1413853096: /*amount*/  return new Property("amount", "SimpleQuantity", "Quantity of the specified food.", 0, 1, amount);
538          case 3493088: /*rate*/  return new Property("rate", "SimpleQuantity", "Rate at which enteral feeding was administered.", 0, 1, rate);
539          case -148762661: /*notConsumed*/  return new Property("notConsumed", "boolean", "Indicator when a patient is in a setting where it is helpful to know if food was not consumed, such as it was refused, held (as in tube feedings), or otherwise not provided. If a consumption is being recorded from an app, such as MyFitnessPal, this indicator will likely not be used.", 0, 1, notConsumed);
540          case -440795649: /*notConsumedReason*/  return new Property("notConsumedReason", "CodeableConcept", "Document the reason the food or fluid was not consumed, such as refused, held, etc.", 0, 1, notConsumedReason);
541          default: return super.getNamedProperty(_hash, _name, _checkValid);
542          }
543
544        }
545
546      @Override
547      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
548        switch (hash) {
549        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
550        case -1684132297: /*nutritionProduct*/ return this.nutritionProduct == null ? new Base[0] : new Base[] {this.nutritionProduct}; // CodeableConcept
551        case -697920873: /*schedule*/ return this.schedule == null ? new Base[0] : new Base[] {this.schedule}; // Timing
552        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Quantity
553        case 3493088: /*rate*/ return this.rate == null ? new Base[0] : new Base[] {this.rate}; // Quantity
554        case -148762661: /*notConsumed*/ return this.notConsumed == null ? new Base[0] : new Base[] {this.notConsumed}; // BooleanType
555        case -440795649: /*notConsumedReason*/ return this.notConsumedReason == null ? new Base[0] : new Base[] {this.notConsumedReason}; // CodeableConcept
556        default: return super.getProperty(hash, name, checkValid);
557        }
558
559      }
560
561      @Override
562      public Base setProperty(int hash, String name, Base value) throws FHIRException {
563        switch (hash) {
564        case 3575610: // type
565          this.type = castToCodeableConcept(value); // CodeableConcept
566          return value;
567        case -1684132297: // nutritionProduct
568          this.nutritionProduct = castToCodeableConcept(value); // CodeableConcept
569          return value;
570        case -697920873: // schedule
571          this.schedule = castToTiming(value); // Timing
572          return value;
573        case -1413853096: // amount
574          this.amount = castToQuantity(value); // Quantity
575          return value;
576        case 3493088: // rate
577          this.rate = castToQuantity(value); // Quantity
578          return value;
579        case -148762661: // notConsumed
580          this.notConsumed = castToBoolean(value); // BooleanType
581          return value;
582        case -440795649: // notConsumedReason
583          this.notConsumedReason = castToCodeableConcept(value); // CodeableConcept
584          return value;
585        default: return super.setProperty(hash, name, value);
586        }
587
588      }
589
590      @Override
591      public Base setProperty(String name, Base value) throws FHIRException {
592        if (name.equals("type")) {
593          this.type = castToCodeableConcept(value); // CodeableConcept
594        } else if (name.equals("nutritionProduct")) {
595          this.nutritionProduct = castToCodeableConcept(value); // CodeableConcept
596        } else if (name.equals("schedule")) {
597          this.schedule = castToTiming(value); // Timing
598        } else if (name.equals("amount")) {
599          this.amount = castToQuantity(value); // Quantity
600        } else if (name.equals("rate")) {
601          this.rate = castToQuantity(value); // Quantity
602        } else if (name.equals("notConsumed")) {
603          this.notConsumed = castToBoolean(value); // BooleanType
604        } else if (name.equals("notConsumedReason")) {
605          this.notConsumedReason = castToCodeableConcept(value); // CodeableConcept
606        } else
607          return super.setProperty(name, value);
608        return value;
609      }
610
611      @Override
612      public Base makeProperty(int hash, String name) throws FHIRException {
613        switch (hash) {
614        case 3575610:  return getType();
615        case -1684132297:  return getNutritionProduct();
616        case -697920873:  return getSchedule();
617        case -1413853096:  return getAmount();
618        case 3493088:  return getRate();
619        case -148762661:  return getNotConsumedElement();
620        case -440795649:  return getNotConsumedReason();
621        default: return super.makeProperty(hash, name);
622        }
623
624      }
625
626      @Override
627      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
628        switch (hash) {
629        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
630        case -1684132297: /*nutritionProduct*/ return new String[] {"CodeableConcept"};
631        case -697920873: /*schedule*/ return new String[] {"Timing"};
632        case -1413853096: /*amount*/ return new String[] {"SimpleQuantity"};
633        case 3493088: /*rate*/ return new String[] {"SimpleQuantity"};
634        case -148762661: /*notConsumed*/ return new String[] {"boolean"};
635        case -440795649: /*notConsumedReason*/ return new String[] {"CodeableConcept"};
636        default: return super.getTypesForProperty(hash, name);
637        }
638
639      }
640
641      @Override
642      public Base addChild(String name) throws FHIRException {
643        if (name.equals("type")) {
644          this.type = new CodeableConcept();
645          return this.type;
646        }
647        else if (name.equals("nutritionProduct")) {
648          this.nutritionProduct = new CodeableConcept();
649          return this.nutritionProduct;
650        }
651        else if (name.equals("schedule")) {
652          this.schedule = new Timing();
653          return this.schedule;
654        }
655        else if (name.equals("amount")) {
656          this.amount = new Quantity();
657          return this.amount;
658        }
659        else if (name.equals("rate")) {
660          this.rate = new Quantity();
661          return this.rate;
662        }
663        else if (name.equals("notConsumed")) {
664          throw new FHIRException("Cannot call addChild on a primitive type NutritionIntake.notConsumed");
665        }
666        else if (name.equals("notConsumedReason")) {
667          this.notConsumedReason = new CodeableConcept();
668          return this.notConsumedReason;
669        }
670        else
671          return super.addChild(name);
672      }
673
674      public NutritionIntakeConsumedItemComponent copy() {
675        NutritionIntakeConsumedItemComponent dst = new NutritionIntakeConsumedItemComponent();
676        copyValues(dst);
677        return dst;
678      }
679
680      public void copyValues(NutritionIntakeConsumedItemComponent dst) {
681        super.copyValues(dst);
682        dst.type = type == null ? null : type.copy();
683        dst.nutritionProduct = nutritionProduct == null ? null : nutritionProduct.copy();
684        dst.schedule = schedule == null ? null : schedule.copy();
685        dst.amount = amount == null ? null : amount.copy();
686        dst.rate = rate == null ? null : rate.copy();
687        dst.notConsumed = notConsumed == null ? null : notConsumed.copy();
688        dst.notConsumedReason = notConsumedReason == null ? null : notConsumedReason.copy();
689      }
690
691      @Override
692      public boolean equalsDeep(Base other_) {
693        if (!super.equalsDeep(other_))
694          return false;
695        if (!(other_ instanceof NutritionIntakeConsumedItemComponent))
696          return false;
697        NutritionIntakeConsumedItemComponent o = (NutritionIntakeConsumedItemComponent) other_;
698        return compareDeep(type, o.type, true) && compareDeep(nutritionProduct, o.nutritionProduct, true)
699           && compareDeep(schedule, o.schedule, true) && compareDeep(amount, o.amount, true) && compareDeep(rate, o.rate, true)
700           && compareDeep(notConsumed, o.notConsumed, true) && compareDeep(notConsumedReason, o.notConsumedReason, true)
701          ;
702      }
703
704      @Override
705      public boolean equalsShallow(Base other_) {
706        if (!super.equalsShallow(other_))
707          return false;
708        if (!(other_ instanceof NutritionIntakeConsumedItemComponent))
709          return false;
710        NutritionIntakeConsumedItemComponent o = (NutritionIntakeConsumedItemComponent) other_;
711        return compareValues(notConsumed, o.notConsumed, true);
712      }
713
714      public boolean isEmpty() {
715        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, nutritionProduct, schedule
716          , amount, rate, notConsumed, notConsumedReason);
717      }
718
719  public String fhirType() {
720    return "NutritionIntake.consumedItem";
721
722  }
723
724  }
725
726    @Block()
727    public static class NutritionIntakeIngredientLabelComponent extends BackboneElement implements IBaseBackboneElement {
728        /**
729         * Total nutrient consumed. This could be a macronutrient (protein, fat, carbohydrate), or a vitamin and mineral.
730         */
731        @Child(name = "nutrient", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
732        @Description(shortDefinition="Total nutrient consumed", formalDefinition="Total nutrient consumed. This could be a macronutrient (protein, fat, carbohydrate), or a vitamin and mineral." )
733        protected CodeableConcept nutrient;
734
735        /**
736         * Total amount of nutrient consumed.
737         */
738        @Child(name = "amount", type = {Quantity.class}, order=2, min=1, max=1, modifier=false, summary=false)
739        @Description(shortDefinition="Total amount of nutrient consumed", formalDefinition="Total amount of nutrient consumed." )
740        protected Quantity amount;
741
742        private static final long serialVersionUID = -1026365827L;
743
744    /**
745     * Constructor
746     */
747      public NutritionIntakeIngredientLabelComponent() {
748        super();
749      }
750
751    /**
752     * Constructor
753     */
754      public NutritionIntakeIngredientLabelComponent(CodeableConcept nutrient, Quantity amount) {
755        super();
756        this.nutrient = nutrient;
757        this.amount = amount;
758      }
759
760        /**
761         * @return {@link #nutrient} (Total nutrient consumed. This could be a macronutrient (protein, fat, carbohydrate), or a vitamin and mineral.)
762         */
763        public CodeableConcept getNutrient() { 
764          if (this.nutrient == null)
765            if (Configuration.errorOnAutoCreate())
766              throw new Error("Attempt to auto-create NutritionIntakeIngredientLabelComponent.nutrient");
767            else if (Configuration.doAutoCreate())
768              this.nutrient = new CodeableConcept(); // cc
769          return this.nutrient;
770        }
771
772        public boolean hasNutrient() { 
773          return this.nutrient != null && !this.nutrient.isEmpty();
774        }
775
776        /**
777         * @param value {@link #nutrient} (Total nutrient consumed. This could be a macronutrient (protein, fat, carbohydrate), or a vitamin and mineral.)
778         */
779        public NutritionIntakeIngredientLabelComponent setNutrient(CodeableConcept value) { 
780          this.nutrient = value;
781          return this;
782        }
783
784        /**
785         * @return {@link #amount} (Total amount of nutrient consumed.)
786         */
787        public Quantity getAmount() { 
788          if (this.amount == null)
789            if (Configuration.errorOnAutoCreate())
790              throw new Error("Attempt to auto-create NutritionIntakeIngredientLabelComponent.amount");
791            else if (Configuration.doAutoCreate())
792              this.amount = new Quantity(); // cc
793          return this.amount;
794        }
795
796        public boolean hasAmount() { 
797          return this.amount != null && !this.amount.isEmpty();
798        }
799
800        /**
801         * @param value {@link #amount} (Total amount of nutrient consumed.)
802         */
803        public NutritionIntakeIngredientLabelComponent setAmount(Quantity value) { 
804          this.amount = value;
805          return this;
806        }
807
808        protected void listChildren(List<Property> children) {
809          super.listChildren(children);
810          children.add(new Property("nutrient", "CodeableConcept", "Total nutrient consumed. This could be a macronutrient (protein, fat, carbohydrate), or a vitamin and mineral.", 0, 1, nutrient));
811          children.add(new Property("amount", "SimpleQuantity", "Total amount of nutrient consumed.", 0, 1, amount));
812        }
813
814        @Override
815        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
816          switch (_hash) {
817          case -1671151641: /*nutrient*/  return new Property("nutrient", "CodeableConcept", "Total nutrient consumed. This could be a macronutrient (protein, fat, carbohydrate), or a vitamin and mineral.", 0, 1, nutrient);
818          case -1413853096: /*amount*/  return new Property("amount", "SimpleQuantity", "Total amount of nutrient consumed.", 0, 1, amount);
819          default: return super.getNamedProperty(_hash, _name, _checkValid);
820          }
821
822        }
823
824      @Override
825      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
826        switch (hash) {
827        case -1671151641: /*nutrient*/ return this.nutrient == null ? new Base[0] : new Base[] {this.nutrient}; // CodeableConcept
828        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Quantity
829        default: return super.getProperty(hash, name, checkValid);
830        }
831
832      }
833
834      @Override
835      public Base setProperty(int hash, String name, Base value) throws FHIRException {
836        switch (hash) {
837        case -1671151641: // nutrient
838          this.nutrient = castToCodeableConcept(value); // CodeableConcept
839          return value;
840        case -1413853096: // amount
841          this.amount = castToQuantity(value); // Quantity
842          return value;
843        default: return super.setProperty(hash, name, value);
844        }
845
846      }
847
848      @Override
849      public Base setProperty(String name, Base value) throws FHIRException {
850        if (name.equals("nutrient")) {
851          this.nutrient = castToCodeableConcept(value); // CodeableConcept
852        } else if (name.equals("amount")) {
853          this.amount = castToQuantity(value); // Quantity
854        } else
855          return super.setProperty(name, value);
856        return value;
857      }
858
859      @Override
860      public Base makeProperty(int hash, String name) throws FHIRException {
861        switch (hash) {
862        case -1671151641:  return getNutrient();
863        case -1413853096:  return getAmount();
864        default: return super.makeProperty(hash, name);
865        }
866
867      }
868
869      @Override
870      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
871        switch (hash) {
872        case -1671151641: /*nutrient*/ return new String[] {"CodeableConcept"};
873        case -1413853096: /*amount*/ return new String[] {"SimpleQuantity"};
874        default: return super.getTypesForProperty(hash, name);
875        }
876
877      }
878
879      @Override
880      public Base addChild(String name) throws FHIRException {
881        if (name.equals("nutrient")) {
882          this.nutrient = new CodeableConcept();
883          return this.nutrient;
884        }
885        else if (name.equals("amount")) {
886          this.amount = new Quantity();
887          return this.amount;
888        }
889        else
890          return super.addChild(name);
891      }
892
893      public NutritionIntakeIngredientLabelComponent copy() {
894        NutritionIntakeIngredientLabelComponent dst = new NutritionIntakeIngredientLabelComponent();
895        copyValues(dst);
896        return dst;
897      }
898
899      public void copyValues(NutritionIntakeIngredientLabelComponent dst) {
900        super.copyValues(dst);
901        dst.nutrient = nutrient == null ? null : nutrient.copy();
902        dst.amount = amount == null ? null : amount.copy();
903      }
904
905      @Override
906      public boolean equalsDeep(Base other_) {
907        if (!super.equalsDeep(other_))
908          return false;
909        if (!(other_ instanceof NutritionIntakeIngredientLabelComponent))
910          return false;
911        NutritionIntakeIngredientLabelComponent o = (NutritionIntakeIngredientLabelComponent) other_;
912        return compareDeep(nutrient, o.nutrient, true) && compareDeep(amount, o.amount, true);
913      }
914
915      @Override
916      public boolean equalsShallow(Base other_) {
917        if (!super.equalsShallow(other_))
918          return false;
919        if (!(other_ instanceof NutritionIntakeIngredientLabelComponent))
920          return false;
921        NutritionIntakeIngredientLabelComponent o = (NutritionIntakeIngredientLabelComponent) other_;
922        return true;
923      }
924
925      public boolean isEmpty() {
926        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(nutrient, amount);
927      }
928
929  public String fhirType() {
930    return "NutritionIntake.ingredientLabel";
931
932  }
933
934  }
935
936    /**
937     * Identifiers associated with this Nutrition Intake that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.
938     */
939    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
940    @Description(shortDefinition="External identifier", formalDefinition="Identifiers associated with this Nutrition Intake that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server." )
941    protected List<Identifier> identifier;
942
943    /**
944     * A plan, proposal or order that is fulfilled in whole or in part by this event.
945     */
946    @Child(name = "basedOn", type = {NutritionOrder.class, CarePlan.class, ServiceRequest.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
947    @Description(shortDefinition="Fulfils plan, proposal or order", formalDefinition="A plan, proposal or order that is fulfilled in whole or in part by this event." )
948    protected List<Reference> basedOn;
949
950    /**
951     * A larger event of which this particular event is a component or step.
952     */
953    @Child(name = "partOf", type = {NutritionIntake.class, Procedure.class, Observation.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
954    @Description(shortDefinition="Part of referenced event", formalDefinition="A larger event of which this particular event is a component or step." )
955    protected List<Reference> partOf;
956
957    /**
958     * A code representing the patient or other source's judgment about the state of the intake that this assertion is about.  Generally, this will be active or completed.
959     */
960    @Child(name = "status", type = {CodeType.class}, order=3, min=1, max=1, modifier=true, summary=true)
961    @Description(shortDefinition="active | completed | entered-in-error | intended | stopped | on-hold | unknown | not-taken", formalDefinition="A code representing the patient or other source's judgment about the state of the intake that this assertion is about.  Generally, this will be active or completed." )
962    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/nutrition-intake-status")
963    protected Enumeration<NutritionIntakeStatus> status;
964
965    /**
966     * Captures the reason for the current state of the NutritionIntake.
967     */
968    @Child(name = "statusReason", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
969    @Description(shortDefinition="Reason for current status", formalDefinition="Captures the reason for the current state of the NutritionIntake." )
970    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/reason-medication-status-codes")
971    protected List<CodeableConcept> statusReason;
972
973    /**
974     * Indicates where the food or fluid was  consumed or prescribed.
975     */
976    @Child(name = "category", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
977    @Description(shortDefinition="Type of nutrition intake setting/reporting", formalDefinition="Indicates where the food or fluid was  consumed or prescribed." )
978    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/nutrition-intake-category")
979    protected List<CodeableConcept> category;
980
981    /**
982     * What food or fluid product or item was consumed.
983     */
984    @Child(name = "consumedItem", type = {}, order=6, min=1, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
985    @Description(shortDefinition="What food or fluid product or item was consumed", formalDefinition="What food or fluid product or item was consumed." )
986    protected List<NutritionIntakeConsumedItemComponent> consumedItem;
987
988    /**
989     * Total nutrient amounts for the whole meal, product, serving, etc.
990     */
991    @Child(name = "ingredientLabel", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
992    @Description(shortDefinition="Total nutrient for the whole meal, product, serving", formalDefinition="Total nutrient amounts for the whole meal, product, serving, etc." )
993    protected List<NutritionIntakeIngredientLabelComponent> ingredientLabel;
994
995    /**
996     * The person, animal or group who is/was consuming the food or fluid.
997     */
998    @Child(name = "subject", type = {Patient.class, Group.class}, order=8, min=1, max=1, modifier=false, summary=true)
999    @Description(shortDefinition="Who is/was consuming the food or fluid", formalDefinition="The person, animal or group who is/was consuming the food or fluid." )
1000    protected Reference subject;
1001
1002    /**
1003     * The encounter that establishes the context for this NutritionIntake.
1004     */
1005    @Child(name = "encounter", type = {Encounter.class}, order=9, min=0, max=1, modifier=false, summary=true)
1006    @Description(shortDefinition="Encounter associated with NutritionIntake", formalDefinition="The encounter that establishes the context for this NutritionIntake." )
1007    protected Reference encounter;
1008
1009    /**
1010     * The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.
1011     */
1012    @Child(name = "effective", type = {DateTimeType.class, Period.class}, order=10, min=0, max=1, modifier=false, summary=true)
1013    @Description(shortDefinition="The date/time or interval when the food or fluid is/was consumed", formalDefinition="The interval of time during which it is being asserted that the patient is/was consuming the food or fluid." )
1014    protected Type effective;
1015
1016    /**
1017     * The date when the Nutrition Intake was asserted by the information source.
1018     */
1019    @Child(name = "dateAsserted", type = {DateTimeType.class}, order=11, min=0, max=1, modifier=false, summary=true)
1020    @Description(shortDefinition="When the consumption was asserted?", formalDefinition="The date when the Nutrition Intake was asserted by the information source." )
1021    protected DateTimeType dateAsserted;
1022
1023    /**
1024     * The person or organization that provided the information about the consumption of this food or fluid. Note: Use derivedFrom when a NutritionIntake is derived from other resources.
1025     */
1026    @Child(name = "informationSource", type = {Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class, Organization.class}, order=12, min=0, max=1, modifier=false, summary=false)
1027    @Description(shortDefinition="Person or organization that provided the information about the consumption of this food or fluid", formalDefinition="The person or organization that provided the information about the consumption of this food or fluid. Note: Use derivedFrom when a NutritionIntake is derived from other resources." )
1028    protected Reference informationSource;
1029
1030    /**
1031     * Allows linking the NutritionIntake to the underlying NutritionOrder, or to other information, such as AllergyIntolerance, that supports or is used to derive the NutritionIntake.
1032     */
1033    @Child(name = "derivedFrom", type = {Reference.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1034    @Description(shortDefinition="Additional supporting information", formalDefinition="Allows linking the NutritionIntake to the underlying NutritionOrder, or to other information, such as AllergyIntolerance, that supports or is used to derive the NutritionIntake." )
1035    protected List<Reference> derivedFrom;
1036
1037    /**
1038     * A reason for why the food or fluid is /was consumed.
1039     */
1040    @Child(name = "reasonCode", type = {CodeableConcept.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1041    @Description(shortDefinition="Reason for why the food or fluid is /was consumed", formalDefinition="A reason for why the food or fluid is /was consumed." )
1042    protected List<CodeableConcept> reasonCode;
1043
1044    /**
1045     * Condition or observation that supports why the food or fluid is /was consumed.
1046     */
1047    @Child(name = "reasonReference", type = {Condition.class, Observation.class, DiagnosticReport.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1048    @Description(shortDefinition="Condition or observation that supports why the food or fluid is /was consumed", formalDefinition="Condition or observation that supports why the food or fluid is /was consumed." )
1049    protected List<Reference> reasonReference;
1050
1051    /**
1052     * Provides extra information about the Nutrition Intake that is not conveyed by the other attributes.
1053     */
1054    @Child(name = "note", type = {Annotation.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1055    @Description(shortDefinition="Further information about the consumption", formalDefinition="Provides extra information about the Nutrition Intake that is not conveyed by the other attributes." )
1056    protected List<Annotation> note;
1057
1058    private static final long serialVersionUID = 1482407460L;
1059
1060  /**
1061   * Constructor
1062   */
1063    public NutritionIntake() {
1064      super();
1065    }
1066
1067  /**
1068   * Constructor
1069   */
1070    public NutritionIntake(Enumeration<NutritionIntakeStatus> status, Reference subject) {
1071      super();
1072      this.status = status;
1073      this.subject = subject;
1074    }
1075
1076    /**
1077     * @return {@link #identifier} (Identifiers associated with this Nutrition Intake that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.)
1078     */
1079    public List<Identifier> getIdentifier() { 
1080      if (this.identifier == null)
1081        this.identifier = new ArrayList<Identifier>();
1082      return this.identifier;
1083    }
1084
1085    /**
1086     * @return Returns a reference to <code>this</code> for easy method chaining
1087     */
1088    public NutritionIntake setIdentifier(List<Identifier> theIdentifier) { 
1089      this.identifier = theIdentifier;
1090      return this;
1091    }
1092
1093    public boolean hasIdentifier() { 
1094      if (this.identifier == null)
1095        return false;
1096      for (Identifier item : this.identifier)
1097        if (!item.isEmpty())
1098          return true;
1099      return false;
1100    }
1101
1102    public Identifier addIdentifier() { //3
1103      Identifier t = new Identifier();
1104      if (this.identifier == null)
1105        this.identifier = new ArrayList<Identifier>();
1106      this.identifier.add(t);
1107      return t;
1108    }
1109
1110    public NutritionIntake addIdentifier(Identifier t) { //3
1111      if (t == null)
1112        return this;
1113      if (this.identifier == null)
1114        this.identifier = new ArrayList<Identifier>();
1115      this.identifier.add(t);
1116      return this;
1117    }
1118
1119    /**
1120     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1121     */
1122    public Identifier getIdentifierFirstRep() { 
1123      if (getIdentifier().isEmpty()) {
1124        addIdentifier();
1125      }
1126      return getIdentifier().get(0);
1127    }
1128
1129    /**
1130     * @return {@link #basedOn} (A plan, proposal or order that is fulfilled in whole or in part by this event.)
1131     */
1132    public List<Reference> getBasedOn() { 
1133      if (this.basedOn == null)
1134        this.basedOn = new ArrayList<Reference>();
1135      return this.basedOn;
1136    }
1137
1138    /**
1139     * @return Returns a reference to <code>this</code> for easy method chaining
1140     */
1141    public NutritionIntake setBasedOn(List<Reference> theBasedOn) { 
1142      this.basedOn = theBasedOn;
1143      return this;
1144    }
1145
1146    public boolean hasBasedOn() { 
1147      if (this.basedOn == null)
1148        return false;
1149      for (Reference item : this.basedOn)
1150        if (!item.isEmpty())
1151          return true;
1152      return false;
1153    }
1154
1155    public Reference addBasedOn() { //3
1156      Reference t = new Reference();
1157      if (this.basedOn == null)
1158        this.basedOn = new ArrayList<Reference>();
1159      this.basedOn.add(t);
1160      return t;
1161    }
1162
1163    public NutritionIntake addBasedOn(Reference t) { //3
1164      if (t == null)
1165        return this;
1166      if (this.basedOn == null)
1167        this.basedOn = new ArrayList<Reference>();
1168      this.basedOn.add(t);
1169      return this;
1170    }
1171
1172    /**
1173     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
1174     */
1175    public Reference getBasedOnFirstRep() { 
1176      if (getBasedOn().isEmpty()) {
1177        addBasedOn();
1178      }
1179      return getBasedOn().get(0);
1180    }
1181
1182    /**
1183     * @return {@link #partOf} (A larger event of which this particular event is a component or step.)
1184     */
1185    public List<Reference> getPartOf() { 
1186      if (this.partOf == null)
1187        this.partOf = new ArrayList<Reference>();
1188      return this.partOf;
1189    }
1190
1191    /**
1192     * @return Returns a reference to <code>this</code> for easy method chaining
1193     */
1194    public NutritionIntake setPartOf(List<Reference> thePartOf) { 
1195      this.partOf = thePartOf;
1196      return this;
1197    }
1198
1199    public boolean hasPartOf() { 
1200      if (this.partOf == null)
1201        return false;
1202      for (Reference item : this.partOf)
1203        if (!item.isEmpty())
1204          return true;
1205      return false;
1206    }
1207
1208    public Reference addPartOf() { //3
1209      Reference t = new Reference();
1210      if (this.partOf == null)
1211        this.partOf = new ArrayList<Reference>();
1212      this.partOf.add(t);
1213      return t;
1214    }
1215
1216    public NutritionIntake addPartOf(Reference t) { //3
1217      if (t == null)
1218        return this;
1219      if (this.partOf == null)
1220        this.partOf = new ArrayList<Reference>();
1221      this.partOf.add(t);
1222      return this;
1223    }
1224
1225    /**
1226     * @return The first repetition of repeating field {@link #partOf}, creating it if it does not already exist
1227     */
1228    public Reference getPartOfFirstRep() { 
1229      if (getPartOf().isEmpty()) {
1230        addPartOf();
1231      }
1232      return getPartOf().get(0);
1233    }
1234
1235    /**
1236     * @return {@link #status} (A code representing the patient or other source's judgment about the state of the intake that this assertion is about.  Generally, this will be active or completed.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1237     */
1238    public Enumeration<NutritionIntakeStatus> getStatusElement() { 
1239      if (this.status == null)
1240        if (Configuration.errorOnAutoCreate())
1241          throw new Error("Attempt to auto-create NutritionIntake.status");
1242        else if (Configuration.doAutoCreate())
1243          this.status = new Enumeration<NutritionIntakeStatus>(new NutritionIntakeStatusEnumFactory()); // bb
1244      return this.status;
1245    }
1246
1247    public boolean hasStatusElement() { 
1248      return this.status != null && !this.status.isEmpty();
1249    }
1250
1251    public boolean hasStatus() { 
1252      return this.status != null && !this.status.isEmpty();
1253    }
1254
1255    /**
1256     * @param value {@link #status} (A code representing the patient or other source's judgment about the state of the intake that this assertion is about.  Generally, this will be active or completed.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1257     */
1258    public NutritionIntake setStatusElement(Enumeration<NutritionIntakeStatus> value) { 
1259      this.status = value;
1260      return this;
1261    }
1262
1263    /**
1264     * @return A code representing the patient or other source's judgment about the state of the intake that this assertion is about.  Generally, this will be active or completed.
1265     */
1266    public NutritionIntakeStatus getStatus() { 
1267      return this.status == null ? null : this.status.getValue();
1268    }
1269
1270    /**
1271     * @param value A code representing the patient or other source's judgment about the state of the intake that this assertion is about.  Generally, this will be active or completed.
1272     */
1273    public NutritionIntake setStatus(NutritionIntakeStatus value) { 
1274        if (this.status == null)
1275          this.status = new Enumeration<NutritionIntakeStatus>(new NutritionIntakeStatusEnumFactory());
1276        this.status.setValue(value);
1277      return this;
1278    }
1279
1280    /**
1281     * @return {@link #statusReason} (Captures the reason for the current state of the NutritionIntake.)
1282     */
1283    public List<CodeableConcept> getStatusReason() { 
1284      if (this.statusReason == null)
1285        this.statusReason = new ArrayList<CodeableConcept>();
1286      return this.statusReason;
1287    }
1288
1289    /**
1290     * @return Returns a reference to <code>this</code> for easy method chaining
1291     */
1292    public NutritionIntake setStatusReason(List<CodeableConcept> theStatusReason) { 
1293      this.statusReason = theStatusReason;
1294      return this;
1295    }
1296
1297    public boolean hasStatusReason() { 
1298      if (this.statusReason == null)
1299        return false;
1300      for (CodeableConcept item : this.statusReason)
1301        if (!item.isEmpty())
1302          return true;
1303      return false;
1304    }
1305
1306    public CodeableConcept addStatusReason() { //3
1307      CodeableConcept t = new CodeableConcept();
1308      if (this.statusReason == null)
1309        this.statusReason = new ArrayList<CodeableConcept>();
1310      this.statusReason.add(t);
1311      return t;
1312    }
1313
1314    public NutritionIntake addStatusReason(CodeableConcept t) { //3
1315      if (t == null)
1316        return this;
1317      if (this.statusReason == null)
1318        this.statusReason = new ArrayList<CodeableConcept>();
1319      this.statusReason.add(t);
1320      return this;
1321    }
1322
1323    /**
1324     * @return The first repetition of repeating field {@link #statusReason}, creating it if it does not already exist
1325     */
1326    public CodeableConcept getStatusReasonFirstRep() { 
1327      if (getStatusReason().isEmpty()) {
1328        addStatusReason();
1329      }
1330      return getStatusReason().get(0);
1331    }
1332
1333    /**
1334     * @return {@link #category} (Indicates where the food or fluid was  consumed or prescribed.)
1335     */
1336    public List<CodeableConcept> getCategory() { 
1337      if (this.category == null)
1338        this.category = new ArrayList<CodeableConcept>();
1339      return this.category;
1340    }
1341
1342    /**
1343     * @return Returns a reference to <code>this</code> for easy method chaining
1344     */
1345    public NutritionIntake setCategory(List<CodeableConcept> theCategory) { 
1346      this.category = theCategory;
1347      return this;
1348    }
1349
1350    public boolean hasCategory() { 
1351      if (this.category == null)
1352        return false;
1353      for (CodeableConcept item : this.category)
1354        if (!item.isEmpty())
1355          return true;
1356      return false;
1357    }
1358
1359    public CodeableConcept addCategory() { //3
1360      CodeableConcept t = new CodeableConcept();
1361      if (this.category == null)
1362        this.category = new ArrayList<CodeableConcept>();
1363      this.category.add(t);
1364      return t;
1365    }
1366
1367    public NutritionIntake addCategory(CodeableConcept t) { //3
1368      if (t == null)
1369        return this;
1370      if (this.category == null)
1371        this.category = new ArrayList<CodeableConcept>();
1372      this.category.add(t);
1373      return this;
1374    }
1375
1376    /**
1377     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
1378     */
1379    public CodeableConcept getCategoryFirstRep() { 
1380      if (getCategory().isEmpty()) {
1381        addCategory();
1382      }
1383      return getCategory().get(0);
1384    }
1385
1386    /**
1387     * @return {@link #consumedItem} (What food or fluid product or item was consumed.)
1388     */
1389    public List<NutritionIntakeConsumedItemComponent> getConsumedItem() { 
1390      if (this.consumedItem == null)
1391        this.consumedItem = new ArrayList<NutritionIntakeConsumedItemComponent>();
1392      return this.consumedItem;
1393    }
1394
1395    /**
1396     * @return Returns a reference to <code>this</code> for easy method chaining
1397     */
1398    public NutritionIntake setConsumedItem(List<NutritionIntakeConsumedItemComponent> theConsumedItem) { 
1399      this.consumedItem = theConsumedItem;
1400      return this;
1401    }
1402
1403    public boolean hasConsumedItem() { 
1404      if (this.consumedItem == null)
1405        return false;
1406      for (NutritionIntakeConsumedItemComponent item : this.consumedItem)
1407        if (!item.isEmpty())
1408          return true;
1409      return false;
1410    }
1411
1412    public NutritionIntakeConsumedItemComponent addConsumedItem() { //3
1413      NutritionIntakeConsumedItemComponent t = new NutritionIntakeConsumedItemComponent();
1414      if (this.consumedItem == null)
1415        this.consumedItem = new ArrayList<NutritionIntakeConsumedItemComponent>();
1416      this.consumedItem.add(t);
1417      return t;
1418    }
1419
1420    public NutritionIntake addConsumedItem(NutritionIntakeConsumedItemComponent t) { //3
1421      if (t == null)
1422        return this;
1423      if (this.consumedItem == null)
1424        this.consumedItem = new ArrayList<NutritionIntakeConsumedItemComponent>();
1425      this.consumedItem.add(t);
1426      return this;
1427    }
1428
1429    /**
1430     * @return The first repetition of repeating field {@link #consumedItem}, creating it if it does not already exist
1431     */
1432    public NutritionIntakeConsumedItemComponent getConsumedItemFirstRep() { 
1433      if (getConsumedItem().isEmpty()) {
1434        addConsumedItem();
1435      }
1436      return getConsumedItem().get(0);
1437    }
1438
1439    /**
1440     * @return {@link #ingredientLabel} (Total nutrient amounts for the whole meal, product, serving, etc.)
1441     */
1442    public List<NutritionIntakeIngredientLabelComponent> getIngredientLabel() { 
1443      if (this.ingredientLabel == null)
1444        this.ingredientLabel = new ArrayList<NutritionIntakeIngredientLabelComponent>();
1445      return this.ingredientLabel;
1446    }
1447
1448    /**
1449     * @return Returns a reference to <code>this</code> for easy method chaining
1450     */
1451    public NutritionIntake setIngredientLabel(List<NutritionIntakeIngredientLabelComponent> theIngredientLabel) { 
1452      this.ingredientLabel = theIngredientLabel;
1453      return this;
1454    }
1455
1456    public boolean hasIngredientLabel() { 
1457      if (this.ingredientLabel == null)
1458        return false;
1459      for (NutritionIntakeIngredientLabelComponent item : this.ingredientLabel)
1460        if (!item.isEmpty())
1461          return true;
1462      return false;
1463    }
1464
1465    public NutritionIntakeIngredientLabelComponent addIngredientLabel() { //3
1466      NutritionIntakeIngredientLabelComponent t = new NutritionIntakeIngredientLabelComponent();
1467      if (this.ingredientLabel == null)
1468        this.ingredientLabel = new ArrayList<NutritionIntakeIngredientLabelComponent>();
1469      this.ingredientLabel.add(t);
1470      return t;
1471    }
1472
1473    public NutritionIntake addIngredientLabel(NutritionIntakeIngredientLabelComponent t) { //3
1474      if (t == null)
1475        return this;
1476      if (this.ingredientLabel == null)
1477        this.ingredientLabel = new ArrayList<NutritionIntakeIngredientLabelComponent>();
1478      this.ingredientLabel.add(t);
1479      return this;
1480    }
1481
1482    /**
1483     * @return The first repetition of repeating field {@link #ingredientLabel}, creating it if it does not already exist
1484     */
1485    public NutritionIntakeIngredientLabelComponent getIngredientLabelFirstRep() { 
1486      if (getIngredientLabel().isEmpty()) {
1487        addIngredientLabel();
1488      }
1489      return getIngredientLabel().get(0);
1490    }
1491
1492    /**
1493     * @return {@link #subject} (The person, animal or group who is/was consuming the food or fluid.)
1494     */
1495    public Reference getSubject() { 
1496      if (this.subject == null)
1497        if (Configuration.errorOnAutoCreate())
1498          throw new Error("Attempt to auto-create NutritionIntake.subject");
1499        else if (Configuration.doAutoCreate())
1500          this.subject = new Reference(); // cc
1501      return this.subject;
1502    }
1503
1504    public boolean hasSubject() { 
1505      return this.subject != null && !this.subject.isEmpty();
1506    }
1507
1508    /**
1509     * @param value {@link #subject} (The person, animal or group who is/was consuming the food or fluid.)
1510     */
1511    public NutritionIntake setSubject(Reference value) { 
1512      this.subject = value;
1513      return this;
1514    }
1515
1516    /**
1517     * @return {@link #encounter} (The encounter that establishes the context for this NutritionIntake.)
1518     */
1519    public Reference getEncounter() { 
1520      if (this.encounter == null)
1521        if (Configuration.errorOnAutoCreate())
1522          throw new Error("Attempt to auto-create NutritionIntake.encounter");
1523        else if (Configuration.doAutoCreate())
1524          this.encounter = new Reference(); // cc
1525      return this.encounter;
1526    }
1527
1528    public boolean hasEncounter() { 
1529      return this.encounter != null && !this.encounter.isEmpty();
1530    }
1531
1532    /**
1533     * @param value {@link #encounter} (The encounter that establishes the context for this NutritionIntake.)
1534     */
1535    public NutritionIntake setEncounter(Reference value) { 
1536      this.encounter = value;
1537      return this;
1538    }
1539
1540    /**
1541     * @return {@link #effective} (The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.)
1542     */
1543    public Type getEffective() { 
1544      return this.effective;
1545    }
1546
1547    /**
1548     * @return {@link #effective} (The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.)
1549     */
1550    public DateTimeType getEffectiveDateTimeType() throws FHIRException { 
1551      if (this.effective == null)
1552        this.effective = new DateTimeType();
1553      if (!(this.effective instanceof DateTimeType))
1554        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.effective.getClass().getName()+" was encountered");
1555      return (DateTimeType) this.effective;
1556    }
1557
1558    public boolean hasEffectiveDateTimeType() { 
1559      return this != null && this.effective instanceof DateTimeType;
1560    }
1561
1562    /**
1563     * @return {@link #effective} (The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.)
1564     */
1565    public Period getEffectivePeriod() throws FHIRException { 
1566      if (this.effective == null)
1567        this.effective = new Period();
1568      if (!(this.effective instanceof Period))
1569        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.effective.getClass().getName()+" was encountered");
1570      return (Period) this.effective;
1571    }
1572
1573    public boolean hasEffectivePeriod() { 
1574      return this != null && this.effective instanceof Period;
1575    }
1576
1577    public boolean hasEffective() { 
1578      return this.effective != null && !this.effective.isEmpty();
1579    }
1580
1581    /**
1582     * @param value {@link #effective} (The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.)
1583     */
1584    public NutritionIntake setEffective(Type value) { 
1585      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
1586        throw new Error("Not the right type for NutritionIntake.effective[x]: "+value.fhirType());
1587      this.effective = value;
1588      return this;
1589    }
1590
1591    /**
1592     * @return {@link #dateAsserted} (The date when the Nutrition Intake was asserted by the information source.). This is the underlying object with id, value and extensions. The accessor "getDateAsserted" gives direct access to the value
1593     */
1594    public DateTimeType getDateAssertedElement() { 
1595      if (this.dateAsserted == null)
1596        if (Configuration.errorOnAutoCreate())
1597          throw new Error("Attempt to auto-create NutritionIntake.dateAsserted");
1598        else if (Configuration.doAutoCreate())
1599          this.dateAsserted = new DateTimeType(); // bb
1600      return this.dateAsserted;
1601    }
1602
1603    public boolean hasDateAssertedElement() { 
1604      return this.dateAsserted != null && !this.dateAsserted.isEmpty();
1605    }
1606
1607    public boolean hasDateAsserted() { 
1608      return this.dateAsserted != null && !this.dateAsserted.isEmpty();
1609    }
1610
1611    /**
1612     * @param value {@link #dateAsserted} (The date when the Nutrition Intake was asserted by the information source.). This is the underlying object with id, value and extensions. The accessor "getDateAsserted" gives direct access to the value
1613     */
1614    public NutritionIntake setDateAssertedElement(DateTimeType value) { 
1615      this.dateAsserted = value;
1616      return this;
1617    }
1618
1619    /**
1620     * @return The date when the Nutrition Intake was asserted by the information source.
1621     */
1622    public Date getDateAsserted() { 
1623      return this.dateAsserted == null ? null : this.dateAsserted.getValue();
1624    }
1625
1626    /**
1627     * @param value The date when the Nutrition Intake was asserted by the information source.
1628     */
1629    public NutritionIntake setDateAsserted(Date value) { 
1630      if (value == null)
1631        this.dateAsserted = null;
1632      else {
1633        if (this.dateAsserted == null)
1634          this.dateAsserted = new DateTimeType();
1635        this.dateAsserted.setValue(value);
1636      }
1637      return this;
1638    }
1639
1640    /**
1641     * @return {@link #informationSource} (The person or organization that provided the information about the consumption of this food or fluid. Note: Use derivedFrom when a NutritionIntake is derived from other resources.)
1642     */
1643    public Reference getInformationSource() { 
1644      if (this.informationSource == null)
1645        if (Configuration.errorOnAutoCreate())
1646          throw new Error("Attempt to auto-create NutritionIntake.informationSource");
1647        else if (Configuration.doAutoCreate())
1648          this.informationSource = new Reference(); // cc
1649      return this.informationSource;
1650    }
1651
1652    public boolean hasInformationSource() { 
1653      return this.informationSource != null && !this.informationSource.isEmpty();
1654    }
1655
1656    /**
1657     * @param value {@link #informationSource} (The person or organization that provided the information about the consumption of this food or fluid. Note: Use derivedFrom when a NutritionIntake is derived from other resources.)
1658     */
1659    public NutritionIntake setInformationSource(Reference value) { 
1660      this.informationSource = value;
1661      return this;
1662    }
1663
1664    /**
1665     * @return {@link #derivedFrom} (Allows linking the NutritionIntake to the underlying NutritionOrder, or to other information, such as AllergyIntolerance, that supports or is used to derive the NutritionIntake.)
1666     */
1667    public List<Reference> getDerivedFrom() { 
1668      if (this.derivedFrom == null)
1669        this.derivedFrom = new ArrayList<Reference>();
1670      return this.derivedFrom;
1671    }
1672
1673    /**
1674     * @return Returns a reference to <code>this</code> for easy method chaining
1675     */
1676    public NutritionIntake setDerivedFrom(List<Reference> theDerivedFrom) { 
1677      this.derivedFrom = theDerivedFrom;
1678      return this;
1679    }
1680
1681    public boolean hasDerivedFrom() { 
1682      if (this.derivedFrom == null)
1683        return false;
1684      for (Reference item : this.derivedFrom)
1685        if (!item.isEmpty())
1686          return true;
1687      return false;
1688    }
1689
1690    public Reference addDerivedFrom() { //3
1691      Reference t = new Reference();
1692      if (this.derivedFrom == null)
1693        this.derivedFrom = new ArrayList<Reference>();
1694      this.derivedFrom.add(t);
1695      return t;
1696    }
1697
1698    public NutritionIntake addDerivedFrom(Reference t) { //3
1699      if (t == null)
1700        return this;
1701      if (this.derivedFrom == null)
1702        this.derivedFrom = new ArrayList<Reference>();
1703      this.derivedFrom.add(t);
1704      return this;
1705    }
1706
1707    /**
1708     * @return The first repetition of repeating field {@link #derivedFrom}, creating it if it does not already exist
1709     */
1710    public Reference getDerivedFromFirstRep() { 
1711      if (getDerivedFrom().isEmpty()) {
1712        addDerivedFrom();
1713      }
1714      return getDerivedFrom().get(0);
1715    }
1716
1717    /**
1718     * @return {@link #reasonCode} (A reason for why the food or fluid is /was consumed.)
1719     */
1720    public List<CodeableConcept> getReasonCode() { 
1721      if (this.reasonCode == null)
1722        this.reasonCode = new ArrayList<CodeableConcept>();
1723      return this.reasonCode;
1724    }
1725
1726    /**
1727     * @return Returns a reference to <code>this</code> for easy method chaining
1728     */
1729    public NutritionIntake setReasonCode(List<CodeableConcept> theReasonCode) { 
1730      this.reasonCode = theReasonCode;
1731      return this;
1732    }
1733
1734    public boolean hasReasonCode() { 
1735      if (this.reasonCode == null)
1736        return false;
1737      for (CodeableConcept item : this.reasonCode)
1738        if (!item.isEmpty())
1739          return true;
1740      return false;
1741    }
1742
1743    public CodeableConcept addReasonCode() { //3
1744      CodeableConcept t = new CodeableConcept();
1745      if (this.reasonCode == null)
1746        this.reasonCode = new ArrayList<CodeableConcept>();
1747      this.reasonCode.add(t);
1748      return t;
1749    }
1750
1751    public NutritionIntake addReasonCode(CodeableConcept t) { //3
1752      if (t == null)
1753        return this;
1754      if (this.reasonCode == null)
1755        this.reasonCode = new ArrayList<CodeableConcept>();
1756      this.reasonCode.add(t);
1757      return this;
1758    }
1759
1760    /**
1761     * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1762     */
1763    public CodeableConcept getReasonCodeFirstRep() { 
1764      if (getReasonCode().isEmpty()) {
1765        addReasonCode();
1766      }
1767      return getReasonCode().get(0);
1768    }
1769
1770    /**
1771     * @return {@link #reasonReference} (Condition or observation that supports why the food or fluid is /was consumed.)
1772     */
1773    public List<Reference> getReasonReference() { 
1774      if (this.reasonReference == null)
1775        this.reasonReference = new ArrayList<Reference>();
1776      return this.reasonReference;
1777    }
1778
1779    /**
1780     * @return Returns a reference to <code>this</code> for easy method chaining
1781     */
1782    public NutritionIntake setReasonReference(List<Reference> theReasonReference) { 
1783      this.reasonReference = theReasonReference;
1784      return this;
1785    }
1786
1787    public boolean hasReasonReference() { 
1788      if (this.reasonReference == null)
1789        return false;
1790      for (Reference item : this.reasonReference)
1791        if (!item.isEmpty())
1792          return true;
1793      return false;
1794    }
1795
1796    public Reference addReasonReference() { //3
1797      Reference t = new Reference();
1798      if (this.reasonReference == null)
1799        this.reasonReference = new ArrayList<Reference>();
1800      this.reasonReference.add(t);
1801      return t;
1802    }
1803
1804    public NutritionIntake addReasonReference(Reference t) { //3
1805      if (t == null)
1806        return this;
1807      if (this.reasonReference == null)
1808        this.reasonReference = new ArrayList<Reference>();
1809      this.reasonReference.add(t);
1810      return this;
1811    }
1812
1813    /**
1814     * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1815     */
1816    public Reference getReasonReferenceFirstRep() { 
1817      if (getReasonReference().isEmpty()) {
1818        addReasonReference();
1819      }
1820      return getReasonReference().get(0);
1821    }
1822
1823    /**
1824     * @return {@link #note} (Provides extra information about the Nutrition Intake that is not conveyed by the other attributes.)
1825     */
1826    public List<Annotation> getNote() { 
1827      if (this.note == null)
1828        this.note = new ArrayList<Annotation>();
1829      return this.note;
1830    }
1831
1832    /**
1833     * @return Returns a reference to <code>this</code> for easy method chaining
1834     */
1835    public NutritionIntake setNote(List<Annotation> theNote) { 
1836      this.note = theNote;
1837      return this;
1838    }
1839
1840    public boolean hasNote() { 
1841      if (this.note == null)
1842        return false;
1843      for (Annotation item : this.note)
1844        if (!item.isEmpty())
1845          return true;
1846      return false;
1847    }
1848
1849    public Annotation addNote() { //3
1850      Annotation t = new Annotation();
1851      if (this.note == null)
1852        this.note = new ArrayList<Annotation>();
1853      this.note.add(t);
1854      return t;
1855    }
1856
1857    public NutritionIntake addNote(Annotation t) { //3
1858      if (t == null)
1859        return this;
1860      if (this.note == null)
1861        this.note = new ArrayList<Annotation>();
1862      this.note.add(t);
1863      return this;
1864    }
1865
1866    /**
1867     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1868     */
1869    public Annotation getNoteFirstRep() { 
1870      if (getNote().isEmpty()) {
1871        addNote();
1872      }
1873      return getNote().get(0);
1874    }
1875
1876      protected void listChildren(List<Property> children) {
1877        super.listChildren(children);
1878        children.add(new Property("identifier", "Identifier", "Identifiers associated with this Nutrition Intake that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier));
1879        children.add(new Property("basedOn", "Reference(NutritionOrder|CarePlan|ServiceRequest)", "A plan, proposal or order that is fulfilled in whole or in part by this event.", 0, java.lang.Integer.MAX_VALUE, basedOn));
1880        children.add(new Property("partOf", "Reference(NutritionIntake|Procedure|Observation)", "A larger event of which this particular event is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf));
1881        children.add(new Property("status", "code", "A code representing the patient or other source's judgment about the state of the intake that this assertion is about.  Generally, this will be active or completed.", 0, 1, status));
1882        children.add(new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the NutritionIntake.", 0, java.lang.Integer.MAX_VALUE, statusReason));
1883        children.add(new Property("category", "CodeableConcept", "Indicates where the food or fluid was  consumed or prescribed.", 0, java.lang.Integer.MAX_VALUE, category));
1884        children.add(new Property("consumedItem", "", "What food or fluid product or item was consumed.", 0, java.lang.Integer.MAX_VALUE, consumedItem));
1885        children.add(new Property("ingredientLabel", "", "Total nutrient amounts for the whole meal, product, serving, etc.", 0, java.lang.Integer.MAX_VALUE, ingredientLabel));
1886        children.add(new Property("subject", "Reference(Patient|Group)", "The person, animal or group who is/was consuming the food or fluid.", 0, 1, subject));
1887        children.add(new Property("encounter", "Reference(Encounter)", "The encounter that establishes the context for this NutritionIntake.", 0, 1, encounter));
1888        children.add(new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.", 0, 1, effective));
1889        children.add(new Property("dateAsserted", "dateTime", "The date when the Nutrition Intake was asserted by the information source.", 0, 1, dateAsserted));
1890        children.add(new Property("informationSource", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "The person or organization that provided the information about the consumption of this food or fluid. Note: Use derivedFrom when a NutritionIntake is derived from other resources.", 0, 1, informationSource));
1891        children.add(new Property("derivedFrom", "Reference(Any)", "Allows linking the NutritionIntake to the underlying NutritionOrder, or to other information, such as AllergyIntolerance, that supports or is used to derive the NutritionIntake.", 0, java.lang.Integer.MAX_VALUE, derivedFrom));
1892        children.add(new Property("reasonCode", "CodeableConcept", "A reason for why the food or fluid is /was consumed.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
1893        children.add(new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport)", "Condition or observation that supports why the food or fluid is /was consumed.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
1894        children.add(new Property("note", "Annotation", "Provides extra information about the Nutrition Intake that is not conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note));
1895      }
1896
1897      @Override
1898      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1899        switch (_hash) {
1900        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Identifiers associated with this Nutrition Intake that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. They are business identifiers assigned to this resource by the performer or other systems and remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier);
1901        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(NutritionOrder|CarePlan|ServiceRequest)", "A plan, proposal or order that is fulfilled in whole or in part by this event.", 0, java.lang.Integer.MAX_VALUE, basedOn);
1902        case -995410646: /*partOf*/  return new Property("partOf", "Reference(NutritionIntake|Procedure|Observation)", "A larger event of which this particular event is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf);
1903        case -892481550: /*status*/  return new Property("status", "code", "A code representing the patient or other source's judgment about the state of the intake that this assertion is about.  Generally, this will be active or completed.", 0, 1, status);
1904        case 2051346646: /*statusReason*/  return new Property("statusReason", "CodeableConcept", "Captures the reason for the current state of the NutritionIntake.", 0, java.lang.Integer.MAX_VALUE, statusReason);
1905        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Indicates where the food or fluid was  consumed or prescribed.", 0, java.lang.Integer.MAX_VALUE, category);
1906        case -854114533: /*consumedItem*/  return new Property("consumedItem", "", "What food or fluid product or item was consumed.", 0, java.lang.Integer.MAX_VALUE, consumedItem);
1907        case -936536157: /*ingredientLabel*/  return new Property("ingredientLabel", "", "Total nutrient amounts for the whole meal, product, serving, etc.", 0, java.lang.Integer.MAX_VALUE, ingredientLabel);
1908        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "The person, animal or group who is/was consuming the food or fluid.", 0, 1, subject);
1909        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The encounter that establishes the context for this NutritionIntake.", 0, 1, encounter);
1910        case 247104889: /*effective[x]*/  return new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.", 0, 1, effective);
1911        case -1468651097: /*effective*/  return new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.", 0, 1, effective);
1912        case -275306910: /*effectiveDateTime*/  return new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.", 0, 1, effective);
1913        case -403934648: /*effectivePeriod*/  return new Property("effective[x]", "dateTime|Period", "The interval of time during which it is being asserted that the patient is/was consuming the food or fluid.", 0, 1, effective);
1914        case -1980855245: /*dateAsserted*/  return new Property("dateAsserted", "dateTime", "The date when the Nutrition Intake was asserted by the information source.", 0, 1, dateAsserted);
1915        case -2123220889: /*informationSource*/  return new Property("informationSource", "Reference(Patient|Practitioner|PractitionerRole|RelatedPerson|Organization)", "The person or organization that provided the information about the consumption of this food or fluid. Note: Use derivedFrom when a NutritionIntake is derived from other resources.", 0, 1, informationSource);
1916        case 1077922663: /*derivedFrom*/  return new Property("derivedFrom", "Reference(Any)", "Allows linking the NutritionIntake to the underlying NutritionOrder, or to other information, such as AllergyIntolerance, that supports or is used to derive the NutritionIntake.", 0, java.lang.Integer.MAX_VALUE, derivedFrom);
1917        case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "A reason for why the food or fluid is /was consumed.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
1918        case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport)", "Condition or observation that supports why the food or fluid is /was consumed.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
1919        case 3387378: /*note*/  return new Property("note", "Annotation", "Provides extra information about the Nutrition Intake that is not conveyed by the other attributes.", 0, java.lang.Integer.MAX_VALUE, note);
1920        default: return super.getNamedProperty(_hash, _name, _checkValid);
1921        }
1922
1923      }
1924
1925      @Override
1926      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1927        switch (hash) {
1928        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1929        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
1930        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
1931        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<NutritionIntakeStatus>
1932        case 2051346646: /*statusReason*/ return this.statusReason == null ? new Base[0] : this.statusReason.toArray(new Base[this.statusReason.size()]); // CodeableConcept
1933        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
1934        case -854114533: /*consumedItem*/ return this.consumedItem == null ? new Base[0] : this.consumedItem.toArray(new Base[this.consumedItem.size()]); // NutritionIntakeConsumedItemComponent
1935        case -936536157: /*ingredientLabel*/ return this.ingredientLabel == null ? new Base[0] : this.ingredientLabel.toArray(new Base[this.ingredientLabel.size()]); // NutritionIntakeIngredientLabelComponent
1936        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1937        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
1938        case -1468651097: /*effective*/ return this.effective == null ? new Base[0] : new Base[] {this.effective}; // Type
1939        case -1980855245: /*dateAsserted*/ return this.dateAsserted == null ? new Base[0] : new Base[] {this.dateAsserted}; // DateTimeType
1940        case -2123220889: /*informationSource*/ return this.informationSource == null ? new Base[0] : new Base[] {this.informationSource}; // Reference
1941        case 1077922663: /*derivedFrom*/ return this.derivedFrom == null ? new Base[0] : this.derivedFrom.toArray(new Base[this.derivedFrom.size()]); // Reference
1942        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
1943        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
1944        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1945        default: return super.getProperty(hash, name, checkValid);
1946        }
1947
1948      }
1949
1950      @Override
1951      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1952        switch (hash) {
1953        case -1618432855: // identifier
1954          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1955          return value;
1956        case -332612366: // basedOn
1957          this.getBasedOn().add(castToReference(value)); // Reference
1958          return value;
1959        case -995410646: // partOf
1960          this.getPartOf().add(castToReference(value)); // Reference
1961          return value;
1962        case -892481550: // status
1963          value = new NutritionIntakeStatusEnumFactory().fromType(castToCode(value));
1964          this.status = (Enumeration) value; // Enumeration<NutritionIntakeStatus>
1965          return value;
1966        case 2051346646: // statusReason
1967          this.getStatusReason().add(castToCodeableConcept(value)); // CodeableConcept
1968          return value;
1969        case 50511102: // category
1970          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
1971          return value;
1972        case -854114533: // consumedItem
1973          this.getConsumedItem().add((NutritionIntakeConsumedItemComponent) value); // NutritionIntakeConsumedItemComponent
1974          return value;
1975        case -936536157: // ingredientLabel
1976          this.getIngredientLabel().add((NutritionIntakeIngredientLabelComponent) value); // NutritionIntakeIngredientLabelComponent
1977          return value;
1978        case -1867885268: // subject
1979          this.subject = castToReference(value); // Reference
1980          return value;
1981        case 1524132147: // encounter
1982          this.encounter = castToReference(value); // Reference
1983          return value;
1984        case -1468651097: // effective
1985          this.effective = castToType(value); // Type
1986          return value;
1987        case -1980855245: // dateAsserted
1988          this.dateAsserted = castToDateTime(value); // DateTimeType
1989          return value;
1990        case -2123220889: // informationSource
1991          this.informationSource = castToReference(value); // Reference
1992          return value;
1993        case 1077922663: // derivedFrom
1994          this.getDerivedFrom().add(castToReference(value)); // Reference
1995          return value;
1996        case 722137681: // reasonCode
1997          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
1998          return value;
1999        case -1146218137: // reasonReference
2000          this.getReasonReference().add(castToReference(value)); // Reference
2001          return value;
2002        case 3387378: // note
2003          this.getNote().add(castToAnnotation(value)); // Annotation
2004          return value;
2005        default: return super.setProperty(hash, name, value);
2006        }
2007
2008      }
2009
2010      @Override
2011      public Base setProperty(String name, Base value) throws FHIRException {
2012        if (name.equals("identifier")) {
2013          this.getIdentifier().add(castToIdentifier(value));
2014        } else if (name.equals("basedOn")) {
2015          this.getBasedOn().add(castToReference(value));
2016        } else if (name.equals("partOf")) {
2017          this.getPartOf().add(castToReference(value));
2018        } else if (name.equals("status")) {
2019          value = new NutritionIntakeStatusEnumFactory().fromType(castToCode(value));
2020          this.status = (Enumeration) value; // Enumeration<NutritionIntakeStatus>
2021        } else if (name.equals("statusReason")) {
2022          this.getStatusReason().add(castToCodeableConcept(value));
2023        } else if (name.equals("category")) {
2024          this.getCategory().add(castToCodeableConcept(value));
2025        } else if (name.equals("consumedItem")) {
2026          this.getConsumedItem().add((NutritionIntakeConsumedItemComponent) value);
2027        } else if (name.equals("ingredientLabel")) {
2028          this.getIngredientLabel().add((NutritionIntakeIngredientLabelComponent) value);
2029        } else if (name.equals("subject")) {
2030          this.subject = castToReference(value); // Reference
2031        } else if (name.equals("encounter")) {
2032          this.encounter = castToReference(value); // Reference
2033        } else if (name.equals("effective[x]")) {
2034          this.effective = castToType(value); // Type
2035        } else if (name.equals("dateAsserted")) {
2036          this.dateAsserted = castToDateTime(value); // DateTimeType
2037        } else if (name.equals("informationSource")) {
2038          this.informationSource = castToReference(value); // Reference
2039        } else if (name.equals("derivedFrom")) {
2040          this.getDerivedFrom().add(castToReference(value));
2041        } else if (name.equals("reasonCode")) {
2042          this.getReasonCode().add(castToCodeableConcept(value));
2043        } else if (name.equals("reasonReference")) {
2044          this.getReasonReference().add(castToReference(value));
2045        } else if (name.equals("note")) {
2046          this.getNote().add(castToAnnotation(value));
2047        } else
2048          return super.setProperty(name, value);
2049        return value;
2050      }
2051
2052      @Override
2053      public Base makeProperty(int hash, String name) throws FHIRException {
2054        switch (hash) {
2055        case -1618432855:  return addIdentifier(); 
2056        case -332612366:  return addBasedOn(); 
2057        case -995410646:  return addPartOf(); 
2058        case -892481550:  return getStatusElement();
2059        case 2051346646:  return addStatusReason(); 
2060        case 50511102:  return addCategory(); 
2061        case -854114533:  return addConsumedItem(); 
2062        case -936536157:  return addIngredientLabel(); 
2063        case -1867885268:  return getSubject();
2064        case 1524132147:  return getEncounter();
2065        case 247104889:  return getEffective();
2066        case -1468651097:  return getEffective();
2067        case -1980855245:  return getDateAssertedElement();
2068        case -2123220889:  return getInformationSource();
2069        case 1077922663:  return addDerivedFrom(); 
2070        case 722137681:  return addReasonCode(); 
2071        case -1146218137:  return addReasonReference(); 
2072        case 3387378:  return addNote(); 
2073        default: return super.makeProperty(hash, name);
2074        }
2075
2076      }
2077
2078      @Override
2079      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2080        switch (hash) {
2081        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2082        case -332612366: /*basedOn*/ return new String[] {"Reference"};
2083        case -995410646: /*partOf*/ return new String[] {"Reference"};
2084        case -892481550: /*status*/ return new String[] {"code"};
2085        case 2051346646: /*statusReason*/ return new String[] {"CodeableConcept"};
2086        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
2087        case -854114533: /*consumedItem*/ return new String[] {};
2088        case -936536157: /*ingredientLabel*/ return new String[] {};
2089        case -1867885268: /*subject*/ return new String[] {"Reference"};
2090        case 1524132147: /*encounter*/ return new String[] {"Reference"};
2091        case -1468651097: /*effective*/ return new String[] {"dateTime", "Period"};
2092        case -1980855245: /*dateAsserted*/ return new String[] {"dateTime"};
2093        case -2123220889: /*informationSource*/ return new String[] {"Reference"};
2094        case 1077922663: /*derivedFrom*/ return new String[] {"Reference"};
2095        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2096        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2097        case 3387378: /*note*/ return new String[] {"Annotation"};
2098        default: return super.getTypesForProperty(hash, name);
2099        }
2100
2101      }
2102
2103      @Override
2104      public Base addChild(String name) throws FHIRException {
2105        if (name.equals("identifier")) {
2106          return addIdentifier();
2107        }
2108        else if (name.equals("basedOn")) {
2109          return addBasedOn();
2110        }
2111        else if (name.equals("partOf")) {
2112          return addPartOf();
2113        }
2114        else if (name.equals("status")) {
2115          throw new FHIRException("Cannot call addChild on a primitive type NutritionIntake.status");
2116        }
2117        else if (name.equals("statusReason")) {
2118          return addStatusReason();
2119        }
2120        else if (name.equals("category")) {
2121          return addCategory();
2122        }
2123        else if (name.equals("consumedItem")) {
2124          return addConsumedItem();
2125        }
2126        else if (name.equals("ingredientLabel")) {
2127          return addIngredientLabel();
2128        }
2129        else if (name.equals("subject")) {
2130          this.subject = new Reference();
2131          return this.subject;
2132        }
2133        else if (name.equals("encounter")) {
2134          this.encounter = new Reference();
2135          return this.encounter;
2136        }
2137        else if (name.equals("effectiveDateTime")) {
2138          this.effective = new DateTimeType();
2139          return this.effective;
2140        }
2141        else if (name.equals("effectivePeriod")) {
2142          this.effective = new Period();
2143          return this.effective;
2144        }
2145        else if (name.equals("dateAsserted")) {
2146          throw new FHIRException("Cannot call addChild on a primitive type NutritionIntake.dateAsserted");
2147        }
2148        else if (name.equals("informationSource")) {
2149          this.informationSource = new Reference();
2150          return this.informationSource;
2151        }
2152        else if (name.equals("derivedFrom")) {
2153          return addDerivedFrom();
2154        }
2155        else if (name.equals("reasonCode")) {
2156          return addReasonCode();
2157        }
2158        else if (name.equals("reasonReference")) {
2159          return addReasonReference();
2160        }
2161        else if (name.equals("note")) {
2162          return addNote();
2163        }
2164        else
2165          return super.addChild(name);
2166      }
2167
2168  public String fhirType() {
2169    return "NutritionIntake";
2170
2171  }
2172
2173      public NutritionIntake copy() {
2174        NutritionIntake dst = new NutritionIntake();
2175        copyValues(dst);
2176        return dst;
2177      }
2178
2179      public void copyValues(NutritionIntake dst) {
2180        super.copyValues(dst);
2181        if (identifier != null) {
2182          dst.identifier = new ArrayList<Identifier>();
2183          for (Identifier i : identifier)
2184            dst.identifier.add(i.copy());
2185        };
2186        if (basedOn != null) {
2187          dst.basedOn = new ArrayList<Reference>();
2188          for (Reference i : basedOn)
2189            dst.basedOn.add(i.copy());
2190        };
2191        if (partOf != null) {
2192          dst.partOf = new ArrayList<Reference>();
2193          for (Reference i : partOf)
2194            dst.partOf.add(i.copy());
2195        };
2196        dst.status = status == null ? null : status.copy();
2197        if (statusReason != null) {
2198          dst.statusReason = new ArrayList<CodeableConcept>();
2199          for (CodeableConcept i : statusReason)
2200            dst.statusReason.add(i.copy());
2201        };
2202        if (category != null) {
2203          dst.category = new ArrayList<CodeableConcept>();
2204          for (CodeableConcept i : category)
2205            dst.category.add(i.copy());
2206        };
2207        if (consumedItem != null) {
2208          dst.consumedItem = new ArrayList<NutritionIntakeConsumedItemComponent>();
2209          for (NutritionIntakeConsumedItemComponent i : consumedItem)
2210            dst.consumedItem.add(i.copy());
2211        };
2212        if (ingredientLabel != null) {
2213          dst.ingredientLabel = new ArrayList<NutritionIntakeIngredientLabelComponent>();
2214          for (NutritionIntakeIngredientLabelComponent i : ingredientLabel)
2215            dst.ingredientLabel.add(i.copy());
2216        };
2217        dst.subject = subject == null ? null : subject.copy();
2218        dst.encounter = encounter == null ? null : encounter.copy();
2219        dst.effective = effective == null ? null : effective.copy();
2220        dst.dateAsserted = dateAsserted == null ? null : dateAsserted.copy();
2221        dst.informationSource = informationSource == null ? null : informationSource.copy();
2222        if (derivedFrom != null) {
2223          dst.derivedFrom = new ArrayList<Reference>();
2224          for (Reference i : derivedFrom)
2225            dst.derivedFrom.add(i.copy());
2226        };
2227        if (reasonCode != null) {
2228          dst.reasonCode = new ArrayList<CodeableConcept>();
2229          for (CodeableConcept i : reasonCode)
2230            dst.reasonCode.add(i.copy());
2231        };
2232        if (reasonReference != null) {
2233          dst.reasonReference = new ArrayList<Reference>();
2234          for (Reference i : reasonReference)
2235            dst.reasonReference.add(i.copy());
2236        };
2237        if (note != null) {
2238          dst.note = new ArrayList<Annotation>();
2239          for (Annotation i : note)
2240            dst.note.add(i.copy());
2241        };
2242      }
2243
2244      protected NutritionIntake typedCopy() {
2245        return copy();
2246      }
2247
2248      @Override
2249      public boolean equalsDeep(Base other_) {
2250        if (!super.equalsDeep(other_))
2251          return false;
2252        if (!(other_ instanceof NutritionIntake))
2253          return false;
2254        NutritionIntake o = (NutritionIntake) other_;
2255        return compareDeep(identifier, o.identifier, true) && compareDeep(basedOn, o.basedOn, true) && compareDeep(partOf, o.partOf, true)
2256           && compareDeep(status, o.status, true) && compareDeep(statusReason, o.statusReason, true) && compareDeep(category, o.category, true)
2257           && compareDeep(consumedItem, o.consumedItem, true) && compareDeep(ingredientLabel, o.ingredientLabel, true)
2258           && compareDeep(subject, o.subject, true) && compareDeep(encounter, o.encounter, true) && compareDeep(effective, o.effective, true)
2259           && compareDeep(dateAsserted, o.dateAsserted, true) && compareDeep(informationSource, o.informationSource, true)
2260           && compareDeep(derivedFrom, o.derivedFrom, true) && compareDeep(reasonCode, o.reasonCode, true)
2261           && compareDeep(reasonReference, o.reasonReference, true) && compareDeep(note, o.note, true);
2262      }
2263
2264      @Override
2265      public boolean equalsShallow(Base other_) {
2266        if (!super.equalsShallow(other_))
2267          return false;
2268        if (!(other_ instanceof NutritionIntake))
2269          return false;
2270        NutritionIntake o = (NutritionIntake) other_;
2271        return compareValues(status, o.status, true) && compareValues(dateAsserted, o.dateAsserted, true);
2272      }
2273
2274      public boolean isEmpty() {
2275        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, basedOn, partOf
2276          , status, statusReason, category, consumedItem, ingredientLabel, subject, encounter
2277          , effective, dateAsserted, informationSource, derivedFrom, reasonCode, reasonReference
2278          , note);
2279      }
2280
2281  @Override
2282  public ResourceType getResourceType() {
2283    return ResourceType.NutritionIntake;
2284   }
2285
2286 /**
2287   * Search parameter: <b>identifier</b>
2288   * <p>
2289   * Description: <b>Return statements with this external identifier</b><br>
2290   * Type: <b>token</b><br>
2291   * Path: <b>NutritionIntake.identifier</b><br>
2292   * </p>
2293   */
2294  @SearchParamDefinition(name="identifier", path="NutritionIntake.identifier", description="Return statements with this external identifier", type="token" )
2295  public static final String SP_IDENTIFIER = "identifier";
2296 /**
2297   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2298   * <p>
2299   * Description: <b>Return statements with this external identifier</b><br>
2300   * Type: <b>token</b><br>
2301   * Path: <b>NutritionIntake.identifier</b><br>
2302   * </p>
2303   */
2304  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2305
2306 /**
2307   * Search parameter: <b>effective</b>
2308   * <p>
2309   * Description: <b>Date when patient was taking (or not taking) the medication</b><br>
2310   * Type: <b>date</b><br>
2311   * Path: <b>NutritionIntake.effective[x]</b><br>
2312   * </p>
2313   */
2314  @SearchParamDefinition(name="effective", path="NutritionIntake.effective", description="Date when patient was taking (or not taking) the medication", type="date" )
2315  public static final String SP_EFFECTIVE = "effective";
2316 /**
2317   * <b>Fluent Client</b> search parameter constant for <b>effective</b>
2318   * <p>
2319   * Description: <b>Date when patient was taking (or not taking) the medication</b><br>
2320   * Type: <b>date</b><br>
2321   * Path: <b>NutritionIntake.effective[x]</b><br>
2322   * </p>
2323   */
2324  public static final ca.uhn.fhir.rest.gclient.DateClientParam EFFECTIVE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_EFFECTIVE);
2325
2326 /**
2327   * Search parameter: <b>nutrition</b>
2328   * <p>
2329   * Description: <b>Return statements of this medication reference</b><br>
2330   * Type: <b>token</b><br>
2331   * Path: <b>NutritionIntake.consumedItem.nutritionProduct</b><br>
2332   * </p>
2333   */
2334  @SearchParamDefinition(name="nutrition", path="NutritionIntake.consumedItem.nutritionProduct", description="Return statements of this medication reference", type="token" )
2335  public static final String SP_NUTRITION = "nutrition";
2336 /**
2337   * <b>Fluent Client</b> search parameter constant for <b>nutrition</b>
2338   * <p>
2339   * Description: <b>Return statements of this medication reference</b><br>
2340   * Type: <b>token</b><br>
2341   * Path: <b>NutritionIntake.consumedItem.nutritionProduct</b><br>
2342   * </p>
2343   */
2344  public static final ca.uhn.fhir.rest.gclient.TokenClientParam NUTRITION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_NUTRITION);
2345
2346 /**
2347   * Search parameter: <b>subject</b>
2348   * <p>
2349   * Description: <b>The identity of a patient, animal or group to list statements for</b><br>
2350   * Type: <b>reference</b><br>
2351   * Path: <b>NutritionIntake.subject</b><br>
2352   * </p>
2353   */
2354  @SearchParamDefinition(name="subject", path="NutritionIntake.subject", description="The identity of a patient, animal or group to list statements for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Group.class, Patient.class } )
2355  public static final String SP_SUBJECT = "subject";
2356 /**
2357   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
2358   * <p>
2359   * Description: <b>The identity of a patient, animal or group to list statements for</b><br>
2360   * Type: <b>reference</b><br>
2361   * Path: <b>NutritionIntake.subject</b><br>
2362   * </p>
2363   */
2364  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
2365
2366/**
2367   * Constant for fluent queries to be used to add include statements. Specifies
2368   * the path value of "<b>NutritionIntake:subject</b>".
2369   */
2370  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("NutritionIntake:subject").toLocked();
2371
2372 /**
2373   * Search parameter: <b>patient</b>
2374   * <p>
2375   * Description: <b>Returns statements for a specific patient.</b><br>
2376   * Type: <b>reference</b><br>
2377   * Path: <b>NutritionIntake.subject</b><br>
2378   * </p>
2379   */
2380  @SearchParamDefinition(name="patient", path="NutritionIntake.subject.where(resolve() is Patient)", description="Returns statements for a specific patient.", type="reference", target={Patient.class } )
2381  public static final String SP_PATIENT = "patient";
2382 /**
2383   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2384   * <p>
2385   * Description: <b>Returns statements for a specific patient.</b><br>
2386   * Type: <b>reference</b><br>
2387   * Path: <b>NutritionIntake.subject</b><br>
2388   * </p>
2389   */
2390  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2391
2392/**
2393   * Constant for fluent queries to be used to add include statements. Specifies
2394   * the path value of "<b>NutritionIntake:patient</b>".
2395   */
2396  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("NutritionIntake:patient").toLocked();
2397
2398 /**
2399   * Search parameter: <b>part-of</b>
2400   * <p>
2401   * Description: <b>Returns statements that are part of another event.</b><br>
2402   * Type: <b>reference</b><br>
2403   * Path: <b>NutritionIntake.partOf</b><br>
2404   * </p>
2405   */
2406  @SearchParamDefinition(name="part-of", path="NutritionIntake.partOf", description="Returns statements that are part of another event.", type="reference", target={NutritionIntake.class, Observation.class, Procedure.class } )
2407  public static final String SP_PART_OF = "part-of";
2408 /**
2409   * <b>Fluent Client</b> search parameter constant for <b>part-of</b>
2410   * <p>
2411   * Description: <b>Returns statements that are part of another event.</b><br>
2412   * Type: <b>reference</b><br>
2413   * Path: <b>NutritionIntake.partOf</b><br>
2414   * </p>
2415   */
2416  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PART_OF = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PART_OF);
2417
2418/**
2419   * Constant for fluent queries to be used to add include statements. Specifies
2420   * the path value of "<b>NutritionIntake:part-of</b>".
2421   */
2422  public static final ca.uhn.fhir.model.api.Include INCLUDE_PART_OF = new ca.uhn.fhir.model.api.Include("NutritionIntake:part-of").toLocked();
2423
2424 /**
2425   * Search parameter: <b>source</b>
2426   * <p>
2427   * Description: <b>Who or where the information in the statement came from</b><br>
2428   * Type: <b>reference</b><br>
2429   * Path: <b>NutritionIntake.informationSource</b><br>
2430   * </p>
2431   */
2432  @SearchParamDefinition(name="source", path="NutritionIntake.informationSource", description="Who or where the information in the statement came from", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
2433  public static final String SP_SOURCE = "source";
2434 /**
2435   * <b>Fluent Client</b> search parameter constant for <b>source</b>
2436   * <p>
2437   * Description: <b>Who or where the information in the statement came from</b><br>
2438   * Type: <b>reference</b><br>
2439   * Path: <b>NutritionIntake.informationSource</b><br>
2440   * </p>
2441   */
2442  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SOURCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SOURCE);
2443
2444/**
2445   * Constant for fluent queries to be used to add include statements. Specifies
2446   * the path value of "<b>NutritionIntake:source</b>".
2447   */
2448  public static final ca.uhn.fhir.model.api.Include INCLUDE_SOURCE = new ca.uhn.fhir.model.api.Include("NutritionIntake:source").toLocked();
2449
2450 /**
2451   * Search parameter: <b>encounter</b>
2452   * <p>
2453   * Description: <b>Returns statements for a specific encounter</b><br>
2454   * Type: <b>reference</b><br>
2455   * Path: <b>NutritionIntake.encounter</b><br>
2456   * </p>
2457   */
2458  @SearchParamDefinition(name="encounter", path="NutritionIntake.encounter", description="Returns statements for a specific encounter", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
2459  public static final String SP_ENCOUNTER = "encounter";
2460 /**
2461   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
2462   * <p>
2463   * Description: <b>Returns statements for a specific encounter</b><br>
2464   * Type: <b>reference</b><br>
2465   * Path: <b>NutritionIntake.encounter</b><br>
2466   * </p>
2467   */
2468  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
2469
2470/**
2471   * Constant for fluent queries to be used to add include statements. Specifies
2472   * the path value of "<b>NutritionIntake:encounter</b>".
2473   */
2474  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("NutritionIntake:encounter").toLocked();
2475
2476 /**
2477   * Search parameter: <b>category</b>
2478   * <p>
2479   * Description: <b>Returns statements of this category of NutritionIntake</b><br>
2480   * Type: <b>token</b><br>
2481   * Path: <b>NutritionIntake.category</b><br>
2482   * </p>
2483   */
2484  @SearchParamDefinition(name="category", path="NutritionIntake.category", description="Returns statements of this category of NutritionIntake", type="token" )
2485  public static final String SP_CATEGORY = "category";
2486 /**
2487   * <b>Fluent Client</b> search parameter constant for <b>category</b>
2488   * <p>
2489   * Description: <b>Returns statements of this category of NutritionIntake</b><br>
2490   * Type: <b>token</b><br>
2491   * Path: <b>NutritionIntake.category</b><br>
2492   * </p>
2493   */
2494  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
2495
2496 /**
2497   * Search parameter: <b>status</b>
2498   * <p>
2499   * Description: <b>Return statements that match the given status</b><br>
2500   * Type: <b>token</b><br>
2501   * Path: <b>NutritionIntake.status</b><br>
2502   * </p>
2503   */
2504  @SearchParamDefinition(name="status", path="NutritionIntake.status", description="Return statements that match the given status", type="token" )
2505  public static final String SP_STATUS = "status";
2506 /**
2507   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2508   * <p>
2509   * Description: <b>Return statements that match the given status</b><br>
2510   * Type: <b>token</b><br>
2511   * Path: <b>NutritionIntake.status</b><br>
2512   * </p>
2513   */
2514  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2515
2516
2517}
2518