Skip to main content
Glama

get_patient_encounters

Retrieve patient encounter records from athenahealth to review medical visits, treatments, and clinical history for care coordination and documentation.

Instructions

Get all encounters for a patient

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patient_idYesPatient ID
department_idNoFilter by department ID (optional)
start_dateNoStart date filter (YYYY-MM-DD) (optional)
end_dateNoEnd date filter (YYYY-MM-DD) (optional)
statusNoFilter by status: OPEN, CLOSED, SIGNED (optional)

Implementation Reference

  • Tool schema definition with input validation schema for get_patient_encounters
    {
      name: 'get_patient_encounters',
      description: 'Get all encounters for a patient',
      inputSchema: {
        type: 'object',
        properties: {
          patient_id: { type: 'string', description: 'Patient ID' },
          department_id: { type: 'string', description: 'Filter by department ID (optional)' },
          start_date: { type: 'string', description: 'Start date filter (YYYY-MM-DD) (optional)' },
          end_date: { type: 'string', description: 'End date filter (YYYY-MM-DD) (optional)' },
          status: { type: 'string', description: 'Filter by status: OPEN, CLOSED, SIGNED (optional)' },
        },
        required: ['patient_id'],
      },
    },
  • Registration and dispatch of get_patient_encounters tool call to the handler in MCP server
    case 'get_patient_encounters':
      return await this.toolHandlers.handleGetPatientEncounters(args);
  • Primary handler function executing the tool: extracts parameters, calls AthenaHealthClient, audits access, returns JSON response or error
    async handleGetPatientEncounters(args: any) {
      try {
        const { patient_id, department_id, start_date, end_date, status } = args;
    
        const encounters = await this.client.getPatientEncounters(patient_id, {
          departmentid: department_id,
          startdate: start_date,
          enddate: end_date,
          status,
        });
    
        auditLog('ENCOUNTER_ACCESS', {
          patientId: patient_id,
          result: 'success',
          resourceType: 'ENCOUNTER',
        });
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(encounters, null, 2),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify({
                error: 'Failed to get patient encounters',
                message: error.message || 'Unknown error occurred',
                status: error.status || null,
                note: 'Encounter endpoints may not be available in the athenahealth preview/sandbox environment.',
              }, null, 2),
            },
          ],
        };
      }
    }
  • Core service implementation making the HTTP GET request to Athenahealth API for patient encounters and handling response normalization
    async getPatientEncounters(patientId: string, params?: {
      departmentid?: string;
      startdate?: string;
      enddate?: string;
      status?: string;
    }): Promise<Encounter[]> {
      const response = await this.makeRequest<any>(
        `${this.config.practice_id}/patients/${patientId}/encounters`,
        {
          method: 'GET',
          params,
        }
      );
    
      // Handle different response structures
      if (response.encounters && Array.isArray(response.encounters)) {
        return response.encounters;
      }
      if (Array.isArray(response)) {
        return response;
      }
      if (response.data && Array.isArray(response.data)) {
        return response.data;
      }
      return [];
    }
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. It states it 'gets' data (implying read-only), but doesn't address permissions needed, rate limits, pagination, error conditions, or what 'all encounters' means in practice (e.g., historical limits). For a tool with 5 parameters and no annotation coverage, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is a single, clear sentence that efficiently conveys the core function. It's appropriately sized for a straightforward retrieval tool and front-loads the essential information. There's no wasted verbiage, though it could benefit from slightly more detail given the lack of annotations.

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 tool with 5 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what constitutes an 'encounter', the format or structure of returned data, pagination behavior, error handling, or authentication requirements. The description alone leaves too many operational questions unanswered for effective agent use.

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?

Schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional parameter semantics beyond implying filtering capability through 'for a patient'. It doesn't explain relationships between parameters (e.g., that department_id, dates, and status are filters applied to the patient's encounters) or provide usage examples. Baseline 3 is appropriate when 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 action ('Get') and resource ('all encounters for a patient'), making the purpose immediately understandable. It distinguishes from siblings like 'get_encounter' (singular) and 'create_encounter', but doesn't explicitly differentiate from 'get_clinical_summary' which might include encounter data. The description is specific but could be more precise about scope.

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. It doesn't mention when to choose this over 'get_encounter' (singular), 'get_clinical_summary', or 'search_patients' which might retrieve similar data. There are no prerequisites, exclusions, or context about appropriate use cases beyond the basic function.

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