Search code examples
hl7-fhir

Searching for Patient within a Bundle


We use Bundles to contain other resources. I want to search for bundles based on these nested resources. e.g. I have bundles that look like this:

{
    "resourceType": "Bundle",
    "type": "collection",
    "entry": [
        {
            "resource": {
                "resourceType": "Patient",
                "identifier": [
                    {
                        "type": {
                            "coding": [
                                {
                                    "code": "foo"
                                }
                            ]
                        },
                        "value": "12345"
                    },
                    {
                        "type": {
                            "coding": [
                                {
                                    "code": "bar"
                                }
                            ]
                        },
                        "value": "abcde"
                    }
                ]
            }
        },
        {
            "resource": {
                "resourceType": "SomeOtherResource"
            }
       }
    ]
}

I want to find all bundles which have Patient with "bar" == "abcde". There will be many such bundles and each Patient will have many identifiers other than "bar"

I've looked through https://www.hl7.org/fhir/search.html, but all the examples I find assume that (e.g.) Patient is at the top level and I can search with [base]/Patient?..., but I am looking for Bundles. I've looked through the search parameters here but those don't include any "contained" entries.

I've tried all the combinations of bundle/patient/identifier I can think of with no luck. Is this even supported?


Solution

  • If your Bundle is a FHIR Document or FHIR Message, you can search by chaining through the 'composition' or 'message' search parameter. Otherwise, there's no standard way to search. In general, content within a Bundle is opaque.