Accessing Task Resources During Execution
Accessing Task Resources During Execution
Access to the Task resources in Activities is provided by the Variables class. It comes with methods which return certain kinds of Task resources. The most commonly used ones are the start Task, referring to the Task / Message Start Event responsible for starting the process, and the latest Task, referring to most recently received Task / Message.
In principle, this is sufficient to access all information in a Task resource, since there is access to the full in-memory representation of the Task resource. This however can be very cumbersome to use and produces a lot of boilerplate when traversing the resource tree to access certain common elements.
Instead of navigating the Task resource's element tree, it is recommended to use the ProcessPluginApi's TaskHelper in conjunction with the method above. The TaskHelper class offers specific methods related to Task resources.
The most common use case for this is retrieving data from a Task's Input Parameter or creating a new Input Parameter for a Message Activity's getAdditionalInputParameters method.
Retrieving Data from Input Parameters
- Know the CodeSystem and Code of the
typeelement of the Input Parameter to extract data from. This depends on the Task's StructureDefinition. Example:
<element id="Task.input:timer-interval.type.coding.system">
<path value="Task.input.type.coding.system" />
<min value="1" />
<fixedUri value="http://dsf.dev/fhir/CodeSystem/dsf-monitor-status" /> <!-- system value -->
</element>
<element id="Task.input:timer-interval.type.coding.version">
<path value="Task.input.type.coding.version"/>
<min value="1"/>
<max value="1"/>
<fixedString value="#{version}"/>
</element>
<element id="Task.input:timer-interval.type.coding.code">
<path value="Task.input.type.coding.code" />
<min value="1" />
<fixedCode value="timer-interval" /> <!-- code value -->
</element>- Know the FHIR Datatype of the Input Parameter defined by its
value[x]element. This also depends on the Task's StructureDefinition. Example:
<element id="Task.input:timer-interval.value[x]">
<path value="Task.input.value[x]" />
<type>
<code value="string" /> <!-- string -->
</type>
</element>- The
TaskHelper'sgetters for Input Parameters should be used depending on the information available. The methods will try to match the provided CodeSystem and Code to any Input Parameter of the provided Task resource. Depending on the method it is possible to receive all matches or just the first one. There are also methods immediately returning the value of the Input Parameter if the FHIR Datatype is provided. Thestringdatatype is used often enough to have its own method immediately returning the String value of the matched Input Parameter.