Skip to content

Support repeatAll (STU) function #2567

@piotrszul

Description

@piotrszul

Add support for repeatAll() STU function.

See: https://build.fhir.org/ig/HL7/FHIRPath/#fn-repeatall

Here is the specification:

repeatAll(projection: ($this) => collection) : collection

Note: The contents of this section are Standard for Trial Use (STU)

This is a scoped function: The projection argument is evaluated for each item (setting $this before 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.
Note: As the function iterates on itself, the meaning of $index is undefined and not set here.

A version of repeat that allows duplicate items in the output collection. Unlike repeat, this function does not check whether items are already present in the output collection before adding them.

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 expression. The results are added to the output collection and also to a new iteration queue, regardless of whether they already exist in either collection. The input queue is then replaced by the new iteration queue and processing continues until there are no more items in the input queue to process.

This function provides better performance than repeat by eliminating the equality comparisons required to check for duplicates, while still providing more targeted traversal than descendants().

The order of items returned by the repeatAll() function is undefined.

Metadata

Metadata

Assignees

Labels

fhirpathRelated to fhirpath reference implementationnew featureNew feature or request

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions