-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Add fhirServerUrl support to enable FHIRPath resolve() function
Is your feature request related to a problem? Please describe.
The @aehrc/sdc-populate package doesn't support the FHIRPath resolve() function. When using expressions like %order.requester.resolve().name.first().family in a questionnaire's initialExpression, the population fails silently and returns empty values.
This is frustrating because resolve() is a standard FHIRPath function that allows questionnaires to populate fields from referenced resources (e.g., getting a Practitioner's name from a ServiceRequest's requester reference) without requiring the calling application to pre-resolve all references manually.
Describe the solution you'd like
Pass fhirServerUrl option to fhirpath.evaluate() calls. According to fhirpath.js documentation, the resolve() function requires this option:
options.fhirServerUrl - a URL pointing to a FHIR RESTful API server that
is used to `resolve()` resources.
The value should come from fetchResourceRequestConfig.sourceServerUrl, which is already available in the codebase. This would require:
- Threading
fetchResourceRequestConfigthrough functions that callfhirpath.evaluate() - Adding
fhirServerUrl: sourceServerUrlto the fhirpath options object - Updating fhirpath.js dependency to version 4.5.0+ (where
resolve()was implemented)
Describe alternatives you've considered (if applicable)
The current workaround is to pre-resolve all referenced resources in the calling application before passing them as separate launch contexts. For example, instead of using %order.requester.resolve(), the application must:
- Fetch the ServiceRequest
- Extract the
requesterreference - Fetch the Practitioner
- Pass it as a separate
%practitionercontext
This works but requires each application to implement custom pre-resolution logic and questionnaires to be designed around this limitation rather than using standard FHIRPath patterns.
Additional context
- The
resolve()function was added to fhirpath.js in version 4.5.0 (2025-07-01) - Current
@aehrc/sdc-populatedepends on fhirpath 3.15.2, which doesn't haveresolve() - The change is backwards compatible - if
sourceServerUrlis not provided,resolve()simply won't work (same as current behavior) - I have a working patch implementation and would be happy to submit a PR if this approach is acceptable
Example questionnaire expression that would work after this change:
{
"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"
}
}]
}