Appearance
smart-forms/forward-variable-reference
warning Reports a variable that references a variable or itemPopulationContext that Smart Forms evaluates after it when it prefills the form.What it checks
Each text/fhirpath variable that Smart Forms population evaluates, when an initialExpression or itemPopulationContext population reads uses it, directly or through other variables. It reports a reference the variable always evaluates to a declaration population evaluates later: a later variable on the Questionnaire root or on the same item, a variable on an ancestor item that comes later in the order population evaluates items in, or an itemPopulationContext.
Example
%bmi references %weight on the Questionnaire root, which Smart Forms evaluates after %bmi when it prefills the form, so %bmi has no value while the form is prefilled.
fsh
Instance: forward-variable-reference-root-later
InstanceOf: Questionnaire
Usage: #example
* status = #draft
* extension[0].url = "http://hl7.org/fhir/StructureDefinition/variable"
* extension[=].valueExpression.name = "bmi"
* extension[=].valueExpression.language = #text/fhirpath
* extension[=].valueExpression.expression = "%weight / 2"
* extension[+].url = "http://hl7.org/fhir/StructureDefinition/variable"
* extension[=].valueExpression.name = "weight"
* extension[=].valueExpression.language = #text/fhirpath
* extension[=].valueExpression.expression = "70"
* extension[+].url = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-launchContext"
* extension[=].extension[0].url = "name"
* extension[=].extension[=].valueCoding = http://hl7.org/fhir/uv/sdc/CodeSystem/launchContext#patient
* extension[=].extension[+].url = "type"
* extension[=].extension[=].valueCode = #Patient
* item[0].linkId = "q"
* item[=].type = #string
* item[=].extension.url = "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression"
* item[=].extension.valueExpression.language = #text/fhirpath
* item[=].extension.valueExpression.expression = "%bmi"