001package org.hl7.fhir.instance.model; 002 003import java.math.BigDecimal; 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// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 035import java.util.List; 036 037import org.hl7.fhir.exceptions.FHIRException; 038import org.hl7.fhir.instance.model.api.ICompositeType; 039 040import ca.uhn.fhir.model.api.annotation.*; 041/** 042 * A series of measurements taken by a device, with upper and lower limits. There may be more than one dimension in the data. 043 */ 044@DatatypeDef(name="SampledData") 045public class SampledData extends Type implements ICompositeType { 046 047 /** 048 * The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series. 049 */ 050 @Child(name = "origin", type = {SimpleQuantity.class}, order=0, min=1, max=1, modifier=false, summary=true) 051 @Description(shortDefinition="Zero value and units", formalDefinition="The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series." ) 052 protected SimpleQuantity origin; 053 054 /** 055 * The length of time between sampling times, measured in milliseconds. 056 */ 057 @Child(name = "period", type = {DecimalType.class}, order=1, min=1, max=1, modifier=false, summary=true) 058 @Description(shortDefinition="Number of milliseconds between samples", formalDefinition="The length of time between sampling times, measured in milliseconds." ) 059 protected DecimalType period; 060 061 /** 062 * A correction factor that is applied to the sampled data points before they are added to the origin. 063 */ 064 @Child(name = "factor", type = {DecimalType.class}, order=2, min=0, max=1, modifier=false, summary=true) 065 @Description(shortDefinition="Multiply data by this before adding to origin", formalDefinition="A correction factor that is applied to the sampled data points before they are added to the origin." ) 066 protected DecimalType factor; 067 068 /** 069 * The lower limit of detection of the measured points. This is needed if any of the data points have the value "L" (lower than detection limit). 070 */ 071 @Child(name = "lowerLimit", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=true) 072 @Description(shortDefinition="Lower limit of detection", formalDefinition="The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit)." ) 073 protected DecimalType lowerLimit; 074 075 /** 076 * The upper limit of detection of the measured points. This is needed if any of the data points have the value "U" (higher than detection limit). 077 */ 078 @Child(name = "upperLimit", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=true) 079 @Description(shortDefinition="Upper limit of detection", formalDefinition="The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit)." ) 080 protected DecimalType upperLimit; 081 082 /** 083 * The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once. 084 */ 085 @Child(name = "dimensions", type = {PositiveIntType.class}, order=5, min=1, max=1, modifier=false, summary=true) 086 @Description(shortDefinition="Number of sample points at each time point", formalDefinition="The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once." ) 087 protected PositiveIntType dimensions; 088 089 /** 090 * A series of data points which are decimal values separated by a single space (character u20). The special values "E" (error), "L" (below detection limit) and "U" (above detection limit) can also be used in place of a decimal value. 091 */ 092 @Child(name = "data", type = {StringType.class}, order=6, min=1, max=1, modifier=false, summary=true) 093 @Description(shortDefinition="Decimal values with spaces, or \"E\" | \"U\" | \"L\"", formalDefinition="A series of data points which are decimal values separated by a single space (character u20). The special values \"E\" (error), \"L\" (below detection limit) and \"U\" (above detection limit) can also be used in place of a decimal value." ) 094 protected StringType data; 095 096 private static final long serialVersionUID = -1763278368L; 097 098 /* 099 * Constructor 100 */ 101 public SampledData() { 102 super(); 103 } 104 105 /* 106 * Constructor 107 */ 108 public SampledData(SimpleQuantity origin, DecimalType period, PositiveIntType dimensions, StringType data) { 109 super(); 110 this.origin = origin; 111 this.period = period; 112 this.dimensions = dimensions; 113 this.data = data; 114 } 115 116 /** 117 * @return {@link #origin} (The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series.) 118 */ 119 public SimpleQuantity getOrigin() { 120 if (this.origin == null) 121 if (Configuration.errorOnAutoCreate()) 122 throw new Error("Attempt to auto-create SampledData.origin"); 123 else if (Configuration.doAutoCreate()) 124 this.origin = new SimpleQuantity(); // cc 125 return this.origin; 126 } 127 128 public boolean hasOrigin() { 129 return this.origin != null && !this.origin.isEmpty(); 130 } 131 132 /** 133 * @param value {@link #origin} (The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series.) 134 */ 135 public SampledData setOrigin(SimpleQuantity value) { 136 this.origin = value; 137 return this; 138 } 139 140 /** 141 * @return {@link #period} (The length of time between sampling times, measured in milliseconds.). This is the underlying object with id, value and extensions. The accessor "getPeriod" gives direct access to the value 142 */ 143 public DecimalType getPeriodElement() { 144 if (this.period == null) 145 if (Configuration.errorOnAutoCreate()) 146 throw new Error("Attempt to auto-create SampledData.period"); 147 else if (Configuration.doAutoCreate()) 148 this.period = new DecimalType(); // bb 149 return this.period; 150 } 151 152 public boolean hasPeriodElement() { 153 return this.period != null && !this.period.isEmpty(); 154 } 155 156 public boolean hasPeriod() { 157 return this.period != null && !this.period.isEmpty(); 158 } 159 160 /** 161 * @param value {@link #period} (The length of time between sampling times, measured in milliseconds.). This is the underlying object with id, value and extensions. The accessor "getPeriod" gives direct access to the value 162 */ 163 public SampledData setPeriodElement(DecimalType value) { 164 this.period = value; 165 return this; 166 } 167 168 /** 169 * @return The length of time between sampling times, measured in milliseconds. 170 */ 171 public BigDecimal getPeriod() { 172 return this.period == null ? null : this.period.getValue(); 173 } 174 175 /** 176 * @param value The length of time between sampling times, measured in milliseconds. 177 */ 178 public SampledData setPeriod(BigDecimal value) { 179 if (this.period == null) 180 this.period = new DecimalType(); 181 this.period.setValue(value); 182 return this; 183 } 184 185 /** 186 * @return {@link #factor} (A correction factor that is applied to the sampled data points before they are added to the origin.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value 187 */ 188 public DecimalType getFactorElement() { 189 if (this.factor == null) 190 if (Configuration.errorOnAutoCreate()) 191 throw new Error("Attempt to auto-create SampledData.factor"); 192 else if (Configuration.doAutoCreate()) 193 this.factor = new DecimalType(); // bb 194 return this.factor; 195 } 196 197 public boolean hasFactorElement() { 198 return this.factor != null && !this.factor.isEmpty(); 199 } 200 201 public boolean hasFactor() { 202 return this.factor != null && !this.factor.isEmpty(); 203 } 204 205 /** 206 * @param value {@link #factor} (A correction factor that is applied to the sampled data points before they are added to the origin.). This is the underlying object with id, value and extensions. The accessor "getFactor" gives direct access to the value 207 */ 208 public SampledData setFactorElement(DecimalType value) { 209 this.factor = value; 210 return this; 211 } 212 213 /** 214 * @return A correction factor that is applied to the sampled data points before they are added to the origin. 215 */ 216 public BigDecimal getFactor() { 217 return this.factor == null ? null : this.factor.getValue(); 218 } 219 220 /** 221 * @param value A correction factor that is applied to the sampled data points before they are added to the origin. 222 */ 223 public SampledData setFactor(BigDecimal value) { 224 if (value == null) 225 this.factor = null; 226 else { 227 if (this.factor == null) 228 this.factor = new DecimalType(); 229 this.factor.setValue(value); 230 } 231 return this; 232 } 233 234 /** 235 * @return {@link #lowerLimit} (The lower limit of detection of the measured points. This is needed if any of the data points have the value "L" (lower than detection limit).). This is the underlying object with id, value and extensions. The accessor "getLowerLimit" gives direct access to the value 236 */ 237 public DecimalType getLowerLimitElement() { 238 if (this.lowerLimit == null) 239 if (Configuration.errorOnAutoCreate()) 240 throw new Error("Attempt to auto-create SampledData.lowerLimit"); 241 else if (Configuration.doAutoCreate()) 242 this.lowerLimit = new DecimalType(); // bb 243 return this.lowerLimit; 244 } 245 246 public boolean hasLowerLimitElement() { 247 return this.lowerLimit != null && !this.lowerLimit.isEmpty(); 248 } 249 250 public boolean hasLowerLimit() { 251 return this.lowerLimit != null && !this.lowerLimit.isEmpty(); 252 } 253 254 /** 255 * @param value {@link #lowerLimit} (The lower limit of detection of the measured points. This is needed if any of the data points have the value "L" (lower than detection limit).). This is the underlying object with id, value and extensions. The accessor "getLowerLimit" gives direct access to the value 256 */ 257 public SampledData setLowerLimitElement(DecimalType value) { 258 this.lowerLimit = value; 259 return this; 260 } 261 262 /** 263 * @return The lower limit of detection of the measured points. This is needed if any of the data points have the value "L" (lower than detection limit). 264 */ 265 public BigDecimal getLowerLimit() { 266 return this.lowerLimit == null ? null : this.lowerLimit.getValue(); 267 } 268 269 /** 270 * @param value The lower limit of detection of the measured points. This is needed if any of the data points have the value "L" (lower than detection limit). 271 */ 272 public SampledData setLowerLimit(BigDecimal value) { 273 if (value == null) 274 this.lowerLimit = null; 275 else { 276 if (this.lowerLimit == null) 277 this.lowerLimit = new DecimalType(); 278 this.lowerLimit.setValue(value); 279 } 280 return this; 281 } 282 283 /** 284 * @return {@link #upperLimit} (The upper limit of detection of the measured points. This is needed if any of the data points have the value "U" (higher than detection limit).). This is the underlying object with id, value and extensions. The accessor "getUpperLimit" gives direct access to the value 285 */ 286 public DecimalType getUpperLimitElement() { 287 if (this.upperLimit == null) 288 if (Configuration.errorOnAutoCreate()) 289 throw new Error("Attempt to auto-create SampledData.upperLimit"); 290 else if (Configuration.doAutoCreate()) 291 this.upperLimit = new DecimalType(); // bb 292 return this.upperLimit; 293 } 294 295 public boolean hasUpperLimitElement() { 296 return this.upperLimit != null && !this.upperLimit.isEmpty(); 297 } 298 299 public boolean hasUpperLimit() { 300 return this.upperLimit != null && !this.upperLimit.isEmpty(); 301 } 302 303 /** 304 * @param value {@link #upperLimit} (The upper limit of detection of the measured points. This is needed if any of the data points have the value "U" (higher than detection limit).). This is the underlying object with id, value and extensions. The accessor "getUpperLimit" gives direct access to the value 305 */ 306 public SampledData setUpperLimitElement(DecimalType value) { 307 this.upperLimit = value; 308 return this; 309 } 310 311 /** 312 * @return The upper limit of detection of the measured points. This is needed if any of the data points have the value "U" (higher than detection limit). 313 */ 314 public BigDecimal getUpperLimit() { 315 return this.upperLimit == null ? null : this.upperLimit.getValue(); 316 } 317 318 /** 319 * @param value The upper limit of detection of the measured points. This is needed if any of the data points have the value "U" (higher than detection limit). 320 */ 321 public SampledData setUpperLimit(BigDecimal value) { 322 if (value == null) 323 this.upperLimit = null; 324 else { 325 if (this.upperLimit == null) 326 this.upperLimit = new DecimalType(); 327 this.upperLimit.setValue(value); 328 } 329 return this; 330 } 331 332 /** 333 * @return {@link #dimensions} (The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once.). This is the underlying object with id, value and extensions. The accessor "getDimensions" gives direct access to the value 334 */ 335 public PositiveIntType getDimensionsElement() { 336 if (this.dimensions == null) 337 if (Configuration.errorOnAutoCreate()) 338 throw new Error("Attempt to auto-create SampledData.dimensions"); 339 else if (Configuration.doAutoCreate()) 340 this.dimensions = new PositiveIntType(); // bb 341 return this.dimensions; 342 } 343 344 public boolean hasDimensionsElement() { 345 return this.dimensions != null && !this.dimensions.isEmpty(); 346 } 347 348 public boolean hasDimensions() { 349 return this.dimensions != null && !this.dimensions.isEmpty(); 350 } 351 352 /** 353 * @param value {@link #dimensions} (The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once.). This is the underlying object with id, value and extensions. The accessor "getDimensions" gives direct access to the value 354 */ 355 public SampledData setDimensionsElement(PositiveIntType value) { 356 this.dimensions = value; 357 return this; 358 } 359 360 /** 361 * @return The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once. 362 */ 363 public int getDimensions() { 364 return this.dimensions == null || this.dimensions.isEmpty() ? 0 : this.dimensions.getValue(); 365 } 366 367 /** 368 * @param value The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once. 369 */ 370 public SampledData setDimensions(int value) { 371 if (this.dimensions == null) 372 this.dimensions = new PositiveIntType(); 373 this.dimensions.setValue(value); 374 return this; 375 } 376 377 /** 378 * @return {@link #data} (A series of data points which are decimal values separated by a single space (character u20). The special values "E" (error), "L" (below detection limit) and "U" (above detection limit) can also be used in place of a decimal value.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value 379 */ 380 public StringType getDataElement() { 381 if (this.data == null) 382 if (Configuration.errorOnAutoCreate()) 383 throw new Error("Attempt to auto-create SampledData.data"); 384 else if (Configuration.doAutoCreate()) 385 this.data = new StringType(); // bb 386 return this.data; 387 } 388 389 public boolean hasDataElement() { 390 return this.data != null && !this.data.isEmpty(); 391 } 392 393 public boolean hasData() { 394 return this.data != null && !this.data.isEmpty(); 395 } 396 397 /** 398 * @param value {@link #data} (A series of data points which are decimal values separated by a single space (character u20). The special values "E" (error), "L" (below detection limit) and "U" (above detection limit) can also be used in place of a decimal value.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value 399 */ 400 public SampledData setDataElement(StringType value) { 401 this.data = value; 402 return this; 403 } 404 405 /** 406 * @return A series of data points which are decimal values separated by a single space (character u20). The special values "E" (error), "L" (below detection limit) and "U" (above detection limit) can also be used in place of a decimal value. 407 */ 408 public String getData() { 409 return this.data == null ? null : this.data.getValue(); 410 } 411 412 /** 413 * @param value A series of data points which are decimal values separated by a single space (character u20). The special values "E" (error), "L" (below detection limit) and "U" (above detection limit) can also be used in place of a decimal value. 414 */ 415 public SampledData setData(String value) { 416 if (this.data == null) 417 this.data = new StringType(); 418 this.data.setValue(value); 419 return this; 420 } 421 422 protected void listChildren(List<Property> childrenList) { 423 super.listChildren(childrenList); 424 childrenList.add(new Property("origin", "SimpleQuantity", "The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series.", 0, java.lang.Integer.MAX_VALUE, origin)); 425 childrenList.add(new Property("period", "decimal", "The length of time between sampling times, measured in milliseconds.", 0, java.lang.Integer.MAX_VALUE, period)); 426 childrenList.add(new Property("factor", "decimal", "A correction factor that is applied to the sampled data points before they are added to the origin.", 0, java.lang.Integer.MAX_VALUE, factor)); 427 childrenList.add(new Property("lowerLimit", "decimal", "The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit).", 0, java.lang.Integer.MAX_VALUE, lowerLimit)); 428 childrenList.add(new Property("upperLimit", "decimal", "The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit).", 0, java.lang.Integer.MAX_VALUE, upperLimit)); 429 childrenList.add(new Property("dimensions", "positiveInt", "The number of sample points at each time point. If this value is greater than one, then the dimensions will be interlaced - all the sample points for a point in time will be recorded at once.", 0, java.lang.Integer.MAX_VALUE, dimensions)); 430 childrenList.add(new Property("data", "string", "A series of data points which are decimal values separated by a single space (character u20). The special values \"E\" (error), \"L\" (below detection limit) and \"U\" (above detection limit) can also be used in place of a decimal value.", 0, java.lang.Integer.MAX_VALUE, data)); 431 } 432 433 @Override 434 public void setProperty(String name, Base value) throws FHIRException { 435 if (name.equals("origin")) 436 this.origin = castToSimpleQuantity(value); // SimpleQuantity 437 else if (name.equals("period")) 438 this.period = castToDecimal(value); // DecimalType 439 else if (name.equals("factor")) 440 this.factor = castToDecimal(value); // DecimalType 441 else if (name.equals("lowerLimit")) 442 this.lowerLimit = castToDecimal(value); // DecimalType 443 else if (name.equals("upperLimit")) 444 this.upperLimit = castToDecimal(value); // DecimalType 445 else if (name.equals("dimensions")) 446 this.dimensions = castToPositiveInt(value); // PositiveIntType 447 else if (name.equals("data")) 448 this.data = castToString(value); // StringType 449 else 450 super.setProperty(name, value); 451 } 452 453 @Override 454 public Base addChild(String name) throws FHIRException { 455 if (name.equals("origin")) { 456 this.origin = new SimpleQuantity(); 457 return this.origin; 458 } 459 else if (name.equals("period")) { 460 throw new FHIRException("Cannot call addChild on a primitive type SampledData.period"); 461 } 462 else if (name.equals("factor")) { 463 throw new FHIRException("Cannot call addChild on a primitive type SampledData.factor"); 464 } 465 else if (name.equals("lowerLimit")) { 466 throw new FHIRException("Cannot call addChild on a primitive type SampledData.lowerLimit"); 467 } 468 else if (name.equals("upperLimit")) { 469 throw new FHIRException("Cannot call addChild on a primitive type SampledData.upperLimit"); 470 } 471 else if (name.equals("dimensions")) { 472 throw new FHIRException("Cannot call addChild on a primitive type SampledData.dimensions"); 473 } 474 else if (name.equals("data")) { 475 throw new FHIRException("Cannot call addChild on a primitive type SampledData.data"); 476 } 477 else 478 return super.addChild(name); 479 } 480 481 public String fhirType() { 482 return "SampledData"; 483 484 } 485 486 public SampledData copy() { 487 SampledData dst = new SampledData(); 488 copyValues(dst); 489 dst.origin = origin == null ? null : origin.copy(); 490 dst.period = period == null ? null : period.copy(); 491 dst.factor = factor == null ? null : factor.copy(); 492 dst.lowerLimit = lowerLimit == null ? null : lowerLimit.copy(); 493 dst.upperLimit = upperLimit == null ? null : upperLimit.copy(); 494 dst.dimensions = dimensions == null ? null : dimensions.copy(); 495 dst.data = data == null ? null : data.copy(); 496 return dst; 497 } 498 499 protected SampledData typedCopy() { 500 return copy(); 501 } 502 503 @Override 504 public boolean equalsDeep(Base other) { 505 if (!super.equalsDeep(other)) 506 return false; 507 if (!(other instanceof SampledData)) 508 return false; 509 SampledData o = (SampledData) other; 510 return compareDeep(origin, o.origin, true) && compareDeep(period, o.period, true) && compareDeep(factor, o.factor, true) 511 && compareDeep(lowerLimit, o.lowerLimit, true) && compareDeep(upperLimit, o.upperLimit, true) && compareDeep(dimensions, o.dimensions, true) 512 && compareDeep(data, o.data, true); 513 } 514 515 @Override 516 public boolean equalsShallow(Base other) { 517 if (!super.equalsShallow(other)) 518 return false; 519 if (!(other instanceof SampledData)) 520 return false; 521 SampledData o = (SampledData) other; 522 return compareValues(period, o.period, true) && compareValues(factor, o.factor, true) && compareValues(lowerLimit, o.lowerLimit, true) 523 && compareValues(upperLimit, o.upperLimit, true) && compareValues(dimensions, o.dimensions, true) && compareValues(data, o.data, true) 524 ; 525 } 526 527 public boolean isEmpty() { 528 return super.isEmpty() && (origin == null || origin.isEmpty()) && (period == null || period.isEmpty()) 529 && (factor == null || factor.isEmpty()) && (lowerLimit == null || lowerLimit.isEmpty()) && (upperLimit == null || upperLimit.isEmpty()) 530 && (dimensions == null || dimensions.isEmpty()) && (data == null || data.isEmpty()); 531 } 532 533 534} 535