Skip to content

fix(fhirpath): evaluate aggregate() iterations in a child of the caller's context - #2967

Open
angela-helios wants to merge 1 commit into
mainfrom
fix/fhirpath-aggregate-terminology-session
Open

angela-helios wants to merge 1 commit into
mainfrom
fix/fhirpath-aggregate-terminology-session

Conversation

@angela-helios

Copy link
Copy Markdown
Contributor

Stacked on #2901. This branch starts from #2901's branch so that Test FHIRPath passes against the current fhir-test-cases master; its commit leaves this diff once #2901 merges.

Closes #2966

Summary

aggregate() evaluated each iteration in EvaluationContext::new_empty. Every iteration therefore got:

  • a new terminology session, so the FHIRPATH_TERMINOLOGY_MAX_CALLS budget, the answer cache and the rate-limit hold started from zero;
  • no terminology server, falling back to FHIRPATH_TERMINOLOGY_SERVER or failing;
  • no resources.

Each iteration now runs in context.create_child_context(), as the lambdas of where() and select() do. The child shares the session, the server and the resources, and reaches the caller's variables through its parent chain. $total is still set per iteration, and current_index is cleared as before.

Tests

terminology_functions::tests::aggregate_iterations_share_the_terminology_budget: with a budget of 2, ('a' | 'b' | 'c' | 'd').aggregate($this.memberOf(VS)) (three evaluated iterations) stops with TerminologyCallLimit after two requests to the stub server.

With the change stashed, the test fails: the iterations have no terminology server at all ("No terminology server is configured"), which is the second half of the bug.

cargo test -p helios-fhirpath: 797 passed, the R4 conformance cases for aggregate() included. Clippy on helios-fhirpath --all-targets is clean.

…er's context

Each aggregate() iteration ran in a fresh empty context, so the terminology
call budget, answer cache and rate-limit hold restarted every iteration,
and the caller's terminology server and resources were lost. Iterations now
run in create_child_context(), sharing all three, as where() and select()
lambdas do.

Closes #2966

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FHIRPath aggregate() starts a fresh terminology session on every iteration

1 participant