簡體   English   中英

如何更新 FHIR API 中的患者?

[英]How to update Patient in FHIR API?

我有患者的 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);
    }

感謝幫助。

電信和地址字段是列表。 因此,如果您有現有數據並且您執行 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" };

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM