Stream: implementers
Topic: Search entries from Bundle
Ivo Lopes (Mar 23 2021 at 09:37):
Hello, I'm having a little difficulty finding the entries that were created with a bundle. Basically I create a transaction bundle, and I receive for example the following response:
{"resourceType":"Bundle","id":"d3b9fc55-fcfb-43ad-93a7-f9f95f1ecfc6","meta":{"versionId":"1","lastUpdated":"2021-03-22T16:33:30.414+00:00"},"type":"transaction","entry":[{"fullUrl":"8e7716d8-fe12-45d2-a440-d0b26f7f672a","resource":{"resourceType":"Patient","id":"8e7716d8-fe12-45d2-a440-d0b26f7f672a","name":[{"use":"usual","text":"gomes","family":"gomes","given":["nuno"]}],"gender":"male","birthDate":"2021-03-22"},"request":{"method":"POST","url":"Patient"}},{"resource":{"resourceType":"Observation","status":"final","code":{"coding":[{"system":"http://snomed.info/sct","code":"46635009","display":"Diabetes mellitus type 1 (disorder)"}]},"subject":{"reference":"8e7716d8-fe12-45d2-a440-d0b26f7f672a"}},"request":{"method":"POST","url":"Observation"}}]}
Everything seems OK, but when I try to search the Patient endpoint for the patient ID I receive a 404. Maybe because they belong to the bundle? is there a way when creating the bundle to create the entries in the Patient and Observation endpoits in my example?
Dexter (Mar 23 2021 at 09:53):
Does this not work? [baseUrl]/Patient/8e7716d8-fe12-45d2-a440-d0b26f7f672a
Ivo Lopes (Mar 23 2021 at 10:15):
No it doesn't work, the may the fullURL be the problem?
Ivo Lopes (Mar 23 2021 at 10:32):
I can find them on [baseUrl]/Bundle
Dexter (Mar 23 2021 at 10:34):
Is this a public server?
Ivo Lopes (Mar 23 2021 at 10:45):
No, it's a private one, using Microsoft Azure API for Fhir.
If I create the bundle in transaction mode it should create the patient and observation in their resource, but apparently no, I might be missing something.
Dexter (Mar 23 2021 at 10:50):
The document here says that transactions aren't supported, yet the bundle you tried to create is a transaction.
ps. I'm pretty new to this too, so please take what I say with a ton of salt :)
Dexter (Mar 23 2021 at 10:51):
As consequence, it might've just created the bundle you specify, instead of "acting out/executing" the transaction.
Ivo Lopes (Mar 23 2021 at 10:59):
I also think of that =( thanks for the document and help
Joel Schneider (Mar 23 2021 at 14:34):
To have the server process the Bundle as a transaction, the client should post it to [baseUrl] instead of [baseUrl]/Bundle
http://hl7.org/fhir/http.html#transaction
Caitlin Voegele (Mar 23 2021 at 15:22):
@Ivo Lopes Dexter is correct, the Azure API for FHIR doesn't support Bundles of type transaction right now. You would have to use a Batch bundle. Let me know if you have other questions!
Caitlin Voegele (Mar 23 2021 at 15:38):
@Ivo Lopes - One clarifying point :) If you POST your bundle to the root, you would have received an error for type transaction bundle. However, if you post to [baseURl]/Bundle, it will create a Bundle resource (i.e. not parse through the resources). So if you want to use the Batch bundle, make sure you POST to the [baseURL]/
Ivo Lopes (Mar 23 2021 at 15:46):
thank you @Caitlin Voegele , but posting it through the [baseURL]/ won't create the entries in each resource neither will revert all in case of a failure, right?
Caitlin Voegele (Mar 23 2021 at 19:25):
Let me know if this answers the question. If you use [baseURL]/ with a batch bundle (changing the type of the bundle), the resources will be uploaded but processed according to the batch. If you use it with a transaction bundle you will get an error.
Ivo Lopes (Mar 24 2021 at 12:20):
Yes using the root and the bundle as a batch works, Thanks
Dexter (Mar 25 2021 at 12:44):
A somewhat related question. What's the main difference b/w using a Batch vs a Transaction?
Jose Costa Teixeira (Mar 25 2021 at 12:58):
http://build.fhir.org/valueset-bundle-type.html
Jose Costa Teixeira (Mar 25 2021 at 12:59):
whether it is one atomic commit or if the parts can be handled separately.
Lloyd McKenzie (Mar 25 2021 at 13:19):
In addition, entries in a transaction are allowed to reference each other. Entries in a batch cannot.
Joel Schneider (Mar 25 2021 at 15:32):
Additional details about the FHIR API's batch/transaction processing:
http://hl7.org/fhir/http.html#transaction
Dexter (Mar 26 2021 at 09:22):
Jose Costa Teixeira said:
http://build.fhir.org/valueset-bundle-type.html
whether it is one atomic commit or if the parts can be handled separately.
Thank you, this perfectly explains what the key differences are!
Dexter (Mar 26 2021 at 09:23):
Lloyd McKenzie said:
In addition, entries in a transaction are allowed to reference each other. Entries in a batch cannot.
Ahh I didn't know that, thank you!
Last updated: Apr 12 2022 at 19:14 UTC