...
A Questionnaire defined with the eHealth profile ehealth-questionnaire-advanced
(see https://docs.ehealth.sundhed.dk/latest-released/ig/StructureDefinition-ehealth-questionnaire-advanced.html) can contain zero, one or more expressions performing a calculation based on answers to questions in the Questionnaire. The expression can make use of zero, one or more variables which identify the particular question/answers more concisely.
Defining a Variable
...
A variable intended for use in an expression (see below) is defined using the extension variable
. An example of a variable is shown below as an excerpt of a Questionnaire (in profile ehealth-questionnaire-advanced
) in JSON:
Code Block | ||
---|---|---|
| ||
{
"url": "http://hl7.org/fhir/StructureDefinition/variable",
"valueExpression": {
"name": "Count",
"language": "text/fhirpath",
"expression": "QuestionnaireResponse.repeat(item).where(linkId='1.2.208.176.1.5.1,7a481674-9016-46bb-8dd8-2ee49f5bbd53,Sundhedsdatastyrelsen').answer.valueInteger"
}
} |
The variable here is defined at Questionnaire root level referencing a particular question through its Questionnaire.item.linkId
. On evaluation in a QuestionnaireResponse, the variable will hold the integer value of the answer (presumably, the referenced Questionnaire.item has integer answer type).
Info |
---|
A variable is supported for a question with answer type choice, integer and decimal provided that:
|
Defining a Calculation Expression
An expression is defined in a separate Questionnaire.item
(or recursively, Questionnaire.item.item
) which shall have:
...
The expression itself is defined in the extension sdc-questionnaire-calculatedExpression
(see calculatedExpression) which is an Expression FHIR element type containing:
language
- the expression language. The supported language is FHIRPath.expression
- the expression
An example calculation expression is shown below as an excerpt of a Questionnaire (in profile ehealth-questionnaire-advanced
) in JSON:
Code Block | ||
---|---|---|
| ||
"extension": [
{
"url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression",
"valueExpression": {
"language": "text/fhirpath",
"expression": "%Animal * %Count"
}
},
"linkId": "1.2.208.176.1.5.1,25d40dde-f91c-4f11-9477-c6cca71d4178,Sundhedsdatastyrelsen",
"text": "Total",
"type": "decimal",
"required": false,
"readOnly": true
} |
Info |
---|
The following runtime behavior is not performed when maintaining the Questionnaire but provides background. On evaluation in a QuestionnaireResponse, the |
Info |
---|
In case the expression is defined using one or more A
|
Releasing a Questionnaire
...