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