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 * Used to record a clinical action that has been performed, which may have been ad hoc, or due to the execution of an Activity in an Instruction workflow. Every Action corresponds to a careflow step of some kind or another.
049 */
050@DatatypeDef(name="ACTION")
051public class ACTION extends CARE_ENTRY implements ICompositeType {
052
053    /**
054     * Point in time at which this action completed. To indicate an unknown time, use a DV_DATE_TIME instance with value set to the time of creation (or some other known time before which the Action is known to have occurred, e.g. data accession timestamp from integration engine), and magnitude_status set to <.
055     */
056    @Child(name = "time", type = {DV_DATE_TIME.class}, order=0, min=1, max=1, modifier=false, summary=false)
057    @Description(shortDefinition="Point in time at which this action completed", formalDefinition="Point in time at which this action completed. To indicate an unknown time, use a DV_DATE_TIME instance with value set to the time of creation (or some other known time before which the Action is known to have occurred, e.g. data accession timestamp from integration engine), and magnitude_status set to <." )
058    protected DV_DATE_TIME time;
059
060    /**
061     * Details of transition in the Instruction state machine caused by this Action.
062     */
063    @Child(name = "ism_transition", type = {ISM_TRANSITION.class}, order=1, min=1, max=1, modifier=false, summary=false)
064    @Description(shortDefinition="Details of transition in the Instruction state machine caused by this Action", formalDefinition="Details of transition in the Instruction state machine caused by this Action." )
065    protected ISM_TRANSITION ism_transition;
066
067    /**
068     * Details of the Instruction that caused this Action to be performed, if there was one.
069     */
070    @Child(name = "instruction_details", type = {INSTRUCTION_DETAILS.class}, order=2, min=0, max=1, modifier=false, summary=false)
071    @Description(shortDefinition="Details of the Instruction that caused this Action to be performed, if there was one", formalDefinition="Details of the Instruction that caused this Action to be performed, if there was one." )
072    protected INSTRUCTION_DETAILS instruction_details;
073
074    /**
075     * Description of the action that has been performed, in the form of an archetyped structure.
076     */
077    @Child(name = "description", type = {ITEM_STRUCTURE.class}, order=3, min=1, max=1, modifier=false, summary=false)
078    @Description(shortDefinition="Description of the action that has been performed, in the form of an archetyped structure", formalDefinition="Description of the action that has been performed, in the form of an archetyped structure." )
079    protected ITEM_STRUCTURE description;
080
081    private static final long serialVersionUID = -850420733L;
082
083  /**
084   * Constructor
085   */
086    public ACTION() {
087      super();
088    }
089
090  /**
091   * Constructor
092   */
093    public ACTION(DV_DATE_TIME time, ISM_TRANSITION ism_transition, ITEM_STRUCTURE description) {
094      super();
095      this.setTime(time);
096      this.setIsm_transition(ism_transition);
097      this.setDescription(description);
098    }
099
100    /**
101     * @return {@link #time} (Point in time at which this action completed. To indicate an unknown time, use a DV_DATE_TIME instance with value set to the time of creation (or some other known time before which the Action is known to have occurred, e.g. data accession timestamp from integration engine), and magnitude_status set to <.)
102     */
103    public DV_DATE_TIME getTime() { 
104      if (this.time == null)
105        if (Configuration.errorOnAutoCreate())
106          throw new Error("Attempt to auto-create ACTION.time");
107        else if (Configuration.doAutoCreate())
108          this.time = new DV_DATE_TIME(); // cc
109      return this.time;
110    }
111
112    public boolean hasTime() { 
113      return this.time != null && !this.time.isEmpty();
114    }
115
116    /**
117     * @param value {@link #time} (Point in time at which this action completed. To indicate an unknown time, use a DV_DATE_TIME instance with value set to the time of creation (or some other known time before which the Action is known to have occurred, e.g. data accession timestamp from integration engine), and magnitude_status set to <.)
118     */
119    public ACTION setTime(DV_DATE_TIME value) { 
120      this.time = value;
121      return this;
122    }
123
124    /**
125     * @return {@link #ism_transition} (Details of transition in the Instruction state machine caused by this Action.)
126     */
127    public ISM_TRANSITION getIsm_transition() { 
128      if (this.ism_transition == null)
129        if (Configuration.errorOnAutoCreate())
130          throw new Error("Attempt to auto-create ACTION.ism_transition");
131        else if (Configuration.doAutoCreate())
132          this.ism_transition = new ISM_TRANSITION(); // cc
133      return this.ism_transition;
134    }
135
136    public boolean hasIsm_transition() { 
137      return this.ism_transition != null && !this.ism_transition.isEmpty();
138    }
139
140    /**
141     * @param value {@link #ism_transition} (Details of transition in the Instruction state machine caused by this Action.)
142     */
143    public ACTION setIsm_transition(ISM_TRANSITION value) { 
144      this.ism_transition = value;
145      return this;
146    }
147
148    /**
149     * @return {@link #instruction_details} (Details of the Instruction that caused this Action to be performed, if there was one.)
150     */
151    public INSTRUCTION_DETAILS getInstruction_details() { 
152      if (this.instruction_details == null)
153        if (Configuration.errorOnAutoCreate())
154          throw new Error("Attempt to auto-create ACTION.instruction_details");
155        else if (Configuration.doAutoCreate())
156          this.instruction_details = new INSTRUCTION_DETAILS(); // cc
157      return this.instruction_details;
158    }
159
160    public boolean hasInstruction_details() { 
161      return this.instruction_details != null && !this.instruction_details.isEmpty();
162    }
163
164    /**
165     * @param value {@link #instruction_details} (Details of the Instruction that caused this Action to be performed, if there was one.)
166     */
167    public ACTION setInstruction_details(INSTRUCTION_DETAILS value) { 
168      this.instruction_details = value;
169      return this;
170    }
171
172    /**
173     * @return {@link #description} (Description of the action that has been performed, in the form of an archetyped structure.)
174     */
175    public ITEM_STRUCTURE getDescription() { 
176      return this.description;
177    }
178
179    public boolean hasDescription() { 
180      return this.description != null && !this.description.isEmpty();
181    }
182
183    /**
184     * @param value {@link #description} (Description of the action that has been performed, in the form of an archetyped structure.)
185     */
186    public ACTION setDescription(ITEM_STRUCTURE value) { 
187      this.description = value;
188      return this;
189    }
190
191      protected void listChildren(List<Property> children) {
192        super.listChildren(children);
193        children.add(new Property("time", "http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME", "Point in time at which this action completed. To indicate an unknown time, use a DV_DATE_TIME instance with value set to the time of creation (or some other known time before which the Action is known to have occurred, e.g. data accession timestamp from integration engine), and magnitude_status set to <.", 0, 1, time));
194        children.add(new Property("ism_transition", "http://openehr.org/fhir/StructureDefinition/ISM-TRANSITION", "Details of transition in the Instruction state machine caused by this Action.", 0, 1, ism_transition));
195        children.add(new Property("instruction_details", "http://openehr.org/fhir/StructureDefinition/INSTRUCTION-DETAILS", "Details of the Instruction that caused this Action to be performed, if there was one.", 0, 1, instruction_details));
196        children.add(new Property("description", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "Description of the action that has been performed, in the form of an archetyped structure.", 0, 1, description));
197      }
198
199      @Override
200      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
201        switch (_hash) {
202        case 3560141: /*time*/  return new Property("time", "http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME", "Point in time at which this action completed. To indicate an unknown time, use a DV_DATE_TIME instance with value set to the time of creation (or some other known time before which the Action is known to have occurred, e.g. data accession timestamp from integration engine), and magnitude_status set to <.", 0, 1, time);
203        case -376386927: /*ism_transition*/  return new Property("ism_transition", "http://openehr.org/fhir/StructureDefinition/ISM-TRANSITION", "Details of transition in the Instruction state machine caused by this Action.", 0, 1, ism_transition);
204        case -676653167: /*instruction_details*/  return new Property("instruction_details", "http://openehr.org/fhir/StructureDefinition/INSTRUCTION-DETAILS", "Details of the Instruction that caused this Action to be performed, if there was one.", 0, 1, instruction_details);
205        case -1724546052: /*description*/  return new Property("description", "http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE", "Description of the action that has been performed, in the form of an archetyped structure.", 0, 1, description);
206        default: return super.getNamedProperty(_hash, _name, _checkValid);
207        }
208
209      }
210
211      @Override
212      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
213        switch (hash) {
214        case 3560141: /*time*/ return this.time == null ? new Base[0] : new Base[] {this.time}; // DV_DATE_TIME
215        case -376386927: /*ism_transition*/ return this.ism_transition == null ? new Base[0] : new Base[] {this.ism_transition}; // ISM_TRANSITION
216        case -676653167: /*instruction_details*/ return this.instruction_details == null ? new Base[0] : new Base[] {this.instruction_details}; // INSTRUCTION_DETAILS
217        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // ITEM_STRUCTURE
218        default: return super.getProperty(hash, name, checkValid);
219        }
220
221      }
222
223      @Override
224      public Base setProperty(int hash, String name, Base value) throws FHIRException {
225        switch (hash) {
226        case 3560141: // time
227          this.time = (DV_DATE_TIME) value; // DV_DATE_TIME
228          return value;
229        case -376386927: // ism_transition
230          this.ism_transition = (ISM_TRANSITION) value; // ISM_TRANSITION
231          return value;
232        case -676653167: // instruction_details
233          this.instruction_details = (INSTRUCTION_DETAILS) value; // INSTRUCTION_DETAILS
234          return value;
235        case -1724546052: // description
236          this.description = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
237          return value;
238        default: return super.setProperty(hash, name, value);
239        }
240
241      }
242
243      @Override
244      public Base setProperty(String name, Base value) throws FHIRException {
245        if (name.equals("time")) {
246          this.time = (DV_DATE_TIME) value; // DV_DATE_TIME
247        } else if (name.equals("ism_transition")) {
248          this.ism_transition = (ISM_TRANSITION) value; // ISM_TRANSITION
249        } else if (name.equals("instruction_details")) {
250          this.instruction_details = (INSTRUCTION_DETAILS) value; // INSTRUCTION_DETAILS
251        } else if (name.equals("description")) {
252          this.description = (ITEM_STRUCTURE) value; // ITEM_STRUCTURE
253        } else
254          return super.setProperty(name, value);
255        return value;
256      }
257
258      @Override
259      public Base makeProperty(int hash, String name) throws FHIRException {
260        switch (hash) {
261        case 3560141:  return getTime();
262        case -376386927:  return getIsm_transition();
263        case -676653167:  return getInstruction_details();
264        case -1724546052: /*div*/
265          throw new Error("Unable to make an instance of the abstract property 'description'");
266        default: return super.makeProperty(hash, name);
267        }
268
269      }
270
271      @Override
272      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
273        switch (hash) {
274        case 3560141: /*time*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-DATE-TIME"};
275        case -376386927: /*ism_transition*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ISM-TRANSITION"};
276        case -676653167: /*instruction_details*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/INSTRUCTION-DETAILS"};
277        case -1724546052: /*description*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/ITEM-STRUCTURE"};
278        default: return super.getTypesForProperty(hash, name);
279        }
280
281      }
282
283      @Override
284      public Base addChild(String name) throws FHIRException {
285        if (name.equals("time")) {
286          this.time = new DV_DATE_TIME();
287          return this.time;
288        }
289        else if (name.equals("ism_transition")) {
290          this.ism_transition = new ISM_TRANSITION();
291          return this.ism_transition;
292        }
293        else if (name.equals("instruction_details")) {
294          this.instruction_details = new INSTRUCTION_DETAILS();
295          return this.instruction_details;
296        }
297        else if (name.equals("description")) {
298          throw new FHIRException("Cannot call addChild on an abstract type ACTION.description");
299        }
300        else
301          return super.addChild(name);
302      }
303
304  public String fhirType() {
305    return "ACTION";
306
307  }
308
309      public ACTION copy() {
310        ACTION dst = new ACTION();
311        copyValues(dst);
312        return dst;
313      }
314
315      public void copyValues(ACTION dst) {
316        super.copyValues(dst);
317        dst.time = time == null ? null : time.copy();
318        dst.ism_transition = ism_transition == null ? null : ism_transition.copy();
319        dst.instruction_details = instruction_details == null ? null : instruction_details.copy();
320        dst.description = description == null ? null : description.copy();
321      }
322
323      protected ACTION typedCopy() {
324        return copy();
325      }
326
327      @Override
328      public boolean equalsDeep(Base other_) {
329        if (!super.equalsDeep(other_))
330          return false;
331        if (!(other_ instanceof ACTION))
332          return false;
333        ACTION o = (ACTION) other_;
334        return compareDeep(time, o.time, true) && compareDeep(ism_transition, o.ism_transition, true) && compareDeep(instruction_details, o.instruction_details, true)
335           && compareDeep(description, o.description, true);
336      }
337
338      @Override
339      public boolean equalsShallow(Base other_) {
340        if (!super.equalsShallow(other_))
341          return false;
342        if (!(other_ instanceof ACTION))
343          return false;
344        ACTION o = (ACTION) other_;
345        return true;
346      }
347
348      public boolean isEmpty() {
349        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(time, ism_transition, instruction_details
350          , description);
351      }
352
353
354}
355