|
1 | | -### Adding Task Output |
| 1 | +### User Tasks in the DSF |
| 2 | + |
| 3 | +Creating a [User Task](../concepts/bpmn/user-tasks.md) in a BPMN model, causes the DSF to automatically generate a [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) resource |
| 4 | +according to a [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) you provided in the [User Task's](../concepts/bpmn/user-tasks.md) `Forms` field when the process execution reaches the [User Task](../concepts/bpmn/user-tasks.md). |
| 5 | +The `Forms` field needs to have a type of `Embedded or External Task Forms` with the `Form key` being the url of your [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) resource. |
| 6 | +The [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) resource needs to be put in the `src/main/resources/fhir/Questionnaire` directory. |
| 7 | +The generated [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) can now be answered by locating |
| 8 | +the [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) in the DSF FHIR server UI through `https://your.dsf.fhir.server/fhir/QuestionnaireResponse?_sort=-_lastUpdated&status=in-progress`. |
| 9 | +After filling out the [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) and submitting it, the process execution will continue with the next BPMN element after the |
| 10 | +[User Task](../concepts/bpmn/user-tasks.md) and the updated [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) will be available through the [Process Plugin Api's](../concepts/dsf/process-api.md) |
| 11 | +`Variables` instance by calling `getLatestReceivedQuestionnaireResponse()`. |
| 12 | + |
| 13 | +You also have the option to register a [Task Listener](https://docs.camunda.org/manual/7.21/user-guide/process-engine/delegation-code/#task-listener) on the [User Task](../concepts/bpmn/user-tasks.md). |
| 14 | +You do this by extending the `DefaultUserTaskListener` class which provides overrides to interact with the [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html). |
| 15 | +Notice that dynamically changing the `item.text` value of an item in a [QuestionnaireResponse](https://www.hl7.org/fhir/R4/questionnaireresponse.html) (that is **NOT** of type `display`) is not allowed. |
| 16 | +For that, you would have to change the `item.text` value of the corresponding [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) resource as well. |
| 17 | +Instead, you should have an item of type `display` above the item whose text should change dynamically, like in the template, and change its `item.text` value. |
| 18 | +In this case, you may also leave out `item.text` element of the item below the display item. |
| 19 | + |
| 20 | +Below you can find a template for a [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) resource. Replace `questionnaire-name` with the name of your [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html) |
| 21 | +and have the file be named the same. The items `business-key` and `user-task-id` are required by the DSF and are always included. You can then add any amount of items of your choosing |
| 22 | +to the [Questionnaire](https://www.hl7.org/fhir/R4/questionnaire.html). |
| 23 | + |
| 24 | +```xml |
| 25 | +<Questionnaire xmlns="http://hl7.org/fhir"> |
| 26 | + <meta> |
| 27 | + <profile value="http://dsf.dev/fhir/StructureDefinition/questionnaire|1.5.0"/> |
| 28 | + <tag> |
| 29 | + <system value="http://dsf.dev/fhir/CodeSystem/read-access-tag"/> |
| 30 | + <code value="ALL"/> |
| 31 | + </tag> |
| 32 | + </meta> |
| 33 | + <url value="http://dsf.dev/fhir/Questionnaire/questionnaire-name"/> <!-- file name should be same as the name of your Questionnaire --> |
| 34 | + <!-- version managed by bpe --> |
| 35 | + <version value="#{version}"/> |
| 36 | + <!-- date managed by bpe --> |
| 37 | + <date value="#{date}"/> |
| 38 | + <!-- status managed by bpe --> |
| 39 | + <status value="unknown"/> |
| 40 | + <item> |
| 41 | + <!-- required --> |
| 42 | + <linkId value="business-key"/> |
| 43 | + <type value="string"/> |
| 44 | + <text value="The business-key of the process execution"/> |
| 45 | + <required value="true"/> |
| 46 | + </item> |
| 47 | + <item> |
| 48 | + <!-- required --> |
| 49 | + <linkId value="user-task-id"/> |
| 50 | + <type value="string"/> |
| 51 | + <text value="The user-task-id of the process execution"/> |
| 52 | + <required value="true"/> |
| 53 | + </item> |
| 54 | + <item> |
| 55 | + <linkId value="text-to-display-above-item"/> |
| 56 | + <type value="display"/> |
| 57 | + <text value="foo"/> |
| 58 | + </item> |
| 59 | + <item> |
| 60 | + <linkId value="item"/> |
| 61 | + <type value="boolean"/> |
| 62 | + <text value="Item description"/> |
| 63 | + <required value="true"/> |
| 64 | + </item> |
| 65 | +</Questionnaire> |
| 66 | +``` |
0 commit comments