Conditional Create In Transaction Bundle

27 views
Skip to first unread message

Abhijit Mazumder

unread,
Jun 9, 2024, 2:07:44 PM6/9/24
to GCP Healthcare Discuss
Hi,
Can someone help me with conditional create in transation bundle. I am adding 
"request": {
        "method": "POST",
        "url": "Practitioner",
        "resourceType ": "Practitioner",
        "headers": {
          "Content-Type": "application/fhir+json",
          "If-None-Exist": "identifier=lifedot|35400"
        }
      }
 to execute but getting  status: 400,
    statusText: 'Bad Request',

I am using nodejs client : 
const bundleFile = 'bundle.json';
const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;

const bundle = JSON.parse(fs.readFileSync(bundleFile));

const request = {parent, requestBody: bundle};
const resource =
await healthcare.projects.locations.datasets.fhirStores.fhir.executeBundle(
request
);
const textData = await resource.data.text();
const parsedData = JSON.parse(textData);
console.log(`Created FHIR resource with ID ${textData}`);
}

executeFhirBundleTxn().catch(console.error);


Attached the bundle.json

Thanks in advance,
Abhijit

modified_bundle.json

Paul Church

unread,
Jun 9, 2024, 9:12:36 PM6/9/24
to Abhijit Mazumder, GCP Healthcare Discuss
There are numerous parse errors returned in the resource body when trying to execute this bundle. They can be found in the resource.data.text() after JSON parsing it (parsedData in your code).

In particular the fields you are adding to entry.request are not correct, see the spec for reference: https://hl7.org/fhir/R4/bundle.html#resource

--
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/f2475ed8-15b3-4a19-9661-ab925b7e8ff9n%40googlegroups.com.

Jared Cobb

unread,
Jun 10, 2024, 11:30:43 AM6/10/24
to Abhijit Mazumder, GCP Healthcare Discuss
I noticed that you have an extra space in some spots for the "resourceType" property like so: "resourceType ".

On Sun, Jun 9, 2024 at 2:07 PM Abhijit Mazumder <abhijit....@gmail.com> wrote:

Abhijit Mazumder

unread,
Jun 10, 2024, 11:30:50 AM6/10/24
to Paul Church, GCP Healthcare Discuss
Thnx Paul/Jared I figured it out . This works "request": {

        "method": "POST",
        "url": "Practitioner",
         ifNoneExist": "identifier=lifedot|35400"
        
      } works.

Leaving it for others
Reply all
Reply to author
Forward
0 new messages