001package org.hl7.fhir.r5.model;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Tue, Dec 28, 2021 07:16+1100 for FHIR v5.0.0-snapshot1
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import org.hl7.fhir.utilities.Utilities;
038import org.hl7.fhir.r5.model.Enumerations.*;
039import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
040import org.hl7.fhir.exceptions.FHIRException;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.ResourceDef;
043import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
044import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
045import ca.uhn.fhir.model.api.annotation.Child;
046import ca.uhn.fhir.model.api.annotation.ChildOrder;
047import ca.uhn.fhir.model.api.annotation.Description;
048import ca.uhn.fhir.model.api.annotation.Block;
049
050/**
051 * An ingredient of a manufactured item or pharmaceutical product.
052 */
053@ResourceDef(name="Ingredient", profile="http://hl7.org/fhir/StructureDefinition/Ingredient")
054public class Ingredient extends DomainResource {
055
056    @Block()
057    public static class IngredientManufacturerComponent extends BackboneElement implements IBaseBackboneElement {
058        /**
059         * The way in which this manufacturer is associated with the ingredient. For example whether it is a possible one (others allowed), or an exclusive authorized one for this ingredient. Note that this is not the manufacturing process role.
060         */
061        @Child(name = "role", type = {Coding.class}, order=1, min=0, max=1, modifier=false, summary=true)
062        @Description(shortDefinition="The way in which this manufacturer is associated with the ingredient. For example whether it is a possible one (others allowed), or an exclusive authorized one for this ingredient. Note that this is not the manufacturing process role", formalDefinition="The way in which this manufacturer is associated with the ingredient. For example whether it is a possible one (others allowed), or an exclusive authorized one for this ingredient. Note that this is not the manufacturing process role." )
063        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/ingredient-manufacturer-role")
064        protected Coding role;
065
066        /**
067         * An organization that manufactures this ingredient.
068         */
069        @Child(name = "manufacturer", type = {Organization.class}, order=2, min=1, max=1, modifier=false, summary=true)
070        @Description(shortDefinition="An organization that manufactures this ingredient", formalDefinition="An organization that manufactures this ingredient." )
071        protected Reference manufacturer;
072
073        private static final long serialVersionUID = -1240157438L;
074
075    /**
076     * Constructor
077     */
078      public IngredientManufacturerComponent() {
079        super();
080      }
081
082    /**
083     * Constructor
084     */
085      public IngredientManufacturerComponent(Reference manufacturer) {
086        super();
087        this.setManufacturer(manufacturer);
088      }
089
090        /**
091         * @return {@link #role} (The way in which this manufacturer is associated with the ingredient. For example whether it is a possible one (others allowed), or an exclusive authorized one for this ingredient. Note that this is not the manufacturing process role.)
092         */
093        public Coding getRole() { 
094          if (this.role == null)
095            if (Configuration.errorOnAutoCreate())
096              throw new Error("Attempt to auto-create IngredientManufacturerComponent.role");
097            else if (Configuration.doAutoCreate())
098              this.role = new Coding(); // cc
099          return this.role;
100        }
101
102        public boolean hasRole() { 
103          return this.role != null && !this.role.isEmpty();
104        }
105
106        /**
107         * @param value {@link #role} (The way in which this manufacturer is associated with the ingredient. For example whether it is a possible one (others allowed), or an exclusive authorized one for this ingredient. Note that this is not the manufacturing process role.)
108         */
109        public IngredientManufacturerComponent setRole(Coding value) { 
110          this.role = value;
111          return this;
112        }
113
114        /**
115         * @return {@link #manufacturer} (An organization that manufactures this ingredient.)
116         */
117        public Reference getManufacturer() { 
118          if (this.manufacturer == null)
119            if (Configuration.errorOnAutoCreate())
120              throw new Error("Attempt to auto-create IngredientManufacturerComponent.manufacturer");
121            else if (Configuration.doAutoCreate())
122              this.manufacturer = new Reference(); // cc
123          return this.manufacturer;
124        }
125
126        public boolean hasManufacturer() { 
127          return this.manufacturer != null && !this.manufacturer.isEmpty();
128        }
129
130        /**
131         * @param value {@link #manufacturer} (An organization that manufactures this ingredient.)
132         */
133        public IngredientManufacturerComponent setManufacturer(Reference value) { 
134          this.manufacturer = value;
135          return this;
136        }
137
138        protected void listChildren(List<Property> children) {
139          super.listChildren(children);
140          children.add(new Property("role", "Coding", "The way in which this manufacturer is associated with the ingredient. For example whether it is a possible one (others allowed), or an exclusive authorized one for this ingredient. Note that this is not the manufacturing process role.", 0, 1, role));
141          children.add(new Property("manufacturer", "Reference(Organization)", "An organization that manufactures this ingredient.", 0, 1, manufacturer));
142        }
143
144        @Override
145        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
146          switch (_hash) {
147          case 3506294: /*role*/  return new Property("role", "Coding", "The way in which this manufacturer is associated with the ingredient. For example whether it is a possible one (others allowed), or an exclusive authorized one for this ingredient. Note that this is not the manufacturing process role.", 0, 1, role);
148          case -1969347631: /*manufacturer*/  return new Property("manufacturer", "Reference(Organization)", "An organization that manufactures this ingredient.", 0, 1, manufacturer);
149          default: return super.getNamedProperty(_hash, _name, _checkValid);
150          }
151
152        }
153
154      @Override
155      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
156        switch (hash) {
157        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // Coding
158        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : new Base[] {this.manufacturer}; // Reference
159        default: return super.getProperty(hash, name, checkValid);
160        }
161
162      }
163
164      @Override
165      public Base setProperty(int hash, String name, Base value) throws FHIRException {
166        switch (hash) {
167        case 3506294: // role
168          this.role = TypeConvertor.castToCoding(value); // Coding
169          return value;
170        case -1969347631: // manufacturer
171          this.manufacturer = TypeConvertor.castToReference(value); // Reference
172          return value;
173        default: return super.setProperty(hash, name, value);
174        }
175
176      }
177
178      @Override
179      public Base setProperty(String name, Base value) throws FHIRException {
180        if (name.equals("role")) {
181          this.role = TypeConvertor.castToCoding(value); // Coding
182        } else if (name.equals("manufacturer")) {
183          this.manufacturer = TypeConvertor.castToReference(value); // Reference
184        } else
185          return super.setProperty(name, value);
186        return value;
187      }
188
189      @Override
190      public Base makeProperty(int hash, String name) throws FHIRException {
191        switch (hash) {
192        case 3506294:  return getRole();
193        case -1969347631:  return getManufacturer();
194        default: return super.makeProperty(hash, name);
195        }
196
197      }
198
199      @Override
200      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
201        switch (hash) {
202        case 3506294: /*role*/ return new String[] {"Coding"};
203        case -1969347631: /*manufacturer*/ return new String[] {"Reference"};
204        default: return super.getTypesForProperty(hash, name);
205        }
206
207      }
208
209      @Override
210      public Base addChild(String name) throws FHIRException {
211        if (name.equals("role")) {
212          this.role = new Coding();
213          return this.role;
214        }
215        else if (name.equals("manufacturer")) {
216          this.manufacturer = new Reference();
217          return this.manufacturer;
218        }
219        else
220          return super.addChild(name);
221      }
222
223      public IngredientManufacturerComponent copy() {
224        IngredientManufacturerComponent dst = new IngredientManufacturerComponent();
225        copyValues(dst);
226        return dst;
227      }
228
229      public void copyValues(IngredientManufacturerComponent dst) {
230        super.copyValues(dst);
231        dst.role = role == null ? null : role.copy();
232        dst.manufacturer = manufacturer == null ? null : manufacturer.copy();
233      }
234
235      @Override
236      public boolean equalsDeep(Base other_) {
237        if (!super.equalsDeep(other_))
238          return false;
239        if (!(other_ instanceof IngredientManufacturerComponent))
240          return false;
241        IngredientManufacturerComponent o = (IngredientManufacturerComponent) other_;
242        return compareDeep(role, o.role, true) && compareDeep(manufacturer, o.manufacturer, true);
243      }
244
245      @Override
246      public boolean equalsShallow(Base other_) {
247        if (!super.equalsShallow(other_))
248          return false;
249        if (!(other_ instanceof IngredientManufacturerComponent))
250          return false;
251        IngredientManufacturerComponent o = (IngredientManufacturerComponent) other_;
252        return true;
253      }
254
255      public boolean isEmpty() {
256        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(role, manufacturer);
257      }
258
259  public String fhirType() {
260    return "Ingredient.manufacturer";
261
262  }
263
264  }
265
266    @Block()
267    public static class IngredientSubstanceComponent extends BackboneElement implements IBaseBackboneElement {
268        /**
269         * A code or full resource that represents the ingredient substance.
270         */
271        @Child(name = "code", type = {CodeableReference.class}, order=1, min=1, max=1, modifier=false, summary=true)
272        @Description(shortDefinition="A code or full resource that represents the ingredient substance", formalDefinition="A code or full resource that represents the ingredient substance." )
273        protected CodeableReference code;
274
275        /**
276         * The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.
277         */
278        @Child(name = "strength", type = {}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
279        @Description(shortDefinition="The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item", formalDefinition="The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item." )
280        protected List<IngredientSubstanceStrengthComponent> strength;
281
282        private static final long serialVersionUID = 538347209L;
283
284    /**
285     * Constructor
286     */
287      public IngredientSubstanceComponent() {
288        super();
289      }
290
291    /**
292     * Constructor
293     */
294      public IngredientSubstanceComponent(CodeableReference code) {
295        super();
296        this.setCode(code);
297      }
298
299        /**
300         * @return {@link #code} (A code or full resource that represents the ingredient substance.)
301         */
302        public CodeableReference getCode() { 
303          if (this.code == null)
304            if (Configuration.errorOnAutoCreate())
305              throw new Error("Attempt to auto-create IngredientSubstanceComponent.code");
306            else if (Configuration.doAutoCreate())
307              this.code = new CodeableReference(); // cc
308          return this.code;
309        }
310
311        public boolean hasCode() { 
312          return this.code != null && !this.code.isEmpty();
313        }
314
315        /**
316         * @param value {@link #code} (A code or full resource that represents the ingredient substance.)
317         */
318        public IngredientSubstanceComponent setCode(CodeableReference value) { 
319          this.code = value;
320          return this;
321        }
322
323        /**
324         * @return {@link #strength} (The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.)
325         */
326        public List<IngredientSubstanceStrengthComponent> getStrength() { 
327          if (this.strength == null)
328            this.strength = new ArrayList<IngredientSubstanceStrengthComponent>();
329          return this.strength;
330        }
331
332        /**
333         * @return Returns a reference to <code>this</code> for easy method chaining
334         */
335        public IngredientSubstanceComponent setStrength(List<IngredientSubstanceStrengthComponent> theStrength) { 
336          this.strength = theStrength;
337          return this;
338        }
339
340        public boolean hasStrength() { 
341          if (this.strength == null)
342            return false;
343          for (IngredientSubstanceStrengthComponent item : this.strength)
344            if (!item.isEmpty())
345              return true;
346          return false;
347        }
348
349        public IngredientSubstanceStrengthComponent addStrength() { //3
350          IngredientSubstanceStrengthComponent t = new IngredientSubstanceStrengthComponent();
351          if (this.strength == null)
352            this.strength = new ArrayList<IngredientSubstanceStrengthComponent>();
353          this.strength.add(t);
354          return t;
355        }
356
357        public IngredientSubstanceComponent addStrength(IngredientSubstanceStrengthComponent t) { //3
358          if (t == null)
359            return this;
360          if (this.strength == null)
361            this.strength = new ArrayList<IngredientSubstanceStrengthComponent>();
362          this.strength.add(t);
363          return this;
364        }
365
366        /**
367         * @return The first repetition of repeating field {@link #strength}, creating it if it does not already exist {3}
368         */
369        public IngredientSubstanceStrengthComponent getStrengthFirstRep() { 
370          if (getStrength().isEmpty()) {
371            addStrength();
372          }
373          return getStrength().get(0);
374        }
375
376        protected void listChildren(List<Property> children) {
377          super.listChildren(children);
378          children.add(new Property("code", "CodeableReference(SubstanceDefinition)", "A code or full resource that represents the ingredient substance.", 0, 1, code));
379          children.add(new Property("strength", "", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, java.lang.Integer.MAX_VALUE, strength));
380        }
381
382        @Override
383        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
384          switch (_hash) {
385          case 3059181: /*code*/  return new Property("code", "CodeableReference(SubstanceDefinition)", "A code or full resource that represents the ingredient substance.", 0, 1, code);
386          case 1791316033: /*strength*/  return new Property("strength", "", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, java.lang.Integer.MAX_VALUE, strength);
387          default: return super.getNamedProperty(_hash, _name, _checkValid);
388          }
389
390        }
391
392      @Override
393      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
394        switch (hash) {
395        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableReference
396        case 1791316033: /*strength*/ return this.strength == null ? new Base[0] : this.strength.toArray(new Base[this.strength.size()]); // IngredientSubstanceStrengthComponent
397        default: return super.getProperty(hash, name, checkValid);
398        }
399
400      }
401
402      @Override
403      public Base setProperty(int hash, String name, Base value) throws FHIRException {
404        switch (hash) {
405        case 3059181: // code
406          this.code = TypeConvertor.castToCodeableReference(value); // CodeableReference
407          return value;
408        case 1791316033: // strength
409          this.getStrength().add((IngredientSubstanceStrengthComponent) value); // IngredientSubstanceStrengthComponent
410          return value;
411        default: return super.setProperty(hash, name, value);
412        }
413
414      }
415
416      @Override
417      public Base setProperty(String name, Base value) throws FHIRException {
418        if (name.equals("code")) {
419          this.code = TypeConvertor.castToCodeableReference(value); // CodeableReference
420        } else if (name.equals("strength")) {
421          this.getStrength().add((IngredientSubstanceStrengthComponent) value);
422        } else
423          return super.setProperty(name, value);
424        return value;
425      }
426
427      @Override
428      public Base makeProperty(int hash, String name) throws FHIRException {
429        switch (hash) {
430        case 3059181:  return getCode();
431        case 1791316033:  return addStrength(); 
432        default: return super.makeProperty(hash, name);
433        }
434
435      }
436
437      @Override
438      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
439        switch (hash) {
440        case 3059181: /*code*/ return new String[] {"CodeableReference"};
441        case 1791316033: /*strength*/ return new String[] {};
442        default: return super.getTypesForProperty(hash, name);
443        }
444
445      }
446
447      @Override
448      public Base addChild(String name) throws FHIRException {
449        if (name.equals("code")) {
450          this.code = new CodeableReference();
451          return this.code;
452        }
453        else if (name.equals("strength")) {
454          return addStrength();
455        }
456        else
457          return super.addChild(name);
458      }
459
460      public IngredientSubstanceComponent copy() {
461        IngredientSubstanceComponent dst = new IngredientSubstanceComponent();
462        copyValues(dst);
463        return dst;
464      }
465
466      public void copyValues(IngredientSubstanceComponent dst) {
467        super.copyValues(dst);
468        dst.code = code == null ? null : code.copy();
469        if (strength != null) {
470          dst.strength = new ArrayList<IngredientSubstanceStrengthComponent>();
471          for (IngredientSubstanceStrengthComponent i : strength)
472            dst.strength.add(i.copy());
473        };
474      }
475
476      @Override
477      public boolean equalsDeep(Base other_) {
478        if (!super.equalsDeep(other_))
479          return false;
480        if (!(other_ instanceof IngredientSubstanceComponent))
481          return false;
482        IngredientSubstanceComponent o = (IngredientSubstanceComponent) other_;
483        return compareDeep(code, o.code, true) && compareDeep(strength, o.strength, true);
484      }
485
486      @Override
487      public boolean equalsShallow(Base other_) {
488        if (!super.equalsShallow(other_))
489          return false;
490        if (!(other_ instanceof IngredientSubstanceComponent))
491          return false;
492        IngredientSubstanceComponent o = (IngredientSubstanceComponent) other_;
493        return true;
494      }
495
496      public boolean isEmpty() {
497        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, strength);
498      }
499
500  public String fhirType() {
501    return "Ingredient.substance";
502
503  }
504
505  }
506
507    @Block()
508    public static class IngredientSubstanceStrengthComponent extends BackboneElement implements IBaseBackboneElement {
509        /**
510         * The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.
511         */
512        @Child(name = "presentation", type = {Ratio.class, RatioRange.class, CodeableConcept.class, Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true)
513        @Description(shortDefinition="The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item", formalDefinition="The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item." )
514        protected DataType presentation;
515
516        /**
517         * A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio.
518         */
519        @Child(name = "presentationText", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
520        @Description(shortDefinition="A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio", formalDefinition="A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio." )
521        protected StringType presentationText;
522
523        /**
524         * The strength per unitary volume (or mass).
525         */
526        @Child(name = "concentration", type = {Ratio.class, RatioRange.class, CodeableConcept.class, Quantity.class}, order=3, min=0, max=1, modifier=false, summary=true)
527        @Description(shortDefinition="The strength per unitary volume (or mass)", formalDefinition="The strength per unitary volume (or mass)." )
528        protected DataType concentration;
529
530        /**
531         * A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio.
532         */
533        @Child(name = "concentrationText", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
534        @Description(shortDefinition="A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio", formalDefinition="A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio." )
535        protected StringType concentrationText;
536
537        /**
538         * A code that indicates if the strength is, for example, based on the ingredient substance as stated or on the substance base (when the ingredient is a salt).
539         */
540        @Child(name = "basis", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
541        @Description(shortDefinition="A code that indicates if the strength is, for example, based on the ingredient substance as stated or on the substance base (when the ingredient is a salt)", formalDefinition="A code that indicates if the strength is, for example, based on the ingredient substance as stated or on the substance base (when the ingredient is a salt)." )
542        protected CodeableConcept basis;
543
544        /**
545         * For when strength is measured at a particular point or distance.
546         */
547        @Child(name = "measurementPoint", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
548        @Description(shortDefinition="For when strength is measured at a particular point or distance", formalDefinition="For when strength is measured at a particular point or distance." )
549        protected StringType measurementPoint;
550
551        /**
552         * The country or countries for which the strength range applies.
553         */
554        @Child(name = "country", type = {CodeableConcept.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
555        @Description(shortDefinition="The country or countries for which the strength range applies", formalDefinition="The country or countries for which the strength range applies." )
556        protected List<CodeableConcept> country;
557
558        /**
559         * Strength expressed in terms of a reference substance.
560         */
561        @Child(name = "referenceStrength", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
562        @Description(shortDefinition="Strength expressed in terms of a reference substance", formalDefinition="Strength expressed in terms of a reference substance." )
563        protected List<IngredientSubstanceStrengthReferenceStrengthComponent> referenceStrength;
564
565        private static final long serialVersionUID = 2084203430L;
566
567    /**
568     * Constructor
569     */
570      public IngredientSubstanceStrengthComponent() {
571        super();
572      }
573
574        /**
575         * @return {@link #presentation} (The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.)
576         */
577        public DataType getPresentation() { 
578          return this.presentation;
579        }
580
581        /**
582         * @return {@link #presentation} (The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.)
583         */
584        public Ratio getPresentationRatio() throws FHIRException { 
585          if (this.presentation == null)
586            this.presentation = new Ratio();
587          if (!(this.presentation instanceof Ratio))
588            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.presentation.getClass().getName()+" was encountered");
589          return (Ratio) this.presentation;
590        }
591
592        public boolean hasPresentationRatio() { 
593          return this != null && this.presentation instanceof Ratio;
594        }
595
596        /**
597         * @return {@link #presentation} (The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.)
598         */
599        public RatioRange getPresentationRatioRange() throws FHIRException { 
600          if (this.presentation == null)
601            this.presentation = new RatioRange();
602          if (!(this.presentation instanceof RatioRange))
603            throw new FHIRException("Type mismatch: the type RatioRange was expected, but "+this.presentation.getClass().getName()+" was encountered");
604          return (RatioRange) this.presentation;
605        }
606
607        public boolean hasPresentationRatioRange() { 
608          return this != null && this.presentation instanceof RatioRange;
609        }
610
611        /**
612         * @return {@link #presentation} (The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.)
613         */
614        public CodeableConcept getPresentationCodeableConcept() throws FHIRException { 
615          if (this.presentation == null)
616            this.presentation = new CodeableConcept();
617          if (!(this.presentation instanceof CodeableConcept))
618            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.presentation.getClass().getName()+" was encountered");
619          return (CodeableConcept) this.presentation;
620        }
621
622        public boolean hasPresentationCodeableConcept() { 
623          return this != null && this.presentation instanceof CodeableConcept;
624        }
625
626        /**
627         * @return {@link #presentation} (The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.)
628         */
629        public Quantity getPresentationQuantity() throws FHIRException { 
630          if (this.presentation == null)
631            this.presentation = new Quantity();
632          if (!(this.presentation instanceof Quantity))
633            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.presentation.getClass().getName()+" was encountered");
634          return (Quantity) this.presentation;
635        }
636
637        public boolean hasPresentationQuantity() { 
638          return this != null && this.presentation instanceof Quantity;
639        }
640
641        public boolean hasPresentation() { 
642          return this.presentation != null && !this.presentation.isEmpty();
643        }
644
645        /**
646         * @param value {@link #presentation} (The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.)
647         */
648        public IngredientSubstanceStrengthComponent setPresentation(DataType value) { 
649          if (value != null && !(value instanceof Ratio || value instanceof RatioRange || value instanceof CodeableConcept || value instanceof Quantity))
650            throw new Error("Not the right type for Ingredient.substance.strength.presentation[x]: "+value.fhirType());
651          this.presentation = value;
652          return this;
653        }
654
655        /**
656         * @return {@link #presentationText} (A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio.). This is the underlying object with id, value and extensions. The accessor "getPresentationText" gives direct access to the value
657         */
658        public StringType getPresentationTextElement() { 
659          if (this.presentationText == null)
660            if (Configuration.errorOnAutoCreate())
661              throw new Error("Attempt to auto-create IngredientSubstanceStrengthComponent.presentationText");
662            else if (Configuration.doAutoCreate())
663              this.presentationText = new StringType(); // bb
664          return this.presentationText;
665        }
666
667        public boolean hasPresentationTextElement() { 
668          return this.presentationText != null && !this.presentationText.isEmpty();
669        }
670
671        public boolean hasPresentationText() { 
672          return this.presentationText != null && !this.presentationText.isEmpty();
673        }
674
675        /**
676         * @param value {@link #presentationText} (A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio.). This is the underlying object with id, value and extensions. The accessor "getPresentationText" gives direct access to the value
677         */
678        public IngredientSubstanceStrengthComponent setPresentationTextElement(StringType value) { 
679          this.presentationText = value;
680          return this;
681        }
682
683        /**
684         * @return A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio.
685         */
686        public String getPresentationText() { 
687          return this.presentationText == null ? null : this.presentationText.getValue();
688        }
689
690        /**
691         * @param value A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio.
692         */
693        public IngredientSubstanceStrengthComponent setPresentationText(String value) { 
694          if (Utilities.noString(value))
695            this.presentationText = null;
696          else {
697            if (this.presentationText == null)
698              this.presentationText = new StringType();
699            this.presentationText.setValue(value);
700          }
701          return this;
702        }
703
704        /**
705         * @return {@link #concentration} (The strength per unitary volume (or mass).)
706         */
707        public DataType getConcentration() { 
708          return this.concentration;
709        }
710
711        /**
712         * @return {@link #concentration} (The strength per unitary volume (or mass).)
713         */
714        public Ratio getConcentrationRatio() throws FHIRException { 
715          if (this.concentration == null)
716            this.concentration = new Ratio();
717          if (!(this.concentration instanceof Ratio))
718            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.concentration.getClass().getName()+" was encountered");
719          return (Ratio) this.concentration;
720        }
721
722        public boolean hasConcentrationRatio() { 
723          return this != null && this.concentration instanceof Ratio;
724        }
725
726        /**
727         * @return {@link #concentration} (The strength per unitary volume (or mass).)
728         */
729        public RatioRange getConcentrationRatioRange() throws FHIRException { 
730          if (this.concentration == null)
731            this.concentration = new RatioRange();
732          if (!(this.concentration instanceof RatioRange))
733            throw new FHIRException("Type mismatch: the type RatioRange was expected, but "+this.concentration.getClass().getName()+" was encountered");
734          return (RatioRange) this.concentration;
735        }
736
737        public boolean hasConcentrationRatioRange() { 
738          return this != null && this.concentration instanceof RatioRange;
739        }
740
741        /**
742         * @return {@link #concentration} (The strength per unitary volume (or mass).)
743         */
744        public CodeableConcept getConcentrationCodeableConcept() throws FHIRException { 
745          if (this.concentration == null)
746            this.concentration = new CodeableConcept();
747          if (!(this.concentration instanceof CodeableConcept))
748            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.concentration.getClass().getName()+" was encountered");
749          return (CodeableConcept) this.concentration;
750        }
751
752        public boolean hasConcentrationCodeableConcept() { 
753          return this != null && this.concentration instanceof CodeableConcept;
754        }
755
756        /**
757         * @return {@link #concentration} (The strength per unitary volume (or mass).)
758         */
759        public Quantity getConcentrationQuantity() throws FHIRException { 
760          if (this.concentration == null)
761            this.concentration = new Quantity();
762          if (!(this.concentration instanceof Quantity))
763            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.concentration.getClass().getName()+" was encountered");
764          return (Quantity) this.concentration;
765        }
766
767        public boolean hasConcentrationQuantity() { 
768          return this != null && this.concentration instanceof Quantity;
769        }
770
771        public boolean hasConcentration() { 
772          return this.concentration != null && !this.concentration.isEmpty();
773        }
774
775        /**
776         * @param value {@link #concentration} (The strength per unitary volume (or mass).)
777         */
778        public IngredientSubstanceStrengthComponent setConcentration(DataType value) { 
779          if (value != null && !(value instanceof Ratio || value instanceof RatioRange || value instanceof CodeableConcept || value instanceof Quantity))
780            throw new Error("Not the right type for Ingredient.substance.strength.concentration[x]: "+value.fhirType());
781          this.concentration = value;
782          return this;
783        }
784
785        /**
786         * @return {@link #concentrationText} (A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio.). This is the underlying object with id, value and extensions. The accessor "getConcentrationText" gives direct access to the value
787         */
788        public StringType getConcentrationTextElement() { 
789          if (this.concentrationText == null)
790            if (Configuration.errorOnAutoCreate())
791              throw new Error("Attempt to auto-create IngredientSubstanceStrengthComponent.concentrationText");
792            else if (Configuration.doAutoCreate())
793              this.concentrationText = new StringType(); // bb
794          return this.concentrationText;
795        }
796
797        public boolean hasConcentrationTextElement() { 
798          return this.concentrationText != null && !this.concentrationText.isEmpty();
799        }
800
801        public boolean hasConcentrationText() { 
802          return this.concentrationText != null && !this.concentrationText.isEmpty();
803        }
804
805        /**
806         * @param value {@link #concentrationText} (A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio.). This is the underlying object with id, value and extensions. The accessor "getConcentrationText" gives direct access to the value
807         */
808        public IngredientSubstanceStrengthComponent setConcentrationTextElement(StringType value) { 
809          this.concentrationText = value;
810          return this;
811        }
812
813        /**
814         * @return A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio.
815         */
816        public String getConcentrationText() { 
817          return this.concentrationText == null ? null : this.concentrationText.getValue();
818        }
819
820        /**
821         * @param value A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio.
822         */
823        public IngredientSubstanceStrengthComponent setConcentrationText(String value) { 
824          if (Utilities.noString(value))
825            this.concentrationText = null;
826          else {
827            if (this.concentrationText == null)
828              this.concentrationText = new StringType();
829            this.concentrationText.setValue(value);
830          }
831          return this;
832        }
833
834        /**
835         * @return {@link #basis} (A code that indicates if the strength is, for example, based on the ingredient substance as stated or on the substance base (when the ingredient is a salt).)
836         */
837        public CodeableConcept getBasis() { 
838          if (this.basis == null)
839            if (Configuration.errorOnAutoCreate())
840              throw new Error("Attempt to auto-create IngredientSubstanceStrengthComponent.basis");
841            else if (Configuration.doAutoCreate())
842              this.basis = new CodeableConcept(); // cc
843          return this.basis;
844        }
845
846        public boolean hasBasis() { 
847          return this.basis != null && !this.basis.isEmpty();
848        }
849
850        /**
851         * @param value {@link #basis} (A code that indicates if the strength is, for example, based on the ingredient substance as stated or on the substance base (when the ingredient is a salt).)
852         */
853        public IngredientSubstanceStrengthComponent setBasis(CodeableConcept value) { 
854          this.basis = value;
855          return this;
856        }
857
858        /**
859         * @return {@link #measurementPoint} (For when strength is measured at a particular point or distance.). This is the underlying object with id, value and extensions. The accessor "getMeasurementPoint" gives direct access to the value
860         */
861        public StringType getMeasurementPointElement() { 
862          if (this.measurementPoint == null)
863            if (Configuration.errorOnAutoCreate())
864              throw new Error("Attempt to auto-create IngredientSubstanceStrengthComponent.measurementPoint");
865            else if (Configuration.doAutoCreate())
866              this.measurementPoint = new StringType(); // bb
867          return this.measurementPoint;
868        }
869
870        public boolean hasMeasurementPointElement() { 
871          return this.measurementPoint != null && !this.measurementPoint.isEmpty();
872        }
873
874        public boolean hasMeasurementPoint() { 
875          return this.measurementPoint != null && !this.measurementPoint.isEmpty();
876        }
877
878        /**
879         * @param value {@link #measurementPoint} (For when strength is measured at a particular point or distance.). This is the underlying object with id, value and extensions. The accessor "getMeasurementPoint" gives direct access to the value
880         */
881        public IngredientSubstanceStrengthComponent setMeasurementPointElement(StringType value) { 
882          this.measurementPoint = value;
883          return this;
884        }
885
886        /**
887         * @return For when strength is measured at a particular point or distance.
888         */
889        public String getMeasurementPoint() { 
890          return this.measurementPoint == null ? null : this.measurementPoint.getValue();
891        }
892
893        /**
894         * @param value For when strength is measured at a particular point or distance.
895         */
896        public IngredientSubstanceStrengthComponent setMeasurementPoint(String value) { 
897          if (Utilities.noString(value))
898            this.measurementPoint = null;
899          else {
900            if (this.measurementPoint == null)
901              this.measurementPoint = new StringType();
902            this.measurementPoint.setValue(value);
903          }
904          return this;
905        }
906
907        /**
908         * @return {@link #country} (The country or countries for which the strength range applies.)
909         */
910        public List<CodeableConcept> getCountry() { 
911          if (this.country == null)
912            this.country = new ArrayList<CodeableConcept>();
913          return this.country;
914        }
915
916        /**
917         * @return Returns a reference to <code>this</code> for easy method chaining
918         */
919        public IngredientSubstanceStrengthComponent setCountry(List<CodeableConcept> theCountry) { 
920          this.country = theCountry;
921          return this;
922        }
923
924        public boolean hasCountry() { 
925          if (this.country == null)
926            return false;
927          for (CodeableConcept item : this.country)
928            if (!item.isEmpty())
929              return true;
930          return false;
931        }
932
933        public CodeableConcept addCountry() { //3
934          CodeableConcept t = new CodeableConcept();
935          if (this.country == null)
936            this.country = new ArrayList<CodeableConcept>();
937          this.country.add(t);
938          return t;
939        }
940
941        public IngredientSubstanceStrengthComponent addCountry(CodeableConcept t) { //3
942          if (t == null)
943            return this;
944          if (this.country == null)
945            this.country = new ArrayList<CodeableConcept>();
946          this.country.add(t);
947          return this;
948        }
949
950        /**
951         * @return The first repetition of repeating field {@link #country}, creating it if it does not already exist {3}
952         */
953        public CodeableConcept getCountryFirstRep() { 
954          if (getCountry().isEmpty()) {
955            addCountry();
956          }
957          return getCountry().get(0);
958        }
959
960        /**
961         * @return {@link #referenceStrength} (Strength expressed in terms of a reference substance.)
962         */
963        public List<IngredientSubstanceStrengthReferenceStrengthComponent> getReferenceStrength() { 
964          if (this.referenceStrength == null)
965            this.referenceStrength = new ArrayList<IngredientSubstanceStrengthReferenceStrengthComponent>();
966          return this.referenceStrength;
967        }
968
969        /**
970         * @return Returns a reference to <code>this</code> for easy method chaining
971         */
972        public IngredientSubstanceStrengthComponent setReferenceStrength(List<IngredientSubstanceStrengthReferenceStrengthComponent> theReferenceStrength) { 
973          this.referenceStrength = theReferenceStrength;
974          return this;
975        }
976
977        public boolean hasReferenceStrength() { 
978          if (this.referenceStrength == null)
979            return false;
980          for (IngredientSubstanceStrengthReferenceStrengthComponent item : this.referenceStrength)
981            if (!item.isEmpty())
982              return true;
983          return false;
984        }
985
986        public IngredientSubstanceStrengthReferenceStrengthComponent addReferenceStrength() { //3
987          IngredientSubstanceStrengthReferenceStrengthComponent t = new IngredientSubstanceStrengthReferenceStrengthComponent();
988          if (this.referenceStrength == null)
989            this.referenceStrength = new ArrayList<IngredientSubstanceStrengthReferenceStrengthComponent>();
990          this.referenceStrength.add(t);
991          return t;
992        }
993
994        public IngredientSubstanceStrengthComponent addReferenceStrength(IngredientSubstanceStrengthReferenceStrengthComponent t) { //3
995          if (t == null)
996            return this;
997          if (this.referenceStrength == null)
998            this.referenceStrength = new ArrayList<IngredientSubstanceStrengthReferenceStrengthComponent>();
999          this.referenceStrength.add(t);
1000          return this;
1001        }
1002
1003        /**
1004         * @return The first repetition of repeating field {@link #referenceStrength}, creating it if it does not already exist {3}
1005         */
1006        public IngredientSubstanceStrengthReferenceStrengthComponent getReferenceStrengthFirstRep() { 
1007          if (getReferenceStrength().isEmpty()) {
1008            addReferenceStrength();
1009          }
1010          return getReferenceStrength().get(0);
1011        }
1012
1013        protected void listChildren(List<Property> children) {
1014          super.listChildren(children);
1015          children.add(new Property("presentation[x]", "Ratio|RatioRange|CodeableConcept|Quantity", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, 1, presentation));
1016          children.add(new Property("presentationText", "string", "A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio.", 0, 1, presentationText));
1017          children.add(new Property("concentration[x]", "Ratio|RatioRange|CodeableConcept|Quantity", "The strength per unitary volume (or mass).", 0, 1, concentration));
1018          children.add(new Property("concentrationText", "string", "A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio.", 0, 1, concentrationText));
1019          children.add(new Property("basis", "CodeableConcept", "A code that indicates if the strength is, for example, based on the ingredient substance as stated or on the substance base (when the ingredient is a salt).", 0, 1, basis));
1020          children.add(new Property("measurementPoint", "string", "For when strength is measured at a particular point or distance.", 0, 1, measurementPoint));
1021          children.add(new Property("country", "CodeableConcept", "The country or countries for which the strength range applies.", 0, java.lang.Integer.MAX_VALUE, country));
1022          children.add(new Property("referenceStrength", "", "Strength expressed in terms of a reference substance.", 0, java.lang.Integer.MAX_VALUE, referenceStrength));
1023        }
1024
1025        @Override
1026        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1027          switch (_hash) {
1028          case 1714280230: /*presentation[x]*/  return new Property("presentation[x]", "Ratio|RatioRange|CodeableConcept|Quantity", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, 1, presentation);
1029          case 696975130: /*presentation*/  return new Property("presentation[x]", "Ratio|RatioRange|CodeableConcept|Quantity", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, 1, presentation);
1030          case -1853112047: /*presentationRatio*/  return new Property("presentation[x]", "Ratio", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, 1, presentation);
1031          case 643336876: /*presentationRatioRange*/  return new Property("presentation[x]", "RatioRange", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, 1, presentation);
1032          case 1095127335: /*presentationCodeableConcept*/  return new Property("presentation[x]", "CodeableConcept", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, 1, presentation);
1033          case -263057979: /*presentationQuantity*/  return new Property("presentation[x]", "Quantity", "The quantity of substance in the unit of presentation, or in the volume (or mass) of the single pharmaceutical product or manufactured item.", 0, 1, presentation);
1034          case 1602853735: /*presentationText*/  return new Property("presentationText", "string", "A textual represention of either the whole of the presentation strength or a part of it - with the rest being in Strength.presentation as a ratio.", 0, 1, presentationText);
1035          case 1153502451: /*concentration[x]*/  return new Property("concentration[x]", "Ratio|RatioRange|CodeableConcept|Quantity", "The strength per unitary volume (or mass).", 0, 1, concentration);
1036          case -410557331: /*concentration*/  return new Property("concentration[x]", "Ratio|RatioRange|CodeableConcept|Quantity", "The strength per unitary volume (or mass).", 0, 1, concentration);
1037          case 405321630: /*concentrationRatio*/  return new Property("concentration[x]", "Ratio", "The strength per unitary volume (or mass).", 0, 1, concentration);
1038          case 436249663: /*concentrationRatioRange*/  return new Property("concentration[x]", "RatioRange", "The strength per unitary volume (or mass).", 0, 1, concentration);
1039          case -90293388: /*concentrationCodeableConcept*/  return new Property("concentration[x]", "CodeableConcept", "The strength per unitary volume (or mass).", 0, 1, concentration);
1040          case 71921688: /*concentrationQuantity*/  return new Property("concentration[x]", "Quantity", "The strength per unitary volume (or mass).", 0, 1, concentration);
1041          case 1398611770: /*concentrationText*/  return new Property("concentrationText", "string", "A textual represention of either the whole of the concentration strength or a part of it - with the rest being in Strength.concentration as a ratio.", 0, 1, concentrationText);
1042          case 93508670: /*basis*/  return new Property("basis", "CodeableConcept", "A code that indicates if the strength is, for example, based on the ingredient substance as stated or on the substance base (when the ingredient is a salt).", 0, 1, basis);
1043          case 235437876: /*measurementPoint*/  return new Property("measurementPoint", "string", "For when strength is measured at a particular point or distance.", 0, 1, measurementPoint);
1044          case 957831062: /*country*/  return new Property("country", "CodeableConcept", "The country or countries for which the strength range applies.", 0, java.lang.Integer.MAX_VALUE, country);
1045          case 1943566508: /*referenceStrength*/  return new Property("referenceStrength", "", "Strength expressed in terms of a reference substance.", 0, java.lang.Integer.MAX_VALUE, referenceStrength);
1046          default: return super.getNamedProperty(_hash, _name, _checkValid);
1047          }
1048
1049        }
1050
1051      @Override
1052      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1053        switch (hash) {
1054        case 696975130: /*presentation*/ return this.presentation == null ? new Base[0] : new Base[] {this.presentation}; // DataType
1055        case 1602853735: /*presentationText*/ return this.presentationText == null ? new Base[0] : new Base[] {this.presentationText}; // StringType
1056        case -410557331: /*concentration*/ return this.concentration == null ? new Base[0] : new Base[] {this.concentration}; // DataType
1057        case 1398611770: /*concentrationText*/ return this.concentrationText == null ? new Base[0] : new Base[] {this.concentrationText}; // StringType
1058        case 93508670: /*basis*/ return this.basis == null ? new Base[0] : new Base[] {this.basis}; // CodeableConcept
1059        case 235437876: /*measurementPoint*/ return this.measurementPoint == null ? new Base[0] : new Base[] {this.measurementPoint}; // StringType
1060        case 957831062: /*country*/ return this.country == null ? new Base[0] : this.country.toArray(new Base[this.country.size()]); // CodeableConcept
1061        case 1943566508: /*referenceStrength*/ return this.referenceStrength == null ? new Base[0] : this.referenceStrength.toArray(new Base[this.referenceStrength.size()]); // IngredientSubstanceStrengthReferenceStrengthComponent
1062        default: return super.getProperty(hash, name, checkValid);
1063        }
1064
1065      }
1066
1067      @Override
1068      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1069        switch (hash) {
1070        case 696975130: // presentation
1071          this.presentation = TypeConvertor.castToType(value); // DataType
1072          return value;
1073        case 1602853735: // presentationText
1074          this.presentationText = TypeConvertor.castToString(value); // StringType
1075          return value;
1076        case -410557331: // concentration
1077          this.concentration = TypeConvertor.castToType(value); // DataType
1078          return value;
1079        case 1398611770: // concentrationText
1080          this.concentrationText = TypeConvertor.castToString(value); // StringType
1081          return value;
1082        case 93508670: // basis
1083          this.basis = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1084          return value;
1085        case 235437876: // measurementPoint
1086          this.measurementPoint = TypeConvertor.castToString(value); // StringType
1087          return value;
1088        case 957831062: // country
1089          this.getCountry().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1090          return value;
1091        case 1943566508: // referenceStrength
1092          this.getReferenceStrength().add((IngredientSubstanceStrengthReferenceStrengthComponent) value); // IngredientSubstanceStrengthReferenceStrengthComponent
1093          return value;
1094        default: return super.setProperty(hash, name, value);
1095        }
1096
1097      }
1098
1099      @Override
1100      public Base setProperty(String name, Base value) throws FHIRException {
1101        if (name.equals("presentation[x]")) {
1102          this.presentation = TypeConvertor.castToType(value); // DataType
1103        } else if (name.equals("presentationText")) {
1104          this.presentationText = TypeConvertor.castToString(value); // StringType
1105        } else if (name.equals("concentration[x]")) {
1106          this.concentration = TypeConvertor.castToType(value); // DataType
1107        } else if (name.equals("concentrationText")) {
1108          this.concentrationText = TypeConvertor.castToString(value); // StringType
1109        } else if (name.equals("basis")) {
1110          this.basis = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
1111        } else if (name.equals("measurementPoint")) {
1112          this.measurementPoint = TypeConvertor.castToString(value); // StringType
1113        } else if (name.equals("country")) {
1114          this.getCountry().add(TypeConvertor.castToCodeableConcept(value));
1115        } else if (name.equals("referenceStrength")) {
1116          this.getReferenceStrength().add((IngredientSubstanceStrengthReferenceStrengthComponent) value);
1117        } else
1118          return super.setProperty(name, value);
1119        return value;
1120      }
1121
1122      @Override
1123      public Base makeProperty(int hash, String name) throws FHIRException {
1124        switch (hash) {
1125        case 1714280230:  return getPresentation();
1126        case 696975130:  return getPresentation();
1127        case 1602853735:  return getPresentationTextElement();
1128        case 1153502451:  return getConcentration();
1129        case -410557331:  return getConcentration();
1130        case 1398611770:  return getConcentrationTextElement();
1131        case 93508670:  return getBasis();
1132        case 235437876:  return getMeasurementPointElement();
1133        case 957831062:  return addCountry(); 
1134        case 1943566508:  return addReferenceStrength(); 
1135        default: return super.makeProperty(hash, name);
1136        }
1137
1138      }
1139
1140      @Override
1141      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1142        switch (hash) {
1143        case 696975130: /*presentation*/ return new String[] {"Ratio", "RatioRange", "CodeableConcept", "Quantity"};
1144        case 1602853735: /*presentationText*/ return new String[] {"string"};
1145        case -410557331: /*concentration*/ return new String[] {"Ratio", "RatioRange", "CodeableConcept", "Quantity"};
1146        case 1398611770: /*concentrationText*/ return new String[] {"string"};
1147        case 93508670: /*basis*/ return new String[] {"CodeableConcept"};
1148        case 235437876: /*measurementPoint*/ return new String[] {"string"};
1149        case 957831062: /*country*/ return new String[] {"CodeableConcept"};
1150        case 1943566508: /*referenceStrength*/ return new String[] {};
1151        default: return super.getTypesForProperty(hash, name);
1152        }
1153
1154      }
1155
1156      @Override
1157      public Base addChild(String name) throws FHIRException {
1158        if (name.equals("presentationRatio")) {
1159          this.presentation = new Ratio();
1160          return this.presentation;
1161        }
1162        else if (name.equals("presentationRatioRange")) {
1163          this.presentation = new RatioRange();
1164          return this.presentation;
1165        }
1166        else if (name.equals("presentationCodeableConcept")) {
1167          this.presentation = new CodeableConcept();
1168          return this.presentation;
1169        }
1170        else if (name.equals("presentationQuantity")) {
1171          this.presentation = new Quantity();
1172          return this.presentation;
1173        }
1174        else if (name.equals("presentationText")) {
1175          throw new FHIRException("Cannot call addChild on a primitive type Ingredient.substance.strength.presentationText");
1176        }
1177        else if (name.equals("concentrationRatio")) {
1178          this.concentration = new Ratio();
1179          return this.concentration;
1180        }
1181        else if (name.equals("concentrationRatioRange")) {
1182          this.concentration = new RatioRange();
1183          return this.concentration;
1184        }
1185        else if (name.equals("concentrationCodeableConcept")) {
1186          this.concentration = new CodeableConcept();
1187          return this.concentration;
1188        }
1189        else if (name.equals("concentrationQuantity")) {
1190          this.concentration = new Quantity();
1191          return this.concentration;
1192        }
1193        else if (name.equals("concentrationText")) {
1194          throw new FHIRException("Cannot call addChild on a primitive type Ingredient.substance.strength.concentrationText");
1195        }
1196        else if (name.equals("basis")) {
1197          this.basis = new CodeableConcept();
1198          return this.basis;
1199        }
1200        else if (name.equals("measurementPoint")) {
1201          throw new FHIRException("Cannot call addChild on a primitive type Ingredient.substance.strength.measurementPoint");
1202        }
1203        else if (name.equals("country")) {
1204          return addCountry();
1205        }
1206        else if (name.equals("referenceStrength")) {
1207          return addReferenceStrength();
1208        }
1209        else
1210          return super.addChild(name);
1211      }
1212
1213      public IngredientSubstanceStrengthComponent copy() {
1214        IngredientSubstanceStrengthComponent dst = new IngredientSubstanceStrengthComponent();
1215        copyValues(dst);
1216        return dst;
1217      }
1218
1219      public void copyValues(IngredientSubstanceStrengthComponent dst) {
1220        super.copyValues(dst);
1221        dst.presentation = presentation == null ? null : presentation.copy();
1222        dst.presentationText = presentationText == null ? null : presentationText.copy();
1223        dst.concentration = concentration == null ? null : concentration.copy();
1224        dst.concentrationText = concentrationText == null ? null : concentrationText.copy();
1225        dst.basis = basis == null ? null : basis.copy();
1226        dst.measurementPoint = measurementPoint == null ? null : measurementPoint.copy();
1227        if (country != null) {
1228          dst.country = new ArrayList<CodeableConcept>();
1229          for (CodeableConcept i : country)
1230            dst.country.add(i.copy());
1231        };
1232        if (referenceStrength != null) {
1233          dst.referenceStrength = new ArrayList<IngredientSubstanceStrengthReferenceStrengthComponent>();
1234          for (IngredientSubstanceStrengthReferenceStrengthComponent i : referenceStrength)
1235            dst.referenceStrength.add(i.copy());
1236        };
1237      }
1238
1239      @Override
1240      public boolean equalsDeep(Base other_) {
1241        if (!super.equalsDeep(other_))
1242          return false;
1243        if (!(other_ instanceof IngredientSubstanceStrengthComponent))
1244          return false;
1245        IngredientSubstanceStrengthComponent o = (IngredientSubstanceStrengthComponent) other_;
1246        return compareDeep(presentation, o.presentation, true) && compareDeep(presentationText, o.presentationText, true)
1247           && compareDeep(concentration, o.concentration, true) && compareDeep(concentrationText, o.concentrationText, true)
1248           && compareDeep(basis, o.basis, true) && compareDeep(measurementPoint, o.measurementPoint, true)
1249           && compareDeep(country, o.country, true) && compareDeep(referenceStrength, o.referenceStrength, true)
1250          ;
1251      }
1252
1253      @Override
1254      public boolean equalsShallow(Base other_) {
1255        if (!super.equalsShallow(other_))
1256          return false;
1257        if (!(other_ instanceof IngredientSubstanceStrengthComponent))
1258          return false;
1259        IngredientSubstanceStrengthComponent o = (IngredientSubstanceStrengthComponent) other_;
1260        return compareValues(presentationText, o.presentationText, true) && compareValues(concentrationText, o.concentrationText, true)
1261           && compareValues(measurementPoint, o.measurementPoint, true);
1262      }
1263
1264      public boolean isEmpty() {
1265        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(presentation, presentationText
1266          , concentration, concentrationText, basis, measurementPoint, country, referenceStrength
1267          );
1268      }
1269
1270  public String fhirType() {
1271    return "Ingredient.substance.strength";
1272
1273  }
1274
1275  }
1276
1277    @Block()
1278    public static class IngredientSubstanceStrengthReferenceStrengthComponent extends BackboneElement implements IBaseBackboneElement {
1279        /**
1280         * Relevant reference substance.
1281         */
1282        @Child(name = "substance", type = {CodeableReference.class}, order=1, min=0, max=1, modifier=false, summary=true)
1283        @Description(shortDefinition="Relevant reference substance", formalDefinition="Relevant reference substance." )
1284        protected CodeableReference substance;
1285
1286        /**
1287         * Strength expressed in terms of a reference substance.
1288         */
1289        @Child(name = "strength", type = {Ratio.class, RatioRange.class, Quantity.class}, order=2, min=1, max=1, modifier=false, summary=true)
1290        @Description(shortDefinition="Strength expressed in terms of a reference substance", formalDefinition="Strength expressed in terms of a reference substance." )
1291        protected DataType strength;
1292
1293        /**
1294         * For when strength is measured at a particular point or distance.
1295         */
1296        @Child(name = "measurementPoint", type = {StringType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1297        @Description(shortDefinition="For when strength is measured at a particular point or distance", formalDefinition="For when strength is measured at a particular point or distance." )
1298        protected StringType measurementPoint;
1299
1300        /**
1301         * The country or countries for which the strength range applies.
1302         */
1303        @Child(name = "country", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1304        @Description(shortDefinition="The country or countries for which the strength range applies", formalDefinition="The country or countries for which the strength range applies." )
1305        protected List<CodeableConcept> country;
1306
1307        private static final long serialVersionUID = 1700529245L;
1308
1309    /**
1310     * Constructor
1311     */
1312      public IngredientSubstanceStrengthReferenceStrengthComponent() {
1313        super();
1314      }
1315
1316    /**
1317     * Constructor
1318     */
1319      public IngredientSubstanceStrengthReferenceStrengthComponent(DataType strength) {
1320        super();
1321        this.setStrength(strength);
1322      }
1323
1324        /**
1325         * @return {@link #substance} (Relevant reference substance.)
1326         */
1327        public CodeableReference getSubstance() { 
1328          if (this.substance == null)
1329            if (Configuration.errorOnAutoCreate())
1330              throw new Error("Attempt to auto-create IngredientSubstanceStrengthReferenceStrengthComponent.substance");
1331            else if (Configuration.doAutoCreate())
1332              this.substance = new CodeableReference(); // cc
1333          return this.substance;
1334        }
1335
1336        public boolean hasSubstance() { 
1337          return this.substance != null && !this.substance.isEmpty();
1338        }
1339
1340        /**
1341         * @param value {@link #substance} (Relevant reference substance.)
1342         */
1343        public IngredientSubstanceStrengthReferenceStrengthComponent setSubstance(CodeableReference value) { 
1344          this.substance = value;
1345          return this;
1346        }
1347
1348        /**
1349         * @return {@link #strength} (Strength expressed in terms of a reference substance.)
1350         */
1351        public DataType getStrength() { 
1352          return this.strength;
1353        }
1354
1355        /**
1356         * @return {@link #strength} (Strength expressed in terms of a reference substance.)
1357         */
1358        public Ratio getStrengthRatio() throws FHIRException { 
1359          if (this.strength == null)
1360            this.strength = new Ratio();
1361          if (!(this.strength instanceof Ratio))
1362            throw new FHIRException("Type mismatch: the type Ratio was expected, but "+this.strength.getClass().getName()+" was encountered");
1363          return (Ratio) this.strength;
1364        }
1365
1366        public boolean hasStrengthRatio() { 
1367          return this != null && this.strength instanceof Ratio;
1368        }
1369
1370        /**
1371         * @return {@link #strength} (Strength expressed in terms of a reference substance.)
1372         */
1373        public RatioRange getStrengthRatioRange() throws FHIRException { 
1374          if (this.strength == null)
1375            this.strength = new RatioRange();
1376          if (!(this.strength instanceof RatioRange))
1377            throw new FHIRException("Type mismatch: the type RatioRange was expected, but "+this.strength.getClass().getName()+" was encountered");
1378          return (RatioRange) this.strength;
1379        }
1380
1381        public boolean hasStrengthRatioRange() { 
1382          return this != null && this.strength instanceof RatioRange;
1383        }
1384
1385        /**
1386         * @return {@link #strength} (Strength expressed in terms of a reference substance.)
1387         */
1388        public Quantity getStrengthQuantity() throws FHIRException { 
1389          if (this.strength == null)
1390            this.strength = new Quantity();
1391          if (!(this.strength instanceof Quantity))
1392            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.strength.getClass().getName()+" was encountered");
1393          return (Quantity) this.strength;
1394        }
1395
1396        public boolean hasStrengthQuantity() { 
1397          return this != null && this.strength instanceof Quantity;
1398        }
1399
1400        public boolean hasStrength() { 
1401          return this.strength != null && !this.strength.isEmpty();
1402        }
1403
1404        /**
1405         * @param value {@link #strength} (Strength expressed in terms of a reference substance.)
1406         */
1407        public IngredientSubstanceStrengthReferenceStrengthComponent setStrength(DataType value) { 
1408          if (value != null && !(value instanceof Ratio || value instanceof RatioRange || value instanceof Quantity))
1409            throw new Error("Not the right type for Ingredient.substance.strength.referenceStrength.strength[x]: "+value.fhirType());
1410          this.strength = value;
1411          return this;
1412        }
1413
1414        /**
1415         * @return {@link #measurementPoint} (For when strength is measured at a particular point or distance.). This is the underlying object with id, value and extensions. The accessor "getMeasurementPoint" gives direct access to the value
1416         */
1417        public StringType getMeasurementPointElement() { 
1418          if (this.measurementPoint == null)
1419            if (Configuration.errorOnAutoCreate())
1420              throw new Error("Attempt to auto-create IngredientSubstanceStrengthReferenceStrengthComponent.measurementPoint");
1421            else if (Configuration.doAutoCreate())
1422              this.measurementPoint = new StringType(); // bb
1423          return this.measurementPoint;
1424        }
1425
1426        public boolean hasMeasurementPointElement() { 
1427          return this.measurementPoint != null && !this.measurementPoint.isEmpty();
1428        }
1429
1430        public boolean hasMeasurementPoint() { 
1431          return this.measurementPoint != null && !this.measurementPoint.isEmpty();
1432        }
1433
1434        /**
1435         * @param value {@link #measurementPoint} (For when strength is measured at a particular point or distance.). This is the underlying object with id, value and extensions. The accessor "getMeasurementPoint" gives direct access to the value
1436         */
1437        public IngredientSubstanceStrengthReferenceStrengthComponent setMeasurementPointElement(StringType value) { 
1438          this.measurementPoint = value;
1439          return this;
1440        }
1441
1442        /**
1443         * @return For when strength is measured at a particular point or distance.
1444         */
1445        public String getMeasurementPoint() { 
1446          return this.measurementPoint == null ? null : this.measurementPoint.getValue();
1447        }
1448
1449        /**
1450         * @param value For when strength is measured at a particular point or distance.
1451         */
1452        public IngredientSubstanceStrengthReferenceStrengthComponent setMeasurementPoint(String value) { 
1453          if (Utilities.noString(value))
1454            this.measurementPoint = null;
1455          else {
1456            if (this.measurementPoint == null)
1457              this.measurementPoint = new StringType();
1458            this.measurementPoint.setValue(value);
1459          }
1460          return this;
1461        }
1462
1463        /**
1464         * @return {@link #country} (The country or countries for which the strength range applies.)
1465         */
1466        public List<CodeableConcept> getCountry() { 
1467          if (this.country == null)
1468            this.country = new ArrayList<CodeableConcept>();
1469          return this.country;
1470        }
1471
1472        /**
1473         * @return Returns a reference to <code>this</code> for easy method chaining
1474         */
1475        public IngredientSubstanceStrengthReferenceStrengthComponent setCountry(List<CodeableConcept> theCountry) { 
1476          this.country = theCountry;
1477          return this;
1478        }
1479
1480        public boolean hasCountry() { 
1481          if (this.country == null)
1482            return false;
1483          for (CodeableConcept item : this.country)
1484            if (!item.isEmpty())
1485              return true;
1486          return false;
1487        }
1488
1489        public CodeableConcept addCountry() { //3
1490          CodeableConcept t = new CodeableConcept();
1491          if (this.country == null)
1492            this.country = new ArrayList<CodeableConcept>();
1493          this.country.add(t);
1494          return t;
1495        }
1496
1497        public IngredientSubstanceStrengthReferenceStrengthComponent addCountry(CodeableConcept t) { //3
1498          if (t == null)
1499            return this;
1500          if (this.country == null)
1501            this.country = new ArrayList<CodeableConcept>();
1502          this.country.add(t);
1503          return this;
1504        }
1505
1506        /**
1507         * @return The first repetition of repeating field {@link #country}, creating it if it does not already exist {3}
1508         */
1509        public CodeableConcept getCountryFirstRep() { 
1510          if (getCountry().isEmpty()) {
1511            addCountry();
1512          }
1513          return getCountry().get(0);
1514        }
1515
1516        protected void listChildren(List<Property> children) {
1517          super.listChildren(children);
1518          children.add(new Property("substance", "CodeableReference(SubstanceDefinition)", "Relevant reference substance.", 0, 1, substance));
1519          children.add(new Property("strength[x]", "Ratio|RatioRange|Quantity", "Strength expressed in terms of a reference substance.", 0, 1, strength));
1520          children.add(new Property("measurementPoint", "string", "For when strength is measured at a particular point or distance.", 0, 1, measurementPoint));
1521          children.add(new Property("country", "CodeableConcept", "The country or countries for which the strength range applies.", 0, java.lang.Integer.MAX_VALUE, country));
1522        }
1523
1524        @Override
1525        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1526          switch (_hash) {
1527          case 530040176: /*substance*/  return new Property("substance", "CodeableReference(SubstanceDefinition)", "Relevant reference substance.", 0, 1, substance);
1528          case 127377567: /*strength[x]*/  return new Property("strength[x]", "Ratio|RatioRange|Quantity", "Strength expressed in terms of a reference substance.", 0, 1, strength);
1529          case 1791316033: /*strength*/  return new Property("strength[x]", "Ratio|RatioRange|Quantity", "Strength expressed in terms of a reference substance.", 0, 1, strength);
1530          case 2141786186: /*strengthRatio*/  return new Property("strength[x]", "Ratio", "Strength expressed in terms of a reference substance.", 0, 1, strength);
1531          case -1300703469: /*strengthRatioRange*/  return new Property("strength[x]", "RatioRange", "Strength expressed in terms of a reference substance.", 0, 1, strength);
1532          case -1793570836: /*strengthQuantity*/  return new Property("strength[x]", "Quantity", "Strength expressed in terms of a reference substance.", 0, 1, strength);
1533          case 235437876: /*measurementPoint*/  return new Property("measurementPoint", "string", "For when strength is measured at a particular point or distance.", 0, 1, measurementPoint);
1534          case 957831062: /*country*/  return new Property("country", "CodeableConcept", "The country or countries for which the strength range applies.", 0, java.lang.Integer.MAX_VALUE, country);
1535          default: return super.getNamedProperty(_hash, _name, _checkValid);
1536          }
1537
1538        }
1539
1540      @Override
1541      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1542        switch (hash) {
1543        case 530040176: /*substance*/ return this.substance == null ? new Base[0] : new Base[] {this.substance}; // CodeableReference
1544        case 1791316033: /*strength*/ return this.strength == null ? new Base[0] : new Base[] {this.strength}; // DataType
1545        case 235437876: /*measurementPoint*/ return this.measurementPoint == null ? new Base[0] : new Base[] {this.measurementPoint}; // StringType
1546        case 957831062: /*country*/ return this.country == null ? new Base[0] : this.country.toArray(new Base[this.country.size()]); // CodeableConcept
1547        default: return super.getProperty(hash, name, checkValid);
1548        }
1549
1550      }
1551
1552      @Override
1553      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1554        switch (hash) {
1555        case 530040176: // substance
1556          this.substance = TypeConvertor.castToCodeableReference(value); // CodeableReference
1557          return value;
1558        case 1791316033: // strength
1559          this.strength = TypeConvertor.castToType(value); // DataType
1560          return value;
1561        case 235437876: // measurementPoint
1562          this.measurementPoint = TypeConvertor.castToString(value); // StringType
1563          return value;
1564        case 957831062: // country
1565          this.getCountry().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
1566          return value;
1567        default: return super.setProperty(hash, name, value);
1568        }
1569
1570      }
1571
1572      @Override
1573      public Base setProperty(String name, Base value) throws FHIRException {
1574        if (name.equals("substance")) {
1575          this.substance = TypeConvertor.castToCodeableReference(value); // CodeableReference
1576        } else if (name.equals("strength[x]")) {
1577          this.strength = TypeConvertor.castToType(value); // DataType
1578        } else if (name.equals("measurementPoint")) {
1579          this.measurementPoint = TypeConvertor.castToString(value); // StringType
1580        } else if (name.equals("country")) {
1581          this.getCountry().add(TypeConvertor.castToCodeableConcept(value));
1582        } else
1583          return super.setProperty(name, value);
1584        return value;
1585      }
1586
1587      @Override
1588      public Base makeProperty(int hash, String name) throws FHIRException {
1589        switch (hash) {
1590        case 530040176:  return getSubstance();
1591        case 127377567:  return getStrength();
1592        case 1791316033:  return getStrength();
1593        case 235437876:  return getMeasurementPointElement();
1594        case 957831062:  return addCountry(); 
1595        default: return super.makeProperty(hash, name);
1596        }
1597
1598      }
1599
1600      @Override
1601      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1602        switch (hash) {
1603        case 530040176: /*substance*/ return new String[] {"CodeableReference"};
1604        case 1791316033: /*strength*/ return new String[] {"Ratio", "RatioRange", "Quantity"};
1605        case 235437876: /*measurementPoint*/ return new String[] {"string"};
1606        case 957831062: /*country*/ return new String[] {"CodeableConcept"};
1607        default: return super.getTypesForProperty(hash, name);
1608        }
1609
1610      }
1611
1612      @Override
1613      public Base addChild(String name) throws FHIRException {
1614        if (name.equals("substance")) {
1615          this.substance = new CodeableReference();
1616          return this.substance;
1617        }
1618        else if (name.equals("strengthRatio")) {
1619          this.strength = new Ratio();
1620          return this.strength;
1621        }
1622        else if (name.equals("strengthRatioRange")) {
1623          this.strength = new RatioRange();
1624          return this.strength;
1625        }
1626        else if (name.equals("strengthQuantity")) {
1627          this.strength = new Quantity();
1628          return this.strength;
1629        }
1630        else if (name.equals("measurementPoint")) {
1631          throw new FHIRException("Cannot call addChild on a primitive type Ingredient.substance.strength.referenceStrength.measurementPoint");
1632        }
1633        else if (name.equals("country")) {
1634          return addCountry();
1635        }
1636        else
1637          return super.addChild(name);
1638      }
1639
1640      public IngredientSubstanceStrengthReferenceStrengthComponent copy() {
1641        IngredientSubstanceStrengthReferenceStrengthComponent dst = new IngredientSubstanceStrengthReferenceStrengthComponent();
1642        copyValues(dst);
1643        return dst;
1644      }
1645
1646      public void copyValues(IngredientSubstanceStrengthReferenceStrengthComponent dst) {
1647        super.copyValues(dst);
1648        dst.substance = substance == null ? null : substance.copy();
1649        dst.strength = strength == null ? null : strength.copy();
1650        dst.measurementPoint = measurementPoint == null ? null : measurementPoint.copy();
1651        if (country != null) {
1652          dst.country = new ArrayList<CodeableConcept>();
1653          for (CodeableConcept i : country)
1654            dst.country.add(i.copy());
1655        };
1656      }
1657
1658      @Override
1659      public boolean equalsDeep(Base other_) {
1660        if (!super.equalsDeep(other_))
1661          return false;
1662        if (!(other_ instanceof IngredientSubstanceStrengthReferenceStrengthComponent))
1663          return false;
1664        IngredientSubstanceStrengthReferenceStrengthComponent o = (IngredientSubstanceStrengthReferenceStrengthComponent) other_;
1665        return compareDeep(substance, o.substance, true) && compareDeep(strength, o.strength, true) && compareDeep(measurementPoint, o.measurementPoint, true)
1666           && compareDeep(country, o.country, true);
1667      }
1668
1669      @Override
1670      public boolean equalsShallow(Base other_) {
1671        if (!super.equalsShallow(other_))
1672          return false;
1673        if (!(other_ instanceof IngredientSubstanceStrengthReferenceStrengthComponent))
1674          return false;
1675        IngredientSubstanceStrengthReferenceStrengthComponent o = (IngredientSubstanceStrengthReferenceStrengthComponent) other_;
1676        return compareValues(measurementPoint, o.measurementPoint, true);
1677      }
1678
1679      public boolean isEmpty() {
1680        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(substance, strength, measurementPoint
1681          , country);
1682      }
1683
1684  public String fhirType() {
1685    return "Ingredient.substance.strength.referenceStrength";
1686
1687  }
1688
1689  }
1690
1691    /**
1692     * The identifier(s) of this Ingredient that are assigned by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate.
1693     */
1694    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=1, modifier=false, summary=true)
1695    @Description(shortDefinition="An identifier or code by which the ingredient can be referenced", formalDefinition="The identifier(s) of this Ingredient that are assigned by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate." )
1696    protected Identifier identifier;
1697
1698    /**
1699     * The status of this ingredient. Enables tracking the life-cycle of the content.
1700     */
1701    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
1702    @Description(shortDefinition="draft | active | retired | unknown", formalDefinition="The status of this ingredient. Enables tracking the life-cycle of the content." )
1703    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/publication-status")
1704    protected Enumeration<PublicationStatus> status;
1705
1706    /**
1707     * The product which this ingredient is a constituent part of.
1708     */
1709    @Child(name = "for", type = {MedicinalProductDefinition.class, AdministrableProductDefinition.class, ManufacturedItemDefinition.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1710    @Description(shortDefinition="The product which this ingredient is a constituent part of", formalDefinition="The product which this ingredient is a constituent part of." )
1711    protected List<Reference> for_;
1712
1713    /**
1714     * A classification of the ingredient identifying its purpose within the product, e.g. active, inactive.
1715     */
1716    @Child(name = "role", type = {CodeableConcept.class}, order=3, min=1, max=1, modifier=false, summary=true)
1717    @Description(shortDefinition="A classification of the ingredient identifying its purpose within the product, e.g. active, inactive", formalDefinition="A classification of the ingredient identifying its purpose within the product, e.g. active, inactive." )
1718    protected CodeableConcept role;
1719
1720    /**
1721     * A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent.
1722     */
1723    @Child(name = "function", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1724    @Description(shortDefinition="A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent", formalDefinition="A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent." )
1725    protected List<CodeableConcept> function;
1726
1727    /**
1728     * A classification of the ingredient according to where in the physical item it tends to be used, such the outer shell of a tablet, inner body or ink.
1729     */
1730    @Child(name = "group", type = {CodeableConcept.class}, order=5, min=0, max=1, modifier=false, summary=true)
1731    @Description(shortDefinition="A classification of the ingredient according to where in the physical item it tends to be used, such the outer shell of a tablet, inner body or ink", formalDefinition="A classification of the ingredient according to where in the physical item it tends to be used, such the outer shell of a tablet, inner body or ink." )
1732    protected CodeableConcept group;
1733
1734    /**
1735     * If the ingredient is a known or suspected allergen.
1736     */
1737    @Child(name = "allergenicIndicator", type = {BooleanType.class}, order=6, min=0, max=1, modifier=false, summary=true)
1738    @Description(shortDefinition="If the ingredient is a known or suspected allergen", formalDefinition="If the ingredient is a known or suspected allergen." )
1739    protected BooleanType allergenicIndicator;
1740
1741    /**
1742     * An organization that manufactures this ingredient.
1743     */
1744    @Child(name = "manufacturer", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1745    @Description(shortDefinition="An organization that manufactures this ingredient", formalDefinition="An organization that manufactures this ingredient." )
1746    protected List<IngredientManufacturerComponent> manufacturer;
1747
1748    /**
1749     * The substance that comprises this ingredient.
1750     */
1751    @Child(name = "substance", type = {}, order=8, min=1, max=1, modifier=false, summary=true)
1752    @Description(shortDefinition="The substance that comprises this ingredient", formalDefinition="The substance that comprises this ingredient." )
1753    protected IngredientSubstanceComponent substance;
1754
1755    private static final long serialVersionUID = -1522820829L;
1756
1757  /**
1758   * Constructor
1759   */
1760    public Ingredient() {
1761      super();
1762    }
1763
1764  /**
1765   * Constructor
1766   */
1767    public Ingredient(PublicationStatus status, CodeableConcept role, IngredientSubstanceComponent substance) {
1768      super();
1769      this.setStatus(status);
1770      this.setRole(role);
1771      this.setSubstance(substance);
1772    }
1773
1774    /**
1775     * @return {@link #identifier} (The identifier(s) of this Ingredient that are assigned by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate.)
1776     */
1777    public Identifier getIdentifier() { 
1778      if (this.identifier == null)
1779        if (Configuration.errorOnAutoCreate())
1780          throw new Error("Attempt to auto-create Ingredient.identifier");
1781        else if (Configuration.doAutoCreate())
1782          this.identifier = new Identifier(); // cc
1783      return this.identifier;
1784    }
1785
1786    public boolean hasIdentifier() { 
1787      return this.identifier != null && !this.identifier.isEmpty();
1788    }
1789
1790    /**
1791     * @param value {@link #identifier} (The identifier(s) of this Ingredient that are assigned by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate.)
1792     */
1793    public Ingredient setIdentifier(Identifier value) { 
1794      this.identifier = value;
1795      return this;
1796    }
1797
1798    /**
1799     * @return {@link #status} (The status of this ingredient. Enables tracking the life-cycle of the content.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1800     */
1801    public Enumeration<PublicationStatus> getStatusElement() { 
1802      if (this.status == null)
1803        if (Configuration.errorOnAutoCreate())
1804          throw new Error("Attempt to auto-create Ingredient.status");
1805        else if (Configuration.doAutoCreate())
1806          this.status = new Enumeration<PublicationStatus>(new PublicationStatusEnumFactory()); // bb
1807      return this.status;
1808    }
1809
1810    public boolean hasStatusElement() { 
1811      return this.status != null && !this.status.isEmpty();
1812    }
1813
1814    public boolean hasStatus() { 
1815      return this.status != null && !this.status.isEmpty();
1816    }
1817
1818    /**
1819     * @param value {@link #status} (The status of this ingredient. Enables tracking the life-cycle of the content.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1820     */
1821    public Ingredient setStatusElement(Enumeration<PublicationStatus> value) { 
1822      this.status = value;
1823      return this;
1824    }
1825
1826    /**
1827     * @return The status of this ingredient. Enables tracking the life-cycle of the content.
1828     */
1829    public PublicationStatus getStatus() { 
1830      return this.status == null ? null : this.status.getValue();
1831    }
1832
1833    /**
1834     * @param value The status of this ingredient. Enables tracking the life-cycle of the content.
1835     */
1836    public Ingredient setStatus(PublicationStatus value) { 
1837        if (this.status == null)
1838          this.status = new Enumeration<PublicationStatus>(new PublicationStatusEnumFactory());
1839        this.status.setValue(value);
1840      return this;
1841    }
1842
1843    /**
1844     * @return {@link #for_} (The product which this ingredient is a constituent part of.)
1845     */
1846    public List<Reference> getFor() { 
1847      if (this.for_ == null)
1848        this.for_ = new ArrayList<Reference>();
1849      return this.for_;
1850    }
1851
1852    /**
1853     * @return Returns a reference to <code>this</code> for easy method chaining
1854     */
1855    public Ingredient setFor(List<Reference> theFor) { 
1856      this.for_ = theFor;
1857      return this;
1858    }
1859
1860    public boolean hasFor() { 
1861      if (this.for_ == null)
1862        return false;
1863      for (Reference item : this.for_)
1864        if (!item.isEmpty())
1865          return true;
1866      return false;
1867    }
1868
1869    public Reference addFor() { //3
1870      Reference t = new Reference();
1871      if (this.for_ == null)
1872        this.for_ = new ArrayList<Reference>();
1873      this.for_.add(t);
1874      return t;
1875    }
1876
1877    public Ingredient addFor(Reference t) { //3
1878      if (t == null)
1879        return this;
1880      if (this.for_ == null)
1881        this.for_ = new ArrayList<Reference>();
1882      this.for_.add(t);
1883      return this;
1884    }
1885
1886    /**
1887     * @return The first repetition of repeating field {@link #for_}, creating it if it does not already exist {3}
1888     */
1889    public Reference getForFirstRep() { 
1890      if (getFor().isEmpty()) {
1891        addFor();
1892      }
1893      return getFor().get(0);
1894    }
1895
1896    /**
1897     * @return {@link #role} (A classification of the ingredient identifying its purpose within the product, e.g. active, inactive.)
1898     */
1899    public CodeableConcept getRole() { 
1900      if (this.role == null)
1901        if (Configuration.errorOnAutoCreate())
1902          throw new Error("Attempt to auto-create Ingredient.role");
1903        else if (Configuration.doAutoCreate())
1904          this.role = new CodeableConcept(); // cc
1905      return this.role;
1906    }
1907
1908    public boolean hasRole() { 
1909      return this.role != null && !this.role.isEmpty();
1910    }
1911
1912    /**
1913     * @param value {@link #role} (A classification of the ingredient identifying its purpose within the product, e.g. active, inactive.)
1914     */
1915    public Ingredient setRole(CodeableConcept value) { 
1916      this.role = value;
1917      return this;
1918    }
1919
1920    /**
1921     * @return {@link #function} (A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent.)
1922     */
1923    public List<CodeableConcept> getFunction() { 
1924      if (this.function == null)
1925        this.function = new ArrayList<CodeableConcept>();
1926      return this.function;
1927    }
1928
1929    /**
1930     * @return Returns a reference to <code>this</code> for easy method chaining
1931     */
1932    public Ingredient setFunction(List<CodeableConcept> theFunction) { 
1933      this.function = theFunction;
1934      return this;
1935    }
1936
1937    public boolean hasFunction() { 
1938      if (this.function == null)
1939        return false;
1940      for (CodeableConcept item : this.function)
1941        if (!item.isEmpty())
1942          return true;
1943      return false;
1944    }
1945
1946    public CodeableConcept addFunction() { //3
1947      CodeableConcept t = new CodeableConcept();
1948      if (this.function == null)
1949        this.function = new ArrayList<CodeableConcept>();
1950      this.function.add(t);
1951      return t;
1952    }
1953
1954    public Ingredient addFunction(CodeableConcept t) { //3
1955      if (t == null)
1956        return this;
1957      if (this.function == null)
1958        this.function = new ArrayList<CodeableConcept>();
1959      this.function.add(t);
1960      return this;
1961    }
1962
1963    /**
1964     * @return The first repetition of repeating field {@link #function}, creating it if it does not already exist {3}
1965     */
1966    public CodeableConcept getFunctionFirstRep() { 
1967      if (getFunction().isEmpty()) {
1968        addFunction();
1969      }
1970      return getFunction().get(0);
1971    }
1972
1973    /**
1974     * @return {@link #group} (A classification of the ingredient according to where in the physical item it tends to be used, such the outer shell of a tablet, inner body or ink.)
1975     */
1976    public CodeableConcept getGroup() { 
1977      if (this.group == null)
1978        if (Configuration.errorOnAutoCreate())
1979          throw new Error("Attempt to auto-create Ingredient.group");
1980        else if (Configuration.doAutoCreate())
1981          this.group = new CodeableConcept(); // cc
1982      return this.group;
1983    }
1984
1985    public boolean hasGroup() { 
1986      return this.group != null && !this.group.isEmpty();
1987    }
1988
1989    /**
1990     * @param value {@link #group} (A classification of the ingredient according to where in the physical item it tends to be used, such the outer shell of a tablet, inner body or ink.)
1991     */
1992    public Ingredient setGroup(CodeableConcept value) { 
1993      this.group = value;
1994      return this;
1995    }
1996
1997    /**
1998     * @return {@link #allergenicIndicator} (If the ingredient is a known or suspected allergen.). This is the underlying object with id, value and extensions. The accessor "getAllergenicIndicator" gives direct access to the value
1999     */
2000    public BooleanType getAllergenicIndicatorElement() { 
2001      if (this.allergenicIndicator == null)
2002        if (Configuration.errorOnAutoCreate())
2003          throw new Error("Attempt to auto-create Ingredient.allergenicIndicator");
2004        else if (Configuration.doAutoCreate())
2005          this.allergenicIndicator = new BooleanType(); // bb
2006      return this.allergenicIndicator;
2007    }
2008
2009    public boolean hasAllergenicIndicatorElement() { 
2010      return this.allergenicIndicator != null && !this.allergenicIndicator.isEmpty();
2011    }
2012
2013    public boolean hasAllergenicIndicator() { 
2014      return this.allergenicIndicator != null && !this.allergenicIndicator.isEmpty();
2015    }
2016
2017    /**
2018     * @param value {@link #allergenicIndicator} (If the ingredient is a known or suspected allergen.). This is the underlying object with id, value and extensions. The accessor "getAllergenicIndicator" gives direct access to the value
2019     */
2020    public Ingredient setAllergenicIndicatorElement(BooleanType value) { 
2021      this.allergenicIndicator = value;
2022      return this;
2023    }
2024
2025    /**
2026     * @return If the ingredient is a known or suspected allergen.
2027     */
2028    public boolean getAllergenicIndicator() { 
2029      return this.allergenicIndicator == null || this.allergenicIndicator.isEmpty() ? false : this.allergenicIndicator.getValue();
2030    }
2031
2032    /**
2033     * @param value If the ingredient is a known or suspected allergen.
2034     */
2035    public Ingredient setAllergenicIndicator(boolean value) { 
2036        if (this.allergenicIndicator == null)
2037          this.allergenicIndicator = new BooleanType();
2038        this.allergenicIndicator.setValue(value);
2039      return this;
2040    }
2041
2042    /**
2043     * @return {@link #manufacturer} (An organization that manufactures this ingredient.)
2044     */
2045    public List<IngredientManufacturerComponent> getManufacturer() { 
2046      if (this.manufacturer == null)
2047        this.manufacturer = new ArrayList<IngredientManufacturerComponent>();
2048      return this.manufacturer;
2049    }
2050
2051    /**
2052     * @return Returns a reference to <code>this</code> for easy method chaining
2053     */
2054    public Ingredient setManufacturer(List<IngredientManufacturerComponent> theManufacturer) { 
2055      this.manufacturer = theManufacturer;
2056      return this;
2057    }
2058
2059    public boolean hasManufacturer() { 
2060      if (this.manufacturer == null)
2061        return false;
2062      for (IngredientManufacturerComponent item : this.manufacturer)
2063        if (!item.isEmpty())
2064          return true;
2065      return false;
2066    }
2067
2068    public IngredientManufacturerComponent addManufacturer() { //3
2069      IngredientManufacturerComponent t = new IngredientManufacturerComponent();
2070      if (this.manufacturer == null)
2071        this.manufacturer = new ArrayList<IngredientManufacturerComponent>();
2072      this.manufacturer.add(t);
2073      return t;
2074    }
2075
2076    public Ingredient addManufacturer(IngredientManufacturerComponent t) { //3
2077      if (t == null)
2078        return this;
2079      if (this.manufacturer == null)
2080        this.manufacturer = new ArrayList<IngredientManufacturerComponent>();
2081      this.manufacturer.add(t);
2082      return this;
2083    }
2084
2085    /**
2086     * @return The first repetition of repeating field {@link #manufacturer}, creating it if it does not already exist {3}
2087     */
2088    public IngredientManufacturerComponent getManufacturerFirstRep() { 
2089      if (getManufacturer().isEmpty()) {
2090        addManufacturer();
2091      }
2092      return getManufacturer().get(0);
2093    }
2094
2095    /**
2096     * @return {@link #substance} (The substance that comprises this ingredient.)
2097     */
2098    public IngredientSubstanceComponent getSubstance() { 
2099      if (this.substance == null)
2100        if (Configuration.errorOnAutoCreate())
2101          throw new Error("Attempt to auto-create Ingredient.substance");
2102        else if (Configuration.doAutoCreate())
2103          this.substance = new IngredientSubstanceComponent(); // cc
2104      return this.substance;
2105    }
2106
2107    public boolean hasSubstance() { 
2108      return this.substance != null && !this.substance.isEmpty();
2109    }
2110
2111    /**
2112     * @param value {@link #substance} (The substance that comprises this ingredient.)
2113     */
2114    public Ingredient setSubstance(IngredientSubstanceComponent value) { 
2115      this.substance = value;
2116      return this;
2117    }
2118
2119      protected void listChildren(List<Property> children) {
2120        super.listChildren(children);
2121        children.add(new Property("identifier", "Identifier", "The identifier(s) of this Ingredient that are assigned by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate.", 0, 1, identifier));
2122        children.add(new Property("status", "code", "The status of this ingredient. Enables tracking the life-cycle of the content.", 0, 1, status));
2123        children.add(new Property("for", "Reference(MedicinalProductDefinition|AdministrableProductDefinition|ManufacturedItemDefinition)", "The product which this ingredient is a constituent part of.", 0, java.lang.Integer.MAX_VALUE, for_));
2124        children.add(new Property("role", "CodeableConcept", "A classification of the ingredient identifying its purpose within the product, e.g. active, inactive.", 0, 1, role));
2125        children.add(new Property("function", "CodeableConcept", "A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent.", 0, java.lang.Integer.MAX_VALUE, function));
2126        children.add(new Property("group", "CodeableConcept", "A classification of the ingredient according to where in the physical item it tends to be used, such the outer shell of a tablet, inner body or ink.", 0, 1, group));
2127        children.add(new Property("allergenicIndicator", "boolean", "If the ingredient is a known or suspected allergen.", 0, 1, allergenicIndicator));
2128        children.add(new Property("manufacturer", "", "An organization that manufactures this ingredient.", 0, java.lang.Integer.MAX_VALUE, manufacturer));
2129        children.add(new Property("substance", "", "The substance that comprises this ingredient.", 0, 1, substance));
2130      }
2131
2132      @Override
2133      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2134        switch (_hash) {
2135        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "The identifier(s) of this Ingredient that are assigned by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate.", 0, 1, identifier);
2136        case -892481550: /*status*/  return new Property("status", "code", "The status of this ingredient. Enables tracking the life-cycle of the content.", 0, 1, status);
2137        case 101577: /*for*/  return new Property("for", "Reference(MedicinalProductDefinition|AdministrableProductDefinition|ManufacturedItemDefinition)", "The product which this ingredient is a constituent part of.", 0, java.lang.Integer.MAX_VALUE, for_);
2138        case 3506294: /*role*/  return new Property("role", "CodeableConcept", "A classification of the ingredient identifying its purpose within the product, e.g. active, inactive.", 0, 1, role);
2139        case 1380938712: /*function*/  return new Property("function", "CodeableConcept", "A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent.", 0, java.lang.Integer.MAX_VALUE, function);
2140        case 98629247: /*group*/  return new Property("group", "CodeableConcept", "A classification of the ingredient according to where in the physical item it tends to be used, such the outer shell of a tablet, inner body or ink.", 0, 1, group);
2141        case 75406931: /*allergenicIndicator*/  return new Property("allergenicIndicator", "boolean", "If the ingredient is a known or suspected allergen.", 0, 1, allergenicIndicator);
2142        case -1969347631: /*manufacturer*/  return new Property("manufacturer", "", "An organization that manufactures this ingredient.", 0, java.lang.Integer.MAX_VALUE, manufacturer);
2143        case 530040176: /*substance*/  return new Property("substance", "", "The substance that comprises this ingredient.", 0, 1, substance);
2144        default: return super.getNamedProperty(_hash, _name, _checkValid);
2145        }
2146
2147      }
2148
2149      @Override
2150      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2151        switch (hash) {
2152        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : new Base[] {this.identifier}; // Identifier
2153        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<PublicationStatus>
2154        case 101577: /*for*/ return this.for_ == null ? new Base[0] : this.for_.toArray(new Base[this.for_.size()]); // Reference
2155        case 3506294: /*role*/ return this.role == null ? new Base[0] : new Base[] {this.role}; // CodeableConcept
2156        case 1380938712: /*function*/ return this.function == null ? new Base[0] : this.function.toArray(new Base[this.function.size()]); // CodeableConcept
2157        case 98629247: /*group*/ return this.group == null ? new Base[0] : new Base[] {this.group}; // CodeableConcept
2158        case 75406931: /*allergenicIndicator*/ return this.allergenicIndicator == null ? new Base[0] : new Base[] {this.allergenicIndicator}; // BooleanType
2159        case -1969347631: /*manufacturer*/ return this.manufacturer == null ? new Base[0] : this.manufacturer.toArray(new Base[this.manufacturer.size()]); // IngredientManufacturerComponent
2160        case 530040176: /*substance*/ return this.substance == null ? new Base[0] : new Base[] {this.substance}; // IngredientSubstanceComponent
2161        default: return super.getProperty(hash, name, checkValid);
2162        }
2163
2164      }
2165
2166      @Override
2167      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2168        switch (hash) {
2169        case -1618432855: // identifier
2170          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
2171          return value;
2172        case -892481550: // status
2173          value = new PublicationStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
2174          this.status = (Enumeration) value; // Enumeration<PublicationStatus>
2175          return value;
2176        case 101577: // for
2177          this.getFor().add(TypeConvertor.castToReference(value)); // Reference
2178          return value;
2179        case 3506294: // role
2180          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2181          return value;
2182        case 1380938712: // function
2183          this.getFunction().add(TypeConvertor.castToCodeableConcept(value)); // CodeableConcept
2184          return value;
2185        case 98629247: // group
2186          this.group = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2187          return value;
2188        case 75406931: // allergenicIndicator
2189          this.allergenicIndicator = TypeConvertor.castToBoolean(value); // BooleanType
2190          return value;
2191        case -1969347631: // manufacturer
2192          this.getManufacturer().add((IngredientManufacturerComponent) value); // IngredientManufacturerComponent
2193          return value;
2194        case 530040176: // substance
2195          this.substance = (IngredientSubstanceComponent) value; // IngredientSubstanceComponent
2196          return value;
2197        default: return super.setProperty(hash, name, value);
2198        }
2199
2200      }
2201
2202      @Override
2203      public Base setProperty(String name, Base value) throws FHIRException {
2204        if (name.equals("identifier")) {
2205          this.identifier = TypeConvertor.castToIdentifier(value); // Identifier
2206        } else if (name.equals("status")) {
2207          value = new PublicationStatusEnumFactory().fromType(TypeConvertor.castToCode(value));
2208          this.status = (Enumeration) value; // Enumeration<PublicationStatus>
2209        } else if (name.equals("for")) {
2210          this.getFor().add(TypeConvertor.castToReference(value));
2211        } else if (name.equals("role")) {
2212          this.role = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2213        } else if (name.equals("function")) {
2214          this.getFunction().add(TypeConvertor.castToCodeableConcept(value));
2215        } else if (name.equals("group")) {
2216          this.group = TypeConvertor.castToCodeableConcept(value); // CodeableConcept
2217        } else if (name.equals("allergenicIndicator")) {
2218          this.allergenicIndicator = TypeConvertor.castToBoolean(value); // BooleanType
2219        } else if (name.equals("manufacturer")) {
2220          this.getManufacturer().add((IngredientManufacturerComponent) value);
2221        } else if (name.equals("substance")) {
2222          this.substance = (IngredientSubstanceComponent) value; // IngredientSubstanceComponent
2223        } else
2224          return super.setProperty(name, value);
2225        return value;
2226      }
2227
2228      @Override
2229      public Base makeProperty(int hash, String name) throws FHIRException {
2230        switch (hash) {
2231        case -1618432855:  return getIdentifier();
2232        case -892481550:  return getStatusElement();
2233        case 101577:  return addFor(); 
2234        case 3506294:  return getRole();
2235        case 1380938712:  return addFunction(); 
2236        case 98629247:  return getGroup();
2237        case 75406931:  return getAllergenicIndicatorElement();
2238        case -1969347631:  return addManufacturer(); 
2239        case 530040176:  return getSubstance();
2240        default: return super.makeProperty(hash, name);
2241        }
2242
2243      }
2244
2245      @Override
2246      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2247        switch (hash) {
2248        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2249        case -892481550: /*status*/ return new String[] {"code"};
2250        case 101577: /*for*/ return new String[] {"Reference"};
2251        case 3506294: /*role*/ return new String[] {"CodeableConcept"};
2252        case 1380938712: /*function*/ return new String[] {"CodeableConcept"};
2253        case 98629247: /*group*/ return new String[] {"CodeableConcept"};
2254        case 75406931: /*allergenicIndicator*/ return new String[] {"boolean"};
2255        case -1969347631: /*manufacturer*/ return new String[] {};
2256        case 530040176: /*substance*/ return new String[] {};
2257        default: return super.getTypesForProperty(hash, name);
2258        }
2259
2260      }
2261
2262      @Override
2263      public Base addChild(String name) throws FHIRException {
2264        if (name.equals("identifier")) {
2265          this.identifier = new Identifier();
2266          return this.identifier;
2267        }
2268        else if (name.equals("status")) {
2269          throw new FHIRException("Cannot call addChild on a primitive type Ingredient.status");
2270        }
2271        else if (name.equals("for")) {
2272          return addFor();
2273        }
2274        else if (name.equals("role")) {
2275          this.role = new CodeableConcept();
2276          return this.role;
2277        }
2278        else if (name.equals("function")) {
2279          return addFunction();
2280        }
2281        else if (name.equals("group")) {
2282          this.group = new CodeableConcept();
2283          return this.group;
2284        }
2285        else if (name.equals("allergenicIndicator")) {
2286          throw new FHIRException("Cannot call addChild on a primitive type Ingredient.allergenicIndicator");
2287        }
2288        else if (name.equals("manufacturer")) {
2289          return addManufacturer();
2290        }
2291        else if (name.equals("substance")) {
2292          this.substance = new IngredientSubstanceComponent();
2293          return this.substance;
2294        }
2295        else
2296          return super.addChild(name);
2297      }
2298
2299  public String fhirType() {
2300    return "Ingredient";
2301
2302  }
2303
2304      public Ingredient copy() {
2305        Ingredient dst = new Ingredient();
2306        copyValues(dst);
2307        return dst;
2308      }
2309
2310      public void copyValues(Ingredient dst) {
2311        super.copyValues(dst);
2312        dst.identifier = identifier == null ? null : identifier.copy();
2313        dst.status = status == null ? null : status.copy();
2314        if (for_ != null) {
2315          dst.for_ = new ArrayList<Reference>();
2316          for (Reference i : for_)
2317            dst.for_.add(i.copy());
2318        };
2319        dst.role = role == null ? null : role.copy();
2320        if (function != null) {
2321          dst.function = new ArrayList<CodeableConcept>();
2322          for (CodeableConcept i : function)
2323            dst.function.add(i.copy());
2324        };
2325        dst.group = group == null ? null : group.copy();
2326        dst.allergenicIndicator = allergenicIndicator == null ? null : allergenicIndicator.copy();
2327        if (manufacturer != null) {
2328          dst.manufacturer = new ArrayList<IngredientManufacturerComponent>();
2329          for (IngredientManufacturerComponent i : manufacturer)
2330            dst.manufacturer.add(i.copy());
2331        };
2332        dst.substance = substance == null ? null : substance.copy();
2333      }
2334
2335      protected Ingredient typedCopy() {
2336        return copy();
2337      }
2338
2339      @Override
2340      public boolean equalsDeep(Base other_) {
2341        if (!super.equalsDeep(other_))
2342          return false;
2343        if (!(other_ instanceof Ingredient))
2344          return false;
2345        Ingredient o = (Ingredient) other_;
2346        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(for_, o.for_, true)
2347           && compareDeep(role, o.role, true) && compareDeep(function, o.function, true) && compareDeep(group, o.group, true)
2348           && compareDeep(allergenicIndicator, o.allergenicIndicator, true) && compareDeep(manufacturer, o.manufacturer, true)
2349           && compareDeep(substance, o.substance, true);
2350      }
2351
2352      @Override
2353      public boolean equalsShallow(Base other_) {
2354        if (!super.equalsShallow(other_))
2355          return false;
2356        if (!(other_ instanceof Ingredient))
2357          return false;
2358        Ingredient o = (Ingredient) other_;
2359        return compareValues(status, o.status, true) && compareValues(allergenicIndicator, o.allergenicIndicator, true)
2360          ;
2361      }
2362
2363      public boolean isEmpty() {
2364        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, for_
2365          , role, function, group, allergenicIndicator, manufacturer, substance);
2366      }
2367
2368  @Override
2369  public ResourceType getResourceType() {
2370    return ResourceType.Ingredient;
2371   }
2372
2373 /**
2374   * Search parameter: <b>for</b>
2375   * <p>
2376   * Description: <b>The product which this ingredient is a constituent part of</b><br>
2377   * Type: <b>reference</b><br>
2378   * Path: <b>Ingredient.for</b><br>
2379   * </p>
2380   */
2381  @SearchParamDefinition(name="for", path="Ingredient.for", description="The product which this ingredient is a constituent part of", type="reference", target={AdministrableProductDefinition.class, ManufacturedItemDefinition.class, MedicinalProductDefinition.class } )
2382  public static final String SP_FOR = "for";
2383 /**
2384   * <b>Fluent Client</b> search parameter constant for <b>for</b>
2385   * <p>
2386   * Description: <b>The product which this ingredient is a constituent part of</b><br>
2387   * Type: <b>reference</b><br>
2388   * Path: <b>Ingredient.for</b><br>
2389   * </p>
2390   */
2391  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam FOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_FOR);
2392
2393/**
2394   * Constant for fluent queries to be used to add include statements. Specifies
2395   * the path value of "<b>Ingredient:for</b>".
2396   */
2397  public static final ca.uhn.fhir.model.api.Include INCLUDE_FOR = new ca.uhn.fhir.model.api.Include("Ingredient:for").toLocked();
2398
2399 /**
2400   * Search parameter: <b>function</b>
2401   * <p>
2402   * Description: <b>A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent</b><br>
2403   * Type: <b>token</b><br>
2404   * Path: <b>Ingredient.function</b><br>
2405   * </p>
2406   */
2407  @SearchParamDefinition(name="function", path="Ingredient.function", description="A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent", type="token" )
2408  public static final String SP_FUNCTION = "function";
2409 /**
2410   * <b>Fluent Client</b> search parameter constant for <b>function</b>
2411   * <p>
2412   * Description: <b>A classification of the ingredient identifying its precise purpose(s) in the drug product. This extends the Ingredient.role to add more detail. Example: Antioxidant, Alkalizing Agent</b><br>
2413   * Type: <b>token</b><br>
2414   * Path: <b>Ingredient.function</b><br>
2415   * </p>
2416   */
2417  public static final ca.uhn.fhir.rest.gclient.TokenClientParam FUNCTION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_FUNCTION);
2418
2419 /**
2420   * Search parameter: <b>identifier</b>
2421   * <p>
2422   * Description: <b>An identifier or code by which the ingredient can be referenced</b><br>
2423   * Type: <b>token</b><br>
2424   * Path: <b>Ingredient.identifier</b><br>
2425   * </p>
2426   */
2427  @SearchParamDefinition(name="identifier", path="Ingredient.identifier", description="An identifier or code by which the ingredient can be referenced", type="token" )
2428  public static final String SP_IDENTIFIER = "identifier";
2429 /**
2430   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
2431   * <p>
2432   * Description: <b>An identifier or code by which the ingredient can be referenced</b><br>
2433   * Type: <b>token</b><br>
2434   * Path: <b>Ingredient.identifier</b><br>
2435   * </p>
2436   */
2437  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
2438
2439 /**
2440   * Search parameter: <b>manufacturer</b>
2441   * <p>
2442   * Description: <b>The organization that manufactures this ingredient</b><br>
2443   * Type: <b>reference</b><br>
2444   * Path: <b>Ingredient.manufacturer</b><br>
2445   * </p>
2446   */
2447  @SearchParamDefinition(name="manufacturer", path="Ingredient.manufacturer", description="The organization that manufactures this ingredient", type="reference" )
2448  public static final String SP_MANUFACTURER = "manufacturer";
2449 /**
2450   * <b>Fluent Client</b> search parameter constant for <b>manufacturer</b>
2451   * <p>
2452   * Description: <b>The organization that manufactures this ingredient</b><br>
2453   * Type: <b>reference</b><br>
2454   * Path: <b>Ingredient.manufacturer</b><br>
2455   * </p>
2456   */
2457  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam MANUFACTURER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_MANUFACTURER);
2458
2459/**
2460   * Constant for fluent queries to be used to add include statements. Specifies
2461   * the path value of "<b>Ingredient:manufacturer</b>".
2462   */
2463  public static final ca.uhn.fhir.model.api.Include INCLUDE_MANUFACTURER = new ca.uhn.fhir.model.api.Include("Ingredient:manufacturer").toLocked();
2464
2465 /**
2466   * Search parameter: <b>role</b>
2467   * <p>
2468   * Description: <b>A classification of the ingredient identifying its purpose within the product, e.g. active, inactive</b><br>
2469   * Type: <b>token</b><br>
2470   * Path: <b>Ingredient.role</b><br>
2471   * </p>
2472   */
2473  @SearchParamDefinition(name="role", path="Ingredient.role", description="A classification of the ingredient identifying its purpose within the product, e.g. active, inactive", type="token" )
2474  public static final String SP_ROLE = "role";
2475 /**
2476   * <b>Fluent Client</b> search parameter constant for <b>role</b>
2477   * <p>
2478   * Description: <b>A classification of the ingredient identifying its purpose within the product, e.g. active, inactive</b><br>
2479   * Type: <b>token</b><br>
2480   * Path: <b>Ingredient.role</b><br>
2481   * </p>
2482   */
2483  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ROLE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ROLE);
2484
2485 /**
2486   * Search parameter: <b>substance-code</b>
2487   * <p>
2488   * Description: <b>Reference to a concept (by class)</b><br>
2489   * Type: <b>token</b><br>
2490   * Path: <b>Ingredient.substance.code.concept</b><br>
2491   * </p>
2492   */
2493  @SearchParamDefinition(name="substance-code", path="Ingredient.substance.code.concept", description="Reference to a concept (by class)", type="token" )
2494  public static final String SP_SUBSTANCE_CODE = "substance-code";
2495 /**
2496   * <b>Fluent Client</b> search parameter constant for <b>substance-code</b>
2497   * <p>
2498   * Description: <b>Reference to a concept (by class)</b><br>
2499   * Type: <b>token</b><br>
2500   * Path: <b>Ingredient.substance.code.concept</b><br>
2501   * </p>
2502   */
2503  public static final ca.uhn.fhir.rest.gclient.TokenClientParam SUBSTANCE_CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_SUBSTANCE_CODE);
2504
2505 /**
2506   * Search parameter: <b>substance-definition</b>
2507   * <p>
2508   * Description: <b>Reference to a resource (by instance)</b><br>
2509   * Type: <b>reference</b><br>
2510   * Path: <b>Ingredient.substance.code.reference</b><br>
2511   * </p>
2512   */
2513  @SearchParamDefinition(name="substance-definition", path="Ingredient.substance.code.reference", description="Reference to a resource (by instance)", type="reference" )
2514  public static final String SP_SUBSTANCE_DEFINITION = "substance-definition";
2515 /**
2516   * <b>Fluent Client</b> search parameter constant for <b>substance-definition</b>
2517   * <p>
2518   * Description: <b>Reference to a resource (by instance)</b><br>
2519   * Type: <b>reference</b><br>
2520   * Path: <b>Ingredient.substance.code.reference</b><br>
2521   * </p>
2522   */
2523  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBSTANCE_DEFINITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBSTANCE_DEFINITION);
2524
2525/**
2526   * Constant for fluent queries to be used to add include statements. Specifies
2527   * the path value of "<b>Ingredient:substance-definition</b>".
2528   */
2529  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBSTANCE_DEFINITION = new ca.uhn.fhir.model.api.Include("Ingredient:substance-definition").toLocked();
2530
2531 /**
2532   * Search parameter: <b>substance</b>
2533   * <p>
2534   * Description: <b>Reference to a resource (by instance)</b><br>
2535   * Type: <b>reference</b><br>
2536   * Path: <b>Ingredient.substance.code.reference</b><br>
2537   * </p>
2538   */
2539  @SearchParamDefinition(name="substance", path="Ingredient.substance.code.reference", description="Reference to a resource (by instance)", type="reference" )
2540  public static final String SP_SUBSTANCE = "substance";
2541 /**
2542   * <b>Fluent Client</b> search parameter constant for <b>substance</b>
2543   * <p>
2544   * Description: <b>Reference to a resource (by instance)</b><br>
2545   * Type: <b>reference</b><br>
2546   * Path: <b>Ingredient.substance.code.reference</b><br>
2547   * </p>
2548   */
2549  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBSTANCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBSTANCE);
2550
2551/**
2552   * Constant for fluent queries to be used to add include statements. Specifies
2553   * the path value of "<b>Ingredient:substance</b>".
2554   */
2555  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBSTANCE = new ca.uhn.fhir.model.api.Include("Ingredient:substance").toLocked();
2556
2557
2558}
2559