updatePractitioner
Modify practitioner details in the Medplum MCP Server by providing the practitioner's unique ID and updated information, ensuring accurate healthcare data management.
Instructions
Updates an existing practitioner's information. Requires the practitioner's ID and the fields to update.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| active | No | Update active status. | |
| practitionerId | Yes | The unique ID of the practitioner to update. |
Implementation Reference
- src/tools/practitionerUtils.ts:163-188 (handler)Core handler function that fetches the existing Practitioner by ID, merges the provided partial updates (excluding resourceType and id), and performs the FHIR update using Medplum.export async function updatePractitioner(practitionerId: string, updates: UpdatePractitionerArgs): Promise<Practitioner> { await ensureAuthenticated(); if (!practitionerId) { throw new Error('Practitioner ID is required to update a practitioner.'); } if (!updates || Object.keys(updates).length === 0) { throw new Error('Updates object cannot be empty for updating a practitioner.'); } const existingPractitioner = await medplum.readResource('Practitioner', practitionerId); if (!existingPractitioner) { throw new Error(`Practitioner with ID ${practitionerId} not found.`); } const { resourceType, id, ...safeUpdates } = updates as any; const practitionerToUpdate: Practitioner = { ...existingPractitioner, ...safeUpdates, resourceType: 'Practitioner', id: practitionerId, }; return medplum.updateResource(practitionerToUpdate); }
- TypeScript interface defining the expected updates parameter, which is a partial Practitioner excluding resourceType and id.export interface UpdatePractitionerArgs extends Omit<Partial<Practitioner>, 'resourceType' | 'id'> { // Add simplified fields if LLM struggles with full FHIR structure }
- src/index.ts:246-263 (registration)MCP tool registration including name, description, and simplified input schema for listTools response.{ name: "updatePractitioner", description: "Updates an existing practitioner's information. Requires the practitioner's ID and the fields to update.", inputSchema: { type: "object", properties: { practitionerId: { type: "string", description: "The unique ID of the practitioner to update.", }, active: { type: "boolean", description: "Update active status.", }, }, required: ["practitionerId"], }, },
- src/index.ts:958-958 (registration)Mapping of tool name to handler function in the toolMapping object used by the CallToolRequest handler.updatePractitioner,
- src/index.ts:1023-1046 (registration)Shared execution logic in CallToolRequest handler that extracts practitionerId and updates from arguments and invokes the tool function for all update* tools.// Update tools that take ID and updates object const { patientId, practitionerId, organizationId, encounterId, observationId, medicationRequestId, medicationId, episodeOfCareId, conditionId, ...updates } = args; const id = patientId || practitionerId || organizationId || encounterId || observationId || medicationRequestId || medicationId || episodeOfCareId || conditionId; // Special handling for updateCondition if (toolName === 'updateCondition') { const updateArgs: any = { id }; if ((updates as any).clinicalStatus) { const key = ((updates as any).clinicalStatus as string).toUpperCase() as keyof typeof ConditionClinicalStatusCodes; updateArgs.clinicalStatus = { coding: [ConditionClinicalStatusCodes[key]] }; } if ((updates as any).verificationStatus) { const verStatusMap: { [key: string]: string } = { 'entered-in-error': 'ENTERED-IN-ERROR' }; const key = (verStatusMap[(updates as any).verificationStatus] || ((updates as any).verificationStatus as string).toUpperCase()) as keyof typeof ConditionVerificationStatusCodes; updateArgs.verificationStatus = { coding: [ConditionVerificationStatusCodes[key]] }; } if ((updates as any).onsetString !== undefined) { updateArgs.onsetString = (updates as any).onsetString; } result = await toolFunction(updateArgs); } else { result = await toolFunction(id, updates); } } else if (toolName === 'createCondition') {