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