Skip to main content
Glama

create_encounter

Create a new patient encounter in athenahealth by specifying patient, department, date, and optional details like provider, type, and chief complaint.

Instructions

Create a new encounter for a patient

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patient_idYesPatient ID
department_idYesDepartment ID
provider_idNoProvider ID (optional)
encounter_dateYesEncounter date (YYYY-MM-DD)
encounter_typeNoType of encounter (optional)
chief_complaintNoChief complaint (optional)
appointment_idNoAssociated appointment ID (optional)

Implementation Reference

  • MCP tool handler that maps input arguments to encounter data, calls the AthenaHealth client to create the encounter, logs the action, and returns the result as JSON text content or error.
    async handleCreateEncounter(args: any) { try { const encounterData = { patientid: args.patient_id, departmentid: args.department_id, providerid: args.provider_id, encounterdate: args.encounter_date, encountertype: args.encounter_type, chiefcomplaint: args.chief_complaint, appointmentid: args.appointment_id, }; const encounter = await this.client.createEncounter(encounterData); auditLog('ENCOUNTER_CREATE', { patientId: args.patient_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 create encounter', message: error.message || 'Unknown error occurred', status: error.status || null, note: 'Encounter creation may not be available in the athenahealth preview/sandbox environment. This endpoint typically requires production API access.', }, null, 2), }, ], }; } }
  • Tool definition including name, description, and input schema for validation of create_encounter parameters.
    { name: 'create_encounter', description: 'Create a new encounter for a patient', inputSchema: { type: 'object', properties: { patient_id: { type: 'string', description: 'Patient ID' }, department_id: { type: 'string', description: 'Department ID' }, provider_id: { type: 'string', description: 'Provider ID (optional)' }, encounter_date: { type: 'string', description: 'Encounter date (YYYY-MM-DD)' }, encounter_type: { type: 'string', description: 'Type of encounter (optional)' }, chief_complaint: { type: 'string', description: 'Chief complaint (optional)' }, appointment_id: { type: 'string', description: 'Associated appointment ID (optional)' }, }, required: ['patient_id', 'department_id', 'encounter_date'], }, },
  • Dispatch case in MCP server request handler that routes create_encounter tool calls to the specific handler method.
    case 'create_encounter': return await this.toolHandlers.handleCreateEncounter(args);
  • Core service method that makes the actual POST request to AthenaHealth API to create the encounter using form-encoded data.
    async createEncounter(encounterData: { patientid: string; departmentid: string; providerid?: string; encounterdate: string; encountertype?: string; chiefcomplaint?: string; appointmentid?: 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`, { method: 'POST', data: formData.toString(), headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, } ); return response.data || response; }

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/ophydami/Athenahealth-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server