【发布时间】:2020-12-20 08:06:28
【问题描述】:
我试图获取标识符、位置、句点等元素,但没有用。我怎么才能得到它? 我的代码如下:
static void Main(string[] args)
{
//The fhir server end point address
string ServiceRootUrl = "http://stu3.test.pyrohealth.net/fhir";
//Create a client to send to the server at a given endpoint.
var FhirClient = new Hl7.Fhir.Rest.FhirClient(ServiceRootUrl);
// increase timeouts since the server might be powered down
FhirClient.Timeout = (60 * 1000);
Console.WriteLine("Press any key to send to server: " + ServiceRootUrl);
Console.WriteLine();
Console.ReadKey();
try
{
//Attempt to send the resource to the server endpoint
Hl7.Fhir.Model.Bundle ReturnedSearchBundle = FhirClient.Search<Hl7.Fhir.Model.Patient>(new string[] { "status=planned" });
Console.WriteLine(string.Format("Found: {0} Fhirman patients.", ReturnedSearchBundle.Total.ToString()));
Console.WriteLine("Their logical IDs are:");
foreach (var Entry in ReturnedSearchBundle.Entry)
{
Console.WriteLine("ID: " + Entry.Resource.Id);
Console.WriteLine("ID2: " + Entry.Identifier);
}
Console.WriteLine();
}
catch (Hl7.Fhir.Rest.FhirOperationException FhirOpExec)
{
//Process any Fhir Errors returned as OperationOutcome resource
Console.WriteLine();
Console.WriteLine("An error message: " + FhirOpExec.Message);
Console.WriteLine();
string xml = Hl7.Fhir.Serialization.FhirSerializer.SerializeResourceToXml(FhirOpExec.Outcome);
XDocument xDoc = XDocument.Parse(xml);
Console.WriteLine(xDoc.ToString());
}
catch (Exception GeneralException)
{
Console.WriteLine();
Console.WriteLine("An error message: " + GeneralException.Message);
Console.WriteLine();
}
Console.WriteLine("Press any key to end.");
Console.ReadKey();
}
结果是 System.Collections.Generic.List`1[Hl7.Fhir.Model.Identifier]
【问题讨论】:
-
这意味着你有一个标识符列表,你必须通过列表来获取数据。列表包含什么?
-
你有什么异常吗?你是否通过代码来确定你失败的地方?将 try 块放在创建 FhirClient 的行周围,以防构造函数失败。如果您没有收到任何异常,则可能患者不在数据库中。您可能使用了错误的数据库。