...
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.
Note |
---|
A Questionnaire defined with eHealth profile |
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:
...
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:
|
An example of a variable evaluating to an ordinal value 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": "BreathingDifficulty", "language": "text/fhirpath", "expression": "iif(QuestionnaireResponse.repeat(item).where(linkId='1.2.208.176.1.5.1,6e6bb131-debd-4675-803b-7d783a75acc6,Sundhedsdatastyrelsen').answer.valueString = 'Severe', 2, iif(QuestionnaireResponse.repeat(item).where(linkId='1.2.208.176.1.5.1,6e6bb131-debd-4675-803b-7d783a75acc6,Sundhedsdatastyrelsen').answer.valueString = 'Normal', 1, {}))" } } |
The expression above relies on the definer to ensure consistency between the actual answer values (in Questionnaire.item.answerOption.answer[x]
) and ordinal values possibly assigned in Questionnaire.item.answerOption.ordinalValue
.
Defining a Calculation Expression
...
language
- the expression language. The supported language is a subset of FHIRPath described below. The expression language is specified as"text/fhirpath"
.expression
- the expression
...
Info |
---|
In case the expression is defined using one or more A
|
Expression Language
The supported expression language is the following subset of FHIRPath:
Arithmetic: multiplication, division, addition & subtraction only
Parentheses ‘
(
' and ')
'Constants
The equals operation (
=
) for primitive typesThe iif function
Releasing a Questionnaire
...