
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 relational database style table data structure, in which columns are named and ordered with respect to each other. Implemented using Cluster-per-row encoding. Each row Cluster must have an identical number of Elements, each of which in turn must have identical names and value types in the corresponding positions in each row. Some columns may be designated key' columns, containing key data for each row, in the manner of relational tables. This allows row-naming, where each row represents a body site, a blood antigen etc. All values in a column have the same data type. Used for representing any data which is logically a table of values, such as blood pressure, most protocols, many blood tests etc. Misuse: Not to be used for time-based data, which should be represented with the temporal class HISTORY. The table may be empty. 049 */ 050@DatatypeDef(name="ITEM_TABLE") 051public class ITEM_TABLE extends ITEM_STRUCTURE implements ICompositeType { 052 053 /** 054 * Physical representation of the table as a list of CLUSTERs, each containing the data of one row of the table. 055 */ 056 @Child(name = "rows", type = {CLUSTER.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 057 @Description(shortDefinition="Physical representation of the table as a list of CLUSTERs, each containing the data of one row of the table", formalDefinition="Physical representation of the table as a list of CLUSTERs, each containing the data of one row of the table." ) 058 protected List<CLUSTER> rowsList; 059 060 private static final long serialVersionUID = 514606961L; 061 062 /** 063 * Constructor 064 */ 065 public ITEM_TABLE() { 066 super(); 067 } 068 069 /** 070 * @return {@link #rows} (Physical representation of the table as a list of CLUSTERs, each containing the data of one row of the table.) 071 */ 072 public List<CLUSTER> getRowsList() { 073 if (this.rowsList == null) 074 this.rowsList = new ArrayList<CLUSTER>(); 075 return this.rowsList; 076 } 077 078 /** 079 * @return Returns a reference to <code>this</code> for easy method chaining 080 */ 081 public ITEM_TABLE setRowsList(List<CLUSTER> theRows) { 082 this.rowsList = theRows; 083 return this; 084 } 085 086 public boolean hasRows() { 087 if (this.rowsList == null) 088 return false; 089 for (CLUSTER item : this.rowsList) 090 if (!item.isEmpty()) 091 return true; 092 return false; 093 } 094 095 public CLUSTER addRows() { //3a 096 CLUSTER t = new CLUSTER(); 097 if (this.rowsList == null) 098 this.rowsList = new ArrayList<CLUSTER>(); 099 this.rowsList.add(t); 100 return t; 101 } 102 103 public ITEM_TABLE addRows(CLUSTER t) { //3b 104 if (t == null) 105 return this; 106 if (this.rowsList == null) 107 this.rowsList = new ArrayList<CLUSTER>(); 108 this.rowsList.add(t); 109 return this; 110 } 111 112 /** 113 * @return The first repetition of repeating field {@link #rows}, creating it if it does not already exist {3} 114 */ 115 public CLUSTER getRowsFirstRep() { 116 if (getRowsList().isEmpty()) { 117 addRows(); 118 } 119 return getRowsList().get(0); 120 } 121 122 protected void listChildren(List<Property> children) { 123 super.listChildren(children); 124 children.add(new Property("rows", "http://openehr.org/fhir/StructureDefinition/CLUSTER", "Physical representation of the table as a list of CLUSTERs, each containing the data of one row of the table.", 0, java.lang.Integer.MAX_VALUE, rowsList)); 125 } 126 127 @Override 128 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 129 switch (_hash) { 130 case 3506649: /*rows*/ return new Property("rows", "http://openehr.org/fhir/StructureDefinition/CLUSTER", "Physical representation of the table as a list of CLUSTERs, each containing the data of one row of the table.", 0, java.lang.Integer.MAX_VALUE, rowsList); 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 3506649: /*rows*/ return this.rowsList == null ? new Base[0] : this.rowsList.toArray(new Base[this.rowsList.size()]); // CLUSTER 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 3506649: // rows 149 this.getRowsList().add((CLUSTER) value); // CLUSTER 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("rows")) { 159 this.getRowsList().add((CLUSTER) value); // CLUSTER 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 3506649: return addRows(); 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 3506649: /*rows*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CLUSTER"}; 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("rows")) { 186 return addRows(); 187 } 188 else 189 return super.addChild(name); 190 } 191 192 public String fhirType() { 193 return "ITEM_TABLE"; 194 195 } 196 197 public ITEM_TABLE copy() { 198 ITEM_TABLE dst = new ITEM_TABLE(); 199 copyValues(dst); 200 return dst; 201 } 202 203 public void copyValues(ITEM_TABLE dst) { 204 super.copyValues(dst); 205 if (rowsList != null) { 206 dst.rowsList = new ArrayList<CLUSTER>(); 207 for (CLUSTER i : rowsList) 208 dst.rowsList.add(i.copy()); 209 }; 210 } 211 212 protected ITEM_TABLE 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_TABLE)) 221 return false; 222 ITEM_TABLE o = (ITEM_TABLE) other_; 223 return compareDeep(rowsList, o.rowsList, true); 224 } 225 226 @Override 227 public boolean equalsShallow(Base other_) { 228 if (!super.equalsShallow(other_)) 229 return false; 230 if (!(other_ instanceof ITEM_TABLE)) 231 return false; 232 ITEM_TABLE o = (ITEM_TABLE) other_; 233 return true; 234 } 235 236 public boolean isEmpty() { 237 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(rowsList); 238 } 239 240 241} 242