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