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