For Clause and Query
Since FQL 4.4 we split up the For-Select-Query syntax, to allow use for a For-Clause only.
For clause
The for-clause can be used as a top level filter clause, so that it can be used and combined with other filters, even followed by another for-clause.
Syntax
ForQuery: 'for' fhir-path-expression
For-Select query
Functional
The for .. select ..
statement:
- takes a set of nodes,
- productes a set of nodes by doing a filter and a projection from with the FHIRPath expression after the
for
, - each of those nodes are then mapped using the field list after the select statement.
- groups each result set in a
row
node - and produces a list of nodes of type
row
Syntax:
ForQuery: 'for' fhir-path-expression 'select' (field-list|group)
A For Query can be used inside a field declaration or as part of a join.
...
select,
<field>,
<field>,
for <fhir-path-expression> 'select' (field-list|group)
Purpose
The main purpose of a for-query is to allow to iterate directly over (multiple) sub nodes of a resource (type) instead of over the resources themselves. A typical use case could be to gather all invariants in different structure definitions in a package.
from
StructureDefinition
for
differential.element
select
id,
join constraint.expression
order by id