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