I am just starting out with FHIR and with json so my question may not be well asked.
I have built a BizTalk pipeline component to convert FHIR-json to FHIR-xml using this library, https://github.com/ewoutkramer/fhir-net-api , based on an example i found here, http://soapfault.com/blog/2016/08/hl7-fhir-json-decoding-in-biztalk/
Here is a code snippet from the pipeline component. It's almost identical to the example.
//Read the json message
using (TextReader tr = new StreamReader(originalDataStream))
{
json = tr.ReadToEnd();
}
//Use FHIR-NET-API to create a FHIR resource from the json
Hl7.Fhir.Serialization.ResourceReader resourceReader = new Hl7.Fhir.Serialization.ResourceReader(FhirJsonParser.CreateFhirReader(json), ParserSettings.Default);
//Use FHIR-NET-API to serialize the resource to XML
byte[] resourceXmlBytes = Hl7.Fhir.Serialization.FhirSerializer.SerializeToXmlBytes(resourceReader.Deserialize());
The pipeline component is able to decode any single json FHIR message that starts with
{
"resourceType": "ImagingStudy",
but I get a parsing error on the messages that start like this,
{
"resourceType" : "Bundle",
"entry" : [{
"resource" : {
"resourceType" : "ImagingStudy",
or
{
"entry": [
{
"fullUrl": "http://fhirtest.uhn.ca/baseDstu2/ImagingStudy/EXexample",
"resource": {
"resourceType": "ImagingStudy",
Here are a couple of the errors I have got,
There was a failure executing the receive pipeline: "LALALA.Imaging.Pipelines.FHIRJasonDecoderRP, LALALA.Imaging.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=19bb8b5ea64396aa" Source: "FHIRJsonDecoder" Receive Port: "RP_LA_Test_FILE" URI: "D:\Projects\LALALA.Imaging\In\*.json" Reason: Data at the root level is invalid. Line 1, position 1.
OR
Reason: At line 1, pos 1: Cannot determine type of resource to create from json input data: no member resourceType was found
For my solution the ultimate goal is to to be able parse bundles of FHIR image study messages into single fhir xml messages that will then be mapped to HL7 ORU messages.
Any help with the issue above or suggestions on how to achieve my end goal using BizTalk would be greatly appreciated.
It's generally not necessary to call the ResourceReader directly, nevertheless I tried to reproduce your error like this:
Both work fine, however. Maybe something goes wrong while reading the stream?
You could also try reading directly from the stream: