-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Describe the bug
FHIRPath expression evaluation for SearchParameters and FHIRPath expression evaluation using the _fhirpath
parameter is not in alignment. _fhirpath
chokes on chained use of resolve()
. This is most notable when using _fhirpath
with FHIR Documents (i.e. Bundles of type document
where entry[0]
is a Composition).
To Reproduce
Steps to reproduce the behavior:
- Create a Patient and a MedicationAdministration
PUT {{ baseUrl }}MedicationAdministration/dtest-medadmin-effectiveperiod-start
{
"resourceType": "Patient",
"id": "dtest-pat-identifier",
"identifier":
[
{
"system": "http://dtest.org/pat",
"value": "123456789101112"
}
]
}
PUT {{ baseUrl }}MedicationAdministration/dtest-medadmin-effectiveperiod-start
{
"resourceType": "MedicationAdministration",
"id": "dtest-medadmin-effectiveperiod-start",
"effectivePeriod":
{
"start": "2023-07-01T01:00:00-05:00"
}
}
- Create a Bundle of type document with a Composite including the resources already created in step 1
PUT {{baseUrl}}Bundle/dtest-bdl-pat-medadmin-effectiveperiod-start
{
"resourceType": "Bundle",
"id": "dtest-bdl-pat-medadmin-effectiveperiod-start",
"type": "document",
"entry":
[
{
"fullUrl": "http://dtest.org/fhir/Composition/dtest-comp-pat-medadmin-effectiveperiod-start",
"resource":
{
"resourceType": "Composition",
"id": "dtest-comp-pat-medadmin-effectiveperiod-start",
"type":
{
"coding":
[
{
"system": "http://loinc.org",
"code": "80565-5",
"display": "Medication administration record"
}
]
},
"subject":
{
"reference": "Patient/dtest-pat-identifier"
},
"section":
[
{
"entry":
[
{
"reference": "MedicationAdministration/dtest-medadmin-effectiveperiod-start"
}
]
}
]
}
},
{
"fullUrl": "http://dtest.org/fhir/Patient/dtest-pat-identifier",
"resource":
{
"resourceType": "Patient",
"id": "dtest-pat-identifier",
"identifier":
[
{
"system": "http://dtest.org/pat",
"value": "123456789101112"
}
]
}
},
{
"fullUrl": "http://example.com/fhir/MedicationAdministration/dtest-medadmin-effectiveperiod-start",
"resource":
{
"resourceType": "MedicationAdministration",
"id": "dtest-medadmin-effectiveperiod-start",
"effectivePeriod":
{
"start": "2023-07-01T01:00:00-05:00"
}
}
}
]
}
- Perform a search using the
_fhirpath
parameter
GET localhost:8000/Bundle/dtest-bdl-pat-medadmin-effectiveperiod-start?_fhirpath=Bundle.entry[0].resource.as(Composition).section.entry.resolve().as(MedicationAdministration).effective
{
"resourceType": "Parameters",
"parameter":
[
{
"name": "result",
"part":
[
{
"name": "expression",
"valueString": "Bundle.entry[0].resource.as(Composition).section.entry.resolve().as(MedicationAdministration).effective"
}
]
}
]
}
Expected behavior
The search should return:
{
"resourceType": "Parameters",
"parameter": [
{
"name": "result",
"part": [
{
"name": "expression",
"valueString": "Bundle.entry[0].resource.as(Composition).section.entry.resolve().as(MedicationAdministration).effective"
},
{
"name": "result",
"valuePeriod": {
"start": "2023-07-01T01:00:00-05:00"
}
}
]
}
]
}
Environment (please complete the following information):
- HAPI FHIR // 6.11.5-SNAPSHOT / build 65f1331 2023-12-05T10:14:45.968-05:00
Additional context
The same fhirPath expression works when used within a defined SearchParameter.
PUT {{baseUrl }}SearchParameter/Bundle-composition-entry-medicationadministration-effective-time
{
"resourceType": "SearchParameter",
"id": "Bundle-composition-entry-medicationadministration-effective-time",
"url": "http://dtest.org/fhir/SearchParameter/Bundle-composition-entry-medicationadministration-effective-time",
"status": "active",
"name": "composition.entry.effective-time",
"code": "composition.entry.effective-time",
"base":
[
"Bundle"
],
"type": "date",
"expression": "Bundle.entry[0].resource.as(Composition).section.entry.resolve().as(MedicationAdministration).effective"
}
GET {{baseUrl }}Bundle?composition.entry.effective-time=ge2021
{
"resourceType": "Bundle",
"id": "637bf0f8-effa-4982-a7c6-12549be453b2",
"meta": {
"lastUpdated": "2023-12-20T19:56:35.648-08:00"
},
"type": "searchset",
"total": 2,
"link": [
{
"relation": "self",
"url": "http://localhost:8000/Bundle?composition.entry.effective-time=ge2021"
}
],
"entry": [
{
"fullUrl": "http://localhost:8000/Bundle/dtest-bdl-pat-medadmin-effectiveperiod-start",
"resource": {
"resourceType": "Bundle",
"id": "dtest-bdl-pat-medadmin-effectiveperiod-start",
"meta": {
"versionId": "1",
"lastUpdated": "2023-12-19T15:12:13.872-08:00",
"source": "#ldCU7ue8EFAxtJZT"
},
"type": "document",
"entry": [
{
"fullUrl": "http://dtest.org/fhir/Composition/dtest-comp-pat-medadmin-effectiveperiod-start",
"resource": {
"resourceType": "Composition",
"id": "dtest-comp-pat-medadmin-effectiveperiod-start",
"type": {
"coding": [
{
"system": "http://loinc.org",
"code": "80565-5",
"display": "Medication administration record"
}
]
},
"subject": {
"reference": "Patient/dtest-pat-identifier"
},
"section": [
{
"entry": [
{
"reference": "MedicationAdministration/dtest-medadmin-effectiveperiod-start"
}
]
}
]
}
},
{
"fullUrl": "http://dtest.org/fhir/Patient/dtest-pat-identifier",
"resource": {
"resourceType": "Patient",
"id": "dtest-pat-identifier",
"identifier": [
{
"system": "http://dtest.org/pat",
"value": "123456789101112"
}
]
}
},
{
"fullUrl": "http://example.com/fhir/MedicationAdministration/dtest-medadmin-effectiveperiod-start",
"resource": {
"resourceType": "MedicationAdministration",
"id": "dtest-medadmin-effectiveperiod-start",
"effectivePeriod": {
"start": "2023-07-01T01:00:00-05:00"
}
}
}
]
},
"search": {
"mode": "match"
}
}
}