Skip to main content
Glama

getConditionById

Retrieve a specific condition resource using its unique ID within the Medplum MCP Server. Simplifies access to healthcare data for precise queries and management.

Instructions

Retrieves a condition resource by its unique ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conditionIdYesThe unique ID of the condition to retrieve.

Implementation Reference

  • The main handler function that retrieves a Condition FHIR resource by its ID using the Medplum client. Handles authentication, reads the resource, logs success, returns null if not found, and OperationOutcome on errors.
    export async function getConditionById( conditionId: string, client?: MedplumClient, ): Promise<Condition | null | OperationOutcome> { const medplumClient = client || medplum; await ensureAuthenticated(); try { if (!conditionId) { throw new Error('Condition ID is required.'); } const condition = (await medplumClient.readResource( 'Condition', conditionId, )) as Condition | null; if (condition) { console.log('Condition retrieved:', condition.id); } return condition; } catch (error: any) { if (error.outcome && error.outcome.issue && error.outcome.issue[0]?.code === 'not-found') { console.log(`Condition with ID "${conditionId}" not found.`); return null; } console.error(`Error retrieving Condition with ID "${conditionId}":`, error); const outcome: OperationOutcome = { resourceType: 'OperationOutcome', issue: [ { severity: 'error', code: 'exception', diagnostics: `Error retrieving Condition: ${error.message || 'Unknown error'}`, }, ], }; if (error.outcome) { console.error('Server OperationOutcome:', JSON.stringify(error.outcome, null, 2)); return error.outcome as OperationOutcome; } return outcome; } }
  • MCP tool schema for getConditionById defining the input as an object with required 'conditionId' string.
    name: "getConditionById", description: "Retrieves a condition resource by its unique ID.", inputSchema: { type: "object", properties: { conditionId: { type: "string", description: "The unique ID of the condition to retrieve.", }, }, required: ["conditionId"], }, },
  • src/index.ts:950-988 (registration)
    Registration of the getConditionById function in the toolMapping object used by the MCP server's CallToolRequest handler to dispatch tool calls.
    const toolMapping: Record<string, (...args: any[]) => Promise<any>> = { createPatient, getPatientById, updatePatient, searchPatients, searchPractitionersByName, createPractitioner, getPractitionerById, updatePractitioner, searchPractitioners, createOrganization, getOrganizationById, updateOrganization, searchOrganizations, createEncounter, getEncounterById, updateEncounter, searchEncounters, createObservation, getObservationById, updateObservation, searchObservations, createMedicationRequest, getMedicationRequestById, updateMedicationRequest, searchMedicationRequests, createMedication, getMedicationById, searchMedications, createEpisodeOfCare, getEpisodeOfCareById, updateEpisodeOfCare, searchEpisodesOfCare, createCondition, getConditionById, updateCondition, searchConditions, generalFhirSearch, };
  • src/index.ts:62-68 (registration)
    Import statement bringing the getConditionById handler into the main index.ts for use in tool mapping.
    createCondition, getConditionById, updateCondition, searchConditions, ConditionClinicalStatusCodes, ConditionVerificationStatusCodes, } from './tools/conditionUtils.js';

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