001package org.hl7.fhir.dstu2.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu2 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023 024import java.math.BigDecimal; 025 026/* 027 Copyright (c) 2011+, HL7, Inc. 028 All rights reserved. 029 030 Redistribution and use in source and binary forms, with or without modification, 031 are permitted provided that the following conditions are met: 032 033 * Redistributions of source code must retain the above copyright notice, this 034 list of conditions and the following disclaimer. 035 * Redistributions in binary form must reproduce the above copyright notice, 036 this list of conditions and the following disclaimer in the documentation 037 and/or other materials provided with the distribution. 038 * Neither the name of HL7 nor the names of its contributors may be used to 039 endorse or promote products derived from this software without specific 040 prior written permission. 041 042 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 043 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 044 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 045 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 046 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 047 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 048 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 049 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 050 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 051 POSSIBILITY OF SUCH DAMAGE. 052 053*/ 054 055// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2 056import java.util.List; 057 058import ca.uhn.fhir.model.api.annotation.Child; 059import ca.uhn.fhir.model.api.annotation.DatatypeDef; 060import ca.uhn.fhir.model.api.annotation.Description; 061import org.hl7.fhir.instance.model.api.ICompositeType; 062import org.hl7.fhir.exceptions.FHIRException; 063/** 064 * A series of measurements taken by a device, with upper and lower limits. There may be more than one dimension in the data. 065 */ 066@DatatypeDef(name="SampledData") 067public class SampledData extends Type implements ICompositeType { 068 069 /** 070 * The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series. 071 */ 072 @Child(name = "origin", type = {SimpleQuantity.class}, order=0, min=1, max=1, modifier=false, summary=true) 073 @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." ) 074 protected SimpleQuantity origin; 075 076 /** 077 * The length of time between sampling times, measured in milliseconds. 078 */ 079 @Child(name = "period", type = {DecimalType.class}, order=1, min=1, max=1, modifier=false, summary=true) 080 @Description(shortDefinition="Number of milliseconds between samples", formalDefinition="The length of time between sampling times, measured in milliseconds." ) 081 protected DecimalType period; 082 083 /** 084 * A correction factor that is applied to the sampled data points before they are added to the origin. 085 */ 086 @Child(name = "factor", type = {DecimalType.class}, order=2, min=0, max=1, modifier=false, summary=true) 087 @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." ) 088 protected DecimalType factor; 089 090 /** 091 * 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). 092 */ 093 @Child(name = "lowerLimit", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=true) 094 @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)." ) 095 protected DecimalType lowerLimit; 096 097 /** 098 * 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). 099 */ 100 @Child(name = "upperLimit", type = {DecimalType.class}, order=4, min=0, max=1, modifier=false, summary=true) 101 @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)." ) 102 protected DecimalType upperLimit; 103 104 /** 105 * 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. 106 */ 107 @Child(name = "dimensions", type = {PositiveIntType.class}, order=5, min=1, max=1, modifier=false, summary=true) 108 @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." ) 109 protected PositiveIntType dimensions; 110 111 /** 112 * 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. 113 */ 114 @Child(name = "data", type = {StringType.class}, order=6, min=1, max=1, modifier=false, summary=true) 115 @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." ) 116 protected StringType data; 117 118 private static final long serialVersionUID = -1763278368L; 119 120 /* 121 * Constructor 122 */ 123 public SampledData() { 124 super(); 125 } 126 127 /* 128 * Constructor 129 */ 130 public SampledData(SimpleQuantity origin, DecimalType period, PositiveIntType dimensions, StringType data) { 131 super(); 132 this.origin = origin; 133 this.period = period; 134 this.dimensions = dimensions; 135 this.data = data; 136 } 137 138 /** 139 * @return {@link #origin} (The base quantity that a measured value of zero represents. In addition, this provides the units of the entire measurement series.) 140 */ 141 public SimpleQuantity getOrigin() { 142 if (this.origin == null) 143 if (Configuration.errorOnAutoCreate()) 144 throw new Error("Attempt to auto-create SampledData.origin"); 145 else if (Configuration.doAutoCreate()) 146 this.origin = new SimpleQuantity(); // cc 147 return this.origin; 148 } 149 150 public boolean hasOrigin() { 151 return this.origin != null && !this.origin.isEmpty(); 152 } 153 154 /** 155 * @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.) 156 */ 157 public SampledData setOrigin(SimpleQuantity value) { 158 this.origin = value; 159 return this; 160 } 161 162 /** 163 * @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 164 */ 165 public DecimalType getPeriodElement() { 166 if (this.period == null) 167 if (Configuration.errorOnAutoCreate()) 168 throw new Error("Attempt to auto-create SampledData.period"); 169 else if (Configuration.doAutoCreate()) 170 this.period = new DecimalType(); // bb 171 return this.period; 172 } 173 174 public boolean hasPeriodElement() { 175 return this.period != null && !this.period.isEmpty(); 176 } 177 178 public boolean hasPeriod() { 179 return this.period != null && !this.period.isEmpty(); 180 } 181 182 /** 183 * @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 184 */ 185 public SampledData setPeriodElement(DecimalType value) { 186 this.period = value; 187 return this; 188 } 189 190 /** 191 * @return The length of time between sampling times, measured in milliseconds. 192 */ 193 public BigDecimal getPeriod() { 194 return this.period == null ? null : this.period.getValue(); 195 } 196 197 /** 198 * @param value The length of time between sampling times, measured in milliseconds. 199 */ 200 public SampledData setPeriod(BigDecimal value) { 201 if (this.period == null) 202 this.period = new DecimalType(); 203 this.period.setValue(value); 204 return this; 205 } 206 207 /** 208 * @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 209 */ 210 public DecimalType getFactorElement() { 211 if (this.factor == null) 212 if (Configuration.errorOnAutoCreate()) 213 throw new Error("Attempt to auto-create SampledData.factor"); 214 else if (Configuration.doAutoCreate()) 215 this.factor = new DecimalType(); // bb 216 return this.factor; 217 } 218 219 public boolean hasFactorElement() { 220 return this.factor != null && !this.factor.isEmpty(); 221 } 222 223 public boolean hasFactor() { 224 return this.factor != null && !this.factor.isEmpty(); 225 } 226 227 /** 228 * @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 229 */ 230 public SampledData setFactorElement(DecimalType value) { 231 this.factor = value; 232 return this; 233 } 234 235 /** 236 * @return A correction factor that is applied to the sampled data points before they are added to the origin. 237 */ 238 public BigDecimal getFactor() { 239 return this.factor == null ? null : this.factor.getValue(); 240 } 241 242 /** 243 * @param value A correction factor that is applied to the sampled data points before they are added to the origin. 244 */ 245 public SampledData setFactor(BigDecimal value) { 246 if (value == null) 247 this.factor = null; 248 else { 249 if (this.factor == null) 250 this.factor = new DecimalType(); 251 this.factor.setValue(value); 252 } 253 return this; 254 } 255 256 /** 257 * @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 258 */ 259 public DecimalType getLowerLimitElement() { 260 if (this.lowerLimit == null) 261 if (Configuration.errorOnAutoCreate()) 262 throw new Error("Attempt to auto-create SampledData.lowerLimit"); 263 else if (Configuration.doAutoCreate()) 264 this.lowerLimit = new DecimalType(); // bb 265 return this.lowerLimit; 266 } 267 268 public boolean hasLowerLimitElement() { 269 return this.lowerLimit != null && !this.lowerLimit.isEmpty(); 270 } 271 272 public boolean hasLowerLimit() { 273 return this.lowerLimit != null && !this.lowerLimit.isEmpty(); 274 } 275 276 /** 277 * @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 278 */ 279 public SampledData setLowerLimitElement(DecimalType value) { 280 this.lowerLimit = value; 281 return this; 282 } 283 284 /** 285 * @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). 286 */ 287 public BigDecimal getLowerLimit() { 288 return this.lowerLimit == null ? null : this.lowerLimit.getValue(); 289 } 290 291 /** 292 * @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). 293 */ 294 public SampledData setLowerLimit(BigDecimal value) { 295 if (value == null) 296 this.lowerLimit = null; 297 else { 298 if (this.lowerLimit == null) 299 this.lowerLimit = new DecimalType(); 300 this.lowerLimit.setValue(value); 301 } 302 return this; 303 } 304 305 /** 306 * @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 307 */ 308 public DecimalType getUpperLimitElement() { 309 if (this.upperLimit == null) 310 if (Configuration.errorOnAutoCreate()) 311 throw new Error("Attempt to auto-create SampledData.upperLimit"); 312 else if (Configuration.doAutoCreate()) 313 this.upperLimit = new DecimalType(); // bb 314 return this.upperLimit; 315 } 316 317 public boolean hasUpperLimitElement() { 318 return this.upperLimit != null && !this.upperLimit.isEmpty(); 319 } 320 321 public boolean hasUpperLimit() { 322 return this.upperLimit != null && !this.upperLimit.isEmpty(); 323 } 324 325 /** 326 * @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 327 */ 328 public SampledData setUpperLimitElement(DecimalType value) { 329 this.upperLimit = value; 330 return this; 331 } 332 333 /** 334 * @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). 335 */ 336 public BigDecimal getUpperLimit() { 337 return this.upperLimit == null ? null : this.upperLimit.getValue(); 338 } 339 340 /** 341 * @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). 342 */ 343 public SampledData setUpperLimit(BigDecimal value) { 344 if (value == null) 345 this.upperLimit = null; 346 else { 347 if (this.upperLimit == null) 348 this.upperLimit = new DecimalType(); 349 this.upperLimit.setValue(value); 350 } 351 return this; 352 } 353 354 /** 355 * @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 356 */ 357 public PositiveIntType getDimensionsElement() { 358 if (this.dimensions == null) 359 if (Configuration.errorOnAutoCreate()) 360 throw new Error("Attempt to auto-create SampledData.dimensions"); 361 else if (Configuration.doAutoCreate()) 362 this.dimensions = new PositiveIntType(); // bb 363 return this.dimensions; 364 } 365 366 public boolean hasDimensionsElement() { 367 return this.dimensions != null && !this.dimensions.isEmpty(); 368 } 369 370 public boolean hasDimensions() { 371 return this.dimensions != null && !this.dimensions.isEmpty(); 372 } 373 374 /** 375 * @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 376 */ 377 public SampledData setDimensionsElement(PositiveIntType value) { 378 this.dimensions = value; 379 return this; 380 } 381 382 /** 383 * @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. 384 */ 385 public int getDimensions() { 386 return this.dimensions == null || this.dimensions.isEmpty() ? 0 : this.dimensions.getValue(); 387 } 388 389 /** 390 * @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. 391 */ 392 public SampledData setDimensions(int value) { 393 if (this.dimensions == null) 394 this.dimensions = new PositiveIntType(); 395 this.dimensions.setValue(value); 396 return this; 397 } 398 399 /** 400 * @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 401 */ 402 public StringType getDataElement() { 403 if (this.data == null) 404 if (Configuration.errorOnAutoCreate()) 405 throw new Error("Attempt to auto-create SampledData.data"); 406 else if (Configuration.doAutoCreate()) 407 this.data = new StringType(); // bb 408 return this.data; 409 } 410 411 public boolean hasDataElement() { 412 return this.data != null && !this.data.isEmpty(); 413 } 414 415 public boolean hasData() { 416 return this.data != null && !this.data.isEmpty(); 417 } 418 419 /** 420 * @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 421 */ 422 public SampledData setDataElement(StringType value) { 423 this.data = value; 424 return this; 425 } 426 427 /** 428 * @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. 429 */ 430 public String getData() { 431 return this.data == null ? null : this.data.getValue(); 432 } 433 434 /** 435 * @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. 436 */ 437 public SampledData setData(String value) { 438 if (this.data == null) 439 this.data = new StringType(); 440 this.data.setValue(value); 441 return this; 442 } 443 444 protected void listChildren(List<Property> childrenList) { 445 super.listChildren(childrenList); 446 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)); 447 childrenList.add(new Property("period", "decimal", "The length of time between sampling times, measured in milliseconds.", 0, java.lang.Integer.MAX_VALUE, period)); 448 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)); 449 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)); 450 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)); 451 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)); 452 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)); 453 } 454 455 @Override 456 public void setProperty(String name, Base value) throws FHIRException { 457 if (name.equals("origin")) 458 this.origin = castToSimpleQuantity(value); // SimpleQuantity 459 else if (name.equals("period")) 460 this.period = castToDecimal(value); // DecimalType 461 else if (name.equals("factor")) 462 this.factor = castToDecimal(value); // DecimalType 463 else if (name.equals("lowerLimit")) 464 this.lowerLimit = castToDecimal(value); // DecimalType 465 else if (name.equals("upperLimit")) 466 this.upperLimit = castToDecimal(value); // DecimalType 467 else if (name.equals("dimensions")) 468 this.dimensions = castToPositiveInt(value); // PositiveIntType 469 else if (name.equals("data")) 470 this.data = castToString(value); // StringType 471 else 472 super.setProperty(name, value); 473 } 474 475 @Override 476 public Base addChild(String name) throws FHIRException { 477 if (name.equals("origin")) { 478 this.origin = new SimpleQuantity(); 479 return this.origin; 480 } 481 else if (name.equals("period")) { 482 throw new FHIRException("Cannot call addChild on a primitive type SampledData.period"); 483 } 484 else if (name.equals("factor")) { 485 throw new FHIRException("Cannot call addChild on a primitive type SampledData.factor"); 486 } 487 else if (name.equals("lowerLimit")) { 488 throw new FHIRException("Cannot call addChild on a primitive type SampledData.lowerLimit"); 489 } 490 else if (name.equals("upperLimit")) { 491 throw new FHIRException("Cannot call addChild on a primitive type SampledData.upperLimit"); 492 } 493 else if (name.equals("dimensions")) { 494 throw new FHIRException("Cannot call addChild on a primitive type SampledData.dimensions"); 495 } 496 else if (name.equals("data")) { 497 throw new FHIRException("Cannot call addChild on a primitive type SampledData.data"); 498 } 499 else 500 return super.addChild(name); 501 } 502 503 public String fhirType() { 504 return "SampledData"; 505 506 } 507 508 public SampledData copy() { 509 SampledData dst = new SampledData(); 510 copyValues(dst); 511 dst.origin = origin == null ? null : origin.copy(); 512 dst.period = period == null ? null : period.copy(); 513 dst.factor = factor == null ? null : factor.copy(); 514 dst.lowerLimit = lowerLimit == null ? null : lowerLimit.copy(); 515 dst.upperLimit = upperLimit == null ? null : upperLimit.copy(); 516 dst.dimensions = dimensions == null ? null : dimensions.copy(); 517 dst.data = data == null ? null : data.copy(); 518 return dst; 519 } 520 521 protected SampledData typedCopy() { 522 return copy(); 523 } 524 525 @Override 526 public boolean equalsDeep(Base other) { 527 if (!super.equalsDeep(other)) 528 return false; 529 if (!(other instanceof SampledData)) 530 return false; 531 SampledData o = (SampledData) other; 532 return compareDeep(origin, o.origin, true) && compareDeep(period, o.period, true) && compareDeep(factor, o.factor, true) 533 && compareDeep(lowerLimit, o.lowerLimit, true) && compareDeep(upperLimit, o.upperLimit, true) && compareDeep(dimensions, o.dimensions, true) 534 && compareDeep(data, o.data, true); 535 } 536 537 @Override 538 public boolean equalsShallow(Base other) { 539 if (!super.equalsShallow(other)) 540 return false; 541 if (!(other instanceof SampledData)) 542 return false; 543 SampledData o = (SampledData) other; 544 return compareValues(period, o.period, true) && compareValues(factor, o.factor, true) && compareValues(lowerLimit, o.lowerLimit, true) 545 && compareValues(upperLimit, o.upperLimit, true) && compareValues(dimensions, o.dimensions, true) && compareValues(data, o.data, true) 546 ; 547 } 548 549 public boolean isEmpty() { 550 return super.isEmpty() && (origin == null || origin.isEmpty()) && (period == null || period.isEmpty()) 551 && (factor == null || factor.isEmpty()) && (lowerLimit == null || lowerLimit.isEmpty()) && (upperLimit == null || upperLimit.isEmpty()) 552 && (dimensions == null || dimensions.isEmpty()) && (data == null || data.isEmpty()); 553 } 554 555 556} 557