Search code examples
hl7-fhir

How to indicate resource deletions in a FHIR response without sending the full resource history?


This is a follow-up to this question about subscription error recovery without the $events operation. The premise of that question is that in a sufficiently busy system, the cost of indefinitely accumulating events for failed subscriptions would be too high, so there should be another way to recover from errors - a way that does not rely on such events being stored.

Instead, it should provide a list of changes compared to the state of the system at an earlier point in time (specified by the client based on the last successfully delivered notification). This list of changes would include resource creation, updates and deletions, but only the latest state of each resource (no intermediate versions).

However, it is unclear what Bundle type would be feasible for returning such a set of changes:

  • Items in bundles of type searchset must always include a resource and can not include a request.method, so it is not possible to indicate deleted resources.
  • Bundles of type history can include deletions but their items should not be resources but versions of resources, so omitting intermediate versions and putting versionless resources (reflecting their latest states) in them would probably not be FHIR-compliant.
  • Bundles of types subscription-notification, transaction and batch are for entirely different purposes, so their usage would be confusing and not FHIR-compliant.

Solution

  • Most of the use cases I have heard of in the past actually want the intermediate versions because some of those state transitions might be meaningful. The system-level or type-level _history method is intended for exactly this case - retrieving all changes since a given timestamp, in the form of a history bundle (likely with a lot of pagination, considering how many changes could have accumulated).

    However, if the intermediate resources are omitted from the result set by some custom operation, a history bundle containing only the most recent versions is only a little bit different from a searchset. I don't see having "versionless" resources as significantly different - is there a specific data element that would be problematic? A custom operation returning a history bundle does not create a conformance problem.