MrDooker
MrDooker

Reputation: 11

How to link batch-response entries with the request entries in FHIR (DSTU3)

I am currently building an application for which it is important to check the existence of resources with a certain profile.

As we need to check this for 40+ profiles I'd like to put this all in 1 batch request and let our HAPI-FHIR server implementation handle this, as opposed to querying them one by one. This would get too chatty otherwise.

Because I only need to know about whether the resource exists I'd like to use _summary=count. I am assuming this increases the performance of the request.

Example request

{
  "resourceType": "Bundle",
  "type": "batch",
  "entry": [
    {
      "request": {
        "method": "GET",
        "url": "/Observation?_profile=http://nictiz.nl/fhir/StructureDefinition/zib-DrugUse&_summary=true"
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "/RelatedPerson?_profile=http://fhir.nl/fhir/StructureDefinition/nl-core-relatedperson&_summary=count"
      }
    }
  ]
}

Response

{
    "resourceType": "Bundle",
    "id": "fd66cfd9-4693-496d-86fc-98289067480b",
    "type": "batch-response",
    "link": [
        {
            "relation": "self",
            "url": "<redacted>"
        }
    ],
    "entry": [
        {
            "resource": {
                "resourceType": "Bundle",
                "id": "2647a49f-0503-496b-b274-07d4e9163f1b",
                "meta": {
                    "lastUpdated": "2021-02-15T11:44:18.035+00:00",
                    "tag": [
                        {
                            "system": "http://hl7.org/fhir/v3/ObservationValue",
                            "code": "SUBSETTED",
                            "display": "Resource encoded in summary mode"
                        }
                    ]
                },
                "type": "searchset",
                "total": 48
            },
            "response": {
                "status": "200 OK"
            }
        },
        {
            "resource": {
                "resourceType": "Bundle",
                "id": "2f9cc861-5d20-4da1-aa9f-12153b75539d",
                "meta": {
                    "lastUpdated": "2021-02-15T11:44:18.151+00:00",
                    "tag": [
                        {
                            "system": "http://hl7.org/fhir/v3/ObservationValue",
                            "code": "SUBSETTED",
                            "display": "Resource encoded in summary mode"
                        }
                    ]
                },
                "type": "searchset",
                "total": 10
            },
            "response": {
                "status": "200 OK"
            }
        }
    ]
}

Can I assume that the ordering of the batch-response is the same as that of the batch-request?

Or is there a method to annotate the batch entries which are persisted onto the batch-response?

Or finally, is there a flag I can turn on to make the response include the request.url part?

I'm using HAPI-FHIR 5.1.0 both for client and server.

Upvotes: 0

Views: 711

Answers (1)

MrDooker
MrDooker

Reputation: 11

Apparently I didn't look well enough in the specs, as I just found the following:

From the FHIR spec

For a batch, or a successful transaction, the response the server SHALL return a Bundle with type set to batch-response or transaction-response that contains one entry for each entry in the request, in the same order, with the outcome of processing the entry.

Upvotes: 1

Related Questions