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 list data structure, where each item has a value and can be referred to by a name and a positional index in the list. The list may be empty. ITEM_LIST is used to represent any data which is logically a list of values, such as blood pressure, most protocols, many blood tests etc. Not to be used for time-based lists, which should be represented with the proper temporal class, i.e. HISTORY.
049 */
050@DatatypeDef(name="ITEM_LIST")
051public class ITEM_LIST extends ITEM_STRUCTURE implements ICompositeType {
052
053    /**
054     * Physical representation of the list.
055     */
056    @Child(name = "items", type = {ELEMENT.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
057    @Description(shortDefinition="Physical representation of the list", formalDefinition="Physical representation of the list." )
058    protected List<ELEMENT> itemsList;
059
060    private static final long serialVersionUID = 42602380L;
061
062  /**
063   * Constructor
064   */
065    public ITEM_LIST() {
066      super();
067    }
068
069    /**
070     * @return {@link #items} (Physical representation of the list.)
071     */
072    public List<ELEMENT> getItemsList() { 
073      if (this.itemsList == null)
074        this.itemsList = new ArrayList<ELEMENT>();
075      return this.itemsList;
076    }
077
078    /**
079     * @return Returns a reference to <code>this</code> for easy method chaining
080     */
081    public ITEM_LIST setItemsList(List<ELEMENT> theItems) { 
082      this.itemsList = theItems;
083      return this;
084    }
085
086    public boolean hasItems() { 
087      if (this.itemsList == null)
088        return false;
089      for (ELEMENT item : this.itemsList)
090        if (!item.isEmpty())
091          return true;
092      return false;
093    }
094
095    public ELEMENT addItems() { //3a
096      ELEMENT t = new ELEMENT();
097      if (this.itemsList == null)
098        this.itemsList = new ArrayList<ELEMENT>();
099      this.itemsList.add(t);
100      return t;
101    }
102
103    public ITEM_LIST addItems(ELEMENT t) { //3b
104      if (t == null)
105        return this;
106      if (this.itemsList == null)
107        this.itemsList = new ArrayList<ELEMENT>();
108      this.itemsList.add(t);
109      return this;
110    }
111
112    /**
113     * @return The first repetition of repeating field {@link #items}, creating it if it does not already exist {3}
114     */
115    public ELEMENT getItemsFirstRep() { 
116      if (getItemsList().isEmpty()) {
117        addItems();
118      }
119      return getItemsList().get(0);
120    }
121
122      protected void listChildren(List<Property> children) {
123        super.listChildren(children);
124        children.add(new Property("items", "http://openehr.org/fhir/StructureDefinition/ELEMENT", "Physical representation of the list.", 0, java.lang.Integer.MAX_VALUE, itemsList));
125      }
126
127      @Override
128      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
129        switch (_hash) {
130        case 100526016: /*items*/  return new Property("items", "http://openehr.org/fhir/StructureDefinition/ELEMENT", "Physical representation of the list.", 0, java.lang.Integer.MAX_VALUE, itemsList);
131        default: return super.getNamedProperty(_hash, _name, _checkValid);
132        }
133
134      }
135
136      @Override
137      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
138        switch (hash) {
139        case 100526016: /*items*/ return this.itemsList == null ? new Base[0] : this.itemsList.toArray(new Base[this.itemsList.size()]); // ELEMENT
140        default: return super.getProperty(hash, name, checkValid);
141        }
142
143      }
144
145      @Override
146      public Base setProperty(int hash, String name, Base value) throws FHIRException {
147        switch (hash) {
148        case 100526016: // items
149          this.getItemsList().add((ELEMENT) value); // ELEMENT
150          return value;
151        default: return super.setProperty(hash, name, value);
152        }
153
154      }
155
156      @Override
157      public Base setProperty(String name, Base value) throws FHIRException {
158        if (name.equals("items")) {
159          this.getItemsList().add((ELEMENT) value); // ELEMENT
160        } else
161          return super.setProperty(name, value);
162        return value;
163      }
164
165      @Override
166      public Base makeProperty(int hash, String name) throws FHIRException {
167        switch (hash) {
168        case 100526016:  return addItems(); 
169        default: return super.makeProperty(hash, name);
170        }
171
172      }
173
174      @Override
175      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
176        switch (hash) {
177        case 100526016: /*items*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ELEMENT"};
178        default: return super.getTypesForProperty(hash, name);
179        }
180
181      }
182
183      @Override
184      public Base addChild(String name) throws FHIRException {
185        if (name.equals("items")) {
186          return addItems();
187        }
188        else
189          return super.addChild(name);
190      }
191
192  public String fhirType() {
193    return "ITEM_LIST";
194
195  }
196
197      public ITEM_LIST copy() {
198        ITEM_LIST dst = new ITEM_LIST();
199        copyValues(dst);
200        return dst;
201      }
202
203      public void copyValues(ITEM_LIST dst) {
204        super.copyValues(dst);
205        if (itemsList != null) {
206          dst.itemsList = new ArrayList<ELEMENT>();
207          for (ELEMENT i : itemsList)
208            dst.itemsList.add(i.copy());
209        };
210      }
211
212      protected ITEM_LIST typedCopy() {
213        return copy();
214      }
215
216      @Override
217      public boolean equalsDeep(Base other_) {
218        if (!super.equalsDeep(other_))
219          return false;
220        if (!(other_ instanceof ITEM_LIST))
221          return false;
222        ITEM_LIST o = (ITEM_LIST) other_;
223        return compareDeep(itemsList, o.itemsList, true);
224      }
225
226      @Override
227      public boolean equalsShallow(Base other_) {
228        if (!super.equalsShallow(other_))
229          return false;
230        if (!(other_ instanceof ITEM_LIST))
231          return false;
232        ITEM_LIST o = (ITEM_LIST) other_;
233        return true;
234      }
235
236      public boolean isEmpty() {
237        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(itemsList);
238      }
239
240
241}
242