如何解决使用 Firely 如何解析来自 HL7.Fhir.Model.Appointment JSON 响应的参与者部分的数据?
使用 Hl7.Fhir.R4 (2.0.1)
当我收到预约的 API 响应时,有一部分参与者使用 Firely 包,我如何提取特定的参与者数据?
例如,对于约会,我在约会参与者的 JSON 中有此部分。
"participant": [
{
"actor": {
"reference": "https://url/fhir/v2/Practitioner/111","display": "https://url/fhir/v2/Practitioner/111"
}
},{
"actor": {
"reference": "https://url/fhir/v2/Location/222","display": "https://url/fhir/v2/Location/222"
}
},{
"actor": {
"reference": "https://url/fhir/v2/Patient/333","display": "https://url/fhir/v2/Patient/333"
}
}
]
如果有从业者演员我想创建一个新的字符串设置为从业者的ID; (111) 在上面的例子中。从参考 URL 中提取该信息的正确方法是什么?
解决方法
您可以使用 ITypedElement 和 FhirPath 来获取您需要的数据。 添加这些 using 语句:
using Hl7.Fhir.Model;
using Hl7.Fhir.ElementModel;
using Hl7.FhirPath;
然后您可以使用以下代码获取包含从业者 ID 的列表:
List<string> practitionerList = new List<string>();
var typedApp = [yourAppointmentResource].ToTypedElement();
foreach (var p in typedApp.Select("participant.actor"))
{
var r = new ResourceIdentity(p.ParseResourceReference().Reference);
if (r.ResourceType.Equals("Practitioner"))
practitionerList.Add(r.Id);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。