Skip to main content
Glama

updatePatient

Update an existing patient's details such as name, birth date, and gender using their unique ID. Designed for Medplum MCP Server to manage FHIR healthcare data.

Instructions

Updates an existing patient's information. Requires the patient's ID and the fields to update.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
birthDateNoNew birth date in YYYY-MM-DD format.
firstNameNoNew first name for the patient.
genderNoNew gender (male, female, other, unknown).
lastNameNoNew last name for the patient.
patientIdYesThe unique ID of the patient to update.

Implementation Reference

  • The core handler function that authenticates, fetches the existing Patient, merges the provided updates (excluding resourceType and id), and updates the resource via Medplum.
    export async function updatePatient(patientId: string, updates: Omit<Partial<Patient>, 'resourceType' | 'id'>): Promise<Patient> { await ensureAuthenticated(); if (!patientId) { throw new Error('Patient ID is required to update a patient.'); } if (!updates || Object.keys(updates).length === 0) { throw new Error('Updates object cannot be empty for updating a patient.'); } const existingPatient = await medplum.readResource('Patient', patientId); if (!existingPatient) { throw new Error(`Patient with ID ${patientId} not found.`); } const { resourceType, id, ...safeUpdates } = updates as any; const patientToUpdate: Patient = { ...(existingPatient as Patient), ...(safeUpdates as Partial<Patient>), resourceType: 'Patient', id: patientId, }; return medplum.updateResource(patientToUpdate); }
  • MCP tool schema definition specifying the input structure for the updatePatient tool, including patientId as required and common updatable fields like name, birthDate, gender.
    name: "updatePatient", description: "Updates an existing patient's information. Requires the patient's ID and the fields to update.", inputSchema: { type: "object", properties: { patientId: { type: "string", description: "The unique ID of the patient to update.", }, firstName: { type: "string", description: "New first name for the patient.", }, lastName: { type: "string", description: "New last name for the patient.", }, birthDate: { type: "string", description: "New birth date in YYYY-MM-DD format.", }, gender: { type: "string", description: "New gender (male, female, other, unknown).", enum: ["male", "female", "other", "unknown"], }, }, required: ["patientId"], }, },
  • src/index.ts:953-953 (registration)
    Registration of the updatePatient handler function in the toolMapping object used by the MCP server to dispatch tool calls.
    updatePatient,
  • src/index.ts:29-29 (registration)
    Import of the updatePatient function from patientUtils.ts into the main index.ts for use in tool handling.
    updatePatient,
  • Auxiliary schema definition for updatePatient, likely used for LLM prompting or documentation, with more detailed description of the updates object.
    { name: 'updatePatient', description: 'Updates an existing patient resource. Requires the patient ID and an object containing the fields to update.', input_schema: { type: 'object', properties: { patientId: { type: 'string', description: 'The unique ID of the patient to update.', }, updates: { type: 'object', description: "An object containing the patient fields to update. For example, { \"birthDate\": \"1990-01-01\", \"gender\": \"female\" }. Refer to the Patient FHIR resource for possible fields. For updating name, provide the full name structure, e.g., { name: [{ given: [\'NewFirstName\', \'NewMiddle\'], family: \'ExistingLastName\' }] }.", // We don't define exhaustive properties for 'updates' here as it's a partial Patient. // The description should guide the LLM. }, }, required: ['patientId', 'updates'], }, },

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/rkirkendall/medplum-mcp'

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