
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 * Model of a transition in the Instruction State Machine, caused by a careflow step. The attributes document the careflow step as well as the ISM transition. 049 */ 050@DatatypeDef(name="ISM_TRANSITION") 051public class ISM_TRANSITION extends PATHABLE implements ICompositeType { 052 053 /** 054 * The ISM current state. Coded by openEHR terminology group Instruction states. 055 */ 056 @Child(name = "current_state", type = {DV_CODED_TEXT.class}, order=0, min=1, max=1, modifier=false, summary=false) 057 @Description(shortDefinition="The ISM current state. Coded by openEHR terminology group Instruction states", formalDefinition="The ISM current state. Coded by openEHR terminology group Instruction states." ) 058 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-instruction_states") 059 protected DV_CODED_TEXT current_state; 060 061 /** 062 * The ISM transition which occurred to arrive in the current_state. Coded by openEHR terminology group Instruction transitions. 063 */ 064 @Child(name = "transition", type = {DV_CODED_TEXT.class}, order=1, min=0, max=1, modifier=false, summary=false) 065 @Description(shortDefinition="The ISM transition which occurred to arrive in the current_state", formalDefinition="The ISM transition which occurred to arrive in the current_state. Coded by openEHR terminology group Instruction transitions." ) 066 @ca.uhn.fhir.model.api.annotation.Binding(valueSet="https://specifications.openehr.org/fhir/valueset-instruction_transitions") 067 protected DV_CODED_TEXT transition; 068 069 /** 070 * The step in the careflow process which occurred as part of generating this action, e.g. dispense , start_administration. This attribute represents the clinical label for the activity, as opposed to current_state which represents the state machine (ISM) computable form. Defined in archetype. 071 */ 072 @Child(name = "careflow_step", type = {DV_CODED_TEXT.class}, order=2, min=0, max=1, modifier=false, summary=false) 073 @Description(shortDefinition="The step in the careflow process which occurred as part of generating this action", formalDefinition="The step in the careflow process which occurred as part of generating this action, e.g. dispense , start_administration. This attribute represents the clinical label for the activity, as opposed to current_state which represents the state machine (ISM) computable form. Defined in archetype." ) 074 protected DV_CODED_TEXT careflow_step; 075 076 /** 077 * Optional possibility of adding one or more reasons for this careflow step having been taken. Multiple reasons may occur in medication management for example. 078 */ 079 @Child(name = "reason", type = {DV_TEXT.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 080 @Description(shortDefinition="Optional possibility of adding one or more reasons for this careflow step having been taken", formalDefinition="Optional possibility of adding one or more reasons for this careflow step having been taken. Multiple reasons may occur in medication management for example." ) 081 protected List<DV_TEXT> reasonList; 082 083 private static final long serialVersionUID = 2077167668L; 084 085 /** 086 * Constructor 087 */ 088 public ISM_TRANSITION() { 089 super(); 090 } 091 092 /** 093 * Constructor 094 */ 095 public ISM_TRANSITION(DV_CODED_TEXT current_state) { 096 super(); 097 this.setCurrent_state(current_state); 098 } 099 100 /** 101 * @return {@link #current_state} (The ISM current state. Coded by openEHR terminology group Instruction states.) 102 */ 103 public DV_CODED_TEXT getCurrent_state() { 104 if (this.current_state == null) 105 if (Configuration.errorOnAutoCreate()) 106 throw new Error("Attempt to auto-create ISM_TRANSITION.current_state"); 107 else if (Configuration.doAutoCreate()) 108 this.current_state = new DV_CODED_TEXT(); // cc 109 return this.current_state; 110 } 111 112 public boolean hasCurrent_state() { 113 return this.current_state != null && !this.current_state.isEmpty(); 114 } 115 116 /** 117 * @param value {@link #current_state} (The ISM current state. Coded by openEHR terminology group Instruction states.) 118 */ 119 public ISM_TRANSITION setCurrent_state(DV_CODED_TEXT value) { 120 this.current_state = value; 121 return this; 122 } 123 124 /** 125 * @return {@link #transition} (The ISM transition which occurred to arrive in the current_state. Coded by openEHR terminology group Instruction transitions.) 126 */ 127 public DV_CODED_TEXT getTransition() { 128 if (this.transition == null) 129 if (Configuration.errorOnAutoCreate()) 130 throw new Error("Attempt to auto-create ISM_TRANSITION.transition"); 131 else if (Configuration.doAutoCreate()) 132 this.transition = new DV_CODED_TEXT(); // cc 133 return this.transition; 134 } 135 136 public boolean hasTransition() { 137 return this.transition != null && !this.transition.isEmpty(); 138 } 139 140 /** 141 * @param value {@link #transition} (The ISM transition which occurred to arrive in the current_state. Coded by openEHR terminology group Instruction transitions.) 142 */ 143 public ISM_TRANSITION setTransition(DV_CODED_TEXT value) { 144 this.transition = value; 145 return this; 146 } 147 148 /** 149 * @return {@link #careflow_step} (The step in the careflow process which occurred as part of generating this action, e.g. dispense , start_administration. This attribute represents the clinical label for the activity, as opposed to current_state which represents the state machine (ISM) computable form. Defined in archetype.) 150 */ 151 public DV_CODED_TEXT getCareflow_step() { 152 if (this.careflow_step == null) 153 if (Configuration.errorOnAutoCreate()) 154 throw new Error("Attempt to auto-create ISM_TRANSITION.careflow_step"); 155 else if (Configuration.doAutoCreate()) 156 this.careflow_step = new DV_CODED_TEXT(); // cc 157 return this.careflow_step; 158 } 159 160 public boolean hasCareflow_step() { 161 return this.careflow_step != null && !this.careflow_step.isEmpty(); 162 } 163 164 /** 165 * @param value {@link #careflow_step} (The step in the careflow process which occurred as part of generating this action, e.g. dispense , start_administration. This attribute represents the clinical label for the activity, as opposed to current_state which represents the state machine (ISM) computable form. Defined in archetype.) 166 */ 167 public ISM_TRANSITION setCareflow_step(DV_CODED_TEXT value) { 168 this.careflow_step = value; 169 return this; 170 } 171 172 /** 173 * @return {@link #reason} (Optional possibility of adding one or more reasons for this careflow step having been taken. Multiple reasons may occur in medication management for example.) 174 */ 175 public List<DV_TEXT> getReasonList() { 176 if (this.reasonList == null) 177 this.reasonList = new ArrayList<DV_TEXT>(); 178 return this.reasonList; 179 } 180 181 /** 182 * @return Returns a reference to <code>this</code> for easy method chaining 183 */ 184 public ISM_TRANSITION setReasonList(List<DV_TEXT> theReason) { 185 this.reasonList = theReason; 186 return this; 187 } 188 189 public boolean hasReason() { 190 if (this.reasonList == null) 191 return false; 192 for (DV_TEXT item : this.reasonList) 193 if (!item.isEmpty()) 194 return true; 195 return false; 196 } 197 198 public DV_TEXT addReason() { //3a 199 DV_TEXT t = new DV_TEXT(); 200 if (this.reasonList == null) 201 this.reasonList = new ArrayList<DV_TEXT>(); 202 this.reasonList.add(t); 203 return t; 204 } 205 206 public ISM_TRANSITION addReason(DV_TEXT t) { //3b 207 if (t == null) 208 return this; 209 if (this.reasonList == null) 210 this.reasonList = new ArrayList<DV_TEXT>(); 211 this.reasonList.add(t); 212 return this; 213 } 214 215 /** 216 * @return The first repetition of repeating field {@link #reason}, creating it if it does not already exist {3} 217 */ 218 public DV_TEXT getReasonFirstRep() { 219 if (getReasonList().isEmpty()) { 220 addReason(); 221 } 222 return getReasonList().get(0); 223 } 224 225 protected void listChildren(List<Property> children) { 226 super.listChildren(children); 227 children.add(new Property("current_state", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "The ISM current state. Coded by openEHR terminology group Instruction states.", 0, 1, current_state)); 228 children.add(new Property("transition", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "The ISM transition which occurred to arrive in the current_state. Coded by openEHR terminology group Instruction transitions.", 0, 1, transition)); 229 children.add(new Property("careflow_step", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "The step in the careflow process which occurred as part of generating this action, e.g. dispense , start_administration. This attribute represents the clinical label for the activity, as opposed to current_state which represents the state machine (ISM) computable form. Defined in archetype.", 0, 1, careflow_step)); 230 children.add(new Property("reason", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Optional possibility of adding one or more reasons for this careflow step having been taken. Multiple reasons may occur in medication management for example.", 0, java.lang.Integer.MAX_VALUE, reasonList)); 231 } 232 233 @Override 234 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 235 switch (_hash) { 236 case -1708972469: /*current_state*/ return new Property("current_state", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "The ISM current state. Coded by openEHR terminology group Instruction states.", 0, 1, current_state); 237 case -1724158635: /*transition*/ return new Property("transition", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "The ISM transition which occurred to arrive in the current_state. Coded by openEHR terminology group Instruction transitions.", 0, 1, transition); 238 case 2086974284: /*careflow_step*/ return new Property("careflow_step", "http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT", "The step in the careflow process which occurred as part of generating this action, e.g. dispense , start_administration. This attribute represents the clinical label for the activity, as opposed to current_state which represents the state machine (ISM) computable form. Defined in archetype.", 0, 1, careflow_step); 239 case -934964668: /*reason*/ return new Property("reason", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Optional possibility of adding one or more reasons for this careflow step having been taken. Multiple reasons may occur in medication management for example.", 0, java.lang.Integer.MAX_VALUE, reasonList); 240 default: return super.getNamedProperty(_hash, _name, _checkValid); 241 } 242 243 } 244 245 @Override 246 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 247 switch (hash) { 248 case -1708972469: /*current_state*/ return this.current_state == null ? new Base[0] : new Base[] {this.current_state}; // DV_CODED_TEXT 249 case -1724158635: /*transition*/ return this.transition == null ? new Base[0] : new Base[] {this.transition}; // DV_CODED_TEXT 250 case 2086974284: /*careflow_step*/ return this.careflow_step == null ? new Base[0] : new Base[] {this.careflow_step}; // DV_CODED_TEXT 251 case -934964668: /*reason*/ return this.reasonList == null ? new Base[0] : this.reasonList.toArray(new Base[this.reasonList.size()]); // DV_TEXT 252 default: return super.getProperty(hash, name, checkValid); 253 } 254 255 } 256 257 @Override 258 public Base setProperty(int hash, String name, Base value) throws FHIRException { 259 switch (hash) { 260 case -1708972469: // current_state 261 this.current_state = (DV_CODED_TEXT) value; // DV_CODED_TEXT 262 return value; 263 case -1724158635: // transition 264 this.transition = (DV_CODED_TEXT) value; // DV_CODED_TEXT 265 return value; 266 case 2086974284: // careflow_step 267 this.careflow_step = (DV_CODED_TEXT) value; // DV_CODED_TEXT 268 return value; 269 case -934964668: // reason 270 this.getReasonList().add((DV_TEXT) value); // DV_TEXT 271 return value; 272 default: return super.setProperty(hash, name, value); 273 } 274 275 } 276 277 @Override 278 public Base setProperty(String name, Base value) throws FHIRException { 279 if (name.equals("current_state")) { 280 this.current_state = (DV_CODED_TEXT) value; // DV_CODED_TEXT 281 } else if (name.equals("transition")) { 282 this.transition = (DV_CODED_TEXT) value; // DV_CODED_TEXT 283 } else if (name.equals("careflow_step")) { 284 this.careflow_step = (DV_CODED_TEXT) value; // DV_CODED_TEXT 285 } else if (name.equals("reason")) { 286 this.getReasonList().add((DV_TEXT) value); // DV_TEXT 287 } else 288 return super.setProperty(name, value); 289 return value; 290 } 291 292 @Override 293 public Base makeProperty(int hash, String name) throws FHIRException { 294 switch (hash) { 295 case -1708972469: return getCurrent_state(); 296 case -1724158635: return getTransition(); 297 case 2086974284: return getCareflow_step(); 298 case -934964668: return addReason(); 299 default: return super.makeProperty(hash, name); 300 } 301 302 } 303 304 @Override 305 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 306 switch (hash) { 307 case -1708972469: /*current_state*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"}; 308 case -1724158635: /*transition*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"}; 309 case 2086974284: /*careflow_step*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-CODED-TEXT"}; 310 case -934964668: /*reason*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-TEXT"}; 311 default: return super.getTypesForProperty(hash, name); 312 } 313 314 } 315 316 @Override 317 public Base addChild(String name) throws FHIRException { 318 if (name.equals("current_state")) { 319 this.current_state = new DV_CODED_TEXT(); 320 return this.current_state; 321 } 322 else if (name.equals("transition")) { 323 this.transition = new DV_CODED_TEXT(); 324 return this.transition; 325 } 326 else if (name.equals("careflow_step")) { 327 this.careflow_step = new DV_CODED_TEXT(); 328 return this.careflow_step; 329 } 330 else if (name.equals("reason")) { 331 return addReason(); 332 } 333 else 334 return super.addChild(name); 335 } 336 337 public String fhirType() { 338 return "ISM_TRANSITION"; 339 340 } 341 342 public ISM_TRANSITION copy() { 343 ISM_TRANSITION dst = new ISM_TRANSITION(); 344 copyValues(dst); 345 return dst; 346 } 347 348 public void copyValues(ISM_TRANSITION dst) { 349 super.copyValues(dst); 350 dst.current_state = current_state == null ? null : current_state.copy(); 351 dst.transition = transition == null ? null : transition.copy(); 352 dst.careflow_step = careflow_step == null ? null : careflow_step.copy(); 353 if (reasonList != null) { 354 dst.reasonList = new ArrayList<DV_TEXT>(); 355 for (DV_TEXT i : reasonList) 356 dst.reasonList.add(i.copy()); 357 }; 358 } 359 360 protected ISM_TRANSITION typedCopy() { 361 return copy(); 362 } 363 364 @Override 365 public boolean equalsDeep(Base other_) { 366 if (!super.equalsDeep(other_)) 367 return false; 368 if (!(other_ instanceof ISM_TRANSITION)) 369 return false; 370 ISM_TRANSITION o = (ISM_TRANSITION) other_; 371 return compareDeep(current_state, o.current_state, true) && compareDeep(transition, o.transition, true) 372 && compareDeep(careflow_step, o.careflow_step, true) && compareDeep(reasonList, o.reasonList, true) 373 ; 374 } 375 376 @Override 377 public boolean equalsShallow(Base other_) { 378 if (!super.equalsShallow(other_)) 379 return false; 380 if (!(other_ instanceof ISM_TRANSITION)) 381 return false; 382 ISM_TRANSITION o = (ISM_TRANSITION) other_; 383 return true; 384 } 385 386 public boolean isEmpty() { 387 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(current_state, transition 388 , careflow_step, reasonList); 389 } 390 391 392} 393