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