HAPI FHIR Plain server: How to implement the processing of FHIR Bundle message of type transaction?

304 views
Skip to first unread message

Joost Van Averbeke

unread,
Apr 7, 2023, 9:42:27 AM4/7/23
to HAPI FHIR
I am creating a HAPI FHIR Plain Server.
I manage to implement FHIR resource providers such as Patient, Encounter, ...

But I also want to be able to process FHIR Bundles of type transaction.
When I try to execute a "create" with a Bundle message to the HAPI Test Server (R4 FHIR) (http://hapi.fhir.org/resource?serverId=home_r4&pretty=false&_summary=&resource=Bundle),
I get the message:

Warning!
Error: HTTP 422 Unprocessable Entity: HAPI-0522: Unable to store a Bundle resource on this server with a Bundle.type value of: transaction. Note that if you are trying to perform a FHIR transaction or batch operation you should POST the Bundle resource to the Base URL of the server, not to the /Bundle endpoint.

Indeed when a post the FHIR Bundle message of type transaction to the root URL (http://hapi.fhir.org/baseR4), my bundle is treated successfuly. "response": {"status": "201 Created", ...}

I conclude that I should not use the Resource Providers and Plain Providers mechanism (https://hapifhir.io/hapi-fhir/docs/server_plain/resource_providers.html) to process incoming bundles of type transaction.

What kind of HAPI FHIR mechanism, should I use?

Could you give me some guidance on to start my HAPI FHIR implementation?
I googled around but couldn't find any starting point.

Thanks in Advance

Joost 

Aitor Pérez Pellitero

unread,
Apr 11, 2023, 2:47:58 AM4/11/23
to HAPI FHIR
Hi Joost,

For exposing the Bundle transaction endpoint you need to use the method annotation "@Transaction" (like you use other annotations like "@Create" or "@Update").

Something like this:

@Transaction
public IBaseBundle transaction(RequestDetails theRequestDetails, @TransactionParam IBaseBundle theResources) {
... your implementation ...


And you will need to declare the class as a PlainProvider or ResourceProvider (with resource type Bundle) in your configuration.

Regards

Joost Van Averbeke

unread,
Apr 11, 2023, 5:50:09 AM4/11/23
to HAPI FHIR
Thank you very much for your feedback.

Op dinsdag 11 april 2023 om 08:47:58 UTC+2 schreef Aitor Pérez Pellitero:
Reply all
Reply to author
Forward
0 new messages