create_patient
Adds a new patient record to Cliniko with required first and last names, plus optional details like date of birth, contact, and address.
Instructions
Create a new patient
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| first_name | Yes | Patient first name | |
| last_name | Yes | Patient last name | |
| title | No | Title (Mr, Ms, Dr, etc) | |
| preferred_name | No | Preferred name | |
| date_of_birth | No | Date of birth (YYYY-MM-DD) | |
| sex | No | Biological sex | |
| No | Email address | ||
| phone_number | No | Primary phone number | |
| address_line_1 | No | Address line 1 | |
| address_line_2 | No | Address line 2 | |
| suburb | No | Suburb/City | |
| postcode | No | Postcode | |
| state | No | State/Province | |
| country | No | Country | |
| medicare_number | No | Medicare number | |
| medicare_reference_number | No | Medicare reference number |
Implementation Reference
- src/tools/patients.ts:111-155 (handler)The handler function for create_patient tool. It maps input fields, builds patientData object (including nested phone_numbers and address), calls client.createPatient(), and returns the created patient as JSON.
}, async (input: z.infer<typeof PatientCreateSchema>) => { try { const patientData: any = { first_name: input.first_name, last_name: input.last_name, }; if (input.title) patientData.title = input.title; if (input.preferred_name) patientData.preferred_name = input.preferred_name; if (input.date_of_birth) patientData.date_of_birth = input.date_of_birth; if (input.sex) patientData.sex = input.sex; if (input.email) patientData.email = input.email; if (input.medicare_number) patientData.medicare_number = input.medicare_number; if (input.medicare_reference_number) patientData.medicare_reference_number = input.medicare_reference_number; // Handle phone numbers if (input.phone_number) { patientData.phone_numbers = [{ number: input.phone_number, type: 'Mobile' }]; } // Handle address if (input.address_line_1 || input.suburb || input.postcode) { patientData.address = {}; if (input.address_line_1) patientData.address.line_1 = input.address_line_1; if (input.address_line_2) patientData.address.line_2 = input.address_line_2; if (input.suburb) patientData.address.suburb = input.suburb; if (input.postcode) patientData.address.postcode = input.postcode; if (input.state) patientData.address.state = input.state; if (input.country) patientData.address.country = input.country; } const patient = await client.createPatient(patientData); return { content: [{ type: 'text', text: JSON.stringify(patient, null, 2) }] }; } catch (error) { throw new Error(`Failed to create patient: ${error instanceof Error ? error.message : 'Unknown error'}`); } }); - src/tools/patients.ts:4-21 (schema)Zod schema (PatientCreateSchema) defining input validation for create_patient, including required first_name/last_name and optional fields like title, email, sex, address, medicare info.
const PatientCreateSchema = z.object({ first_name: z.string().describe('Patient first name'), last_name: z.string().describe('Patient last name'), title: z.string().optional().describe('Title (Mr, Ms, Dr, etc)'), preferred_name: z.string().optional().describe('Preferred name'), date_of_birth: z.string().optional().describe('Date of birth (YYYY-MM-DD)'), sex: z.enum(['Male', 'Female', 'Other']).optional().describe('Biological sex'), email: z.string().email().optional().describe('Email address'), phone_number: z.string().optional().describe('Primary phone number'), address_line_1: z.string().optional().describe('Address line 1'), address_line_2: z.string().optional().describe('Address line 2'), suburb: z.string().optional().describe('Suburb/City'), postcode: z.string().optional().describe('Postcode'), state: z.string().optional().describe('State/Province'), country: z.string().optional().describe('Country'), medicare_number: z.string().optional().describe('Medicare number'), medicare_reference_number: z.string().optional().describe('Medicare reference number'), }); - src/tools/patients.ts:87-110 (registration)Registration of the 'create_patient' tool via server.tool(), including the inputSchema definition with required fields first_name and last_name.
server.tool('create_patient', { description: 'Create a new patient', inputSchema: { type: 'object', properties: { first_name: { type: 'string', description: 'Patient first name' }, last_name: { type: 'string', description: 'Patient last name' }, title: { type: 'string', description: 'Title (Mr, Ms, Dr, etc)' }, preferred_name: { type: 'string', description: 'Preferred name' }, date_of_birth: { type: 'string', description: 'Date of birth (YYYY-MM-DD)' }, sex: { type: 'string', enum: ['Male', 'Female', 'Other'], description: 'Biological sex' }, email: { type: 'string', description: 'Email address' }, phone_number: { type: 'string', description: 'Primary phone number' }, address_line_1: { type: 'string', description: 'Address line 1' }, address_line_2: { type: 'string', description: 'Address line 2' }, suburb: { type: 'string', description: 'Suburb/City' }, postcode: { type: 'string', description: 'Postcode' }, state: { type: 'string', description: 'State/Province' }, country: { type: 'string', description: 'Country' }, medicare_number: { type: 'string', description: 'Medicare number' }, medicare_reference_number: { type: 'string', description: 'Medicare reference number' } }, required: ['first_name', 'last_name'] }, - src/index.ts:58-58 (registration)Registration call: registerPatientTools(toolRegistry, clinikoClient) wires up all patient tools including create_patient into the MCP server.
registerPatientTools(toolRegistry, clinikoClient); - src/cliniko-client.ts:66-71 (helper)The ClinikoClient.createPatient() method that sends a POST request to /patients with the patient data JSON body.
async createPatient(patient: Partial<Patient>): Promise<Patient> { return this.request<Patient>('/patients', { method: 'POST', body: JSON.stringify(patient), }); }