Repository navigation
fix(fhirpath): keep resolve() to the evaluated record's contained resources - #2969
Open
angela-helios wants to merge 1 commit into
Open
angela-helios wants to merge 1 commit into
angela-helios wants to merge 1 commit into
Conversation
…ources In SQL-on-FHIR's pooled scope, resolve() took the first match across every record and its contained resources, so a #id could resolve to a resource contained in another record, and a Type/id to another record's contained resource ahead of the real one. The context now remembers the record it was built for when the pool is set (forEach/repeat contexts inherit it); #id matches only that record's contained resources, Type/id only top-level ones, and Type/id/_history/v is read as Type/id. Closes #2968
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2968
Summary
In SQL-on-FHIR's pooled scope (a bundle, or HFS's
InProcessSofRunnerscan batch),resolve()took the first candidate that matched across every record and every record's contained resources:#idmatched a resource contained in another record;Type/idmatched another record's contained resource ahead of the real top-level one.Changes
EvaluationContext.resolution_root. Whenset_resolution_scopewidensresourcesto a pool, it first records the(resourceType, id)of the record the context was built for. SOF'sforEach/repeatcontexts take it from their parent with the newinherit_resolution_root. Clones and child contexts carry it.resolve_function:#idor bare id matches only resources contained in the root record. Without a root, in a single-resource context, it matches any contained resource, as before.Type/id, and the trailing-id fallback, match only top-level resources. A contained resource is addressed by#id.Type/id/_history/vis read asType/idinstead of matching any candidate whose id isv.Not changed
idshare the identity(type, None), so two id-less records of the same type in one bundle still share contained ids.Tests
crates/sof/tests/resolve_tests.rs:a_fragment_resolves_within_its_own_record_onlyPatient #p; each row gets its own Patient's family name.a_typed_reference_never_resolves_to_another_records_contained_resourcePatient/otherresolves to the top-level Patient "Real", not to "Planted", which an earlier record contains.With the three source files stashed, both fail:
obs-breports "First", and the typed reference resolves to "Planted".Runs:
helios-fhirpath: 796 passed.helios-sof: the lib and the 26 test files that useresolve(),forEachorrepeat, 519 passed, the existing contained, bundle-scope and absolute-URL resolve tests included. The rest are left to CI: building all 58 binaries fills the local disk.Clippy on
helios-fhirpathandhelios-sof(--lib --tests) is clean.