FHIR Bundle API

385 views
Skip to first unread message

Anil Sharma

unread,
Oct 26, 2020, 9:14:52 AM10/26/20
to GCP Healthcare Discuss
Did anyone try Upsert use case with the bundle API? Even when I provide "id" of a FHIR resource, the API creates a new resource instead of updating it. GCP FHIR API-v1 does not support PATCH, PUT entries in the bundle. GCP API API-v1beta1 does permit but does not work as expected.

Any thoughts will be greatly appreciated. 

For now, I am thinking of a work around, lookup FHIR resource, use bundle API for newly created resources, use patch API for patching existing resource (one at a time). I found bundle API is many times faster (30X just by wall clock).

Thank you for the help.

Paul Church

unread,
Oct 26, 2020, 12:26:32 PM10/26/20
to Anil Sharma, GCP Healthcare Discuss
PUT entries in a bundle, including upsert, are supported in all API versions. The only relevant difference between v1 and v1beta1 should be that v1beta1 supports conditional operations and v1 does not. Make sure your store config has enable_update_create set, or PUT will only allow an update to an existing resource. The id needs to be set both inside the resource, and in request.url.

This example should work, I tested against v1 and v1beta1:
{
        "resourceType": "Bundle",
        "type": "transaction",
        "entry": [
                {
                        "resource": {
                                "resourceType": "Patient",
                                "id": "1",
                                "gender": "male",
                                "active": true
                        },
                        "request": {
                                "method": "PUT",
                                "url": "Patient/1"
                        }
                }
        ]
}

If you have a case that isn't working as expected, we can take a look at it - maybe we can improve the error message if it turns out not to be valid.

There's no support in the FHIR spec for PATCH in a bundle. This comes up occasionally and people propose ways to wrap a json patch inside the bundle payload but it's a bit awkward and nothing has been accepted yet.

--
You received this message because you are subscribed to the Google Groups "GCP Healthcare Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gcp-healthcare-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gcp-healthcare-discuss/3d1dfc50-ecc0-41db-97b4-a7d65f35e1d0n%40googlegroups.com.

Anil Sharma

unread,
Oct 26, 2020, 7:49:24 PM10/26/20
to GCP Healthcare Discuss
It worked. Thank you so much. It 

I will note the mistake so to help others. It would also be helpful to in correcting the error message.

The input which did not work was as follows:

"request" : {

        "method" : "PUT",

        "url" : "Person"

  }

I now realize that URL is not correct. It is missing the resource id. This gave the following error message. 

{

  "issue": [

    {

      "code": "invalid",

      "details": {

        "text": "invalid_bundle"

      },

      "diagnostics": "conditional operations are not supported in API version v1",

      "severity": "error"

    }

  ],

  "resourceType": "OperationOutcome"

}


Once I corrected the input as follows, it worked fine.

"request" : {

        "method" : "PUT",

        "url" : "Person/7eea18e9-ef51-4585-a00a-94ced2e67d63"

  }



Paul Church

unread,
Oct 26, 2020, 9:02:53 PM10/26/20
to Anil Sharma, GCP Healthcare Discuss
Thanks, we'll follow up on that error message. Looks like it's being interpreted as a conditional update.

Reply all
Reply to author
Forward
0 new messages