我刚刚开始使用FHIR和json,所以我的问题可能不是很好。
我已经构建了一个BizTalk管道组件,使用此库https://github.com/ewoutkramer/fhir-net-api将FHIR-json转换为FHIR-xml,基于我在此处找到的示例,http://soapfault.com/blog/2016/08/hl7-fhir-json-decoding-in-biztalk/
以下是管道组件的代码段。它与示例几乎完全相同。
//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());
管道组件能够解码以...开头的任何单个json FHIR消息
{
"resourceType": "ImagingStudy",
但是我在这样的消息上得到了解析错误,
{
"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实现我的最终目标的建议将不胜感激。
答案 0 :(得分:0)
通常没有必要直接调用ResourceReader,但是我试图像这样重现你的错误:
\s*
然而,两者都很好。阅读流时可能出现问题?
您也可以尝试直接从流中阅读:
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);