001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import java.math.*;
040import org.hl7.fhir.utilities.Utilities;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.ChildOrder;
043import ca.uhn.fhir.model.api.annotation.Description;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Block;
046import org.hl7.fhir.instance.model.api.*;
047import org.hl7.fhir.exceptions.FHIRException;
048/**
049 * A measured amount (or an amount that can potentially be measured). Note that measured amounts include amounts that are not precisely quantified, including amounts involving arbitrary units and floating currencies.
050 */
051@DatatypeDef(name="Quantity")
052public class Quantity extends Type implements ICompositeType, ICoding {
053
054    public enum QuantityComparator {
055        /**
056         * The actual value is less than the given value.
057         */
058        LESS_THAN, 
059        /**
060         * The actual value is less than or equal to the given value.
061         */
062        LESS_OR_EQUAL, 
063        /**
064         * The actual value is greater than or equal to the given value.
065         */
066        GREATER_OR_EQUAL, 
067        /**
068         * The actual value is greater than the given value.
069         */
070        GREATER_THAN, 
071        /**
072         * added to help the parsers with the generic types
073         */
074        NULL;
075        public static QuantityComparator fromCode(String codeString) throws FHIRException {
076            if (codeString == null || "".equals(codeString))
077                return null;
078        if ("<".equals(codeString))
079          return LESS_THAN;
080        if ("<=".equals(codeString))
081          return LESS_OR_EQUAL;
082        if (">=".equals(codeString))
083          return GREATER_OR_EQUAL;
084        if (">".equals(codeString))
085          return GREATER_THAN;
086        if (Configuration.isAcceptInvalidEnums())
087          return null;
088        else
089          throw new FHIRException("Unknown QuantityComparator code '"+codeString+"'");
090        }
091        public String toCode() {
092          switch (this) {
093            case LESS_THAN: return "<";
094            case LESS_OR_EQUAL: return "<=";
095            case GREATER_OR_EQUAL: return ">=";
096            case GREATER_THAN: return ">";
097            case NULL: return null;
098            default: return "?";
099          }
100        }
101        public String getSystem() {
102          switch (this) {
103            case LESS_THAN: return "http://hl7.org/fhir/quantity-comparator";
104            case LESS_OR_EQUAL: return "http://hl7.org/fhir/quantity-comparator";
105            case GREATER_OR_EQUAL: return "http://hl7.org/fhir/quantity-comparator";
106            case GREATER_THAN: return "http://hl7.org/fhir/quantity-comparator";
107            case NULL: return null;
108            default: return "?";
109          }
110        }
111        public String getDefinition() {
112          switch (this) {
113            case LESS_THAN: return "The actual value is less than the given value.";
114            case LESS_OR_EQUAL: return "The actual value is less than or equal to the given value.";
115            case GREATER_OR_EQUAL: return "The actual value is greater than or equal to the given value.";
116            case GREATER_THAN: return "The actual value is greater than the given value.";
117            case NULL: return null;
118            default: return "?";
119          }
120        }
121        public String getDisplay() {
122          switch (this) {
123            case LESS_THAN: return "Less than";
124            case LESS_OR_EQUAL: return "Less or Equal to";
125            case GREATER_OR_EQUAL: return "Greater or Equal to";
126            case GREATER_THAN: return "Greater than";
127            case NULL: return null;
128            default: return "?";
129          }
130        }
131    }
132
133  public static class QuantityComparatorEnumFactory implements EnumFactory<QuantityComparator> {
134    public QuantityComparator fromCode(String codeString) throws IllegalArgumentException {
135      if (codeString == null || "".equals(codeString))
136            if (codeString == null || "".equals(codeString))
137                return null;
138        if ("<".equals(codeString))
139          return QuantityComparator.LESS_THAN;
140        if ("<=".equals(codeString))
141          return QuantityComparator.LESS_OR_EQUAL;
142        if (">=".equals(codeString))
143          return QuantityComparator.GREATER_OR_EQUAL;
144        if (">".equals(codeString))
145          return QuantityComparator.GREATER_THAN;
146        throw new IllegalArgumentException("Unknown QuantityComparator code '"+codeString+"'");
147        }
148        public Enumeration<QuantityComparator> fromType(Base code) throws FHIRException {
149          if (code == null)
150            return null;
151          if (code.isEmpty())
152            return new Enumeration<QuantityComparator>(this);
153          String codeString = ((PrimitiveType) code).asStringValue();
154          if (codeString == null || "".equals(codeString))
155            return null;
156        if ("<".equals(codeString))
157          return new Enumeration<QuantityComparator>(this, QuantityComparator.LESS_THAN);
158        if ("<=".equals(codeString))
159          return new Enumeration<QuantityComparator>(this, QuantityComparator.LESS_OR_EQUAL);
160        if (">=".equals(codeString))
161          return new Enumeration<QuantityComparator>(this, QuantityComparator.GREATER_OR_EQUAL);
162        if (">".equals(codeString))
163          return new Enumeration<QuantityComparator>(this, QuantityComparator.GREATER_THAN);
164        throw new FHIRException("Unknown QuantityComparator code '"+codeString+"'");
165        }
166    public String toCode(QuantityComparator code) {
167      if (code == QuantityComparator.LESS_THAN)
168        return "<";
169      if (code == QuantityComparator.LESS_OR_EQUAL)
170        return "<=";
171      if (code == QuantityComparator.GREATER_OR_EQUAL)
172        return ">=";
173      if (code == QuantityComparator.GREATER_THAN)
174        return ">";
175      return "?";
176      }
177    public String toSystem(QuantityComparator code) {
178      return code.getSystem();
179      }
180    }
181
182    /**
183     * The value of the measured amount. The value includes an implicit precision in the presentation of the value.
184     */
185    @Child(name = "value", type = {DecimalType.class}, order=0, min=0, max=1, modifier=false, summary=true)
186    @Description(shortDefinition="Numerical value (with implicit precision)", formalDefinition="The value of the measured amount. The value includes an implicit precision in the presentation of the value." )
187    protected DecimalType value;
188
189    /**
190     * How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.
191     */
192    @Child(name = "comparator", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true)
193    @Description(shortDefinition="< | <= | >= | > - how to understand the value", formalDefinition="How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \"<\" , then the real value is < stated value." )
194    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/quantity-comparator")
195    protected Enumeration<QuantityComparator> comparator;
196
197    /**
198     * A human-readable form of the unit.
199     */
200    @Child(name = "unit", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true)
201    @Description(shortDefinition="Unit representation", formalDefinition="A human-readable form of the unit." )
202    protected StringType unit;
203
204    /**
205     * The identification of the system that provides the coded form of the unit.
206     */
207    @Child(name = "system", type = {UriType.class}, order=3, min=0, max=1, modifier=false, summary=true)
208    @Description(shortDefinition="System that defines coded unit form", formalDefinition="The identification of the system that provides the coded form of the unit." )
209    protected UriType system;
210
211    /**
212     * A computer processable form of the unit in some unit representation system.
213     */
214    @Child(name = "code", type = {CodeType.class}, order=4, min=0, max=1, modifier=false, summary=true)
215    @Description(shortDefinition="Coded form of the unit", formalDefinition="A computer processable form of the unit in some unit representation system." )
216    protected CodeType code;
217
218    private static final long serialVersionUID = 1069574054L;
219
220  /**
221   * Constructor
222   */
223    public Quantity() {
224      super();
225    }
226
227 /**
228   * Convenience constructor
229   * 
230   * @param theValue The {@link #setValue(double) value}
231   */
232  public Quantity(double theValue) {
233    setValue(theValue);
234  }
235
236  /**
237   * Convenience constructor
238   * 
239   * @param theValue The {@link #setValue(long) value}
240   */
241  public Quantity(long theValue) {
242    setValue(theValue);
243  }
244  
245  /**
246   * Convenience constructor
247   * 
248   * @param theComparator The {@link #setComparator(QuantityComparator) comparator}
249   * @param theValue The {@link #setValue(BigDecimal) value}
250   * @param theSystem The {@link #setSystem(String)} (the code system for the units}
251   * @param theCode The {@link #setCode(String)} (the code for the units}
252   * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units}
253   */
254  public Quantity(QuantityComparator theComparator, double theValue, String theSystem, String theCode, String theUnit) {
255    setValue(theValue);
256    setComparator(theComparator);
257    setSystem(theSystem);
258    setCode(theCode);
259    setUnit(theUnit);
260  }
261
262  /**
263   * Convenience constructor
264   * 
265   * @param theComparator The {@link #setComparator(QuantityComparator) comparator}
266   * @param theValue The {@link #setValue(BigDecimal) value}
267   * @param theSystem The {@link #setSystem(String)} (the code system for the units}
268   * @param theCode The {@link #setCode(String)} (the code for the units}
269   * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units}
270   */
271  public Quantity(QuantityComparator theComparator, long theValue, String theSystem, String theCode, String theUnit) {
272    setValue(theValue);
273    setComparator(theComparator);
274    setSystem(theSystem);
275    setCode(theCode);
276    setUnit(theUnit);
277  }
278    /**
279     * @return {@link #value} (The value of the measured amount. The value includes an implicit precision in the presentation of the value.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
280     */
281    public DecimalType getValueElement() { 
282      if (this.value == null)
283        if (Configuration.errorOnAutoCreate())
284          throw new Error("Attempt to auto-create Quantity.value");
285        else if (Configuration.doAutoCreate())
286          this.value = new DecimalType(); // bb
287      return this.value;
288    }
289
290    public boolean hasValueElement() { 
291      return this.value != null && !this.value.isEmpty();
292    }
293
294    public boolean hasValue() { 
295      return this.value != null && !this.value.isEmpty();
296    }
297
298    /**
299     * @param value {@link #value} (The value of the measured amount. The value includes an implicit precision in the presentation of the value.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
300     */
301    public Quantity setValueElement(DecimalType value) { 
302      this.value = value;
303      return this;
304    }
305
306    /**
307     * @return The value of the measured amount. The value includes an implicit precision in the presentation of the value.
308     */
309    public BigDecimal getValue() { 
310      return this.value == null ? null : this.value.getValue();
311    }
312
313    /**
314     * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value.
315     */
316    public Quantity setValue(BigDecimal value) { 
317      if (value == null)
318        this.value = null;
319      else {
320        if (this.value == null)
321          this.value = new DecimalType();
322        this.value.setValue(value);
323      }
324      return this;
325    }
326
327    /**
328     * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value.
329     */
330    public Quantity setValue(long value) { 
331          this.value = new DecimalType();
332        this.value.setValue(value);
333      return this;
334    }
335
336    /**
337     * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value.
338     */
339    public Quantity setValue(double value) { 
340          this.value = new DecimalType();
341        this.value.setValue(value);
342      return this;
343    }
344
345    /**
346     * @return {@link #comparator} (How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.). This is the underlying object with id, value and extensions. The accessor "getComparator" gives direct access to the value
347     */
348    public Enumeration<QuantityComparator> getComparatorElement() { 
349      if (this.comparator == null)
350        if (Configuration.errorOnAutoCreate())
351          throw new Error("Attempt to auto-create Quantity.comparator");
352        else if (Configuration.doAutoCreate())
353          this.comparator = new Enumeration<QuantityComparator>(new QuantityComparatorEnumFactory()); // bb
354      return this.comparator;
355    }
356
357    public boolean hasComparatorElement() { 
358      return this.comparator != null && !this.comparator.isEmpty();
359    }
360
361    public boolean hasComparator() { 
362      return this.comparator != null && !this.comparator.isEmpty();
363    }
364
365    /**
366     * @param value {@link #comparator} (How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.). This is the underlying object with id, value and extensions. The accessor "getComparator" gives direct access to the value
367     */
368    public Quantity setComparatorElement(Enumeration<QuantityComparator> value) { 
369      this.comparator = value;
370      return this;
371    }
372
373    /**
374     * @return How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.
375     */
376    public QuantityComparator getComparator() { 
377      return this.comparator == null ? null : this.comparator.getValue();
378    }
379
380    /**
381     * @param value How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.
382     */
383    public Quantity setComparator(QuantityComparator value) { 
384      if (value == null)
385        this.comparator = null;
386      else {
387        if (this.comparator == null)
388          this.comparator = new Enumeration<QuantityComparator>(new QuantityComparatorEnumFactory());
389        this.comparator.setValue(value);
390      }
391      return this;
392    }
393
394    /**
395     * @return {@link #unit} (A human-readable form of the unit.). This is the underlying object with id, value and extensions. The accessor "getUnit" gives direct access to the value
396     */
397    public StringType getUnitElement() { 
398      if (this.unit == null)
399        if (Configuration.errorOnAutoCreate())
400          throw new Error("Attempt to auto-create Quantity.unit");
401        else if (Configuration.doAutoCreate())
402          this.unit = new StringType(); // bb
403      return this.unit;
404    }
405
406    public boolean hasUnitElement() { 
407      return this.unit != null && !this.unit.isEmpty();
408    }
409
410    public boolean hasUnit() { 
411      return this.unit != null && !this.unit.isEmpty();
412    }
413
414    /**
415     * @param value {@link #unit} (A human-readable form of the unit.). This is the underlying object with id, value and extensions. The accessor "getUnit" gives direct access to the value
416     */
417    public Quantity setUnitElement(StringType value) { 
418      this.unit = value;
419      return this;
420    }
421
422    /**
423     * @return A human-readable form of the unit.
424     */
425    public String getUnit() { 
426      return this.unit == null ? null : this.unit.getValue();
427    }
428
429    /**
430     * @param value A human-readable form of the unit.
431     */
432    public Quantity setUnit(String value) { 
433      if (Utilities.noString(value))
434        this.unit = null;
435      else {
436        if (this.unit == null)
437          this.unit = new StringType();
438        this.unit.setValue(value);
439      }
440      return this;
441    }
442
443    /**
444     * @return {@link #system} (The identification of the system that provides the coded form of the unit.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value
445     */
446    public UriType getSystemElement() { 
447      if (this.system == null)
448        if (Configuration.errorOnAutoCreate())
449          throw new Error("Attempt to auto-create Quantity.system");
450        else if (Configuration.doAutoCreate())
451          this.system = new UriType(); // bb
452      return this.system;
453    }
454
455    public boolean hasSystemElement() { 
456      return this.system != null && !this.system.isEmpty();
457    }
458
459    public boolean hasSystem() { 
460      return this.system != null && !this.system.isEmpty();
461    }
462
463    /**
464     * @param value {@link #system} (The identification of the system that provides the coded form of the unit.). This is the underlying object with id, value and extensions. The accessor "getSystem" gives direct access to the value
465     */
466    public Quantity setSystemElement(UriType value) { 
467      this.system = value;
468      return this;
469    }
470
471    /**
472     * @return The identification of the system that provides the coded form of the unit.
473     */
474    public String getSystem() { 
475      return this.system == null ? null : this.system.getValue();
476    }
477
478    /**
479     * @param value The identification of the system that provides the coded form of the unit.
480     */
481    public Quantity setSystem(String value) { 
482      if (Utilities.noString(value))
483        this.system = null;
484      else {
485        if (this.system == null)
486          this.system = new UriType();
487        this.system.setValue(value);
488      }
489      return this;
490    }
491
492    /**
493     * @return {@link #code} (A computer processable form of the unit in some unit representation system.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
494     */
495    public CodeType getCodeElement() { 
496      if (this.code == null)
497        if (Configuration.errorOnAutoCreate())
498          throw new Error("Attempt to auto-create Quantity.code");
499        else if (Configuration.doAutoCreate())
500          this.code = new CodeType(); // bb
501      return this.code;
502    }
503
504    public boolean hasCodeElement() { 
505      return this.code != null && !this.code.isEmpty();
506    }
507
508    public boolean hasCode() { 
509      return this.code != null && !this.code.isEmpty();
510    }
511
512    /**
513     * @param value {@link #code} (A computer processable form of the unit in some unit representation system.). This is the underlying object with id, value and extensions. The accessor "getCode" gives direct access to the value
514     */
515    public Quantity setCodeElement(CodeType value) { 
516      this.code = value;
517      return this;
518    }
519
520    /**
521     * @return A computer processable form of the unit in some unit representation system.
522     */
523    public String getCode() { 
524      return this.code == null ? null : this.code.getValue();
525    }
526
527    /**
528     * @param value A computer processable form of the unit in some unit representation system.
529     */
530    public Quantity setCode(String value) { 
531      if (Utilities.noString(value))
532        this.code = null;
533      else {
534        if (this.code == null)
535          this.code = new CodeType();
536        this.code.setValue(value);
537      }
538      return this;
539    }
540
541      protected void listChildren(List<Property> children) {
542        super.listChildren(children);
543        children.add(new Property("value", "decimal", "The value of the measured amount. The value includes an implicit precision in the presentation of the value.", 0, 1, value));
544        children.add(new Property("comparator", "code", "How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \"<\" , then the real value is < stated value.", 0, 1, comparator));
545        children.add(new Property("unit", "string", "A human-readable form of the unit.", 0, 1, unit));
546        children.add(new Property("system", "uri", "The identification of the system that provides the coded form of the unit.", 0, 1, system));
547        children.add(new Property("code", "code", "A computer processable form of the unit in some unit representation system.", 0, 1, code));
548      }
549
550      @Override
551      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
552        switch (_hash) {
553        case 111972721: /*value*/  return new Property("value", "decimal", "The value of the measured amount. The value includes an implicit precision in the presentation of the value.", 0, 1, value);
554        case -844673834: /*comparator*/  return new Property("comparator", "code", "How the value should be understood and represented - whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is \"<\" , then the real value is < stated value.", 0, 1, comparator);
555        case 3594628: /*unit*/  return new Property("unit", "string", "A human-readable form of the unit.", 0, 1, unit);
556        case -887328209: /*system*/  return new Property("system", "uri", "The identification of the system that provides the coded form of the unit.", 0, 1, system);
557        case 3059181: /*code*/  return new Property("code", "code", "A computer processable form of the unit in some unit representation system.", 0, 1, code);
558        default: return super.getNamedProperty(_hash, _name, _checkValid);
559        }
560
561      }
562
563      @Override
564      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
565        switch (hash) {
566        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DecimalType
567        case -844673834: /*comparator*/ return this.comparator == null ? new Base[0] : new Base[] {this.comparator}; // Enumeration<QuantityComparator>
568        case 3594628: /*unit*/ return this.unit == null ? new Base[0] : new Base[] {this.unit}; // StringType
569        case -887328209: /*system*/ return this.system == null ? new Base[0] : new Base[] {this.system}; // UriType
570        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeType
571        default: return super.getProperty(hash, name, checkValid);
572        }
573
574      }
575
576      @Override
577      public Base setProperty(int hash, String name, Base value) throws FHIRException {
578        switch (hash) {
579        case 111972721: // value
580          this.value = castToDecimal(value); // DecimalType
581          return value;
582        case -844673834: // comparator
583          value = new QuantityComparatorEnumFactory().fromType(castToCode(value));
584          this.comparator = (Enumeration) value; // Enumeration<QuantityComparator>
585          return value;
586        case 3594628: // unit
587          this.unit = castToString(value); // StringType
588          return value;
589        case -887328209: // system
590          this.system = castToUri(value); // UriType
591          return value;
592        case 3059181: // code
593          this.code = castToCode(value); // CodeType
594          return value;
595        default: return super.setProperty(hash, name, value);
596        }
597
598      }
599
600      @Override
601      public Base setProperty(String name, Base value) throws FHIRException {
602        if (name.equals("value")) {
603          this.value = castToDecimal(value); // DecimalType
604        } else if (name.equals("comparator")) {
605          value = new QuantityComparatorEnumFactory().fromType(castToCode(value));
606          this.comparator = (Enumeration) value; // Enumeration<QuantityComparator>
607        } else if (name.equals("unit")) {
608          this.unit = castToString(value); // StringType
609        } else if (name.equals("system")) {
610          this.system = castToUri(value); // UriType
611        } else if (name.equals("code")) {
612          this.code = castToCode(value); // CodeType
613        } else
614          return super.setProperty(name, value);
615        return value;
616      }
617
618      @Override
619      public Base makeProperty(int hash, String name) throws FHIRException {
620        switch (hash) {
621        case 111972721:  return getValueElement();
622        case -844673834:  return getComparatorElement();
623        case 3594628:  return getUnitElement();
624        case -887328209:  return getSystemElement();
625        case 3059181:  return getCodeElement();
626        default: return super.makeProperty(hash, name);
627        }
628
629      }
630
631      @Override
632      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
633        switch (hash) {
634        case 111972721: /*value*/ return new String[] {"decimal"};
635        case -844673834: /*comparator*/ return new String[] {"code"};
636        case 3594628: /*unit*/ return new String[] {"string"};
637        case -887328209: /*system*/ return new String[] {"uri"};
638        case 3059181: /*code*/ return new String[] {"code"};
639        default: return super.getTypesForProperty(hash, name);
640        }
641
642      }
643
644      @Override
645      public Base addChild(String name) throws FHIRException {
646        if (name.equals("value")) {
647          throw new FHIRException("Cannot call addChild on a primitive type Quantity.value");
648        }
649        else if (name.equals("comparator")) {
650          throw new FHIRException("Cannot call addChild on a primitive type Quantity.comparator");
651        }
652        else if (name.equals("unit")) {
653          throw new FHIRException("Cannot call addChild on a primitive type Quantity.unit");
654        }
655        else if (name.equals("system")) {
656          throw new FHIRException("Cannot call addChild on a primitive type Quantity.system");
657        }
658        else if (name.equals("code")) {
659          throw new FHIRException("Cannot call addChild on a primitive type Quantity.code");
660        }
661        else
662          return super.addChild(name);
663      }
664
665  public String fhirType() {
666    return "Quantity";
667
668  }
669
670      public Quantity copy() {
671        Quantity dst = new Quantity();
672        copyValues(dst);
673        return dst;
674      }
675
676      public void copyValues(Quantity dst) {
677        super.copyValues(dst);
678        dst.value = value == null ? null : value.copy();
679        dst.comparator = comparator == null ? null : comparator.copy();
680        dst.unit = unit == null ? null : unit.copy();
681        dst.system = system == null ? null : system.copy();
682        dst.code = code == null ? null : code.copy();
683      }
684
685      protected Quantity typedCopy() {
686        return copy();
687      }
688
689      @Override
690      public boolean equalsDeep(Base other_) {
691        if (!super.equalsDeep(other_))
692          return false;
693        if (!(other_ instanceof Quantity))
694          return false;
695        Quantity o = (Quantity) other_;
696        return compareDeep(value, o.value, true) && compareDeep(comparator, o.comparator, true) && compareDeep(unit, o.unit, true)
697           && compareDeep(system, o.system, true) && compareDeep(code, o.code, true);
698      }
699
700      @Override
701      public boolean equalsShallow(Base other_) {
702        if (!super.equalsShallow(other_))
703          return false;
704        if (!(other_ instanceof Quantity))
705          return false;
706        Quantity o = (Quantity) other_;
707        return compareValues(value, o.value, true) && compareValues(comparator, o.comparator, true) && compareValues(unit, o.unit, true)
708           && compareValues(system, o.system, true) && compareValues(code, o.code, true);
709      }
710
711      public boolean isEmpty() {
712        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(value, comparator, unit
713          , system, code);
714      }
715
716// added from java-adornments.txt:
717
718      @Override
719      public String getVersion() {
720        return null;
721      }
722
723      @Override
724      public boolean hasVersion() {
725        return false;
726      }
727
728      @Override
729      public boolean supportsVersion() {
730        return false;
731      }
732
733      @Override
734      public String getDisplay() {
735        return null;
736      }
737
738      @Override
739      public boolean hasDisplay() {
740        return false;
741      }
742
743      @Override
744      public boolean supportsDisplay() {
745        return false;
746      }
747
748   public static Quantity fromUcum(String v, String code) {
749      Quantity res = new Quantity();
750      res.setValue(new BigDecimal(v));
751      res.setSystem("http://unitsofmeasure.org");
752      res.setCode(code);
753      return res;
754    }
755
756
757
758// end addition
759
760}