FHIRPath Function: repeat
This is a scoped function: The
projectionargument is evaluated for each item (setting$thisbefore each iteration); and the results are included in the output collection. The function is then re-evaluated on the output collection, repeating until no new items are added.<br/>Note: As the function iterates on itself, the meaning of$indexis undefined and not set here.
A version of select that will repeat the projection and add items to the output collection only if they are not already in the output collection as determined by the equals (=) operator.
This can be evaluated by adding all items in the input collection to an input queue, then for each item in the input queue evaluate the repeat expression. If the result of the repeat expression is not in the output collection, add it to both the output collection and also the input queue. Processing continues until the input queue is empty.
This function can be used to traverse a tree and selecting only specific children:
ValueSet.expansion.repeat(contains)
Will repeat finding children called contains, until no new items are found.
Questionnaire.repeat(item)
Will repeat finding children called item, until no new items are found.
Note that this is slightly different from:
Questionnaire.descendants().select(item)
which would find any descendants called item, not just the ones nested inside other item elements.
The order of items returned by the repeat() function is undefined.
Summary
- Category: Filtering and projection
- Section:
5.2.5 - Return Type:
collection - Empty Input Result:
empty - Errors on Multiple Input:
false
Description
A version of select that will repeat the projection and add items to the output collection only if they are not already in the output collection as determined by the equals (=) operator.
Arguments
Type Mapping
Example
Questionnaire.repeat(item)