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