001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017package ca.uhn.fhir.model.dstu2.composite; 018 019import java.net.URI; 020import java.math.BigDecimal; 021import org.apache.commons.lang3.StringUtils; 022import java.util.*; 023import ca.uhn.fhir.model.api.*; 024import ca.uhn.fhir.model.primitive.*; 025import ca.uhn.fhir.model.api.annotation.*; 026import ca.uhn.fhir.model.base.composite.*; 027 028import ca.uhn.fhir.model.dstu2.valueset.AddressTypeEnum; 029import ca.uhn.fhir.model.dstu2.valueset.AddressUseEnum; 030import ca.uhn.fhir.model.dstu2.valueset.AggregationModeEnum; 031import ca.uhn.fhir.model.dstu2.valueset.BindingStrengthEnum; 032import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt; 033import ca.uhn.fhir.model.dstu2.composite.CodingDt; 034import ca.uhn.fhir.model.dstu2.valueset.ConstraintSeverityEnum; 035import ca.uhn.fhir.model.dstu2.valueset.ContactPointSystemEnum; 036import ca.uhn.fhir.model.dstu2.valueset.ContactPointUseEnum; 037import ca.uhn.fhir.model.dstu2.resource.Device; 038import ca.uhn.fhir.model.dstu2.valueset.EventTimingEnum; 039import ca.uhn.fhir.model.dstu2.valueset.IdentifierTypeCodesEnum; 040import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum; 041import ca.uhn.fhir.model.dstu2.valueset.NameUseEnum; 042import ca.uhn.fhir.model.dstu2.resource.Organization; 043import ca.uhn.fhir.model.dstu2.resource.Patient; 044import ca.uhn.fhir.model.dstu2.composite.PeriodDt; 045import ca.uhn.fhir.model.dstu2.resource.Practitioner; 046import ca.uhn.fhir.model.dstu2.valueset.PropertyRepresentationEnum; 047import ca.uhn.fhir.model.dstu2.valueset.QuantityComparatorEnum; 048import ca.uhn.fhir.model.dstu2.composite.QuantityDt; 049import ca.uhn.fhir.model.dstu2.composite.RangeDt; 050import ca.uhn.fhir.model.dstu2.resource.RelatedPerson; 051import ca.uhn.fhir.model.dstu2.valueset.SignatureTypeCodesEnum; 052import ca.uhn.fhir.model.dstu2.valueset.SlicingRulesEnum; 053import ca.uhn.fhir.model.api.TemporalPrecisionEnum; 054import ca.uhn.fhir.model.dstu2.valueset.TimingAbbreviationEnum; 055import ca.uhn.fhir.model.dstu2.valueset.UnitsOfTimeEnum; 056import ca.uhn.fhir.model.dstu2.resource.ValueSet; 057import ca.uhn.fhir.model.dstu2.composite.BoundCodeableConceptDt; 058import ca.uhn.fhir.model.dstu2.composite.DurationDt; 059import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt; 060import ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt; 061import ca.uhn.fhir.model.primitive.Base64BinaryDt; 062import ca.uhn.fhir.model.primitive.BooleanDt; 063import ca.uhn.fhir.model.primitive.BoundCodeDt; 064import ca.uhn.fhir.model.primitive.CodeDt; 065import ca.uhn.fhir.model.primitive.DateTimeDt; 066import ca.uhn.fhir.model.primitive.DecimalDt; 067import ca.uhn.fhir.model.primitive.IdDt; 068import ca.uhn.fhir.model.primitive.InstantDt; 069import ca.uhn.fhir.model.primitive.IntegerDt; 070import ca.uhn.fhir.model.primitive.MarkdownDt; 071import ca.uhn.fhir.model.primitive.PositiveIntDt; 072import ca.uhn.fhir.model.primitive.StringDt; 073import ca.uhn.fhir.model.primitive.UnsignedIntDt; 074import ca.uhn.fhir.model.primitive.UriDt; 075 076/** 077 * HAPI/FHIR <b>QuantityDt</b> Datatype 078 * () 079 * 080 * <p> 081 * <b>Definition:</b> 082 * 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 083 * </p> 084 * 085 * <p> 086 * <b>Requirements:</b> 087 * Need to able to capture all sorts of measured values, even if the measured value are not precisely quantified. Values include exact measures such as 3.51g, customary units such as 3 tablets, and currencies such as $100.32USD 088 * </p> 089 */ 090@DatatypeDef(name="QuantityDt") 091public class QuantityDt 092 extends BaseQuantityDt implements ICompositeDatatype{ 093 094 /** 095 * Constructor 096 */ 097 public QuantityDt() { 098 // nothing 099 } 100 101 102 /** 103 * Constructor 104 */ 105 @SimpleSetter 106 public QuantityDt(@SimpleSetter.Parameter(name="theValue") double theValue) { 107 setValue(theValue); 108 } 109 110 /** 111 * Constructor 112 */ 113 @SimpleSetter 114 public QuantityDt(@SimpleSetter.Parameter(name="theValue") long theValue) { 115 setValue(theValue); 116 } 117 118 /** 119 * Constructor 120 */ 121 @SimpleSetter 122 public QuantityDt(@SimpleSetter.Parameter(name = "theComparator") QuantityComparatorEnum theComparator, @SimpleSetter.Parameter(name = "theValue") double theValue, 123 @SimpleSetter.Parameter(name = "theUnits") String theUnits) { 124 setValue(theValue); 125 setComparator(theComparator); 126 setUnits(theUnits); 127 } 128 129 /** 130 * Constructor 131 */ 132 @SimpleSetter 133 public QuantityDt(@SimpleSetter.Parameter(name = "theComparator") QuantityComparatorEnum theComparator, @SimpleSetter.Parameter(name = "theValue") long theValue, 134 @SimpleSetter.Parameter(name = "theUnits") String theUnits) { 135 setValue(theValue); 136 setComparator(theComparator); 137 setUnits(theUnits); 138 } 139 140 /** 141 * Constructor 142 */ 143 @SimpleSetter 144 public QuantityDt(@SimpleSetter.Parameter(name="theComparator") QuantityComparatorEnum theComparator, @SimpleSetter.Parameter(name="theValue") double theValue, @SimpleSetter.Parameter(name="theSystem") String theSystem, @SimpleSetter.Parameter(name="theUnits") String theUnits) { 145 setValue(theValue); 146 setComparator(theComparator); 147 setSystem(theSystem); 148 setUnits(theUnits); 149 } 150 151 /** 152 * Constructor 153 */ 154 @SimpleSetter 155 public QuantityDt(@SimpleSetter.Parameter(name="theComparator") QuantityComparatorEnum theComparator, @SimpleSetter.Parameter(name="theValue") long theValue, @SimpleSetter.Parameter(name="theSystem") String theSystem, @SimpleSetter.Parameter(name="theUnits") String theUnits) { 156 setValue(theValue); 157 setComparator(theComparator); 158 setSystem(theSystem); 159 setUnits(theUnits); 160 } 161 162 /** 163 * @deprecated Use {@link #setUnit(String)} instead - Quantity.units was renamed to Quantity.unit in DSTU2 164 */ 165 @Deprecated 166 @Override 167 public BaseQuantityDt setUnits(String theString) { 168 return setUnit(theString); 169 } 170 171 /** 172 * @deprecated Use {@link #getUnitElement()} - Quantity.units was renamed to Quantity.unit in DSTU2 173 */ 174 @Deprecated 175 @Override 176 public StringDt getUnitsElement() { 177 return getUnitElement(); 178 } 179 180 @Child(name="value", type=DecimalDt.class, order=0, min=0, max=1, summary=true, modifier=false) 181 @Description( 182 shortDefinition="", 183 formalDefinition="The value of the measured amount. The value includes an implicit precision in the presentation of the value" 184 ) 185 private DecimalDt myValue; 186 187 @Child(name="comparator", type=CodeDt.class, order=1, min=0, max=1, summary=true, modifier=true) 188 @Description( 189 shortDefinition="", 190 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" 191 ) 192 private BoundCodeDt<QuantityComparatorEnum> myComparator; 193 194 @Child(name="unit", type=StringDt.class, order=2, min=0, max=1, summary=true, modifier=false) 195 @Description( 196 shortDefinition="", 197 formalDefinition="A human-readable form of the unit" 198 ) 199 private StringDt myUnit; 200 201 @Child(name="system", type=UriDt.class, order=3, min=0, max=1, summary=true, modifier=false) 202 @Description( 203 shortDefinition="", 204 formalDefinition="The identification of the system that provides the coded form of the unit" 205 ) 206 private UriDt mySystem; 207 208 @Child(name="code", type=CodeDt.class, order=4, min=0, max=1, summary=true, modifier=false) 209 @Description( 210 shortDefinition="", 211 formalDefinition="A computer processable form of the unit in some unit representation system" 212 ) 213 private CodeDt myCode; 214 215 216 @Override 217 public boolean isEmpty() { 218 return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myValue, myComparator, myUnit, mySystem, myCode); 219 } 220 221 @Override 222 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) { 223 return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myValue, myComparator, myUnit, mySystem, myCode); 224 } 225 226 /** 227 * Gets the value(s) for <b>value</b> (). 228 * creating it if it does 229 * not exist. Will not return <code>null</code>. 230 * 231 * <p> 232 * <b>Definition:</b> 233 * The value of the measured amount. The value includes an implicit precision in the presentation of the value 234 * </p> 235 */ 236 public DecimalDt getValueElement() { 237 if (myValue == null) { 238 myValue = new DecimalDt(); 239 } 240 return myValue; 241 } 242 243 244 /** 245 * Gets the value(s) for <b>value</b> (). 246 * creating it if it does 247 * not exist. Will not return <code>null</code>. 248 * 249 * <p> 250 * <b>Definition:</b> 251 * The value of the measured amount. The value includes an implicit precision in the presentation of the value 252 * </p> 253 */ 254 public BigDecimal getValue() { 255 return getValueElement().getValue(); 256 } 257 258 /** 259 * Sets the value(s) for <b>value</b> () 260 * 261 * <p> 262 * <b>Definition:</b> 263 * The value of the measured amount. The value includes an implicit precision in the presentation of the value 264 * </p> 265 */ 266 public QuantityDt setValue(DecimalDt theValue) { 267 myValue = theValue; 268 return this; 269 } 270 271 272 273 /** 274 * Sets the value for <b>value</b> () 275 * 276 * <p> 277 * <b>Definition:</b> 278 * The value of the measured amount. The value includes an implicit precision in the presentation of the value 279 * </p> 280 */ 281 public QuantityDt setValue( long theValue) { 282 myValue = new DecimalDt(theValue); 283 return this; 284 } 285 286 /** 287 * Sets the value for <b>value</b> () 288 * 289 * <p> 290 * <b>Definition:</b> 291 * The value of the measured amount. The value includes an implicit precision in the presentation of the value 292 * </p> 293 */ 294 public QuantityDt setValue( double theValue) { 295 myValue = new DecimalDt(theValue); 296 return this; 297 } 298 299 /** 300 * Sets the value for <b>value</b> () 301 * 302 * <p> 303 * <b>Definition:</b> 304 * The value of the measured amount. The value includes an implicit precision in the presentation of the value 305 * </p> 306 */ 307 public QuantityDt setValue( java.math.BigDecimal theValue) { 308 myValue = new DecimalDt(theValue); 309 return this; 310 } 311 312 313 /** 314 * Gets the value(s) for <b>comparator</b> (). 315 * creating it if it does 316 * not exist. Will not return <code>null</code>. 317 * 318 * <p> 319 * <b>Definition:</b> 320 * 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 321 * </p> 322 */ 323 public BoundCodeDt<QuantityComparatorEnum> getComparatorElement() { 324 if (myComparator == null) { 325 myComparator = new BoundCodeDt<QuantityComparatorEnum>(QuantityComparatorEnum.VALUESET_BINDER); 326 } 327 return myComparator; 328 } 329 330 331 /** 332 * Gets the value(s) for <b>comparator</b> (). 333 * creating it if it does 334 * not exist. Will not return <code>null</code>. 335 * 336 * <p> 337 * <b>Definition:</b> 338 * 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 339 * </p> 340 */ 341 public String getComparator() { 342 return getComparatorElement().getValue(); 343 } 344 345 /** 346 * Sets the value(s) for <b>comparator</b> () 347 * 348 * <p> 349 * <b>Definition:</b> 350 * 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 351 * </p> 352 */ 353 public QuantityDt setComparator(BoundCodeDt<QuantityComparatorEnum> theValue) { 354 myComparator = theValue; 355 return this; 356 } 357 358 359 360 /** 361 * Sets the value(s) for <b>comparator</b> () 362 * 363 * <p> 364 * <b>Definition:</b> 365 * 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 366 * </p> 367 */ 368 public QuantityDt setComparator(QuantityComparatorEnum theValue) { 369 setComparator(new BoundCodeDt<QuantityComparatorEnum>(QuantityComparatorEnum.VALUESET_BINDER, theValue)); 370 371/* 372 getComparatorElement().setValueAsEnum(theValue); 373*/ 374 return this; 375 } 376 377 378 /** 379 * Gets the value(s) for <b>unit</b> (). 380 * creating it if it does 381 * not exist. Will not return <code>null</code>. 382 * 383 * <p> 384 * <b>Definition:</b> 385 * A human-readable form of the unit 386 * </p> 387 */ 388 public StringDt getUnitElement() { 389 if (myUnit == null) { 390 myUnit = new StringDt(); 391 } 392 return myUnit; 393 } 394 395 396 /** 397 * Gets the value(s) for <b>unit</b> (). 398 * creating it if it does 399 * not exist. Will not return <code>null</code>. 400 * 401 * <p> 402 * <b>Definition:</b> 403 * A human-readable form of the unit 404 * </p> 405 */ 406 public String getUnit() { 407 return getUnitElement().getValue(); 408 } 409 410 /** 411 * Sets the value(s) for <b>unit</b> () 412 * 413 * <p> 414 * <b>Definition:</b> 415 * A human-readable form of the unit 416 * </p> 417 */ 418 public QuantityDt setUnit(StringDt theValue) { 419 myUnit = theValue; 420 return this; 421 } 422 423 424 425 /** 426 * Sets the value for <b>unit</b> () 427 * 428 * <p> 429 * <b>Definition:</b> 430 * A human-readable form of the unit 431 * </p> 432 */ 433 public QuantityDt setUnit( String theString) { 434 myUnit = new StringDt(theString); 435 return this; 436 } 437 438 439 /** 440 * Gets the value(s) for <b>system</b> (). 441 * creating it if it does 442 * not exist. Will not return <code>null</code>. 443 * 444 * <p> 445 * <b>Definition:</b> 446 * The identification of the system that provides the coded form of the unit 447 * </p> 448 */ 449 public UriDt getSystemElement() { 450 if (mySystem == null) { 451 mySystem = new UriDt(); 452 } 453 return mySystem; 454 } 455 456 457 /** 458 * Gets the value(s) for <b>system</b> (). 459 * creating it if it does 460 * not exist. Will not return <code>null</code>. 461 * 462 * <p> 463 * <b>Definition:</b> 464 * The identification of the system that provides the coded form of the unit 465 * </p> 466 */ 467 public String getSystem() { 468 return getSystemElement().getValue(); 469 } 470 471 /** 472 * Sets the value(s) for <b>system</b> () 473 * 474 * <p> 475 * <b>Definition:</b> 476 * The identification of the system that provides the coded form of the unit 477 * </p> 478 */ 479 public QuantityDt setSystem(UriDt theValue) { 480 mySystem = theValue; 481 return this; 482 } 483 484 485 486 /** 487 * Sets the value for <b>system</b> () 488 * 489 * <p> 490 * <b>Definition:</b> 491 * The identification of the system that provides the coded form of the unit 492 * </p> 493 */ 494 public QuantityDt setSystem( String theUri) { 495 mySystem = new UriDt(theUri); 496 return this; 497 } 498 499 500 /** 501 * Gets the value(s) for <b>code</b> (). 502 * creating it if it does 503 * not exist. Will not return <code>null</code>. 504 * 505 * <p> 506 * <b>Definition:</b> 507 * A computer processable form of the unit in some unit representation system 508 * </p> 509 */ 510 public CodeDt getCodeElement() { 511 if (myCode == null) { 512 myCode = new CodeDt(); 513 } 514 return myCode; 515 } 516 517 518 /** 519 * Gets the value(s) for <b>code</b> (). 520 * creating it if it does 521 * not exist. Will not return <code>null</code>. 522 * 523 * <p> 524 * <b>Definition:</b> 525 * A computer processable form of the unit in some unit representation system 526 * </p> 527 */ 528 public String getCode() { 529 return getCodeElement().getValue(); 530 } 531 532 /** 533 * Sets the value(s) for <b>code</b> () 534 * 535 * <p> 536 * <b>Definition:</b> 537 * A computer processable form of the unit in some unit representation system 538 * </p> 539 */ 540 public QuantityDt setCode(CodeDt theValue) { 541 myCode = theValue; 542 return this; 543 } 544 545 546 547 /** 548 * Sets the value for <b>code</b> () 549 * 550 * <p> 551 * <b>Definition:</b> 552 * A computer processable form of the unit in some unit representation system 553 * </p> 554 */ 555 public QuantityDt setCode( String theCode) { 556 myCode = new CodeDt(theCode); 557 return this; 558 } 559 560 561 562 563}