Search code examples
mongodbhl7-fhir

HL7-FHIR handle CRUD and history


Learning FHIR, I have this basic CRUD question, but I still need your help.

In order to keep history, are the Create, Update and Delete basically inserting a new record with special flag/status?

Just brainstorming, For update, should I insert a new record and update the previous record as 'not active'? For delete, should I update the previous record as 'deleted';

In order to keep history, should I wrap the resources as a sub-component in my document. For example,

{ _id: Object_id, _history: history_record, _metadata: other_metadata, fhir_resource: fhir_resource }

Is the above wrapper idea a common practice? Do you have any article and sample implementation about this?

Best regards, Autorun


Solution

  • Yep, you're pretty much spot on. The spec mentions this kind of design in a couple pf places, for example in delete:

    "For servers that maintain a version history, the delete interaction does not remove a resource's version history. From a version history respect, deleting a resource is the equivalent of creating a special kind of history entry that has no content and is marked as deleted."