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 default: return "?"; 098 } 099 } 100 public String getSystem() { 101 switch (this) { 102 case LESS_THAN: return "http://hl7.org/fhir/quantity-comparator"; 103 case LESS_OR_EQUAL: return "http://hl7.org/fhir/quantity-comparator"; 104 case GREATER_OR_EQUAL: return "http://hl7.org/fhir/quantity-comparator"; 105 case GREATER_THAN: return "http://hl7.org/fhir/quantity-comparator"; 106 default: return "?"; 107 } 108 } 109 public String getDefinition() { 110 switch (this) { 111 case LESS_THAN: return "The actual value is less than the given value."; 112 case LESS_OR_EQUAL: return "The actual value is less than or equal to the given value."; 113 case GREATER_OR_EQUAL: return "The actual value is greater than or equal to the given value."; 114 case GREATER_THAN: return "The actual value is greater than the given value."; 115 default: return "?"; 116 } 117 } 118 public String getDisplay() { 119 switch (this) { 120 case LESS_THAN: return "Less than"; 121 case LESS_OR_EQUAL: return "Less or Equal to"; 122 case GREATER_OR_EQUAL: return "Greater or Equal to"; 123 case GREATER_THAN: return "Greater than"; 124 default: return "?"; 125 } 126 } 127 } 128 129 public static class QuantityComparatorEnumFactory implements EnumFactory<QuantityComparator> { 130 public QuantityComparator fromCode(String codeString) throws IllegalArgumentException { 131 if (codeString == null || "".equals(codeString)) 132 if (codeString == null || "".equals(codeString)) 133 return null; 134 if ("<".equals(codeString)) 135 return QuantityComparator.LESS_THAN; 136 if ("<=".equals(codeString)) 137 return QuantityComparator.LESS_OR_EQUAL; 138 if (">=".equals(codeString)) 139 return QuantityComparator.GREATER_OR_EQUAL; 140 if (">".equals(codeString)) 141 return QuantityComparator.GREATER_THAN; 142 throw new IllegalArgumentException("Unknown QuantityComparator code '"+codeString+"'"); 143 } 144 public Enumeration<QuantityComparator> fromType(Base code) throws FHIRException { 145 if (code == null) 146 return null; 147 if (code.isEmpty()) 148 return new Enumeration<QuantityComparator>(this); 149 String codeString = ((PrimitiveType) code).asStringValue(); 150 if (codeString == null || "".equals(codeString)) 151 return null; 152 if ("<".equals(codeString)) 153 return new Enumeration<QuantityComparator>(this, QuantityComparator.LESS_THAN); 154 if ("<=".equals(codeString)) 155 return new Enumeration<QuantityComparator>(this, QuantityComparator.LESS_OR_EQUAL); 156 if (">=".equals(codeString)) 157 return new Enumeration<QuantityComparator>(this, QuantityComparator.GREATER_OR_EQUAL); 158 if (">".equals(codeString)) 159 return new Enumeration<QuantityComparator>(this, QuantityComparator.GREATER_THAN); 160 throw new FHIRException("Unknown QuantityComparator code '"+codeString+"'"); 161 } 162 public String toCode(QuantityComparator code) { 163 if (code == QuantityComparator.LESS_THAN) 164 return "<"; 165 if (code == QuantityComparator.LESS_OR_EQUAL) 166 return "<="; 167 if (code == QuantityComparator.GREATER_OR_EQUAL) 168 return ">="; 169 if (code == QuantityComparator.GREATER_THAN) 170 return ">"; 171 return "?"; 172 } 173 public String toSystem(QuantityComparator code) { 174 return code.getSystem(); 175 } 176 } 177 178 /** 179 * The value of the measured amount. The value includes an implicit precision in the presentation of the value. 180 */ 181 @Child(name = "value", type = {DecimalType.class}, order=0, min=0, max=1, modifier=false, summary=true) 182 @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." ) 183 protected DecimalType value; 184 185 /** 186 * 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. 187 */ 188 @Child(name = "comparator", type = {CodeType.class}, order=1, min=0, max=1, modifier=true, summary=true) 189 @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." ) 190 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/quantity-comparator") 191 protected Enumeration<QuantityComparator> comparator; 192 193 /** 194 * A human-readable form of the unit. 195 */ 196 @Child(name = "unit", type = {StringType.class}, order=2, min=0, max=1, modifier=false, summary=true) 197 @Description(shortDefinition="Unit representation", formalDefinition="A human-readable form of the unit." ) 198 protected StringType unit; 199 200 /** 201 * The identification of the system that provides the coded form of the unit. 202 */ 203 @Child(name = "system", type = {UriType.class}, order=3, min=0, max=1, modifier=false, summary=true) 204 @Description(shortDefinition="System that defines coded unit form", formalDefinition="The identification of the system that provides the coded form of the unit." ) 205 protected UriType system; 206 207 /** 208 * A computer processable form of the unit in some unit representation system. 209 */ 210 @Child(name = "code", type = {CodeType.class}, order=4, min=0, max=1, modifier=false, summary=true) 211 @Description(shortDefinition="Coded form of the unit", formalDefinition="A computer processable form of the unit in some unit representation system." ) 212 protected CodeType code; 213 214 private static final long serialVersionUID = 1069574054L; 215 216 /** 217 * Constructor 218 */ 219 public Quantity() { 220 super(); 221 } 222 223 /** 224 * Convenience constructor 225 * 226 * @param theValue The {@link #setValue(double) value} 227 */ 228 public Quantity(double theValue) { 229 setValue(theValue); 230 } 231 232 /** 233 * Convenience constructor 234 * 235 * @param theValue The {@link #setValue(long) value} 236 */ 237 public Quantity(long theValue) { 238 setValue(theValue); 239 } 240 241 /** 242 * Convenience constructor 243 * 244 * @param theComparator The {@link #setComparator(QuantityComparator) comparator} 245 * @param theValue The {@link #setValue(BigDecimal) value} 246 * @param theSystem The {@link #setSystem(String)} (the code system for the units} 247 * @param theCode The {@link #setCode(String)} (the code for the units} 248 * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units} 249 */ 250 public Quantity(QuantityComparator theComparator, double theValue, String theSystem, String theCode, String theUnit) { 251 setValue(theValue); 252 setComparator(theComparator); 253 setSystem(theSystem); 254 setCode(theCode); 255 setUnit(theUnit); 256 } 257 258 /** 259 * Convenience constructor 260 * 261 * @param theComparator The {@link #setComparator(QuantityComparator) comparator} 262 * @param theValue The {@link #setValue(BigDecimal) value} 263 * @param theSystem The {@link #setSystem(String)} (the code system for the units} 264 * @param theCode The {@link #setCode(String)} (the code for the units} 265 * @param theUnit The {@link #setUnit(String)} (the human readable display name for the units} 266 */ 267 public Quantity(QuantityComparator theComparator, long theValue, String theSystem, String theCode, String theUnit) { 268 setValue(theValue); 269 setComparator(theComparator); 270 setSystem(theSystem); 271 setCode(theCode); 272 setUnit(theUnit); 273 } 274 /** 275 * @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 276 */ 277 public DecimalType getValueElement() { 278 if (this.value == null) 279 if (Configuration.errorOnAutoCreate()) 280 throw new Error("Attempt to auto-create Quantity.value"); 281 else if (Configuration.doAutoCreate()) 282 this.value = new DecimalType(); // bb 283 return this.value; 284 } 285 286 public boolean hasValueElement() { 287 return this.value != null && !this.value.isEmpty(); 288 } 289 290 public boolean hasValue() { 291 return this.value != null && !this.value.isEmpty(); 292 } 293 294 /** 295 * @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 296 */ 297 public Quantity setValueElement(DecimalType value) { 298 this.value = value; 299 return this; 300 } 301 302 /** 303 * @return The value of the measured amount. The value includes an implicit precision in the presentation of the value. 304 */ 305 public BigDecimal getValue() { 306 return this.value == null ? null : this.value.getValue(); 307 } 308 309 /** 310 * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value. 311 */ 312 public Quantity setValue(BigDecimal value) { 313 if (value == null) 314 this.value = null; 315 else { 316 if (this.value == null) 317 this.value = new DecimalType(); 318 this.value.setValue(value); 319 } 320 return this; 321 } 322 323 /** 324 * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value. 325 */ 326 public Quantity setValue(long value) { 327 this.value = new DecimalType(); 328 this.value.setValue(value); 329 return this; 330 } 331 332 /** 333 * @param value The value of the measured amount. The value includes an implicit precision in the presentation of the value. 334 */ 335 public Quantity setValue(double value) { 336 this.value = new DecimalType(); 337 this.value.setValue(value); 338 return this; 339 } 340 341 /** 342 * @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 343 */ 344 public Enumeration<QuantityComparator> getComparatorElement() { 345 if (this.comparator == null) 346 if (Configuration.errorOnAutoCreate()) 347 throw new Error("Attempt to auto-create Quantity.comparator"); 348 else if (Configuration.doAutoCreate()) 349 this.comparator = new Enumeration<QuantityComparator>(new QuantityComparatorEnumFactory()); // bb 350 return this.comparator; 351 } 352 353 public boolean hasComparatorElement() { 354 return this.comparator != null && !this.comparator.isEmpty(); 355 } 356 357 public boolean hasComparator() { 358 return this.comparator != null && !this.comparator.isEmpty(); 359 } 360 361 /** 362 * @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 363 */ 364 public Quantity setComparatorElement(Enumeration<QuantityComparator> value) { 365 this.comparator = value; 366 return this; 367 } 368 369 /** 370 * @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. 371 */ 372 public QuantityComparator getComparator() { 373 return this.comparator == null ? null : this.comparator.getValue(); 374 } 375 376 /** 377 * @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. 378 */ 379 public Quantity setComparator(QuantityComparator value) { 380 if (value == null) 381 this.comparator = null; 382 else { 383 if (this.comparator == null) 384 this.comparator = new Enumeration<QuantityComparator>(new QuantityComparatorEnumFactory()); 385 this.comparator.setValue(value); 386 } 387 return this; 388 } 389 390 /** 391 * @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 392 */ 393 public StringType getUnitElement() { 394 if (this.unit == null) 395 if (Configuration.errorOnAutoCreate()) 396 throw new Error("Attempt to auto-create Quantity.unit"); 397 else if (Configuration.doAutoCreate()) 398 this.unit = new StringType(); // bb 399 return this.unit; 400 } 401 402 public boolean hasUnitElement() { 403 return this.unit != null && !this.unit.isEmpty(); 404 } 405 406 public boolean hasUnit() { 407 return this.unit != null && !this.unit.isEmpty(); 408 } 409 410 /** 411 * @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 412 */ 413 public Quantity setUnitElement(StringType value) { 414 this.unit = value; 415 return this; 416 } 417 418 /** 419 * @return A human-readable form of the unit. 420 */ 421 public String getUnit() { 422 return this.unit == null ? null : this.unit.getValue(); 423 } 424 425 /** 426 * @param value A human-readable form of the unit. 427 */ 428 public Quantity setUnit(String value) { 429 if (Utilities.noString(value)) 430 this.unit = null; 431 else { 432 if (this.unit == null) 433 this.unit = new StringType(); 434 this.unit.setValue(value); 435 } 436 return this; 437 } 438 439 /** 440 * @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 441 */ 442 public UriType getSystemElement() { 443 if (this.system == null) 444 if (Configuration.errorOnAutoCreate()) 445 throw new Error("Attempt to auto-create Quantity.system"); 446 else if (Configuration.doAutoCreate()) 447 this.system = new UriType(); // bb 448 return this.system; 449 } 450 451 public boolean hasSystemElement() { 452 return this.system != null && !this.system.isEmpty(); 453 } 454 455 public boolean hasSystem() { 456 return this.system != null && !this.system.isEmpty(); 457 } 458 459 /** 460 * @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 461 */ 462 public Quantity setSystemElement(UriType value) { 463 this.system = value; 464 return this; 465 } 466 467 /** 468 * @return The identification of the system that provides the coded form of the unit. 469 */ 470 public String getSystem() { 471 return this.system == null ? null : this.system.getValue(); 472 } 473 474 /** 475 * @param value The identification of the system that provides the coded form of the unit. 476 */ 477 public Quantity setSystem(String value) { 478 if (Utilities.noString(value)) 479 this.system = null; 480 else { 481 if (this.system == null) 482 this.system = new UriType(); 483 this.system.setValue(value); 484 } 485 return this; 486 } 487 488 /** 489 * @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 490 */ 491 public CodeType getCodeElement() { 492 if (this.code == null) 493 if (Configuration.errorOnAutoCreate()) 494 throw new Error("Attempt to auto-create Quantity.code"); 495 else if (Configuration.doAutoCreate()) 496 this.code = new CodeType(); // bb 497 return this.code; 498 } 499 500 public boolean hasCodeElement() { 501 return this.code != null && !this.code.isEmpty(); 502 } 503 504 public boolean hasCode() { 505 return this.code != null && !this.code.isEmpty(); 506 } 507 508 /** 509 * @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 510 */ 511 public Quantity setCodeElement(CodeType value) { 512 this.code = value; 513 return this; 514 } 515 516 /** 517 * @return A computer processable form of the unit in some unit representation system. 518 */ 519 public String getCode() { 520 return this.code == null ? null : this.code.getValue(); 521 } 522 523 /** 524 * @param value A computer processable form of the unit in some unit representation system. 525 */ 526 public Quantity setCode(String value) { 527 if (Utilities.noString(value)) 528 this.code = null; 529 else { 530 if (this.code == null) 531 this.code = new CodeType(); 532 this.code.setValue(value); 533 } 534 return this; 535 } 536 537 protected void listChildren(List<Property> children) { 538 super.listChildren(children); 539 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)); 540 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)); 541 children.add(new Property("unit", "string", "A human-readable form of the unit.", 0, 1, unit)); 542 children.add(new Property("system", "uri", "The identification of the system that provides the coded form of the unit.", 0, 1, system)); 543 children.add(new Property("code", "code", "A computer processable form of the unit in some unit representation system.", 0, 1, code)); 544 } 545 546 @Override 547 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 548 switch (_hash) { 549 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); 550 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); 551 case 3594628: /*unit*/ return new Property("unit", "string", "A human-readable form of the unit.", 0, 1, unit); 552 case -887328209: /*system*/ return new Property("system", "uri", "The identification of the system that provides the coded form of the unit.", 0, 1, system); 553 case 3059181: /*code*/ return new Property("code", "code", "A computer processable form of the unit in some unit representation system.", 0, 1, code); 554 default: return super.getNamedProperty(_hash, _name, _checkValid); 555 } 556 557 } 558 559 @Override 560 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 561 switch (hash) { 562 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DecimalType 563 case -844673834: /*comparator*/ return this.comparator == null ? new Base[0] : new Base[] {this.comparator}; // Enumeration<QuantityComparator> 564 case 3594628: /*unit*/ return this.unit == null ? new Base[0] : new Base[] {this.unit}; // StringType 565 case -887328209: /*system*/ return this.system == null ? new Base[0] : new Base[] {this.system}; // UriType 566 case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeType 567 default: return super.getProperty(hash, name, checkValid); 568 } 569 570 } 571 572 @Override 573 public Base setProperty(int hash, String name, Base value) throws FHIRException { 574 switch (hash) { 575 case 111972721: // value 576 this.value = castToDecimal(value); // DecimalType 577 return value; 578 case -844673834: // comparator 579 value = new QuantityComparatorEnumFactory().fromType(castToCode(value)); 580 this.comparator = (Enumeration) value; // Enumeration<QuantityComparator> 581 return value; 582 case 3594628: // unit 583 this.unit = castToString(value); // StringType 584 return value; 585 case -887328209: // system 586 this.system = castToUri(value); // UriType 587 return value; 588 case 3059181: // code 589 this.code = castToCode(value); // CodeType 590 return value; 591 default: return super.setProperty(hash, name, value); 592 } 593 594 } 595 596 @Override 597 public Base setProperty(String name, Base value) throws FHIRException { 598 if (name.equals("value")) { 599 this.value = castToDecimal(value); // DecimalType 600 } else if (name.equals("comparator")) { 601 value = new QuantityComparatorEnumFactory().fromType(castToCode(value)); 602 this.comparator = (Enumeration) value; // Enumeration<QuantityComparator> 603 } else if (name.equals("unit")) { 604 this.unit = castToString(value); // StringType 605 } else if (name.equals("system")) { 606 this.system = castToUri(value); // UriType 607 } else if (name.equals("code")) { 608 this.code = castToCode(value); // CodeType 609 } else 610 return super.setProperty(name, value); 611 return value; 612 } 613 614 @Override 615 public Base makeProperty(int hash, String name) throws FHIRException { 616 switch (hash) { 617 case 111972721: return getValueElement(); 618 case -844673834: return getComparatorElement(); 619 case 3594628: return getUnitElement(); 620 case -887328209: return getSystemElement(); 621 case 3059181: return getCodeElement(); 622 default: return super.makeProperty(hash, name); 623 } 624 625 } 626 627 @Override 628 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 629 switch (hash) { 630 case 111972721: /*value*/ return new String[] {"decimal"}; 631 case -844673834: /*comparator*/ return new String[] {"code"}; 632 case 3594628: /*unit*/ return new String[] {"string"}; 633 case -887328209: /*system*/ return new String[] {"uri"}; 634 case 3059181: /*code*/ return new String[] {"code"}; 635 default: return super.getTypesForProperty(hash, name); 636 } 637 638 } 639 640 @Override 641 public Base addChild(String name) throws FHIRException { 642 if (name.equals("value")) { 643 throw new FHIRException("Cannot call addChild on a primitive type Quantity.value"); 644 } 645 else if (name.equals("comparator")) { 646 throw new FHIRException("Cannot call addChild on a primitive type Quantity.comparator"); 647 } 648 else if (name.equals("unit")) { 649 throw new FHIRException("Cannot call addChild on a primitive type Quantity.unit"); 650 } 651 else if (name.equals("system")) { 652 throw new FHIRException("Cannot call addChild on a primitive type Quantity.system"); 653 } 654 else if (name.equals("code")) { 655 throw new FHIRException("Cannot call addChild on a primitive type Quantity.code"); 656 } 657 else 658 return super.addChild(name); 659 } 660 661 public String fhirType() { 662 return "Quantity"; 663 664 } 665 666 public Quantity copy() { 667 Quantity dst = new Quantity(); 668 copyValues(dst); 669 return dst; 670 } 671 672 public void copyValues(Quantity dst) { 673 super.copyValues(dst); 674 dst.value = value == null ? null : value.copy(); 675 dst.comparator = comparator == null ? null : comparator.copy(); 676 dst.unit = unit == null ? null : unit.copy(); 677 dst.system = system == null ? null : system.copy(); 678 dst.code = code == null ? null : code.copy(); 679 } 680 681 protected Quantity typedCopy() { 682 return copy(); 683 } 684 685 @Override 686 public boolean equalsDeep(Base other_) { 687 if (!super.equalsDeep(other_)) 688 return false; 689 if (!(other_ instanceof Quantity)) 690 return false; 691 Quantity o = (Quantity) other_; 692 return compareDeep(value, o.value, true) && compareDeep(comparator, o.comparator, true) && compareDeep(unit, o.unit, true) 693 && compareDeep(system, o.system, true) && compareDeep(code, o.code, true); 694 } 695 696 @Override 697 public boolean equalsShallow(Base other_) { 698 if (!super.equalsShallow(other_)) 699 return false; 700 if (!(other_ instanceof Quantity)) 701 return false; 702 Quantity o = (Quantity) other_; 703 return compareValues(value, o.value, true) && compareValues(comparator, o.comparator, true) && compareValues(unit, o.unit, true) 704 && compareValues(system, o.system, true) && compareValues(code, o.code, true); 705 } 706 707 public boolean isEmpty() { 708 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(value, comparator, unit 709 , system, code); 710 } 711 712// added from java-adornments.txt: 713 714 @Override 715 public String getVersion() { 716 return null; 717 } 718 719 @Override 720 public boolean hasVersion() { 721 return false; 722 } 723 724 @Override 725 public boolean supportsVersion() { 726 return false; 727 } 728 729 @Override 730 public String getDisplay() { 731 return null; 732 } 733 734 @Override 735 public boolean hasDisplay() { 736 return false; 737 } 738 739 @Override 740 public boolean supportsDisplay() { 741 return false; 742 } 743 744 public static Quantity fromUcum(String v, String code) { 745 Quantity res = new Quantity(); 746 res.setValue(new BigDecimal(v)); 747 res.setSystem("http://unitsofmeasure.org"); 748 res.setCode(code); 749 return res; 750 } 751 752 753 754// end addition 755 756}