
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 * The leaf variant of ITEM, to which a DATA_VALUE instance is attached. 049 */ 050@DatatypeDef(name="ELEMENT") 051public class ELEMENT extends ITEM implements ICompositeType { 052 053 /** 054 * Flavour of null value, e.g. 253|unknown|, 271|no information|, 272|masked|, and 273|not applicable|. 055 */ 056 @Child(name = "null_flavour", type = {DV_CODED_TEXT.class}, order=0, min=0, max=1, modifier=false, summary=false) 057 @Description(shortDefinition="Flavour of null value, e.g. 253|unknown|, 271|no information|, 272|masked|, and 273|not applicable|", formalDefinition="Flavour of null value, e.g. 253|unknown|, 271|no information|, 272|masked|, and 273|not applicable|." ) 058 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-null_flavours") 059 protected DV_CODED_TEXT null_flavour; 060 061 /** 062 * Property representing leaf value object of ELEMENT. In real data, any concrete subtype of DATA_VALUE can be used. 063 */ 064 @Child(name = "value", type = {DATA_VALUE.class}, order=1, min=0, max=1, modifier=false, summary=false) 065 @Description(shortDefinition="Property representing leaf value object of ELEMENT (any concrete subtype of DATA_VALUE)", formalDefinition="Property representing leaf value object of ELEMENT. In real data, any concrete subtype of DATA_VALUE can be used." ) 066 protected DATA_VALUE value; 067 068 /** 069 * Optional specific reason for null value; if set, null_flavour must be set. Null reason may apply only to a minority of clinical data, commonly needed in reporting contexts. 070 */ 071 @Child(name = "null_reason", type = {DV_TEXT.class}, order=2, min=0, max=1, modifier=false, summary=false) 072 @Description(shortDefinition="Optional specific reason for null value; if set, null_flavour must be set", formalDefinition="Optional specific reason for null value; if set, null_flavour must be set. Null reason may apply only to a minority of clinical data, commonly needed in reporting contexts." ) 073 protected DV_TEXT null_reason; 074 075 private static final long serialVersionUID = -741031778L; 076 077 /** 078 * Constructor 079 */ 080 public ELEMENT() { 081 super(); 082 } 083 084 /** 085 * @return {@link #null_flavour} (Flavour of null value, e.g. 253|unknown|, 271|no information|, 272|masked|, and 273|not applicable|.) 086 */ 087 public DV_CODED_TEXT getNull_flavour() { 088 if (this.null_flavour == null) 089 if (Configuration.errorOnAutoCreate()) 090 throw new Error("Attempt to auto-create ELEMENT.null_flavour"); 091 else if (Configuration.doAutoCreate()) 092 this.null_flavour = new DV_CODED_TEXT(); // cc 093 return this.null_flavour; 094 } 095 096 public boolean hasNull_flavour() { 097 return this.null_flavour != null && !this.null_flavour.isEmpty(); 098 } 099 100 /** 101 * @param value {@link #null_flavour} (Flavour of null value, e.g. 253|unknown|, 271|no information|, 272|masked|, and 273|not applicable|.) 102 */ 103 public ELEMENT setNull_flavour(DV_CODED_TEXT value) { 104 this.null_flavour = value; 105 return this; 106 } 107 108 /** 109 * @return {@link #value} (Property representing leaf value object of ELEMENT. In real data, any concrete subtype of DATA_VALUE can be used.) 110 */ 111 public DATA_VALUE getValue() { 112 return this.value; 113 } 114 115 public boolean hasValue() { 116 return this.value != null && !this.value.isEmpty(); 117 } 118 119 /** 120 * @param value {@link #value} (Property representing leaf value object of ELEMENT. In real data, any concrete subtype of DATA_VALUE can be used.) 121 */ 122 public ELEMENT setValue(DATA_VALUE value) { 123 this.value = value; 124 return this; 125 } 126 127 /** 128 * @return {@link #null_reason} (Optional specific reason for null value; if set, null_flavour must be set. Null reason may apply only to a minority of clinical data, commonly needed in reporting contexts.) 129 */ 130 public DV_TEXT getNull_reason() { 131 if (this.null_reason == null) 132 if (Configuration.errorOnAutoCreate()) 133 throw new Error("Attempt to auto-create ELEMENT.null_reason"); 134 else if (Configuration.doAutoCreate()) 135 this.null_reason = new DV_TEXT(); // cc 136 return this.null_reason; 137 } 138 139 public boolean hasNull_reason() { 140 return this.null_reason != null && !this.null_reason.isEmpty(); 141 } 142 143 /** 144 * @param value {@link #null_reason} (Optional specific reason for null value; if set, null_flavour must be set. Null reason may apply only to a minority of clinical data, commonly needed in reporting contexts.) 145 */ 146 public ELEMENT setNull_reason(DV_TEXT value) { 147 this.null_reason = value; 148 return this; 149 } 150 151 protected void listChildren(List<Property> children) { 152 super.listChildren(children); 153 children.add(new Property("null_flavour", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Flavour of null value, e.g. 253|unknown|, 271|no information|, 272|masked|, and 273|not applicable|.", 0, 1, null_flavour)); 154 children.add(new Property("value", "http://openehr.org/fhir/StructureDefinition/DATA-VALUE", "Property representing leaf value object of ELEMENT. In real data, any concrete subtype of DATA_VALUE can be used.", 0, 1, value)); 155 children.add(new Property("null_reason", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Optional specific reason for null value; if set, null_flavour must be set. Null reason may apply only to a minority of clinical data, commonly needed in reporting contexts.", 0, 1, null_reason)); 156 } 157 158 @Override 159 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 160 switch (_hash) { 161 case 1423585081: /*null_flavour*/ return new Property("null_flavour", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "Flavour of null value, e.g. 253|unknown|, 271|no information|, 272|masked|, and 273|not applicable|.", 0, 1, null_flavour); 162 case 111972721: /*value*/ return new Property("value", "http://openehr.org/fhir/StructureDefinition/DATA-VALUE", "Property representing leaf value object of ELEMENT. In real data, any concrete subtype of DATA_VALUE can be used.", 0, 1, value); 163 case 1768477692: /*null_reason*/ return new Property("null_reason", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Optional specific reason for null value; if set, null_flavour must be set. Null reason may apply only to a minority of clinical data, commonly needed in reporting contexts.", 0, 1, null_reason); 164 default: return super.getNamedProperty(_hash, _name, _checkValid); 165 } 166 167 } 168 169 @Override 170 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 171 switch (hash) { 172 case 1423585081: /*null_flavour*/ return this.null_flavour == null ? new Base[0] : new Base[] {this.null_flavour}; // DV_CODED_TEXT 173 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DATA_VALUE 174 case 1768477692: /*null_reason*/ return this.null_reason == null ? new Base[0] : new Base[] {this.null_reason}; // DV_TEXT 175 default: return super.getProperty(hash, name, checkValid); 176 } 177 178 } 179 180 @Override 181 public Base setProperty(int hash, String name, Base value) throws FHIRException { 182 switch (hash) { 183 case 1423585081: // null_flavour 184 this.null_flavour = (DV_CODED_TEXT) value; // DV_CODED_TEXT 185 return value; 186 case 111972721: // value 187 this.value = (DATA_VALUE) value; // DATA_VALUE 188 return value; 189 case 1768477692: // null_reason 190 this.null_reason = (DV_TEXT) value; // DV_TEXT 191 return value; 192 default: return super.setProperty(hash, name, value); 193 } 194 195 } 196 197 @Override 198 public Base setProperty(String name, Base value) throws FHIRException { 199 if (name.equals("null_flavour")) { 200 this.null_flavour = (DV_CODED_TEXT) value; // DV_CODED_TEXT 201 } else if (name.equals("value")) { 202 this.value = (DATA_VALUE) value; // DATA_VALUE 203 } else if (name.equals("null_reason")) { 204 this.null_reason = (DV_TEXT) value; // DV_TEXT 205 } else 206 return super.setProperty(name, value); 207 return value; 208 } 209 210 @Override 211 public Base makeProperty(int hash, String name) throws FHIRException { 212 switch (hash) { 213 case 1423585081: return getNull_flavour(); 214 case 111972721: /*div*/ 215 throw new Error("Unable to make an instance of the abstract property 'value'"); 216 case 1768477692: return getNull_reason(); 217 default: return super.makeProperty(hash, name); 218 } 219 220 } 221 222 @Override 223 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 224 switch (hash) { 225 case 1423585081: /*null_flavour*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"}; 226 case 111972721: /*value*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DATA-VALUE"}; 227 case 1768477692: /*null_reason*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-TEXT"}; 228 default: return super.getTypesForProperty(hash, name); 229 } 230 231 } 232 233 @Override 234 public Base addChild(String name) throws FHIRException { 235 if (name.equals("null_flavour")) { 236 this.null_flavour = new DV_CODED_TEXT(); 237 return this.null_flavour; 238 } 239 else if (name.equals("value")) { 240 throw new FHIRException("Cannot call addChild on an abstract type ELEMENT.value"); 241 } 242 else if (name.equals("null_reason")) { 243 this.null_reason = new DV_TEXT(); 244 return this.null_reason; 245 } 246 else 247 return super.addChild(name); 248 } 249 250 public String fhirType() { 251 return "ELEMENT"; 252 253 } 254 255 public ELEMENT copy() { 256 ELEMENT dst = new ELEMENT(); 257 copyValues(dst); 258 return dst; 259 } 260 261 public void copyValues(ELEMENT dst) { 262 super.copyValues(dst); 263 dst.null_flavour = null_flavour == null ? null : null_flavour.copy(); 264 dst.value = value == null ? null : value.copy(); 265 dst.null_reason = null_reason == null ? null : null_reason.copy(); 266 } 267 268 protected ELEMENT typedCopy() { 269 return copy(); 270 } 271 272 @Override 273 public boolean equalsDeep(Base other_) { 274 if (!super.equalsDeep(other_)) 275 return false; 276 if (!(other_ instanceof ELEMENT)) 277 return false; 278 ELEMENT o = (ELEMENT) other_; 279 return compareDeep(null_flavour, o.null_flavour, true) && compareDeep(value, o.value, true) && compareDeep(null_reason, o.null_reason, true) 280 ; 281 } 282 283 @Override 284 public boolean equalsShallow(Base other_) { 285 if (!super.equalsShallow(other_)) 286 return false; 287 if (!(other_ instanceof ELEMENT)) 288 return false; 289 ELEMENT o = (ELEMENT) other_; 290 return true; 291 } 292 293 public boolean isEmpty() { 294 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(null_flavour, value, null_reason 295 ); 296 } 297 298 299} 300