Appearance
Expression parsing
Reads the text of an expression: FHIRPath with the pinned fhirpath.js, and x-fhir-query with a small scanner. It is not a stage of the run but a set of helpers that the rules and Name analysis call.
FHIRPath. Only a site whose language is exactly text/fhirpath is parsed; CQL and other languages never are. fhirpath.ts is the only file that uses fhirpath.js, pinned to 4.10.1, so the linter parses as the engine does. From the parse tree it reads:
- the syntax error and its position, when the text does not parse, which
sdc/parse-errorreports, orsdc/fragment-parse-errorin a query fragment; - the function calls, which
sdc/unknown-functionchecks against the functions fhirpath.js implements; - the
%namereferences, leaving out names thatdefineVariablebinds earlier in the chain. Each says whether it is complete, and whether it is conditional: fhirpath.js may skip it, as in aniifbranch; - the linkId references, written
where(linkId = '…'); - whether the expression reads its input other than its linkId, which plugin rules use to tell whether a value can differ between repetitions of a group.
x-fhir-query. Both codes, application/x-fhir-query (R4) and text/x-fhir-query (R5), are read as queries. The scanner finds each {{…}} fragment, which becomes a FHIRPath site of its own, and checks that the query has the shape of a FHIR search. It does not check resource types or search parameters.
Schema
FHIRPath, in fhirpath.ts:
x-fhir-query, in x-fhir-query.ts:
Code
In packages/core/src/analysis/:
fhirpath.ts:findFhirPathSyntaxProblem,findFunctionCalls,findVariableReferences,findLinkIdReferencesandreadsInput. Each returnsundefinedwhen the text does not parse.x-fhir-query.ts:scanQueryFragmentsandfindQueryShapeProblem.isQueryLanguage, which plugins can import, is here too.fhirpath-function-catalog.ts: the names of the functions fhirpath.js implements. It is generated bynpm run generate:functions --workspace @aehrc/sdc-questionnaire-lint; regenerate it after bumping fhirpath.js, and never edit it by hand.
The analysis helpers in the architecture map have the details.