FHIR Chat · Bundle type Transaction · implementers

Stream: implementers

Topic: Bundle type Transaction


view this post on Zulip Sridhar Vellore (Aug 20 2019 at 12:03):

I am trying to create Bundle of type transaction, I am expecting Fhir Server to create each of the resources in the Bundle but when I call the Create option I get an error "Error: HTTP 422 : Unable to store a Bundle resource on this server with a Bundle.type value of: transaction", I am getting the same error on public Test Server too, am I doing something incorrect?

view this post on Zulip Alexander Kiel (Aug 20 2019 at 12:20):

You have to POST the transaction bundle to the FHIR base URL not the [base]/Bundle URL.

view this post on Zulip Alexander Kiel (Aug 20 2019 at 12:21):

https://www.hl7.org/fhir/http.html#transaction

view this post on Zulip Sridhar Vellore (Aug 20 2019 at 14:42):

I posted a bundle of type Transaction to base URL localhost:8080/fhir/fhir/ and getting below message
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "This is the base URL of FHIR server. Unable to handle this request, as it does not contain a resource type or operation name."
}
]
}

and this is partial part of the Bundle
{
"resourceType": "Bundle",
"id": "916827a3-4434-4ade-9819-2cbc0e720a70",
"meta": {
"lastUpdated": "2019-08-19T06:03:48.152+00:00"
},
"identifier": {
"use": "official",
"system": "https://xyz.com/Patient",
"value": "7238593"
},
"type": "transaction",
"entry": [ ...
]
}

view this post on Zulip Alexander Kiel (Aug 20 2019 at 15:11):

What server is it? What does the capability statement say? You can access it under [base]/metadata. In it, on of the rest.interaction.code has to be transaction. Otherwise the transaction interaction isn't supported.

view this post on Zulip Sridhar Vellore (Aug 21 2019 at 10:56):

I checked the metadata and for Bundle there is no transaction setting for rest.interaction.code, What changes do I need to make to allow Transactions for Bundle?

view this post on Zulip Alexander Kiel (Aug 21 2019 at 11:45):

I didn't refer to Bundle specific interations. I mean the system-wide Restful interactions specified here: https://www.hl7.org/fhir/capabilitystatement-definitions.html#CapabilityStatement.rest.interaction

view this post on Zulip Angus Millar (Aug 22 2019 at 05:15):

I'm not sure if your server support TRansaction Bundle or not but if it did it should not be at the endpoint you have stated: localhost:8080/fhir/fhir/
The correct endpoint would be localhost:8080/fhir. The error you are getting makes complete sense. The server expects the 'fhir' on the end of localhost:8080/fhir/fhir/ to be a Resource type, for instance, localhost:8080/fhir/Patient/
Try again sending the Transaction Bundle to localhost:8080/fhir

view this post on Zulip Sridhar Vellore (Aug 26 2019 at 06:23):

@Angus Millar Thanks for the input, FhirServer I hosted at localhost:8080/fhir is protected with Okta so I am getting back an Okta page, alternatively I tried to post it to Public server "http://hapi.fhir.org/baseR4/Bundle" when the Bundle type is document I am getting back a 201 Created and the resource is created, but when I switch it to type "transaction" or "batch" I am getting a Status: 422 Unprocessable Entity and below response, The functionality I am expecting is that when I post a Bundle the server should be creating all the resources in the Bundle as distinct entities, is this functionality available off the shelf or do I need to implement it?

{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>Unable to store a Bundle resource on this server with a Bundle.type value of: transaction</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
},
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "Unable to store a Bundle resource on this server with a Bundle.type value of: transaction"
}
]
}

view this post on Zulip Alexander Kiel (Aug 26 2019 at 08:25):

Hi @Sridhar Vellore I already pointed you to the transaction endpoint documented here: https://www.hl7.org/fhir/http.html#transaction

You can't POST a transaction bundle to the Bundle create endpoint.

view this post on Zulip Angus Millar (Aug 26 2019 at 22:21):

