Skip to content

Conversation

@not-in-stock
Copy link

Summary

This PR adds support for the FHIRPath resolve() function in the @aehrc/sdc-populate package by passing the fhirServerUrl option to fhirpath.evaluate() calls.

Changes

  • Update fhirpath dependency to ^4.5.0 (where resolve() was implemented)
  • Add missing dev dependency @testing-library/jest-dom for tests
  • Thread fetchResourceRequestConfig through functions that call fhirpath.evaluate():
    • evaluateFhirPathVariables()
    • evaluateFhirPathEmbeddings()
    • generateExpressionValues()
    • evaluateItemPopulationContexts()

Motivation

The resolve() function is a standard FHIRPath function that allows questionnaires to populate fields from referenced resources without requiring the calling application to pre-resolve all references manually.

Previously, expressions like %order.requester.resolve().name.first().family would fail silently and return empty values because fhirpath.evaluate() wasn't configured with a FHIR server URL.

Example

After this change, questionnaires can use expressions like:

{
  "linkId": "ordering-physician-name",
  "type": "string",
  "extension": [{
    "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression",
    "valueExpression": {
      "language": "text/fhirpath",
      "expression": "%order.requester.resolve().name.first().given.first() & ' ' & %order.requester.resolve().name.first().family"
    }
  }]
}

Backwards Compatibility

This change is fully backwards compatible:

  • If fetchResourceRequestConfig.sourceServerUrl is not provided, resolve() simply won't work (same as current behavior)
  • All existing tests pass

Test Plan

  • All existing unit tests pass
  • Build succeeds
  • Manually tested with a questionnaire using resolve() expressions in a SMART on FHIR app

…lve() function

Thread `fetchResourceRequestConfig` through fhirpath.evaluate() calls to pass
the `fhirServerUrl` option, which enables the FHIRPath `resolve()` function
to fetch referenced resources from the FHIR server.
@not-in-stock not-in-stock changed the title feat(sdc-populate): Add fhirServerUrl support to enable FHIRPath reso… issue/1806: Add fhirServerUrl support to enable FHIRPath reso… Jan 29, 2026
@not-in-stock not-in-stock changed the title issue/1806: Add fhirServerUrl support to enable FHIRPath reso… issue/1806: Add fhirServerUrl support to enable FHIRPath resolve() function Jan 29, 2026
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.

1 participant