001package org.hl7.fhir.r4.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r4
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023/*
024  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.List;
054
055import org.hl7.fhir.exceptions.FHIRException;
056import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058import org.hl7.fhir.utilities.Utilities;
059
060import ca.uhn.fhir.model.api.annotation.Block;
061import ca.uhn.fhir.model.api.annotation.Child;
062import ca.uhn.fhir.model.api.annotation.DatatypeDef;
063import ca.uhn.fhir.model.api.annotation.Description;
064/**
065 * Chemical substances are a single substance type whose primary defining element is the molecular structure. Chemical substances shall be defined on the basis of their complete covalent molecular structure; the presence of a salt (counter-ion) and/or solvates (water, alcohols) is also captured. Purity, grade, physical form or particle size are not taken into account in the definition of a chemical substance or in the assignment of a Substance ID.
066 */
067@DatatypeDef(name="SubstanceAmount")
068public class SubstanceAmount extends BackboneType implements ICompositeType {
069
070    @Block()
071    public static class SubstanceAmountReferenceRangeComponent extends Element implements IBaseDatatypeElement {
072        /**
073         * Lower limit possible or expected.
074         */
075        @Child(name = "lowLimit", type = {Quantity.class}, order=1, min=0, max=1, modifier=false, summary=true)
076        @Description(shortDefinition="Lower limit possible or expected", formalDefinition="Lower limit possible or expected." )
077        protected Quantity lowLimit;
078
079        /**
080         * Upper limit possible or expected.
081         */
082        @Child(name = "highLimit", type = {Quantity.class}, order=2, min=0, max=1, modifier=false, summary=true)
083        @Description(shortDefinition="Upper limit possible or expected", formalDefinition="Upper limit possible or expected." )
084        protected Quantity highLimit;
085
086        private static final long serialVersionUID = -193230412L;
087
088    /**
089     * Constructor
090     */
091      public SubstanceAmountReferenceRangeComponent() {
092        super();
093      }
094
095        /**
096         * @return {@link #lowLimit} (Lower limit possible or expected.)
097         */
098        public Quantity getLowLimit() { 
099          if (this.lowLimit == null)
100            if (Configuration.errorOnAutoCreate())
101              throw new Error("Attempt to auto-create SubstanceAmountReferenceRangeComponent.lowLimit");
102            else if (Configuration.doAutoCreate())
103              this.lowLimit = new Quantity(); // cc
104          return this.lowLimit;
105        }
106
107        public boolean hasLowLimit() { 
108          return this.lowLimit != null && !this.lowLimit.isEmpty();
109        }
110
111        /**
112         * @param value {@link #lowLimit} (Lower limit possible or expected.)
113         */
114        public SubstanceAmountReferenceRangeComponent setLowLimit(Quantity value) { 
115          this.lowLimit = value;
116          return this;
117        }
118
119        /**
120         * @return {@link #highLimit} (Upper limit possible or expected.)
121         */
122        public Quantity getHighLimit() { 
123          if (this.highLimit == null)
124            if (Configuration.errorOnAutoCreate())
125              throw new Error("Attempt to auto-create SubstanceAmountReferenceRangeComponent.highLimit");
126            else if (Configuration.doAutoCreate())
127              this.highLimit = new Quantity(); // cc
128          return this.highLimit;
129        }
130
131        public boolean hasHighLimit() { 
132          return this.highLimit != null && !this.highLimit.isEmpty();
133        }
134
135        /**
136         * @param value {@link #highLimit} (Upper limit possible or expected.)
137         */
138        public SubstanceAmountReferenceRangeComponent setHighLimit(Quantity value) { 
139          this.highLimit = value;
140          return this;
141        }
142
143        protected void listChildren(List<Property> children) {
144          super.listChildren(children);
145          children.add(new Property("lowLimit", "Quantity", "Lower limit possible or expected.", 0, 1, lowLimit));
146          children.add(new Property("highLimit", "Quantity", "Upper limit possible or expected.", 0, 1, highLimit));
147        }
148
149        @Override
150        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
151          switch (_hash) {
152          case -1841058617: /*lowLimit*/  return new Property("lowLimit", "Quantity", "Lower limit possible or expected.", 0, 1, lowLimit);
153          case -710757575: /*highLimit*/  return new Property("highLimit", "Quantity", "Upper limit possible or expected.", 0, 1, highLimit);
154          default: return super.getNamedProperty(_hash, _name, _checkValid);
155          }
156
157        }
158
159      @Override
160      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
161        switch (hash) {
162        case -1841058617: /*lowLimit*/ return this.lowLimit == null ? new Base[0] : new Base[] {this.lowLimit}; // Quantity
163        case -710757575: /*highLimit*/ return this.highLimit == null ? new Base[0] : new Base[] {this.highLimit}; // Quantity
164        default: return super.getProperty(hash, name, checkValid);
165        }
166
167      }
168
169      @Override
170      public Base setProperty(int hash, String name, Base value) throws FHIRException {
171        switch (hash) {
172        case -1841058617: // lowLimit
173          this.lowLimit = castToQuantity(value); // Quantity
174          return value;
175        case -710757575: // highLimit
176          this.highLimit = castToQuantity(value); // Quantity
177          return value;
178        default: return super.setProperty(hash, name, value);
179        }
180
181      }
182
183      @Override
184      public Base setProperty(String name, Base value) throws FHIRException {
185        if (name.equals("lowLimit")) {
186          this.lowLimit = castToQuantity(value); // Quantity
187        } else if (name.equals("highLimit")) {
188          this.highLimit = castToQuantity(value); // Quantity
189        } else
190          return super.setProperty(name, value);
191        return value;
192      }
193
194      @Override
195      public Base makeProperty(int hash, String name) throws FHIRException {
196        switch (hash) {
197        case -1841058617:  return getLowLimit(); 
198        case -710757575:  return getHighLimit(); 
199        default: return super.makeProperty(hash, name);
200        }
201
202      }
203
204      @Override
205      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
206        switch (hash) {
207        case -1841058617: /*lowLimit*/ return new String[] {"Quantity"};
208        case -710757575: /*highLimit*/ return new String[] {"Quantity"};
209        default: return super.getTypesForProperty(hash, name);
210        }
211
212      }
213
214      @Override
215      public Base addChild(String name) throws FHIRException {
216        if (name.equals("lowLimit")) {
217          this.lowLimit = new Quantity();
218          return this.lowLimit;
219        }
220        else if (name.equals("highLimit")) {
221          this.highLimit = new Quantity();
222          return this.highLimit;
223        }
224        else
225          return super.addChild(name);
226      }
227
228      public SubstanceAmountReferenceRangeComponent copy() {
229        SubstanceAmountReferenceRangeComponent dst = new SubstanceAmountReferenceRangeComponent();
230        copyValues(dst);
231        dst.lowLimit = lowLimit == null ? null : lowLimit.copy();
232        dst.highLimit = highLimit == null ? null : highLimit.copy();
233        return dst;
234      }
235
236      @Override
237      public boolean equalsDeep(Base other_) {
238        if (!super.equalsDeep(other_))
239          return false;
240        if (!(other_ instanceof SubstanceAmountReferenceRangeComponent))
241          return false;
242        SubstanceAmountReferenceRangeComponent o = (SubstanceAmountReferenceRangeComponent) other_;
243        return compareDeep(lowLimit, o.lowLimit, true) && compareDeep(highLimit, o.highLimit, true);
244      }
245
246      @Override
247      public boolean equalsShallow(Base other_) {
248        if (!super.equalsShallow(other_))
249          return false;
250        if (!(other_ instanceof SubstanceAmountReferenceRangeComponent))
251          return false;
252        SubstanceAmountReferenceRangeComponent o = (SubstanceAmountReferenceRangeComponent) other_;
253        return true;
254      }
255
256      public boolean isEmpty() {
257        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(lowLimit, highLimit);
258      }
259
260  public String fhirType() {
261    return "SubstanceAmount.referenceRange";
262
263  }
264
265  }
266
267    /**
268     * Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.
269     */
270    @Child(name = "amount", type = {Quantity.class, Range.class, StringType.class}, order=0, min=0, max=1, modifier=false, summary=true)
271    @Description(shortDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field", formalDefinition="Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field." )
272    protected Type amount;
273
274    /**
275     * Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.
276     */
277    @Child(name = "amountType", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
278    @Description(shortDefinition="Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements", formalDefinition="Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements." )
279    protected CodeableConcept amountType;
280
281    /**
282     * A textual comment on a numeric value.
283     */
284    @Child(name = "amountText", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
285    @Description(shortDefinition="A textual comment on a numeric value", formalDefinition="A textual comment on a numeric value." )
286    protected StringType amountText;
287
288    /**
289     * Reference range of possible or expected values.
290     */
291    @Child(name = "referenceRange", type = {}, order=3, min=0, max=1, modifier=false, summary=true)
292    @Description(shortDefinition="Reference range of possible or expected values", formalDefinition="Reference range of possible or expected values." )
293    protected SubstanceAmountReferenceRangeComponent referenceRange;
294
295    private static final long serialVersionUID = -174997548L;
296
297  /**
298   * Constructor
299   */
300    public SubstanceAmount() {
301      super();
302    }
303
304    /**
305     * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.)
306     */
307    public Type getAmount() { 
308      return this.amount;
309    }
310
311    /**
312     * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.)
313     */
314    public Quantity getAmountQuantity() throws FHIRException { 
315      if (this.amount == null)
316        this.amount = new Quantity();
317      if (!(this.amount instanceof Quantity))
318        throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.amount.getClass().getName()+" was encountered");
319      return (Quantity) this.amount;
320    }
321
322    public boolean hasAmountQuantity() { 
323      return this != null && this.amount instanceof Quantity;
324    }
325
326    /**
327     * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.)
328     */
329    public Range getAmountRange() throws FHIRException { 
330      if (this.amount == null)
331        this.amount = new Range();
332      if (!(this.amount instanceof Range))
333        throw new FHIRException("Type mismatch: the type Range was expected, but "+this.amount.getClass().getName()+" was encountered");
334      return (Range) this.amount;
335    }
336
337    public boolean hasAmountRange() { 
338      return this != null && this.amount instanceof Range;
339    }
340
341    /**
342     * @return {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.)
343     */
344    public StringType getAmountStringType() throws FHIRException { 
345      if (this.amount == null)
346        this.amount = new StringType();
347      if (!(this.amount instanceof StringType))
348        throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.amount.getClass().getName()+" was encountered");
349      return (StringType) this.amount;
350    }
351
352    public boolean hasAmountStringType() { 
353      return this != null && this.amount instanceof StringType;
354    }
355
356    public boolean hasAmount() { 
357      return this.amount != null && !this.amount.isEmpty();
358    }
359
360    /**
361     * @param value {@link #amount} (Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.)
362     */
363    public SubstanceAmount setAmount(Type value) { 
364      if (value != null && !(value instanceof Quantity || value instanceof Range || value instanceof StringType))
365        throw new Error("Not the right type for SubstanceAmount.amount[x]: "+value.fhirType());
366      this.amount = value;
367      return this;
368    }
369
370    /**
371     * @return {@link #amountType} (Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.)
372     */
373    public CodeableConcept getAmountType() { 
374      if (this.amountType == null)
375        if (Configuration.errorOnAutoCreate())
376          throw new Error("Attempt to auto-create SubstanceAmount.amountType");
377        else if (Configuration.doAutoCreate())
378          this.amountType = new CodeableConcept(); // cc
379      return this.amountType;
380    }
381
382    public boolean hasAmountType() { 
383      return this.amountType != null && !this.amountType.isEmpty();
384    }
385
386    /**
387     * @param value {@link #amountType} (Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.)
388     */
389    public SubstanceAmount setAmountType(CodeableConcept value) { 
390      this.amountType = value;
391      return this;
392    }
393
394    /**
395     * @return {@link #amountText} (A textual comment on a numeric value.). This is the underlying object with id, value and extensions. The accessor "getAmountText" gives direct access to the value
396     */
397    public StringType getAmountTextElement() { 
398      if (this.amountText == null)
399        if (Configuration.errorOnAutoCreate())
400          throw new Error("Attempt to auto-create SubstanceAmount.amountText");
401        else if (Configuration.doAutoCreate())
402          this.amountText = new StringType(); // bb
403      return this.amountText;
404    }
405
406    public boolean hasAmountTextElement() { 
407      return this.amountText != null && !this.amountText.isEmpty();
408    }
409
410    public boolean hasAmountText() { 
411      return this.amountText != null && !this.amountText.isEmpty();
412    }
413
414    /**
415     * @param value {@link #amountText} (A textual comment on a numeric value.). This is the underlying object with id, value and extensions. The accessor "getAmountText" gives direct access to the value
416     */
417    public SubstanceAmount setAmountTextElement(StringType value) { 
418      this.amountText = value;
419      return this;
420    }
421
422    /**
423     * @return A textual comment on a numeric value.
424     */
425    public String getAmountText() { 
426      return this.amountText == null ? null : this.amountText.getValue();
427    }
428
429    /**
430     * @param value A textual comment on a numeric value.
431     */
432    public SubstanceAmount setAmountText(String value) { 
433      if (Utilities.noString(value))
434        this.amountText = null;
435      else {
436        if (this.amountText == null)
437          this.amountText = new StringType();
438        this.amountText.setValue(value);
439      }
440      return this;
441    }
442
443    /**
444     * @return {@link #referenceRange} (Reference range of possible or expected values.)
445     */
446    public SubstanceAmountReferenceRangeComponent getReferenceRange() { 
447      if (this.referenceRange == null)
448        if (Configuration.errorOnAutoCreate())
449          throw new Error("Attempt to auto-create SubstanceAmount.referenceRange");
450        else if (Configuration.doAutoCreate())
451          this.referenceRange = new SubstanceAmountReferenceRangeComponent(); // cc
452      return this.referenceRange;
453    }
454
455    public boolean hasReferenceRange() { 
456      return this.referenceRange != null && !this.referenceRange.isEmpty();
457    }
458
459    /**
460     * @param value {@link #referenceRange} (Reference range of possible or expected values.)
461     */
462    public SubstanceAmount setReferenceRange(SubstanceAmountReferenceRangeComponent value) { 
463      this.referenceRange = value;
464      return this;
465    }
466
467      protected void listChildren(List<Property> children) {
468        super.listChildren(children);
469        children.add(new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount));
470        children.add(new Property("amountType", "CodeableConcept", "Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.", 0, 1, amountType));
471        children.add(new Property("amountText", "string", "A textual comment on a numeric value.", 0, 1, amountText));
472        children.add(new Property("referenceRange", "", "Reference range of possible or expected values.", 0, 1, referenceRange));
473      }
474
475      @Override
476      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
477        switch (_hash) {
478        case 646780200: /*amount[x]*/  return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount);
479        case -1413853096: /*amount*/  return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount);
480        case 1664303363: /*amountQuantity*/  return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount);
481        case -1223462971: /*amountRange*/  return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount);
482        case 773651081: /*amountString*/  return new Property("amount[x]", "Quantity|Range|string", "Used to capture quantitative values for a variety of elements. If only limits are given, the arithmetic mean would be the average. If only a single definite value for a given element is given, it would be captured in this field.", 0, 1, amount);
483        case -1424857166: /*amountType*/  return new Property("amountType", "CodeableConcept", "Most elements that require a quantitative value will also have a field called amount type. Amount type should always be specified because the actual value of the amount is often dependent on it. EXAMPLE: In capturing the actual relative amounts of substances or molecular fragments it is essential to indicate whether the amount refers to a mole ratio or weight ratio. For any given element an effort should be made to use same the amount type for all related definitional elements.", 0, 1, amountType);
484        case -1424876123: /*amountText*/  return new Property("amountText", "string", "A textual comment on a numeric value.", 0, 1, amountText);
485        case -1912545102: /*referenceRange*/  return new Property("referenceRange", "", "Reference range of possible or expected values.", 0, 1, referenceRange);
486        default: return super.getNamedProperty(_hash, _name, _checkValid);
487        }
488
489      }
490
491      @Override
492      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
493        switch (hash) {
494        case -1413853096: /*amount*/ return this.amount == null ? new Base[0] : new Base[] {this.amount}; // Type
495        case -1424857166: /*amountType*/ return this.amountType == null ? new Base[0] : new Base[] {this.amountType}; // CodeableConcept
496        case -1424876123: /*amountText*/ return this.amountText == null ? new Base[0] : new Base[] {this.amountText}; // StringType
497        case -1912545102: /*referenceRange*/ return this.referenceRange == null ? new Base[0] : new Base[] {this.referenceRange}; // SubstanceAmountReferenceRangeComponent
498        default: return super.getProperty(hash, name, checkValid);
499        }
500
501      }
502
503      @Override
504      public Base setProperty(int hash, String name, Base value) throws FHIRException {
505        switch (hash) {
506        case -1413853096: // amount
507          this.amount = castToType(value); // Type
508          return value;
509        case -1424857166: // amountType
510          this.amountType = castToCodeableConcept(value); // CodeableConcept
511          return value;
512        case -1424876123: // amountText
513          this.amountText = castToString(value); // StringType
514          return value;
515        case -1912545102: // referenceRange
516          this.referenceRange = (SubstanceAmountReferenceRangeComponent) value; // SubstanceAmountReferenceRangeComponent
517          return value;
518        default: return super.setProperty(hash, name, value);
519        }
520
521      }
522
523      @Override
524      public Base setProperty(String name, Base value) throws FHIRException {
525        if (name.equals("amount[x]")) {
526          this.amount = castToType(value); // Type
527        } else if (name.equals("amountType")) {
528          this.amountType = castToCodeableConcept(value); // CodeableConcept
529        } else if (name.equals("amountText")) {
530          this.amountText = castToString(value); // StringType
531        } else if (name.equals("referenceRange")) {
532          this.referenceRange = (SubstanceAmountReferenceRangeComponent) value; // SubstanceAmountReferenceRangeComponent
533        } else
534          return super.setProperty(name, value);
535        return value;
536      }
537
538      @Override
539      public Base makeProperty(int hash, String name) throws FHIRException {
540        switch (hash) {
541        case 646780200:  return getAmount(); 
542        case -1413853096:  return getAmount(); 
543        case -1424857166:  return getAmountType(); 
544        case -1424876123:  return getAmountTextElement();
545        case -1912545102:  return getReferenceRange(); 
546        default: return super.makeProperty(hash, name);
547        }
548
549      }
550
551      @Override
552      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
553        switch (hash) {
554        case -1413853096: /*amount*/ return new String[] {"Quantity", "Range", "string"};
555        case -1424857166: /*amountType*/ return new String[] {"CodeableConcept"};
556        case -1424876123: /*amountText*/ return new String[] {"string"};
557        case -1912545102: /*referenceRange*/ return new String[] {};
558        default: return super.getTypesForProperty(hash, name);
559        }
560
561      }
562
563      @Override
564      public Base addChild(String name) throws FHIRException {
565        if (name.equals("amountQuantity")) {
566          this.amount = new Quantity();
567          return this.amount;
568        }
569        else if (name.equals("amountRange")) {
570          this.amount = new Range();
571          return this.amount;
572        }
573        else if (name.equals("amountString")) {
574          this.amount = new StringType();
575          return this.amount;
576        }
577        else if (name.equals("amountType")) {
578          this.amountType = new CodeableConcept();
579          return this.amountType;
580        }
581        else if (name.equals("amountText")) {
582          throw new FHIRException("Cannot call addChild on a primitive type SubstanceAmount.amountText");
583        }
584        else if (name.equals("referenceRange")) {
585          this.referenceRange = new SubstanceAmountReferenceRangeComponent();
586          return this.referenceRange;
587        }
588        else
589          return super.addChild(name);
590      }
591
592  public String fhirType() {
593    return "SubstanceAmount";
594
595  }
596
597      public SubstanceAmount copy() {
598        SubstanceAmount dst = new SubstanceAmount();
599        copyValues(dst);
600        dst.amount = amount == null ? null : amount.copy();
601        dst.amountType = amountType == null ? null : amountType.copy();
602        dst.amountText = amountText == null ? null : amountText.copy();
603        dst.referenceRange = referenceRange == null ? null : referenceRange.copy();
604        return dst;
605      }
606
607      protected SubstanceAmount typedCopy() {
608        return copy();
609      }
610
611      @Override
612      public boolean equalsDeep(Base other_) {
613        if (!super.equalsDeep(other_))
614          return false;
615        if (!(other_ instanceof SubstanceAmount))
616          return false;
617        SubstanceAmount o = (SubstanceAmount) other_;
618        return compareDeep(amount, o.amount, true) && compareDeep(amountType, o.amountType, true) && compareDeep(amountText, o.amountText, true)
619           && compareDeep(referenceRange, o.referenceRange, true);
620      }
621
622      @Override
623      public boolean equalsShallow(Base other_) {
624        if (!super.equalsShallow(other_))
625          return false;
626        if (!(other_ instanceof SubstanceAmount))
627          return false;
628        SubstanceAmount o = (SubstanceAmount) other_;
629        return compareValues(amountText, o.amountText, true);
630      }
631
632      public boolean isEmpty() {
633        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(amount, amountType, amountText
634          , referenceRange);
635      }
636
637
638}
639