Try and send your transaction bundle to either of these two endpoints and I can check late to see if I can see any problems with what you are doing. Both of these do support transaction bundles as you describe:
FHIR STU3 Endpoint
https://stu3.test.pyrohealth.net/fhir
FHIR R4 Endpoint
https://r4.test.pyrohealth.net/fhir

view this post on Zulip Alexander Kiel (Aug 27 2019 at 06:31):

But please, do not send any sensitive data :-)

view this post on Zulip Armstrong Dcosta (Aug 27 2019 at 09:27):

Hi, I am new Hapi, just setup the default server and changed the connection to MySQL, How can i populate the Database Resources ? Please Help.

view this post on Zulip Alexander Kiel (Aug 27 2019 at 09:28):

@Armstrong Dcosta You can populate the database with resources using the Restful API documented here: https://www.hl7.org/fhir/http.html

view this post on Zulip Armstrong Dcosta (Aug 30 2019 at 09:55):

Armstrong Dcosta You can populate the database with resources using the Restful API documented here: https://www.hl7.org/fhir/http.html

Thanks @Alexander Kiel , I got that working. I have another question
Q. Using hapi-fhir-cli, Can I run two fhir version running on the same port ? Currently I have version r4 running on http://localhost:8080/, and I want to add dstu3 version. Can this be achieved ?

view this post on Zulip Alexander Kiel (Aug 30 2019 at 10:24):

@Armstrong Dcosta I don't know. Please ask in the hapi stream.

view this post on Zulip Sridhar Vellore (Sep 03 2019 at 05:26):

@Angus Millar
I posted request to https://r4.test.pyrohealth.net/fhir and I received response in the attached file, I have also attached the request JSON, here are the settings in my application.yml and the response I am getting when hitting http://localhost:8080/fhir.

{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "This is the base URL of FHIR server. Unable to handle this request, as it does not contain a resource type or operation name."
}
]
}


