【发布时间】:2022-01-06 15:49:01
【问题描述】:
我正在尝试将二进制数据保存到 FHIR DB。
这是我的方法:
public static Patient SavePdfForms(string resource, HttpClientEventHandler messageHandler, string[] pdfForms, Patient patient, FhirClient BinaryBundleClient)
{
Bundle BinaryBundle = new Bundle();
BinaryBundle.Type = Bundle.BundleType.Collection;
try
{
foreach (var item in pdfForms)
{
Binary BinaryData = new Binary();
var bytearray = Encoding.ASCII.GetBytes(item);
BinaryData.Data = bytearray;
BinaryData.ContentType = "application/fhir+json";
var binaryResource = BinaryBundleClient.Create(BinaryData);
BinaryBundle.AddResourceEntry(BinaryData, resource + "/BundleResource/" + binaryResource.Id);
}
}
catch (Exception ex)
{
throw;
}
var bundleId = BinaryBundleClient.Create(BinaryBundle);
patient.Identifier.Add(new Identifier("BinaryBundle", bundleId.Id));
return BinaryBundleClient.Update(patient);
}
pdfForms 的字符串[] 是 base64,对于每个表单,我都在创建一个新的二进制文件并添加数据和内容类型。但是var binaryResource = BinaryBundleClient.Create(BinaryData); 行会引发错误,并且数据不是有效的 json。我尝试了不同的内容类型,但这不起作用。任何想法为什么?
【问题讨论】:
标签: c# azure-functions hl7-fhir