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 * Logical tree data structure. The tree may be empty. Used for representing data which are logically a tree such as audiology results, microbiology results, biochemistry results.
049 */
050@DatatypeDef(name="ITEM_TREE")
051public class ITEM_TREE extends ITEM_STRUCTURE implements ICompositeType {
052
053    /**
054     * The items comprising the ITEM_TREE. Can include 0 or more CLUSTERs and/or 0 or more individual ELEMENTs.
055     */
056    @Child(name = "items", type = {ITEM.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
057    @Description(shortDefinition="The items comprising the ITEM_TREE. Can include 0 or more CLUSTERs and/or 0 or more individual ELEMENTs", formalDefinition="The items comprising the ITEM_TREE. Can include 0 or more CLUSTERs and/or 0 or more individual ELEMENTs." )
058    protected List<ITEM> itemsList;
059
060    private static final long serialVersionUID = -285267557L;
061
062  /**
063   * Constructor
064   */
065    public ITEM_TREE() {
066      super();
067    }
068
069    /**
070     * @return {@link #items} (The items comprising the ITEM_TREE. Can include 0 or more CLUSTERs and/or 0 or more individual ELEMENTs.)
071     */
072    public List<ITEM> getItemsList() { 
073      if (this.itemsList == null)
074        this.itemsList = new ArrayList<ITEM>();
075      return this.itemsList;
076    }
077
078    /**
079     * @return Returns a reference to <code>this</code> for easy method chaining
080     */
081    public ITEM_TREE setItemsList(List<ITEM> theItems) { 
082      this.itemsList = theItems;
083      return this;
084    }
085
086    public boolean hasItems() { 
087      if (this.itemsList == null)
088        return false;
089      for (ITEM item : this.itemsList)
090        if (!item.isEmpty())
091          return true;
092      return false;
093    }
094
095    public ITEM_TREE addItems(ITEM t) { //3b
096      if (t == null)
097        return this;
098      if (this.itemsList == null)
099        this.itemsList = new ArrayList<ITEM>();
100      this.itemsList.add(t);
101      return this;
102    }
103
104      protected void listChildren(List<Property> children) {
105        super.listChildren(children);
106        children.add(new Property("items", "http://openehr.org/fhir/StructureDefinition/ITEM", "The items comprising the ITEM_TREE. Can include 0 or more CLUSTERs and/or 0 or more individual ELEMENTs.", 0, java.lang.Integer.MAX_VALUE, itemsList));
107      }
108
109      @Override
110      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
111        switch (_hash) {
112        case 100526016: /*items*/  return new Property("items", "http://openehr.org/fhir/StructureDefinition/ITEM", "The items comprising the ITEM_TREE. Can include 0 or more CLUSTERs and/or 0 or more individual ELEMENTs.", 0, java.lang.Integer.MAX_VALUE, itemsList);
113        default: return super.getNamedProperty(_hash, _name, _checkValid);
114        }
115
116      }
117
118      @Override
119      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
120        switch (hash) {
121        case 100526016: /*items*/ return this.itemsList == null ? new Base[0] : this.itemsList.toArray(new Base[this.itemsList.size()]); // ITEM
122        default: return super.getProperty(hash, name, checkValid);
123        }
124
125      }
126
127      @Override
128      public Base setProperty(int hash, String name, Base value) throws FHIRException {
129        switch (hash) {
130        case 100526016: // items
131          this.getItemsList().add((ITEM) value); // ITEM
132          return value;
133        default: return super.setProperty(hash, name, value);
134        }
135
136      }
137
138      @Override
139      public Base setProperty(String name, Base value) throws FHIRException {
140        if (name.equals("items")) {
141          this.getItemsList().add((ITEM) value); // ITEM
142        } else
143          return super.setProperty(name, value);
144        return value;
145      }
146
147      @Override
148      public Base makeProperty(int hash, String name) throws FHIRException {
149        switch (hash) {
150        case 100526016: /*div*/
151          throw new Error("Unable to make an instance of the abstract property 'items'");
152        default: return super.makeProperty(hash, name);
153        }
154
155      }
156
157      @Override
158      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
159        switch (hash) {
160        case 100526016: /*items*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ITEM"};
161        default: return super.getTypesForProperty(hash, name);
162        }
163
164      }
165
166      @Override
167      public Base addChild(String name) throws FHIRException {
168        if (name.equals("items")) {
169          throw new FHIRException("Cannot call addChild on an abstract type ITEM_TREE.items");
170        }
171        else
172          return super.addChild(name);
173      }
174
175  public String fhirType() {
176    return "ITEM_TREE";
177
178  }
179
180      public ITEM_TREE copy() {
181        ITEM_TREE dst = new ITEM_TREE();
182        copyValues(dst);
183        return dst;
184      }
185
186      public void copyValues(ITEM_TREE dst) {
187        super.copyValues(dst);
188        if (itemsList != null) {
189          dst.itemsList = new ArrayList<ITEM>();
190          for (ITEM i : itemsList)
191            dst.itemsList.add(i.copy());
192        };
193      }
194
195      protected ITEM_TREE typedCopy() {
196        return copy();
197      }
198
199      @Override
200      public boolean equalsDeep(Base other_) {
201        if (!super.equalsDeep(other_))
202          return false;
203        if (!(other_ instanceof ITEM_TREE))
204          return false;
205        ITEM_TREE o = (ITEM_TREE) other_;
206        return compareDeep(itemsList, o.itemsList, true);
207      }
208
209      @Override
210      public boolean equalsShallow(Base other_) {
211        if (!super.equalsShallow(other_))
212          return false;
213        if (!(other_ instanceof ITEM_TREE))
214          return false;
215        ITEM_TREE o = (ITEM_TREE) other_;
216        return true;
217      }
218
219      public boolean isEmpty() {
220        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(itemsList);
221      }
222
223
224}
225