使用 Firely 如何解析来自 HL7.Fhir.Model.Appointment JSON 响应的参与者部分的数据?

Using Firely how can I parse the data from the participant section of a HL7.Fhir.Model.Appointment JSON response?

使用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 Hl7.Fhir.Model;
using Hl7.Fhir.ElementModel;
using Hl7.FhirPath;

然后您可以使用以下代码获取包含 Practitioner 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);
}