Search code examples
hl7-fhirhapi-fhir

Operation failure doing conditional delete against Fhir server with large number of patients


I'm trying to perform a conditional delete what involves many records. When attempting to delete patients that meet the criteria, I receive the following exception when using the .NET FHIR client (Hl7.Fhir.Rest). I have a feeling like may be due to some default batch size but I don't know how I would alter the IFhirClient to just delete anything it finds.

Failed to DELETE resource with match URL "Patient?identifier= because this search matched 450 resources. 412 - PreCondition Failed

_fhirClient.Delete("Patient", criteria);

Solution

  • This is not related to the FhirClient, but to the implementation at the side of the server. See the FHIR Specification at http://hl7.org/fhir/R4/http.html#3.1.0.7.1:

    Multiple matches: A server may choose to delete all the matching resources, or it may choose to return a 412 Precondition Failed error indicating the client's criteria were not selective enough.

    E.g. Vonk FHIR Server has a setting for the maximum number of deletes that can be performed at once. The hapi-fhir tag on your question suggests that you need to consult the hapi documentation for a similar setting.