Skip to main content

Resource History

The Medplum backend stores every version of a resource, allowing you to easily track changes over time. Resource history can be viewed in the Medplum App or by accessing the /_history endpoint.

Accessing History in the Medplum App

To access a resource's history in the Medplum App, follow these steps:

  • Navigate to the resources page at
  • Select your desired resource. This will bring you to that resource's page.
  • Select the History tab from the array of tabs at the top of the page.

History Tab

Alternatively, you can navigate directly to this page at

The History tab shows every version of the selected resource, representing each time the resoruce was changed. Along with this, it will show when the change was made, as well as the user who made the update.

Selecting a version will bring you to the Diff page, which displays the differences between that version and the version directly previous to it.

Diff Page

You can also view the raw JSON of the selected version by clickin on the Raw tab.

Raw Page

Accessing the /_history Endpoint

The history of a resouce can also be viewed by accessing the /_history endpoint in the FHIR API. This endpoint allows you to retrieve the history of an individual resource, a resource type, or all resources in your system.

To access the /_history endpoint, make a GET request to the url of the desired resource or resource type.

The Medplum SDK also provides the readHistory helper function to access the /_history endpoint.

await medplum.readHistory('Patient', 'homer-simpson');

These requests return a Bundle resource with the different versions stored as an array of resources in the entry field.

Resource Creation Time

There is currently no support for directly accessing the time and date that a resource was initially created. To do this use the /_history endpoint to retrieve all versions and view the lastUpdated field of the original version. Note that the GraphQL endpoint does not currently have a spec for the history API.

Reverting Changes to a Resource

While there is no direct method to revert changes made to a resource, it can be easily done using the readHistory and readVersion helper functions provided by Medplum.

The readHistory function is used to get the entire history of the resource. You can then choose the version and use readVersion to return the complete details of that version of the resource. The current resource can then be updated to the historic details.

Example: Revert resource to a previous version
// Read the history, returning a bundle of history entries
const history = await medplum.readHistory('Patient', 'homer-simpson');

// Implement your own logic to get the historic version of the resource you want.
// You will need the versionId to use the readVersion function.
const versionId = getVersionId(history);

// readVersion will return the historic Patient resource
const version = await medplum.readVersion('Patient', 'homer-simpson', versionId);

// Pass the historic version to updateResource to revert to that version
await medplum.updateResource(version);

This method does not actually revert the resources to the previous version, but it creates a new entry in the resource's history with all of the same details as the historic version.