Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FHIR Patch replace operation fails when replacing elements in a multi cardinality elements in FHIR resources when using FHIR patch (application/fhir) syntax #6656

Open
mrdnctrk opened this issue Jan 27, 2025 · 0 comments

Comments

@mrdnctrk
Copy link
Collaborator

Describe the bug
FHIR Patch with replace operation that tries to replace an child element of a high cardinality field fails.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Patient Resource that contains a high cardinality element such as identifier
{
    "resourceType": "Patient",
    "identifier": [
    { 
       "system": "sys1",
       "value": "val1"
    },
    { 
       "system": "sys2",
       "value": "val2"
    }
   ]
}
  1. Try to Patch the Patient by replacing the second identifier:

PATCH /Patient/{patient-id}
-Content-Type: application/fhir

{
    "resourceType": "Parameters",
    "parameter": [
        {
            "name": "operation",
            "part": [
                {
                    "name": "type",
                    "valueCode": "replace"
                },
                {
                    "name": "path",
                    "valueString": "Patient.identifier[1]"
                },
                {
                    "name": "value",
                    "valueIdentifier": { 
                        "system": "sys3", 
                        "value": "value3"
                    }
                }
            ]
        }
    ]
}
  1. See 500 Response with the response:
{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "error",
            "code": "processing",
            "diagnostics": "HAPI-0389: Failed to call access method: java.lang.NullPointerException: Cannot invoke \"ca.uhn.fhir.context.BaseRuntimeChildDefinition.getValidChildNames()\" because \"childDef\" is null"
        }
    ]
} 

Expected behavior
The patch operation should succeed.

The same problem exists if path contain a where filter instead of index:

                {
                    "name": "path",
                    "valueString": "Patient.identifier.where(system='sys2')"
                }

Note: A similar operation succeeds when using json patch syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant