update_encounter
Modify existing patient encounter records in athenahealth by updating chief complaints, diagnosis codes, procedure codes, or encounter status for accurate clinical documentation.
Instructions
Update an existing encounter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| encounter_id | Yes | Encounter ID | |
| chief_complaint | No | Chief complaint (optional) | |
| diagnosis_codes | No | Comma-separated ICD-10 diagnosis codes (optional) | |
| procedure_codes | No | Comma-separated CPT procedure codes (optional) | |
| status | No | Status: OPEN, CLOSED, SIGNED (optional) |
Implementation Reference
- src/handlers/tool-handlers.ts:593-633 (handler)The primary handler function executing the 'update_encounter' tool logic. Parses arguments, constructs update payload, invokes AthenaHealthClient, audits the action, and formats response as MCP content.async handleUpdateEncounter(args: any) { try { const encounterData = { chiefcomplaint: args.chief_complaint, diagnosiscodes: args.diagnosis_codes, procedurecodes: args.procedure_codes, status: args.status, }; const encounter = await this.client.updateEncounter(args.encounter_id, encounterData); auditLog('ENCOUNTER_UPDATE', { resourceId: args.encounter_id, result: 'success', resourceType: 'ENCOUNTER', }); return { content: [ { type: 'text' as const, text: JSON.stringify(encounter, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text' as const, text: JSON.stringify({ error: 'Failed to update encounter', message: error.message || 'Unknown error occurred', status: error.status || null, note: 'Encounter update may not be available in the athenahealth preview/sandbox environment.', }, null, 2), }, ], }; } }
- src/definitions/tools.ts:210-224 (schema)Tool schema defining the 'update_encounter' name, description, and input validation schema.{ name: 'update_encounter', description: 'Update an existing encounter', inputSchema: { type: 'object', properties: { encounter_id: { type: 'string', description: 'Encounter ID' }, chief_complaint: { type: 'string', description: 'Chief complaint (optional)' }, diagnosis_codes: { type: 'string', description: 'Comma-separated ICD-10 diagnosis codes (optional)' }, procedure_codes: { type: 'string', description: 'Comma-separated CPT procedure codes (optional)' }, status: { type: 'string', description: 'Status: OPEN, CLOSED, SIGNED (optional)' }, }, required: ['encounter_id'], }, },
- src/mcp-server.ts:215-216 (registration)Registration in MCP server's call_tool request handler switch statement, dispatching 'update_encounter' to the appropriate tool handler.case 'update_encounter': return await this.toolHandlers.handleUpdateEncounter(args);
- Supporting service method in EncounterService that performs the actual HTTP PUT request to Athenahealth API to update encounter details.async updateEncounter(encounterId: string, encounterData: { chiefcomplaint?: string; diagnosiscodes?: string; procedurecodes?: string; status?: string; }): Promise<Encounter> { const formData = new URLSearchParams(); Object.entries(encounterData).forEach(([key, value]) => { if (value !== undefined && value !== null) { formData.append(key, String(value)); } }); const response = await this.makeRequest<AthenaHealthResponse<Encounter>>( `${this.config.practice_id}/encounters/${encounterId}`, { method: 'PUT', data: formData.toString(), headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, } ); return response.data || response; }