向 R4 患者添加扩展

Add extension to R4 Patient

如何将以下内容添加到 R4 患者?

        "search": {
            "extension": [
                {
                    "url": "http://hl7.org/fhir/StructureDefinition/match-grade",
                    "valueCode": "certain"
                }
            ],
            "mode": "match",
            "score": 1.0
        }

stu2 和 stu3(我认为)下的对象已被弃用。

DSTU3 and Later
// Create an example patient
Patient patient = new Patient();
patient.addIdentifier().setUse(Identifier.IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");

// Create an extension
Extension ext = new Extension();
ext.setUrl("http://example.com/extensions#someext");
ext.setValue(new DateTimeType("2011-01-02T11:13:15"));

// Add the extension to the resource
patient.addExtension(ext);

来自以下患者匹配的完整“响应”json(样本数据,不是真实数据!!)

{
    "resourceType": "Bundle",
    "id": "94897c77-4120-482f-bdb4-4c8b9a71ade1",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2020-11-24T08:45:49.445-05:00"
    },
    "type": "searchset",
    "total": 1,
    "link": [
        {
            "relation": "self",
            "url": "http://wildfhir4.aegis.net/fhir4-0-0/Patient/$match?"
        }
    ],
    "entry": [
        {
            "fullUrl": "http://wildfhir4.aegis.net/fhir4-0-0/Patient/9126db824dcf4d5ab3f68e63bd5eaced",
            "resource": {
                "resourceType": "Patient",
                "id": "9126db824dcf4d5ab3f68e63bd5eaced",
                "meta": {
                    "versionId": "1",
                    "lastUpdated": "2020-09-03T09:03:28.193-04:00",
                    "tag": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
                            "code": "HTEST",
                            "display": "test health data"
                        }
                    ]
                },
                "text": {
                    "status": "generated",
                    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><table><tbody><tr><td>Name</td><td>Peter James                             \n              <b>Chalmers</b> (&quot;Jim&quot;)                        \n            </td></tr><tr><td>Address</td><td>534 Erewhon, Pleasantville, Vic, 3999</td></tr><tr><td>Contacts</td><td>Home: unknown. Work: (03) 5555 6473</td></tr><tr><td>Id</td><td>MRN: 12345 (Acme Healthcare)</td></tr></tbody></table></div>"
                },
                "identifier": [
                    {
                        "use": "usual",
                        "type": {
                            "coding": [
                                {
                                    "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                                    "code": "MR"
                                }
                            ]
                        },
                        "system": "urn:oid:1.2.36.146.595.217.0.1",
                        "value": "12345",
                        "period": {
                            "start": "2001-05-06"
                        },
                        "assigner": {
                            "display": "Acme Healthcare"
                        }
                    }
                ],
                "active": true,
                "name": [
                    {
                        "use": "official",
                        "family": "Chalmers",
                        "given": [
                            "Peter",
                            "James"
                        ]
                    },
                    {
                        "use": "usual",
                        "given": [
                            "Jim"
                        ]
                    },
                    {
                        "use": "maiden",
                        "family": "Windsor",
                        "given": [
                            "Peter",
                            "James"
                        ],
                        "period": {
                            "end": "2002"
                        }
                    }
                ],
                "telecom": [
                    {
                        "use": "home"
                    },
                    {
                        "system": "phone",
                        "value": "(03) 5555 6473",
                        "use": "work",
                        "rank": 1
                    },
                    {
                        "system": "phone",
                        "value": "(03) 3410 5613",
                        "use": "mobile",
                        "rank": 2
                    },
                    {
                        "system": "phone",
                        "value": "(03) 5555 8834",
                        "use": "old",
                        "period": {
                            "end": "2014"
                        }
                    }
                ],
                "gender": "male",
                "birthDate": "1974-12-25",
                "_birthDate": {
                    "extension": [
                        {
                            "url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
                            "valueDateTime": "1974-12-25T14:35:45-05:00"
                        }
                    ]
                },
                "deceasedBoolean": false,
                "address": [
                    {
                        "use": "home",
                        "type": "both",
                        "text": "534 Erewhon St PeasantVille, Rainbow, Vic  3999",
                        "line": [
                            "534 Erewhon St"
                        ],
                        "city": "PleasantVille",
                        "district": "Rainbow",
                        "state": "Vic",
                        "postalCode": "3999",
                        "period": {
                            "start": "1974-12-25"
                        }
                    }
                ],
                "contact": [
                    {
                        "relationship": [
                            {
                                "coding": [
                                    {
                                        "system": "http://terminology.hl7.org/CodeSystem/v2-0131",
                                        "code": "N"
                                    }
                                ]
                            }
                        ],
                        "name": {
                            "family": "du Marché",
                            "_family": {
                                "extension": [
                                    {
                                        "url": "http://hl7.org/fhir/StructureDefinition/humanname-own-prefix",
                                        "valueString": "VV"
                                    }
                                ]
                            },
                            "given": [
                                "Bénédicte"
                            ]
                        },
                        "telecom": [
                            {
                                "system": "phone",
                                "value": "+33 (237) 998327"
                            }
                        ],
                        "address": {
                            "use": "home",
                            "type": "both",
                            "line": [
                                "534 Erewhon St"
                            ],
                            "city": "PleasantVille",
                            "district": "Rainbow",
                            "state": "Vic",
                            "postalCode": "3999",
                            "period": {
                                "start": "1974-12-25"
                            }
                        },
                        "gender": "female",
                        "period": {
                            "start": "2012"
                        }
                    }
                ],
                "managingOrganization": {
                    "reference": "Organization/1"
                }
            },
            "search": {
                "extension": [
                    {
                        "url": "http://hl7.org/fhir/StructureDefinition/match-grade",
                        "valueCode": "certain"
                    }
                ],
                "mode": "match",
                "score": 1.0
            }
        }
    ]
}

