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 * Abstract class defining the concept of ordered values, which includes ordinals as well as true quantities. It defines the functions < and is_strictly_comparable_to(), the latter of which must evaluate to True for instances being compared with the < function, or used as limits in the DV_INTERVAL<T> class
049 */
050@DatatypeDef(name="DV_ORDERED")
051public abstract class DV_ORDERED extends DATA_VALUE implements ICompositeType {
052
053    /**
054     * Optional normal status indicator of value with respect to normal range for this value. Often included by lab, even if the normal range itself is not included. Coded by ordinals in series HHH, HH, H, (nothing), L, LL, LLL; see openEHR terminology group normal_status.
055     */
056    @Child(name = "normal_status", type = {CODE_PHRASE.class}, order=0, min=0, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Optional normal status indicator of value with respect to normal range for this value", formalDefinition="Optional normal status indicator of value with respect to normal range for this value. Often included by lab, even if the normal range itself is not included. Coded by ordinals in series HHH, HH, H, (nothing), L, LL, LLL; see openEHR terminology group normal_status." )
058    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-normal_statuses")
059    protected CODE_PHRASE normal_status;
060
061    /**
062     * Optional normal range.
063     */
064    @Child(name = "normal_range", type = {DV_INTERVAL.class}, order=1, min=0, max=1, modifier=false, summary=false)
065    @Description(shortDefinition="Optional normal range", formalDefinition="Optional normal range." )
066    protected DV_INTERVAL normal_range;
067
068    /**
069     * Optional tagged other reference ranges for this value in its particular measurement context.
070     */
071    @Child(name = "other_reference_ranges", type = {REFERENCE_RANGE.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
072    @Description(shortDefinition="Optional tagged other reference ranges for this value in its particular measurement context", formalDefinition="Optional tagged other reference ranges for this value in its particular measurement context." )
073    protected List<REFERENCE_RANGE> other_reference_rangesList;
074
075    private static final long serialVersionUID = 1994158948L;
076
077  /**
078   * Constructor
079   */
080    public DV_ORDERED() {
081      super();
082    }
083
084    /**
085     * @return {@link #normal_status} (Optional normal status indicator of value with respect to normal range for this value. Often included by lab, even if the normal range itself is not included. Coded by ordinals in series HHH, HH, H, (nothing), L, LL, LLL; see openEHR terminology group normal_status.)
086     */
087    public CODE_PHRASE getNormal_status() { 
088      if (this.normal_status == null)
089        if (Configuration.errorOnAutoCreate())
090          throw new Error("Attempt to auto-create DV_ORDERED.normal_status");
091        else if (Configuration.doAutoCreate())
092          this.normal_status = new CODE_PHRASE(); // cc
093      return this.normal_status;
094    }
095
096    public boolean hasNormal_status() { 
097      return this.normal_status != null && !this.normal_status.isEmpty();
098    }
099
100    /**
101     * @param value {@link #normal_status} (Optional normal status indicator of value with respect to normal range for this value. Often included by lab, even if the normal range itself is not included. Coded by ordinals in series HHH, HH, H, (nothing), L, LL, LLL; see openEHR terminology group normal_status.)
102     */
103    public DV_ORDERED setNormal_status(CODE_PHRASE value) { 
104      this.normal_status = value;
105      return this;
106    }
107
108    /**
109     * @return {@link #normal_range} (Optional normal range.)
110     */
111    public DV_INTERVAL getNormal_range() { 
112      if (this.normal_range == null)
113        if (Configuration.errorOnAutoCreate())
114          throw new Error("Attempt to auto-create DV_ORDERED.normal_range");
115        else if (Configuration.doAutoCreate())
116          this.normal_range = new DV_INTERVAL(); // cc
117      return this.normal_range;
118    }
119
120    public boolean hasNormal_range() { 
121      return this.normal_range != null && !this.normal_range.isEmpty();
122    }
123
124    /**
125     * @param value {@link #normal_range} (Optional normal range.)
126     */
127    public DV_ORDERED setNormal_range(DV_INTERVAL value) { 
128      this.normal_range = value;
129      return this;
130    }
131
132    /**
133     * @return {@link #other_reference_ranges} (Optional tagged other reference ranges for this value in its particular measurement context.)
134     */
135    public List<REFERENCE_RANGE> getOther_reference_rangesList() { 
136      if (this.other_reference_rangesList == null)
137        this.other_reference_rangesList = new ArrayList<REFERENCE_RANGE>();
138      return this.other_reference_rangesList;
139    }
140
141    /**
142     * @return Returns a reference to <code>this</code> for easy method chaining
143     */
144    public DV_ORDERED setOther_reference_rangesList(List<REFERENCE_RANGE> theOther_reference_ranges) { 
145      this.other_reference_rangesList = theOther_reference_ranges;
146      return this;
147    }
148
149    public boolean hasOther_reference_ranges() { 
150      if (this.other_reference_rangesList == null)
151        return false;
152      for (REFERENCE_RANGE item : this.other_reference_rangesList)
153        if (!item.isEmpty())
154          return true;
155      return false;
156    }
157
158    public REFERENCE_RANGE addOther_reference_ranges() { //3a
159      REFERENCE_RANGE t = new REFERENCE_RANGE();
160      if (this.other_reference_rangesList == null)
161        this.other_reference_rangesList = new ArrayList<REFERENCE_RANGE>();
162      this.other_reference_rangesList.add(t);
163      return t;
164    }
165
166    public DV_ORDERED addOther_reference_ranges(REFERENCE_RANGE t) { //3b
167      if (t == null)
168        return this;
169      if (this.other_reference_rangesList == null)
170        this.other_reference_rangesList = new ArrayList<REFERENCE_RANGE>();
171      this.other_reference_rangesList.add(t);
172      return this;
173    }
174
175    /**
176     * @return The first repetition of repeating field {@link #other_reference_ranges}, creating it if it does not already exist {3}
177     */
178    public REFERENCE_RANGE getOther_reference_rangesFirstRep() { 
179      if (getOther_reference_rangesList().isEmpty()) {
180        addOther_reference_ranges();
181      }
182      return getOther_reference_rangesList().get(0);
183    }
184
185      protected void listChildren(List<Property> children) {
186        super.listChildren(children);
187        children.add(new Property("normal_status", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Optional normal status indicator of value with respect to normal range for this value. Often included by lab, even if the normal range itself is not included. Coded by ordinals in series HHH, HH, H, (nothing), L, LL, LLL; see openEHR terminology group normal_status.", 0, 1, normal_status));
188        children.add(new Property("normal_range", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "Optional normal range.", 0, 1, normal_range));
189        children.add(new Property("other_reference_ranges", "http://openehr.org/fhir/StructureDefinition/REFERENCE-RANGE", "Optional tagged other reference ranges for this value in its particular measurement context.", 0, java.lang.Integer.MAX_VALUE, other_reference_rangesList));
190      }
191
192      @Override
193      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
194        switch (_hash) {
195        case -1868886454: /*normal_status*/  return new Property("normal_status", "http://openehr.org/fhir/StructureDefinition/CODE-PHRASE", "Optional normal status indicator of value with respect to normal range for this value. Often included by lab, even if the normal range itself is not included. Coded by ordinals in series HHH, HH, H, (nothing), L, LL, LLL; see openEHR terminology group normal_status.", 0, 1, normal_status);
196        case 492425189: /*normal_range*/  return new Property("normal_range", "http://openehr.org/fhir/StructureDefinition/DV-INTERVAL", "Optional normal range.", 0, 1, normal_range);
197        case -1668425831: /*other_reference_ranges*/  return new Property("other_reference_ranges", "http://openehr.org/fhir/StructureDefinition/REFERENCE-RANGE", "Optional tagged other reference ranges for this value in its particular measurement context.", 0, java.lang.Integer.MAX_VALUE, other_reference_rangesList);
198        default: return super.getNamedProperty(_hash, _name, _checkValid);
199        }
200
201      }
202
203      @Override
204      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
205        switch (hash) {
206        case -1868886454: /*normal_status*/ return this.normal_status == null ? new Base[0] : new Base[] {this.normal_status}; // CODE_PHRASE
207        case 492425189: /*normal_range*/ return this.normal_range == null ? new Base[0] : new Base[] {this.normal_range}; // DV_INTERVAL
208        case -1668425831: /*other_reference_ranges*/ return this.other_reference_rangesList == null ? new Base[0] : this.other_reference_rangesList.toArray(new Base[this.other_reference_rangesList.size()]); // REFERENCE_RANGE
209        default: return super.getProperty(hash, name, checkValid);
210        }
211
212      }
213
214      @Override
215      public Base setProperty(int hash, String name, Base value) throws FHIRException {
216        switch (hash) {
217        case -1868886454: // normal_status
218          this.normal_status = (CODE_PHRASE) value; // CODE_PHRASE
219          return value;
220        case 492425189: // normal_range
221          this.normal_range = (DV_INTERVAL) value; // DV_INTERVAL
222          return value;
223        case -1668425831: // other_reference_ranges
224          this.getOther_reference_rangesList().add((REFERENCE_RANGE) value); // REFERENCE_RANGE
225          return value;
226        default: return super.setProperty(hash, name, value);
227        }
228
229      }
230
231      @Override
232      public Base setProperty(String name, Base value) throws FHIRException {
233        if (name.equals("normal_status")) {
234          this.normal_status = (CODE_PHRASE) value; // CODE_PHRASE
235        } else if (name.equals("normal_range")) {
236          this.normal_range = (DV_INTERVAL) value; // DV_INTERVAL
237        } else if (name.equals("other_reference_ranges")) {
238          this.getOther_reference_rangesList().add((REFERENCE_RANGE) value); // REFERENCE_RANGE
239        } else
240          return super.setProperty(name, value);
241        return value;
242      }
243
244      @Override
245      public Base makeProperty(int hash, String name) throws FHIRException {
246        switch (hash) {
247        case -1868886454:  return getNormal_status();
248        case 492425189:  return getNormal_range();
249        case -1668425831:  return addOther_reference_ranges(); 
250        default: return super.makeProperty(hash, name);
251        }
252
253      }
254
255      @Override
256      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
257        switch (hash) {
258        case -1868886454: /*normal_status*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CODE-PHRASE"};
259        case 492425189: /*normal_range*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-INTERVAL"};
260        case -1668425831: /*other_reference_ranges*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/REFERENCE-RANGE"};
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("normal_status")) {
269          this.normal_status = new CODE_PHRASE();
270          return this.normal_status;
271        }
272        else if (name.equals("normal_range")) {
273          this.normal_range = new DV_INTERVAL();
274          return this.normal_range;
275        }
276        else if (name.equals("other_reference_ranges")) {
277          return addOther_reference_ranges();
278        }
279        else
280          return super.addChild(name);
281      }
282
283  public String fhirType() {
284    return "DV_ORDERED";
285
286  }
287
288      public abstract DV_ORDERED copy();
289
290      public void copyValues(DV_ORDERED dst) {
291        super.copyValues(dst);
292        dst.normal_status = normal_status == null ? null : normal_status.copy();
293        dst.normal_range = normal_range == null ? null : normal_range.copy();
294        if (other_reference_rangesList != null) {
295          dst.other_reference_rangesList = new ArrayList<REFERENCE_RANGE>();
296          for (REFERENCE_RANGE i : other_reference_rangesList)
297            dst.other_reference_rangesList.add(i.copy());
298        };
299      }
300
301      @Override
302      public boolean equalsDeep(Base other_) {
303        if (!super.equalsDeep(other_))
304          return false;
305        if (!(other_ instanceof DV_ORDERED))
306          return false;
307        DV_ORDERED o = (DV_ORDERED) other_;
308        return compareDeep(normal_status, o.normal_status, true) && compareDeep(normal_range, o.normal_range, true)
309           && compareDeep(other_reference_rangesList, o.other_reference_rangesList, true);
310      }
311
312      @Override
313      public boolean equalsShallow(Base other_) {
314        if (!super.equalsShallow(other_))
315          return false;
316        if (!(other_ instanceof DV_ORDERED))
317          return false;
318        DV_ORDERED o = (DV_ORDERED) other_;
319        return true;
320      }
321
322      public boolean isEmpty() {
323        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(normal_status, normal_range
324          , other_reference_rangesList);
325      }
326
327
328}
329