FHIR Chat · FHIRPath Patch on uninitialized object/list · fhirpath

Stream: fhirpath

Topic: FHIRPath Patch on uninitialized object/list


view this post on Zulip Mikael Weaver (Dec 06 2021 at 20:02):

Hello! I'm working on a FHIRPath Patch implementation for our FHIR server. I've run into two related use cases where data needs to be added to a resource, but the target object or list isn't initialized. The specification page doesn't address proper behavior for this scenario, so my assumption is that the behavior is left up to the implementer. Is that correct? Also, any input on what the server should do for these scenarios?

JSONPatch specifically calls this out in RFC 6902 4.1. The spec says "However, the object itself or an array containing it does need to exist, and it remains an error for that not to be the case".

Below are a couple of sample use cases. Thanks for the help!

Use Case 1: Adding a value to a nested object that doesn't exist.
The Patient has an identifier defined without a period. The user wants to be able to expire the identifier. Should the server initialize the period object that doesn't exist on the object or return an error?

{
    "resourceType": "Patient",
    "identifier": [
        {
            "use": "official",
            "value": "123"
        }
    ]
}
{
    "resourceType": "Parameters",
    "parameter": [
        {
            "name": "operation",
            "part": [
                {
                    "name": "type",
                    "valueCode": "add"
                },
                {
                    "name": "path",
                    "valueString": "Patient.identifier.where(use = 'official').period"
                },
                {
                    "name": "name",
                    "valueString": "end"
                },
                {
                    "name": "value",
                    "valueDate": "2021-12-01"
                }
            ]
        }
    ]
}

Use Case 2: Inserting a value into a list that doesn't exist.
A Patient resource exists without any identifiers. The user wants to add an identifier to the patient. Should the server initialize the identifier list or return an error?

{
    "resourceType": "Patient"
}
{
    "resourceType": "Parameters",
    "parameter": [
        {
            "name": "operation",
            "part": [
                {
                    "name": "type",
                    "valueCode": "add"
                },
                {
                    "name": "path",
                    "valueString": "Patient"
                },
                {
                    "name": "name",
                    "valueString": "identifier"
                },
                {
                    "name": "value",
                    "valueIdentifier": {
                        "system": "http://example.org",
                        "value": "value 3"
                    }
                }
            ]
        }
    ]
}

view this post on Zulip Mikael Weaver (Dec 09 2021 at 23:54):

See the orig thread for the answer


Last updated: Apr 12 2022 at 19:14 UTC