Skip to content

Commit b443f9f

Browse files
committed
Finished exercise description
1 parent b2ae183 commit b443f9f

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

exercises/exercise-7.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This exercise introduces a new scenario which will serve as an example where [Us
77
will be utilized. The scenario is a voting process where one DSF instances of the tutorial setup will send a binary question (yes/no) to the other instances and itself.
88
The question can be set when starting the voting process. The question can will then be answerable through a [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) resource on the instance's DSF FHIR server.
99
The answer then gets sent back to the instance which initiated the voting process.
10-
The scenario comes with a skeleton including two BPMN models for the voting process and the subprocess which handles the vote itself.
10+
The scenario comes with a skeleton including two BPMN models. One for orchestrating the voting process called found in `voting-process.bpmn` and the subprocess which handles the vote itself found in `vote.bpmn`.
1111
It also includes most of the Java implementation for both processes and the required FHIR resources. Your task will be to fill in the parts concerning the [User Task](../learning/concepts/bpmn/user-task.md)
1212
and [Task Output Parameters](../learning/concepts/fhir/task.md#task-output-parameters).
1313

@@ -18,7 +18,10 @@ and [adding Task Output Parameters](../learning/guides/adding-task-output-parame
1818
Solutions to this exercise are found on the branch `solutions/exercise-7`. The skeleton can be found on the branch `skeleton/exercise-7`.
1919

2020
## Exercise Tasks
21-
1. Add a [Task Output Parameter](../learning/concepts/fhir/task.md#task-output-parameters) called `voting-result`:
21+
1. The StructureDefinition `task-start-voting-process.xml` describes the Task resource which starts the voting process. It already has an input parameter called `binary-question` which stores
22+
the question you want to pose to all DSF instances in the network. When the entire voting process is finished, we would like to see all the voting results of the other instances listed as
23+
output parameters in this resource.
24+
Add a [Task Output Parameter](../learning/concepts/fhir/task.md#task-output-parameters) called `voting-result`:
2225
* This parameter stores the voting result of one instance as either `yes`, `no` or `timeout`. This can be achieved by using a `Coding` as the type for `Task.output.value[x]`.
2326
The codings for this are already provided by the CodeSystem `voting-process` located in `src/main/resources/fhir/CodeSystem/voting-process.xml` and included in a ValueSet
2427
called `voting-results` located in `src/main/resources/fhir/ValueSet/voting-results.xml`.
@@ -85,7 +88,7 @@ Solutions to this exercise are found on the branch `solutions/exercise-7`. The s
8588
``` xml
8689
<element id="Task.output:example-output.extension:my-extension">
8790
<path value="Task.output.extension"/>
88-
<sliceName value="my-extension"/>
91+
<sliceName value="example-output"/>
8992
<min value="1"/>
9093
<max value="1"/>
9194
<type>
@@ -96,17 +99,31 @@ Solutions to this exercise are found on the branch `solutions/exercise-7`. The s
9699
```
97100
</details>
98101
</details>
99-
2. Create a [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) in `src/main/resources/fhir/Questionnaire/user-vote.xml` called `user-vote`.
102+
2. In the next steps, we will create the part of the process where a user has to interact with a [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html)
103+
in the DSF FHIR server web UI to answer the question defined in the input parameter of `task-start-voting-process.xml`.
104+
Create a [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) in `src/main/resources/fhir/Questionnaire/user-vote.xml` called `user-vote`.
100105
Don't forget to register it in the Process Plugin Definition for the `vote` process.
101106
<details>
102107
<summary>Don't know how the Questionnaire should look like?</summary>
103108

104109
Check out the [template](../learning/guides/user-tasks-in-the-dsf.md#questionnaire-template) again. Don't forget changing the URL.
105110
</details>
106-
3. Add a [User Task](../learning/concepts/bpmn/user-task.md) to `vote.bpmn` located in `src/main/resources/bpe/vote.bpmn`:
111+
112+
* Add an item with linkId `binary-question` and type `display`.
113+
* Add an item with linkId `vote` and type `boolean`.
114+
3. We now have a [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) resource that can be referenced in the BPMN model's [User Tasks](../learning/concepts/bpmn/user-task.md).
115+
If referenced, the DSF will take this [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) as a template to create the [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html)
116+
that can be answered by a user in the DSF FHIR server web UI.
117+
Add a [User Task](../learning/concepts/bpmn/user-task.md) to `vote.bpmn` located in `src/main/resources/bpe/vote.bpmn`:
107118
* The [User Task](../learning/concepts/bpmn/user-task.md) should be inserted between the [Exclusive Gateway](../learning/concepts/bpmn/gateways.md) and the `Save User Vote` [Service Task](../learning/concepts/bpmn/service-tasks.md).
108119
The connection from the [Exclusive Gateway](../learning/concepts/bpmn/gateways.md) requires a [Condition](../learning/concepts/bpmn/conditions.md) element with type `Expression` and `Condition Expression` with value `${userVote}`.
109-
* The [User Task](../learning/concepts/bpmn/user-task.md) requires a `Form key` attribute with the value of the Questionnaire URL you created in the previous step. This option is found under `Forms` and type `Embedded or External Task Forms`.
120+
* The [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) resource is referenced by providing a `Form key` attribute with the value of the [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) URL you created in the previous step appended by the version placeholder `|#{version}`. This option is found under `Forms` and type `Embedded or External Task Forms`.
121+
4. The [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) that is automatically created will copy its items from the template [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html).
122+
This means we need a way to set the `item.text` element of the `binary-question` item you created in the previous step, dynamically. This mechanism is provided by [Task Listeners](https://docs.camunda.org/manual/7.21/user-guide/process-engine/delegation-code/#task-listener).
123+
Create a [Task Listener](https://docs.camunda.org/manual/7.21/user-guide/process-engine/delegation-code/#task-listener) in `src/main/java/dev/dsf/process/tutorial/listener` for the [User Task](../learning/concepts/bpmn/user-task.md) you added in the previous step:
124+
* The new Java class needs to inherit from `DefaultUserTaskListener`
125+
* Override `beforeQuestionnaireResponseCreate` and set the text of the [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) item with linkId `binary-question` to the value of the
126+
Start Task's input parameter with name `binary-question`
110127

111128
## Solution Verification
112129
### Maven Build and Automated Tests

0 commit comments

Comments
 (0)