Skip to main content
Glama

create_patient

Register new patients in the athenahealth system by providing required information like name, date of birth, sex, and department ID to establish medical records.

Instructions

Register a new patient in the system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstnameYesPatient first name
lastnameYesPatient last name
dobYesDate of birth (MM/DD/YYYY or YYYY-MM-DD)
sexYesSex (M or F)
department_idYesPrimary department ID
emailNoEmail address (optional)
mobile_phoneNoMobile phone number (optional)
home_phoneNoHome phone number (optional)
address1NoStreet address (optional)
cityNoCity (optional)
stateNoState (optional)
zipNoZIP code (optional)
guarantor_firstnameNoGuarantor first name (optional)
guarantor_lastnameNoGuarantor last name (optional)
guarantor_dobNoGuarantor date of birth (optional)
guarantor_relationshipNoRelationship to patient: 1=Self, 2=Spouse, 3=Child, 4=Other (optional)

Implementation Reference

  • The primary handler function for the 'create_patient' tool. It maps tool arguments to patient data structure, removes undefined fields, invokes the Athenahealth client to create the patient, performs audit logging on success, and returns the patient object or a detailed error response in MCP content format.
    async handleCreatePatient(args: any) {
      try {
        console.error('handleCreatePatient received args:', JSON.stringify(args, null, 2));
    
        const patientData = {
          firstname: args.firstname,
          lastname: args.lastname,
          dob: args.dob,
          sex: args.sex,
          departmentid: args.department_id,
          email: args.email,
          mobilephone: args.mobile_phone,
          homephone: args.home_phone,
          address1: args.address1,
          city: args.city,
          state: args.state,
          zip: args.zip,
          guarantorfirstname: args.guarantor_firstname,
          guarantorlastname: args.guarantor_lastname,
          guarantordob: args.guarantor_dob,
          guarantorrelationshiptopatient: args.guarantor_relationship,
        };
    
        console.error('patientData before cleanup:', JSON.stringify(patientData, null, 2));
    
        // Remove undefined fields
        Object.keys(patientData).forEach(key => {
          if (patientData[key as keyof typeof patientData] === undefined) {
            delete patientData[key as keyof typeof patientData];
          }
        });
    
        console.error('patientData after cleanup:', JSON.stringify(patientData, null, 2));
    
        const patient = await this.client.createPatient(patientData);
    
        auditLog('PATIENT_CREATE', {
          result: 'success',
          resourceType: 'PATIENT',
        });
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(patient, null, 2),
            },
          ],
        };
      } catch (error: any) {
        console.error('Create patient error:', error);
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify({
                error: 'Failed to create patient',
                message: error.message || 'Unknown error occurred',
                error_code: error.error || null,
                detailcode: error.detailcode || null,
                api_details: error.details || null,
                api_response: error.response || null,
                status_code: error.status || null,
                note: 'Check the api_response field for specific validation errors from athenahealth',
              }, null, 2),
            },
          ],
        };
      }
    }
  • Defines the tool metadata including name, description, and detailed input schema with required and optional parameters for creating a patient.
      name: 'create_patient',
      description: 'Register a new patient in the system',
      inputSchema: {
        type: 'object',
        properties: {
          firstname: { type: 'string', description: 'Patient first name' },
          lastname: { type: 'string', description: 'Patient last name' },
          dob: { type: 'string', description: 'Date of birth (MM/DD/YYYY or YYYY-MM-DD)' },
          sex: { type: 'string', description: 'Sex (M or F)' },
          department_id: { type: 'string', description: 'Primary department ID' },
          email: { type: 'string', description: 'Email address (optional)' },
          mobile_phone: { type: 'string', description: 'Mobile phone number (optional)' },
          home_phone: { type: 'string', description: 'Home phone number (optional)' },
          address1: { type: 'string', description: 'Street address (optional)' },
          city: { type: 'string', description: 'City (optional)' },
          state: { type: 'string', description: 'State (optional)' },
          zip: { type: 'string', description: 'ZIP code (optional)' },
          guarantor_firstname: { type: 'string', description: 'Guarantor first name (optional)' },
          guarantor_lastname: { type: 'string', description: 'Guarantor last name (optional)' },
          guarantor_dob: { type: 'string', description: 'Guarantor date of birth (optional)' },
          guarantor_relationship: { type: 'string', description: 'Relationship to patient: 1=Self, 2=Spouse, 3=Child, 4=Other (optional)' },
        },
        required: ['firstname', 'lastname', 'dob', 'sex', 'department_id'],
      },
    },
  • Dispatches the 'create_patient' tool call to the corresponding handler method in the MCP server implementation.
    case 'create_patient':
      return await this.toolHandlers.handleCreatePatient(args);
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. 'Register a new patient' implies a write operation, but it doesn't specify permissions required, whether duplicates are allowed, what happens on success (e.g., returns patient ID), or error handling. This is a significant gap for a mutation tool with 16 parameters.

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 with zero waste—'Register a new patient in the system' is front-loaded and directly conveys the core action. Every word earns its place, making it easy for an agent to parse quickly without unnecessary elaboration.

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 complex mutation tool with 16 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns (e.g., patient ID), error conditions, or dependencies like valid department_id. Given the richness needed for such a tool, this leaves major gaps in understanding.

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%, with all parameters well-documented in the schema (e.g., dob formats, optional fields, guarantor relationship codes). The description adds no additional parameter semantics beyond implying patient registration, so it meets the baseline 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 action ('Register') and resource ('new patient in the system'), making the purpose immediately understandable. It distinguishes from siblings like 'search_patients' or 'get_patient_encounters' by focusing on creation rather than retrieval. However, it doesn't specify what 'register' entails beyond creation, missing some nuance.

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 'search_patients' for existing patients or 'create_appointment' for scheduling. There's no mention of prerequisites, such as needing department_id from 'list_departments', or exclusions, leaving the agent to infer usage from context alone.

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