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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Create' implies a write operation, it doesn't mention permission requirements, whether the encounter becomes immediately active, what happens on duplicate creation, or what the response contains. For a mutation tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a tool with good schema documentation and gets straight to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 7 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what constitutes a successful creation, what data is returned, or how this tool relates to other encounter management tools in the sibling list. The schema handles parameter documentation, but behavioral context is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional parameter information beyond what's already in the schema, maintaining the baseline score of 3 where the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create') and resource ('new encounter for a patient'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'create_appointment' or 'create_patient' by specifying what makes an encounter distinct in this medical context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'create_appointment' or 'update_encounter', nor does it mention prerequisites such as needing an existing patient record. It simply states what the tool does without contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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