h2:
console:
enabled: true
hapi:
fhir:
version: R4
server:
path: /fhir/*
rest:
server-name: hapi-fhir-spring-boot-sample-server-jpa
server-version: 1.0.0
implementation-description: Spring Boot Jpa Server Sample
default-response-encoding: json
e-tag-support: enabled
default-pretty-print: true
validation:
enabled: true
request-only: true
jpa:
scheduling-disabled: true
subscription-enabled: false
management:
security:
enabled: false

pyrohealthResp.txt
Request.txt

view this post on Zulip Angus Millar (Sep 03 2019 at 06:43):

Ok Sridhar, let me look into this and i will get back to you.

view this post on Zulip Angus Millar (Sep 03 2019 at 07:43):

Ok, a little odd, I can't seem to find the request you made in any of the server logs, what date did you make this request?
That aside, I took your transaction bundle from the Request.txt and put it in PostMan and did a POST to the endpoint https://r4.test.pyrohealth.net/fhir with the Content-Type header set to 'application/fhir+json' and it worked just fine, no errors at all. Here is the response I go back:

{
    "resourceType": "Bundle",
    "id": "16e5e986-d669-4bad-af33-d886a3d884fa",
    "meta": {
        "lastUpdated": "2019-09-03T07:35:43.6295852+00:00"
    },
    "identifier": {
        "use": "official",
        "system": "https://mcmrt.tnckn.com.com/Patient",
        "value": "7238593"
    },
    "type": "transaction-response",
    "entry": [
        {
            "fullUrl": "https://r4.test.pyrohealth.net/fhir/MessageHeader/8c5221fe-2ceb-45c1-a431-934cbd78242c",
            "resource": {
                "resourceType": "MessageHeader",
                "id": "8c5221fe-2ceb-45c1-a431-934cbd78242c",
                "meta": {
                    "versionId": "1",
                    "lastUpdated": "2019-09-03T07:35:43.6764288+00:00"
                },
                "eventCoding": {
                    "system": "https://mcmrt.tnckn.com/fhir/message-events",
                    "code": "msgcode"
                },
                "sender": {
                    "reference": "Organization/org-001"
                },
                "source": {
                    "name": "ROME2",
                    "endpoint": "E0393CD2-B78F-4CBE-890B-FE4D3965ECFA"
                }
            },
            "response": {
                "status": "201 Created",
                "location": "https://r4.test.pyrohealth.net/fhir/MessageHeader/8c5221fe-2ceb-45c1-a431-934cbd78242c/_history/1",
                "etag": "W/\"1\"",
                "lastModified": "2019-09-03T07:35:43.6764288+00:00"
            }
        },
        {
            "fullUrl": "https://r4.test.pyrohealth.net/fhir/Parameters/d89821f7-6810-4d91-9f64-34ab472e8435",
            "resource": {
                "resourceType": "Parameters",
                "id": "d89821f7-6810-4d91-9f64-34ab472e8435",
                "meta": {
                    "versionId": "1",
                    "lastUpdated": "2019-09-03T07:35:43.8795514+00:00"
                },
                "parameter": [
                    {
                        "name": "RequestId",
                        "valueString": "c3130d18-ec49-4d5e-bb02-4182f154ef35"
                    },
                    {
                        "name": "RequestorId",
                        "valueString": "RequestorId"
                    },
                    {
                        "name": "RequestingApplication",
                        "valueString": "RequestingApplication"
                    },
                    {
                        "name": "RequestDateTime",
                        "valueDateTime": "2019-04-09T16:16:35-04:00"
                    },
                    {
                        "name": "RequestType",
                        "valueString": "RequestType"
                    },
                    {
                        "name": "ExpirationDate",
                        "valueDateTime": "2019-04-19T16:16:35-04:00"
                    },
                    {
                        "name": "DOSStartDate",
                        "valueDate": "2014-08-17"
                    },
                    {
                        "name": "DOSEndDate",
                        "valueDate": "2090-07-04"
                    }
                ]
            },
            "response": {
                "status": "201 Created",
                "location": "https://r4.test.pyrohealth.net/fhir/Parameters/d89821f7-6810-4d91-9f64-34ab472e8435/_history/1",
                "etag": "W/\"1\"",
                "lastModified": "2019-09-03T07:35:43.8795514+00:00"
            }
        }
    ]
}

view this post on Zulip Angus Millar (Sep 03 2019 at 07:48):

Ok, I know what happened. I think you did not set the Content-Type header as I did above. I tried again and this time I did not set the Content-Type header at all and I got the exact same OperationOutcome response that you also received. Try again but this time set the Content-Type like this:
Content-Type: application/fhir+json

view this post on Zulip Sridhar Vellore (Sep 04 2019 at 10:38):

@Angus Millar I tried by setting the Content-Type to application/fhir+json but I am getting a different error. btw have you implemented any logic to handle Bundle with type as transaction?
Here are the responses when hitting different URL's

Public Server => http://hapi.fhir.org/baseR4
{
"resourceType": "Bundle",
"id": "822f4d05-9b06-4f88-8afd-213341ee533b",
"type": "transaction-response",
"link": [
{
"relation": "self",
"url": "http://hapi.fhir.org/baseR4"
}
],
"entry": [
{
"response": {
"status": "201 Created",
"location": "MessageHeader/156656/_history/1",
"etag": "1",
"lastModified": "2019-09-04T09:56:17.208+00:00"
}
},
{
"response": {
"status": "201 Created",
"location": "Parameters/156657/_history/1",
"etag": "1",
"lastModified": "2019-09-04T09:56:17.208+00:00"
}
}
]
}

PyroHealth => https://r4.test.pyrohealth.net/fhir
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\r\n <div>\r\n <h4>OperationOutcome Issue: 1</h4>\r\n <table>\r\n <tr>\r\n <td>\r\n <span>\r\n <b>Severity: </b>\r\n </span>\r\n </td>\r\n <td>\r\n <span>fatal</span>\r\n </td>\r\n </tr>\r\n <tr>\r\n <td>\r\n <span>\r\n <b>Type: </b>\r\n </span>\r\n </td>\r\n <td>\r\n <span>not-supported</span>\r\n </td>\r\n </tr>\r\n <tr>\r\n <td>\r\n <span>\r\n <b>Detail Text: </b>\r\n </span>\r\n </td>\r\n <td>\r\n <span>None of the Http Accept header values are suported by the server. The primary values that are supported are application/fhir+json and application/fhir+xml</span>\r\n </td>\r\n </tr>\r\n </table>\r\n </div>\r\n</div>"
},
"issue": [
{
"severity": "fatal",
"code": "not-supported",
"details": {
"text": "None of the Http Accept header values are suported by the server. The primary values that are supported are application/fhir+json and application/fhir+xml"
}
}
]
}

My Local Server => http://localhost:8080/fhir
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "processing",
"diagnostics": "This is the base URL of FHIR server. Unable to handle this request, as it does not contain a resource type or operation name."
}
]
}

view this post on Zulip Lloyd McKenzie (Sep 04 2019 at 14:02):

Based on those errors, it seems that you're not setting the content-type properly. The first server is forgiving. The second is not. And the third doesn't support transaction at all.

view this post on Zulip Angus Millar (Sep 04 2019 at 14:02):

Hi @Sridhar Vellore , My apologies, as the OperationOutcome says you also need to set the Accept header as well. Set it also to application/fhir+json. Yes, the endpoint https://r4.test.pyrohealth.net/fhir does support bundles of type Transaction, as I showed in my last comment. I can't comment on the same support on the other endpoints.

view this post on Zulip Sridhar Vellore (Sep 05 2019 at 05:33):

@Angus Millar Thanks for the input, When I looked up on Hapi Fhir documentation on how to implement Transaction I saw this info https://hapifhir.io/doc_rest_operations.html#_toc_system_level_-_transaction. I was not sure how and where to implement this method, so I wrote a new class that extends Bundle and was planning to provide the implementation

public class TxnBundleResourceProvider extends BundleResourceProvider {

@Transaction
public Bundle transaction(@TransactionParam Bundle theInput) {
    for (Bundle.BundleEntryComponent nextEntry : theInput.getEntry()) {

I am using Hapi Fhir JPA Server on SpringBoot and I would like to know how can I force the Restful Server to instantiate my ResourceProvider, or it would be helpful if you can point me towards any resource that provides detail on how to implement a Transaction.

view this post on Zulip Angus Millar (Sep 06 2019 at 05:33):

Hi @Sridhar Vellore , Looking at that HAPI reference you provided it appears the HAPI server does not natively support Bundles of type Transaction. They do appear to provide an integration point for you to provide your own implementation. As they have warned it is not the simplest of jobs to implement as it has many aspects to consider. I'm afraid I can't help you directly with the HAPI implementation you require. What I can provide you is my implementation in .NET, as a guide. That's not to say mine if perfect but it might help you a little.
https://github.com/angusmillar/Pyro/blob/release-r4/Pyro.Common/FhirOperation/BundleTransaction/BundleTransactionOperation.cs

view this post on Zulip Sridhar Vellore (Sep 06 2019 at 05:50):

Thank you Millar

view this post on Zulip Jeremy Chapman (Sep 13 2019 at 18:29):

If a bundle type is a transaction, what is the first resource?can it be anything?

view this post on Zulip Patrick Werner (Sep 13 2019 at 18:34):

you mean the first entry? Yes can be anything.

view this post on Zulip Ali Haider (Sep 14 2019 at 11:01):

Hey guys, need your help. I need to implement Search using FHIR, does anybody have any idea???

view this post on Zulip Grahame Grieve (Sep 14 2019 at 11:01):

please see https://wiki.hl7.org/index.php?title=FHIR_Rules_for_asking_questions

view this post on Zulip Ali Haider (Sep 14 2019 at 11:04):

thanks @Grahame Grieve I will look into it


Last updated: Apr 12 2022 at 19:14 UTC