Skip to main content
Glama
resource-history.ts1.48 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 // start-block imports import { MedplumClient } from '@medplum/core'; import type { Bundle } from '@medplum/fhirtypes'; // end-block imports const medplum = new MedplumClient(); // start-block accessHistoryTs await medplum.readHistory('Patient', 'homer-simpson'); // end-block accessHistoryTs /* // start-block accessHistoryCli medplum get 'Patient/homer-simpson/_history' // end-block accessHistoryCli // start-block accessHistoryCurl curl 'https://api.medplum.com/fhir/R4/Patient/homer-simpson/_history' \ -H 'authorization: Bearer $ACCESS_TOKEN' \ -H 'content-type: application/fhir+json' \ // end-block accessHistoryCurl */ // start-block revertChanges // 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); // end-block revertChanges function getVersionId(history: Bundle): string { console.log(history); return 'versionId'; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server