FHIR Chat · Performing a batch request · dotnet

Stream: dotnet

Topic: Performing a batch request


view this post on Zulip Dimitar (Dec 09 2017 at 19:17):

Hello,
How is it possible for me to build a batch request in the .NET FHIR API?

view this post on Zulip Yunwei Wang (Dec 09 2017 at 20:00):

var bundle = new Bundle() { Type = Bundle.BundleType.Batch };

view this post on Zulip Dimitar (Dec 09 2017 at 20:08):

@Yunwei Wang Thank you, can the TransactionBuilder be used as well in that case or?

view this post on Zulip Yunwei Wang (Dec 09 2017 at 20:16):

A Bundle can be either batch or transaction. If you need transaction, use TransactionBuider.

view this post on Zulip Dimitar (Dec 09 2017 at 20:21):

Then why is there a parameter in transaction builder that accepts the type of bundle to be returned:
pasted image

view this post on Zulip Yunwei Wang (Dec 09 2017 at 20:25):

Interesting. That means TransactionBuilder can be used to build batch bundle. I always use Bundle itself for batch request. Anyway, now I think the difference is like String vs StringBuilder. Just pick one you are comfortable with.

view this post on Zulip Dimitar (Dec 09 2017 at 20:48):

@Yunwei Wang Alright, thank you for the clarification, I will consider your aproach aswell, it's good to know that both work. You are right, it's very similar to the StringBuilder.

view this post on Zulip Dimitar (Dec 10 2017 at 00:23):

I am facing one problem however, whenever I build all of my get request, with the TransactionBuilder and execute the transaction of batches, it doesn't do the GET requests, when I tried the URLs they work just fine, am I doing something wrong or?

view this post on Zulip Brian Postlethwaite (Dec 10 2017 at 00:49):

code snippit would be useful.
When I'm developing I often run fiddler in the background so that I can examine and understand what is going over the wire.
With a Batch operation, there is only a single call, which is the POST of the bundle to the endpoint. All of the interactions inside the bundle are executed on the server, and the results are found in the returned bundle.
Hope that helps.

view this post on Zulip Dimitar (Dec 10 2017 at 01:02):

@Brian Postlethwaite Basically, what I am doing, is the following, I add string GET requests, to a list. After I add them to the list, I build a transaction, based on each GET request, which was built using those strings, the following way:
pasted image
And after that is done, I execute a transaction, which is supposed to post that batch, with the get requests.

view this post on Zulip Dimitar (Dec 10 2017 at 01:15):

pasted image
Those are the get requests
I get a 404 Error Unknown resource type 'http:'

view this post on Zulip Brian Postlethwaite (Dec 10 2017 at 01:37):

That does look strange, not sure what {lastN} is, it looks like its going to mess with the Resource name, should that be on the left of the "?"

view this post on Zulip Dimitar (Dec 10 2017 at 01:46):

In my case lastn is empty string, because hapi server, doesn't support the lastn operation http://hl7.org/fhir/STU3/observation-operations.html#lastn
pasted image

view this post on Zulip Brian Postlethwaite (Dec 10 2017 at 03:00):

You have uri.Unescape, I think you meant to have Uri.EscapeString

view this post on Zulip Dimitar (Dec 10 2017 at 13:07):

(deleted)

view this post on Zulip Dimitar (Dec 10 2017 at 13:13):

@Brian Postlethwaite it's very strange, because when I look into the transaction builder, where the for one of the element URl is, for example "http://fhirtest.uhn.ca/baseDstu3/Observation?patient=Patient/330828&code=http://loinc.org|8302-2,http://loinc.org|8306-3,http://loinc.org|8308-9&date=ge2013-11-12T00:00:00", executes just fine in postman, however it gives that error when its sent as a transaction.

view this post on Zulip Dimitar (Dec 10 2017 at 13:37):

(deleted)

view this post on Zulip Dimitar (Dec 10 2017 at 14:19):

Ok I found out what he problem is, basically in the request URL of each entry in the Bundle, it starts with the Server URI, which was the parameter of the transaction bundle, and whenever I would execute the Transaction, it would execute the get Request like so: [baseUrl]/[baseUrl]/Observation?patient=Patient etc..

view this post on Zulip Dimitar (Dec 10 2017 at 14:22):

@Yunwei Wang So Yunwei, I think your approach is the way to go :)


Last updated: Apr 12 2022 at 19:14 UTC