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 org.hl7.fhir.r5.openehr.Enumerations.*;
038import org.hl7.fhir.exceptions.FHIRException;
039import org.hl7.fhir.r5.model.*;
040import org.hl7.fhir.instance.model.api.ICompositeType;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.ChildOrder;
043import ca.uhn.fhir.model.api.annotation.DatatypeDef;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046
047/**
048 * Defines a named range to be associated with any DV_ORDERED datum. Each such range is particular to the patient and context, e.g. sex, age, and any other factor which affects ranges. May be used to represent normal, therapeutic, dangerous, critical etc ranges.
049 */
050@DatatypeDef(name="REFERENCE_RANGE")
051public class REFERENCE_RANGE extends LogicalBase implements ICompositeType {
052
053    /**
054     * Term whose value indicates the meaning of this range, e.g. normal, critical, therapeutic etc.
055     */
056    @Child(name = "meaning", type = {DV_TEXT.class}, order=0, min=1, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Term whose value indicates the meaning of this range, e.g. normal, critical, therapeutic etc", formalDefinition="Term whose value indicates the meaning of this range, e.g. normal, critical, therapeutic etc." )
058    protected DV_TEXT meaning;
059
060    /**
061     * The data range for this meaning, e.g. critical etc.
062     */
063    @Child(name = "range", type = {DV_INTERVAL.class}, order=1, min=1, max=1, modifier=false, summary=false)
064    @Description(shortDefinition="The data range for this meaning, e.g. critical etc", formalDefinition="The data range for this meaning, e.g. critical etc." )
065    protected DV_INTERVAL range;
066
067    private static final long serialVersionUID = 610983054L;
068
069  /**
070   * Constructor
071   */
072    public REFERENCE_RANGE() {
073      super();
074    }
075
076  /**
077   * Constructor
078   */
079    public REFERENCE_RANGE(DV_TEXT meaning, DV_INTERVAL range) {
080      super();
081      this.setMeaning(meaning);
082      this.setRange(range);
083    }
084
085    /**
086     * @return {@link #meaning} (Term whose value indicates the meaning of this range, e.g. normal, critical, therapeutic etc.)
087     */
088    public DV_TEXT getMeaning() { 
089      if (this.meaning == null)
090        if (Configuration.errorOnAutoCreate())
091          throw new Error("Attempt to auto-create REFERENCE_RANGE.meaning");
092        else if (Configuration.doAutoCreate())
093          this.meaning = new DV_TEXT(); // cc
094      return this.meaning;
095    }
096
097    public boolean hasMeaning() { 
098      return this.meaning != null && !this.meaning.isEmpty();
099    }
100
101    /**
102     * @param value {@link #meaning} (Term whose value indicates the meaning of this range, e.g. normal, critical, therapeutic etc.)
103     */
104    public REFERENCE_RANGE setMeaning(DV_TEXT value) { 
105      this.meaning = value;
106      return this;
107    }
108
109    /**
110     * @return {@link #range} (The data range for this meaning, e.g. critical etc.)
111     */
112    public DV_INTERVAL getRange() { 
113      if (this.range == null)
114        if (Configuration.errorOnAutoCreate())
115          throw new Error("Attempt to auto-create REFERENCE_RANGE.range");
116        else if (Configuration.doAutoCreate())
117          this.range = new DV_INTERVAL(); // cc
118      return this.range;
119    }
120
121    public boolean hasRange() { 
122      return this.range != null && !this.range.isEmpty();
123    }
124
125    /**
126     * @param value {@link #range} (The data range for this meaning, e.g. critical etc.)
127     */
128    public REFERENCE_RANGE setRange(DV_INTERVAL value) { 
129      this.range = value;
130      return this;
131    }
132
133      protected void listChildren(List<Property> children) {
134        super.listChildren(children);
135        children.add(new Property("meaning", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Term whose value indicates the meaning of this range, e.g. normal, critical, therapeutic etc.", 0, 1, meaning));
136        children.add(new Property("range", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "The data range for this meaning, e.g. critical etc.", 0, 1, range));
137      }
138
139      @Override
140      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
141        switch (_hash) {
142        case 938160637: /*meaning*/  return new Property("meaning", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Term whose value indicates the meaning of this range, e.g. normal, critical, therapeutic etc.", 0, 1, meaning);
143        case 108280125: /*range*/  return new Property("range", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "The data range for this meaning, e.g. critical etc.", 0, 1, range);
144        default: return super.getNamedProperty(_hash, _name, _checkValid);
145        }
146
147      }
148
149      @Override
150      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
151        switch (hash) {
152        case 938160637: /*meaning*/ return this.meaning == null ? new Base[0] : new Base[] {this.meaning}; // DV_TEXT
153        case 108280125: /*range*/ return this.range == null ? new Base[0] : new Base[] {this.range}; // DV_INTERVAL
154        default: return super.getProperty(hash, name, checkValid);
155        }
156
157      }
158
159      @Override
160      public Base setProperty(int hash, String name, Base value) throws FHIRException {
161        switch (hash) {
162        case 938160637: // meaning
163          this.meaning = (DV_TEXT) value; // DV_TEXT
164          return value;
165        case 108280125: // range
166          this.range = (DV_INTERVAL) value; // DV_INTERVAL
167          return value;
168        default: return super.setProperty(hash, name, value);
169        }
170
171      }
172
173      @Override
174      public Base setProperty(String name, Base value) throws FHIRException {
175        if (name.equals("meaning")) {
176          this.meaning = (DV_TEXT) value; // DV_TEXT
177        } else if (name.equals("range")) {
178          this.range = (DV_INTERVAL) value; // DV_INTERVAL
179        } else
180          return super.setProperty(name, value);
181        return value;
182      }
183
184      @Override
185      public Base makeProperty(int hash, String name) throws FHIRException {
186        switch (hash) {
187        case 938160637:  return getMeaning();
188        case 108280125:  return getRange();
189        default: return super.makeProperty(hash, name);
190        }
191
192      }
193
194      @Override
195      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
196        switch (hash) {
197        case 938160637: /*meaning*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-TEXT"};
198        case 108280125: /*range*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-INTERVAL"};
199        default: return super.getTypesForProperty(hash, name);
200        }
201
202      }
203
204      @Override
205      public Base addChild(String name) throws FHIRException {
206        if (name.equals("meaning")) {
207          this.meaning = new DV_TEXT();
208          return this.meaning;
209        }
210        else if (name.equals("range")) {
211          this.range = new DV_INTERVAL();
212          return this.range;
213        }
214        else
215          return super.addChild(name);
216      }
217
218  public String fhirType() {
219    return "REFERENCE_RANGE";
220
221  }
222
223      public REFERENCE_RANGE copy() {
224        REFERENCE_RANGE dst = new REFERENCE_RANGE();
225        copyValues(dst);
226        return dst;
227      }
228
229      public void copyValues(REFERENCE_RANGE dst) {
230        super.copyValues(dst);
231        dst.meaning = meaning == null ? null : meaning.copy();
232        dst.range = range == null ? null : range.copy();
233      }
234
235      protected REFERENCE_RANGE typedCopy() {
236        return copy();
237      }
238
239      @Override
240      public boolean equalsDeep(Base other_) {
241        if (!super.equalsDeep(other_))
242          return false;
243        if (!(other_ instanceof REFERENCE_RANGE))
244          return false;
245        REFERENCE_RANGE o = (REFERENCE_RANGE) other_;
246        return compareDeep(meaning, o.meaning, true) && compareDeep(range, o.range, true);
247      }
248
249      @Override
250      public boolean equalsShallow(Base other_) {
251        if (!super.equalsShallow(other_))
252          return false;
253        if (!(other_ instanceof REFERENCE_RANGE))
254          return false;
255        REFERENCE_RANGE o = (REFERENCE_RANGE) other_;
256        return true;
257      }
258
259      public boolean isEmpty() {
260        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(meaning, range);
261      }
262
263
264}
265