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