
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 * Entry subtype for all clinical data in the past or present, i.e. which (by the time it is recorded) has already occurred. OBSERVATION data is expressed using the class HISTORY<T>, which guarantees that it is situated in time. OBSERVATION is used for all notionally objective (i.e. measured in some way) observations of phenomena, and patient-reported phenomena, e.g. pain. Not to be used for recording opinion or future statements of any kind, including instructions, intentions, plans etc. 049 */ 050@DatatypeDef(name="OBSERVATION") 051public class OBSERVATION extends CARE_ENTRY implements ICompositeType { 052 053 /** 054 * The data of this observation, in the form of a history of values which may be of any complexity. 055 */ 056 @Child(name = "data", type = {HISTORY.class}, order=0, min=1, max=1, modifier=false, summary=false) 057 @Description(shortDefinition="The data of this observation, in the form of a history of values which may be of any complexity", formalDefinition="The data of this observation, in the form of a history of values which may be of any complexity." ) 058 protected HISTORY data; 059 060 /** 061 * Optional recording of the state of subject of this observation during the observation process, in the form of a separate history of values which may be of any complexity. State may also be recorded within the History of the data attribute. 062 */ 063 @Child(name = "state", type = {HISTORY.class}, order=1, min=0, max=1, modifier=false, summary=false) 064 @Description(shortDefinition="Optional recording of the state of subject of this observation during the observation process", formalDefinition="Optional recording of the state of subject of this observation during the observation process, in the form of a separate history of values which may be of any complexity. State may also be recorded within the History of the data attribute." ) 065 protected HISTORY state; 066 067 private static final long serialVersionUID = -787276715L; 068 069 /** 070 * Constructor 071 */ 072 public OBSERVATION() { 073 super(); 074 } 075 076 /** 077 * Constructor 078 */ 079 public OBSERVATION(HISTORY data) { 080 super(); 081 this.setData(data); 082 } 083 084 /** 085 * @return {@link #data} (The data of this observation, in the form of a history of values which may be of any complexity.) 086 */ 087 public HISTORY getData() { 088 if (this.data == null) 089 if (Configuration.errorOnAutoCreate()) 090 throw new Error("Attempt to auto-create OBSERVATION.data"); 091 else if (Configuration.doAutoCreate()) 092 this.data = new HISTORY(); // cc 093 return this.data; 094 } 095 096 public boolean hasData() { 097 return this.data != null && !this.data.isEmpty(); 098 } 099 100 /** 101 * @param value {@link #data} (The data of this observation, in the form of a history of values which may be of any complexity.) 102 */ 103 public OBSERVATION setData(HISTORY value) { 104 this.data = value; 105 return this; 106 } 107 108 /** 109 * @return {@link #state} (Optional recording of the state of subject of this observation during the observation process, in the form of a separate history of values which may be of any complexity. State may also be recorded within the History of the data attribute.) 110 */ 111 public HISTORY getState() { 112 if (this.state == null) 113 if (Configuration.errorOnAutoCreate()) 114 throw new Error("Attempt to auto-create OBSERVATION.state"); 115 else if (Configuration.doAutoCreate()) 116 this.state = new HISTORY(); // cc 117 return this.state; 118 } 119 120 public boolean hasState() { 121 return this.state != null && !this.state.isEmpty(); 122 } 123 124 /** 125 * @param value {@link #state} (Optional recording of the state of subject of this observation during the observation process, in the form of a separate history of values which may be of any complexity. State may also be recorded within the History of the data attribute.) 126 */ 127 public OBSERVATION setState(HISTORY value) { 128 this.state = value; 129 return this; 130 } 131 132 protected void listChildren(List<Property> children) { 133 super.listChildren(children); 134 children.add(new Property("data", "http://openehr.org/fhir/StructureDefinition/HISTORY", "The data of this observation, in the form of a history of values which may be of any complexity.", 0, 1, data)); 135 children.add(new Property("state", "http://openehr.org/fhir/StructureDefinition/HISTORY", "Optional recording of the state of subject of this observation during the observation process, in the form of a separate history of values which may be of any complexity. State may also be recorded within the History of the data attribute.", 0, 1, state)); 136 } 137 138 @Override 139 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 140 switch (_hash) { 141 case 3076010: /*data*/ return new Property("data", "http://openehr.org/fhir/StructureDefinition/HISTORY", "The data of this observation, in the form of a history of values which may be of any complexity.", 0, 1, data); 142 case 109757585: /*state*/ return new Property("state", "http://openehr.org/fhir/StructureDefinition/HISTORY", "Optional recording of the state of subject of this observation during the observation process, in the form of a separate history of values which may be of any complexity. State may also be recorded within the History of the data attribute.", 0, 1, state); 143 default: return super.getNamedProperty(_hash, _name, _checkValid); 144 } 145 146 } 147 148 @Override 149 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 150 switch (hash) { 151 case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // HISTORY 152 case 109757585: /*state*/ return this.state == null ? new Base[0] : new Base[] {this.state}; // HISTORY 153 default: return super.getProperty(hash, name, checkValid); 154 } 155 156 } 157 158 @Override 159 public Base setProperty(int hash, String name, Base value) throws FHIRException { 160 switch (hash) { 161 case 3076010: // data 162 this.data = (HISTORY) value; // HISTORY 163 return value; 164 case 109757585: // state 165 this.state = (HISTORY) value; // HISTORY 166 return value; 167 default: return super.setProperty(hash, name, value); 168 } 169 170 } 171 172 @Override 173 public Base setProperty(String name, Base value) throws FHIRException { 174 if (name.equals("data")) { 175 this.data = (HISTORY) value; // HISTORY 176 } else if (name.equals("state")) { 177 this.state = (HISTORY) value; // HISTORY 178 } else 179 return super.setProperty(name, value); 180 return value; 181 } 182 183 @Override 184 public Base makeProperty(int hash, String name) throws FHIRException { 185 switch (hash) { 186 case 3076010: return getData(); 187 case 109757585: return getState(); 188 default: return super.makeProperty(hash, name); 189 } 190 191 } 192 193 @Override 194 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 195 switch (hash) { 196 case 3076010: /*data*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/HISTORY"}; 197 case 109757585: /*state*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/HISTORY"}; 198 default: return super.getTypesForProperty(hash, name); 199 } 200 201 } 202 203 @Override 204 public Base addChild(String name) throws FHIRException { 205 if (name.equals("data")) { 206 this.data = new HISTORY(); 207 return this.data; 208 } 209 else if (name.equals("state")) { 210 this.state = new HISTORY(); 211 return this.state; 212 } 213 else 214 return super.addChild(name); 215 } 216 217 public String fhirType() { 218 return "OBSERVATION"; 219 220 } 221 222 public OBSERVATION copy() { 223 OBSERVATION dst = new OBSERVATION(); 224 copyValues(dst); 225 return dst; 226 } 227 228 public void copyValues(OBSERVATION dst) { 229 super.copyValues(dst); 230 dst.data = data == null ? null : data.copy(); 231 dst.state = state == null ? null : state.copy(); 232 } 233 234 protected OBSERVATION typedCopy() { 235 return copy(); 236 } 237 238 @Override 239 public boolean equalsDeep(Base other_) { 240 if (!super.equalsDeep(other_)) 241 return false; 242 if (!(other_ instanceof OBSERVATION)) 243 return false; 244 OBSERVATION o = (OBSERVATION) other_; 245 return compareDeep(data, o.data, true) && compareDeep(state, o.state, true); 246 } 247 248 @Override 249 public boolean equalsShallow(Base other_) { 250 if (!super.equalsShallow(other_)) 251 return false; 252 if (!(other_ instanceof OBSERVATION)) 253 return false; 254 OBSERVATION o = (OBSERVATION) other_; 255 return true; 256 } 257 258 public boolean isEmpty() { 259 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(data, state); 260 } 261 262 263} 264