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