LinuxForHealth / FHIR

The LinuxForHealth FHIR® Server and related projects

Home Page:https://linuxforhealth.github.io/FHIR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Composition:entry _include not supported

CHelfgott opened this issue · comments

Describe the bug
I have a Composition with two layers of sections, and resources referenced in the "entry" field of the subsection:

   { 
      resourceType: "Composition",
      encounter: { type: "Encounter", reference: "Encounter/18950d5c0c9-1806ad9f-e7da-422c-be68-a08b3f5a6241" },
      ...,
      section: [
         { 
             title: "Section 1", 
             section: [
                { 
                    title: "Subsection 1A", 
                    entry: [
                        { type: "MedicationDispense", reference: "MedicationDispense/blah-blah-blah" },
                        { type: "MedicationAdministration", reference: "MedicationAdministration/blah-blah-blah" },
                    ], 
                }, 
                { 
                    title: "Subsection 1B", 
                    entry: [{ type: "QuestionnaireResponse", reference: "QuestionnaireResponse/blah-blah-blah" }], 
                },
             ],
          },
          {
             title: "Section 2", 
             section: [
                { 
                    title: "Subsection 2A", 
                    entry: [{ type: "Observation", reference: "Observation/blah-blah-blah" }], 
                },
             ],
          },
      ],
   }

I place a search call, attempting to retrieve the Composition and all associated entry resources.
curl -X 'GET' 'http://localhost:3001/fhir-server/api/v4/Composition?encounter=18950d5c0c9-1806ad9f-e7da-422c-be68-a08b3f5a6241&_include=Composition:entry&_include:iterate=AdverseEvent:substance&_include:iterate=MedicationAdministration:medication&_include:iterate=MedicationDispense:medication&_include:iterate=Medication:ingredient' -H 'accept: application/fhir+json'

The response is a Bundle with total: 1 containing only the Composition.

Environment
Which version of LinuxForHealth FHIR Server?
v4

To Reproduce
Create a Composition resource with nested sections and entry fields, attempt to retrieve all referenced entry resources using Composition search with an _include Composition:entry parameter.

Expected behavior
I expected all resources referenced in Composition.section.section.entry to be included in the search bundle.

I additionally tried filtering on the types of resources to be returned by e.g. Composition:entry:MedicationAdministration. No dice.
My suspicion, just from poking around the repo, is that the issue comes from
https://github.com/LinuxForHealth/FHIR/blob/main/conformance/fhir-core-r4/src/main/resources/hl7/fhir/core/401/package/SearchParameter-Composition-entry.json
where it defines

  "expression": "Composition.section.entry",
  "xpath": "f:Composition/f:section/f:entry",

My guess is that means the search parameter is only capturing the top-level sections of the Composition; given that Composition.section is explicitly recursive, this is probably not conformant.

Incidentally, I suspect this is an issue with other resources/search params with a recursive structure, such as Questionnaire:definition.

According to the current normative version of FHIRPath, the correct way of doing this is "expression": "Composition.repeat(section).entry".
Likewise with Questionnaire items.