User Tasks in the DSF
User Tasks in the DSF
Creating a User Task in a BPMN model causes the DSF to automatically generate a QuestionnaireResponse resource based on the Questionnaire specified in the User Task's Forms
field when process execution reaches the User Task. The Forms
field must have the type Embedded or External Task Forms
, with the Form key
set to the URL of the Questionnaire resource. The Questionnaire resource must be placed in the src/main/resources/fhir/Questionnaire
directory.
The generated QuestionnaireResponse can be accessed and answered by navigating to https://your.dsf.fhir.server/fhir/QuestionnaireResponse?_sort=-_lastUpdated&status=in-progress
in the DSF FHIR server UI. After completing and submitting the QuestionnaireResponse, the process execution will proceed to the next BPMN element following the User Task. The updated QuestionnaireResponse will then be accessible via the Process Plugin Api's Variables
instance by calling getLatestReceivedQuestionnaireResponse()
.
It is also possible to register a Task Listener on the User Task. This enables manipulation of the QuestionnaireResponse before it is posted to the DSF FHIR server. This can be achieved by extending the DefaultUserTaskListener
class, which provides overrides for interacting with the QuestionnaireResponse.
Dynamically changing the item.text
value of an item in a QuestionnaireResponse (if the item is not of type display
) is not permitted. To change text dynamically, the item.text
value of the corresponding Questionnaire resource must also be updated. As an alternative, an item of type display
can be placed above the item requiring dynamic text, and its item.text
value can be modified instead, as shown in the template. In this case, the item.text
element of the item below the display item may be omitted.
Below is a template for a Questionnaire resource. The placeholder questionnaire-name
should be replaced with the actual name of the Questionnaire, and the file should be named accordingly. The items business-key
and user-task-id
are required by the DSF and must always be included. Additional items can be added to the Questionnaire as needed.
Questionnaire Template
<Questionnaire xmlns="http://hl7.org/fhir">
<meta>
<profile value="http://dsf.dev/fhir/StructureDefinition/questionnaire|1.5.0"/>
<tag>
<system value="http://dsf.dev/fhir/CodeSystem/read-access-tag"/>
<code value="ALL"/>
</tag>
</meta>
<url value="http://dsf.dev/fhir/Questionnaire/questionnaire-name"/> <!-- file name should be same as the name of your Questionnaire -->
<!-- version managed by bpe -->
<version value="#{version}"/>
<!-- date managed by bpe -->
<date value="#{date}"/>
<!-- status managed by bpe -->
<status value="unknown"/>
<item>
<!-- required -->
<linkId value="business-key"/>
<type value="string"/>
<text value="The business-key of the process execution"/>
<required value="true"/>
</item>
<item>
<!-- required -->
<linkId value="user-task-id"/>
<type value="string"/>
<text value="The user-task-id of the process execution"/>
<required value="true"/>
</item>
<item>
<linkId value="text-to-display-above-item"/>
<type value="display"/>
<text value="foo"/>
</item>
<item>
<linkId value="item"/>
<type value="boolean"/>
<text value="Item description"/>
<required value="true"/>
</item>
</Questionnaire>