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