create_appointment
Schedule patient appointments by specifying provider, department, date, time, and appointment type within the athenahealth system.
Instructions
Create a new appointment for a patient
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appointment_type | Yes | Appointment type | |
| date | Yes | Appointment date (YYYY-MM-DD) | |
| department_id | Yes | Department ID | |
| duration | No | Duration in minutes (optional) | |
| notes | No | Appointment notes (optional) | |
| patient_id | Yes | Patient ID | |
| provider_id | Yes | Provider ID | |
| reason | No | Reason for visit (optional) | |
| start_time | Yes | Start time (HH:MM) |
Input Schema (JSON Schema)
{
"properties": {
"appointment_type": {
"description": "Appointment type",
"type": "string"
},
"date": {
"description": "Appointment date (YYYY-MM-DD)",
"type": "string"
},
"department_id": {
"description": "Department ID",
"type": "string"
},
"duration": {
"description": "Duration in minutes (optional)",
"type": "string"
},
"notes": {
"description": "Appointment notes (optional)",
"type": "string"
},
"patient_id": {
"description": "Patient ID",
"type": "string"
},
"provider_id": {
"description": "Provider ID",
"type": "string"
},
"reason": {
"description": "Reason for visit (optional)",
"type": "string"
},
"start_time": {
"description": "Start time (HH:MM)",
"type": "string"
}
},
"required": [
"patient_id",
"provider_id",
"department_id",
"appointment_type",
"date",
"start_time"
],
"type": "object"
}
Implementation Reference
- src/handlers/tool-handlers.ts:148-192 (handler)The MCP tool handler that executes create_appointment: maps input args to API parameters, calls AthenaHealthClient.createAppointment, logs audit, returns JSON response or error.async handleCreateAppointment(args: any) { try { const appointment = await this.client.createAppointment({ patientid: args.patient_id, providerid: args.provider_id, departmentid: args.department_id, appointmenttype: args.appointment_type, date: args.date, starttime: args.start_time, duration: args.duration, reasonforvisit: args.reason, appointmentnotes: args.notes, }); auditLog('APPOINTMENT_CREATE', { patientId: args.patient_id, result: 'success', resourceType: 'APPOINTMENT', }); return { content: [ { type: 'text' as const, text: JSON.stringify(appointment, null, 2), }, ], }; } catch (error: any) { console.error('Create appointment error:', error); return { content: [ { type: 'text' as const, text: JSON.stringify({ error: 'Failed to create appointment', message: error.message || 'Unknown error occurred', details: error.details || error.message, note: 'This endpoint may not be available in the preview/sandbox environment or may require specific appointment types', }, null, 2), }, ], }; } }
- src/definitions/tools.ts:56-74 (schema)Tool definition including name, description, and input schema/JSON validation for create_appointment.{ name: 'create_appointment', description: 'Create a new appointment for a patient', inputSchema: { type: 'object', properties: { patient_id: { type: 'string', description: 'Patient ID' }, provider_id: { type: 'string', description: 'Provider ID' }, department_id: { type: 'string', description: 'Department ID' }, appointment_type: { type: 'string', description: 'Appointment type' }, date: { type: 'string', description: 'Appointment date (YYYY-MM-DD)' }, start_time: { type: 'string', description: 'Start time (HH:MM)' }, duration: { type: 'string', description: 'Duration in minutes (optional)' }, reason: { type: 'string', description: 'Reason for visit (optional)' }, notes: { type: 'string', description: 'Appointment notes (optional)' }, }, required: ['patient_id', 'provider_id', 'department_id', 'appointment_type', 'date', 'start_time'], }, },
- src/mcp-server.ts:185-186 (registration)MCP server switch case that registers the create_appointment tool and routes calls to the handler.case 'create_appointment': return await this.toolHandlers.handleCreateAppointment(args);
- Core service method that makes the actual POST request to AthenaHealth API /appointments endpoint to create the appointment.async createAppointment(appointment: { patientid: string; providerid: string; departmentid: string; appointmenttype: string; date: string; starttime: string; duration?: string; reasonforvisit?: string; appointmentnotes?: string; }): Promise<Appointment> { const formData = new URLSearchParams(); Object.entries(appointment).forEach(([key, value]) => { if (value !== undefined && value !== null) { formData.append(key, String(value)); } }); const response = await this.makeRequest<AthenaHealthResponse<Appointment>>( `${this.config.practice_id}/appointments`, { method: 'POST', data: formData.toString(), headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, } ); return response.data; } }