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