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