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