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