BizTalk中的FHIR JSON到XML解码 [英] FHIR JSON to XML decoding in BizTalk

查看:190
本文介绍了BizTalk中的FHIR JSON到XML解码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是从FHIR和json开始,所以我的问题可能不会被很好地问到.

我已经构建了一个BizTalk管道组件,以使用该库 https://github.com/ewoutkramer/fhir-net-api ,基于我在这里找到的示例

但是我收到这样的开头消息的解析错误,

{
  "resourceType" : "Bundle",
  "entry" : [{
      "resource" : {
        "resourceType" : "ImagingStudy",

{
  "entry": [
    {
      "fullUrl":     "http://fhirtest.uhn.ca/baseDstu2/ImagingStudy/EXexample",
      "resource": {
        "resourceType": "ImagingStudy",

这是我遇到的几个错误,

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

对于我的解决方案,最终目标是能够将FHIR图像研究消息包解析为单个fhir xml消息,然后将其映射为HL7 ORU消息.

对于上述问题的任何帮助或有关使用BizTalk实现最终目标的建议,将不胜感激.

解决方案

通常不必直接调用ResourceReader,尽管如此,我还是尝试重现您的错误:

var json = @"{
            ""resourceType"" : ""Bundle"",
            ""entry"" : [{
                  ""resource"" : {
                       ""resourceType"" : ""ImagingStudy""
                                       }}]}";

// SHORT VERSION: var b = new FhirJsonParser().Parse<Bundle>(json);
var b = new     
             Hl7.Fhir.Serialization.ResourceReader(
               FhirJsonParser.CreateFhirReader(json),  
                          ParserSettings.Default).Deserialize();

Assert.IsNotNull(b);

但是,两者都可以正常工作.也许在阅读信息流时出了什么问题?

您还可以尝试直接从流中读取内容:

var b = new FhirJsonParser().Parse<Bundle>(new 
                     Newtonsoft.Json.JsonTextReader(stream));

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:

var json = @"{
            ""resourceType"" : ""Bundle"",
            ""entry"" : [{
                  ""resource"" : {
                       ""resourceType"" : ""ImagingStudy""
                                       }}]}";

// SHORT VERSION: var b = new FhirJsonParser().Parse<Bundle>(json);
var b = new     
             Hl7.Fhir.Serialization.ResourceReader(
               FhirJsonParser.CreateFhirReader(json),  
                          ParserSettings.Default).Deserialize();

Assert.IsNotNull(b);

Both work fine, however. Maybe something goes wrong while reading the stream?

You could also try reading directly from the stream:

var b = new FhirJsonParser().Parse<Bundle>(new 
                     Newtonsoft.Json.JsonTextReader(stream));

这篇关于BizTalk中的FHIR JSON到XML解码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