Skip to content

FHIR bundle in JSON #2503

Answered by mbaltus
testlorenzospa asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can read a string from file or have an in-memory string and parse it to a Bundle object first, before you do what you would like after the REST call. Another option is to use one of the publicly available FHIR test servers.

Here's an example reading a Bundle from file and parsing it:

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Hl7.Fhir.Serialization;
using System.Text.Json;

void Test() {
  JsonSerializerOptions options = new JsonSerializerOptions().ForFhir();

  string jsonInput = File.ReadAllText("bundle.json");
  Bundle bundle = JsonSerializer.Deserialize<Bundle>(jsonInput, options);

  foreach (var entry in bundle.Entry)
  {  // do something with the entry }
}

or…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by marcovisserFurore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants