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