【问题标题】:How to update Patient in FHIR API?如何在 FHIR API 中更新患者?
【发布时间】:2020-12-23 11:32:56
【问题描述】:

我有患者的 JSON 数据,我尝试用新数据更新它。 当我尝试更新此患者时,条目将重复并且不会像这样更新:

{
   "telecom": [
    {
        "system": "phone",
        "value": "2222215",
        "use": "home"
    },
    {
        "system": "phone",
        "value": "2222215",
        "use": "home"
    }
],
"gender": "male",
"birthDate": "2020-12-24",
"address": [
    {
        "use": "home",
        "line": [
            "28MCT"
        ],
        "city": "Hưng Yên",
        "district": "Huyện Kim Động",
        "state": "Thị Trấn Lương Bằng",
        "country": "VNM"
    },
    {
        "use": "home",
        "city": "Hưng Yên",
        "district": "Huyện Kim Động",
        "state": "Thị Trấn Lương Bằng",
        "country": "VNM"
    }
]}

确切的更新方式是什么?这是我的代码:

private static void UpdatePatient(string patientId)
    {
        var client = new FhirClient("http://hapi.fhir.org/baseR4");
        Patient pat = client.Read<Patient>("Patient/1723313");
        pat.Address.Add(new Address(){ 
            Line = new string[1] {"28 MCT"},
            District = "Bến Cát",
            State = "An Thới",
            City = "Bình Dương",
            Country = "VNM"
        });
        client.Update<Patient>(pat);
    }

感谢您的帮助。

【问题讨论】:

  • 您是否通过 HTTP 调试器运行客户端网络流量?

标签: c# json hl7-fhir


【解决方案1】:

电信和地址字段是列表。因此,如果您有现有数据并且您执行 pat.Address.Add,它将向现有列表添加一个新项目 - 保留现有地址。在将更新的数据发送到服务器之前,您实际上必须先更新您的 Telecom/Address 字段。

例如 - 在 client.Read 和 client.Update 之间,使用 System.Linq:

var a = x.Address.First(ca => ca.Use == Address.AddressUse.Home);
a.Line = new string[] { "28 MCT" };

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多