001package org.hl7.fhir.dstu3.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * A request to supply a diet, formula feeding (enteral) or oral nutritional supplement to a patient/resident.
047 */
048@ResourceDef(name="NutritionOrder", profile="http://hl7.org/fhir/Profile/NutritionOrder")
049public class NutritionOrder extends DomainResource {
050
051    public enum NutritionOrderStatus {
052        /**
053         * The request has been proposed.
054         */
055        PROPOSED, 
056        /**
057         * The request is in preliminary form prior to being sent.
058         */
059        DRAFT, 
060        /**
061         * The request has been planned.
062         */
063        PLANNED, 
064        /**
065         * The request has been placed.
066         */
067        REQUESTED, 
068        /**
069         * The request is 'actionable', but not all actions that are implied by it have occurred yet.
070         */
071        ACTIVE, 
072        /**
073         * Actions implied by the request have been temporarily halted, but are expected to continue later. May also be called "suspended".
074         */
075        ONHOLD, 
076        /**
077         * All actions that are implied by the order have occurred and no continuation is planned (this will rarely be made explicit).
078         */
079        COMPLETED, 
080        /**
081         * The request has been withdrawn and is no longer actionable.
082         */
083        CANCELLED, 
084        /**
085         * The request was entered in error and voided.
086         */
087        ENTEREDINERROR, 
088        /**
089         * added to help the parsers with the generic types
090         */
091        NULL;
092        public static NutritionOrderStatus fromCode(String codeString) throws FHIRException {
093            if (codeString == null || "".equals(codeString))
094                return null;
095        if ("proposed".equals(codeString))
096          return PROPOSED;
097        if ("draft".equals(codeString))
098          return DRAFT;
099        if ("planned".equals(codeString))
100          return PLANNED;
101        if ("requested".equals(codeString))
102          return REQUESTED;
103        if ("active".equals(codeString))
104          return ACTIVE;
105        if ("on-hold".equals(codeString))
106          return ONHOLD;
107        if ("completed".equals(codeString))
108          return COMPLETED;
109        if ("cancelled".equals(codeString))
110          return CANCELLED;
111        if ("entered-in-error".equals(codeString))
112          return ENTEREDINERROR;
113        if (Configuration.isAcceptInvalidEnums())
114          return null;
115        else
116          throw new FHIRException("Unknown NutritionOrderStatus code '"+codeString+"'");
117        }
118        public String toCode() {
119          switch (this) {
120            case PROPOSED: return "proposed";
121            case DRAFT: return "draft";
122            case PLANNED: return "planned";
123            case REQUESTED: return "requested";
124            case ACTIVE: return "active";
125            case ONHOLD: return "on-hold";
126            case COMPLETED: return "completed";
127            case CANCELLED: return "cancelled";
128            case ENTEREDINERROR: return "entered-in-error";
129            default: return "?";
130          }
131        }
132        public String getSystem() {
133          switch (this) {
134            case PROPOSED: return "http://hl7.org/fhir/nutrition-request-status";
135            case DRAFT: return "http://hl7.org/fhir/nutrition-request-status";
136            case PLANNED: return "http://hl7.org/fhir/nutrition-request-status";
137            case REQUESTED: return "http://hl7.org/fhir/nutrition-request-status";
138            case ACTIVE: return "http://hl7.org/fhir/nutrition-request-status";
139            case ONHOLD: return "http://hl7.org/fhir/nutrition-request-status";
140            case COMPLETED: return "http://hl7.org/fhir/nutrition-request-status";
141            case CANCELLED: return "http://hl7.org/fhir/nutrition-request-status";
142            case ENTEREDINERROR: return "http://hl7.org/fhir/nutrition-request-status";
143            default: return "?";
144          }
145        }
146        public String getDefinition() {
147          switch (this) {
148            case PROPOSED: return "The request has been proposed.";
149            case DRAFT: return "The request is in preliminary form prior to being sent.";
150            case PLANNED: return "The request has been planned.";
151            case REQUESTED: return "The request has been placed.";
152            case ACTIVE: return "The request is 'actionable', but not all actions that are implied by it have occurred yet.";
153            case ONHOLD: return "Actions implied by the request have been temporarily halted, but are expected to continue later. May also be called \"suspended\".";
154            case COMPLETED: return "All actions that are implied by the order have occurred and no continuation is planned (this will rarely be made explicit).";
155            case CANCELLED: return "The request has been withdrawn and is no longer actionable.";
156            case ENTEREDINERROR: return "The request was entered in error and voided.";
157            default: return "?";
158          }
159        }
160        public String getDisplay() {
161          switch (this) {
162            case PROPOSED: return "Proposed";
163            case DRAFT: return "Draft";
164            case PLANNED: return "Planned";
165            case REQUESTED: return "Requested";
166            case ACTIVE: return "Active";
167            case ONHOLD: return "On-Hold";
168            case COMPLETED: return "Completed";
169            case CANCELLED: return "Cancelled";
170            case ENTEREDINERROR: return "Entered in Error";
171            default: return "?";
172          }
173        }
174    }
175
176  public static class NutritionOrderStatusEnumFactory implements EnumFactory<NutritionOrderStatus> {
177    public NutritionOrderStatus fromCode(String codeString) throws IllegalArgumentException {
178      if (codeString == null || "".equals(codeString))
179            if (codeString == null || "".equals(codeString))
180                return null;
181        if ("proposed".equals(codeString))
182          return NutritionOrderStatus.PROPOSED;
183        if ("draft".equals(codeString))
184          return NutritionOrderStatus.DRAFT;
185        if ("planned".equals(codeString))
186          return NutritionOrderStatus.PLANNED;
187        if ("requested".equals(codeString))
188          return NutritionOrderStatus.REQUESTED;
189        if ("active".equals(codeString))
190          return NutritionOrderStatus.ACTIVE;
191        if ("on-hold".equals(codeString))
192          return NutritionOrderStatus.ONHOLD;
193        if ("completed".equals(codeString))
194          return NutritionOrderStatus.COMPLETED;
195        if ("cancelled".equals(codeString))
196          return NutritionOrderStatus.CANCELLED;
197        if ("entered-in-error".equals(codeString))
198          return NutritionOrderStatus.ENTEREDINERROR;
199        throw new IllegalArgumentException("Unknown NutritionOrderStatus code '"+codeString+"'");
200        }
201        public Enumeration<NutritionOrderStatus> fromType(Base code) throws FHIRException {
202          if (code == null)
203            return null;
204          if (code.isEmpty())
205            return new Enumeration<NutritionOrderStatus>(this);
206          String codeString = ((PrimitiveType) code).asStringValue();
207          if (codeString == null || "".equals(codeString))
208            return null;
209        if ("proposed".equals(codeString))
210          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.PROPOSED);
211        if ("draft".equals(codeString))
212          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.DRAFT);
213        if ("planned".equals(codeString))
214          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.PLANNED);
215        if ("requested".equals(codeString))
216          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.REQUESTED);
217        if ("active".equals(codeString))
218          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.ACTIVE);
219        if ("on-hold".equals(codeString))
220          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.ONHOLD);
221        if ("completed".equals(codeString))
222          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.COMPLETED);
223        if ("cancelled".equals(codeString))
224          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.CANCELLED);
225        if ("entered-in-error".equals(codeString))
226          return new Enumeration<NutritionOrderStatus>(this, NutritionOrderStatus.ENTEREDINERROR);
227        throw new FHIRException("Unknown NutritionOrderStatus code '"+codeString+"'");
228        }
229    public String toCode(NutritionOrderStatus code) {
230      if (code == NutritionOrderStatus.PROPOSED)
231        return "proposed";
232      if (code == NutritionOrderStatus.DRAFT)
233        return "draft";
234      if (code == NutritionOrderStatus.PLANNED)
235        return "planned";
236      if (code == NutritionOrderStatus.REQUESTED)
237        return "requested";
238      if (code == NutritionOrderStatus.ACTIVE)
239        return "active";
240      if (code == NutritionOrderStatus.ONHOLD)
241        return "on-hold";
242      if (code == NutritionOrderStatus.COMPLETED)
243        return "completed";
244      if (code == NutritionOrderStatus.CANCELLED)
245        return "cancelled";
246      if (code == NutritionOrderStatus.ENTEREDINERROR)
247        return "entered-in-error";
248      return "?";
249      }
250    public String toSystem(NutritionOrderStatus code) {
251      return code.getSystem();
252      }
253    }
254
255    @Block()
256    public static class NutritionOrderOralDietComponent extends BackboneElement implements IBaseBackboneElement {
257        /**
258         * The kind of diet or dietary restriction such as fiber restricted diet or diabetic diet.
259         */
260        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
261        @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." )
262        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/diet-type")
263        protected List<CodeableConcept> type;
264
265        /**
266         * The time period and frequency at which the diet should be given.  The diet should be given for the combination of all schedules if more than one schedule is present.
267         */
268        @Child(name = "schedule", type = {Timing.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
269        @Description(shortDefinition="Scheduled frequency of diet", formalDefinition="The time period and frequency at which the diet should be given.  The diet should be given for the combination of all schedules if more than one schedule is present." )
270        protected List<Timing> schedule;
271
272        /**
273         * Class that defines the quantity and type of nutrient modifications (for example carbohydrate, fiber or sodium) required for the oral diet.
274         */
275        @Child(name = "nutrient", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
276        @Description(shortDefinition="Required  nutrient modifications", formalDefinition="Class that defines the quantity and type of nutrient modifications (for example carbohydrate, fiber or sodium) required for the oral diet." )
277        protected List<NutritionOrderOralDietNutrientComponent> nutrient;
278
279        /**
280         * Class that describes any texture modifications required for the patient to safely consume various types of solid foods.
281         */
282        @Child(name = "texture", type = {}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
283        @Description(shortDefinition="Required  texture modifications", formalDefinition="Class that describes any texture modifications required for the patient to safely consume various types of solid foods." )
284        protected List<NutritionOrderOralDietTextureComponent> texture;
285
286        /**
287         * The required consistency (e.g. honey-thick, nectar-thick, thin, thickened.) of liquids or fluids served to the patient.
288         */
289        @Child(name = "fluidConsistencyType", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
290        @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." )
291        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/consistency-type")
292        protected List<CodeableConcept> fluidConsistencyType;
293
294        /**
295         * Free text or additional instructions or information pertaining to the oral diet.
296         */
297        @Child(name = "instruction", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
298        @Description(shortDefinition="Instructions or additional information about the oral diet", formalDefinition="Free text or additional instructions or information pertaining to the oral diet." )
299        protected StringType instruction;
300
301        private static final long serialVersionUID = 973058412L;
302
303    /**
304     * Constructor
305     */
306      public NutritionOrderOralDietComponent() {
307        super();
308      }
309
310        /**
311         * @return {@link #type} (The kind of diet or dietary restriction such as fiber restricted diet or diabetic diet.)
312         */
313        public List<CodeableConcept> getType() { 
314          if (this.type == null)
315            this.type = new ArrayList<CodeableConcept>();
316          return this.type;
317        }
318
319        /**
320         * @return Returns a reference to <code>this</code> for easy method chaining
321         */
322        public NutritionOrderOralDietComponent setType(List<CodeableConcept> theType) { 
323          this.type = theType;
324          return this;
325        }
326
327        public boolean hasType() { 
328          if (this.type == null)
329            return false;
330          for (CodeableConcept item : this.type)
331            if (!item.isEmpty())
332              return true;
333          return false;
334        }
335
336        public CodeableConcept addType() { //3
337          CodeableConcept t = new CodeableConcept();
338          if (this.type == null)
339            this.type = new ArrayList<CodeableConcept>();
340          this.type.add(t);
341          return t;
342        }
343
344        public NutritionOrderOralDietComponent addType(CodeableConcept t) { //3
345          if (t == null)
346            return this;
347          if (this.type == null)
348            this.type = new ArrayList<CodeableConcept>();
349          this.type.add(t);
350          return this;
351        }
352
353        /**
354         * @return The first repetition of repeating field {@link #type}, creating it if it does not already exist
355         */
356        public CodeableConcept getTypeFirstRep() { 
357          if (getType().isEmpty()) {
358            addType();
359          }
360          return getType().get(0);
361        }
362
363        /**
364         * @return {@link #schedule} (The time period and frequency at which the diet should be given.  The diet should be given for the combination of all schedules if more than one schedule is present.)
365         */
366        public List<Timing> getSchedule() { 
367          if (this.schedule == null)
368            this.schedule = new ArrayList<Timing>();
369          return this.schedule;
370        }
371
372        /**
373         * @return Returns a reference to <code>this</code> for easy method chaining
374         */
375        public NutritionOrderOralDietComponent setSchedule(List<Timing> theSchedule) { 
376          this.schedule = theSchedule;
377          return this;
378        }
379
380        public boolean hasSchedule() { 
381          if (this.schedule == null)
382            return false;
383          for (Timing item : this.schedule)
384            if (!item.isEmpty())
385              return true;
386          return false;
387        }
388
389        public Timing addSchedule() { //3
390          Timing t = new Timing();
391          if (this.schedule == null)
392            this.schedule = new ArrayList<Timing>();
393          this.schedule.add(t);
394          return t;
395        }
396
397        public NutritionOrderOralDietComponent addSchedule(Timing t) { //3
398          if (t == null)
399            return this;
400          if (this.schedule == null)
401            this.schedule = new ArrayList<Timing>();
402          this.schedule.add(t);
403          return this;
404        }
405
406        /**
407         * @return The first repetition of repeating field {@link #schedule}, creating it if it does not already exist
408         */
409        public Timing getScheduleFirstRep() { 
410          if (getSchedule().isEmpty()) {
411            addSchedule();
412          }
413          return getSchedule().get(0);
414        }
415
416        /**
417         * @return {@link #nutrient} (Class that defines the quantity and type of nutrient modifications (for example carbohydrate, fiber or sodium) required for the oral diet.)
418         */
419        public List<NutritionOrderOralDietNutrientComponent> getNutrient() { 
420          if (this.nutrient == null)
421            this.nutrient = new ArrayList<NutritionOrderOralDietNutrientComponent>();
422          return this.nutrient;
423        }
424
425        /**
426         * @return Returns a reference to <code>this</code> for easy method chaining
427         */
428        public NutritionOrderOralDietComponent setNutrient(List<NutritionOrderOralDietNutrientComponent> theNutrient) { 
429          this.nutrient = theNutrient;
430          return this;
431        }
432
433        public boolean hasNutrient() { 
434          if (this.nutrient == null)
435            return false;
436          for (NutritionOrderOralDietNutrientComponent item : this.nutrient)
437            if (!item.isEmpty())
438              return true;
439          return false;
440        }
441
442        public NutritionOrderOralDietNutrientComponent addNutrient() { //3
443          NutritionOrderOralDietNutrientComponent t = new NutritionOrderOralDietNutrientComponent();
444          if (this.nutrient == null)
445            this.nutrient = new ArrayList<NutritionOrderOralDietNutrientComponent>();
446          this.nutrient.add(t);
447          return t;
448        }
449
450        public NutritionOrderOralDietComponent addNutrient(NutritionOrderOralDietNutrientComponent t) { //3
451          if (t == null)
452            return this;
453          if (this.nutrient == null)
454            this.nutrient = new ArrayList<NutritionOrderOralDietNutrientComponent>();
455          this.nutrient.add(t);
456          return this;
457        }
458
459        /**
460         * @return The first repetition of repeating field {@link #nutrient}, creating it if it does not already exist
461         */
462        public NutritionOrderOralDietNutrientComponent getNutrientFirstRep() { 
463          if (getNutrient().isEmpty()) {
464            addNutrient();
465          }
466          return getNutrient().get(0);
467        }
468
469        /**
470         * @return {@link #texture} (Class that describes any texture modifications required for the patient to safely consume various types of solid foods.)
471         */
472        public List<NutritionOrderOralDietTextureComponent> getTexture() { 
473          if (this.texture == null)
474            this.texture = new ArrayList<NutritionOrderOralDietTextureComponent>();
475          return this.texture;
476        }
477
478        /**
479         * @return Returns a reference to <code>this</code> for easy method chaining
480         */
481        public NutritionOrderOralDietComponent setTexture(List<NutritionOrderOralDietTextureComponent> theTexture) { 
482          this.texture = theTexture;
483          return this;
484        }
485
486        public boolean hasTexture() { 
487          if (this.texture == null)
488            return false;
489          for (NutritionOrderOralDietTextureComponent item : this.texture)
490            if (!item.isEmpty())
491              return true;
492          return false;
493        }
494
495        public NutritionOrderOralDietTextureComponent addTexture() { //3
496          NutritionOrderOralDietTextureComponent t = new NutritionOrderOralDietTextureComponent();
497          if (this.texture == null)
498            this.texture = new ArrayList<NutritionOrderOralDietTextureComponent>();
499          this.texture.add(t);
500          return t;
501        }
502
503        public NutritionOrderOralDietComponent addTexture(NutritionOrderOralDietTextureComponent t) { //3
504          if (t == null)
505            return this;
506          if (this.texture == null)
507            this.texture = new ArrayList<NutritionOrderOralDietTextureComponent>();
508          this.texture.add(t);
509          return this;
510        }
511
512        /**
513         * @return The first repetition of repeating field {@link #texture}, creating it if it does not already exist
514         */
515        public NutritionOrderOralDietTextureComponent getTextureFirstRep() { 
516          if (getTexture().isEmpty()) {
517            addTexture();
518          }
519          return getTexture().get(0);
520        }
521
522        /**
523         * @return {@link #fluidConsistencyType} (The required consistency (e.g. honey-thick, nectar-thick, thin, thickened.) of liquids or fluids served to the patient.)
524         */
525        public List<CodeableConcept> getFluidConsistencyType() { 
526          if (this.fluidConsistencyType == null)
527            this.fluidConsistencyType = new ArrayList<CodeableConcept>();
528          return this.fluidConsistencyType;
529        }
530
531        /**
532         * @return Returns a reference to <code>this</code> for easy method chaining
533         */
534        public NutritionOrderOralDietComponent setFluidConsistencyType(List<CodeableConcept> theFluidConsistencyType) { 
535          this.fluidConsistencyType = theFluidConsistencyType;
536          return this;
537        }
538
539        public boolean hasFluidConsistencyType() { 
540          if (this.fluidConsistencyType == null)
541            return false;
542          for (CodeableConcept item : this.fluidConsistencyType)
543            if (!item.isEmpty())
544              return true;
545          return false;
546        }
547
548        public CodeableConcept addFluidConsistencyType() { //3
549          CodeableConcept t = new CodeableConcept();
550          if (this.fluidConsistencyType == null)
551            this.fluidConsistencyType = new ArrayList<CodeableConcept>();
552          this.fluidConsistencyType.add(t);
553          return t;
554        }
555
556        public NutritionOrderOralDietComponent addFluidConsistencyType(CodeableConcept t) { //3
557          if (t == null)
558            return this;
559          if (this.fluidConsistencyType == null)
560            this.fluidConsistencyType = new ArrayList<CodeableConcept>();
561          this.fluidConsistencyType.add(t);
562          return this;
563        }
564
565        /**
566         * @return The first repetition of repeating field {@link #fluidConsistencyType}, creating it if it does not already exist
567         */
568        public CodeableConcept getFluidConsistencyTypeFirstRep() { 
569          if (getFluidConsistencyType().isEmpty()) {
570            addFluidConsistencyType();
571          }
572          return getFluidConsistencyType().get(0);
573        }
574
575        /**
576         * @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
577         */
578        public StringType getInstructionElement() { 
579          if (this.instruction == null)
580            if (Configuration.errorOnAutoCreate())
581              throw new Error("Attempt to auto-create NutritionOrderOralDietComponent.instruction");
582            else if (Configuration.doAutoCreate())
583              this.instruction = new StringType(); // bb
584          return this.instruction;
585        }
586
587        public boolean hasInstructionElement() { 
588          return this.instruction != null && !this.instruction.isEmpty();
589        }
590
591        public boolean hasInstruction() { 
592          return this.instruction != null && !this.instruction.isEmpty();
593        }
594
595        /**
596         * @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
597         */
598        public NutritionOrderOralDietComponent setInstructionElement(StringType value) { 
599          this.instruction = value;
600          return this;
601        }
602
603        /**
604         * @return Free text or additional instructions or information pertaining to the oral diet.
605         */
606        public String getInstruction() { 
607          return this.instruction == null ? null : this.instruction.getValue();
608        }
609
610        /**
611         * @param value Free text or additional instructions or information pertaining to the oral diet.
612         */
613        public NutritionOrderOralDietComponent setInstruction(String value) { 
614          if (Utilities.noString(value))
615            this.instruction = null;
616          else {
617            if (this.instruction == null)
618              this.instruction = new StringType();
619            this.instruction.setValue(value);
620          }
621          return this;
622        }
623
624        protected void listChildren(List<Property> childrenList) {
625          super.listChildren(childrenList);
626          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));
627          childrenList.add(new Property("schedule", "Timing", "The time period and frequency at which the diet should be given.  The diet should be given for the combination of all schedules if more than one schedule is present.", 0, java.lang.Integer.MAX_VALUE, schedule));
628          childrenList.add(new Property("nutrient", "", "Class that defines the quantity and type of nutrient modifications (for example carbohydrate, fiber or sodium) required for the oral diet.", 0, java.lang.Integer.MAX_VALUE, nutrient));
629          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));
630          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));
631          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));
632        }
633
634      @Override
635      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
636        switch (hash) {
637        case 3575610: /*type*/ return this.type == null ? new Base[0] : this.type.toArray(new Base[this.type.size()]); // CodeableConcept
638        case -697920873: /*schedule*/ return this.schedule == null ? new Base[0] : this.schedule.toArray(new Base[this.schedule.size()]); // Timing
639        case -1671151641: /*nutrient*/ return this.nutrient == null ? new Base[0] : this.nutrient.toArray(new Base[this.nutrient.size()]); // NutritionOrderOralDietNutrientComponent
640        case -1417816805: /*texture*/ return this.texture == null ? new Base[0] : this.texture.toArray(new Base[this.texture.size()]); // NutritionOrderOralDietTextureComponent
641        case -525105592: /*fluidConsistencyType*/ return this.fluidConsistencyType == null ? new Base[0] : this.fluidConsistencyType.toArray(new Base[this.fluidConsistencyType.size()]); // CodeableConcept
642        case 301526158: /*instruction*/ return this.instruction == null ? new Base[0] : new Base[] {this.instruction}; // StringType
643        default: return super.getProperty(hash, name, checkValid);
644        }
645
646      }
647
648      @Override
649      public Base setProperty(int hash, String name, Base value) throws FHIRException {
650        switch (hash) {
651        case 3575610: // type
652          this.getType().add(castToCodeableConcept(value)); // CodeableConcept
653          return value;
654        case -697920873: // schedule
655          this.getSchedule().add(castToTiming(value)); // Timing
656          return value;
657        case -1671151641: // nutrient
658          this.getNutrient().add((NutritionOrderOralDietNutrientComponent) value); // NutritionOrderOralDietNutrientComponent
659          return value;
660        case -1417816805: // texture
661          this.getTexture().add((NutritionOrderOralDietTextureComponent) value); // NutritionOrderOralDietTextureComponent
662          return value;
663        case -525105592: // fluidConsistencyType
664          this.getFluidConsistencyType().add(castToCodeableConcept(value)); // CodeableConcept
665          return value;
666        case 301526158: // instruction
667          this.instruction = castToString(value); // StringType
668          return value;
669        default: return super.setProperty(hash, name, value);
670        }
671
672      }
673
674      @Override
675      public Base setProperty(String name, Base value) throws FHIRException {
676        if (name.equals("type")) {
677          this.getType().add(castToCodeableConcept(value));
678        } else if (name.equals("schedule")) {
679          this.getSchedule().add(castToTiming(value));
680        } else if (name.equals("nutrient")) {
681          this.getNutrient().add((NutritionOrderOralDietNutrientComponent) value);
682        } else if (name.equals("texture")) {
683          this.getTexture().add((NutritionOrderOralDietTextureComponent) value);
684        } else if (name.equals("fluidConsistencyType")) {
685          this.getFluidConsistencyType().add(castToCodeableConcept(value));
686        } else if (name.equals("instruction")) {
687          this.instruction = castToString(value); // StringType
688        } else
689          return super.setProperty(name, value);
690        return value;
691      }
692
693      @Override
694      public Base makeProperty(int hash, String name) throws FHIRException {
695        switch (hash) {
696        case 3575610:  return addType(); 
697        case -697920873:  return addSchedule(); 
698        case -1671151641:  return addNutrient(); 
699        case -1417816805:  return addTexture(); 
700        case -525105592:  return addFluidConsistencyType(); 
701        case 301526158:  return getInstructionElement();
702        default: return super.makeProperty(hash, name);
703        }
704
705      }
706
707      @Override
708      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
709        switch (hash) {
710        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
711        case -697920873: /*schedule*/ return new String[] {"Timing"};
712        case -1671151641: /*nutrient*/ return new String[] {};
713        case -1417816805: /*texture*/ return new String[] {};
714        case -525105592: /*fluidConsistencyType*/ return new String[] {"CodeableConcept"};
715        case 301526158: /*instruction*/ return new String[] {"string"};
716        default: return super.getTypesForProperty(hash, name);
717        }
718
719      }
720
721      @Override
722      public Base addChild(String name) throws FHIRException {
723        if (name.equals("type")) {
724          return addType();
725        }
726        else if (name.equals("schedule")) {
727          return addSchedule();
728        }
729        else if (name.equals("nutrient")) {
730          return addNutrient();
731        }
732        else if (name.equals("texture")) {
733          return addTexture();
734        }
735        else if (name.equals("fluidConsistencyType")) {
736          return addFluidConsistencyType();
737        }
738        else if (name.equals("instruction")) {
739          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.instruction");
740        }
741        else
742          return super.addChild(name);
743      }
744
745      public NutritionOrderOralDietComponent copy() {
746        NutritionOrderOralDietComponent dst = new NutritionOrderOralDietComponent();
747        copyValues(dst);
748        if (type != null) {
749          dst.type = new ArrayList<CodeableConcept>();
750          for (CodeableConcept i : type)
751            dst.type.add(i.copy());
752        };
753        if (schedule != null) {
754          dst.schedule = new ArrayList<Timing>();
755          for (Timing i : schedule)
756            dst.schedule.add(i.copy());
757        };
758        if (nutrient != null) {
759          dst.nutrient = new ArrayList<NutritionOrderOralDietNutrientComponent>();
760          for (NutritionOrderOralDietNutrientComponent i : nutrient)
761            dst.nutrient.add(i.copy());
762        };
763        if (texture != null) {
764          dst.texture = new ArrayList<NutritionOrderOralDietTextureComponent>();
765          for (NutritionOrderOralDietTextureComponent i : texture)
766            dst.texture.add(i.copy());
767        };
768        if (fluidConsistencyType != null) {
769          dst.fluidConsistencyType = new ArrayList<CodeableConcept>();
770          for (CodeableConcept i : fluidConsistencyType)
771            dst.fluidConsistencyType.add(i.copy());
772        };
773        dst.instruction = instruction == null ? null : instruction.copy();
774        return dst;
775      }
776
777      @Override
778      public boolean equalsDeep(Base other) {
779        if (!super.equalsDeep(other))
780          return false;
781        if (!(other instanceof NutritionOrderOralDietComponent))
782          return false;
783        NutritionOrderOralDietComponent o = (NutritionOrderOralDietComponent) other;
784        return compareDeep(type, o.type, true) && compareDeep(schedule, o.schedule, true) && compareDeep(nutrient, o.nutrient, true)
785           && compareDeep(texture, o.texture, true) && compareDeep(fluidConsistencyType, o.fluidConsistencyType, true)
786           && compareDeep(instruction, o.instruction, true);
787      }
788
789      @Override
790      public boolean equalsShallow(Base other) {
791        if (!super.equalsShallow(other))
792          return false;
793        if (!(other instanceof NutritionOrderOralDietComponent))
794          return false;
795        NutritionOrderOralDietComponent o = (NutritionOrderOralDietComponent) other;
796        return compareValues(instruction, o.instruction, true);
797      }
798
799      public boolean isEmpty() {
800        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, schedule, nutrient
801          , texture, fluidConsistencyType, instruction);
802      }
803
804  public String fhirType() {
805    return "NutritionOrder.oralDiet";
806
807  }
808
809  }
810
811    @Block()
812    public static class NutritionOrderOralDietNutrientComponent extends BackboneElement implements IBaseBackboneElement {
813        /**
814         * The nutrient that is being modified such as carbohydrate or sodium.
815         */
816        @Child(name = "modifier", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
817        @Description(shortDefinition="Type of nutrient that is being modified", formalDefinition="The nutrient that is being modified such as carbohydrate or sodium." )
818        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/nutrient-code")
819        protected CodeableConcept modifier;
820
821        /**
822         * The quantity of the specified nutrient to include in diet.
823         */
824        @Child(name = "amount", type = {SimpleQuantity.class}, order=2, min=0, max=1, modifier=false, summary=false)
825        @Description(shortDefinition="Quantity of the specified nutrient", formalDefinition="The quantity of the specified nutrient to include in diet." )
826        protected SimpleQuantity amount;
827
828        private static final long serialVersionUID = 465107295L;
829
830    /**
831     * Constructor
832     */
833      public NutritionOrderOralDietNutrientComponent() {
834        super();
835      }
836
837        /**
838         * @return {@link #modifier} (The nutrient that is being modified such as carbohydrate or sodium.)
839         */
840        public CodeableConcept getModifier() { 
841          if (this.modifier == null)
842            if (Configuration.errorOnAutoCreate())
843              throw new Error("Attempt to auto-create NutritionOrderOralDietNutrientComponent.modifier");
844            else if (Configuration.doAutoCreate())
845              this.modifier = new CodeableConcept(); // cc
846          return this.modifier;
847        }
848
849        public boolean hasModifier() { 
850          return this.modifier != null && !this.modifier.isEmpty();
851        }
852
853        /**
854         * @param value {@link #modifier} (The nutrient that is being modified such as carbohydrate or sodium.)
855         */
856        public NutritionOrderOralDietNutrientComponent setModifier(CodeableConcept value) { 
857          this.modifier = value;
858          return this;
859        }
860
861        /**
862         * @return {@link #amount} (The quantity of the specified nutrient to include in diet.)
863         */
864        public SimpleQuantity getAmount() { 
865          if (this.amount == null)
866            if (Configuration.errorOnAutoCreate())
867              throw new Error("Attempt to auto-create NutritionOrderOralDietNutrientComponent.amount");
868            else if (Configuration.doAutoCreate())
869              this.amount = new SimpleQuantity(); // cc
870          return this.amount;
871        }
872
873        public boolean hasAmount() { 
874          return this.amount != null && !this.amount.isEmpty();
875        }
876
877        /**
878         * @param value {@link #amount} (The quantity of the specified nutrient to include in diet.)
879         */
880        public NutritionOrderOralDietNutrientComponent setAmount(SimpleQuantity value) { 
881          this.amount = value;
882          return this;
883        }
884
885        protected void listChildren(List<Property> childrenList) {
886          super.listChildren(childrenList);
887          childrenList.add(new Property("modifier", "CodeableConcept", "The nutrient that is being modified such as carbohydrate or sodium.", 0, java.lang.Integer.MAX_VALUE, modifier));
888          childrenList.add(new Property("amount", "SimpleQuantity", "The quantity of the specified nutrient to include in diet.", 0, java.lang.Integer.MAX_VALUE, amount));
889        }
890
891      @Override
892      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
893        switch (hash) {
894        case -615513385: /*modifier*/ return this.modifier == null ? new Base[0] : new Base[] {this.modifier}; // CodeableConcept
895        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // SimpleQuantity
896        default: return super.getProperty(hash, name, checkValid);
897        }
898
899      }
900
901      @Override
902      public Base setProperty(int hash, String name, Base value) throws FHIRException {
903        switch (hash) {
904        case -615513385: // modifier
905          this.modifier = castToCodeableConcept(value); // CodeableConcept
906          return value;
907        case -1413853096: // amount
908          this.amount = castToSimpleQuantity(value); // SimpleQuantity
909          return value;
910        default: return super.setProperty(hash, name, value);
911        }
912
913      }
914
915      @Override
916      public Base setProperty(String name, Base value) throws FHIRException {
917        if (name.equals("modifier")) {
918          this.modifier = castToCodeableConcept(value); // CodeableConcept
919        } else if (name.equals("amount")) {
920          this.amount = castToSimpleQuantity(value); // SimpleQuantity
921        } else
922          return super.setProperty(name, value);
923        return value;
924      }
925
926      @Override
927      public Base makeProperty(int hash, String name) throws FHIRException {
928        switch (hash) {
929        case -615513385:  return getModifier(); 
930        case -1413853096:  return getAmount(); 
931        default: return super.makeProperty(hash, name);
932        }
933
934      }
935
936      @Override
937      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
938        switch (hash) {
939        case -615513385: /*modifier*/ return new String[] {"CodeableConcept"};
940        case -1413853096: /*amount*/ return new String[] {"SimpleQuantity"};
941        default: return super.getTypesForProperty(hash, name);
942        }
943
944      }
945
946      @Override
947      public Base addChild(String name) throws FHIRException {
948        if (name.equals("modifier")) {
949          this.modifier = new CodeableConcept();
950          return this.modifier;
951        }
952        else if (name.equals("amount")) {
953          this.amount = new SimpleQuantity();
954          return this.amount;
955        }
956        else
957          return super.addChild(name);
958      }
959
960      public NutritionOrderOralDietNutrientComponent copy() {
961        NutritionOrderOralDietNutrientComponent dst = new NutritionOrderOralDietNutrientComponent();
962        copyValues(dst);
963        dst.modifier = modifier == null ? null : modifier.copy();
964        dst.amount = amount == null ? null : amount.copy();
965        return dst;
966      }
967
968      @Override
969      public boolean equalsDeep(Base other) {
970        if (!super.equalsDeep(other))
971          return false;
972        if (!(other instanceof NutritionOrderOralDietNutrientComponent))
973          return false;
974        NutritionOrderOralDietNutrientComponent o = (NutritionOrderOralDietNutrientComponent) other;
975        return compareDeep(modifier, o.modifier, true) && compareDeep(amount, o.amount, true);
976      }
977
978      @Override
979      public boolean equalsShallow(Base other) {
980        if (!super.equalsShallow(other))
981          return false;
982        if (!(other instanceof NutritionOrderOralDietNutrientComponent))
983          return false;
984        NutritionOrderOralDietNutrientComponent o = (NutritionOrderOralDietNutrientComponent) other;
985        return true;
986      }
987
988      public boolean isEmpty() {
989        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifier, amount);
990      }
991
992  public String fhirType() {
993    return "NutritionOrder.oralDiet.nutrient";
994
995  }
996
997  }
998
999    @Block()
1000    public static class NutritionOrderOralDietTextureComponent extends BackboneElement implements IBaseBackboneElement {
1001        /**
1002         * Any texture modifications (for solid foods) that should be made, e.g. easy to chew, chopped, ground, and pureed.
1003         */
1004        @Child(name = "modifier", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=false)
1005        @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." )
1006        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/texture-code")
1007        protected CodeableConcept modifier;
1008
1009        /**
1010         * The food type(s) (e.g. meats, all foods)  that the texture modification applies to.  This could be all foods types.
1011         */
1012        @Child(name = "foodType", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
1013        @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." )
1014        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/modified-foodtype")
1015        protected CodeableConcept foodType;
1016
1017        private static final long serialVersionUID = -56402817L;
1018
1019    /**
1020     * Constructor
1021     */
1022      public NutritionOrderOralDietTextureComponent() {
1023        super();
1024      }
1025
1026        /**
1027         * @return {@link #modifier} (Any texture modifications (for solid foods) that should be made, e.g. easy to chew, chopped, ground, and pureed.)
1028         */
1029        public CodeableConcept getModifier() { 
1030          if (this.modifier == null)
1031            if (Configuration.errorOnAutoCreate())
1032              throw new Error("Attempt to auto-create NutritionOrderOralDietTextureComponent.modifier");
1033            else if (Configuration.doAutoCreate())
1034              this.modifier = new CodeableConcept(); // cc
1035          return this.modifier;
1036        }
1037
1038        public boolean hasModifier() { 
1039          return this.modifier != null && !this.modifier.isEmpty();
1040        }
1041
1042        /**
1043         * @param value {@link #modifier} (Any texture modifications (for solid foods) that should be made, e.g. easy to chew, chopped, ground, and pureed.)
1044         */
1045        public NutritionOrderOralDietTextureComponent setModifier(CodeableConcept value) { 
1046          this.modifier = value;
1047          return this;
1048        }
1049
1050        /**
1051         * @return {@link #foodType} (The food type(s) (e.g. meats, all foods)  that the texture modification applies to.  This could be all foods types.)
1052         */
1053        public CodeableConcept getFoodType() { 
1054          if (this.foodType == null)
1055            if (Configuration.errorOnAutoCreate())
1056              throw new Error("Attempt to auto-create NutritionOrderOralDietTextureComponent.foodType");
1057            else if (Configuration.doAutoCreate())
1058              this.foodType = new CodeableConcept(); // cc
1059          return this.foodType;
1060        }
1061
1062        public boolean hasFoodType() { 
1063          return this.foodType != null && !this.foodType.isEmpty();
1064        }
1065
1066        /**
1067         * @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.)
1068         */
1069        public NutritionOrderOralDietTextureComponent setFoodType(CodeableConcept value) { 
1070          this.foodType = value;
1071          return this;
1072        }
1073
1074        protected void listChildren(List<Property> childrenList) {
1075          super.listChildren(childrenList);
1076          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));
1077          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));
1078        }
1079
1080      @Override
1081      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1082        switch (hash) {
1083        case -615513385: /*modifier*/ return this.modifier == null ? new Base[0] : new Base[] {this.modifier}; // CodeableConcept
1084        case 379498680: /*foodType*/ return this.foodType == null ? new Base[0] : new Base[] {this.foodType}; // CodeableConcept
1085        default: return super.getProperty(hash, name, checkValid);
1086        }
1087
1088      }
1089
1090      @Override
1091      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1092        switch (hash) {
1093        case -615513385: // modifier
1094          this.modifier = castToCodeableConcept(value); // CodeableConcept
1095          return value;
1096        case 379498680: // foodType
1097          this.foodType = castToCodeableConcept(value); // CodeableConcept
1098          return value;
1099        default: return super.setProperty(hash, name, value);
1100        }
1101
1102      }
1103
1104      @Override
1105      public Base setProperty(String name, Base value) throws FHIRException {
1106        if (name.equals("modifier")) {
1107          this.modifier = castToCodeableConcept(value); // CodeableConcept
1108        } else if (name.equals("foodType")) {
1109          this.foodType = castToCodeableConcept(value); // CodeableConcept
1110        } else
1111          return super.setProperty(name, value);
1112        return value;
1113      }
1114
1115      @Override
1116      public Base makeProperty(int hash, String name) throws FHIRException {
1117        switch (hash) {
1118        case -615513385:  return getModifier(); 
1119        case 379498680:  return getFoodType(); 
1120        default: return super.makeProperty(hash, name);
1121        }
1122
1123      }
1124
1125      @Override
1126      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1127        switch (hash) {
1128        case -615513385: /*modifier*/ return new String[] {"CodeableConcept"};
1129        case 379498680: /*foodType*/ return new String[] {"CodeableConcept"};
1130        default: return super.getTypesForProperty(hash, name);
1131        }
1132
1133      }
1134
1135      @Override
1136      public Base addChild(String name) throws FHIRException {
1137        if (name.equals("modifier")) {
1138          this.modifier = new CodeableConcept();
1139          return this.modifier;
1140        }
1141        else if (name.equals("foodType")) {
1142          this.foodType = new CodeableConcept();
1143          return this.foodType;
1144        }
1145        else
1146          return super.addChild(name);
1147      }
1148
1149      public NutritionOrderOralDietTextureComponent copy() {
1150        NutritionOrderOralDietTextureComponent dst = new NutritionOrderOralDietTextureComponent();
1151        copyValues(dst);
1152        dst.modifier = modifier == null ? null : modifier.copy();
1153        dst.foodType = foodType == null ? null : foodType.copy();
1154        return dst;
1155      }
1156
1157      @Override
1158      public boolean equalsDeep(Base other) {
1159        if (!super.equalsDeep(other))
1160          return false;
1161        if (!(other instanceof NutritionOrderOralDietTextureComponent))
1162          return false;
1163        NutritionOrderOralDietTextureComponent o = (NutritionOrderOralDietTextureComponent) other;
1164        return compareDeep(modifier, o.modifier, true) && compareDeep(foodType, o.foodType, true);
1165      }
1166
1167      @Override
1168      public boolean equalsShallow(Base other) {
1169        if (!super.equalsShallow(other))
1170          return false;
1171        if (!(other instanceof NutritionOrderOralDietTextureComponent))
1172          return false;
1173        NutritionOrderOralDietTextureComponent o = (NutritionOrderOralDietTextureComponent) other;
1174        return true;
1175      }
1176
1177      public boolean isEmpty() {
1178        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(modifier, foodType);
1179      }
1180
1181  public String fhirType() {
1182    return "NutritionOrder.oralDiet.texture";
1183
1184  }
1185
1186  }
1187
1188    @Block()
1189    public static class NutritionOrderSupplementComponent extends BackboneElement implements IBaseBackboneElement {
1190        /**
1191         * The kind of nutritional supplement product required such as a high protein or pediatric clear liquid supplement.
1192         */
1193        @Child(name = "type", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1194        @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." )
1195        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/supplement-type")
1196        protected CodeableConcept type;
1197
1198        /**
1199         * The product or brand name of the nutritional supplement such as "Acme Protein Shake".
1200         */
1201        @Child(name = "productName", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1202        @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\"." )
1203        protected StringType productName;
1204
1205        /**
1206         * The time period and frequency at which the supplement(s) should be given.  The supplement should be given for the combination of all schedules if more than one schedule is present.
1207         */
1208        @Child(name = "schedule", type = {Timing.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1209        @Description(shortDefinition="Scheduled frequency of supplement", formalDefinition="The time period and frequency at which the supplement(s) should be given.  The supplement should be given for the combination of all schedules if more than one schedule is present." )
1210        protected List<Timing> schedule;
1211
1212        /**
1213         * The amount of the nutritional supplement to be given.
1214         */
1215        @Child(name = "quantity", type = {SimpleQuantity.class}, order=4, min=0, max=1, modifier=false, summary=false)
1216        @Description(shortDefinition="Amount of the nutritional supplement", formalDefinition="The amount of the nutritional supplement to be given." )
1217        protected SimpleQuantity quantity;
1218
1219        /**
1220         * Free text or additional instructions or information pertaining to the oral supplement.
1221         */
1222        @Child(name = "instruction", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=true)
1223        @Description(shortDefinition="Instructions or additional information about the oral supplement", formalDefinition="Free text or additional instructions or information pertaining to the oral supplement." )
1224        protected StringType instruction;
1225
1226        private static final long serialVersionUID = 297545236L;
1227
1228    /**
1229     * Constructor
1230     */
1231      public NutritionOrderSupplementComponent() {
1232        super();
1233      }
1234
1235        /**
1236         * @return {@link #type} (The kind of nutritional supplement product required such as a high protein or pediatric clear liquid supplement.)
1237         */
1238        public CodeableConcept getType() { 
1239          if (this.type == null)
1240            if (Configuration.errorOnAutoCreate())
1241              throw new Error("Attempt to auto-create NutritionOrderSupplementComponent.type");
1242            else if (Configuration.doAutoCreate())
1243              this.type = new CodeableConcept(); // cc
1244          return this.type;
1245        }
1246
1247        public boolean hasType() { 
1248          return this.type != null && !this.type.isEmpty();
1249        }
1250
1251        /**
1252         * @param value {@link #type} (The kind of nutritional supplement product required such as a high protein or pediatric clear liquid supplement.)
1253         */
1254        public NutritionOrderSupplementComponent setType(CodeableConcept value) { 
1255          this.type = value;
1256          return this;
1257        }
1258
1259        /**
1260         * @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
1261         */
1262        public StringType getProductNameElement() { 
1263          if (this.productName == null)
1264            if (Configuration.errorOnAutoCreate())
1265              throw new Error("Attempt to auto-create NutritionOrderSupplementComponent.productName");
1266            else if (Configuration.doAutoCreate())
1267              this.productName = new StringType(); // bb
1268          return this.productName;
1269        }
1270
1271        public boolean hasProductNameElement() { 
1272          return this.productName != null && !this.productName.isEmpty();
1273        }
1274
1275        public boolean hasProductName() { 
1276          return this.productName != null && !this.productName.isEmpty();
1277        }
1278
1279        /**
1280         * @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
1281         */
1282        public NutritionOrderSupplementComponent setProductNameElement(StringType value) { 
1283          this.productName = value;
1284          return this;
1285        }
1286
1287        /**
1288         * @return The product or brand name of the nutritional supplement such as "Acme Protein Shake".
1289         */
1290        public String getProductName() { 
1291          return this.productName == null ? null : this.productName.getValue();
1292        }
1293
1294        /**
1295         * @param value The product or brand name of the nutritional supplement such as "Acme Protein Shake".
1296         */
1297        public NutritionOrderSupplementComponent setProductName(String value) { 
1298          if (Utilities.noString(value))
1299            this.productName = null;
1300          else {
1301            if (this.productName == null)
1302              this.productName = new StringType();
1303            this.productName.setValue(value);
1304          }
1305          return this;
1306        }
1307
1308        /**
1309         * @return {@link #schedule} (The time period and frequency at which the supplement(s) should be given.  The supplement should be given for the combination of all schedules if more than one schedule is present.)
1310         */
1311        public List<Timing> getSchedule() { 
1312          if (this.schedule == null)
1313            this.schedule = new ArrayList<Timing>();
1314          return this.schedule;
1315        }
1316
1317        /**
1318         * @return Returns a reference to <code>this</code> for easy method chaining
1319         */
1320        public NutritionOrderSupplementComponent setSchedule(List<Timing> theSchedule) { 
1321          this.schedule = theSchedule;
1322          return this;
1323        }
1324
1325        public boolean hasSchedule() { 
1326          if (this.schedule == null)
1327            return false;
1328          for (Timing item : this.schedule)
1329            if (!item.isEmpty())
1330              return true;
1331          return false;
1332        }
1333
1334        public Timing addSchedule() { //3
1335          Timing t = new Timing();
1336          if (this.schedule == null)
1337            this.schedule = new ArrayList<Timing>();
1338          this.schedule.add(t);
1339          return t;
1340        }
1341
1342        public NutritionOrderSupplementComponent addSchedule(Timing t) { //3
1343          if (t == null)
1344            return this;
1345          if (this.schedule == null)
1346            this.schedule = new ArrayList<Timing>();
1347          this.schedule.add(t);
1348          return this;
1349        }
1350
1351        /**
1352         * @return The first repetition of repeating field {@link #schedule}, creating it if it does not already exist
1353         */
1354        public Timing getScheduleFirstRep() { 
1355          if (getSchedule().isEmpty()) {
1356            addSchedule();
1357          }
1358          return getSchedule().get(0);
1359        }
1360
1361        /**
1362         * @return {@link #quantity} (The amount of the nutritional supplement to be given.)
1363         */
1364        public SimpleQuantity getQuantity() { 
1365          if (this.quantity == null)
1366            if (Configuration.errorOnAutoCreate())
1367              throw new Error("Attempt to auto-create NutritionOrderSupplementComponent.quantity");
1368            else if (Configuration.doAutoCreate())
1369              this.quantity = new SimpleQuantity(); // cc
1370          return this.quantity;
1371        }
1372
1373        public boolean hasQuantity() { 
1374          return this.quantity != null && !this.quantity.isEmpty();
1375        }
1376
1377        /**
1378         * @param value {@link #quantity} (The amount of the nutritional supplement to be given.)
1379         */
1380        public NutritionOrderSupplementComponent setQuantity(SimpleQuantity value) { 
1381          this.quantity = value;
1382          return this;
1383        }
1384
1385        /**
1386         * @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
1387         */
1388        public StringType getInstructionElement() { 
1389          if (this.instruction == null)
1390            if (Configuration.errorOnAutoCreate())
1391              throw new Error("Attempt to auto-create NutritionOrderSupplementComponent.instruction");
1392            else if (Configuration.doAutoCreate())
1393              this.instruction = new StringType(); // bb
1394          return this.instruction;
1395        }
1396
1397        public boolean hasInstructionElement() { 
1398          return this.instruction != null && !this.instruction.isEmpty();
1399        }
1400
1401        public boolean hasInstruction() { 
1402          return this.instruction != null && !this.instruction.isEmpty();
1403        }
1404
1405        /**
1406         * @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
1407         */
1408        public NutritionOrderSupplementComponent setInstructionElement(StringType value) { 
1409          this.instruction = value;
1410          return this;
1411        }
1412
1413        /**
1414         * @return Free text or additional instructions or information pertaining to the oral supplement.
1415         */
1416        public String getInstruction() { 
1417          return this.instruction == null ? null : this.instruction.getValue();
1418        }
1419
1420        /**
1421         * @param value Free text or additional instructions or information pertaining to the oral supplement.
1422         */
1423        public NutritionOrderSupplementComponent setInstruction(String value) { 
1424          if (Utilities.noString(value))
1425            this.instruction = null;
1426          else {
1427            if (this.instruction == null)
1428              this.instruction = new StringType();
1429            this.instruction.setValue(value);
1430          }
1431          return this;
1432        }
1433
1434        protected void listChildren(List<Property> childrenList) {
1435          super.listChildren(childrenList);
1436          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));
1437          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));
1438          childrenList.add(new Property("schedule", "Timing", "The time period and frequency at which the supplement(s) should be given.  The supplement should be given for the combination of all schedules if more than one schedule is present.", 0, java.lang.Integer.MAX_VALUE, schedule));
1439          childrenList.add(new Property("quantity", "SimpleQuantity", "The amount of the nutritional supplement to be given.", 0, java.lang.Integer.MAX_VALUE, quantity));
1440          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));
1441        }
1442
1443      @Override
1444      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1445        switch (hash) {
1446        case 3575610: /*type*/ return this.type == null ? new Base[0] : new Base[] {this.type}; // CodeableConcept
1447        case -1491817446: /*productName*/ return this.productName == null ? new Base[0] : new Base[] {this.productName}; // StringType
1448        case -697920873: /*schedule*/ return this.schedule == null ? new Base[0] : this.schedule.toArray(new Base[this.schedule.size()]); // Timing
1449        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
1450        case 301526158: /*instruction*/ return this.instruction == null ? new Base[0] : new Base[] {this.instruction}; // StringType
1451        default: return super.getProperty(hash, name, checkValid);
1452        }
1453
1454      }
1455
1456      @Override
1457      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1458        switch (hash) {
1459        case 3575610: // type
1460          this.type = castToCodeableConcept(value); // CodeableConcept
1461          return value;
1462        case -1491817446: // productName
1463          this.productName = castToString(value); // StringType
1464          return value;
1465        case -697920873: // schedule
1466          this.getSchedule().add(castToTiming(value)); // Timing
1467          return value;
1468        case -1285004149: // quantity
1469          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
1470          return value;
1471        case 301526158: // instruction
1472          this.instruction = castToString(value); // StringType
1473          return value;
1474        default: return super.setProperty(hash, name, value);
1475        }
1476
1477      }
1478
1479      @Override
1480      public Base setProperty(String name, Base value) throws FHIRException {
1481        if (name.equals("type")) {
1482          this.type = castToCodeableConcept(value); // CodeableConcept
1483        } else if (name.equals("productName")) {
1484          this.productName = castToString(value); // StringType
1485        } else if (name.equals("schedule")) {
1486          this.getSchedule().add(castToTiming(value));
1487        } else if (name.equals("quantity")) {
1488          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
1489        } else if (name.equals("instruction")) {
1490          this.instruction = castToString(value); // StringType
1491        } else
1492          return super.setProperty(name, value);
1493        return value;
1494      }
1495
1496      @Override
1497      public Base makeProperty(int hash, String name) throws FHIRException {
1498        switch (hash) {
1499        case 3575610:  return getType(); 
1500        case -1491817446:  return getProductNameElement();
1501        case -697920873:  return addSchedule(); 
1502        case -1285004149:  return getQuantity(); 
1503        case 301526158:  return getInstructionElement();
1504        default: return super.makeProperty(hash, name);
1505        }
1506
1507      }
1508
1509      @Override
1510      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1511        switch (hash) {
1512        case 3575610: /*type*/ return new String[] {"CodeableConcept"};
1513        case -1491817446: /*productName*/ return new String[] {"string"};
1514        case -697920873: /*schedule*/ return new String[] {"Timing"};
1515        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
1516        case 301526158: /*instruction*/ return new String[] {"string"};
1517        default: return super.getTypesForProperty(hash, name);
1518        }
1519
1520      }
1521
1522      @Override
1523      public Base addChild(String name) throws FHIRException {
1524        if (name.equals("type")) {
1525          this.type = new CodeableConcept();
1526          return this.type;
1527        }
1528        else if (name.equals("productName")) {
1529          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.productName");
1530        }
1531        else if (name.equals("schedule")) {
1532          return addSchedule();
1533        }
1534        else if (name.equals("quantity")) {
1535          this.quantity = new SimpleQuantity();
1536          return this.quantity;
1537        }
1538        else if (name.equals("instruction")) {
1539          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.instruction");
1540        }
1541        else
1542          return super.addChild(name);
1543      }
1544
1545      public NutritionOrderSupplementComponent copy() {
1546        NutritionOrderSupplementComponent dst = new NutritionOrderSupplementComponent();
1547        copyValues(dst);
1548        dst.type = type == null ? null : type.copy();
1549        dst.productName = productName == null ? null : productName.copy();
1550        if (schedule != null) {
1551          dst.schedule = new ArrayList<Timing>();
1552          for (Timing i : schedule)
1553            dst.schedule.add(i.copy());
1554        };
1555        dst.quantity = quantity == null ? null : quantity.copy();
1556        dst.instruction = instruction == null ? null : instruction.copy();
1557        return dst;
1558      }
1559
1560      @Override
1561      public boolean equalsDeep(Base other) {
1562        if (!super.equalsDeep(other))
1563          return false;
1564        if (!(other instanceof NutritionOrderSupplementComponent))
1565          return false;
1566        NutritionOrderSupplementComponent o = (NutritionOrderSupplementComponent) other;
1567        return compareDeep(type, o.type, true) && compareDeep(productName, o.productName, true) && compareDeep(schedule, o.schedule, true)
1568           && compareDeep(quantity, o.quantity, true) && compareDeep(instruction, o.instruction, true);
1569      }
1570
1571      @Override
1572      public boolean equalsShallow(Base other) {
1573        if (!super.equalsShallow(other))
1574          return false;
1575        if (!(other instanceof NutritionOrderSupplementComponent))
1576          return false;
1577        NutritionOrderSupplementComponent o = (NutritionOrderSupplementComponent) other;
1578        return compareValues(productName, o.productName, true) && compareValues(instruction, o.instruction, true)
1579          ;
1580      }
1581
1582      public boolean isEmpty() {
1583        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, productName, schedule
1584          , quantity, instruction);
1585      }
1586
1587  public String fhirType() {
1588    return "NutritionOrder.supplement";
1589
1590  }
1591
1592  }
1593
1594    @Block()
1595    public static class NutritionOrderEnteralFormulaComponent extends BackboneElement implements IBaseBackboneElement {
1596        /**
1597         * The type of enteral or infant formula such as an adult standard formula with fiber or a soy-based infant formula.
1598         */
1599        @Child(name = "baseFormulaType", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
1600        @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." )
1601        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/entformula-type")
1602        protected CodeableConcept baseFormulaType;
1603
1604        /**
1605         * The product or brand name of the enteral or infant formula product such as "ACME Adult Standard Formula".
1606         */
1607        @Child(name = "baseFormulaProductName", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1608        @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\"." )
1609        protected StringType baseFormulaProductName;
1610
1611        /**
1612         * 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.
1613         */
1614        @Child(name = "additiveType", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=false)
1615        @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." )
1616        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/entformula-additive")
1617        protected CodeableConcept additiveType;
1618
1619        /**
1620         * The product or brand name of the type of modular component to be added to the formula.
1621         */
1622        @Child(name = "additiveProductName", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1623        @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." )
1624        protected StringType additiveProductName;
1625
1626        /**
1627         * 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.
1628         */
1629        @Child(name = "caloricDensity", type = {SimpleQuantity.class}, order=5, min=0, max=1, modifier=false, summary=false)
1630        @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." )
1631        protected SimpleQuantity caloricDensity;
1632
1633        /**
1634         * The route or physiological path of administration into the patient's gastrointestinal  tract for purposes of providing the formula feeding, e.g. nasogastric tube.
1635         */
1636        @Child(name = "routeofAdministration", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=false)
1637        @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." )
1638        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/enteral-route")
1639        protected CodeableConcept routeofAdministration;
1640
1641        /**
1642         * 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.
1643         */
1644        @Child(name = "administration", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1645        @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." )
1646        protected List<NutritionOrderEnteralFormulaAdministrationComponent> administration;
1647
1648        /**
1649         * 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.
1650         */
1651        @Child(name = "maxVolumeToDeliver", type = {SimpleQuantity.class}, order=8, min=0, max=1, modifier=false, summary=false)
1652        @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." )
1653        protected SimpleQuantity maxVolumeToDeliver;
1654
1655        /**
1656         * Free text formula administration, feeding instructions or additional instructions or information.
1657         */
1658        @Child(name = "administrationInstruction", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=true)
1659        @Description(shortDefinition="Formula feeding instructions expressed as text", formalDefinition="Free text formula administration, feeding instructions or additional instructions or information." )
1660        protected StringType administrationInstruction;
1661
1662        private static final long serialVersionUID = 292116061L;
1663
1664    /**
1665     * Constructor
1666     */
1667      public NutritionOrderEnteralFormulaComponent() {
1668        super();
1669      }
1670
1671        /**
1672         * @return {@link #baseFormulaType} (The type of enteral or infant formula such as an adult standard formula with fiber or a soy-based infant formula.)
1673         */
1674        public CodeableConcept getBaseFormulaType() { 
1675          if (this.baseFormulaType == null)
1676            if (Configuration.errorOnAutoCreate())
1677              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.baseFormulaType");
1678            else if (Configuration.doAutoCreate())
1679              this.baseFormulaType = new CodeableConcept(); // cc
1680          return this.baseFormulaType;
1681        }
1682
1683        public boolean hasBaseFormulaType() { 
1684          return this.baseFormulaType != null && !this.baseFormulaType.isEmpty();
1685        }
1686
1687        /**
1688         * @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.)
1689         */
1690        public NutritionOrderEnteralFormulaComponent setBaseFormulaType(CodeableConcept value) { 
1691          this.baseFormulaType = value;
1692          return this;
1693        }
1694
1695        /**
1696         * @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
1697         */
1698        public StringType getBaseFormulaProductNameElement() { 
1699          if (this.baseFormulaProductName == null)
1700            if (Configuration.errorOnAutoCreate())
1701              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.baseFormulaProductName");
1702            else if (Configuration.doAutoCreate())
1703              this.baseFormulaProductName = new StringType(); // bb
1704          return this.baseFormulaProductName;
1705        }
1706
1707        public boolean hasBaseFormulaProductNameElement() { 
1708          return this.baseFormulaProductName != null && !this.baseFormulaProductName.isEmpty();
1709        }
1710
1711        public boolean hasBaseFormulaProductName() { 
1712          return this.baseFormulaProductName != null && !this.baseFormulaProductName.isEmpty();
1713        }
1714
1715        /**
1716         * @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
1717         */
1718        public NutritionOrderEnteralFormulaComponent setBaseFormulaProductNameElement(StringType value) { 
1719          this.baseFormulaProductName = value;
1720          return this;
1721        }
1722
1723        /**
1724         * @return The product or brand name of the enteral or infant formula product such as "ACME Adult Standard Formula".
1725         */
1726        public String getBaseFormulaProductName() { 
1727          return this.baseFormulaProductName == null ? null : this.baseFormulaProductName.getValue();
1728        }
1729
1730        /**
1731         * @param value The product or brand name of the enteral or infant formula product such as "ACME Adult Standard Formula".
1732         */
1733        public NutritionOrderEnteralFormulaComponent setBaseFormulaProductName(String value) { 
1734          if (Utilities.noString(value))
1735            this.baseFormulaProductName = null;
1736          else {
1737            if (this.baseFormulaProductName == null)
1738              this.baseFormulaProductName = new StringType();
1739            this.baseFormulaProductName.setValue(value);
1740          }
1741          return this;
1742        }
1743
1744        /**
1745         * @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.)
1746         */
1747        public CodeableConcept getAdditiveType() { 
1748          if (this.additiveType == null)
1749            if (Configuration.errorOnAutoCreate())
1750              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.additiveType");
1751            else if (Configuration.doAutoCreate())
1752              this.additiveType = new CodeableConcept(); // cc
1753          return this.additiveType;
1754        }
1755
1756        public boolean hasAdditiveType() { 
1757          return this.additiveType != null && !this.additiveType.isEmpty();
1758        }
1759
1760        /**
1761         * @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.)
1762         */
1763        public NutritionOrderEnteralFormulaComponent setAdditiveType(CodeableConcept value) { 
1764          this.additiveType = value;
1765          return this;
1766        }
1767
1768        /**
1769         * @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
1770         */
1771        public StringType getAdditiveProductNameElement() { 
1772          if (this.additiveProductName == null)
1773            if (Configuration.errorOnAutoCreate())
1774              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.additiveProductName");
1775            else if (Configuration.doAutoCreate())
1776              this.additiveProductName = new StringType(); // bb
1777          return this.additiveProductName;
1778        }
1779
1780        public boolean hasAdditiveProductNameElement() { 
1781          return this.additiveProductName != null && !this.additiveProductName.isEmpty();
1782        }
1783
1784        public boolean hasAdditiveProductName() { 
1785          return this.additiveProductName != null && !this.additiveProductName.isEmpty();
1786        }
1787
1788        /**
1789         * @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
1790         */
1791        public NutritionOrderEnteralFormulaComponent setAdditiveProductNameElement(StringType value) { 
1792          this.additiveProductName = value;
1793          return this;
1794        }
1795
1796        /**
1797         * @return The product or brand name of the type of modular component to be added to the formula.
1798         */
1799        public String getAdditiveProductName() { 
1800          return this.additiveProductName == null ? null : this.additiveProductName.getValue();
1801        }
1802
1803        /**
1804         * @param value The product or brand name of the type of modular component to be added to the formula.
1805         */
1806        public NutritionOrderEnteralFormulaComponent setAdditiveProductName(String value) { 
1807          if (Utilities.noString(value))
1808            this.additiveProductName = null;
1809          else {
1810            if (this.additiveProductName == null)
1811              this.additiveProductName = new StringType();
1812            this.additiveProductName.setValue(value);
1813          }
1814          return this;
1815        }
1816
1817        /**
1818         * @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.)
1819         */
1820        public SimpleQuantity getCaloricDensity() { 
1821          if (this.caloricDensity == null)
1822            if (Configuration.errorOnAutoCreate())
1823              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.caloricDensity");
1824            else if (Configuration.doAutoCreate())
1825              this.caloricDensity = new SimpleQuantity(); // cc
1826          return this.caloricDensity;
1827        }
1828
1829        public boolean hasCaloricDensity() { 
1830          return this.caloricDensity != null && !this.caloricDensity.isEmpty();
1831        }
1832
1833        /**
1834         * @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.)
1835         */
1836        public NutritionOrderEnteralFormulaComponent setCaloricDensity(SimpleQuantity value) { 
1837          this.caloricDensity = value;
1838          return this;
1839        }
1840
1841        /**
1842         * @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.)
1843         */
1844        public CodeableConcept getRouteofAdministration() { 
1845          if (this.routeofAdministration == null)
1846            if (Configuration.errorOnAutoCreate())
1847              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.routeofAdministration");
1848            else if (Configuration.doAutoCreate())
1849              this.routeofAdministration = new CodeableConcept(); // cc
1850          return this.routeofAdministration;
1851        }
1852
1853        public boolean hasRouteofAdministration() { 
1854          return this.routeofAdministration != null && !this.routeofAdministration.isEmpty();
1855        }
1856
1857        /**
1858         * @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.)
1859         */
1860        public NutritionOrderEnteralFormulaComponent setRouteofAdministration(CodeableConcept value) { 
1861          this.routeofAdministration = value;
1862          return this;
1863        }
1864
1865        /**
1866         * @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.)
1867         */
1868        public List<NutritionOrderEnteralFormulaAdministrationComponent> getAdministration() { 
1869          if (this.administration == null)
1870            this.administration = new ArrayList<NutritionOrderEnteralFormulaAdministrationComponent>();
1871          return this.administration;
1872        }
1873
1874        /**
1875         * @return Returns a reference to <code>this</code> for easy method chaining
1876         */
1877        public NutritionOrderEnteralFormulaComponent setAdministration(List<NutritionOrderEnteralFormulaAdministrationComponent> theAdministration) { 
1878          this.administration = theAdministration;
1879          return this;
1880        }
1881
1882        public boolean hasAdministration() { 
1883          if (this.administration == null)
1884            return false;
1885          for (NutritionOrderEnteralFormulaAdministrationComponent item : this.administration)
1886            if (!item.isEmpty())
1887              return true;
1888          return false;
1889        }
1890
1891        public NutritionOrderEnteralFormulaAdministrationComponent addAdministration() { //3
1892          NutritionOrderEnteralFormulaAdministrationComponent t = new NutritionOrderEnteralFormulaAdministrationComponent();
1893          if (this.administration == null)
1894            this.administration = new ArrayList<NutritionOrderEnteralFormulaAdministrationComponent>();
1895          this.administration.add(t);
1896          return t;
1897        }
1898
1899        public NutritionOrderEnteralFormulaComponent addAdministration(NutritionOrderEnteralFormulaAdministrationComponent t) { //3
1900          if (t == null)
1901            return this;
1902          if (this.administration == null)
1903            this.administration = new ArrayList<NutritionOrderEnteralFormulaAdministrationComponent>();
1904          this.administration.add(t);
1905          return this;
1906        }
1907
1908        /**
1909         * @return The first repetition of repeating field {@link #administration}, creating it if it does not already exist
1910         */
1911        public NutritionOrderEnteralFormulaAdministrationComponent getAdministrationFirstRep() { 
1912          if (getAdministration().isEmpty()) {
1913            addAdministration();
1914          }
1915          return getAdministration().get(0);
1916        }
1917
1918        /**
1919         * @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.)
1920         */
1921        public SimpleQuantity getMaxVolumeToDeliver() { 
1922          if (this.maxVolumeToDeliver == null)
1923            if (Configuration.errorOnAutoCreate())
1924              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.maxVolumeToDeliver");
1925            else if (Configuration.doAutoCreate())
1926              this.maxVolumeToDeliver = new SimpleQuantity(); // cc
1927          return this.maxVolumeToDeliver;
1928        }
1929
1930        public boolean hasMaxVolumeToDeliver() { 
1931          return this.maxVolumeToDeliver != null && !this.maxVolumeToDeliver.isEmpty();
1932        }
1933
1934        /**
1935         * @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.)
1936         */
1937        public NutritionOrderEnteralFormulaComponent setMaxVolumeToDeliver(SimpleQuantity value) { 
1938          this.maxVolumeToDeliver = value;
1939          return this;
1940        }
1941
1942        /**
1943         * @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
1944         */
1945        public StringType getAdministrationInstructionElement() { 
1946          if (this.administrationInstruction == null)
1947            if (Configuration.errorOnAutoCreate())
1948              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaComponent.administrationInstruction");
1949            else if (Configuration.doAutoCreate())
1950              this.administrationInstruction = new StringType(); // bb
1951          return this.administrationInstruction;
1952        }
1953
1954        public boolean hasAdministrationInstructionElement() { 
1955          return this.administrationInstruction != null && !this.administrationInstruction.isEmpty();
1956        }
1957
1958        public boolean hasAdministrationInstruction() { 
1959          return this.administrationInstruction != null && !this.administrationInstruction.isEmpty();
1960        }
1961
1962        /**
1963         * @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
1964         */
1965        public NutritionOrderEnteralFormulaComponent setAdministrationInstructionElement(StringType value) { 
1966          this.administrationInstruction = value;
1967          return this;
1968        }
1969
1970        /**
1971         * @return Free text formula administration, feeding instructions or additional instructions or information.
1972         */
1973        public String getAdministrationInstruction() { 
1974          return this.administrationInstruction == null ? null : this.administrationInstruction.getValue();
1975        }
1976
1977        /**
1978         * @param value Free text formula administration, feeding instructions or additional instructions or information.
1979         */
1980        public NutritionOrderEnteralFormulaComponent setAdministrationInstruction(String value) { 
1981          if (Utilities.noString(value))
1982            this.administrationInstruction = null;
1983          else {
1984            if (this.administrationInstruction == null)
1985              this.administrationInstruction = new StringType();
1986            this.administrationInstruction.setValue(value);
1987          }
1988          return this;
1989        }
1990
1991        protected void listChildren(List<Property> childrenList) {
1992          super.listChildren(childrenList);
1993          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));
1994          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));
1995          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));
1996          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));
1997          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));
1998          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));
1999          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));
2000          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));
2001          childrenList.add(new Property("administrationInstruction", "string", "Free text formula administration, feeding instructions or additional instructions or information.", 0, java.lang.Integer.MAX_VALUE, administrationInstruction));
2002        }
2003
2004      @Override
2005      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2006        switch (hash) {
2007        case -138930641: /*baseFormulaType*/ return this.baseFormulaType == null ? new Base[0] : new Base[] {this.baseFormulaType}; // CodeableConcept
2008        case -1267705979: /*baseFormulaProductName*/ return this.baseFormulaProductName == null ? new Base[0] : new Base[] {this.baseFormulaProductName}; // StringType
2009        case -470746842: /*additiveType*/ return this.additiveType == null ? new Base[0] : new Base[] {this.additiveType}; // CodeableConcept
2010        case 488079534: /*additiveProductName*/ return this.additiveProductName == null ? new Base[0] : new Base[] {this.additiveProductName}; // StringType
2011        case 186983261: /*caloricDensity*/ return this.caloricDensity == null ? new Base[0] : new Base[] {this.caloricDensity}; // SimpleQuantity
2012        case -1710107042: /*routeofAdministration*/ return this.routeofAdministration == null ? new Base[0] : new Base[] {this.routeofAdministration}; // CodeableConcept
2013        case 1255702622: /*administration*/ return this.administration == null ? new Base[0] : this.administration.toArray(new Base[this.administration.size()]); // NutritionOrderEnteralFormulaAdministrationComponent
2014        case 2017924652: /*maxVolumeToDeliver*/ return this.maxVolumeToDeliver == null ? new Base[0] : new Base[] {this.maxVolumeToDeliver}; // SimpleQuantity
2015        case 427085136: /*administrationInstruction*/ return this.administrationInstruction == null ? new Base[0] : new Base[] {this.administrationInstruction}; // StringType
2016        default: return super.getProperty(hash, name, checkValid);
2017        }
2018
2019      }
2020
2021      @Override
2022      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2023        switch (hash) {
2024        case -138930641: // baseFormulaType
2025          this.baseFormulaType = castToCodeableConcept(value); // CodeableConcept
2026          return value;
2027        case -1267705979: // baseFormulaProductName
2028          this.baseFormulaProductName = castToString(value); // StringType
2029          return value;
2030        case -470746842: // additiveType
2031          this.additiveType = castToCodeableConcept(value); // CodeableConcept
2032          return value;
2033        case 488079534: // additiveProductName
2034          this.additiveProductName = castToString(value); // StringType
2035          return value;
2036        case 186983261: // caloricDensity
2037          this.caloricDensity = castToSimpleQuantity(value); // SimpleQuantity
2038          return value;
2039        case -1710107042: // routeofAdministration
2040          this.routeofAdministration = castToCodeableConcept(value); // CodeableConcept
2041          return value;
2042        case 1255702622: // administration
2043          this.getAdministration().add((NutritionOrderEnteralFormulaAdministrationComponent) value); // NutritionOrderEnteralFormulaAdministrationComponent
2044          return value;
2045        case 2017924652: // maxVolumeToDeliver
2046          this.maxVolumeToDeliver = castToSimpleQuantity(value); // SimpleQuantity
2047          return value;
2048        case 427085136: // administrationInstruction
2049          this.administrationInstruction = castToString(value); // StringType
2050          return value;
2051        default: return super.setProperty(hash, name, value);
2052        }
2053
2054      }
2055
2056      @Override
2057      public Base setProperty(String name, Base value) throws FHIRException {
2058        if (name.equals("baseFormulaType")) {
2059          this.baseFormulaType = castToCodeableConcept(value); // CodeableConcept
2060        } else if (name.equals("baseFormulaProductName")) {
2061          this.baseFormulaProductName = castToString(value); // StringType
2062        } else if (name.equals("additiveType")) {
2063          this.additiveType = castToCodeableConcept(value); // CodeableConcept
2064        } else if (name.equals("additiveProductName")) {
2065          this.additiveProductName = castToString(value); // StringType
2066        } else if (name.equals("caloricDensity")) {
2067          this.caloricDensity = castToSimpleQuantity(value); // SimpleQuantity
2068        } else if (name.equals("routeofAdministration")) {
2069          this.routeofAdministration = castToCodeableConcept(value); // CodeableConcept
2070        } else if (name.equals("administration")) {
2071          this.getAdministration().add((NutritionOrderEnteralFormulaAdministrationComponent) value);
2072        } else if (name.equals("maxVolumeToDeliver")) {
2073          this.maxVolumeToDeliver = castToSimpleQuantity(value); // SimpleQuantity
2074        } else if (name.equals("administrationInstruction")) {
2075          this.administrationInstruction = castToString(value); // StringType
2076        } else
2077          return super.setProperty(name, value);
2078        return value;
2079      }
2080
2081      @Override
2082      public Base makeProperty(int hash, String name) throws FHIRException {
2083        switch (hash) {
2084        case -138930641:  return getBaseFormulaType(); 
2085        case -1267705979:  return getBaseFormulaProductNameElement();
2086        case -470746842:  return getAdditiveType(); 
2087        case 488079534:  return getAdditiveProductNameElement();
2088        case 186983261:  return getCaloricDensity(); 
2089        case -1710107042:  return getRouteofAdministration(); 
2090        case 1255702622:  return addAdministration(); 
2091        case 2017924652:  return getMaxVolumeToDeliver(); 
2092        case 427085136:  return getAdministrationInstructionElement();
2093        default: return super.makeProperty(hash, name);
2094        }
2095
2096      }
2097
2098      @Override
2099      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2100        switch (hash) {
2101        case -138930641: /*baseFormulaType*/ return new String[] {"CodeableConcept"};
2102        case -1267705979: /*baseFormulaProductName*/ return new String[] {"string"};
2103        case -470746842: /*additiveType*/ return new String[] {"CodeableConcept"};
2104        case 488079534: /*additiveProductName*/ return new String[] {"string"};
2105        case 186983261: /*caloricDensity*/ return new String[] {"SimpleQuantity"};
2106        case -1710107042: /*routeofAdministration*/ return new String[] {"CodeableConcept"};
2107        case 1255702622: /*administration*/ return new String[] {};
2108        case 2017924652: /*maxVolumeToDeliver*/ return new String[] {"SimpleQuantity"};
2109        case 427085136: /*administrationInstruction*/ return new String[] {"string"};
2110        default: return super.getTypesForProperty(hash, name);
2111        }
2112
2113      }
2114
2115      @Override
2116      public Base addChild(String name) throws FHIRException {
2117        if (name.equals("baseFormulaType")) {
2118          this.baseFormulaType = new CodeableConcept();
2119          return this.baseFormulaType;
2120        }
2121        else if (name.equals("baseFormulaProductName")) {
2122          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.baseFormulaProductName");
2123        }
2124        else if (name.equals("additiveType")) {
2125          this.additiveType = new CodeableConcept();
2126          return this.additiveType;
2127        }
2128        else if (name.equals("additiveProductName")) {
2129          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.additiveProductName");
2130        }
2131        else if (name.equals("caloricDensity")) {
2132          this.caloricDensity = new SimpleQuantity();
2133          return this.caloricDensity;
2134        }
2135        else if (name.equals("routeofAdministration")) {
2136          this.routeofAdministration = new CodeableConcept();
2137          return this.routeofAdministration;
2138        }
2139        else if (name.equals("administration")) {
2140          return addAdministration();
2141        }
2142        else if (name.equals("maxVolumeToDeliver")) {
2143          this.maxVolumeToDeliver = new SimpleQuantity();
2144          return this.maxVolumeToDeliver;
2145        }
2146        else if (name.equals("administrationInstruction")) {
2147          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.administrationInstruction");
2148        }
2149        else
2150          return super.addChild(name);
2151      }
2152
2153      public NutritionOrderEnteralFormulaComponent copy() {
2154        NutritionOrderEnteralFormulaComponent dst = new NutritionOrderEnteralFormulaComponent();
2155        copyValues(dst);
2156        dst.baseFormulaType = baseFormulaType == null ? null : baseFormulaType.copy();
2157        dst.baseFormulaProductName = baseFormulaProductName == null ? null : baseFormulaProductName.copy();
2158        dst.additiveType = additiveType == null ? null : additiveType.copy();
2159        dst.additiveProductName = additiveProductName == null ? null : additiveProductName.copy();
2160        dst.caloricDensity = caloricDensity == null ? null : caloricDensity.copy();
2161        dst.routeofAdministration = routeofAdministration == null ? null : routeofAdministration.copy();
2162        if (administration != null) {
2163          dst.administration = new ArrayList<NutritionOrderEnteralFormulaAdministrationComponent>();
2164          for (NutritionOrderEnteralFormulaAdministrationComponent i : administration)
2165            dst.administration.add(i.copy());
2166        };
2167        dst.maxVolumeToDeliver = maxVolumeToDeliver == null ? null : maxVolumeToDeliver.copy();
2168        dst.administrationInstruction = administrationInstruction == null ? null : administrationInstruction.copy();
2169        return dst;
2170      }
2171
2172      @Override
2173      public boolean equalsDeep(Base other) {
2174        if (!super.equalsDeep(other))
2175          return false;
2176        if (!(other instanceof NutritionOrderEnteralFormulaComponent))
2177          return false;
2178        NutritionOrderEnteralFormulaComponent o = (NutritionOrderEnteralFormulaComponent) other;
2179        return compareDeep(baseFormulaType, o.baseFormulaType, true) && compareDeep(baseFormulaProductName, o.baseFormulaProductName, true)
2180           && compareDeep(additiveType, o.additiveType, true) && compareDeep(additiveProductName, o.additiveProductName, true)
2181           && compareDeep(caloricDensity, o.caloricDensity, true) && compareDeep(routeofAdministration, o.routeofAdministration, true)
2182           && compareDeep(administration, o.administration, true) && compareDeep(maxVolumeToDeliver, o.maxVolumeToDeliver, true)
2183           && compareDeep(administrationInstruction, o.administrationInstruction, true);
2184      }
2185
2186      @Override
2187      public boolean equalsShallow(Base other) {
2188        if (!super.equalsShallow(other))
2189          return false;
2190        if (!(other instanceof NutritionOrderEnteralFormulaComponent))
2191          return false;
2192        NutritionOrderEnteralFormulaComponent o = (NutritionOrderEnteralFormulaComponent) other;
2193        return compareValues(baseFormulaProductName, o.baseFormulaProductName, true) && compareValues(additiveProductName, o.additiveProductName, true)
2194           && compareValues(administrationInstruction, o.administrationInstruction, true);
2195      }
2196
2197      public boolean isEmpty() {
2198        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(baseFormulaType, baseFormulaProductName
2199          , additiveType, additiveProductName, caloricDensity, routeofAdministration, administration
2200          , maxVolumeToDeliver, administrationInstruction);
2201      }
2202
2203  public String fhirType() {
2204    return "NutritionOrder.enteralFormula";
2205
2206  }
2207
2208  }
2209
2210    @Block()
2211    public static class NutritionOrderEnteralFormulaAdministrationComponent extends BackboneElement implements IBaseBackboneElement {
2212        /**
2213         * The time period and frequency at which the enteral formula should be delivered to the patient.
2214         */
2215        @Child(name = "schedule", type = {Timing.class}, order=1, min=0, max=1, modifier=false, summary=false)
2216        @Description(shortDefinition="Scheduled frequency of enteral feeding", formalDefinition="The time period and frequency at which the enteral formula should be delivered to the patient." )
2217        protected Timing schedule;
2218
2219        /**
2220         * The volume of formula to provide to the patient per the specified administration schedule.
2221         */
2222        @Child(name = "quantity", type = {SimpleQuantity.class}, order=2, min=0, max=1, modifier=false, summary=false)
2223        @Description(shortDefinition="The volume of formula to provide", formalDefinition="The volume of formula to provide to the patient per the specified administration schedule." )
2224        protected SimpleQuantity quantity;
2225
2226        /**
2227         * The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.
2228         */
2229        @Child(name = "rate", type = {SimpleQuantity.class, Ratio.class}, order=3, min=0, max=1, modifier=false, summary=false)
2230        @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." )
2231        protected Type rate;
2232
2233        private static final long serialVersionUID = 1895031997L;
2234
2235    /**
2236     * Constructor
2237     */
2238      public NutritionOrderEnteralFormulaAdministrationComponent() {
2239        super();
2240      }
2241
2242        /**
2243         * @return {@link #schedule} (The time period and frequency at which the enteral formula should be delivered to the patient.)
2244         */
2245        public Timing getSchedule() { 
2246          if (this.schedule == null)
2247            if (Configuration.errorOnAutoCreate())
2248              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaAdministrationComponent.schedule");
2249            else if (Configuration.doAutoCreate())
2250              this.schedule = new Timing(); // cc
2251          return this.schedule;
2252        }
2253
2254        public boolean hasSchedule() { 
2255          return this.schedule != null && !this.schedule.isEmpty();
2256        }
2257
2258        /**
2259         * @param value {@link #schedule} (The time period and frequency at which the enteral formula should be delivered to the patient.)
2260         */
2261        public NutritionOrderEnteralFormulaAdministrationComponent setSchedule(Timing value) { 
2262          this.schedule = value;
2263          return this;
2264        }
2265
2266        /**
2267         * @return {@link #quantity} (The volume of formula to provide to the patient per the specified administration schedule.)
2268         */
2269        public SimpleQuantity getQuantity() { 
2270          if (this.quantity == null)
2271            if (Configuration.errorOnAutoCreate())
2272              throw new Error("Attempt to auto-create NutritionOrderEnteralFormulaAdministrationComponent.quantity");
2273            else if (Configuration.doAutoCreate())
2274              this.quantity = new SimpleQuantity(); // cc
2275          return this.quantity;
2276        }
2277
2278        public boolean hasQuantity() { 
2279          return this.quantity != null && !this.quantity.isEmpty();
2280        }
2281
2282        /**
2283         * @param value {@link #quantity} (The volume of formula to provide to the patient per the specified administration schedule.)
2284         */
2285        public NutritionOrderEnteralFormulaAdministrationComponent setQuantity(SimpleQuantity value) { 
2286          this.quantity = value;
2287          return this;
2288        }
2289
2290        /**
2291         * @return {@link #rate} (The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.)
2292         */
2293        public Type getRate() { 
2294          return this.rate;
2295        }
2296
2297        /**
2298         * @return {@link #rate} (The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.)
2299         */
2300        public SimpleQuantity getRateSimpleQuantity() throws FHIRException { 
2301          if (!(this.rate instanceof SimpleQuantity))
2302            throw new FHIRException("Type mismatch: the type SimpleQuantity was expected, but "+this.rate.getClass().getName()+" was encountered");
2303          return (SimpleQuantity) this.rate;
2304        }
2305
2306        public boolean hasRateSimpleQuantity() { 
2307          return this.rate instanceof SimpleQuantity;
2308        }
2309
2310        /**
2311         * @return {@link #rate} (The rate of administration of formula via a feeding pump, e.g. 60 mL per hour, according to the specified schedule.)
2312         */
2313        public Ratio getRateRatio() throws FHIRException { 
2314          if (!(this.rate instanceof Ratio))
2315            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.rate.getClass().getName()+" was encountered");
2316          return (Ratio) this.rate;
2317        }
2318
2319        public boolean hasRateRatio() { 
2320          return this.rate instanceof Ratio;
2321        }
2322
2323        public boolean hasRate() { 
2324          return this.rate != null && !this.rate.isEmpty();
2325        }
2326
2327        /**
2328         * @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.)
2329         */
2330        public NutritionOrderEnteralFormulaAdministrationComponent setRate(Type value) { 
2331          this.rate = value;
2332          return this;
2333        }
2334
2335        protected void listChildren(List<Property> childrenList) {
2336          super.listChildren(childrenList);
2337          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));
2338          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));
2339          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));
2340        }
2341
2342      @Override
2343      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2344        switch (hash) {
2345        case -697920873: /*schedule*/ return this.schedule == null ? new Base[0] : new Base[] {this.schedule}; // Timing
2346        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // SimpleQuantity
2347        case 3493088: /*rate*/ return this.rate == null ? new Base[0] : new Base[] {this.rate}; // Type
2348        default: return super.getProperty(hash, name, checkValid);
2349        }
2350
2351      }
2352
2353      @Override
2354      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2355        switch (hash) {
2356        case -697920873: // schedule
2357          this.schedule = castToTiming(value); // Timing
2358          return value;
2359        case -1285004149: // quantity
2360          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
2361          return value;
2362        case 3493088: // rate
2363          this.rate = castToType(value); // Type
2364          return value;
2365        default: return super.setProperty(hash, name, value);
2366        }
2367
2368      }
2369
2370      @Override
2371      public Base setProperty(String name, Base value) throws FHIRException {
2372        if (name.equals("schedule")) {
2373          this.schedule = castToTiming(value); // Timing
2374        } else if (name.equals("quantity")) {
2375          this.quantity = castToSimpleQuantity(value); // SimpleQuantity
2376        } else if (name.equals("rate[x]")) {
2377          this.rate = castToType(value); // Type
2378        } else
2379          return super.setProperty(name, value);
2380        return value;
2381      }
2382
2383      @Override
2384      public Base makeProperty(int hash, String name) throws FHIRException {
2385        switch (hash) {
2386        case -697920873:  return getSchedule(); 
2387        case -1285004149:  return getQuantity(); 
2388        case 983460768:  return getRate(); 
2389        case 3493088:  return getRate(); 
2390        default: return super.makeProperty(hash, name);
2391        }
2392
2393      }
2394
2395      @Override
2396      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2397        switch (hash) {
2398        case -697920873: /*schedule*/ return new String[] {"Timing"};
2399        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
2400        case 3493088: /*rate*/ return new String[] {"SimpleQuantity", "Ratio"};
2401        default: return super.getTypesForProperty(hash, name);
2402        }
2403
2404      }
2405
2406      @Override
2407      public Base addChild(String name) throws FHIRException {
2408        if (name.equals("schedule")) {
2409          this.schedule = new Timing();
2410          return this.schedule;
2411        }
2412        else if (name.equals("quantity")) {
2413          this.quantity = new SimpleQuantity();
2414          return this.quantity;
2415        }
2416        else if (name.equals("rateSimpleQuantity")) {
2417          this.rate = new SimpleQuantity();
2418          return this.rate;
2419        }
2420        else if (name.equals("rateRatio")) {
2421          this.rate = new Ratio();
2422          return this.rate;
2423        }
2424        else
2425          return super.addChild(name);
2426      }
2427
2428      public NutritionOrderEnteralFormulaAdministrationComponent copy() {
2429        NutritionOrderEnteralFormulaAdministrationComponent dst = new NutritionOrderEnteralFormulaAdministrationComponent();
2430        copyValues(dst);
2431        dst.schedule = schedule == null ? null : schedule.copy();
2432        dst.quantity = quantity == null ? null : quantity.copy();
2433        dst.rate = rate == null ? null : rate.copy();
2434        return dst;
2435      }
2436
2437      @Override
2438      public boolean equalsDeep(Base other) {
2439        if (!super.equalsDeep(other))
2440          return false;
2441        if (!(other instanceof NutritionOrderEnteralFormulaAdministrationComponent))
2442          return false;
2443        NutritionOrderEnteralFormulaAdministrationComponent o = (NutritionOrderEnteralFormulaAdministrationComponent) other;
2444        return compareDeep(schedule, o.schedule, true) && compareDeep(quantity, o.quantity, true) && compareDeep(rate, o.rate, true)
2445          ;
2446      }
2447
2448      @Override
2449      public boolean equalsShallow(Base other) {
2450        if (!super.equalsShallow(other))
2451          return false;
2452        if (!(other instanceof NutritionOrderEnteralFormulaAdministrationComponent))
2453          return false;
2454        NutritionOrderEnteralFormulaAdministrationComponent o = (NutritionOrderEnteralFormulaAdministrationComponent) other;
2455        return true;
2456      }
2457
2458      public boolean isEmpty() {
2459        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(schedule, quantity, rate
2460          );
2461      }
2462
2463  public String fhirType() {
2464    return "NutritionOrder.enteralFormula.administration";
2465
2466  }
2467
2468  }
2469
2470    /**
2471     * Identifiers assigned to this order by the order sender or by the order receiver.
2472     */
2473    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2474    @Description(shortDefinition="Identifiers assigned to this order", formalDefinition="Identifiers assigned to this order by the order sender or by the order receiver." )
2475    protected List<Identifier> identifier;
2476
2477    /**
2478     * The workflow status of the nutrition order/request.
2479     */
2480    @Child(name = "status", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
2481    @Description(shortDefinition="proposed | draft | planned | requested | active | on-hold | completed | cancelled | entered-in-error", formalDefinition="The workflow status of the nutrition order/request." )
2482    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/nutrition-request-status")
2483    protected Enumeration<NutritionOrderStatus> status;
2484
2485    /**
2486     * The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.
2487     */
2488    @Child(name = "patient", type = {Patient.class}, order=2, min=1, max=1, modifier=false, summary=true)
2489    @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." )
2490    protected Reference patient;
2491
2492    /**
2493     * 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.)
2494     */
2495    protected Patient patientTarget;
2496
2497    /**
2498     * An encounter that provides additional information about the healthcare context in which this request is made.
2499     */
2500    @Child(name = "encounter", type = {Encounter.class}, order=3, min=0, max=1, modifier=false, summary=false)
2501    @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." )
2502    protected Reference encounter;
2503
2504    /**
2505     * 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.)
2506     */
2507    protected Encounter encounterTarget;
2508
2509    /**
2510     * The date and time that this nutrition order was requested.
2511     */
2512    @Child(name = "dateTime", type = {DateTimeType.class}, order=4, min=1, max=1, modifier=false, summary=true)
2513    @Description(shortDefinition="Date and time the nutrition order was requested", formalDefinition="The date and time that this nutrition order was requested." )
2514    protected DateTimeType dateTime;
2515
2516    /**
2517     * The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.
2518     */
2519    @Child(name = "orderer", type = {Practitioner.class}, order=5, min=0, max=1, modifier=false, summary=true)
2520    @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." )
2521    protected Reference orderer;
2522
2523    /**
2524     * 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.)
2525     */
2526    protected Practitioner ordererTarget;
2527
2528    /**
2529     * A link to a record of allergies or intolerances  which should be included in the nutrition order.
2530     */
2531    @Child(name = "allergyIntolerance", type = {AllergyIntolerance.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2532    @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." )
2533    protected List<Reference> allergyIntolerance;
2534    /**
2535     * 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.)
2536     */
2537    protected List<AllergyIntolerance> allergyIntoleranceTarget;
2538
2539
2540    /**
2541     * 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.
2542     */
2543    @Child(name = "foodPreferenceModifier", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2544    @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." )
2545    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/encounter-diet")
2546    protected List<CodeableConcept> foodPreferenceModifier;
2547
2548    /**
2549     * 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.
2550     */
2551    @Child(name = "excludeFoodModifier", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2552    @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." )
2553    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/food-type")
2554    protected List<CodeableConcept> excludeFoodModifier;
2555
2556    /**
2557     * Diet given orally in contrast to enteral (tube) feeding.
2558     */
2559    @Child(name = "oralDiet", type = {}, order=9, min=0, max=1, modifier=false, summary=false)
2560    @Description(shortDefinition="Oral diet components", formalDefinition="Diet given orally in contrast to enteral (tube) feeding." )
2561    protected NutritionOrderOralDietComponent oralDiet;
2562
2563    /**
2564     * Oral nutritional products given in order to add further nutritional value to the patient's diet.
2565     */
2566    @Child(name = "supplement", type = {}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2567    @Description(shortDefinition="Supplement components", formalDefinition="Oral nutritional products given in order to add further nutritional value to the patient's diet." )
2568    protected List<NutritionOrderSupplementComponent> supplement;
2569
2570    /**
2571     * Feeding provided through the gastrointestinal tract via a tube, catheter, or stoma that delivers nutrition distal to the oral cavity.
2572     */
2573    @Child(name = "enteralFormula", type = {}, order=11, min=0, max=1, modifier=false, summary=false)
2574    @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." )
2575    protected NutritionOrderEnteralFormulaComponent enteralFormula;
2576
2577    private static final long serialVersionUID = 1429947433L;
2578
2579  /**
2580   * Constructor
2581   */
2582    public NutritionOrder() {
2583      super();
2584    }
2585
2586  /**
2587   * Constructor
2588   */
2589    public NutritionOrder(Reference patient, DateTimeType dateTime) {
2590      super();
2591      this.patient = patient;
2592      this.dateTime = dateTime;
2593    }
2594
2595    /**
2596     * @return {@link #identifier} (Identifiers assigned to this order by the order sender or by the order receiver.)
2597     */
2598    public List<Identifier> getIdentifier() { 
2599      if (this.identifier == null)
2600        this.identifier = new ArrayList<Identifier>();
2601      return this.identifier;
2602    }
2603
2604    /**
2605     * @return Returns a reference to <code>this</code> for easy method chaining
2606     */
2607    public NutritionOrder setIdentifier(List<Identifier> theIdentifier) { 
2608      this.identifier = theIdentifier;
2609      return this;
2610    }
2611
2612    public boolean hasIdentifier() { 
2613      if (this.identifier == null)
2614        return false;
2615      for (Identifier item : this.identifier)
2616        if (!item.isEmpty())
2617          return true;
2618      return false;
2619    }
2620
2621    public Identifier addIdentifier() { //3
2622      Identifier t = new Identifier();
2623      if (this.identifier == null)
2624        this.identifier = new ArrayList<Identifier>();
2625      this.identifier.add(t);
2626      return t;
2627    }
2628
2629    public NutritionOrder addIdentifier(Identifier t) { //3
2630      if (t == null)
2631        return this;
2632      if (this.identifier == null)
2633        this.identifier = new ArrayList<Identifier>();
2634      this.identifier.add(t);
2635      return this;
2636    }
2637
2638    /**
2639     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
2640     */
2641    public Identifier getIdentifierFirstRep() { 
2642      if (getIdentifier().isEmpty()) {
2643        addIdentifier();
2644      }
2645      return getIdentifier().get(0);
2646    }
2647
2648    /**
2649     * @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
2650     */
2651    public Enumeration<NutritionOrderStatus> getStatusElement() { 
2652      if (this.status == null)
2653        if (Configuration.errorOnAutoCreate())
2654          throw new Error("Attempt to auto-create NutritionOrder.status");
2655        else if (Configuration.doAutoCreate())
2656          this.status = new Enumeration<NutritionOrderStatus>(new NutritionOrderStatusEnumFactory()); // bb
2657      return this.status;
2658    }
2659
2660    public boolean hasStatusElement() { 
2661      return this.status != null && !this.status.isEmpty();
2662    }
2663
2664    public boolean hasStatus() { 
2665      return this.status != null && !this.status.isEmpty();
2666    }
2667
2668    /**
2669     * @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
2670     */
2671    public NutritionOrder setStatusElement(Enumeration<NutritionOrderStatus> value) { 
2672      this.status = value;
2673      return this;
2674    }
2675
2676    /**
2677     * @return The workflow status of the nutrition order/request.
2678     */
2679    public NutritionOrderStatus getStatus() { 
2680      return this.status == null ? null : this.status.getValue();
2681    }
2682
2683    /**
2684     * @param value The workflow status of the nutrition order/request.
2685     */
2686    public NutritionOrder setStatus(NutritionOrderStatus value) { 
2687      if (value == null)
2688        this.status = null;
2689      else {
2690        if (this.status == null)
2691          this.status = new Enumeration<NutritionOrderStatus>(new NutritionOrderStatusEnumFactory());
2692        this.status.setValue(value);
2693      }
2694      return this;
2695    }
2696
2697    /**
2698     * @return {@link #patient} (The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.)
2699     */
2700    public Reference getPatient() { 
2701      if (this.patient == null)
2702        if (Configuration.errorOnAutoCreate())
2703          throw new Error("Attempt to auto-create NutritionOrder.patient");
2704        else if (Configuration.doAutoCreate())
2705          this.patient = new Reference(); // cc
2706      return this.patient;
2707    }
2708
2709    public boolean hasPatient() { 
2710      return this.patient != null && !this.patient.isEmpty();
2711    }
2712
2713    /**
2714     * @param value {@link #patient} (The person (patient) who needs the nutrition order for an oral diet, nutritional supplement and/or enteral or formula feeding.)
2715     */
2716    public NutritionOrder setPatient(Reference value) { 
2717      this.patient = value;
2718      return this;
2719    }
2720
2721    /**
2722     * @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.)
2723     */
2724    public Patient getPatientTarget() { 
2725      if (this.patientTarget == null)
2726        if (Configuration.errorOnAutoCreate())
2727          throw new Error("Attempt to auto-create NutritionOrder.patient");
2728        else if (Configuration.doAutoCreate())
2729          this.patientTarget = new Patient(); // aa
2730      return this.patientTarget;
2731    }
2732
2733    /**
2734     * @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.)
2735     */
2736    public NutritionOrder setPatientTarget(Patient value) { 
2737      this.patientTarget = value;
2738      return this;
2739    }
2740
2741    /**
2742     * @return {@link #encounter} (An encounter that provides additional information about the healthcare context in which this request is made.)
2743     */
2744    public Reference getEncounter() { 
2745      if (this.encounter == null)
2746        if (Configuration.errorOnAutoCreate())
2747          throw new Error("Attempt to auto-create NutritionOrder.encounter");
2748        else if (Configuration.doAutoCreate())
2749          this.encounter = new Reference(); // cc
2750      return this.encounter;
2751    }
2752
2753    public boolean hasEncounter() { 
2754      return this.encounter != null && !this.encounter.isEmpty();
2755    }
2756
2757    /**
2758     * @param value {@link #encounter} (An encounter that provides additional information about the healthcare context in which this request is made.)
2759     */
2760    public NutritionOrder setEncounter(Reference value) { 
2761      this.encounter = value;
2762      return this;
2763    }
2764
2765    /**
2766     * @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.)
2767     */
2768    public Encounter getEncounterTarget() { 
2769      if (this.encounterTarget == null)
2770        if (Configuration.errorOnAutoCreate())
2771          throw new Error("Attempt to auto-create NutritionOrder.encounter");
2772        else if (Configuration.doAutoCreate())
2773          this.encounterTarget = new Encounter(); // aa
2774      return this.encounterTarget;
2775    }
2776
2777    /**
2778     * @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.)
2779     */
2780    public NutritionOrder setEncounterTarget(Encounter value) { 
2781      this.encounterTarget = value;
2782      return this;
2783    }
2784
2785    /**
2786     * @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
2787     */
2788    public DateTimeType getDateTimeElement() { 
2789      if (this.dateTime == null)
2790        if (Configuration.errorOnAutoCreate())
2791          throw new Error("Attempt to auto-create NutritionOrder.dateTime");
2792        else if (Configuration.doAutoCreate())
2793          this.dateTime = new DateTimeType(); // bb
2794      return this.dateTime;
2795    }
2796
2797    public boolean hasDateTimeElement() { 
2798      return this.dateTime != null && !this.dateTime.isEmpty();
2799    }
2800
2801    public boolean hasDateTime() { 
2802      return this.dateTime != null && !this.dateTime.isEmpty();
2803    }
2804
2805    /**
2806     * @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
2807     */
2808    public NutritionOrder setDateTimeElement(DateTimeType value) { 
2809      this.dateTime = value;
2810      return this;
2811    }
2812
2813    /**
2814     * @return The date and time that this nutrition order was requested.
2815     */
2816    public Date getDateTime() { 
2817      return this.dateTime == null ? null : this.dateTime.getValue();
2818    }
2819
2820    /**
2821     * @param value The date and time that this nutrition order was requested.
2822     */
2823    public NutritionOrder setDateTime(Date value) { 
2824        if (this.dateTime == null)
2825          this.dateTime = new DateTimeType();
2826        this.dateTime.setValue(value);
2827      return this;
2828    }
2829
2830    /**
2831     * @return {@link #orderer} (The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.)
2832     */
2833    public Reference getOrderer() { 
2834      if (this.orderer == null)
2835        if (Configuration.errorOnAutoCreate())
2836          throw new Error("Attempt to auto-create NutritionOrder.orderer");
2837        else if (Configuration.doAutoCreate())
2838          this.orderer = new Reference(); // cc
2839      return this.orderer;
2840    }
2841
2842    public boolean hasOrderer() { 
2843      return this.orderer != null && !this.orderer.isEmpty();
2844    }
2845
2846    /**
2847     * @param value {@link #orderer} (The practitioner that holds legal responsibility for ordering the diet, nutritional supplement, or formula feedings.)
2848     */
2849    public NutritionOrder setOrderer(Reference value) { 
2850      this.orderer = value;
2851      return this;
2852    }
2853
2854    /**
2855     * @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.)
2856     */
2857    public Practitioner getOrdererTarget() { 
2858      if (this.ordererTarget == null)
2859        if (Configuration.errorOnAutoCreate())
2860          throw new Error("Attempt to auto-create NutritionOrder.orderer");
2861        else if (Configuration.doAutoCreate())
2862          this.ordererTarget = new Practitioner(); // aa
2863      return this.ordererTarget;
2864    }
2865
2866    /**
2867     * @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.)
2868     */
2869    public NutritionOrder setOrdererTarget(Practitioner value) { 
2870      this.ordererTarget = value;
2871      return this;
2872    }
2873
2874    /**
2875     * @return {@link #allergyIntolerance} (A link to a record of allergies or intolerances  which should be included in the nutrition order.)
2876     */
2877    public List<Reference> getAllergyIntolerance() { 
2878      if (this.allergyIntolerance == null)
2879        this.allergyIntolerance = new ArrayList<Reference>();
2880      return this.allergyIntolerance;
2881    }
2882
2883    /**
2884     * @return Returns a reference to <code>this</code> for easy method chaining
2885     */
2886    public NutritionOrder setAllergyIntolerance(List<Reference> theAllergyIntolerance) { 
2887      this.allergyIntolerance = theAllergyIntolerance;
2888      return this;
2889    }
2890
2891    public boolean hasAllergyIntolerance() { 
2892      if (this.allergyIntolerance == null)
2893        return false;
2894      for (Reference item : this.allergyIntolerance)
2895        if (!item.isEmpty())
2896          return true;
2897      return false;
2898    }
2899
2900    public Reference addAllergyIntolerance() { //3
2901      Reference t = new Reference();
2902      if (this.allergyIntolerance == null)
2903        this.allergyIntolerance = new ArrayList<Reference>();
2904      this.allergyIntolerance.add(t);
2905      return t;
2906    }
2907
2908    public NutritionOrder addAllergyIntolerance(Reference t) { //3
2909      if (t == null)
2910        return this;
2911      if (this.allergyIntolerance == null)
2912        this.allergyIntolerance = new ArrayList<Reference>();
2913      this.allergyIntolerance.add(t);
2914      return this;
2915    }
2916
2917    /**
2918     * @return The first repetition of repeating field {@link #allergyIntolerance}, creating it if it does not already exist
2919     */
2920    public Reference getAllergyIntoleranceFirstRep() { 
2921      if (getAllergyIntolerance().isEmpty()) {
2922        addAllergyIntolerance();
2923      }
2924      return getAllergyIntolerance().get(0);
2925    }
2926
2927    /**
2928     * @deprecated Use Reference#setResource(IBaseResource) instead
2929     */
2930    @Deprecated
2931    public List<AllergyIntolerance> getAllergyIntoleranceTarget() { 
2932      if (this.allergyIntoleranceTarget == null)
2933        this.allergyIntoleranceTarget = new ArrayList<AllergyIntolerance>();
2934      return this.allergyIntoleranceTarget;
2935    }
2936
2937    /**
2938     * @deprecated Use Reference#setResource(IBaseResource) instead
2939     */
2940    @Deprecated
2941    public AllergyIntolerance addAllergyIntoleranceTarget() { 
2942      AllergyIntolerance r = new AllergyIntolerance();
2943      if (this.allergyIntoleranceTarget == null)
2944        this.allergyIntoleranceTarget = new ArrayList<AllergyIntolerance>();
2945      this.allergyIntoleranceTarget.add(r);
2946      return r;
2947    }
2948
2949    /**
2950     * @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.)
2951     */
2952    public List<CodeableConcept> getFoodPreferenceModifier() { 
2953      if (this.foodPreferenceModifier == null)
2954        this.foodPreferenceModifier = new ArrayList<CodeableConcept>();
2955      return this.foodPreferenceModifier;
2956    }
2957
2958    /**
2959     * @return Returns a reference to <code>this</code> for easy method chaining
2960     */
2961    public NutritionOrder setFoodPreferenceModifier(List<CodeableConcept> theFoodPreferenceModifier) { 
2962      this.foodPreferenceModifier = theFoodPreferenceModifier;
2963      return this;
2964    }
2965
2966    public boolean hasFoodPreferenceModifier() { 
2967      if (this.foodPreferenceModifier == null)
2968        return false;
2969      for (CodeableConcept item : this.foodPreferenceModifier)
2970        if (!item.isEmpty())
2971          return true;
2972      return false;
2973    }
2974
2975    public CodeableConcept addFoodPreferenceModifier() { //3
2976      CodeableConcept t = new CodeableConcept();
2977      if (this.foodPreferenceModifier == null)
2978        this.foodPreferenceModifier = new ArrayList<CodeableConcept>();
2979      this.foodPreferenceModifier.add(t);
2980      return t;
2981    }
2982
2983    public NutritionOrder addFoodPreferenceModifier(CodeableConcept t) { //3
2984      if (t == null)
2985        return this;
2986      if (this.foodPreferenceModifier == null)
2987        this.foodPreferenceModifier = new ArrayList<CodeableConcept>();
2988      this.foodPreferenceModifier.add(t);
2989      return this;
2990    }
2991
2992    /**
2993     * @return The first repetition of repeating field {@link #foodPreferenceModifier}, creating it if it does not already exist
2994     */
2995    public CodeableConcept getFoodPreferenceModifierFirstRep() { 
2996      if (getFoodPreferenceModifier().isEmpty()) {
2997        addFoodPreferenceModifier();
2998      }
2999      return getFoodPreferenceModifier().get(0);
3000    }
3001
3002    /**
3003     * @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.)
3004     */
3005    public List<CodeableConcept> getExcludeFoodModifier() { 
3006      if (this.excludeFoodModifier == null)
3007        this.excludeFoodModifier = new ArrayList<CodeableConcept>();
3008      return this.excludeFoodModifier;
3009    }
3010
3011    /**
3012     * @return Returns a reference to <code>this</code> for easy method chaining
3013     */
3014    public NutritionOrder setExcludeFoodModifier(List<CodeableConcept> theExcludeFoodModifier) { 
3015      this.excludeFoodModifier = theExcludeFoodModifier;
3016      return this;
3017    }
3018
3019    public boolean hasExcludeFoodModifier() { 
3020      if (this.excludeFoodModifier == null)
3021        return false;
3022      for (CodeableConcept item : this.excludeFoodModifier)
3023        if (!item.isEmpty())
3024          return true;
3025      return false;
3026    }
3027
3028    public CodeableConcept addExcludeFoodModifier() { //3
3029      CodeableConcept t = new CodeableConcept();
3030      if (this.excludeFoodModifier == null)
3031        this.excludeFoodModifier = new ArrayList<CodeableConcept>();
3032      this.excludeFoodModifier.add(t);
3033      return t;
3034    }
3035
3036    public NutritionOrder addExcludeFoodModifier(CodeableConcept t) { //3
3037      if (t == null)
3038        return this;
3039      if (this.excludeFoodModifier == null)
3040        this.excludeFoodModifier = new ArrayList<CodeableConcept>();
3041      this.excludeFoodModifier.add(t);
3042      return this;
3043    }
3044
3045    /**
3046     * @return The first repetition of repeating field {@link #excludeFoodModifier}, creating it if it does not already exist
3047     */
3048    public CodeableConcept getExcludeFoodModifierFirstRep() { 
3049      if (getExcludeFoodModifier().isEmpty()) {
3050        addExcludeFoodModifier();
3051      }
3052      return getExcludeFoodModifier().get(0);
3053    }
3054
3055    /**
3056     * @return {@link #oralDiet} (Diet given orally in contrast to enteral (tube) feeding.)
3057     */
3058    public NutritionOrderOralDietComponent getOralDiet() { 
3059      if (this.oralDiet == null)
3060        if (Configuration.errorOnAutoCreate())
3061          throw new Error("Attempt to auto-create NutritionOrder.oralDiet");
3062        else if (Configuration.doAutoCreate())
3063          this.oralDiet = new NutritionOrderOralDietComponent(); // cc
3064      return this.oralDiet;
3065    }
3066
3067    public boolean hasOralDiet() { 
3068      return this.oralDiet != null && !this.oralDiet.isEmpty();
3069    }
3070
3071    /**
3072     * @param value {@link #oralDiet} (Diet given orally in contrast to enteral (tube) feeding.)
3073     */
3074    public NutritionOrder setOralDiet(NutritionOrderOralDietComponent value) { 
3075      this.oralDiet = value;
3076      return this;
3077    }
3078
3079    /**
3080     * @return {@link #supplement} (Oral nutritional products given in order to add further nutritional value to the patient's diet.)
3081     */
3082    public List<NutritionOrderSupplementComponent> getSupplement() { 
3083      if (this.supplement == null)
3084        this.supplement = new ArrayList<NutritionOrderSupplementComponent>();
3085      return this.supplement;
3086    }
3087
3088    /**
3089     * @return Returns a reference to <code>this</code> for easy method chaining
3090     */
3091    public NutritionOrder setSupplement(List<NutritionOrderSupplementComponent> theSupplement) { 
3092      this.supplement = theSupplement;
3093      return this;
3094    }
3095
3096    public boolean hasSupplement() { 
3097      if (this.supplement == null)
3098        return false;
3099      for (NutritionOrderSupplementComponent item : this.supplement)
3100        if (!item.isEmpty())
3101          return true;
3102      return false;
3103    }
3104
3105    public NutritionOrderSupplementComponent addSupplement() { //3
3106      NutritionOrderSupplementComponent t = new NutritionOrderSupplementComponent();
3107      if (this.supplement == null)
3108        this.supplement = new ArrayList<NutritionOrderSupplementComponent>();
3109      this.supplement.add(t);
3110      return t;
3111    }
3112
3113    public NutritionOrder addSupplement(NutritionOrderSupplementComponent t) { //3
3114      if (t == null)
3115        return this;
3116      if (this.supplement == null)
3117        this.supplement = new ArrayList<NutritionOrderSupplementComponent>();
3118      this.supplement.add(t);
3119      return this;
3120    }
3121
3122    /**
3123     * @return The first repetition of repeating field {@link #supplement}, creating it if it does not already exist
3124     */
3125    public NutritionOrderSupplementComponent getSupplementFirstRep() { 
3126      if (getSupplement().isEmpty()) {
3127        addSupplement();
3128      }
3129      return getSupplement().get(0);
3130    }
3131
3132    /**
3133     * @return {@link #enteralFormula} (Feeding provided through the gastrointestinal tract via a tube, catheter, or stoma that delivers nutrition distal to the oral cavity.)
3134     */
3135    public NutritionOrderEnteralFormulaComponent getEnteralFormula() { 
3136      if (this.enteralFormula == null)
3137        if (Configuration.errorOnAutoCreate())
3138          throw new Error("Attempt to auto-create NutritionOrder.enteralFormula");
3139        else if (Configuration.doAutoCreate())
3140          this.enteralFormula = new NutritionOrderEnteralFormulaComponent(); // cc
3141      return this.enteralFormula;
3142    }
3143
3144    public boolean hasEnteralFormula() { 
3145      return this.enteralFormula != null && !this.enteralFormula.isEmpty();
3146    }
3147
3148    /**
3149     * @param value {@link #enteralFormula} (Feeding provided through the gastrointestinal tract via a tube, catheter, or stoma that delivers nutrition distal to the oral cavity.)
3150     */
3151    public NutritionOrder setEnteralFormula(NutritionOrderEnteralFormulaComponent value) { 
3152      this.enteralFormula = value;
3153      return this;
3154    }
3155
3156      protected void listChildren(List<Property> childrenList) {
3157        super.listChildren(childrenList);
3158        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));
3159        childrenList.add(new Property("status", "code", "The workflow status of the nutrition order/request.", 0, java.lang.Integer.MAX_VALUE, status));
3160        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));
3161        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));
3162        childrenList.add(new Property("dateTime", "dateTime", "The date and time that this nutrition order was requested.", 0, java.lang.Integer.MAX_VALUE, dateTime));
3163        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));
3164        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));
3165        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));
3166        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));
3167        childrenList.add(new Property("oralDiet", "", "Diet given orally in contrast to enteral (tube) feeding.", 0, java.lang.Integer.MAX_VALUE, oralDiet));
3168        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));
3169        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));
3170      }
3171
3172      @Override
3173      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
3174        switch (hash) {
3175        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
3176        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<NutritionOrderStatus>
3177        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
3178        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
3179        case 1792749467: /*dateTime*/ return this.dateTime == null ? new Base[0] : new Base[] {this.dateTime}; // DateTimeType
3180        case -1207109509: /*orderer*/ return this.orderer == null ? new Base[0] : new Base[] {this.orderer}; // Reference
3181        case -120164120: /*allergyIntolerance*/ return this.allergyIntolerance == null ? new Base[0] : this.allergyIntolerance.toArray(new Base[this.allergyIntolerance.size()]); // Reference
3182        case 659473872: /*foodPreferenceModifier*/ return this.foodPreferenceModifier == null ? new Base[0] : this.foodPreferenceModifier.toArray(new Base[this.foodPreferenceModifier.size()]); // CodeableConcept
3183        case 1760260175: /*excludeFoodModifier*/ return this.excludeFoodModifier == null ? new Base[0] : this.excludeFoodModifier.toArray(new Base[this.excludeFoodModifier.size()]); // CodeableConcept
3184        case 1153521250: /*oralDiet*/ return this.oralDiet == null ? new Base[0] : new Base[] {this.oralDiet}; // NutritionOrderOralDietComponent
3185        case -711993159: /*supplement*/ return this.supplement == null ? new Base[0] : this.supplement.toArray(new Base[this.supplement.size()]); // NutritionOrderSupplementComponent
3186        case -671083805: /*enteralFormula*/ return this.enteralFormula == null ? new Base[0] : new Base[] {this.enteralFormula}; // NutritionOrderEnteralFormulaComponent
3187        default: return super.getProperty(hash, name, checkValid);
3188        }
3189
3190      }
3191
3192      @Override
3193      public Base setProperty(int hash, String name, Base value) throws FHIRException {
3194        switch (hash) {
3195        case -1618432855: // identifier
3196          this.getIdentifier().add(castToIdentifier(value)); // Identifier
3197          return value;
3198        case -892481550: // status
3199          value = new NutritionOrderStatusEnumFactory().fromType(castToCode(value));
3200          this.status = (Enumeration) value; // Enumeration<NutritionOrderStatus>
3201          return value;
3202        case -791418107: // patient
3203          this.patient = castToReference(value); // Reference
3204          return value;
3205        case 1524132147: // encounter
3206          this.encounter = castToReference(value); // Reference
3207          return value;
3208        case 1792749467: // dateTime
3209          this.dateTime = castToDateTime(value); // DateTimeType
3210          return value;
3211        case -1207109509: // orderer
3212          this.orderer = castToReference(value); // Reference
3213          return value;
3214        case -120164120: // allergyIntolerance
3215          this.getAllergyIntolerance().add(castToReference(value)); // Reference
3216          return value;
3217        case 659473872: // foodPreferenceModifier
3218          this.getFoodPreferenceModifier().add(castToCodeableConcept(value)); // CodeableConcept
3219          return value;
3220        case 1760260175: // excludeFoodModifier
3221          this.getExcludeFoodModifier().add(castToCodeableConcept(value)); // CodeableConcept
3222          return value;
3223        case 1153521250: // oralDiet
3224          this.oralDiet = (NutritionOrderOralDietComponent) value; // NutritionOrderOralDietComponent
3225          return value;
3226        case -711993159: // supplement
3227          this.getSupplement().add((NutritionOrderSupplementComponent) value); // NutritionOrderSupplementComponent
3228          return value;
3229        case -671083805: // enteralFormula
3230          this.enteralFormula = (NutritionOrderEnteralFormulaComponent) value; // NutritionOrderEnteralFormulaComponent
3231          return value;
3232        default: return super.setProperty(hash, name, value);
3233        }
3234
3235      }
3236
3237      @Override
3238      public Base setProperty(String name, Base value) throws FHIRException {
3239        if (name.equals("identifier")) {
3240          this.getIdentifier().add(castToIdentifier(value));
3241        } else if (name.equals("status")) {
3242          value = new NutritionOrderStatusEnumFactory().fromType(castToCode(value));
3243          this.status = (Enumeration) value; // Enumeration<NutritionOrderStatus>
3244        } else if (name.equals("patient")) {
3245          this.patient = castToReference(value); // Reference
3246        } else if (name.equals("encounter")) {
3247          this.encounter = castToReference(value); // Reference
3248        } else if (name.equals("dateTime")) {
3249          this.dateTime = castToDateTime(value); // DateTimeType
3250        } else if (name.equals("orderer")) {
3251          this.orderer = castToReference(value); // Reference
3252        } else if (name.equals("allergyIntolerance")) {
3253          this.getAllergyIntolerance().add(castToReference(value));
3254        } else if (name.equals("foodPreferenceModifier")) {
3255          this.getFoodPreferenceModifier().add(castToCodeableConcept(value));
3256        } else if (name.equals("excludeFoodModifier")) {
3257          this.getExcludeFoodModifier().add(castToCodeableConcept(value));
3258        } else if (name.equals("oralDiet")) {
3259          this.oralDiet = (NutritionOrderOralDietComponent) value; // NutritionOrderOralDietComponent
3260        } else if (name.equals("supplement")) {
3261          this.getSupplement().add((NutritionOrderSupplementComponent) value);
3262        } else if (name.equals("enteralFormula")) {
3263          this.enteralFormula = (NutritionOrderEnteralFormulaComponent) value; // NutritionOrderEnteralFormulaComponent
3264        } else
3265          return super.setProperty(name, value);
3266        return value;
3267      }
3268
3269      @Override
3270      public Base makeProperty(int hash, String name) throws FHIRException {
3271        switch (hash) {
3272        case -1618432855:  return addIdentifier(); 
3273        case -892481550:  return getStatusElement();
3274        case -791418107:  return getPatient(); 
3275        case 1524132147:  return getEncounter(); 
3276        case 1792749467:  return getDateTimeElement();
3277        case -1207109509:  return getOrderer(); 
3278        case -120164120:  return addAllergyIntolerance(); 
3279        case 659473872:  return addFoodPreferenceModifier(); 
3280        case 1760260175:  return addExcludeFoodModifier(); 
3281        case 1153521250:  return getOralDiet(); 
3282        case -711993159:  return addSupplement(); 
3283        case -671083805:  return getEnteralFormula(); 
3284        default: return super.makeProperty(hash, name);
3285        }
3286
3287      }
3288
3289      @Override
3290      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
3291        switch (hash) {
3292        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
3293        case -892481550: /*status*/ return new String[] {"code"};
3294        case -791418107: /*patient*/ return new String[] {"Reference"};
3295        case 1524132147: /*encounter*/ return new String[] {"Reference"};
3296        case 1792749467: /*dateTime*/ return new String[] {"dateTime"};
3297        case -1207109509: /*orderer*/ return new String[] {"Reference"};
3298        case -120164120: /*allergyIntolerance*/ return new String[] {"Reference"};
3299        case 659473872: /*foodPreferenceModifier*/ return new String[] {"CodeableConcept"};
3300        case 1760260175: /*excludeFoodModifier*/ return new String[] {"CodeableConcept"};
3301        case 1153521250: /*oralDiet*/ return new String[] {};
3302        case -711993159: /*supplement*/ return new String[] {};
3303        case -671083805: /*enteralFormula*/ return new String[] {};
3304        default: return super.getTypesForProperty(hash, name);
3305        }
3306
3307      }
3308
3309      @Override
3310      public Base addChild(String name) throws FHIRException {
3311        if (name.equals("identifier")) {
3312          return addIdentifier();
3313        }
3314        else if (name.equals("status")) {
3315          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.status");
3316        }
3317        else if (name.equals("patient")) {
3318          this.patient = new Reference();
3319          return this.patient;
3320        }
3321        else if (name.equals("encounter")) {
3322          this.encounter = new Reference();
3323          return this.encounter;
3324        }
3325        else if (name.equals("dateTime")) {
3326          throw new FHIRException("Cannot call addChild on a primitive type NutritionOrder.dateTime");
3327        }
3328        else if (name.equals("orderer")) {
3329          this.orderer = new Reference();
3330          return this.orderer;
3331        }
3332        else if (name.equals("allergyIntolerance")) {
3333          return addAllergyIntolerance();
3334        }
3335        else if (name.equals("foodPreferenceModifier")) {
3336          return addFoodPreferenceModifier();
3337        }
3338        else if (name.equals("excludeFoodModifier")) {
3339          return addExcludeFoodModifier();
3340        }
3341        else if (name.equals("oralDiet")) {
3342          this.oralDiet = new NutritionOrderOralDietComponent();
3343          return this.oralDiet;
3344        }
3345        else if (name.equals("supplement")) {
3346          return addSupplement();
3347        }
3348        else if (name.equals("enteralFormula")) {
3349          this.enteralFormula = new NutritionOrderEnteralFormulaComponent();
3350          return this.enteralFormula;
3351        }
3352        else
3353          return super.addChild(name);
3354      }
3355
3356  public String fhirType() {
3357    return "NutritionOrder";
3358
3359  }
3360
3361      public NutritionOrder copy() {
3362        NutritionOrder dst = new NutritionOrder();
3363        copyValues(dst);
3364        if (identifier != null) {
3365          dst.identifier = new ArrayList<Identifier>();
3366          for (Identifier i : identifier)
3367            dst.identifier.add(i.copy());
3368        };
3369        dst.status = status == null ? null : status.copy();
3370        dst.patient = patient == null ? null : patient.copy();
3371        dst.encounter = encounter == null ? null : encounter.copy();
3372        dst.dateTime = dateTime == null ? null : dateTime.copy();
3373        dst.orderer = orderer == null ? null : orderer.copy();
3374        if (allergyIntolerance != null) {
3375          dst.allergyIntolerance = new ArrayList<Reference>();
3376          for (Reference i : allergyIntolerance)
3377            dst.allergyIntolerance.add(i.copy());
3378        };
3379        if (foodPreferenceModifier != null) {
3380          dst.foodPreferenceModifier = new ArrayList<CodeableConcept>();
3381          for (CodeableConcept i : foodPreferenceModifier)
3382            dst.foodPreferenceModifier.add(i.copy());
3383        };
3384        if (excludeFoodModifier != null) {
3385          dst.excludeFoodModifier = new ArrayList<CodeableConcept>();
3386          for (CodeableConcept i : excludeFoodModifier)
3387            dst.excludeFoodModifier.add(i.copy());
3388        };
3389        dst.oralDiet = oralDiet == null ? null : oralDiet.copy();
3390        if (supplement != null) {
3391          dst.supplement = new ArrayList<NutritionOrderSupplementComponent>();
3392          for (NutritionOrderSupplementComponent i : supplement)
3393            dst.supplement.add(i.copy());
3394        };
3395        dst.enteralFormula = enteralFormula == null ? null : enteralFormula.copy();
3396        return dst;
3397      }
3398
3399      protected NutritionOrder typedCopy() {
3400        return copy();
3401      }
3402
3403      @Override
3404      public boolean equalsDeep(Base other) {
3405        if (!super.equalsDeep(other))
3406          return false;
3407        if (!(other instanceof NutritionOrder))
3408          return false;
3409        NutritionOrder o = (NutritionOrder) other;
3410        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(patient, o.patient, true)
3411           && compareDeep(encounter, o.encounter, true) && compareDeep(dateTime, o.dateTime, true) && compareDeep(orderer, o.orderer, true)
3412           && compareDeep(allergyIntolerance, o.allergyIntolerance, true) && compareDeep(foodPreferenceModifier, o.foodPreferenceModifier, true)
3413           && compareDeep(excludeFoodModifier, o.excludeFoodModifier, true) && compareDeep(oralDiet, o.oralDiet, true)
3414           && compareDeep(supplement, o.supplement, true) && compareDeep(enteralFormula, o.enteralFormula, true)
3415          ;
3416      }
3417
3418      @Override
3419      public boolean equalsShallow(Base other) {
3420        if (!super.equalsShallow(other))
3421          return false;
3422        if (!(other instanceof NutritionOrder))
3423          return false;
3424        NutritionOrder o = (NutritionOrder) other;
3425        return compareValues(status, o.status, true) && compareValues(dateTime, o.dateTime, true);
3426      }
3427
3428      public boolean isEmpty() {
3429        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, patient
3430          , encounter, dateTime, orderer, allergyIntolerance, foodPreferenceModifier, excludeFoodModifier
3431          , oralDiet, supplement, enteralFormula);
3432      }
3433
3434  @Override
3435  public ResourceType getResourceType() {
3436    return ResourceType.NutritionOrder;
3437   }
3438
3439 /**
3440   * Search parameter: <b>identifier</b>
3441   * <p>
3442   * Description: <b>Return nutrition orders with this external identifier</b><br>
3443   * Type: <b>token</b><br>
3444   * Path: <b>NutritionOrder.identifier</b><br>
3445   * </p>
3446   */
3447  @SearchParamDefinition(name="identifier", path="NutritionOrder.identifier", description="Return nutrition orders with this external identifier", type="token" )
3448  public static final String SP_IDENTIFIER = "identifier";
3449 /**
3450   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3451   * <p>
3452   * Description: <b>Return nutrition orders with this external identifier</b><br>
3453   * Type: <b>token</b><br>
3454   * Path: <b>NutritionOrder.identifier</b><br>
3455   * </p>
3456   */
3457  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3458
3459 /**
3460   * Search parameter: <b>datetime</b>
3461   * <p>
3462   * Description: <b>Return nutrition orders requested on this date</b><br>
3463   * Type: <b>date</b><br>
3464   * Path: <b>NutritionOrder.dateTime</b><br>
3465   * </p>
3466   */
3467  @SearchParamDefinition(name="datetime", path="NutritionOrder.dateTime", description="Return nutrition orders requested on this date", type="date" )
3468  public static final String SP_DATETIME = "datetime";
3469 /**
3470   * <b>Fluent Client</b> search parameter constant for <b>datetime</b>
3471   * <p>
3472   * Description: <b>Return nutrition orders requested on this date</b><br>
3473   * Type: <b>date</b><br>
3474   * Path: <b>NutritionOrder.dateTime</b><br>
3475   * </p>
3476   */
3477  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATETIME = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATETIME);
3478
3479 /**
3480   * Search parameter: <b>provider</b>
3481   * <p>
3482   * Description: <b>The identify of the provider who placed the nutrition order</b><br>
3483   * Type: <b>reference</b><br>
3484   * Path: <b>NutritionOrder.orderer</b><br>
3485   * </p>
3486   */
3487  @SearchParamDefinition(name="provider", path="NutritionOrder.orderer", description="The identify of the provider who placed the nutrition order", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Practitioner.class } )
3488  public static final String SP_PROVIDER = "provider";
3489 /**
3490   * <b>Fluent Client</b> search parameter constant for <b>provider</b>
3491   * <p>
3492   * Description: <b>The identify of the provider who placed the nutrition order</b><br>
3493   * Type: <b>reference</b><br>
3494   * Path: <b>NutritionOrder.orderer</b><br>
3495   * </p>
3496   */
3497  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PROVIDER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PROVIDER);
3498
3499/**
3500   * Constant for fluent queries to be used to add include statements. Specifies
3501   * the path value of "<b>NutritionOrder:provider</b>".
3502   */
3503  public static final ca.uhn.fhir.model.api.Include INCLUDE_PROVIDER = new ca.uhn.fhir.model.api.Include("NutritionOrder:provider").toLocked();
3504
3505 /**
3506   * Search parameter: <b>patient</b>
3507   * <p>
3508   * Description: <b>The identity of the person who requires the diet, formula or nutritional supplement</b><br>
3509   * Type: <b>reference</b><br>
3510   * Path: <b>NutritionOrder.patient</b><br>
3511   * </p>
3512   */
3513  @SearchParamDefinition(name="patient", path="NutritionOrder.patient", description="The identity of the person who requires the diet, formula or nutritional supplement", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
3514  public static final String SP_PATIENT = "patient";
3515 /**
3516   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3517   * <p>
3518   * Description: <b>The identity of the person who requires the diet, formula or nutritional supplement</b><br>
3519   * Type: <b>reference</b><br>
3520   * Path: <b>NutritionOrder.patient</b><br>
3521   * </p>
3522   */
3523  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3524
3525/**
3526   * Constant for fluent queries to be used to add include statements. Specifies
3527   * the path value of "<b>NutritionOrder:patient</b>".
3528   */
3529  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("NutritionOrder:patient").toLocked();
3530
3531 /**
3532   * Search parameter: <b>supplement</b>
3533   * <p>
3534   * Description: <b>Type of supplement product requested</b><br>
3535   * Type: <b>token</b><br>
3536   * Path: <b>NutritionOrder.supplement.type</b><br>
3537   * </p>
3538   */
3539  @SearchParamDefinition(name="supplement", path="NutritionOrder.supplement.type", description="Type of supplement product requested", type="token" )
3540  public static final String SP_SUPPLEMENT = "supplement";
3541 /**
3542   * <b>Fluent Client</b> search parameter constant for <b>supplement</b>
3543   * <p>
3544   * Description: <b>Type of supplement product requested</b><br>
3545   * Type: <b>token</b><br>
3546   * Path: <b>NutritionOrder.supplement.type</b><br>
3547   * </p>
3548   */
3549  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SUPPLEMENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SUPPLEMENT);
3550
3551 /**
3552   * Search parameter: <b>formula</b>
3553   * <p>
3554   * Description: <b>Type of enteral or infant formula</b><br>
3555   * Type: <b>token</b><br>
3556   * Path: <b>NutritionOrder.enteralFormula.baseFormulaType</b><br>
3557   * </p>
3558   */
3559  @SearchParamDefinition(name="formula", path="NutritionOrder.enteralFormula.baseFormulaType", description="Type of enteral or infant formula", type="token" )
3560  public static final String SP_FORMULA = "formula";
3561 /**
3562   * <b>Fluent Client</b> search parameter constant for <b>formula</b>
3563   * <p>
3564   * Description: <b>Type of enteral or infant formula</b><br>
3565   * Type: <b>token</b><br>
3566   * Path: <b>NutritionOrder.enteralFormula.baseFormulaType</b><br>
3567   * </p>
3568   */
3569  public static final ca.uhn.fhir.rest.gclient.TokenClientParam FORMULA = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_FORMULA);
3570
3571 /**
3572   * Search parameter: <b>encounter</b>
3573   * <p>
3574   * Description: <b>Return nutrition orders with this encounter identifier</b><br>
3575   * Type: <b>reference</b><br>
3576   * Path: <b>NutritionOrder.encounter</b><br>
3577   * </p>
3578   */
3579  @SearchParamDefinition(name="encounter", path="NutritionOrder.encounter", description="Return nutrition orders with this encounter identifier", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
3580  public static final String SP_ENCOUNTER = "encounter";
3581 /**
3582   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
3583   * <p>
3584   * Description: <b>Return nutrition orders with this encounter identifier</b><br>
3585   * Type: <b>reference</b><br>
3586   * Path: <b>NutritionOrder.encounter</b><br>
3587   * </p>
3588   */
3589  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
3590
3591/**
3592   * Constant for fluent queries to be used to add include statements. Specifies
3593   * the path value of "<b>NutritionOrder:encounter</b>".
3594   */
3595  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("NutritionOrder:encounter").toLocked();
3596
3597 /**
3598   * Search parameter: <b>oraldiet</b>
3599   * <p>
3600   * Description: <b>Type of diet that can be consumed orally (i.e., take via the mouth).</b><br>
3601   * Type: <b>token</b><br>
3602   * Path: <b>NutritionOrder.oralDiet.type</b><br>
3603   * </p>
3604   */
3605  @SearchParamDefinition(name="oraldiet", path="NutritionOrder.oralDiet.type", description="Type of diet that can be consumed orally (i.e., take via the mouth).", type="token" )
3606  public static final String SP_ORALDIET = "oraldiet";
3607 /**
3608   * <b>Fluent Client</b> search parameter constant for <b>oraldiet</b>
3609   * <p>
3610   * Description: <b>Type of diet that can be consumed orally (i.e., take via the mouth).</b><br>
3611   * Type: <b>token</b><br>
3612   * Path: <b>NutritionOrder.oralDiet.type</b><br>
3613   * </p>
3614   */
3615  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ORALDIET = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ORALDIET);
3616
3617 /**
3618   * Search parameter: <b>status</b>
3619   * <p>
3620   * Description: <b>Status of the nutrition order.</b><br>
3621   * Type: <b>token</b><br>
3622   * Path: <b>NutritionOrder.status</b><br>
3623   * </p>
3624   */
3625  @SearchParamDefinition(name="status", path="NutritionOrder.status", description="Status of the nutrition order.", type="token" )
3626  public static final String SP_STATUS = "status";
3627 /**
3628   * <b>Fluent Client</b> search parameter constant for <b>status</b>
3629   * <p>
3630   * Description: <b>Status of the nutrition order.</b><br>
3631   * Type: <b>token</b><br>
3632   * Path: <b>NutritionOrder.status</b><br>
3633   * </p>
3634   */
3635  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
3636
3637 /**
3638   * Search parameter: <b>additive</b>
3639   * <p>
3640   * Description: <b>Type of module component to add to the feeding</b><br>
3641   * Type: <b>token</b><br>
3642   * Path: <b>NutritionOrder.enteralFormula.additiveType</b><br>
3643   * </p>
3644   */
3645  @SearchParamDefinition(name="additive", path="NutritionOrder.enteralFormula.additiveType", description="Type of module component to add to the feeding", type="token" )
3646  public static final String SP_ADDITIVE = "additive";
3647 /**
3648   * <b>Fluent Client</b> search parameter constant for <b>additive</b>
3649   * <p>
3650   * Description: <b>Type of module component to add to the feeding</b><br>
3651   * Type: <b>token</b><br>
3652   * Path: <b>NutritionOrder.enteralFormula.additiveType</b><br>
3653   * </p>
3654   */
3655  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ADDITIVE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ADDITIVE);
3656
3657
3658}
3659