Skip to main content
Glama

create_prescription

Create new patient prescriptions with medication details, dosage instructions, and pharmacy information through clinical workflow integration.

Instructions

Create a new prescription for a patient

Input Schema

NameRequiredDescriptionDefault
days_supplyYesDays supply
dosageYesDosage (e.g., "10mg")
frequencyYesFrequency (e.g., "twice daily")
medication_nameYesMedication name
notesNoAdditional notes (optional)
patient_idYesPatient ID
pharmacy_idNoPharmacy ID (optional)
quantityYesQuantity to dispense
refillsYesNumber of refills
routeYesRoute of administration (e.g., "oral")

Input Schema (JSON Schema)

{ "properties": { "days_supply": { "description": "Days supply", "type": "string" }, "dosage": { "description": "Dosage (e.g., \"10mg\")", "type": "string" }, "frequency": { "description": "Frequency (e.g., \"twice daily\")", "type": "string" }, "medication_name": { "description": "Medication name", "type": "string" }, "notes": { "description": "Additional notes (optional)", "type": "string" }, "patient_id": { "description": "Patient ID", "type": "string" }, "pharmacy_id": { "description": "Pharmacy ID (optional)", "type": "string" }, "quantity": { "description": "Quantity to dispense", "type": "string" }, "refills": { "description": "Number of refills", "type": "string" }, "route": { "description": "Route of administration (e.g., \"oral\")", "type": "string" } }, "required": [ "patient_id", "medication_name", "dosage", "route", "frequency", "quantity", "refills", "days_supply" ], "type": "object" }

Implementation Reference

  • The main MCP tool handler for 'create_prescription' that destructures arguments, maps them to service call parameters, invokes the client.createPrescription, audits the action, and returns a standardized MCP response with the prescription data or error details.
    async handleCreatePrescription(args: any) { try { const { patient_id, ...prescriptionData } = args; const prescription = await this.client.createPrescription(patient_id, { medicationname: prescriptionData.medication_name, dosage: prescriptionData.dosage, route: prescriptionData.route, frequency: prescriptionData.frequency, quantity: prescriptionData.quantity, refills: prescriptionData.refills, daysupply: prescriptionData.days_supply, pharmacyid: prescriptionData.pharmacy_id, notes: prescriptionData.notes, }); auditLog('PRESCRIPTION_CREATE', { patientId: patient_id, result: 'success', resourceType: 'PRESCRIPTION', }); return { content: [ { type: 'text' as const, text: JSON.stringify(prescription, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text' as const, text: JSON.stringify({ error: 'Failed to create prescription', message: error.message || 'Unknown error occurred', status: error.status || null, note: 'The prescription endpoint is not available in the athenahealth preview/sandbox environment. This endpoint requires a production API account.', }, null, 2), }, ], }; } }
  • The tool call request handler in the MCP server that routes 'create_prescription' calls to the corresponding handler method via a switch statement on the tool name.
    switch (name) { case 'search_patients': return await this.toolHandlers.handleSearchPatients(args); case 'check_drug_interactions': return await this.toolHandlers.handleCheckDrugInteractions(args); case 'create_prescription': return await this.toolHandlers.handleCreatePrescription(args); case 'create_appointment': return await this.toolHandlers.handleCreateAppointment(args); case 'acknowledge_alert': return await this.toolHandlers.handleAcknowledgeAlert(args); case 'get_clinical_summary': return await this.toolHandlers.handleGetClinicalSummary(args); case 'list_departments': return await this.toolHandlers.handleListDepartments(args); case 'list_providers': return await this.toolHandlers.handleListProviders(args); case 'check_appointment_availability': return await this.toolHandlers.handleCheckAppointmentAvailability(args); case 'create_patient': return await this.toolHandlers.handleCreatePatient(args); case 'get_patient_encounters': return await this.toolHandlers.handleGetPatientEncounters(args); case 'get_encounter': return await this.toolHandlers.handleGetEncounter(args); case 'create_encounter': return await this.toolHandlers.handleCreateEncounter(args); case 'update_encounter': return await this.toolHandlers.handleUpdateEncounter(args); default: throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
  • Tool definition including name, description, and detailed input schema with properties and required fields for the create_prescription tool.
    { name: 'create_prescription', description: 'Create a new prescription for a patient', inputSchema: { type: 'object', properties: { patient_id: { type: 'string', description: 'Patient ID' }, medication_name: { type: 'string', description: 'Medication name' }, dosage: { type: 'string', description: 'Dosage (e.g., "10mg")' }, route: { type: 'string', description: 'Route of administration (e.g., "oral")' }, frequency: { type: 'string', description: 'Frequency (e.g., "twice daily")' }, quantity: { type: 'string', description: 'Quantity to dispense' }, refills: { type: 'string', description: 'Number of refills' }, days_supply: { type: 'string', description: 'Days supply' }, pharmacy_id: { type: 'string', description: 'Pharmacy ID (optional)' }, notes: { type: 'string', description: 'Additional notes (optional)' }, }, required: ['patient_id', 'medication_name', 'dosage', 'route', 'frequency', 'quantity', 'refills', 'days_supply'], }, },
  • Supporting service method that handles the actual HTTP POST request to AthenaHealth's prescription creation endpoint, formatting parameters as URL-encoded form data.
    async createPrescription(patientId: string, prescription: { medicationname: string; dosage: string; route: string; frequency: string; quantity: string; refills: string; daysupply: string; pharmacyid?: string; notes?: string; }): Promise<Prescription> { const formData = new URLSearchParams(); Object.entries(prescription).forEach(([key, value]) => { if (value !== undefined && value !== null) { formData.append(key, String(value)); } }); const response = await this.makeRequest<AthenaHealthResponse<Prescription>>( `${this.config.practice_id}/patients/${patientId}/prescriptions`, { method: 'POST', data: formData.toString(), headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, } ); return response.data; }

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