You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/exercise-7.md
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ This exercise introduces a new scenario which will serve as an example where [Us
7
7
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.
8
8
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.
9
9
The answer then gets sent back to the instance which initiated the voting process.
10
-
The scenario comes with a skeleton including two BPMN modelsfor 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`.
11
11
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)
12
12
and [Task Output Parameters](../learning/concepts/fhir/task.md#task-output-parameters).
13
13
@@ -18,7 +18,10 @@ and [adding Task Output Parameters](../learning/guides/adding-task-output-parame
18
18
Solutions to this exercise are found on the branch `solutions/exercise-7`. The skeleton can be found on the branch `skeleton/exercise-7`.
19
19
20
20
## 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`:
22
25
* 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]`.
23
26
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
24
27
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
@@ -96,17 +99,31 @@ Solutions to this exercise are found on the branch `solutions/exercise-7`. The s
96
99
```
97
100
</details>
98
101
</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`.
100
105
Don't forget to register it in the Process Plugin Definition for the `vote` process.
101
106
<details>
102
107
<summary>Don't know how the Questionnaire should look like?</summary>
103
108
104
109
Check out the [template](../learning/guides/user-tasks-in-the-dsf.md#questionnaire-template) again. Don't forget changing the URL.
105
110
</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`:
107
118
* 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).
108
119
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`
0 commit comments