
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 * For representing state values which obey a defined state machine, such as a variable representing the states of an instruction or care process. 049 */ 050@DatatypeDef(name="DV_STATE") 051public class DV_STATE extends DATA_VALUE implements ICompositeType { 052 053 /** 054 * The state name. State names are determined by a state/event table defined in archetypes, and coded using openEHR Terminology or local archetype terms, as specified by the archetype. 055 */ 056 @Child(name = "value", type = {DV_CODED_TEXT.class}, order=0, min=1, max=1, modifier=false, summary=false) 057 @Description(shortDefinition="The state name", formalDefinition="The state name. State names are determined by a state/event table defined in archetypes, and coded using openEHR Terminology or local archetype terms, as specified by the archetype." ) 058 protected DV_CODED_TEXT value; 059 060 /** 061 * Indicates whether this state is a terminal state, such as 'aborted', 'completed' etc. from which no further transitions are possible. 062 */ 063 @Child(name = "is_terminal", type = {BooleanType.class}, order=1, min=1, max=1, modifier=false, summary=false) 064 @Description(shortDefinition="Indicates whether this state is a terminal state", formalDefinition="Indicates whether this state is a terminal state, such as 'aborted', 'completed' etc. from which no further transitions are possible." ) 065 protected BooleanType is_terminal; 066 067 private static final long serialVersionUID = -1675630194L; 068 069 /** 070 * Constructor 071 */ 072 public DV_STATE() { 073 super(); 074 } 075 076 /** 077 * Constructor 078 */ 079 public DV_STATE(DV_CODED_TEXT value, boolean is_terminal) { 080 super(); 081 this.setValue(value); 082 this.setIs_terminal(is_terminal); 083 } 084 085 /** 086 * @return {@link #value} (The state name. State names are determined by a state/event table defined in archetypes, and coded using openEHR Terminology or local archetype terms, as specified by the archetype.) 087 */ 088 public DV_CODED_TEXT getValue() { 089 if (this.value == null) 090 if (Configuration.errorOnAutoCreate()) 091 throw new Error("Attempt to auto-create DV_STATE.value"); 092 else if (Configuration.doAutoCreate()) 093 this.value = new DV_CODED_TEXT(); // cc 094 return this.value; 095 } 096 097 public boolean hasValue() { 098 return this.value != null && !this.value.isEmpty(); 099 } 100 101 /** 102 * @param value {@link #value} (The state name. State names are determined by a state/event table defined in archetypes, and coded using openEHR Terminology or local archetype terms, as specified by the archetype.) 103 */ 104 public DV_STATE setValue(DV_CODED_TEXT value) { 105 this.value = value; 106 return this; 107 } 108 109 /** 110 * @return {@link #is_terminal} (Indicates whether this state is a terminal state, such as 'aborted', 'completed' etc. from which no further transitions are possible.). This is the underlying object with id, value and extensions. The accessor "getIs_terminal" gives direct access to the value 111 */ 112 public BooleanType getIs_terminalElement() { 113 if (this.is_terminal == null) 114 if (Configuration.errorOnAutoCreate()) 115 throw new Error("Attempt to auto-create DV_STATE.is_terminal"); 116 else if (Configuration.doAutoCreate()) 117 this.is_terminal = new BooleanType(); // bb 118 return this.is_terminal; 119 } 120 121 public boolean hasIs_terminalElement() { 122 return this.is_terminal != null && !this.is_terminal.isEmpty(); 123 } 124 125 public boolean hasIs_terminal() { 126 return this.is_terminal != null && !this.is_terminal.isEmpty(); 127 } 128 129 /** 130 * @param value {@link #is_terminal} (Indicates whether this state is a terminal state, such as 'aborted', 'completed' etc. from which no further transitions are possible.). This is the underlying object with id, value and extensions. The accessor "getIs_terminal" gives direct access to the value 131 */ 132 public DV_STATE setIs_terminalElement(BooleanType value) { 133 this.is_terminal = value; 134 return this; 135 } 136 137 /** 138 * @return Indicates whether this state is a terminal state, such as 'aborted', 'completed' etc. from which no further transitions are possible. 139 */ 140 public boolean getIs_terminal() { 141 return this.is_terminal == null || this.is_terminal.isEmpty() ? false : this.is_terminal.getValue(); 142 } 143 144 /** 145 * @param value Indicates whether this state is a terminal state, such as 'aborted', 'completed' etc. from which no further transitions are possible. 146 */ 147 public DV_STATE setIs_terminal(boolean value) { 148 if (this.is_terminal == null) 149 this.is_terminal = new BooleanType(); 150 this.is_terminal.setValue(value); 151 return this; 152 } 153 154 protected void listChildren(List<Property> children) { 155 super.listChildren(children); 156 children.add(new Property("value", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "The state name. State names are determined by a state/event table defined in archetypes, and coded using openEHR Terminology or local archetype terms, as specified by the archetype.", 0, 1, value)); 157 children.add(new Property("is_terminal", "boolean", "Indicates whether this state is a terminal state, such as 'aborted', 'completed' etc. from which no further transitions are possible.", 0, 1, is_terminal)); 158 } 159 160 @Override 161 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 162 switch (_hash) { 163 case 111972721: /*value*/ return new Property("value", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "The state name. State names are determined by a state/event table defined in archetypes, and coded using openEHR Terminology or local archetype terms, as specified by the archetype.", 0, 1, value); 164 case -1916279311: /*is_terminal*/ return new Property("is_terminal", "boolean", "Indicates whether this state is a terminal state, such as 'aborted', 'completed' etc. from which no further transitions are possible.", 0, 1, is_terminal); 165 default: return super.getNamedProperty(_hash, _name, _checkValid); 166 } 167 168 } 169 170 @Override 171 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 172 switch (hash) { 173 case 111972721: /*value*/ return this.value == null ? new Base[0] : new Base[] {this.value}; // DV_CODED_TEXT 174 case -1916279311: /*is_terminal*/ return this.is_terminal == null ? new Base[0] : new Base[] {this.is_terminal}; // BooleanType 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 111972721: // value 184 this.value = (DV_CODED_TEXT) value; // DV_CODED_TEXT 185 return value; 186 case -1916279311: // is_terminal 187 this.is_terminal = TypeConvertor.castToBoolean(value); // BooleanType 188 return value; 189 default: return super.setProperty(hash, name, value); 190 } 191 192 } 193 194 @Override 195 public Base setProperty(String name, Base value) throws FHIRException { 196 if (name.equals("value")) { 197 this.value = (DV_CODED_TEXT) value; // DV_CODED_TEXT 198 } else if (name.equals("is_terminal")) { 199 this.is_terminal = TypeConvertor.castToBoolean(value); // BooleanType 200 } else 201 return super.setProperty(name, value); 202 return value; 203 } 204 205 @Override 206 public Base makeProperty(int hash, String name) throws FHIRException { 207 switch (hash) { 208 case 111972721: return getValue(); 209 case -1916279311: return getIs_terminalElement(); 210 default: return super.makeProperty(hash, name); 211 } 212 213 } 214 215 @Override 216 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 217 switch (hash) { 218 case 111972721: /*value*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"}; 219 case -1916279311: /*is_terminal*/ return new String[] {"boolean"}; 220 default: return super.getTypesForProperty(hash, name); 221 } 222 223 } 224 225 @Override 226 public Base addChild(String name) throws FHIRException { 227 if (name.equals("value")) { 228 this.value = new DV_CODED_TEXT(); 229 return this.value; 230 } 231 else if (name.equals("is_terminal")) { 232 throw new FHIRException("Cannot call addChild on a singleton property DV_STATE.is_terminal"); 233 } 234 else 235 return super.addChild(name); 236 } 237 238 public String fhirType() { 239 return "DV_STATE"; 240 241 } 242 243 public DV_STATE copy() { 244 DV_STATE dst = new DV_STATE(); 245 copyValues(dst); 246 return dst; 247 } 248 249 public void copyValues(DV_STATE dst) { 250 super.copyValues(dst); 251 dst.value = value == null ? null : value.copy(); 252 dst.is_terminal = is_terminal == null ? null : is_terminal.copy(); 253 } 254 255 protected DV_STATE typedCopy() { 256 return copy(); 257 } 258 259 @Override 260 public boolean equalsDeep(Base other_) { 261 if (!super.equalsDeep(other_)) 262 return false; 263 if (!(other_ instanceof DV_STATE)) 264 return false; 265 DV_STATE o = (DV_STATE) other_; 266 return compareDeep(value, o.value, true) && compareDeep(is_terminal, o.is_terminal, true); 267 } 268 269 @Override 270 public boolean equalsShallow(Base other_) { 271 if (!super.equalsShallow(other_)) 272 return false; 273 if (!(other_ instanceof DV_STATE)) 274 return false; 275 DV_STATE o = (DV_STATE) other_; 276 return compareValues(is_terminal, o.is_terminal, true); 277 } 278 279 public boolean isEmpty() { 280 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(value, is_terminal); 281 } 282 283 284} 285