001package org.hl7.fhir.r5.openehr;
002
003
004/*
005  Copyright (c) 2011+, HL7, Inc.
006  All rights reserved.
007  
008  Redistribution and use in source and binary forms, with or without modification, \
009  are permitted provided that the following conditions are met:
010  
011   * Redistributions of source code must retain the above copyright notice, this \
012     list of conditions and the following disclaimer.
013   * Redistributions in binary form must reproduce the above copyright notice, \
014     this list of conditions and the following disclaimer in the documentation \
015     and/or other materials provided with the distribution.
016   * Neither the name of HL7 nor the names of its contributors may be used to 
017     endorse or promote products derived from this software without specific 
018     prior written permission.
019  
020  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
021  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
022  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
023  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
024  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
025  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
026  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
027  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
028  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
029  POSSIBILITY OF SUCH DAMAGE.
030  */
031
032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0
033
034import java.util.ArrayList;
035import java.util.Date;
036import java.util.List;
037import java.math.*;
038import org.hl7.fhir.r5.openehr.Enumerations.*;
039import org.hl7.fhir.exceptions.FHIRException;
040import org.hl7.fhir.r5.model.*;
041import org.hl7.fhir.instance.model.api.ICompositeType;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.DatatypeDef;
045import ca.uhn.fhir.model.api.annotation.Description;
046import ca.uhn.fhir.model.api.annotation.Block;
047
048/**
049 * A data type that represents scale values, where there is:
050
051a) implied ordering, b) no implication that the distance between each value is constant, and c) the total number of values is finite; d) non-integer values are allowed.
052
053  Example:
054````  
055  Borg CR 10 Scale
056  
057  0    No Breathlessness at all
058  0.5  Very Very Slight (Just Noticeable)
059  1    Very Slight
060  2    Slight Breathlessness
061  3    Moderate
062  ... etc
063````
064
065For scores that include only Integers, DV_SCALE may also be used, but DV_ORDINAL should be supported to accommodate existing data instances of that type.
066 */
067@DatatypeDef(name="DV_SCALE")
068public class DV_SCALE extends DV_ORDERED implements ICompositeType {
069
070    /**
071     * Coded textual representation of this value in the scale range, which may be strings made from symbols or other enumerations of terms such as no breathlessness, very very slight, slight breathlessness. Codes come from archetypes.
072
073In some cases, a scale may include values that have no code/symbol. In this case, the symbol will be a DV-CODED-TEXT including the terminology_id and a blank String value for code_string.
074     */
075    @Child(name = "symbol", type = {DV_CODED_TEXT.class}, order=0, min=1, max=1, modifier=false, summary=false)
076    @Description(shortDefinition="Coded textual representation of this value in the scale range, which may be strings made from symbols or other enumerations of terms", formalDefinition="Coded textual representation of this value in the scale range, which may be strings made from symbols or other enumerations of terms such as no breathlessness, very very slight, slight breathlessness. Codes come from archetypes.\r\n\r\nIn some cases, a scale may include values that have no code/symbol. In this case, the symbol will be a DV-CODED-TEXT including the terminology_id and a blank String value for code_string." )
077    protected DV_CODED_TEXT symbol;
078
079    /**
080     * Real number value of Scale item.
081     */
082    @Child(name = "value", type = {DecimalType.class}, order=1, min=1, max=1, modifier=false, summary=false)
083    @Description(shortDefinition="Real number value of Scale item", formalDefinition="Real number value of Scale item." )
084    protected DecimalType value;
085
086    private static final long serialVersionUID = -1085111458L;
087
088  /**
089   * Constructor
090   */
091    public DV_SCALE() {
092      super();
093    }
094
095  /**
096   * Constructor
097   */
098    public DV_SCALE(DV_CODED_TEXT symbol, BigDecimal value) {
099      super();
100      this.setSymbol(symbol);
101      this.setValue(value);
102    }
103
104    /**
105     * @return {@link #symbol} (Coded textual representation of this value in the scale range, which may be strings made from symbols or other enumerations of terms such as no breathlessness, very very slight, slight breathlessness. Codes come from archetypes.
106
107In some cases, a scale may include values that have no code/symbol. In this case, the symbol will be a DV-CODED-TEXT including the terminology_id and a blank String value for code_string.)
108     */
109    public DV_CODED_TEXT getSymbol() { 
110      if (this.symbol == null)
111        if (Configuration.errorOnAutoCreate())
112          throw new Error("Attempt to auto-create DV_SCALE.symbol");
113        else if (Configuration.doAutoCreate())
114          this.symbol = new DV_CODED_TEXT(); // cc
115      return this.symbol;
116    }
117
118    public boolean hasSymbol() { 
119      return this.symbol != null && !this.symbol.isEmpty();
120    }
121
122    /**
123     * @param value {@link #symbol} (Coded textual representation of this value in the scale range, which may be strings made from symbols or other enumerations of terms such as no breathlessness, very very slight, slight breathlessness. Codes come from archetypes.
124
125In some cases, a scale may include values that have no code/symbol. In this case, the symbol will be a DV-CODED-TEXT including the terminology_id and a blank String value for code_string.)
126     */
127    public DV_SCALE setSymbol(DV_CODED_TEXT value) { 
128      this.symbol = value;
129      return this;
130    }
131
132    /**
133     * @return {@link #value} (Real number value of Scale item.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
134     */
135    public DecimalType getValueElement() { 
136      if (this.value == null)
137        if (Configuration.errorOnAutoCreate())
138          throw new Error("Attempt to auto-create DV_SCALE.value");
139        else if (Configuration.doAutoCreate())
140          this.value = new DecimalType(); // bb
141      return this.value;
142    }
143
144    public boolean hasValueElement() { 
145      return this.value != null && !this.value.isEmpty();
146    }
147
148    public boolean hasValue() { 
149      return this.value != null && !this.value.isEmpty();
150    }
151
152    /**
153     * @param value {@link #value} (Real number value of Scale item.). This is the underlying object with id, value and extensions. The accessor "getValue" gives direct access to the value
154     */
155    public DV_SCALE setValueElement(DecimalType value) { 
156      this.value = value;
157      return this;
158    }
159
160    /**
161     * @return Real number value of Scale item.
162     */
163    public BigDecimal getValue() { 
164      return this.value == null ? null : this.value.getValue();
165    }
166
167    /**
168     * @param value Real number value of Scale item.
169     */
170    public DV_SCALE setValue(BigDecimal value) { 
171        if (this.value == null)
172          this.value = new DecimalType();
173        this.value.setValue(value);
174      return this;
175    }
176
177    /**
178     * @param value Real number value of Scale item.
179     */
180    public DV_SCALE setValue(long value) { 
181          this.value = new DecimalType();
182        this.value.setValue(value);
183      return this;
184    }
185
186    /**
187     * @param value Real number value of Scale item.
188     */
189    public DV_SCALE setValue(double value) { 
190          this.value = new DecimalType();
191        this.value.setValue(value);
192      return this;
193    }
194
195      protected void listChildren(List<Property> children) {
196        super.listChildren(children);
197        children.add(new Property("symbol", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Coded textual representation of this value in the scale range, which may be strings made from symbols or other enumerations of terms such as no breathlessness, very very slight, slight breathlessness. Codes come from archetypes.\r\n\r\nIn some cases, a scale may include values that have no code/symbol. In this case, the symbol will be a DV-CODED-TEXT including the terminology_id and a blank String value for code_string.", 0, 1, symbol));
198        children.add(new Property("value", "decimal", "Real number value of Scale item.", 0, 1, value));
199      }
200
201      @Override
202      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
203        switch (_hash) {
204        case -887523944: /*symbol*/  return new Property("symbol", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Coded textual representation of this value in the scale range, which may be strings made from symbols or other enumerations of terms such as no breathlessness, very very slight, slight breathlessness. Codes come from archetypes.\r\n\r\nIn some cases, a scale may include values that have no code/symbol. In this case, the symbol will be a DV-CODED-TEXT including the terminology_id and a blank String value for code_string.", 0, 1, symbol);
205        case 111972721: /*value*/  return new Property("value", "decimal", "Real number value of Scale item.", 0, 1, value);
206        default: return super.getNamedProperty(_hash, _name, _checkValid);
207        }
208
209      }
210
211      @Override
212      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
213        switch (hash) {
214        case -887523944: /*symbol*/ return this.symbol == null ? new Base[0] : new Base[] {this.symbol}; // DV_CODED_TEXT
215        case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DecimalType
216        default: return super.getProperty(hash, name, checkValid);
217        }
218
219      }
220
221      @Override
222      public Base setProperty(int hash, String name, Base value) throws FHIRException {
223        switch (hash) {
224        case -887523944: // symbol
225          this.symbol = (DV_CODED_TEXT) value; // DV_CODED_TEXT
226          return value;
227        case 111972721: // value
228          this.value = TypeConvertor.castToDecimal(value); // DecimalType
229          return value;
230        default: return super.setProperty(hash, name, value);
231        }
232
233      }
234
235      @Override
236      public Base setProperty(String name, Base value) throws FHIRException {
237        if (name.equals("symbol")) {
238          this.symbol = (DV_CODED_TEXT) value; // DV_CODED_TEXT
239        } else if (name.equals("value")) {
240          this.value = TypeConvertor.castToDecimal(value); // DecimalType
241        } else
242          return super.setProperty(name, value);
243        return value;
244      }
245
246      @Override
247      public Base makeProperty(int hash, String name) throws FHIRException {
248        switch (hash) {
249        case -887523944:  return getSymbol();
250        case 111972721:  return getValueElement();
251        default: return super.makeProperty(hash, name);
252        }
253
254      }
255
256      @Override
257      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
258        switch (hash) {
259        case -887523944: /*symbol*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"};
260        case 111972721: /*value*/ return new String[] {"decimal"};
261        default: return super.getTypesForProperty(hash, name);
262        }
263
264      }
265
266      @Override
267      public Base addChild(String name) throws FHIRException {
268        if (name.equals("symbol")) {
269          this.symbol = new DV_CODED_TEXT();
270          return this.symbol;
271        }
272        else if (name.equals("value")) {
273          throw new FHIRException("Cannot call addChild on a singleton property DV_SCALE.value");
274        }
275        else
276          return super.addChild(name);
277      }
278
279  public String fhirType() {
280    return "DV_SCALE";
281
282  }
283
284      public DV_SCALE copy() {
285        DV_SCALE dst = new DV_SCALE();
286        copyValues(dst);
287        return dst;
288      }
289
290      public void copyValues(DV_SCALE dst) {
291        super.copyValues(dst);
292        dst.symbol = symbol == null ? null : symbol.copy();
293        dst.value = value == null ? null : value.copy();
294      }
295
296      protected DV_SCALE typedCopy() {
297        return copy();
298      }
299
300      @Override
301      public boolean equalsDeep(Base other_) {
302        if (!super.equalsDeep(other_))
303          return false;
304        if (!(other_ instanceof DV_SCALE))
305          return false;
306        DV_SCALE o = (DV_SCALE) other_;
307        return compareDeep(symbol, o.symbol, true) && compareDeep(value, o.value, true);
308      }
309
310      @Override
311      public boolean equalsShallow(Base other_) {
312        if (!super.equalsShallow(other_))
313          return false;
314        if (!(other_ instanceof DV_SCALE))
315          return false;
316        DV_SCALE o = (DV_SCALE) other_;
317        return compareValues(value, o.value, true);
318      }
319
320      public boolean isEmpty() {
321        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(symbol, value);
322      }
323
324
325}
326