Skip to main content
Glama

getEncounterById

Retrieve specific healthcare encounter details by providing its unique ID, enabling efficient access to patient interaction records within the Medplum FHIR server.

Instructions

Retrieves an encounter by its unique ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
encounterIdYesThe unique ID of the encounter to retrieve.

Implementation Reference

  • The core handler function that authenticates with Medplum, validates the encounter ID, reads the Encounter FHIR resource by ID, returns it or null if not found, handling not-found errors gracefully.
    export async function getEncounterById(args: { encounterId: string }): Promise<Encounter | null> { await ensureAuthenticated(); if (!args.encounterId) { throw new Error('Encounter ID is required to fetch an encounter.'); } try { const encounter = await medplum.readResource('Encounter', args.encounterId); return encounter; } catch (error: any) { if (error.outcome?.issue?.[0]?.code === 'not-found') { return null; } throw error; } }
  • JSON Schema definition for the input parameters of the getEncounterById tool, specifying the required 'encounterId' string parameter.
    name: 'getEncounterById', description: 'Retrieves a specific encounter resource by its unique ID.', input_schema: { type: 'object', properties: { encounterId: { type: 'string', description: 'The unique ID of the encounter to retrieve.', }, }, required: ['encounterId'], }, },
  • MCP-specific inputSchema for the getEncounterById tool used by the server, defining the required 'encounterId' parameter.
    name: "getEncounterById", description: "Retrieves an encounter by its unique ID.", inputSchema: { type: "object", properties: { encounterId: { type: "string", description: "The unique ID of the encounter to retrieve.", }, }, required: ["encounterId"], },
  • src/index.ts:32-37 (registration)
    Import statement registering the getEncounterById function from encounterUtils for use in the MCP server.
    import { createEncounter, getEncounterById, updateEncounter, searchEncounters, } from './tools/encounterUtils.js';
  • src/index.ts:965-965 (registration)
    Entry in the toolMapping object that maps the tool name 'getEncounterById' to its handler function for execution.
    getEncounterById,

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