我刚开始使用FHIR和json,所以我的问题可能没有被很好地问出来。
基于我在这里找到的示例http://soapfault.com/blog/2016/08/hl7-fhir-json-decoding-in-biztalk/,我使用这个库https://github.com/ewoutkramer/fhir-net-api构建了一个BizTalk管道组件,用于将FHIR-json转换为FHIR-xml。
下面是管道组件的代码片段。它与示例几乎完全相同。
//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());管道组件能够解码以{ "resourceType": "ImagingStudy",开头的任何单个json FHIR消息。
但是我在像这样开始的消息上得到了一个解析错误,
{
"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.或
Reason: At line 1, pos 1: Cannot determine type of resource to create from json input data: no member resourceType was found对于我的解决方案,最终目标是能够将成堆的冷杉图像研究消息解析成单个冷杉xml消息,然后将这些消息映射到HL7 ORU消息。
对于上述问题的任何帮助,或者关于如何使用BizTalk实现我的最终目标的建议,我们将不胜感激。
发布于 2017-02-17 17:05:29
通常不需要直接调用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));https://stackoverflow.com/questions/42287503
复制相似问题