附加:我发现了这个:

https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/org/hl7/fhir/r4/model/codesystems/MatchGrade.html

Patient 不允许使用该扩展名。它是使用 Bundle.entry.search 的上下文定义的。这不是患者本身的特征,而是基于一组特定搜索条件的搜索结果中特定条目的特征。同一个 Patient 实例在一次搜索中很可能是一个好的结果,而在不同的搜索中可能是一个糟糕的结果。所以要添加扩展,你必须将它添加到 'search' 对象上,而不是 patient.

好的。

在这里。主要对象是 Bundle 下的 inner/nested 个对象....因此我没有早点看到它们。 (示例:Bundle.BundleEntrySearchComponent)

// a java example with the import statements. #shocking!
//import org.hl7.fhir.r4.model.Bundle;
//import org.hl7.fhir.r4.model.CodeType;
//import org.hl7.fhir.r4.model.Extension;
//import org.hl7.fhir.r4.model.Patient;
//import org.hl7.fhir.r4.model.codesystems.MatchGrade;

//import java.util.Collections;


    Bundle innerBundle = new Bundle();
    innerBundle.setType(Bundle.BundleType.SEARCHSET);
    innerBundle.setTotal(1);

    Patient pat = new Patient();
    HumanName hn = new HumanName();
    hn.setFamily("Smith");
    p.setName(Collections.singletonList(hn));


        Bundle.BundleEntrySearchComponent besc = new Bundle.BundleEntrySearchComponent();
        besc.setScore(0.88);
        besc.setMode(Bundle.SearchEntryMode.MATCH);

        Bundle.BundleEntryComponent bec = new Bundle.BundleEntryComponent();

        Extension matchGradeExtension = besc.addExtension();
        matchGradeExtension.setUrl("http://hl7.org/fhir/StructureDefinition/match-grade");
        matchGradeExtension.setValue(new CodeType(MatchGrade.PROBABLE.toCode()));
        bec.setResource(pat);
        bec.setSearch(besc);

        innerBundle.setEntry(Collections.singletonList(bec));

Json 看起来像这样:

{
    "resourceType": "Bundle",
    "type": "searchset",
    "total": 1,
    "entry": [
        {
            "resource": {
                "resourceType": "Patient",
                "name": [
                    {
                        "family": "Smith"
                    }
                ]
            },
            "search": {
                "extension": [
                    {
                        "url": "http://hl7.org/fhir/StructureDefinition/match-grade",
                        "valueCode": "certain"
                    }
                ],
                "mode": "match",
                "score": 0.88
            }
        }
    ]
}