001package org.hl7.fhir.dstu2.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
046import org.hl7.fhir.exceptions.FHIRException;
047import org.hl7.fhir.utilities.Utilities;
048/**
049 * A request to supply a diet, formula feeding (enteral) or oral nutritional supplement to a patient/resident.
050 */
051@ResourceDef(name="NutritionOrder", profile="http://hl7.org/fhir/Profile/NutritionOrder")
052public class NutritionOrder extends DomainResource {
053
054    public enum NutritionOrderStatus {
055        /**
056         * The request has been proposed.
057         */
058        PROPOSED, 
059        /**
060         * The request is in preliminary form prior to being sent.
061         */
062        DRAFT, 
063        /**
064         * The request has been planned.
065         */
066        PLANNED, 
067        /**
068         * The request has been placed.
069         */
070        REQUESTED, 
071        /**
072         * The request is 'actionable', but not all actions that are implied by it have occurred yet.
073         */
074        ACTIVE, 
075        /**
076         * Actions implied by the request have been temporarily halted, but are expected to continue later. May also be called "suspended".
077         */
078        ONHOLD, 
079        /**
080         * All actions that are implied by the order have occurred and no continuation is planned (this will rarely be made explicit).
081         */
082        COMPLETED, 
083        /**
084         * The request has been withdrawn and is no longer actionable.
085         */
086        CANCELLED, 
087        /**
088         * added to help the parsers
089         */
090        NULL;
091        public static NutritionOrderStatus fromCode(String codeString) throws FHIRException {
092            if (codeString == null || "".equals(codeString))
093                return null;
094        if ("proposed".equals(codeString))
095          return PROPOSED;
096        if ("draft".equals(codeString))
097          return DRAFT;
098        if ("planned".equals(codeString))
099          return PLANNED;
100        if ("requested".equals(codeString))
101          return REQUESTED;
102        if ("active".equals(codeString))
103          return ACTIVE;
104        if ("on-hold".equals(codeString))
105          return ONHOLD;
106        if ("completed".equals(codeString))
107          return COMPLETED;
108        if ("cancelled".equals(codeString))
109          return CANCELLED;
110        throw new FHIRException("Unknown NutritionOrderStatus code '"+codeString+"'");
111        }
112        public String toCode() {
113          switch (this) {
114            case PROPOSED: return "proposed";
115            case DRAFT: return "draft";
116            case PLANNED: return "planned";
117            case REQUESTED: return "requested";
118            case ACTIVE: return "active";
119            case ONHOLD: return "on-hold";
120            case COMPLETED: return "completed";
121            case CANCELLED: return "cancelled";
122            case NULL: return null;
123            default: return "?";
124          }
125        }
126        public String getSystem() {
127          switch (this) {
128            case PROPOSED: return "http://hl7.org/fhir/nutrition-order-status";
129            case DRAFT: return "http://hl7.org/fhir/nutrition-order-status";
130            case PLANNED: return "http://hl7.org/fhir/nutrition-order-status";
131            case REQUESTED: return "http://hl7.org/fhir/nutrition-order-status";
132            case ACTIVE: return "http://hl7.org/fhir/nutrition-order-status";
133            case ONHOLD: return "http://hl7.org/fhir/nutrition-order-status";
134            case COMPLETED: return "http://hl7.org/fhir/nutrition-order-status";
135            case CANCELLED: return "http://hl7.org/fhir/nutrition-order-status";
136            case NULL: return null;
137            default: return "?";
138          }
139        }
140        public String getDefinition() {
141          switch (this) {
142            case PROPOSED: return "The request has been proposed.";
143            case DRAFT: return "The request is in preliminary form prior to being sent.";
144            case PLANNED: return "The request has been planned.";
145            case REQUESTED: return "The request has been placed.";
146            case ACTIVE: return "The request is 'actionable', but not all actions that are implied by it have occurred yet.";
147            case ONHOLD: return "Actions implied by the request have been temporarily halted, but are expected to continue later. May also be called \"suspended\".";
148            case COMPLETED: return "All actions that are implied by the order have occurred and no continuation is planned (this will rarely be made explicit).";
149            case CANCELLED: return "The request has been withdrawn and is no longer actionable.";
150            case NULL: return null;
151            default: return "?";
152          }
153        }
154        public String getDisplay() {
155          switch (this) {
156            case PROPOSED: return "Proposed";
157            case DRAFT: return "Draft";
158            case PLANNED: return "Planned";
159            case REQUESTED: return "Requested";
160            case ACTIVE: return "Active";
161            case ONHOLD: return "On-Hold";
162            case COMPLETED: return "Completed";
163            case CANCELLED: return "Cancelled";
164            case NULL: return null;
165            default: return "?";
166          }
167        }
168    }
169
170  public static class NutritionOrderStatusEnumFactory implements EnumFactory<NutritionOrderStatus> {
171    public NutritionOrderStatus fromCode(String codeString) throws IllegalArgumentException {
172      if (codeString == null || "".equals(codeString))
173            if (codeString == null || "".equals(codeString))
174                return null;
175        if ("proposed".equals(codeString))
176          return NutritionOrderStatus.PROPOSED;
177        if ("draft".equals(codeString))
178          return NutritionOrderStatus.DRAFT;
179        if ("planned".equals(codeString))
180          return NutritionOrderStatus.PLANNED;
181        if ("requested".equals(codeString))
182          return NutritionOrderStatus.REQUESTED;
183        if ("active".equals(codeString))
184          return NutritionOrderStatus.ACTIVE;
185        if ("on-hold".equals(codeString))
186          return NutritionOrderStatus.ONHOLD;
187        if ("completed".equals(codeString))
188          return NutritionOrderStatus.COMPLETED;
189        if ("cancelled".equals(codeString))
190          return NutritionOrderStatus.CANCELLED;
191        throw new IllegalArgumentException("Unknown NutritionOrderStatus code '"+codeString+"'");
192        }
193        public Enumeration<NutritionOrderStatus> fromType(Base code) throws FHIRException {
194          if (code == null || code.isEmpty())
195            return null;
196          String codeString = ((PrimitiveType) code).asStringValue();
197          if (codeString == null || "".equals(codeString))
198            return null;
199        if ("proposed".equals(codeString))
200          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.PROPOSED);
201        if ("draft".equals(codeString))
202          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.DRAFT);
203        if ("planned".equals(codeString))
204          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.PLANNED);
205        if ("requested".equals(codeString))
206          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.REQUESTED);
207        if ("active".equals(codeString))
208          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.ACTIVE);
209        if ("on-hold".equals(codeString))
210          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.ONHOLD);
211        if ("completed".equals(codeString))
212          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.COMPLETED);
213        if ("cancelled".equals(codeString))
214          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.CANCELLED);
215        throw new FHIRException("Unknown NutritionOrderStatus code '"+codeString+"'");
216        }
217    public String toCode(NutritionOrderStatus code) {
218      if (code == NutritionOrderStatus.PROPOSED)
219        return "proposed";
220      if (code == NutritionOrderStatus.DRAFT)
221        return "draft";
222      if (code == NutritionOrderStatus.PLANNED)
223        return "planned";
224      if (code == NutritionOrderStatus.REQUESTED)
225        return "requested";
226      if (code == NutritionOrderStatus.ACTIVE)
227        return "active";
228      if (code == NutritionOrderStatus.ONHOLD)
229        return "on-hold";
230      if (code == NutritionOrderStatus.COMPLETED)
231        return "completed";
232      if (code == NutritionOrderStatus.CANCELLED)
233        return "cancelled";
234      return "?";
235      }
236    }
237
238    @Block()
239    public static class NutritionOrderOralDietComponent extends BackboneElement implements IBaseBackboneElement {
240        /**
241         * The kind of diet or dietary restriction such as fiber restricted diet or diabetic diet.
242         */
243        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
244        @Description(shortDefinition="Type of oral diet or diet restrictions that describe what can be consumed orally", formalDefinition="The kind of diet or dietary restriction such as fiber restricted diet or diabetic diet." )
245        protected List<CodeableConcept> type;
246
247        /**
248         * The time period and frequency at which the diet should be given.
249         */
250        @Child(name = "schedule", type = {Timing.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
251        @Description(shortDefinition="Scheduled frequency of diet", formalDefinition="The time period and frequency at which the diet should be given." )
252        protected List<Timing> schedule;
253
254        /**
255         * Class that defines the quantity and type of nutrient modifications required for the oral diet.
256         */
257        @Child(name = "nutrient", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
258        @Description(shortDefinition="Required  nutrient modifications", formalDefinition="Class that defines the quantity and type of nutrient modifications required for the oral diet." )
259        protected List<NutritionOrderOralDietNutrientComponent> nutrient;
260
261        /**
262         * Class that describes any texture modifications required for the patient to safely consume various types of solid foods.
263         */
264        @Child(name = "texture", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
265        @Description(shortDefinition="Required  texture modifications", formalDefinition="Class that describes any texture modifications required for the patient to safely consume various types of solid foods." )
266        protected List<NutritionOrderOralDietTextureComponent> texture;
267
268        /**
269         * The required consistency (e.g. honey-thick, nectar-thick, thin, thickened.) of liquids or fluids served to the patient.
270         */
271        @Child(name = "fluidConsistencyType", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
272        @Description(shortDefinition="The required consistency of fluids and liquids provided to the patient", formalDefinition="The required consistency (e.g. honey-thick, nectar-thick, thin, thickened.) of liquids or fluids served to the patient." )
273        protected List<CodeableConcept> fluidConsistencyType;
274
275        /**
276         * Free text or additional instructions or information pertaining to the oral diet.
277         */
278        @Child(name = "instruction", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
279        @Description(shortDefinition="Instructions or additional information about the oral diet", formalDefinition="Free text or additional instructions or information pertaining to the oral diet." )
280        protected StringType instruction;
281
282        private static final long serialVersionUID = 973058412L;
283
284    /*
285     * Constructor
286     */
287      public NutritionOrderOralDietComponent() {
288        super();
289      }
290
291        /**
292         * @return {@link #type} (The kind of diet or dietary restriction such as fiber restricted diet or diabetic diet.)
293         */
294        public List<CodeableConcept> getType() { 
295          if (this.type == null)
296            this.type = new ArrayList<CodeableConcept>();
297          return this.type;
298        }
299
300        public boolean hasType() { 
301          if (this.type == null)
302            return false;
303          for (CodeableConcept item : this.type)
304            if (!item.isEmpty())
305              return true;
306          return false;
307        }
308
309        /**
310         * @return {@link #type} (The kind of diet or dietary restriction such as fiber restricted diet or diabetic diet.)
311         */
312    // syntactic sugar
313        public CodeableConcept addType() { //3
314          CodeableConcept t = new CodeableConcept();
315          if (this.type == null)
316            this.type = new ArrayList<CodeableConcept>();
317          this.type.add(t);
318          return t;
319        }
320
321    // syntactic sugar
322        public NutritionOrderOralDietComponent addType(CodeableConcept t) { //3
323          if (t == null)
324            return this;
325          if (this.type == null)
326            this.type = new ArrayList<CodeableConcept>();
327          this.type.add(t);
328          return this;
329        }
330
331        /**
332         * @return {@link #schedule} (The time period and frequency at which the diet should be given.)
333         */
334        public List<Timing> getSchedule() { 
335          if (this.schedule == null)
336            this.schedule = new ArrayList<Timing>();
337          return this.schedule;
338        }
339
340        public boolean hasSchedule() { 
341          if (this.schedule == null)
342            return false;
343          for (Timing item : this.schedule)
344            if (!item.isEmpty())
345              return true;
346          return false;
347        }
348
349        /**
350         * @return {@link #schedule} (The time period and frequency at which the diet should be given.)
351         */
352    // syntactic sugar
353        public Timing addSchedule() { //3
354          Timing t = new Timing();
355          if (this.schedule == null)
356            this.schedule = new ArrayList<Timing>();
357          this.schedule.add(t);
358          return t;
359        }
360
361    // syntactic sugar
362        public NutritionOrderOralDietComponent addSchedule(Timing t) { //3
363          if (t == null)
364            return this;
365          if (this.schedule == null)
366            this.schedule = new ArrayList<Timing>();
367          this.schedule.add(t);
368          return this;
369        }
370
371        /**
372         * @return {@link #nutrient} (Class that defines the quantity and type of nutrient modifications required for the oral diet.)
373         */
374        public List<NutritionOrderOralDietNutrientComponent> getNutrient() { 
375          if (this.nutrient == null)
376            this.nutrient = new ArrayList<NutritionOrderOralDietNutrientComponent>();
377          return this.nutrient;
378        }
379
380        public boolean hasNutrient() { 
381          if (this.nutrient == null)
382            return false;
383          for (NutritionOrderOralDietNutrientComponent item : this.nutrient)
384            if (!item.isEmpty())
385              return true;
386          return false;
387        }
388
389        /**
390         * @return {@link #nutrient} (Class that defines the quantity and type of nutrient modifications required for the oral diet.)
391         */
392    // syntactic sugar
393        public NutritionOrderOralDietNutrientComponent addNutrient() { //3
394          NutritionOrderOralDietNutrientComponent t = new NutritionOrderOralDietNutrientComponent();
395          if (this.nutrient == null)
396            this.nutrient = new ArrayList<NutritionOrderOralDietNutrientComponent>();
397          this.nutrient.add(t);
398          return t;
399        }
400
401    // syntactic sugar
402        public NutritionOrderOralDietComponent addNutrient(NutritionOrderOralDietNutrientComponent t) { //3
403          if (t == null)
404            return this;
405          if (this.nutrient == null)
406            this.nutrient = new ArrayList<NutritionOrderOralDietNutrientComponent>();
407          this.nutrient.add(t);
408          return this;
409        }
410
411        /**
412         * @return {@link #texture} (Class that describes any texture modifications required for the patient to safely consume various types of solid foods.)
413         */
414        public List<NutritionOrderOralDietTextureComponent> getTexture() { 
415          if (this.texture == null)
416            this.texture = new ArrayList<NutritionOrderOralDietTextureComponent>();
417          return this.texture;
418        }
419
420        public boolean hasTexture() { 
421          if (this.texture == null)
422            return false;
423          for (NutritionOrderOralDietTextureComponent item : this.texture)
424            if (!item.isEmpty())
425              return true;
426          return false;
427        }
428
429        /**
430         * @return {@link #texture} (Class that describes any texture modifications required for the patient to safely consume various types of solid foods.)
431         */
432    // syntactic sugar
433        public NutritionOrderOralDietTextureComponent addTexture() { //3
434          NutritionOrderOralDietTextureComponent t = new NutritionOrderOralDietTextureComponent();
435          if (this.texture == null)
436            this.texture = new ArrayList<NutritionOrderOralDietTextureComponent>();
437          this.texture.add(t);
438          return t;
439        }
440
441    // syntactic sugar
442        public NutritionOrderOralDietComponent addTexture(NutritionOrderOralDietTextureComponent t) { //3
443          if (t == null)
444            return this;
445          if (this.texture == null)
446            this.texture = new ArrayList<NutritionOrderOralDietTextureComponent>();
447          this.texture.add(t);
448          return this;
449        }
450
451        /**
452         * @return {@link #fluidConsistencyType} (The required consistency (e.g. honey-thick, nectar-thick, thin, thickened.) of liquids or fluids served to the patient.)
453         */
454        public List<CodeableConcept> getFluidConsistencyType() { 
455          if (this.fluidConsistencyType == null)
456            this.fluidConsistencyType = new ArrayList<CodeableConcept>();
457          return this.fluidConsistencyType;
458        }
459
460        public boolean hasFluidConsistencyType() { 
461          if (this.fluidConsistencyType == null)
462            return false;
463          for (CodeableConcept item : this.fluidConsistencyType)
464            if (!item.isEmpty())
465              return true;
466          return false;
467        }
468
469        /**
470         * @return {@link #fluidConsistencyType} (The required consistency (e.g. honey-thick, nectar-thick, thin, thickened.) of liquids or fluids served to the patient.)
471         */
472    // syntactic sugar
473        public CodeableConcept addFluidConsistencyType() { //3
474          CodeableConcept t = new CodeableConcept();
475          if (this.fluidConsistencyType == null)
476            this.fluidConsistencyType = new ArrayList<CodeableConcept>();
477          this.fluidConsistencyType.add(t);
478          return t;
479        }
480
481    // syntactic sugar
482        public NutritionOrderOralDietComponent addFluidConsistencyType(CodeableConcept t) { //3
483          if (t == null)
484            return this;
485          if (this.fluidConsistencyType == null)
486            this.fluidConsistencyType = new ArrayList<CodeableConcept>();
487          this.fluidConsistencyType.add(t);
488          return this;
489        }
490
491        /**
492         * @return {@link #instruction} (Free text or additional instructions or information pertaining to the oral diet.). This is the underlying object with id, value and extensions. The accessor "getInstruction" gives direct access to the value
493         */
494        public StringType getInstructionElement() { 
495          if (this.instruction == null)
496            if (Configuration.errorOnAutoCreate())
497              throw new Error("Attempt to auto-create NutritionOrderOralDietComponent.instruction");
498            else if (Configuration.doAutoCreate())
499              this.instruction = new StringType(); // bb
500          return this.instruction;
501        }
502
503        public boolean hasInstructionElement() { 
504          return this.instruction != null && !this.instruction.isEmpty();
505        }
506
507        public boolean hasInstruction() { 
508          return this.instruction != null && !this.instruction.isEmpty();
509        }
510
511        /**
512         * @param value {@link #instruction} (Free text or additional instructions or information pertaining to the oral diet.). This is the underlying object with id, value and extensions. The accessor "getInstruction" gives direct access to the value
513         */
514        public NutritionOrderOralDietComponent setInstructionElement(StringType value) { 
515          this.instruction = value;
516          return this;
517        }
518
519        /**
520         * @return Free text or additional instructions or information pertaining to the oral diet.
521         */
522        public String getInstruction() { 
523          return this.instruction == null ? null : this.instruction.getValue();
524        }
525
526        /**
527         * @param value Free text or additional instructions or information pertaining to the oral diet.
528         */
529        public NutritionOrderOralDietComponent setInstruction(String value) { 
530          if (Utilities.noString(value))
531            this.instruction = null;
532          else {
533            if (this.instruction == null)
534              this.instruction = new StringType();
535            this.instruction.setValue(value);
536          }
537          return this;
538        }
539
540        protected void listChildren(List<Property> childrenList) {
541          super.listChildren(childrenList);
542          childrenList.add(new Property("type", "CodeableConcept", "The kind of diet or dietary restriction such as fiber restricted diet or diabetic diet.", 0, java.lang.Integer.MAX_VALUE, type));
543          childrenList.add(new Property("schedule", "Timing", "The time period and frequency at which the diet should be given.", 0, java.lang.Integer.MAX_VALUE, schedule));
544          childrenList.add(new Property("nutrient", "", "Class that defines the quantity and type of nutrient modifications required for the oral diet.", 0, java.lang.Integer.MAX_VALUE, nutrient));
545          childrenList.add(new Property("texture", "", "Class that describes any texture modifications required for the patient to safely consume various types of solid foods.", 0, java.lang.Integer.MAX_VALUE, texture));
546          childrenList.add(new Property("fluidConsistencyType", "CodeableConcept", "The required consistency (e.g. honey-thick, nectar-thick, thin, thickened.) of liquids or fluids served to the patient.", 0, java.lang.Integer.MAX_VALUE, fluidConsistencyType));
547          childrenList.add(new Property("instruction", "string", "Free text or additional instructions or information pertaining to the oral diet.", 0, java.lang.Integer.MAX_VALUE, instruction));
548        }
549
550      @Override
551      public void setProperty(String name, Base value) throws FHIRException {
552        if (name.equals("type"))
553          this.getType().add(castToCodeableConcept(value));
554        else if (name.equals("schedule"))
555          this.getSchedule().add(castToTiming(value));
556        else if (name.equals("nutrient"))
557          this.getNutrient().add((NutritionOrderOralDietNutrientComponent) value);
558        else if (name.equals("texture"))
559          this.getTexture().add((NutritionOrderOralDietTextureComponent) value);
560        else if (name.equals("fluidConsistencyType"))
561          this.getFluidConsistencyType().add(castToCodeableConcept(value));
562        else if (name.equals("instruction"))
563          this.instruction = castToString(value); // StringType
564        else
565          super.setProperty(name, value);
566      }
567
568      @Override
569      public Base addChild(String name) throws FHIRException {
570        if (name.equals("type")) {
571          return addType();
572        }
573        else if (name.equals("schedule")) {
574          return addSchedule();
575        }
576        else if (name.equals("nutrient")) {
577          return addNutrient();
578        }
579        else if (name.equals("texture")) {
580          return addTexture();
581        }
582        else if (name.equals("fluidConsistencyType")) {
583          return addFluidConsistencyType();
584        }
585        else if (name.equals("instruction")) {
586          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.instruction");
587        }
588        else
589          return super.addChild(name);
590      }
591
592      public NutritionOrderOralDietComponent copy() {
593        NutritionOrderOralDietComponent dst = new NutritionOrderOralDietComponent();
594        copyValues(dst);
595        if (type != null) {
596          dst.type = new ArrayList<CodeableConcept>();
597          for (CodeableConcept i : type)
598            dst.type.add(i.copy());
599        };
600        if (schedule != null) {
601          dst.schedule = new ArrayList<Timing>();
602          for (Timing i : schedule)
603            dst.schedule.add(i.copy());
604        };
605        if (nutrient != null) {
606          dst.nutrient = new ArrayList<NutritionOrderOralDietNutrientComponent>();
607          for (NutritionOrderOralDietNutrientComponent i : nutrient)
608            dst.nutrient.add(i.copy());
609        };
610        if (texture != null) {
611          dst.texture = new ArrayList<NutritionOrderOralDietTextureComponent>();
612          for (NutritionOrderOralDietTextureComponent i : texture)
613            dst.texture.add(i.copy());
614        };
615        if (fluidConsistencyType != null) {
616          dst.fluidConsistencyType = new ArrayList<CodeableConcept>();
617          for (CodeableConcept i : fluidConsistencyType)
618            dst.fluidConsistencyType.add(i.copy());
619        };
620        dst.instruction = instruction == null ? null : instruction.copy();
621        return dst;
622      }
623
624      @Override
625      public boolean equalsDeep(Base other) {
626        if (!super.equalsDeep(other))
627          return false;
628        if (!(other instanceof NutritionOrderOralDietComponent))
629          return false;
630        NutritionOrderOralDietComponent o = (NutritionOrderOralDietComponent) other;
631        return compareDeep(type, o.type, true) && compareDeep(schedule, o.schedule, true) && compareDeep(nutrient, o.nutrient, true)
632           && compareDeep(texture, o.texture, true) && compareDeep(fluidConsistencyType, o.fluidConsistencyType, true)
633           && compareDeep(instruction, o.instruction, true);
634      }
635
636      @Override
637      public boolean equalsShallow(Base other) {
638        if (!super.equalsShallow(other))
639          return false;
640        if (!(other instanceof NutritionOrderOralDietComponent))
641          return false;
642        NutritionOrderOralDietComponent o = (NutritionOrderOralDietComponent) other;
643        return compareValues(instruction, o.instruction, true);
644      }
645
646      public boolean isEmpty() {
647        return super.isEmpty() && (type == null || type.isEmpty()) && (schedule == null || schedule.isEmpty())
648           && (nutrient == null || nutrient.isEmpty()) && (texture == null || texture.isEmpty()) && (fluidConsistencyType == null || fluidConsistencyType.isEmpty())
649           && (instruction == null || instruction.isEmpty());
650      }
651
652  public String fhirType() {
653    return "NutritionOrder.oralDiet";
654
655  }
656
657  }
658
659    @Block()
660    public static class NutritionOrderOralDietNutrientComponent extends BackboneElement implements IBaseBackboneElement {
661        /**
662         * The nutrient that is being modified such as carbohydrate or sodium.
663         */
664        @Child(name = "modifier", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
665        @Description(shortDefinition="Type of nutrient that is being modified", formalDefinition="The nutrient that is being modified such as carbohydrate or sodium." )
666        protected CodeableConcept modifier;
667
668        /**
669         * The quantity of the specified nutrient to include in diet.
670         */
671        @Child(name = "amount", type = {SimpleQuantity.class}, order=2, min=0, max=1, modifier=false, summary=false)
672        @Description(shortDefinition="Quantity of the specified nutrient", formalDefinition="The quantity of the specified nutrient to include in diet." )
673        protected SimpleQuantity amount;
674
675        private static final long serialVersionUID = 465107295L;
676
677    /*
678     * Constructor
679     */
680      public NutritionOrderOralDietNutrientComponent() {
681        super();
682      }
683
684        /**
685         * @return {@link #modifier} (The nutrient that is being modified such as carbohydrate or sodium.)
686         */
687        public CodeableConcept getModifier() { 
688          if (this.modifier == null)
689            if (Configuration.errorOnAutoCreate())
690              throw new Error("Attempt to auto-create NutritionOrderOralDietNutrientComponent.modifier");
691            else if (Configuration.doAutoCreate())
692              this.modifier = new CodeableConcept(); // cc
693          return this.modifier;
694        }
695
696        public boolean hasModifier() { 
697          return this.modifier != null && !this.modifier.isEmpty();
698        }
699
700        /**
701         * @param value {@link #modifier} (The nutrient that is being modified such as carbohydrate or sodium.)
702         */
703        public NutritionOrderOralDietNutrientComponent setModifier(CodeableConcept value) { 
704          this.modifier = value;
705          return this;
706        }
707
708        /**
709         * @return {@link #amount} (The quantity of the specified nutrient to include in diet.)
710         */
711        public SimpleQuantity getAmount() { 
712          if (this.amount == null)
713            if (Configuration.errorOnAutoCreate())
714              throw new Error("Attempt to auto-create NutritionOrderOralDietNutrientComponent.amount");
715            else if (Configuration.doAutoCreate())
716              this.amount = new SimpleQuantity(); // cc
717          return this.amount;
718        }
719
720        public boolean hasAmount() { 
721          return this.amount != null && !this.amount.isEmpty();
722        }
723
724        /**
725         * @param value {@link #amount} (The quantity of the specified nutrient to include in diet.)
726         */
727        public NutritionOrderOralDietNutrientComponent setAmount(SimpleQuantity value) { 
728          this.amount = value;
729          return this;
730        }
731
732        protected void listChildren(List<Property> childrenList) {
733          super.listChildren(childrenList);
734          childrenList.add(new Property("modifier", "CodeableConcept", "The nutrient that is being modified such as carbohydrate or sodium.", 0, java.lang.Integer.MAX_VALUE, modifier));
735          childrenList.add(new Property("amount", "SimpleQuantity", "The quantity of the specified nutrient to include in diet.", 0, java.lang.Integer.MAX_VALUE, amount));
736        }
737
738      @Override
739      public void setProperty(String name, Base value) throws FHIRException {
740        if (name.equals("modifier"))
741          this.modifier = castToCodeableConcept(value); // CodeableConcept
742        else if (name.equals("amount"))
743          this.amount = castToSimpleQuantity(value); // SimpleQuantity
744        else
745          super.setProperty(name, value);
746      }
747
748      @Override
749      public Base addChild(String name) throws FHIRException {
750        if (name.equals("modifier")) {
751          this.modifier = new CodeableConcept();
752          return this.modifier;
753        }
754        else if (name.equals("amount")) {
755          this.amount = new SimpleQuantity();
756          return this.amount;
757        }
758        else
759          return super.addChild(name);
760      }
761
762      public NutritionOrderOralDietNutrientComponent copy() {
763        NutritionOrderOralDietNutrientComponent dst = new NutritionOrderOralDietNutrientComponent();
764        copyValues(dst);
765        dst.modifier = modifier == null ? null : modifier.copy();
766        dst.amount = amount == null ? null : amount.copy();
767        return dst;
768      }
769
770      @Override
771      public boolean equalsDeep(Base other) {
772        if (!super.equalsDeep(other))
773          return false;
774        if (!(other instanceof NutritionOrderOralDietNutrientComponent))
775          return false;
776        NutritionOrderOralDietNutrientComponent o = (NutritionOrderOralDietNutrientComponent) other;
777        return compareDeep(modifier, o.modifier, true) && compareDeep(amount, o.amount, true);
778      }
779
780      @Override
781      public boolean equalsShallow(Base other) {
782        if (!super.equalsShallow(other))
783          return false;
784        if (!(other instanceof NutritionOrderOralDietNutrientComponent))
785          return false;
786        NutritionOrderOralDietNutrientComponent o = (NutritionOrderOralDietNutrientComponent) other;
787        return true;
788      }
789
790      public boolean isEmpty() {
791        return super.isEmpty() && (modifier == null || modifier.isEmpty()) && (amount == null || amount.isEmpty())
792          ;
793      }
794
795  public String fhirType() {
796    return "NutritionOrder.oralDiet.nutrient";
797
798  }
799
800  }
801
802    @Block()
803    public static class NutritionOrderOralDietTextureComponent extends BackboneElement implements IBaseBackboneElement {
804        /**
805         * Any texture modifications (for solid foods) that should be made, e.g. easy to chew, chopped, ground, and pureed.
806         */
807        @Child(name = "modifier", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
808        @Description(shortDefinition="Code to indicate how to alter the texture of the foods, e.g. pureed", formalDefinition="Any texture modifications (for solid foods) that should be made, e.g. easy to chew, chopped, ground, and pureed." )
809        protected CodeableConcept modifier;
810
811        /**
812         * The food type(s) (e.g. meats, all foods)  that the texture modification applies to.  This could be all foods types.
813         */
814        @Child(name = "foodType", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
815        @Description(shortDefinition="Concepts that are used to identify an entity that is ingested for nutritional purposes", formalDefinition="The food type(s) (e.g. meats, all foods)  that the texture modification applies to.  This could be all foods types." )
816        protected CodeableConcept foodType;
817
818        private static final long serialVersionUID = -56402817L;
819
820    /*
821     * Constructor
822     */
823      public NutritionOrderOralDietTextureComponent() {
824        super();
825      }
826
827        /**
828         * @return {@link #modifier} (Any texture modifications (for solid foods) that should be made, e.g. easy to chew, chopped, ground, and pureed.)
829         */
830        public CodeableConcept getModifier() { 
831          if (this.modifier == null)
832            if (Configuration.errorOnAutoCreate())
833              throw new Error("Attempt to auto-create NutritionOrderOralDietTextureComponent.modifier");
834            else if (Configuration.doAutoCreate())
835              this.modifier = new CodeableConcept(); // cc
836          return this.modifier;
837        }
838
839        public boolean hasModifier() { 
840          return this.modifier != null && !this.modifier.isEmpty();
841        }
842
843        /**
844         * @param value {@link #modifier} (Any texture modifications (for solid foods) that should be made, e.g. easy to chew, chopped, ground, and pureed.)
845         */
846        public NutritionOrderOralDietTextureComponent setModifier(CodeableConcept value) { 
847          this.modifier = value;
848          return this;
849        }
850
851        /**
852         * @return {@link #foodType} (The food type(s) (e.g. meats, all foods)  that the texture modification applies to.  This could be all foods types.)
853         */
854        public CodeableConcept getFoodType() { 
855          if (this.foodType == null)
856            if (Configuration.errorOnAutoCreate())
857              throw new Error("Attempt to auto-create NutritionOrderOralDietTextureComponent.foodType");
858            else if (Configuration.doAutoCreate())
859              this.foodType = new CodeableConcept(); // cc
860          return this.foodType;
861        }
862
863        public boolean hasFoodType() { 
864          return this.foodType != null && !this.foodType.isEmpty();
865        }
866
867        /**
868         * @param value {@link #foodType} (The food type(s) (e.g. meats, all foods)  that the texture modification applies to.  This could be all foods types.)
869         */
870        public NutritionOrderOralDietTextureComponent setFoodType(CodeableConcept value) { 
871          this.foodType = value;
872          return this;
873        }
874
875        protected void listChildren(List<Property> childrenList) {
876          super.listChildren(childrenList);
877          childrenList.add(new Property("modifier", "CodeableConcept", "Any texture modifications (for solid foods) that should be made, e.g. easy to chew, chopped, ground, and pureed.", 0, java.lang.Integer.MAX_VALUE, modifier));
878          childrenList.add(new Property("foodType", "CodeableConcept", "The food type(s) (e.g. meats, all foods)  that the texture modification applies to.  This could be all foods types.", 0, java.lang.Integer.MAX_VALUE, foodType));
879        }
880
881      @Override
882      public void setProperty(String name, Base value) throws FHIRException {
883        if (name.equals("modifier"))
884          this.modifier = castToCodeableConcept(value); // CodeableConcept
885        else if (name.equals("foodType"))
886          this.foodType = castToCodeableConcept(value); // CodeableConcept
887        else
888          super.setProperty(name, value);
889      }
890
891      @Override
892      public Base addChild(String name) throws FHIRException {
893        if (name.equals("modifier")) {
894          this.modifier = new CodeableConcept();
895          return this.modifier;
896        }
897        else if (name.equals("foodType")) {
898          this.foodType = new CodeableConcept();
899          return this.foodType;
900        }
901        else
902          return super.addChild(name);
903      }
904
905      public NutritionOrderOralDietTextureComponent copy() {
906        NutritionOrderOralDietTextureComponent dst = new NutritionOrderOralDietTextureComponent();
907        copyValues(dst);
908        dst.modifier = modifier == null ? null : modifier.copy();
909        dst.foodType = foodType == null ? null : foodType.copy();
910        return dst;
911      }
912
913      @Override
914      public boolean equalsDeep(Base other) {
915        if (!super.equalsDeep(other))
916          return false;
917        if (!(other instanceof NutritionOrderOralDietTextureComponent))
918          return false;
919        NutritionOrderOralDietTextureComponent o = (NutritionOrderOralDietTextureComponent) other;
920        return compareDeep(modifier, o.modifier, true) && compareDeep(foodType, o.foodType, true);
921      }
922
923      @Override
924      public boolean equalsShallow(Base other) {
925        if (!super.equalsShallow(other))
926          return false;
927        if (!(other instanceof NutritionOrderOralDietTextureComponent))
928          return false;
929        NutritionOrderOralDietTextureComponent o = (NutritionOrderOralDietTextureComponent) other;
930        return true;
931      }
932
933      public boolean isEmpty() {
934        return super.isEmpty() && (modifier == null || modifier.isEmpty()) && (foodType == null || foodType.isEmpty())
935          ;
936      }
937
938  public String fhirType() {
939    return "NutritionOrder.oralDiet.texture";
940
941  }
942
943  }
944
945    @Block()
946    public static class NutritionOrderSupplementComponent extends BackboneElement implements IBaseBackboneElement {
947        /**
948         * The kind of nutritional supplement product required such as a high protein or pediatric clear liquid supplement.
949         */
950        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
951        @Description(shortDefinition="Type of supplement product requested", formalDefinition="The kind of nutritional supplement product required such as a high protein or pediatric clear liquid supplement." )
952        protected CodeableConcept type;
953
954        /**
955         * The product or brand name of the nutritional supplement such as "Acme Protein Shake".
956         */
957        @Child(name = "productName", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
958        @Description(shortDefinition="Product or brand name of the nutritional supplement", formalDefinition="The product or brand name of the nutritional supplement such as \"Acme Protein Shake\"." )
959        protected StringType productName;
960
961        /**
962         * The time period and frequency at which the supplement(s) should be given.
963         */
964        @Child(name = "schedule", type = {Timing.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
965        @Description(shortDefinition="Scheduled frequency of supplement", formalDefinition="The time period and frequency at which the supplement(s) should be given." )
966        protected List<Timing> schedule;
967
968        /**
969         * The amount of the nutritional supplement to be given.
970         */
971        @Child(name = "quantity", type = {SimpleQuantity.class}, order=4, min=0, max=1, modifier=false, summary=false)
972        @Description(shortDefinition="Amount of the nutritional supplement", formalDefinition="The amount of the nutritional supplement to be given." )
973        protected SimpleQuantity quantity;
974
975        /**
976         * Free text or additional instructions or information pertaining to the oral supplement.
977         */
978        @Child(name = "instruction", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
979        @Description(shortDefinition="Instructions or additional information about the oral supplement", formalDefinition="Free text or additional instructions or information pertaining to the oral supplement." )
980        protected StringType instruction;
981
982        private static final long serialVersionUID = 297545236L;
983
984    /*
985     * Constructor
986     */
987      public NutritionOrderSupplementComponent() {
988        super();
989      }
990
991        /**
992         * @return {@link #type} (The kind of nutritional supplement product required such as a high protein or pediatric clear liquid supplement.)
993         */
994        public CodeableConcept getType() { 
995          if (this.type == null)
996            if (Configuration.errorOnAutoCreate())
997              throw new Error("Attempt to auto-create NutritionOrderSupplementComponent.type");
998            else if (Configuration.doAutoCreate())
999              this.type = new CodeableConcept(); // cc
1000          return this.type;
1001        }
1002
1003        public boolean hasType() { 
1004          return this.type != null && !this.type.isEmpty();
1005        }
1006
1007        /**
1008         * @param value {@link #type} (The kind of nutritional supplement product required such as a high protein or pediatric clear liquid supplement.)
1009         */
1010        public NutritionOrderSupplementComponent setType(CodeableConcept value) { 
1011          this.type = value;
1012          return this;
1013        }
1014
1015        /**
1016         * @return {@link #productName} (The product or brand name of the nutritional supplement such as "Acme Protein Shake".). This is the underlying object with id, value and extensions. The accessor "getProductName" gives direct access to the value
1017         */
1018        public StringType getProductNameElement() { 
1019          if (this.productName == null)
1020            if (Configuration.errorOnAutoCreate())
1021              throw new Error("Attempt to auto-create NutritionOrderSupplementComponent.productName");
1022            else if (Configuration.doAutoCreate())
1023              this.productName = new StringType(); // bb
1024          return this.productName;
1025        }
1026
1027        public boolean hasProductNameElement() { 
1028          return this.productName != null && !this.productName.isEmpty();
1029        }
1030
1031        public boolean hasProductName() { 
1032          return this.productName != null && !this.productName.isEmpty();
1033        }
1034
1035        /**
1036         * @param value {@link #productName} (The product or brand name of the nutritional supplement such as "Acme Protein Shake".). This is the underlying object with id, value and extensions. The accessor "getProductName" gives direct access to the value
1037         */
1038        public NutritionOrderSupplementComponent setProductNameElement(StringType value) { 
1039          this.productName = value;
1040          return this;
1041        }
1042
1043        /**
1044         * @return The product or brand name of the nutritional supplement such as "Acme Protein Shake".
1045         */
1046        public String getProductName() { 
1047          return this.productName == null ? null : this.productName.getValue();
1048        }
1049
1050        /**
1051         * @param value The product or brand name of the nutritional supplement such as "Acme Protein Shake".
1052         */
1053        public NutritionOrderSupplementComponent setProductName(String value) { 
1054          if (Utilities.noString(value))
1055            this.productName = null;
1056          else {
1057            if (this.productName == null)
1058              this.productName = new StringType();
1059            this.productName.setValue(value);
1060          }
1061          return this;
1062        }
1063
1064        /**
1065         * @return {@link #schedule} (The time period and frequency at which the supplement(s) should be given.)
1066         */
1067        public List<Timing> getSchedule() { 
1068          if (this.schedule == null)
1069            this.schedule = new ArrayList<Timing>();
1070          return this.schedule;
1071        }
1072
1073        public boolean hasSchedule() { 
1074          if (this.schedule == null)
1075            return false;
1076          for (Timing item : this.schedule)
1077            if (!item.isEmpty())
1078              return true;
1079          return false;
1080        }
1081
1082        /**
1083         * @return {@link #schedule} (The time period and frequency at which the supplement(s) should be given.)
1084         */
1085    // syntactic sugar
1086        public Timing addSchedule() { //3
1087          Timing t = new Timing();
1088          if (this.schedule == null)
1089            this.schedule = new ArrayList<Timing>();
1090          this.schedule.add(t);
1091          return t;
1092        }
1093
1094    // syntactic sugar
1095        public NutritionOrderSupplementComponent addSchedule(Timing t) { //3
1096          if (t == null)
1097            return this;
1098          if (this.schedule == null)
1099            this.schedule = new ArrayList<Timing>();
1100          this.schedule.add(t);
1101          return this;
1102        }
1103
1104        /**
1105         * @return {@link #quantity} (The amount of the nutritional supplement to be given.)
1106         */
1107        public SimpleQuantity getQuantity() { 
1108          if (this.quantity == null)
1109            if (Configuration.errorOnAutoCreate())
1110              throw new Error("Attempt to auto-create NutritionOrderSupplementComponent.quantity");
1111            else if (Configuration.doAutoCreate())
1112              this.quantity = new SimpleQuantity(); // cc
1113          return this.quantity;
1114        }
1115
1116        public boolean hasQuantity() { 
1117          return this.quantity != null && !this.quantity.isEmpty();
1118        }
1119
1120        /**
1121         * @param value {@link #quantity} (The amount of the nutritional supplement to be given.)
1122         */
1123        public NutritionOrderSupplementComponent setQuantity(SimpleQuantity value) { 
1124          this.quantity = value;
1125          return this;
1126        }
1127
1128        /**
1129         * @return {@link #instruction} (Free text or additional instructions or information pertaining to the oral supplement.). This is the underlying object with id, value and extensions. The accessor "getInstruction" gives direct access to the value
1130         */
1131        public StringType getInstructionElement() { 
1132          if (this.instruction == null)
1133            if (Configuration.errorOnAutoCreate())
1134              throw new Error("Attempt to auto-create NutritionOrderSupplementComponent.instruction");
1135            else if (Configuration.doAutoCreate())
1136              this.instruction = new StringType(); // bb
1137          return this.instruction;
1138        }
1139
1140        public boolean hasInstructionElement() { 
1141          return this.instruction != null && !this.instruction.isEmpty();
1142        }
1143
1144        public boolean hasInstruction() { 
1145          return this.instruction != null && !this.instruction.isEmpty();
1146        }
1147
1148        /**
1149         * @param value {@link #instruction} (Free text or additional instructions or information pertaining to the oral supplement.). This is the underlying object with id, value and extensions. The accessor "getInstruction" gives direct access to the value
1150         */
1151        public NutritionOrderSupplementComponent setInstructionElement(StringType value) { 
1152          this.instruction = value;
1153          return this;
1154        }
1155
1156        /**
1157         * @return Free text or additional instructions or information pertaining to the oral supplement.
1158         */
1159        public String getInstruction() { 
1160          return this.instruction == null ? null : this.instruction.getValue();
1161        }
1162
1163        /**
1164         * @param value Free text or additional instructions or information pertaining to the oral supplement.
1165         */
1166        public NutritionOrderSupplementComponent setInstruction(String value) { 
1167          if (Utilities.noString(value))
1168            this.instruction = null;
1169          else {
1170            if (this.instruction == null)
1171              this.instruction = new StringType();
1172            this.instruction.setValue(value);
1173          }
1174          return this;
1175        }
1176
1177        protected void listChildren(List<Property> childrenList) {
1178          super.listChildren(childrenList);
1179          childrenList.add(new Property("type", "CodeableConcept", "The kind of nutritional supplement product required such as a high protein or pediatric clear liquid supplement.", 0, java.lang.Integer.MAX_VALUE, type));
1180          childrenList.add(new Property("productName", "string", "The product or brand name of the nutritional supplement such as \"Acme Protein Shake\".", 0, java.lang.Integer.MAX_VALUE, productName));
1181          childrenList.add(new Property("schedule", "Timing", "The time period and frequency at which the supplement(s) should be given.", 0, java.lang.Integer.MAX_VALUE, schedule));
1182          childrenList.add(new Property("quantity", "SimpleQuantity", "The amount of the nutritional supplement to be given.", 0, java.lang.Integer.MAX_VALUE, quantity));
1183          childrenList.add(new Property("instruction", "string", "Free text or additional instructions or information pertaining to the oral supplement.", 0, java.lang.Integer.MAX_VALUE, instruction));
1184        }
1185
1186      @Override
1187      public void setProperty(String name, Base value) throws FHIRException {
1188        if (name.equals("type"))
1189          this.type = castToCodeableConcept(value); // CodeableConcept
1190        else if (name.equals("productName"))
1191          this.productName = castToString(value); // StringType
1192        else if (name.equals("schedule"))
1193          this.getSchedule().add(castToTiming(value));
1194        else if (name.equals("quantity"))
1195          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
1196        else if (name.equals("instruction"))
1197          this.instruction = castToString(value); // StringType
1198        else
1199          super.setProperty(name, value);
1200      }
1201
1202      @Override
1203      public Base addChild(String name) throws FHIRException {
1204        if (name.equals("type")) {
1205          this.type = new CodeableConcept();
1206          return this.type;
1207        }
1208        else if (name.equals("productName")) {
1209          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.productName");
1210        }
1211        else if (name.equals("schedule")) {
1212          return addSchedule();
1213        }
1214        else if (name.equals("quantity")) {
1215          this.quantity = new SimpleQuantity();
1216          return this.quantity;
1217        }
1218        else if (name.equals("instruction")) {
1219          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.instruction");
1220        }
1221        else
1222          return super.addChild(name);
1223      }
1224
1225      public NutritionOrderSupplementComponent copy() {
1226        NutritionOrderSupplementComponent dst = new NutritionOrderSupplementComponent();
1227        copyValues(dst);
1228        dst.type = type == null ? null : type.copy();
1229        dst.productName = productName == null ? null : productName.copy();
1230        if (schedule != null) {
1231          dst.schedule = new ArrayList<Timing>();
1232          for (Timing i : schedule)
1233            dst.schedule.add(i.copy());
1234        };
1235        dst.quantity = quantity == null ? null : quantity.copy();
1236        dst.instruction = instruction == null ? null : instruction.copy();
1237        return dst;
1238      }
1239
1240      @Override
1241      public boolean equalsDeep(Base other) {
1242        if (!super.equalsDeep(other))
1243          return false;
1244        if (!(other instanceof NutritionOrderSupplementComponent))
1245          return false;
1246        NutritionOrderSupplementComponent o = (NutritionOrderSupplementComponent) other;
1247        return compareDeep(type, o.type, true) && compareDeep(productName, o.productName, true) && compareDeep(schedule, o.schedule, true)
1248           && compareDeep(quantity, o.quantity, true) && compareDeep(instruction, o.instruction, true);
1249      }
1250
1251      @Override
1252      public boolean equalsShallow(Base other) {
1253        if (!super.equalsShallow(other))
1254          return false;
1255        if (!(other instanceof NutritionOrderSupplementComponent))
1256          return false;
1257        NutritionOrderSupplementComponent o = (NutritionOrderSupplementComponent) other;
1258        return compareValues(productName, o.productName, true) && compareValues(instruction, o.instruction, true)
1259          ;
1260      }
1261
1262      public boolean isEmpty() {
1263        return super.isEmpty() && (type == null || type.isEmpty()) && (productName == null || productName.isEmpty())
1264           && (schedule == null || schedule.isEmpty()) && (quantity == null || quantity.isEmpty()) && (instruction == null || instruction.isEmpty())
1265          ;
1266      }
1267
1268  public String fhirType() {
1269    return "NutritionOrder.supplement";
1270
1271  }
1272
1273  }
1274
1275    @Block()
1276    public static class NutritionOrderEnteralFormulaComponent extends BackboneElement implements IBaseBackboneElement {
1277        /**
1278         * The type of enteral or infant formula such as an adult standard formula with fiber or a soy-based infant formula.
1279         */
1280        @Child(name = "baseFormulaType", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1281        @Description(shortDefinition="Type of enteral or infant formula", formalDefinition="The type of enteral or infant formula such as an adult standard formula with fiber or a soy-based infant formula." )
1282        protected CodeableConcept baseFormulaType;
1283
1284        /**
1285         * The product or brand name of the enteral or infant formula product such as "ACME Adult Standard Formula".
1286         */
1287        @Child(name = "baseFormulaProductName", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1288        @Description(shortDefinition="Product or brand name of the enteral or infant formula", formalDefinition="The product or brand name of the enteral or infant formula product such as \"ACME Adult Standard Formula\"." )
1289        protected StringType baseFormulaProductName;
1290
1291        /**
1292         * Indicates the type of modular component such as protein, carbohydrate, fat or fiber to be provided in addition to or mixed with the base formula.
1293         */
1294        @Child(name = "additiveType", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
1295        @Description(shortDefinition="Type of modular component to add to the feeding", formalDefinition="Indicates the type of modular component such as protein, carbohydrate, fat or fiber to be provided in addition to or mixed with the base formula." )
1296        protected CodeableConcept additiveType;
1297
1298        /**
1299         * The product or brand name of the type of modular component to be added to the formula.
1300         */
1301        @Child(name = "additiveProductName", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1302        @Description(shortDefinition="Product or brand name of the modular additive", formalDefinition="The product or brand name of the type of modular component to be added to the formula." )
1303        protected StringType additiveProductName;
1304
1305        /**
1306         * The amount of energy (Calories) that the formula should provide per specified volume, typically per mL or fluid oz.  For example, an infant may require a formula that provides 24 Calories per fluid ounce or an adult may require an enteral formula that provides 1.5 Calorie/mL.
1307         */
1308        @Child(name = "caloricDensity", type = {SimpleQuantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
1309        @Description(shortDefinition="Amount of energy per specified volume that is required", formalDefinition="The amount of energy (Calories) that the formula should provide per specified volume, typically per mL or fluid oz.  For example, an infant may require a formula that provides 24 Calories per fluid ounce or an adult may require an enteral formula that provides 1.5 Calorie/mL." )
1310        protected SimpleQuantity caloricDensity;
1311
1312        /**
1313         * The route or physiological path of administration into the patient's gastrointestinal  tract for purposes of providing the formula feeding, e.g. nasogastric tube.
1314         */
1315        @Child(name = "routeofAdministration", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=false)
1316        @Description(shortDefinition="How the formula should enter the patient's gastrointestinal tract", formalDefinition="The route or physiological path of administration into the patient's gastrointestinal  tract for purposes of providing the formula feeding, e.g. nasogastric tube." )
1317        protected CodeableConcept routeofAdministration;
1318
1319        /**
1320         * Formula administration instructions as structured data.  This repeating structure allows for changing the administration rate or volume over time for both bolus and continuous feeding.  An example of this would be an instruction to increase the rate of continuous feeding every 2 hours.
1321         */
1322        @Child(name = "administration", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1323        @Description(shortDefinition="Formula feeding instruction as structured data", formalDefinition="Formula administration instructions as structured data.  This repeating structure allows for changing the administration rate or volume over time for both bolus and continuous feeding.  An example of this would be an instruction to increase the rate of continuous feeding every 2 hours." )
1324        protected List<NutritionOrderEnteralFormulaAdministrationComponent> administration;
1325
1326        /**
1327         * The maximum total quantity of formula that may be administered to a subject over the period of time, e.g. 1440 mL over 24 hours.
1328         */
1329        @Child(name = "maxVolumeToDeliver", type = {SimpleQuantity.class}, order=8, min=0, max=1, modifier=false, summary=false)
1330        @Description(shortDefinition="Upper limit on formula volume per unit of time", formalDefinition="The maximum total quantity of formula that may be administered to a subject over the period of time, e.g. 1440 mL over 24 hours." )
1331        protected SimpleQuantity maxVolumeToDeliver;
1332
1333        /**
1334         * Free text formula administration, feeding instructions or additional instructions or information.
1335         */
1336        @Child(name = "administrationInstruction", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=true)
1337        @Description(shortDefinition="Formula feeding instructions expressed as text", formalDefinition="Free text formula administration, feeding instructions or additional instructions or information." )
1338        protected StringType administrationInstruction;
1339
1340        private static final long serialVersionUID = 292116061L;
1341
1342    /*
1343     * Constructor
1344     */
1345      public NutritionOrderEnteralFormulaComponent() {
1346        super();
1347      }
1348
1349        /**
1350         * @return {@link #baseFormulaType} (The type of enteral or infant formula such as an adult standard formula with fiber or a soy-based infant formula.)
1351         */
1352        public CodeableConcept getBaseFormulaType() { 
1353          if (this.baseFormulaType == null)
1354            if (Configuration.errorOnAutoCreate())
1355              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.baseFormulaType");
1356            else if (Configuration.doAutoCreate())
1357              this.baseFormulaType = new CodeableConcept(); // cc
1358          return this.baseFormulaType;
1359        }
1360
1361        public boolean hasBaseFormulaType() { 
1362          return this.baseFormulaType != null && !this.baseFormulaType.isEmpty();
1363        }
1364
1365        /**
1366         * @param value {@link #baseFormulaType} (The type of enteral or infant formula such as an adult standard formula with fiber or a soy-based infant formula.)
1367         */
1368        public NutritionOrderEnteralFormulaComponent setBaseFormulaType(CodeableConcept value) { 
1369          this.baseFormulaType = value;
1370          return this;
1371        }
1372
1373        /**
1374         * @return {@link #baseFormulaProductName} (The product or brand name of the enteral or infant formula product such as "ACME Adult Standard Formula".). This is the underlying object with id, value and extensions. The accessor "getBaseFormulaProductName" gives direct access to the value
1375         */
1376        public StringType getBaseFormulaProductNameElement() { 
1377          if (this.baseFormulaProductName == null)
1378            if (Configuration.errorOnAutoCreate())
1379              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.baseFormulaProductName");
1380            else if (Configuration.doAutoCreate())
1381              this.baseFormulaProductName = new StringType(); // bb
1382          return this.baseFormulaProductName;
1383        }
1384
1385        public boolean hasBaseFormulaProductNameElement() { 
1386          return this.baseFormulaProductName != null && !this.baseFormulaProductName.isEmpty();
1387        }
1388
1389        public boolean hasBaseFormulaProductName() { 
1390          return this.baseFormulaProductName != null && !this.baseFormulaProductName.isEmpty();
1391        }
1392
1393        /**
1394         * @param value {@link #baseFormulaProductName} (The product or brand name of the enteral or infant formula product such as "ACME Adult Standard Formula".). This is the underlying object with id, value and extensions. The accessor "getBaseFormulaProductName" gives direct access to the value
1395         */
1396        public NutritionOrderEnteralFormulaComponent setBaseFormulaProductNameElement(StringType value) { 
1397          this.baseFormulaProductName = value;
1398          return this;
1399        }
1400
1401        /**
1402         * @return The product or brand name of the enteral or infant formula product such as "ACME Adult Standard Formula".
1403         */
1404        public String getBaseFormulaProductName() { 
1405          return this.baseFormulaProductName == null ? null : this.baseFormulaProductName.getValue();
1406        }
1407
1408        /**
1409         * @param value The product or brand name of the enteral or infant formula product such as "ACME Adult Standard Formula".
1410         */
1411        public NutritionOrderEnteralFormulaComponent setBaseFormulaProductName(String value) { 
1412          if (Utilities.noString(value))
1413            this.baseFormulaProductName = null;
1414          else {
1415            if (this.baseFormulaProductName == null)
1416              this.baseFormulaProductName = new StringType();
1417            this.baseFormulaProductName.setValue(value);
1418          }
1419          return this;
1420        }
1421
1422        /**
1423         * @return {@link #additiveType} (Indicates the type of modular component such as protein, carbohydrate, fat or fiber to be provided in addition to or mixed with the base formula.)
1424         */
1425        public CodeableConcept getAdditiveType() { 
1426          if (this.additiveType == null)
1427            if (Configuration.errorOnAutoCreate())
1428              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.additiveType");
1429            else if (Configuration.doAutoCreate())
1430              this.additiveType = new CodeableConcept(); // cc
1431          return this.additiveType;
1432        }
1433
1434        public boolean hasAdditiveType() { 
1435          return this.additiveType != null && !this.additiveType.isEmpty();
1436        }
1437
1438        /**
1439         * @param value {@link #additiveType} (Indicates the type of modular component such as protein, carbohydrate, fat or fiber to be provided in addition to or mixed with the base formula.)
1440         */
1441        public NutritionOrderEnteralFormulaComponent setAdditiveType(CodeableConcept value) { 
1442          this.additiveType = value;
1443          return this;
1444        }
1445
1446        /**
1447         * @return {@link #additiveProductName} (The product or brand name of the type of modular component to be added to the formula.). This is the underlying object with id, value and extensions. The accessor "getAdditiveProductName" gives direct access to the value
1448         */
1449        public StringType getAdditiveProductNameElement() { 
1450          if (this.additiveProductName == null)
1451            if (Configuration.errorOnAutoCreate())
1452              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.additiveProductName");
1453            else if (Configuration.doAutoCreate())
1454              this.additiveProductName = new StringType(); // bb
1455          return this.additiveProductName;
1456        }
1457
1458        public boolean hasAdditiveProductNameElement() { 
1459          return this.additiveProductName != null && !this.additiveProductName.isEmpty();
1460        }
1461
1462        public boolean hasAdditiveProductName() { 
1463          return this.additiveProductName != null && !this.additiveProductName.isEmpty();
1464        }
1465
1466        /**
1467         * @param value {@link #additiveProductName} (The product or brand name of the type of modular component to be added to the formula.). This is the underlying object with id, value and extensions. The accessor "getAdditiveProductName" gives direct access to the value
1468         */
1469        public NutritionOrderEnteralFormulaComponent setAdditiveProductNameElement(StringType value) { 
1470          this.additiveProductName = value;
1471          return this;
1472        }
1473
1474        /**
1475         * @return The product or brand name of the type of modular component to be added to the formula.
1476         */
1477        public String getAdditiveProductName() { 
1478          return this.additiveProductName == null ? null : this.additiveProductName.getValue();
1479        }
1480
1481        /**
1482         * @param value The product or brand name of the type of modular component to be added to the formula.
1483         */
1484        public NutritionOrderEnteralFormulaComponent setAdditiveProductName(String value) { 
1485          if (Utilities.noString(value))
1486            this.additiveProductName = null;
1487          else {
1488            if (this.additiveProductName == null)
1489              this.additiveProductName = new StringType();
1490            this.additiveProductName.setValue(value);
1491          }
1492          return this;
1493        }
1494
1495        /**
1496         * @return {@link #caloricDensity} (The amount of energy (Calories) that the formula should provide per specified volume, typically per mL or fluid oz.  For example, an infant may require a formula that provides 24 Calories per fluid ounce or an adult may require an enteral formula that provides 1.5 Calorie/mL.)
1497         */
1498        public SimpleQuantity getCaloricDensity() { 
1499          if (this.caloricDensity == null)
1500            if (Configuration.errorOnAutoCreate())
1501              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.caloricDensity");
1502            else if (Configuration.doAutoCreate())
1503              this.caloricDensity = new SimpleQuantity(); // cc
1504          return this.caloricDensity;
1505        }
1506
1507        public boolean hasCaloricDensity() { 
1508          return this.caloricDensity != null && !this.caloricDensity.isEmpty();
1509        }
1510
1511        /**
1512         * @param value {@link #caloricDensity} (The amount of energy (Calories) that the formula should provide per specified volume, typically per mL or fluid oz.  For example, an infant may require a formula that provides 24 Calories per fluid ounce or an adult may require an enteral formula that provides 1.5 Calorie/mL.)
1513         */
1514        public NutritionOrderEnteralFormulaComponent setCaloricDensity(SimpleQuantity value) { 
1515          this.caloricDensity = value;
1516          return this;
1517        }
1518
1519        /**
1520         * @return {@link #routeofAdministration} (The route or physiological path of administration into the patient's gastrointestinal  tract for purposes of providing the formula feeding, e.g. nasogastric tube.)
1521         */
1522        public CodeableConcept getRouteofAdministration() { 
1523          if (this.routeofAdministration == null)
1524            if (Configuration.errorOnAutoCreate())
1525              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.routeofAdministration");
1526            else if (Configuration.doAutoCreate())
1527              this.routeofAdministration = new CodeableConcept(); // cc
1528          return this.routeofAdministration;
1529        }
1530
1531        public boolean hasRouteofAdministration() { 
1532          return this.routeofAdministration != null && !this.routeofAdministration.isEmpty();
1533        }
1534
1535        /**
1536         * @param value {@link #routeofAdministration} (The route or physiological path of administration into the patient's gastrointestinal  tract for purposes of providing the formula feeding, e.g. nasogastric tube.)
1537         */
1538        public NutritionOrderEnteralFormulaComponent setRouteofAdministration(CodeableConcept value) { 
1539          this.routeofAdministration = value;
1540          return this;
1541        }
1542
1543        /**
1544         * @return {@link #administration} (Formula administration instructions as structured data.  This repeating structure allows for changing the administration rate or volume over time for both bolus and continuous feeding.  An example of this would be an instruction to increase the rate of continuous feeding every 2 hours.)
1545         */
1546        public List<NutritionOrderEnteralFormulaAdministrationComponent> getAdministration() { 
1547          if (this.administration == null)
1548            this.administration = new ArrayList<NutritionOrderEnteralFormulaAdministrationComponent>();
1549          return this.administration;
1550        }
1551
1552        public boolean hasAdministration() { 
1553          if (this.administration == null)
1554            return false;
1555          for (NutritionOrderEnteralFormulaAdministrationComponent item : this.administration)
1556            if (!item.isEmpty())
1557              return true;
1558          return false;
1559        }
1560
1561        /**
1562         * @return {@link #administration} (Formula administration instructions as structured data.  This repeating structure allows for changing the administration rate or volume over time for both bolus and continuous feeding.  An example of this would be an instruction to increase the rate of continuous feeding every 2 hours.)
1563         */
1564    // syntactic sugar
1565        public NutritionOrderEnteralFormulaAdministrationComponent addAdministration() { //3
1566          NutritionOrderEnteralFormulaAdministrationComponent t = new NutritionOrderEnteralFormulaAdministrationComponent();
1567          if (this.administration == null)
1568            this.administration = new ArrayList<NutritionOrderEnteralFormulaAdministrationComponent>();
1569          this.administration.add(t);
1570          return t;
1571        }
1572
1573    // syntactic sugar
1574        public NutritionOrderEnteralFormulaComponent addAdministration(NutritionOrderEnteralFormulaAdministrationComponent t) { //3
1575          if (t == null)
1576            return this;
1577          if (this.administration == null)
1578            this.administration = new ArrayList<NutritionOrderEnteralFormulaAdministrationComponent>();
1579          this.administration.add(t);
1580          return this;
1581        }
1582
1583        /**
1584         * @return {@link #maxVolumeToDeliver} (The maximum total quantity of formula that may be administered to a subject over the period of time, e.g. 1440 mL over 24 hours.)
1585         */
1586        public SimpleQuantity getMaxVolumeToDeliver() { 
1587          if (this.maxVolumeToDeliver == null)
1588            if (Configuration.errorOnAutoCreate())
1589              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.maxVolumeToDeliver");
1590            else if (Configuration.doAutoCreate())
1591              this.maxVolumeToDeliver = new SimpleQuantity(); // cc
1592          return this.maxVolumeToDeliver;
1593        }
1594
1595        public boolean hasMaxVolumeToDeliver() { 
1596          return this.maxVolumeToDeliver != null && !this.maxVolumeToDeliver.isEmpty();
1597        }
1598
1599        /**
1600         * @param value {@link #maxVolumeToDeliver} (The maximum total quantity of formula that may be administered to a subject over the period of time, e.g. 1440 mL over 24 hours.)
1601         */
1602        public NutritionOrderEnteralFormulaComponent setMaxVolumeToDeliver(SimpleQuantity value) { 
1603          this.maxVolumeToDeliver = value;
1604          return this;
1605        }
1606
1607        /**
1608         * @return {@link #administrationInstruction} (Free text formula administration, feeding instructions or additional instructions or information.). This is the underlying object with id, value and extensions. The accessor "getAdministrationInstruction" gives direct access to the value
1609         */
1610        public StringType getAdministrationInstructionElement() { 
1611          if (this.administrationInstruction == null)
1612            if (Configuration.errorOnAutoCreate())
1613              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.administrationInstruction");
1614            else if (Configuration.doAutoCreate())
1615              this.administrationInstruction = new StringType(); // bb
1616          return this.administrationInstruction;
1617        }
1618
1619        public boolean hasAdministrationInstructionElement() { 
1620          return this.administrationInstruction != null && !this.administrationInstruction.isEmpty();
1621        }
1622
1623        public boolean hasAdministrationInstruction() { 
1624          return this.administrationInstruction != null && !this.administrationInstruction.isEmpty();
1625        }
1626
1627        /**
1628         * @param value {@link #administrationInstruction} (Free text formula administration, feeding instructions or additional instructions or information.). This is the underlying object with id, value and extensions. The accessor "getAdministrationInstruction" gives direct access to the value
1629         */
1630        public NutritionOrderEnteralFormulaComponent setAdministrationInstructionElement(StringType value) { 
1631          this.administrationInstruction = value;
1632          return this;
1633        }
1634
1635        /**
1636         * @return Free text formula administration, feeding instructions or additional instructions or information.
1637         */
1638        public String getAdministrationInstruction() { 
1639          return this.administrationInstruction == null ? null : this.administrationInstruction.getValue();
1640        }
1641
1642        /**
1643         * @param value Free text formula administration, feeding instructions or additional instructions or information.
1644         */
1645        public NutritionOrderEnteralFormulaComponent setAdministrationInstruction(String value) { 
1646          if (Utilities.noString(value))
1647            this.administrationInstruction = null;
1648          else {
1649            if (this.administrationInstruction == null)
1650              this.administrationInstruction = new StringType();
1651            this.administrationInstruction.setValue(value);
1652          }
1653          return this;
1654        }
1655
1656        protected void listChildren(List<Property> childrenList) {
1657          super.listChildren(childrenList);
1658          childrenList.add(new Property("baseFormulaType", "CodeableConcept", "The type of enteral or infant formula such as an adult standard formula with fiber or a soy-based infant formula.", 0, java.lang.Integer.MAX_VALUE, baseFormulaType));
1659          childrenList.add(new Property("baseFormulaProductName", "string", "The product or brand name of the enteral or infant formula product such as \"ACME Adult Standard Formula\".", 0, java.lang.Integer.MAX_VALUE, baseFormulaProductName));
1660          childrenList.add(new Property("additiveType", "CodeableConcept", "Indicates the type of modular component such as protein, carbohydrate, fat or fiber to be provided in addition to or mixed with the base formula.", 0, java.lang.Integer.MAX_VALUE, additiveType));
1661          childrenList.add(new Property("additiveProductName", "string", "The product or brand name of the type of modular component to be added to the formula.", 0, java.lang.Integer.MAX_VALUE, additiveProductName));
1662          childrenList.add(new Property("caloricDensity", "SimpleQuantity", "The amount of energy (Calories) that the formula should provide per specified volume, typically per mL or fluid oz.  For example, an infant may require a formula that provides 24 Calories per fluid ounce or an adult may require an enteral formula that provides 1.5 Calorie/mL.", 0, java.lang.Integer.MAX_VALUE, caloricDensity));
1663          childrenList.add(new Property("routeofAdministration", "CodeableConcept", "The route or physiological path of administration into the patient's gastrointestinal  tract for purposes of providing the formula feeding, e.g. nasogastric tube.", 0, java.lang.Integer.MAX_VALUE, routeofAdministration));
1664          childrenList.add(new Property("administration", "", "Formula administration instructions as structured data.  This repeating structure allows for changing the administration rate or volume over time for both bolus and continuous feeding.  An example of this would be an instruction to increase the rate of continuous feeding every 2 hours.", 0, java.lang.Integer.MAX_VALUE, administration));
1665          childrenList.add(new Property("maxVolumeToDeliver", "SimpleQuantity", "The maximum total quantity of formula that may be administered to a subject over the period of time, e.g. 1440 mL over 24 hours.", 0, java.lang.Integer.MAX_VALUE, maxVolumeToDeliver));
1666          childrenList.add(new Property("administrationInstruction", "string", "Free text formula administration, feeding instructions or additional instructions or information.", 0, java.lang.Integer.MAX_VALUE, administrationInstruction));
1667        }
1668
1669      @Override
1670      public void setProperty(String name, Base value) throws FHIRException {
1671        if (name.equals("baseFormulaType"))
1672          this.baseFormulaType = castToCodeableConcept(value); // CodeableConcept
1673        else if (name.equals("baseFormulaProductName"))
1674          this.baseFormulaProductName = castToString(value); // StringType
1675        else if (name.equals("additiveType"))
1676          this.additiveType = castToCodeableConcept(value); // CodeableConcept
1677        else if (name.equals("additiveProductName"))
1678          this.additiveProductName = castToString(value); // StringType
1679        else if (name.equals("caloricDensity"))
1680          this.caloricDensity = castToSimpleQuantity(value); // SimpleQuantity
1681        else if (name.equals("routeofAdministration"))
1682          this.routeofAdministration = castToCodeableConcept(value); // CodeableConcept
1683        else if (name.equals("administration"))
1684          this.getAdministration().add((NutritionOrderEnteralFormulaAdministrationComponent) value);
1685        else if (name.equals("maxVolumeToDeliver"))
1686          this.maxVolumeToDeliver = castToSimpleQuantity(value); // SimpleQuantity
1687        else if (name.equals("administrationInstruction"))
1688          this.administrationInstruction = castToString(value); // StringType
1689        else
1690          super.setProperty(name, value);
1691      }
1692
1693      @Override
1694      public Base addChild(String name) throws FHIRException {
1695        if (name.equals("baseFormulaType")) {
1696          this.baseFormulaType = new CodeableConcept();
1697          return this.baseFormulaType;
1698        }
1699        else if (name.equals("baseFormulaProductName")) {
1700          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.baseFormulaProductName");
1701        }
1702        else if (name.equals("additiveType")) {
1703          this.additiveType = new CodeableConcept();
1704          return this.additiveType;
1705        }
1706        else if (name.equals("additiveProductName")) {
1707          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.additiveProductName");
1708        }
1709        else if (name.equals("caloricDensity")) {
1710          this.caloricDensity = new SimpleQuantity();
1711          return this.caloricDensity;
1712        }
1713        else if (name.equals("routeofAdministration")) {
1714          this.routeofAdministration = new CodeableConcept();
1715          return this.routeofAdministration;
1716        }
1717        else if (name.equals("administration")) {
1718          return addAdministration();
1719        }
1720        else if (name.equals("maxVolumeToDeliver")) {
1721          this.maxVolumeToDeliver = new SimpleQuantity();
1722          return this.maxVolumeToDeliver;
1723        }
1724        else if (name.equals("administrationInstruction")) {
1725          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.administrationInstruction");
1726        }
1727        else
1728          return super.addChild(name);
1729      }
1730
1731      public NutritionOrderEnteralFormulaComponent copy() {
1732        NutritionOrderEnteralFormulaComponent dst = new NutritionOrderEnteralFormulaComponent();
1733        copyValues(dst);
1734        dst.baseFormulaType = baseFormulaType == null ? null : baseFormulaType.copy();
1735        dst.baseFormulaProductName = baseFormulaProductName == null ? null : baseFormulaProductName.copy();
1736        dst.additiveType = additiveType == null ? null : additiveType.copy();
1737        dst.additiveProductName = additiveProductName == null ? null : additiveProductName.copy();
1738        dst.caloricDensity = caloricDensity == null ? null : caloricDensity.copy();
1739        dst.routeofAdministration = routeofAdministration == null ? null : routeofAdministration.copy();
1740        if (administration != null) {
1741          dst.administration = new ArrayList<NutritionOrderEnteralFormulaAdministrationComponent>();
1742          for (NutritionOrderEnteralFormulaAdministrationComponent i : administration)
1743            dst.administration.add(i.copy());
1744        };
1745        dst.maxVolumeToDeliver = maxVolumeToDeliver == null ? null : maxVolumeToDeliver.copy();
1746        dst.administrationInstruction = administrationInstruction == null ? null : administrationInstruction.copy();
1747        return dst;
1748      }
1749
1750      @Override
1751      public boolean equalsDeep(Base other) {
1752        if (!super.equalsDeep(other))
1753          return false;
1754        if (!(other instanceof NutritionOrderEnteralFormulaComponent))
1755          return false;
1756        NutritionOrderEnteralFormulaComponent o = (NutritionOrderEnteralFormulaComponent) other;
1757        return compareDeep(baseFormulaType, o.baseFormulaType, true) && compareDeep(baseFormulaProductName, o.baseFormulaProductName, true)
1758           && compareDeep(additiveType, o.additiveType, true) && compareDeep(additiveProductName, o.additiveProductName, true)
1759           && compareDeep(caloricDensity, o.caloricDensity, true) && compareDeep(routeofAdministration, o.routeofAdministration, true)
1760           && compareDeep(administration, o.administration, true) && compareDeep(maxVolumeToDeliver, o.maxVolumeToDeliver, true)
1761           && compareDeep(administrationInstruction, o.administrationInstruction, true);
1762      }
1763
1764      @Override
1765      public boolean equalsShallow(Base other) {
1766        if (!super.equalsShallow(other))
1767          return false;
1768        if (!(other instanceof NutritionOrderEnteralFormulaComponent))
1769          return false;
1770        NutritionOrderEnteralFormulaComponent o = (NutritionOrderEnteralFormulaComponent) other;
1771        return compareValues(baseFormulaProductName, o.baseFormulaProductName, true) && compareValues(additiveProductName, o.additiveProductName, true)
1772           && compareValues(administrationInstruction, o.administrationInstruction, true);
1773      }
1774
1775      public boolean isEmpty() {
1776        return super.isEmpty() && (baseFormulaType == null || baseFormulaType.isEmpty()) && (baseFormulaProductName == null || baseFormulaProductName.isEmpty())
1777           && (additiveType == null || additiveType.isEmpty()) && (additiveProductName == null || additiveProductName.isEmpty())
1778           && (caloricDensity == null || caloricDensity.isEmpty()) && (routeofAdministration == null || routeofAdministration.isEmpty())
1779           && (administration == null || administration.isEmpty()) && (maxVolumeToDeliver == null || maxVolumeToDeliver.isEmpty())
1780           && (administrationInstruction == null || administrationInstruction.isEmpty());
1781      }
1782
1783  public String fhirType() {
1784    return "NutritionOrder.enteralFormula";
1785
1786  }
1787
1788  }
1789
1790    @Block()
1791    public static class NutritionOrderEnteralFormulaAdministrationComponent extends BackboneElement implements IBaseBackboneElement {
1792        /**
1793         * The time period and frequency at which the enteral formula should be delivered to the patient.
1794         */
1795        @Child(name = "schedule", type = {Timing.class}, order=1, min=0, max=1, modifier=false, summary=false)
1796        @Description(shortDefinition="Scheduled frequency of enteral feeding", formalDefinition="The time period and frequency at which the enteral formula should be delivered to the patient." )
1797        protected Timing schedule;
1798
1799        /**
1800         * The volume of formula to provide to the patient per the specified administration schedule.
1801         */
1802        @Child(name = "quantity", type = {SimpleQuantity.class}, order=2, min=0, max=1, modifier=false, summary=false)
1803        @Description(shortDefinition="The volume of formula to provide", formalDefinition="The volume of formula to provide to the patient per the specified administration schedule." )
1804        protected SimpleQuantity quantity;
1805
1806        /**
1807         * The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.
1808         */
1809        @Child(name = "rate", type = {SimpleQuantity.class, Ratio.class}, order=3, min=0, max=1, modifier=false, summary=false)
1810        @Description(shortDefinition="Speed with which the formula is provided per period of time", formalDefinition="The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule." )
1811        protected Type rate;
1812
1813        private static final long serialVersionUID = 1895031997L;
1814
1815    /*
1816     * Constructor
1817     */
1818      public NutritionOrderEnteralFormulaAdministrationComponent() {
1819        super();
1820      }
1821
1822        /**
1823         * @return {@link #schedule} (The time period and frequency at which the enteral formula should be delivered to the patient.)
1824         */
1825        public Timing getSchedule() { 
1826          if (this.schedule == null)
1827            if (Configuration.errorOnAutoCreate())
1828              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaAdministrationComponent.schedule");
1829            else if (Configuration.doAutoCreate())
1830              this.schedule = new Timing(); // cc
1831          return this.schedule;
1832        }
1833
1834        public boolean hasSchedule() { 
1835          return this.schedule != null && !this.schedule.isEmpty();
1836        }
1837
1838        /**
1839         * @param value {@link #schedule} (The time period and frequency at which the enteral formula should be delivered to the patient.)
1840         */
1841        public NutritionOrderEnteralFormulaAdministrationComponent setSchedule(Timing value) { 
1842          this.schedule = value;
1843          return this;
1844        }
1845
1846        /**
1847         * @return {@link #quantity} (The volume of formula to provide to the patient per the specified administration schedule.)
1848         */
1849        public SimpleQuantity getQuantity() { 
1850          if (this.quantity == null)
1851            if (Configuration.errorOnAutoCreate())
1852              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaAdministrationComponent.quantity");
1853            else if (Configuration.doAutoCreate())
1854              this.quantity = new SimpleQuantity(); // cc
1855          return this.quantity;
1856        }
1857
1858        public boolean hasQuantity() { 
1859          return this.quantity != null && !this.quantity.isEmpty();
1860        }
1861
1862        /**
1863         * @param value {@link #quantity} (The volume of formula to provide to the patient per the specified administration schedule.)
1864         */
1865        public NutritionOrderEnteralFormulaAdministrationComponent setQuantity(SimpleQuantity value) { 
1866          this.quantity = value;
1867          return this;
1868        }
1869
1870        /**
1871         * @return {@link #rate} (The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.)
1872         */
1873        public Type getRate() { 
1874          return this.rate;
1875        }
1876
1877        /**
1878         * @return {@link #rate} (The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.)
1879         */
1880        public SimpleQuantity getRateSimpleQuantity() throws FHIRException { 
1881          if (!(this.rate instanceof SimpleQuantity))
1882            throw new FHIRException("Type mismatch: the type SimpleQuantity was expected, but "+this.rate.getClass().getName()+" was encountered");
1883          return (SimpleQuantity) this.rate;
1884        }
1885
1886        public boolean hasRateSimpleQuantity() { 
1887          return this.rate instanceof SimpleQuantity;
1888        }
1889
1890        /**
1891         * @return {@link #rate} (The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.)
1892         */
1893        public Ratio getRateRatio() throws FHIRException { 
1894          if (!(this.rate instanceof Ratio))
1895            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.rate.getClass().getName()+" was encountered");
1896          return (Ratio) this.rate;
1897        }
1898
1899        public boolean hasRateRatio() { 
1900          return this.rate instanceof Ratio;
1901        }
1902
1903        public boolean hasRate() { 
1904          return this.rate != null && !this.rate.isEmpty();
1905        }
1906
1907        /**
1908         * @param value {@link #rate} (The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.)
1909         */
1910        public NutritionOrderEnteralFormulaAdministrationComponent setRate(Type value) { 
1911          this.rate = value;
1912          return this;
1913        }
1914
1915        protected void listChildren(List<Property> childrenList) {
1916          super.listChildren(childrenList);
1917          childrenList.add(new Property("schedule", "Timing", "The time period and frequency at which the enteral formula should be delivered to the patient.", 0, java.lang.Integer.MAX_VALUE, schedule));
1918          childrenList.add(new Property("quantity", "SimpleQuantity", "The volume of formula to provide to the patient per the specified administration schedule.", 0, java.lang.Integer.MAX_VALUE, quantity));
1919          childrenList.add(new Property("rate[x]", "SimpleQuantity|Ratio", "The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.", 0, java.lang.Integer.MAX_VALUE, rate));
1920        }
1921
1922      @Override
1923      public void setProperty(String name, Base value) throws FHIRException {
1924        if (name.equals("schedule"))
1925          this.schedule = castToTiming(value); // Timing
1926        else if (name.equals("quantity"))
1927          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
1928        else if (name.equals("rate[x]"))
1929          this.rate = (Type) value; // Type
1930        else
1931          super.setProperty(name, value);
1932      }
1933
1934      @Override
1935      public Base addChild(String name) throws FHIRException {
1936        if (name.equals("schedule")) {
1937          this.schedule = new Timing();
1938          return this.schedule;
1939        }
1940        else if (name.equals("quantity")) {
1941          this.quantity = new SimpleQuantity();
1942          return this.quantity;
1943        }
1944        else if (name.equals("rateSimpleQuantity")) {
1945          this.rate = new SimpleQuantity();
1946          return this.rate;
1947        }
1948        else if (name.equals("rateRatio")) {
1949          this.rate = new Ratio();
1950          return this.rate;
1951        }
1952        else
1953          return super.addChild(name);
1954      }
1955
1956      public NutritionOrderEnteralFormulaAdministrationComponent copy() {
1957        NutritionOrderEnteralFormulaAdministrationComponent dst = new NutritionOrderEnteralFormulaAdministrationComponent();
1958        copyValues(dst);
1959        dst.schedule = schedule == null ? null : schedule.copy();
1960        dst.quantity = quantity == null ? null : quantity.copy();
1961        dst.rate = rate == null ? null : rate.copy();
1962        return dst;
1963      }
1964
1965      @Override
1966      public boolean equalsDeep(Base other) {
1967        if (!super.equalsDeep(other))
1968          return false;
1969        if (!(other instanceof NutritionOrderEnteralFormulaAdministrationComponent))
1970          return false;
1971        NutritionOrderEnteralFormulaAdministrationComponent o = (NutritionOrderEnteralFormulaAdministrationComponent) other;
1972        return compareDeep(schedule, o.schedule, true) && compareDeep(quantity, o.quantity, true) && compareDeep(rate, o.rate, true)
1973          ;
1974      }
1975
1976      @Override
1977      public boolean equalsShallow(Base other) {
1978        if (!super.equalsShallow(other))
1979          return false;
1980        if (!(other instanceof NutritionOrderEnteralFormulaAdministrationComponent))
1981          return false;
1982        NutritionOrderEnteralFormulaAdministrationComponent o = (NutritionOrderEnteralFormulaAdministrationComponent) other;
1983        return true;
1984      }
1985
1986      public boolean isEmpty() {
1987        return super.isEmpty() && (schedule == null || schedule.isEmpty()) && (quantity == null || quantity.isEmpty())
1988           && (rate == null || rate.isEmpty());
1989      }
1990
1991  public String fhirType() {
1992    return "NutritionOrder.enteralFormula.administration";
1993
1994  }
1995
1996  }
1997
1998    /**
1999     * The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.
2000     */
2001    @Child(name = "patient", type = {Patient.class}, order=0, min=1, max=1, modifier=false, summary=true)
2002    @Description(shortDefinition="The person who requires the diet, formula or nutritional supplement", formalDefinition="The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding." )
2003    protected Reference patient;
2004
2005    /**
2006     * The actual object that is the target of the reference (The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.)
2007     */
2008    protected Patient patientTarget;
2009
2010    /**
2011     * The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.
2012     */
2013    @Child(name = "orderer", type = {Practitioner.class}, order=1, min=0, max=1, modifier=false, summary=true)
2014    @Description(shortDefinition="Who ordered the diet, formula or nutritional supplement", formalDefinition="The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings." )
2015    protected Reference orderer;
2016
2017    /**
2018     * The actual object that is the target of the reference (The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.)
2019     */
2020    protected Practitioner ordererTarget;
2021
2022    /**
2023     * Identifiers assigned to this order by the order sender or by the order receiver.
2024     */
2025    @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2026    @Description(shortDefinition="Identifiers assigned to this order", formalDefinition="Identifiers assigned to this order by the order sender or by the order receiver." )
2027    protected List<Identifier> identifier;
2028
2029    /**
2030     * An encounter that provides additional information about the healthcare context in which this request is made.
2031     */
2032    @Child(name = "encounter", type = {Encounter.class}, order=3, min=0, max=1, modifier=false, summary=false)
2033    @Description(shortDefinition="The encounter associated with this nutrition order", formalDefinition="An encounter that provides additional information about the healthcare context in which this request is made." )
2034    protected Reference encounter;
2035
2036    /**
2037     * The actual object that is the target of the reference (An encounter that provides additional information about the healthcare context in which this request is made.)
2038     */
2039    protected Encounter encounterTarget;
2040
2041    /**
2042     * The date and time that this nutrition order was requested.
2043     */
2044    @Child(name = "dateTime", type = {DateTimeType.class}, order=4, min=1, max=1, modifier=false, summary=true)
2045    @Description(shortDefinition="Date and time the nutrition order was requested", formalDefinition="The date and time that this nutrition order was requested." )
2046    protected DateTimeType dateTime;
2047
2048    /**
2049     * The workflow status of the nutrition order/request.
2050     */
2051    @Child(name = "status", type = {CodeType.class}, order=5, min=0, max=1, modifier=true, summary=true)
2052    @Description(shortDefinition="proposed | draft | planned | requested | active | on-hold | completed | cancelled", formalDefinition="The workflow status of the nutrition order/request." )
2053    protected Enumeration<NutritionOrderStatus> status;
2054
2055    /**
2056     * A link to a record of allergies or intolerances  which should be included in the nutrition order.
2057     */
2058    @Child(name = "allergyIntolerance", type = {AllergyIntolerance.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2059    @Description(shortDefinition="List of the patient's food and nutrition-related allergies and intolerances", formalDefinition="A link to a record of allergies or intolerances  which should be included in the nutrition order." )
2060    protected List<Reference> allergyIntolerance;
2061    /**
2062     * The actual objects that are the target of the reference (A link to a record of allergies or intolerances  which should be included in the nutrition order.)
2063     */
2064    protected List<AllergyIntolerance> allergyIntoleranceTarget;
2065
2066
2067    /**
2068     * This modifier is used to convey order-specific modifiers about the type of food that should be given. These can be derived from patient allergies, intolerances, or preferences such as Halal, Vegan or Kosher. This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings.
2069     */
2070    @Child(name = "foodPreferenceModifier", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2071    @Description(shortDefinition="Order-specific modifier about the type of food that should be given", formalDefinition="This modifier is used to convey order-specific modifiers about the type of food that should be given. These can be derived from patient allergies, intolerances, or preferences such as Halal, Vegan or Kosher. This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings." )
2072    protected List<CodeableConcept> foodPreferenceModifier;
2073
2074    /**
2075     * This modifier is used to convey order-specific modifiers about the type of food that should NOT be given. These can be derived from patient allergies, intolerances, or preferences such as No Red Meat, No Soy or No Wheat or  Gluten-Free.  While it should not be necessary to repeat allergy or intolerance information captured in the referenced allergyIntolerance resource in the excludeFoodModifier, this element may be used to convey additional specificity related to foods that should be eliminated from the patient’s diet for any reason.  This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings.
2076     */
2077    @Child(name = "excludeFoodModifier", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2078    @Description(shortDefinition="Order-specific modifier about the type of food that should not be given", formalDefinition="This modifier is used to convey order-specific modifiers about the type of food that should NOT be given. These can be derived from patient allergies, intolerances, or preferences such as No Red Meat, No Soy or No Wheat or  Gluten-Free.  While it should not be necessary to repeat allergy or intolerance information captured in the referenced allergyIntolerance resource in the excludeFoodModifier, this element may be used to convey additional specificity related to foods that should be eliminated from the patient’s diet for any reason.  This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings." )
2079    protected List<CodeableConcept> excludeFoodModifier;
2080
2081    /**
2082     * Diet given orally in contrast to enteral (tube) feeding.
2083     */
2084    @Child(name = "oralDiet", type = {}, order=9, min=0, max=1, modifier=false, summary=false)
2085    @Description(shortDefinition="Oral diet components", formalDefinition="Diet given orally in contrast to enteral (tube) feeding." )
2086    protected NutritionOrderOralDietComponent oralDiet;
2087
2088    /**
2089     * Oral nutritional products given in order to add further nutritional value to the patient's diet.
2090     */
2091    @Child(name = "supplement", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2092    @Description(shortDefinition="Supplement components", formalDefinition="Oral nutritional products given in order to add further nutritional value to the patient's diet." )
2093    protected List<NutritionOrderSupplementComponent> supplement;
2094
2095    /**
2096     * Feeding provided through the gastrointestinal tract via a tube, catheter, or stoma that delivers nutrition distal to the oral cavity.
2097     */
2098    @Child(name = "enteralFormula", type = {}, order=11, min=0, max=1, modifier=false, summary=false)
2099    @Description(shortDefinition="Enteral formula components", formalDefinition="Feeding provided through the gastrointestinal tract via a tube, catheter, or stoma that delivers nutrition distal to the oral cavity." )
2100    protected NutritionOrderEnteralFormulaComponent enteralFormula;
2101
2102    private static final long serialVersionUID = 1139624085L;
2103
2104  /*
2105   * Constructor
2106   */
2107    public NutritionOrder() {
2108      super();
2109    }
2110
2111  /*
2112   * Constructor
2113   */
2114    public NutritionOrder(Reference patient, DateTimeType dateTime) {
2115      super();
2116      this.patient = patient;
2117      this.dateTime = dateTime;
2118    }
2119
2120    /**
2121     * @return {@link #patient} (The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.)
2122     */
2123    public Reference getPatient() { 
2124      if (this.patient == null)
2125        if (Configuration.errorOnAutoCreate())
2126          throw new Error("Attempt to auto-create NutritionOrder.patient");
2127        else if (Configuration.doAutoCreate())
2128          this.patient = new Reference(); // cc
2129      return this.patient;
2130    }
2131
2132    public boolean hasPatient() { 
2133      return this.patient != null && !this.patient.isEmpty();
2134    }
2135
2136    /**
2137     * @param value {@link #patient} (The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.)
2138     */
2139    public NutritionOrder setPatient(Reference value) { 
2140      this.patient = value;
2141      return this;
2142    }
2143
2144    /**
2145     * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.)
2146     */
2147    public Patient getPatientTarget() { 
2148      if (this.patientTarget == null)
2149        if (Configuration.errorOnAutoCreate())
2150          throw new Error("Attempt to auto-create NutritionOrder.patient");
2151        else if (Configuration.doAutoCreate())
2152          this.patientTarget = new Patient(); // aa
2153      return this.patientTarget;
2154    }
2155
2156    /**
2157     * @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.)
2158     */
2159    public NutritionOrder setPatientTarget(Patient value) { 
2160      this.patientTarget = value;
2161      return this;
2162    }
2163
2164    /**
2165     * @return {@link #orderer} (The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.)
2166     */
2167    public Reference getOrderer() { 
2168      if (this.orderer == null)
2169        if (Configuration.errorOnAutoCreate())
2170          throw new Error("Attempt to auto-create NutritionOrder.orderer");
2171        else if (Configuration.doAutoCreate())
2172          this.orderer = new Reference(); // cc
2173      return this.orderer;
2174    }
2175
2176    public boolean hasOrderer() { 
2177      return this.orderer != null && !this.orderer.isEmpty();
2178    }
2179
2180    /**
2181     * @param value {@link #orderer} (The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.)
2182     */
2183    public NutritionOrder setOrderer(Reference value) { 
2184      this.orderer = value;
2185      return this;
2186    }
2187
2188    /**
2189     * @return {@link #orderer} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.)
2190     */
2191    public Practitioner getOrdererTarget() { 
2192      if (this.ordererTarget == null)
2193        if (Configuration.errorOnAutoCreate())
2194          throw new Error("Attempt to auto-create NutritionOrder.orderer");
2195        else if (Configuration.doAutoCreate())
2196          this.ordererTarget = new Practitioner(); // aa
2197      return this.ordererTarget;
2198    }
2199
2200    /**
2201     * @param value {@link #orderer} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.)
2202     */
2203    public NutritionOrder setOrdererTarget(Practitioner value) { 
2204      this.ordererTarget = value;
2205      return this;
2206    }
2207
2208    /**
2209     * @return {@link #identifier} (Identifiers assigned to this order by the order sender or by the order receiver.)
2210     */
2211    public List<Identifier> getIdentifier() { 
2212      if (this.identifier == null)
2213        this.identifier = new ArrayList<Identifier>();
2214      return this.identifier;
2215    }
2216
2217    public boolean hasIdentifier() { 
2218      if (this.identifier == null)
2219        return false;
2220      for (Identifier item : this.identifier)
2221        if (!item.isEmpty())
2222          return true;
2223      return false;
2224    }
2225
2226    /**
2227     * @return {@link #identifier} (Identifiers assigned to this order by the order sender or by the order receiver.)
2228     */
2229    // syntactic sugar
2230    public Identifier addIdentifier() { //3
2231      Identifier t = new Identifier();
2232      if (this.identifier == null)
2233        this.identifier = new ArrayList<Identifier>();
2234      this.identifier.add(t);
2235      return t;
2236    }
2237
2238    // syntactic sugar
2239    public NutritionOrder addIdentifier(Identifier t) { //3
2240      if (t == null)
2241        return this;
2242      if (this.identifier == null)
2243        this.identifier = new ArrayList<Identifier>();
2244      this.identifier.add(t);
2245      return this;
2246    }
2247
2248    /**
2249     * @return {@link #encounter} (An encounter that provides additional information about the healthcare context in which this request is made.)
2250     */
2251    public Reference getEncounter() { 
2252      if (this.encounter == null)
2253        if (Configuration.errorOnAutoCreate())
2254          throw new Error("Attempt to auto-create NutritionOrder.encounter");
2255        else if (Configuration.doAutoCreate())
2256          this.encounter = new Reference(); // cc
2257      return this.encounter;
2258    }
2259
2260    public boolean hasEncounter() { 
2261      return this.encounter != null && !this.encounter.isEmpty();
2262    }
2263
2264    /**
2265     * @param value {@link #encounter} (An encounter that provides additional information about the healthcare context in which this request is made.)
2266     */
2267    public NutritionOrder setEncounter(Reference value) { 
2268      this.encounter = value;
2269      return this;
2270    }
2271
2272    /**
2273     * @return {@link #encounter} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (An encounter that provides additional information about the healthcare context in which this request is made.)
2274     */
2275    public Encounter getEncounterTarget() { 
2276      if (this.encounterTarget == null)
2277        if (Configuration.errorOnAutoCreate())
2278          throw new Error("Attempt to auto-create NutritionOrder.encounter");
2279        else if (Configuration.doAutoCreate())
2280          this.encounterTarget = new Encounter(); // aa
2281      return this.encounterTarget;
2282    }
2283
2284    /**
2285     * @param value {@link #encounter} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (An encounter that provides additional information about the healthcare context in which this request is made.)
2286     */
2287    public NutritionOrder setEncounterTarget(Encounter value) { 
2288      this.encounterTarget = value;
2289      return this;
2290    }
2291
2292    /**
2293     * @return {@link #dateTime} (The date and time that this nutrition order was requested.). This is the underlying object with id, value and extensions. The accessor "getDateTime" gives direct access to the value
2294     */
2295    public DateTimeType getDateTimeElement() { 
2296      if (this.dateTime == null)
2297        if (Configuration.errorOnAutoCreate())
2298          throw new Error("Attempt to auto-create NutritionOrder.dateTime");
2299        else if (Configuration.doAutoCreate())
2300          this.dateTime = new DateTimeType(); // bb
2301      return this.dateTime;
2302    }
2303
2304    public boolean hasDateTimeElement() { 
2305      return this.dateTime != null && !this.dateTime.isEmpty();
2306    }
2307
2308    public boolean hasDateTime() { 
2309      return this.dateTime != null && !this.dateTime.isEmpty();
2310    }
2311
2312    /**
2313     * @param value {@link #dateTime} (The date and time that this nutrition order was requested.). This is the underlying object with id, value and extensions. The accessor "getDateTime" gives direct access to the value
2314     */
2315    public NutritionOrder setDateTimeElement(DateTimeType value) { 
2316      this.dateTime = value;
2317      return this;
2318    }
2319
2320    /**
2321     * @return The date and time that this nutrition order was requested.
2322     */
2323    public Date getDateTime() { 
2324      return this.dateTime == null ? null : this.dateTime.getValue();
2325    }
2326
2327    /**
2328     * @param value The date and time that this nutrition order was requested.
2329     */
2330    public NutritionOrder setDateTime(Date value) { 
2331        if (this.dateTime == null)
2332          this.dateTime = new DateTimeType();
2333        this.dateTime.setValue(value);
2334      return this;
2335    }
2336
2337    /**
2338     * @return {@link #status} (The workflow status of the nutrition order/request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2339     */
2340    public Enumeration<NutritionOrderStatus> getStatusElement() { 
2341      if (this.status == null)
2342        if (Configuration.errorOnAutoCreate())
2343          throw new Error("Attempt to auto-create NutritionOrder.status");
2344        else if (Configuration.doAutoCreate())
2345          this.status = new Enumeration<NutritionOrderStatus>(new NutritionOrderStatusEnumFactory()); // bb
2346      return this.status;
2347    }
2348
2349    public boolean hasStatusElement() { 
2350      return this.status != null && !this.status.isEmpty();
2351    }
2352
2353    public boolean hasStatus() { 
2354      return this.status != null && !this.status.isEmpty();
2355    }
2356
2357    /**
2358     * @param value {@link #status} (The workflow status of the nutrition order/request.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
2359     */
2360    public NutritionOrder setStatusElement(Enumeration<NutritionOrderStatus> value) { 
2361      this.status = value;
2362      return this;
2363    }
2364
2365    /**
2366     * @return The workflow status of the nutrition order/request.
2367     */
2368    public NutritionOrderStatus getStatus() { 
2369      return this.status == null ? null : this.status.getValue();
2370    }
2371
2372    /**
2373     * @param value The workflow status of the nutrition order/request.
2374     */
2375    public NutritionOrder setStatus(NutritionOrderStatus value) { 
2376      if (value == null)
2377        this.status = null;
2378      else {
2379        if (this.status == null)
2380          this.status = new Enumeration<NutritionOrderStatus>(new NutritionOrderStatusEnumFactory());
2381        this.status.setValue(value);
2382      }
2383      return this;
2384    }
2385
2386    /**
2387     * @return {@link #allergyIntolerance} (A link to a record of allergies or intolerances  which should be included in the nutrition order.)
2388     */
2389    public List<Reference> getAllergyIntolerance() { 
2390      if (this.allergyIntolerance == null)
2391        this.allergyIntolerance = new ArrayList<Reference>();
2392      return this.allergyIntolerance;
2393    }
2394
2395    public boolean hasAllergyIntolerance() { 
2396      if (this.allergyIntolerance == null)
2397        return false;
2398      for (Reference item : this.allergyIntolerance)
2399        if (!item.isEmpty())
2400          return true;
2401      return false;
2402    }
2403
2404    /**
2405     * @return {@link #allergyIntolerance} (A link to a record of allergies or intolerances  which should be included in the nutrition order.)
2406     */
2407    // syntactic sugar
2408    public Reference addAllergyIntolerance() { //3
2409      Reference t = new Reference();
2410      if (this.allergyIntolerance == null)
2411        this.allergyIntolerance = new ArrayList<Reference>();
2412      this.allergyIntolerance.add(t);
2413      return t;
2414    }
2415
2416    // syntactic sugar
2417    public NutritionOrder addAllergyIntolerance(Reference t) { //3
2418      if (t == null)
2419        return this;
2420      if (this.allergyIntolerance == null)
2421        this.allergyIntolerance = new ArrayList<Reference>();
2422      this.allergyIntolerance.add(t);
2423      return this;
2424    }
2425
2426    /**
2427     * @return {@link #allergyIntolerance} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. A link to a record of allergies or intolerances  which should be included in the nutrition order.)
2428     */
2429    public List<AllergyIntolerance> getAllergyIntoleranceTarget() { 
2430      if (this.allergyIntoleranceTarget == null)
2431        this.allergyIntoleranceTarget = new ArrayList<AllergyIntolerance>();
2432      return this.allergyIntoleranceTarget;
2433    }
2434
2435    // syntactic sugar
2436    /**
2437     * @return {@link #allergyIntolerance} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. A link to a record of allergies or intolerances  which should be included in the nutrition order.)
2438     */
2439    public AllergyIntolerance addAllergyIntoleranceTarget() { 
2440      AllergyIntolerance r = new AllergyIntolerance();
2441      if (this.allergyIntoleranceTarget == null)
2442        this.allergyIntoleranceTarget = new ArrayList<AllergyIntolerance>();
2443      this.allergyIntoleranceTarget.add(r);
2444      return r;
2445    }
2446
2447    /**
2448     * @return {@link #foodPreferenceModifier} (This modifier is used to convey order-specific modifiers about the type of food that should be given. These can be derived from patient allergies, intolerances, or preferences such as Halal, Vegan or Kosher. This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings.)
2449     */
2450    public List<CodeableConcept> getFoodPreferenceModifier() { 
2451      if (this.foodPreferenceModifier == null)
2452        this.foodPreferenceModifier = new ArrayList<CodeableConcept>();
2453      return this.foodPreferenceModifier;
2454    }
2455
2456    public boolean hasFoodPreferenceModifier() { 
2457      if (this.foodPreferenceModifier == null)
2458        return false;
2459      for (CodeableConcept item : this.foodPreferenceModifier)
2460        if (!item.isEmpty())
2461          return true;
2462      return false;
2463    }
2464
2465    /**
2466     * @return {@link #foodPreferenceModifier} (This modifier is used to convey order-specific modifiers about the type of food that should be given. These can be derived from patient allergies, intolerances, or preferences such as Halal, Vegan or Kosher. This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings.)
2467     */
2468    // syntactic sugar
2469    public CodeableConcept addFoodPreferenceModifier() { //3
2470      CodeableConcept t = new CodeableConcept();
2471      if (this.foodPreferenceModifier == null)
2472        this.foodPreferenceModifier = new ArrayList<CodeableConcept>();
2473      this.foodPreferenceModifier.add(t);
2474      return t;
2475    }
2476
2477    // syntactic sugar
2478    public NutritionOrder addFoodPreferenceModifier(CodeableConcept t) { //3
2479      if (t == null)
2480        return this;
2481      if (this.foodPreferenceModifier == null)
2482        this.foodPreferenceModifier = new ArrayList<CodeableConcept>();
2483      this.foodPreferenceModifier.add(t);
2484      return this;
2485    }
2486
2487    /**
2488     * @return {@link #excludeFoodModifier} (This modifier is used to convey order-specific modifiers about the type of food that should NOT be given. These can be derived from patient allergies, intolerances, or preferences such as No Red Meat, No Soy or No Wheat or  Gluten-Free.  While it should not be necessary to repeat allergy or intolerance information captured in the referenced allergyIntolerance resource in the excludeFoodModifier, this element may be used to convey additional specificity related to foods that should be eliminated from the patient’s diet for any reason.  This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings.)
2489     */
2490    public List<CodeableConcept> getExcludeFoodModifier() { 
2491      if (this.excludeFoodModifier == null)
2492        this.excludeFoodModifier = new ArrayList<CodeableConcept>();
2493      return this.excludeFoodModifier;
2494    }
2495
2496    public boolean hasExcludeFoodModifier() { 
2497      if (this.excludeFoodModifier == null)
2498        return false;
2499      for (CodeableConcept item : this.excludeFoodModifier)
2500        if (!item.isEmpty())
2501          return true;
2502      return false;
2503    }
2504
2505    /**
2506     * @return {@link #excludeFoodModifier} (This modifier is used to convey order-specific modifiers about the type of food that should NOT be given. These can be derived from patient allergies, intolerances, or preferences such as No Red Meat, No Soy or No Wheat or  Gluten-Free.  While it should not be necessary to repeat allergy or intolerance information captured in the referenced allergyIntolerance resource in the excludeFoodModifier, this element may be used to convey additional specificity related to foods that should be eliminated from the patient’s diet for any reason.  This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings.)
2507     */
2508    // syntactic sugar
2509    public CodeableConcept addExcludeFoodModifier() { //3
2510      CodeableConcept t = new CodeableConcept();
2511      if (this.excludeFoodModifier == null)
2512        this.excludeFoodModifier = new ArrayList<CodeableConcept>();
2513      this.excludeFoodModifier.add(t);
2514      return t;
2515    }
2516
2517    // syntactic sugar
2518    public NutritionOrder addExcludeFoodModifier(CodeableConcept t) { //3
2519      if (t == null)
2520        return this;
2521      if (this.excludeFoodModifier == null)
2522        this.excludeFoodModifier = new ArrayList<CodeableConcept>();
2523      this.excludeFoodModifier.add(t);
2524      return this;
2525    }
2526
2527    /**
2528     * @return {@link #oralDiet} (Diet given orally in contrast to enteral (tube) feeding.)
2529     */
2530    public NutritionOrderOralDietComponent getOralDiet() { 
2531      if (this.oralDiet == null)
2532        if (Configuration.errorOnAutoCreate())
2533          throw new Error("Attempt to auto-create NutritionOrder.oralDiet");
2534        else if (Configuration.doAutoCreate())
2535          this.oralDiet = new NutritionOrderOralDietComponent(); // cc
2536      return this.oralDiet;
2537    }
2538
2539    public boolean hasOralDiet() { 
2540      return this.oralDiet != null && !this.oralDiet.isEmpty();
2541    }
2542
2543    /**
2544     * @param value {@link #oralDiet} (Diet given orally in contrast to enteral (tube) feeding.)
2545     */
2546    public NutritionOrder setOralDiet(NutritionOrderOralDietComponent value) { 
2547      this.oralDiet = value;
2548      return this;
2549    }
2550
2551    /**
2552     * @return {@link #supplement} (Oral nutritional products given in order to add further nutritional value to the patient's diet.)
2553     */
2554    public List<NutritionOrderSupplementComponent> getSupplement() { 
2555      if (this.supplement == null)
2556        this.supplement = new ArrayList<NutritionOrderSupplementComponent>();
2557      return this.supplement;
2558    }
2559
2560    public boolean hasSupplement() { 
2561      if (this.supplement == null)
2562        return false;
2563      for (NutritionOrderSupplementComponent item : this.supplement)
2564        if (!item.isEmpty())
2565          return true;
2566      return false;
2567    }
2568
2569    /**
2570     * @return {@link #supplement} (Oral nutritional products given in order to add further nutritional value to the patient's diet.)
2571     */
2572    // syntactic sugar
2573    public NutritionOrderSupplementComponent addSupplement() { //3
2574      NutritionOrderSupplementComponent t = new NutritionOrderSupplementComponent();
2575      if (this.supplement == null)
2576        this.supplement = new ArrayList<NutritionOrderSupplementComponent>();
2577      this.supplement.add(t);
2578      return t;
2579    }
2580
2581    // syntactic sugar
2582    public NutritionOrder addSupplement(NutritionOrderSupplementComponent t) { //3
2583      if (t == null)
2584        return this;
2585      if (this.supplement == null)
2586        this.supplement = new ArrayList<NutritionOrderSupplementComponent>();
2587      this.supplement.add(t);
2588      return this;
2589    }
2590
2591    /**
2592     * @return {@link #enteralFormula} (Feeding provided through the gastrointestinal tract via a tube, catheter, or stoma that delivers nutrition distal to the oral cavity.)
2593     */
2594    public NutritionOrderEnteralFormulaComponent getEnteralFormula() { 
2595      if (this.enteralFormula == null)
2596        if (Configuration.errorOnAutoCreate())
2597          throw new Error("Attempt to auto-create NutritionOrder.enteralFormula");
2598        else if (Configuration.doAutoCreate())
2599          this.enteralFormula = new NutritionOrderEnteralFormulaComponent(); // cc
2600      return this.enteralFormula;
2601    }
2602
2603    public boolean hasEnteralFormula() { 
2604      return this.enteralFormula != null && !this.enteralFormula.isEmpty();
2605    }
2606
2607    /**
2608     * @param value {@link #enteralFormula} (Feeding provided through the gastrointestinal tract via a tube, catheter, or stoma that delivers nutrition distal to the oral cavity.)
2609     */
2610    public NutritionOrder setEnteralFormula(NutritionOrderEnteralFormulaComponent value) { 
2611      this.enteralFormula = value;
2612      return this;
2613    }
2614
2615      protected void listChildren(List<Property> childrenList) {
2616        super.listChildren(childrenList);
2617        childrenList.add(new Property("patient", "Reference(Patient)", "The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.", 0, java.lang.Integer.MAX_VALUE, patient));
2618        childrenList.add(new Property("orderer", "Reference(Practitioner)", "The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.", 0, java.lang.Integer.MAX_VALUE, orderer));
2619        childrenList.add(new Property("identifier", "Identifier", "Identifiers assigned to this order by the order sender or by the order receiver.", 0, java.lang.Integer.MAX_VALUE, identifier));
2620        childrenList.add(new Property("encounter", "Reference(Encounter)", "An encounter that provides additional information about the healthcare context in which this request is made.", 0, java.lang.Integer.MAX_VALUE, encounter));
2621        childrenList.add(new Property("dateTime", "dateTime", "The date and time that this nutrition order was requested.", 0, java.lang.Integer.MAX_VALUE, dateTime));
2622        childrenList.add(new Property("status", "code", "The workflow status of the nutrition order/request.", 0, java.lang.Integer.MAX_VALUE, status));
2623        childrenList.add(new Property("allergyIntolerance", "Reference(AllergyIntolerance)", "A link to a record of allergies or intolerances  which should be included in the nutrition order.", 0, java.lang.Integer.MAX_VALUE, allergyIntolerance));
2624        childrenList.add(new Property("foodPreferenceModifier", "CodeableConcept", "This modifier is used to convey order-specific modifiers about the type of food that should be given. These can be derived from patient allergies, intolerances, or preferences such as Halal, Vegan or Kosher. This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings.", 0, java.lang.Integer.MAX_VALUE, foodPreferenceModifier));
2625        childrenList.add(new Property("excludeFoodModifier", "CodeableConcept", "This modifier is used to convey order-specific modifiers about the type of food that should NOT be given. These can be derived from patient allergies, intolerances, or preferences such as No Red Meat, No Soy or No Wheat or  Gluten-Free.  While it should not be necessary to repeat allergy or intolerance information captured in the referenced allergyIntolerance resource in the excludeFoodModifier, this element may be used to convey additional specificity related to foods that should be eliminated from the patient’s diet for any reason.  This modifier applies to the entire nutrition order inclusive of the oral diet, nutritional supplements and enteral formula feedings.", 0, java.lang.Integer.MAX_VALUE, excludeFoodModifier));
2626        childrenList.add(new Property("oralDiet", "", "Diet given orally in contrast to enteral (tube) feeding.", 0, java.lang.Integer.MAX_VALUE, oralDiet));
2627        childrenList.add(new Property("supplement", "", "Oral nutritional products given in order to add further nutritional value to the patient's diet.", 0, java.lang.Integer.MAX_VALUE, supplement));
2628        childrenList.add(new Property("enteralFormula", "", "Feeding provided through the gastrointestinal tract via a tube, catheter, or stoma that delivers nutrition distal to the oral cavity.", 0, java.lang.Integer.MAX_VALUE, enteralFormula));
2629      }
2630
2631      @Override
2632      public void setProperty(String name, Base value) throws FHIRException {
2633        if (name.equals("patient"))
2634          this.patient = castToReference(value); // Reference
2635        else if (name.equals("orderer"))
2636          this.orderer = castToReference(value); // Reference
2637        else if (name.equals("identifier"))
2638          this.getIdentifier().add(castToIdentifier(value));
2639        else if (name.equals("encounter"))
2640          this.encounter = castToReference(value); // Reference
2641        else if (name.equals("dateTime"))
2642          this.dateTime = castToDateTime(value); // DateTimeType
2643        else if (name.equals("status"))
2644          this.status = new NutritionOrderStatusEnumFactory().fromType(value); // Enumeration<NutritionOrderStatus>
2645        else if (name.equals("allergyIntolerance"))
2646          this.getAllergyIntolerance().add(castToReference(value));
2647        else if (name.equals("foodPreferenceModifier"))
2648          this.getFoodPreferenceModifier().add(castToCodeableConcept(value));
2649        else if (name.equals("excludeFoodModifier"))
2650          this.getExcludeFoodModifier().add(castToCodeableConcept(value));
2651        else if (name.equals("oralDiet"))
2652          this.oralDiet = (NutritionOrderOralDietComponent) value; // NutritionOrderOralDietComponent
2653        else if (name.equals("supplement"))
2654          this.getSupplement().add((NutritionOrderSupplementComponent) value);
2655        else if (name.equals("enteralFormula"))
2656          this.enteralFormula = (NutritionOrderEnteralFormulaComponent) value; // NutritionOrderEnteralFormulaComponent
2657        else
2658          super.setProperty(name, value);
2659      }
2660
2661      @Override
2662      public Base addChild(String name) throws FHIRException {
2663        if (name.equals("patient")) {
2664          this.patient = new Reference();
2665          return this.patient;
2666        }
2667        else if (name.equals("orderer")) {
2668          this.orderer = new Reference();
2669          return this.orderer;
2670        }
2671        else if (name.equals("identifier")) {
2672          return addIdentifier();
2673        }
2674        else if (name.equals("encounter")) {
2675          this.encounter = new Reference();
2676          return this.encounter;
2677        }
2678        else if (name.equals("dateTime")) {
2679          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.dateTime");
2680        }
2681        else if (name.equals("status")) {
2682          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.status");
2683        }
2684        else if (name.equals("allergyIntolerance")) {
2685          return addAllergyIntolerance();
2686        }
2687        else if (name.equals("foodPreferenceModifier")) {
2688          return addFoodPreferenceModifier();
2689        }
2690        else if (name.equals("excludeFoodModifier")) {
2691          return addExcludeFoodModifier();
2692        }
2693        else if (name.equals("oralDiet")) {
2694          this.oralDiet = new NutritionOrderOralDietComponent();
2695          return this.oralDiet;
2696        }
2697        else if (name.equals("supplement")) {
2698          return addSupplement();
2699        }
2700        else if (name.equals("enteralFormula")) {
2701          this.enteralFormula = new NutritionOrderEnteralFormulaComponent();
2702          return this.enteralFormula;
2703        }
2704        else
2705          return super.addChild(name);
2706      }
2707
2708  public String fhirType() {
2709    return "NutritionOrder";
2710
2711  }
2712
2713      public NutritionOrder copy() {
2714        NutritionOrder dst = new NutritionOrder();
2715        copyValues(dst);
2716        dst.patient = patient == null ? null : patient.copy();
2717        dst.orderer = orderer == null ? null : orderer.copy();
2718        if (identifier != null) {
2719          dst.identifier = new ArrayList<Identifier>();
2720          for (Identifier i : identifier)
2721            dst.identifier.add(i.copy());
2722        };
2723        dst.encounter = encounter == null ? null : encounter.copy();
2724        dst.dateTime = dateTime == null ? null : dateTime.copy();
2725        dst.status = status == null ? null : status.copy();
2726        if (allergyIntolerance != null) {
2727          dst.allergyIntolerance = new ArrayList<Reference>();
2728          for (Reference i : allergyIntolerance)
2729            dst.allergyIntolerance.add(i.copy());
2730        };
2731        if (foodPreferenceModifier != null) {
2732          dst.foodPreferenceModifier = new ArrayList<CodeableConcept>();
2733          for (CodeableConcept i : foodPreferenceModifier)
2734            dst.foodPreferenceModifier.add(i.copy());
2735        };
2736        if (excludeFoodModifier != null) {
2737          dst.excludeFoodModifier = new ArrayList<CodeableConcept>();
2738          for (CodeableConcept i : excludeFoodModifier)
2739            dst.excludeFoodModifier.add(i.copy());
2740        };
2741        dst.oralDiet = oralDiet == null ? null : oralDiet.copy();
2742        if (supplement != null) {
2743          dst.supplement = new ArrayList<NutritionOrderSupplementComponent>();
2744          for (NutritionOrderSupplementComponent i : supplement)
2745            dst.supplement.add(i.copy());
2746        };
2747        dst.enteralFormula = enteralFormula == null ? null : enteralFormula.copy();
2748        return dst;
2749      }
2750
2751      protected NutritionOrder typedCopy() {
2752        return copy();
2753      }
2754
2755      @Override
2756      public boolean equalsDeep(Base other) {
2757        if (!super.equalsDeep(other))
2758          return false;
2759        if (!(other instanceof NutritionOrder))
2760          return false;
2761        NutritionOrder o = (NutritionOrder) other;
2762        return compareDeep(patient, o.patient, true) && compareDeep(orderer, o.orderer, true) && compareDeep(identifier, o.identifier, true)
2763           && compareDeep(encounter, o.encounter, true) && compareDeep(dateTime, o.dateTime, true) && compareDeep(status, o.status, true)
2764           && compareDeep(allergyIntolerance, o.allergyIntolerance, true) && compareDeep(foodPreferenceModifier, o.foodPreferenceModifier, true)
2765           && compareDeep(excludeFoodModifier, o.excludeFoodModifier, true) && compareDeep(oralDiet, o.oralDiet, true)
2766           && compareDeep(supplement, o.supplement, true) && compareDeep(enteralFormula, o.enteralFormula, true)
2767          ;
2768      }
2769
2770      @Override
2771      public boolean equalsShallow(Base other) {
2772        if (!super.equalsShallow(other))
2773          return false;
2774        if (!(other instanceof NutritionOrder))
2775          return false;
2776        NutritionOrder o = (NutritionOrder) other;
2777        return compareValues(dateTime, o.dateTime, true) && compareValues(status, o.status, true);
2778      }
2779
2780      public boolean isEmpty() {
2781        return super.isEmpty() && (patient == null || patient.isEmpty()) && (orderer == null || orderer.isEmpty())
2782           && (identifier == null || identifier.isEmpty()) && (encounter == null || encounter.isEmpty())
2783           && (dateTime == null || dateTime.isEmpty()) && (status == null || status.isEmpty()) && (allergyIntolerance == null || allergyIntolerance.isEmpty())
2784           && (foodPreferenceModifier == null || foodPreferenceModifier.isEmpty()) && (excludeFoodModifier == null || excludeFoodModifier.isEmpty())
2785           && (oralDiet == null || oralDiet.isEmpty()) && (supplement == null || supplement.isEmpty())
2786           && (enteralFormula == null || enteralFormula.isEmpty());
2787      }
2788
2789  @Override
2790  public ResourceType getResourceType() {
2791    return ResourceType.NutritionOrder;
2792   }
2793
2794  @SearchParamDefinition(name="identifier", path="NutritionOrder.identifier", description="Return nutrition orders with this external identifier", type="token" )
2795  public static final String SP_IDENTIFIER = "identifier";
2796  @SearchParamDefinition(name="datetime", path="NutritionOrder.dateTime", description="Return nutrition orders requested on this date", type="date" )
2797  public static final String SP_DATETIME = "datetime";
2798  @SearchParamDefinition(name="provider", path="NutritionOrder.orderer", description="The identify of the provider who placed the nutrition order", type="reference" )
2799  public static final String SP_PROVIDER = "provider";
2800  @SearchParamDefinition(name="patient", path="NutritionOrder.patient", description="The identity of the person who requires the diet, formula or nutritional supplement", type="reference" )
2801  public static final String SP_PATIENT = "patient";
2802  @SearchParamDefinition(name="supplement", path="NutritionOrder.supplement.type", description="Type of supplement product requested", type="token" )
2803  public static final String SP_SUPPLEMENT = "supplement";
2804  @SearchParamDefinition(name="formula", path="NutritionOrder.enteralFormula.baseFormulaType", description="Type of enteral or infant formula", type="token" )
2805  public static final String SP_FORMULA = "formula";
2806  @SearchParamDefinition(name="encounter", path="NutritionOrder.encounter", description="Return nutrition orders with this encounter identifier", type="reference" )
2807  public static final String SP_ENCOUNTER = "encounter";
2808  @SearchParamDefinition(name="oraldiet", path="NutritionOrder.oralDiet.type", description="Type of diet that can be consumed orally (i.e., take via the mouth).", type="token" )
2809  public static final String SP_ORALDIET = "oraldiet";
2810  @SearchParamDefinition(name="status", path="NutritionOrder.status", description="Status of the nutrition order.", type="token" )
2811  public static final String SP_STATUS = "status";
2812  @SearchParamDefinition(name="additive", path="NutritionOrder.enteralFormula.additiveType", description="Type of module component to add to the feeding", type="token" )
2813  public static final String SP_ADDITIVE = "additive";
2814
2815}