
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 the abstract notion of a single event in a series. This class is generic, allowing types to be generated which are locked to particular spatial types, such as EVENT<ITEM_LIST>. Subtypes express point or intveral data. 049 */ 050@DatatypeDef(name="EVENT") 051public abstract class EVENT extends LOCATABLE implements ICompositeType { 052 053 /** 054 * Time of this event. If the width is non-zero, it is the time point of the trailing edge of the event 055 */ 056 @Child(name = "time", type = {DV_DATE_TIME.class}, order=0, min=1, max=1, modifier=false, summary=false) 057 @Description(shortDefinition="Time of this event", formalDefinition="Time of this event. If the width is non-zero, it is the time point of the trailing edge of the event" ) 058 protected DV_DATE_TIME time; 059 060 /** 061 * Optional state data for this event. 062 */ 063 @Child(name = "state", type = {ITEM_STRUCTURE.class}, order=1, min=0, max=1, modifier=false, summary=false) 064 @Description(shortDefinition="Optional state data for this event", formalDefinition="Optional state data for this event." ) 065 protected ITEM_STRUCTURE state; 066 067 /** 068 * The data of this event. 069 */ 070 @Child(name = "data", type = {Reference.class}, order=2, min=1, max=1, modifier=false, summary=false) 071 @Description(shortDefinition="The data of this event", formalDefinition="The data of this event." ) 072 protected Any data; 073 074 private static final long serialVersionUID = 1692464616L; 075 076 /** 077 * Constructor 078 */ 079 public EVENT() { 080 super(); 081 } 082 083 /** 084 * Constructor 085 */ 086 public EVENT(DV_DATE_TIME time, Any data) { 087 super(); 088 this.setTime(time); 089 this.setData(data); 090 } 091 092 /** 093 * @return {@link #time} (Time of this event. If the width is non-zero, it is the time point of the trailing edge of the event) 094 */ 095 public DV_DATE_TIME getTime() { 096 if (this.time == null) 097 if (Configuration.errorOnAutoCreate()) 098 throw new Error("Attempt to auto-create EVENT.time"); 099 else if (Configuration.doAutoCreate()) 100 this.time = new DV_DATE_TIME(); // cc 101 return this.time; 102 } 103 104 public boolean hasTime() { 105 return this.time != null && !this.time.isEmpty(); 106 } 107 108 /** 109 * @param value {@link #time} (Time of this event. If the width is non-zero, it is the time point of the trailing edge of the event) 110 */ 111 public EVENT setTime(DV_DATE_TIME value) { 112 this.time = value; 113 return this; 114 } 115 116 /** 117 * @return {@link #state} (Optional state data for this event.) 118 */ 119 public ITEM_STRUCTURE getState() { 120 return this.state; 121 } 122 123 public boolean hasState() { 124 return this.state != null && !this.state.isEmpty(); 125 } 126 127 /** 128 * @param value {@link #state} (Optional state data for this event.) 129 */ 130 public EVENT setState(ITEM_STRUCTURE value) { 131 this.state = value; 132 return this; 133 } 134 135 /** 136 * @return {@link #data} (The data of this event.) 137 */ 138 public Any getData() { 139 return this.data; 140 } 141 142 public boolean hasData() { 143 return this.data != null && !this.data.isEmpty(); 144 } 145 146 /** 147 * @param value {@link #data} (The data of this event.) 148 */ 149 public EVENT setData(Any value) { 150 this.data = value; 151 return this; 152 } 153 154 protected void listChildren(List<Property> children) { 155 super.listChildren(children); 156 children.add(new Property("time", "http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME", "Time of this event. If the width is non-zero, it is the time point of the trailing edge of the event", 0, 1, time)); 157 children.add(new Property("state", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "Optional state data for this event.", 0, 1, state)); 158 children.add(new Property("data", "http://openehr.org/fhir/StructureDefinition/Any", "The data of this event.", 0, 1, data)); 159 } 160 161 @Override 162 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 163 switch (_hash) { 164 case 3560141: /*time*/ return new Property("time", "http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME", "Time of this event. If the width is non-zero, it is the time point of the trailing edge of the event", 0, 1, time); 165 case 109757585: /*state*/ return new Property("state", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "Optional state data for this event.", 0, 1, state); 166 case 3076010: /*data*/ return new Property("data", "http://openehr.org/fhir/StructureDefinition/Any", "The data of this event.", 0, 1, data); 167 default: return super.getNamedProperty(_hash, _name, _checkValid); 168 } 169 170 } 171 172 @Override 173 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 174 switch (hash) { 175 case 3560141: /*time*/ return this.time == null ? new Base[0] : new Base[] {this.time}; // DV_DATE_TIME 176 case 109757585: /*state*/ return this.state == null ? new Base[0] : new Base[] {this.state}; // ITEM_STRUCTURE 177 case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Any 178 default: return super.getProperty(hash, name, checkValid); 179 } 180 181 } 182 183 @Override 184 public Base setProperty(int hash, String name, Base value) throws FHIRException { 185 switch (hash) { 186 case 3560141: // time 187 this.time = (DV_DATE_TIME) value; // DV_DATE_TIME 188 return value; 189 case 109757585: // state 190 this.state = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE 191 return value; 192 case 3076010: // data 193 this.data = (Any) value; // Any 194 return value; 195 default: return super.setProperty(hash, name, value); 196 } 197 198 } 199 200 @Override 201 public Base setProperty(String name, Base value) throws FHIRException { 202 if (name.equals("time")) { 203 this.time = (DV_DATE_TIME) value; // DV_DATE_TIME 204 } else if (name.equals("state")) { 205 this.state = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE 206 } else if (name.equals("data")) { 207 this.data = (Any) value; // Any 208 } else 209 return super.setProperty(name, value); 210 return value; 211 } 212 213 @Override 214 public Base makeProperty(int hash, String name) throws FHIRException { 215 switch (hash) { 216 case 3560141: return getTime(); 217 case 109757585: /*div*/ 218 throw new Error("Unable to make an instance of the abstract property 'state'"); 219 case 3076010: /*div*/ 220 throw new Error("Unable to make an instance of the abstract property 'data'"); 221 default: return super.makeProperty(hash, name); 222 } 223 224 } 225 226 @Override 227 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 228 switch (hash) { 229 case 3560141: /*time*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME"}; 230 case 109757585: /*state*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE"}; 231 case 3076010: /*data*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/Any"}; 232 default: return super.getTypesForProperty(hash, name); 233 } 234 235 } 236 237 @Override 238 public Base addChild(String name) throws FHIRException { 239 if (name.equals("time")) { 240 this.time = new DV_DATE_TIME(); 241 return this.time; 242 } 243 else if (name.equals("state")) { 244 throw new FHIRException("Cannot call addChild on an abstract type EVENT.state"); 245 } 246 else if (name.equals("data")) { 247 throw new FHIRException("Cannot call addChild on an abstract type EVENT.data"); 248 } 249 else 250 return super.addChild(name); 251 } 252 253 public String fhirType() { 254 return "EVENT"; 255 256 } 257 258 public abstract EVENT copy(); 259 260 public void copyValues(EVENT dst) { 261 super.copyValues(dst); 262 dst.time = time == null ? null : time.copy(); 263 dst.state = state == null ? null : state.copy(); 264 dst.data = data == null ? null : data.copy(); 265 } 266 267 @Override 268 public boolean equalsDeep(Base other_) { 269 if (!super.equalsDeep(other_)) 270 return false; 271 if (!(other_ instanceof EVENT)) 272 return false; 273 EVENT o = (EVENT) other_; 274 return compareDeep(time, o.time, true) && compareDeep(state, o.state, true) && compareDeep(data, o.data, true) 275 ; 276 } 277 278 @Override 279 public boolean equalsShallow(Base other_) { 280 if (!super.equalsShallow(other_)) 281 return false; 282 if (!(other_ instanceof EVENT)) 283 return false; 284 EVENT o = (EVENT) other_; 285 return true; 286 } 287 288 public boolean isEmpty() { 289 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(time, state, data); 290 } 291 292 293} 294