Stream: implementers
Topic: Bundle response
Alex Neiva (Aug 24 2018 at 15:21):
Hello,
i have a question regarding the Bundle message. When my server receives a POST, according to the FHIR spec, we should return a Bundle. My doubt is, it is mandatory send back the whole resource created plus the response tag inside the Bundle, or can can we just send the response tag inside the Bundle, just to avoid send back "everything" again?
Example:
<Bundle>
<entry>
<response>...</response>
</entry>
</Bundle>
Thank you
John Moehrke (Aug 24 2018 at 15:27):
See http://build.fhir.org/http.html#prefer
Alex Neiva (Aug 24 2018 at 15:31):
Oh great... i did not see that! Thank you very much
Jean Duteau (Aug 24 2018 at 15:32):
The link that John posted gives the best guidance, but I just wanted to question your statement "...according to the FHIR spec, we should return a Bundle." If I'm POSTing a single resource, I'm pretty sure that you don't return a Bundle, but either just the response code, the resource I just posted (with metadata filled in) or an OperationOutcome.
Alex Neiva (Aug 24 2018 at 15:37):
At the end of that link is a table where it is mentioned the Interaction:Response. It is only mandatory for the search and transaction interactions.
In my case i was using the transaction so i mentioned that it is mandatory. For the created it is optional but preferred.
Jean Duteau (Aug 24 2018 at 15:38):
Ah, you didn't mention that you were sending a transaction. Sorry.
Alex Neiva (Aug 24 2018 at 15:43):
Yes, my mistake eheheh :thumbs_up:
Marco Westerink (Nov 05 2020 at 15:32):
Hello,
I've got a question about the return value of a batch bundle. We are working with a custom build FHIR server and asked the following question to the Dev team.
note: the CDR being the FHIR server.
-------------------Start-----------------
We have an issue when posting a batch bundle to the CDR with validation enabled.
When there is one item in the batch that does not pass validation the whole batch is rejected and a single OperationOutcome is returned instead of a bundle with an OperationOutcome per item in the request batch bundle.
This would be the right behavior in case of a transaction bundle but not in case of a batch bundle. A Bundle posted to the batch-transaction endpoint should(https://www.hl7.org/fhir/http.html#transaction-response): "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. For a failed transaction, the server returns a single OperationOutcome instead of a Bundle."
So only a failed transaction should return a single OperationOutcome. In case of a batch all entries should be processed and validated separately as stated (https://www.hl7.org/fhir/http.html#transaction): " The resources in the bundle are each processed separately as if they were an individual interaction or operation as otherwise described on this page, or the Operations framework. The actions are subject to the normal processing for each, including the meta element, verification and version aware updates, and transactional integrity. In the case of a batch each entry is treated as if an individual interaction or operation, in the case of a transaction all interactions or operations either succeed or fail together (see below)."
We already had ad quick discussion about this and the reasoning of validating the bundle as a whole is that a Bundle is also a resource of its own and should be validated as such. This is true if we were actually posting a Bundle as a data entry in the type specific url like http://cdrurl/tenantid/Bundle. But in this case we are posting it to the transaction endpoint where it must be processed in a different way as described above.
-------------------END-----------------
The response is that they still believe that the implementation is according to spec. Can anyone shed some light on this?
Kind regards,
Marco Westerink
Vassil Peytchev (Nov 05 2020 at 15:50):
The specification seems to be clear:
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. For a failed transaction, the server returns a single OperationOutcome instead of a Bundle.
What is the nature of the failed validation in one item in the batch that does not pass validation
?
Marco Westerink (Nov 09 2020 at 06:13):
Thanks for your answer. My thoughts exactly.
It's a profile violation fabricated to test the behavior.
Anand Mohan Tumuluri (Nov 19 2020 at 09:03):
I work for the "custom built" FHIR server referenced above. Our FHIR server, by design, performs input validation and DDoS content limit enforcement at the boundary as requests are being read. Any request with a body goes through this process and the requests are only handled by their respective handlers only after they are deemed to be not violating validation rules or content limits. This validation acts on the entire Bundle in this case, is unaware whether it is a single resource or batch bundle or transaction bundle and any validation failures are returned as a single OperationOutcome.
After the validation, the bundle is "processed" as a batch where each entry is processed independently and any failing entry results in a OperationOutcome entry that is returned together with successful entries in a response bundle.
The question in point is
Are we in violation of the spec if we return a single OperationOutcome instead of a Bundle at any stage of the batch request processing? Are the servers always expected to return a bundle even if the given Bundle is wrong or misses Authorization header or if a 10GB bundle is posted as a batch.
I had tested this on @Grahame Grieve 's reference server with an intentionally fabricated bundle and of course was able to simulate the case where it returned a single OperationOutcome within a couple attempts.
Anand Mohan Tumuluri (Nov 19 2020 at 09:04):
(deleted)
Anand Mohan Tumuluri (Nov 19 2020 at 09:04):
curl --location --request POST 'http://test.fhir.org/r3' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"resourceType": "Bundle",
"type": "batch",
"entry": [
{
"fullUrl": "Observation/127",
"resource": {
"resourceType": "Observation",
"status": "reviewed",
"category": [
{
"coding": [
{
"system": "http://hl7.org/fhir/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
]
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "29463-7",
"display": "Body Weight"
},
{
"system": "http://loinc.org",
"code": "3141-9",
"display": "Body weight Measured"
},
{
"system": "http://snomed.info/sct",
"code": "27113001",
"display": "Body weight"
},
{
"system": "http://acme.org/devices/clinical-codes",
"code": "body-weight",
"display": "Body Weight"
}
]
},
"subject": {
"reference": "Patient/example"
},
"context": {
"reference": "Encounter/example"
},
"effectiveDateTime": "2016-03-28",
"valueQuantity": {
"value": 185,
"unit": "lbs",
"system": "http://unitsofmeasure.org",
"code": "[lb_av]"
}
},
"request": {
"method": "POST",
"url": "Observation"
}
}
]
}'```
Anand Mohan Tumuluri (Nov 19 2020 at 09:07):
I had given an invalid code for Observation.status as reviewed. And that returns a single OperationOutcome as below
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>unknown code: reviewed from a set of choices of (\"\", \"registered\", \"preliminary\", \"final\", \"amended\", \"corrected\", \"cancelled\", \"entered-in-error\", \"unknown\") for \"$.entry[0].resource/status\"</p></div>"
},
"issue": [
{
"severity": "error",
"details": {
"text": "unknown code: reviewed from a set of choices of (\"\", \"registered\", \"preliminary\", \"final\", \"amended\", \"corrected\", \"cancelled\", \"entered-in-error\", \"unknown\") for \"$.entry[0].resource/status\""
},
"diagnostics": "(00000000017C84D3){FHIRServer.exe} [0000000001BC94D3] Unknown function at TMethodImplementationIntercept + $1720E63\r\n(0000000005AE1BAC){FHIRServer.exe} [0000000005EE2BAC] Unknown function at TMethodImplementationIntercept + $5A3A53C\r\n(0000000005AE3AE0){FHIRServer.exe} [0000000005EE4AE0] Unknown function at TMethodImplementationIntercept + $5A3C470\r\n(000000000004B717){FHIRServer.exe} [000000000044C717] Unknown function at __dbk_fcall_wrapper + $2E157\r\n(000000000004C00B){FHIRServer.exe} [000000000044D00B] Unknown function at __dbk_fcall_wrapper + $2EA4B\r\n(00000000000115D6){FHIRServer.exe} [00000000004125D6]\r\n(0000000000011611){FHIRServer.exe} [0000000000412611]\r\n(00000000017C84D3){FHIRServer.exe} [0000000001BC94D3] Unknown function at TMethodImplementationIntercept + $1720E63\r\n(00000000018D11CF){FHIRServer.exe} [0000000001CD21CF] Unknown function at TMethodImplementationIntercept + $1829B5F\r\n(00000000018D0FC8){FHIRServer.exe} [0000000001CD1FC8] Unknown function at TMethodImplementationIntercept + $1829958\r\n(00000000019535FE){FHIRServer.exe} [0000000001D545FE] Unknown function at TMethodImplementationIntercept + $18ABF8E\r\n(00000000016291D5){FHIRServer.exe} [0000000001A2A1D5] Unknown function at TMethodImplementationIntercept + $1581B65\r\n(00000000016292E2){FHIRServer.exe} [0000000001A2A2E2] Unknown function at TMethodImplementationIntercept + $1581C72\r\n(000000000180CD52){FHIRServer.exe} [0000000001C0DD52] Unknown function at TMethodImplementationIntercept + $17656E2\r\n(000000000180CBF8){FHIRServer.exe} [0000000001C0DBF8] Unknown function at TMethodImplementationIntercept + $1765588\r\n(000000000180CBA2){FHIRServer.exe} [0000000001C0DBA2] Unknown function at TMethodImplementationIntercept + $1765532\r\n(0000000000686A37){FHIRServer.exe} [0000000000A87A37] Unknown function at TMethodImplementationIntercept + $5DF3C7\r\n(000000000180EC0E){FHIRServer.exe} [0000000001C0FC0E] Unknown function at TMethodImplementationIntercept + $176759E\r\n(000000000180E938){FHIRServer.exe} [0000000001C0F938] Unknown function at TMethodImplementationIntercept + $17672C8\r\n(0000000001952B54){FHIRServer.exe} [0000000001D53B54] Unknown function at TMethodImplementationIntercept + $18AB4E4\r\n(00000000016291D5){FHIRServer.exe} [0000000001A2A1D5] Unknown function at TMethodImplementationIntercept + $1581B65\r\n(000000000068612F){FHIRServer.exe} [0000000000A8712F] Unknown function at TMethodImplementationIntercept + $5DEABF\r\n(000000000068945B){FHIRServer.exe} [0000000000A8A45B] Unknown function at TMethodImplementationIntercept + $5E1DEB\r\n(00000000058DDE93){FHIRServer.exe} [0000000005CDEE93] Unknown function at TMethodImplementationIntercept + $5836823\r\n(00000000058D6483){FHIRServer.exe} [0000000005CD7483] Unknown function at TMethodImplementationIntercept + $582EE13\r\n(00000000058D2F0A){FHIRServer.exe} [0000000005CD3F0A] Unknown function at TMethodImplementationIntercept + $582B89A\r\n(00000000058F6F39){FHIRServer.exe} [0000000005CF7F39] Unknown function at TMethodImplementationIntercept + $584F8C9\r\n(00000000006EDAE9){FHIRServer.exe} [0000000000AEEAE9] Unknown function at TMethodImplementationIntercept + $646479\r\n(00000000006EF46A){FHIRServer.exe} [0000000000AF046A] Unknown function at TMethodImplementationIntercept + $647DFA\r\n(0000000000456C99){FHIRServer.exe} [0000000000857C99] Unknown function at TMethodImplementationIntercept + $3AF629\r\n(0000000000454CAA){FHIRServer.exe} [0000000000855CAA] Unknown function at TMethodImplementationIntercept + $3AD63A\r\n(000000000045994B){FHIRServer.exe} [000000000085A94B] Unknown function at TMethodImplementationIntercept + $3B22DB\r\n(0000000000458AEB){FHIRServer.exe} [0000000000859AEB] Unknown function at TMethodImplementationIntercept + $3B147B\r\n(0000000000139683){FHIRServer.exe} [000000000053A683] Unknown function at TMethodImplementationIntercept + $92013\r\n(000000000001219D){FHIRServer.exe} [000000000041319D]\r\n(00000000000074D4){KERNEL32.DLL} [00007FFD2DF284D4] BaseThreadInitThunk + $14\r\n(0000000000050791){ntdll.dll } [00007FFD2E021791] RtlUserThreadStart + $21\r\n"
}
]
}
Grahame Grieve (Nov 19 2020 at 09:14):
I don't know how specific we are about this, but a single operation outcome with an error means that the entire batch processing failed altogether. A single operation with a success is an error on the part of the server
Last updated: Apr 12 2022 at 19:14 UTC