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