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