getMedicationRequestById
Retrieve specific medication request details using its unique ID on the Medplum MCP Server. Provides quick access to essential healthcare data for efficient management.
Instructions
Retrieves a medication request by its unique ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| medicationRequestId | Yes | The unique ID of the medication request to retrieve. |
Implementation Reference
- The main handler function that authenticates, validates the medicationRequestId, and retrieves the MedicationRequest resource using medplum.readResource, returning null if not found./** * Retrieves a MedicationRequest by its ID. * @param args - The arguments containing the medication request ID. * @returns The MedicationRequest resource, or null if not found. */ export async function getMedicationRequestById(args: GetMedicationRequestByIdArgs): Promise<MedicationRequest | null> { await ensureAuthenticated(); if (!args.medicationRequestId) { throw new Error('MedicationRequest ID is required to fetch a medication request.'); } try { return await medplum.readResource('MedicationRequest', args.medicationRequestId); } catch (error: any) { if (error.outcome?.issue?.[0]?.code === 'not-found') { return null; } throw error; } }
- TypeScript interface defining the input parameters for the getMedicationRequestById handler.// Interface for retrieving a MedicationRequest by ID export interface GetMedicationRequestByIdArgs { medicationRequestId: string; }
- src/index.ts:595-607 (schema)MCP tool schema definition including name, description, and input schema for validation in the MCP server.name: "getMedicationRequestById", description: "Retrieves a medication request by its unique ID.", inputSchema: { type: "object", properties: { medicationRequestId: { type: "string", description: "The unique ID of the medication request to retrieve.", }, }, required: ["medicationRequestId"], }, },
- src/index.ts:973-973 (registration)Registration of the getMedicationRequestById handler function in the toolMapping object used by the MCP server's CallToolRequest handler.getMedicationRequestById,
- src/index.ts:45-48 (registration)Import statement that brings the getMedicationRequestById function into the index module for registration.createMedicationRequest, getMedicationRequestById, updateMedicationRequest, searchMedicationRequests,