getEpisodeOfCareById
Retrieve healthcare episode details using a unique ID to access and manage patient care data efficiently on Medplum MCP Server.
Instructions
Retrieves an episode of care by its unique ID.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"episodeOfCareId": "<episodeOfCareId>"
},
"name": "getEpisodeOfCareById"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| episodeOfCareId | Yes | The unique ID of the episode of care to retrieve. |
Implementation Reference
- src/tools/episodeOfCareUtils.ts:125-161 (handler)Core handler function that implements the tool logic: reads EpisodeOfCare resource by ID from Medplum, handles not-found as null, errors as OperationOutcome.
export async function getEpisodeOfCareById( episodeOfCareId: string, client?: MedplumClient, ): Promise<EpisodeOfCare | null | OperationOutcome> { const medplumClient = client || medplum; await ensureAuthenticated(); try { if (!episodeOfCareId) { throw new Error('EpisodeOfCare ID is required.'); } const result = (await medplumClient.readResource( 'EpisodeOfCare', episodeOfCareId, )) as EpisodeOfCare | null; console.log(result ? 'EpisodeOfCare retrieved:' : 'EpisodeOfCare not found:', episodeOfCareId); return result; } catch (error: any) { if (error.outcome && error.outcome.issue && error.outcome.issue[0]?.code === 'not-found') { console.log(`EpisodeOfCare with ID "${episodeOfCareId}" not found.`); return null; } const outcome: OperationOutcome = { resourceType: 'OperationOutcome', issue: [ { severity: 'error', code: 'exception', diagnostics: `Error retrieving EpisodeOfCare: ${error.message || 'Unknown error'}`, }, ], }; if (error.outcome) { return error.outcome as OperationOutcome; } return outcome; } } - src/index.ts:738-750 (schema)Input schema definition for the tool used in MCP server tool list.
name: "getEpisodeOfCareById", description: "Retrieves an episode of care by its unique ID.", inputSchema: { type: "object", properties: { episodeOfCareId: { type: "string", description: "The unique ID of the episode of care to retrieve.", }, }, required: ["episodeOfCareId"], }, }, - src/index.ts:980-980 (registration)Maps the tool name to the handler function in the tool execution dispatcher.
getEpisodeOfCareById, - src/index.ts:56-60 (registration)Imports the handler function for use in the MCP server.
createEpisodeOfCare, getEpisodeOfCareById, updateEpisodeOfCare, searchEpisodesOfCare, } from './tools/episodeOfCareUtils.js'; - src/tools/toolSchemas.ts:608-617 (schema)Legacy or additional schema definition for the tool (possibly not actively used).
name: 'getEpisodeOfCareById', description: 'Retrieves a specific EpisodeOfCare resource by its ID.', input_schema: { type: 'object', properties: { episodeOfCareId: { type: 'string', description: 'The unique ID of the EpisodeOfCare to retrieve.' } }, required: ['episodeOfCareId'] } },