Kulcare Docs
DeveloperBilling03 api reference

Appointment APIs

This document covers all appointment-related endpoints for booking, managing, and tracking patient appointments.

Authentication

All appointment endpoints require authentication. Include the JWT token in the Authorization header:

Authorization: Bearer YOUR_AUTH_TOKEN

Base URL

/appointments

Endpoints Overview

MethodEndpointDescription
GET/appointmentsList appointments with filtering
POST/appointmentsCreate new appointment
GET/appointments/:idGet appointment details
PUT/appointments/:idUpdate appointment
DELETE/appointments/:idCancel appointment
POST/appointments/:id/check_inCheck in patient
POST/appointments/:id/start_consultationStart consultation
POST/appointments/:id/completeComplete appointment
GET/appointments/slotsGet available time slots
GET/appointments/todayToday's appointments
GET/appointments/upcomingUpcoming appointments

List Appointments

GET /appointments

Retrieve appointments with optional filtering and pagination.

Query Parameters

ParameterTypeDescriptionExample
pageIntegerPage number (default: 1)1
per_pageIntegerItems per page (default: 20)20
dateStringFilter by appointment date2025-01-15
doctor_idIntegerFilter by doctor123
patient_idIntegerFilter by patient456
statusStringFilter by statusscheduled
start_dateStringDate range start2025-01-01
end_dateStringDate range end2025-01-31

Status Values

  • scheduled - Appointment booked
  • confirmed - Patient confirmed
  • checked_in - Patient arrived
  • in_progress - Consultation started
  • completed - Consultation finished
  • cancelled - Appointment cancelled
  • no_show - Patient didn't arrive

Example Request

curl -X GET "http://localhost:3000/appointments?date=2025-01-15&status=scheduled" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Example Response

{
  "success": true,
  "data": [
    {
      "id": 123,
      "appointment_date": "2025-01-15",
      "appointment_time": "10:00",
      "duration": 30,
      "status": "scheduled",
      "reason": "Regular checkup",
      "notes": "Patient reports mild headaches",
      "patient": {
        "id": 456,
        "first_name": "John",
        "last_name": "Doe",
        "phone_number": "9999999999",
        "age": 35
      },
      "doctor": {
        "id": 789,
        "first_name": "Dr. Sarah",
        "last_name": "Smith",
        "speciality": "General Physician",
        "consultation_fee": 500
      },
      "clinic": {
        "id": 101,
        "name": "City Health Clinic"
      },
      "created_at": "2025-01-10T08:30:00Z",
      "updated_at": "2025-01-12T14:20:00Z"
    }
  ],
  "meta": {
    "page": 1,
    "per_page": 20,
    "total": 45,
    "total_pages": 3
  }
}

Create Appointment

POST /appointments

Book a new appointment for a patient.

Request Body

{
  "appointment": {
    "clinic_patient_id": 456,
    "clinic_doctor_id": 789,
    "appointment_date": "2025-01-15",
    "appointment_time": "10:00",
    "duration": 30,
    "reason": "Regular checkup",
    "notes": "Patient reports mild headaches",
    "appointment_type": "consultation",
    "booking_source": "online"
  }
}

Parameters

ParameterTypeRequiredDescription
clinic_patient_idIntegerYesPatient ID
clinic_doctor_idIntegerYesDoctor ID
appointment_dateStringYesAppointment date (YYYY-MM-DD)
appointment_timeStringYesAppointment time (HH:MM)
durationIntegerNoDuration in minutes (default: 30)
reasonStringNoReason for visit
notesStringNoAdditional notes
appointment_typeStringNoType of appointment
booking_sourceStringNoHow appointment was booked

Appointment Types

  • consultation - Regular consultation
  • follow_up - Follow-up visit
  • emergency - Emergency appointment
  • teleconsultation - Video consultation
  • procedure - Medical procedure

Booking Sources

  • online - Web/mobile app
  • phone - Phone booking
  • walk_in - Walk-in patient
  • referral - Referred by another doctor

Example Request

curl -X POST http://localhost:3000/appointments \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "appointment": {
      "clinic_patient_id": 456,
      "clinic_doctor_id": 789,
      "appointment_date": "2025-01-15",
      "appointment_time": "10:00",
      "reason": "Regular checkup"
    }
  }'

Success Response (201 Created)

{
  "success": true,
  "data": {
    "id": 123,
    "appointment_date": "2025-01-15",
    "appointment_time": "10:00",
    "status": "scheduled",
    "appointment_number": "APT001234",
    "confirmation_code": "ABC123",
    // ... complete appointment data
  },
  "message": "Appointment booked successfully"
}

Error Response (422 Unprocessable Entity)

{
  "success": false,
  "error": "Appointment could not be created",
  "errors": {
    "appointment_time": ["is not available"],
    "clinic_doctor_id": ["doctor is not available on this date"]
  }
}

Get Appointment Details

GET /appointments/:id

Get detailed information about a specific appointment.

Example Request

curl -X GET http://localhost:3000/appointments/123 \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Success Response

{
  "success": true,
  "data": {
    "id": 123,
    "appointment_date": "2025-01-15",
    "appointment_time": "10:00",
    "duration": 30,
    "status": "scheduled",
    "reason": "Regular checkup",
    "notes": "Patient reports mild headaches",
    "appointment_type": "consultation",
    "appointment_number": "APT001234",
    "confirmation_code": "ABC123",
    "patient": {
      "id": 456,
      "first_name": "John",
      "last_name": "Doe",
      "phone_number": "9999999999",
      "email": "john.doe@email.com",
      "age": 35,
      "gender": "M",
      "blood_group": "O+",
      "allergies": ["Penicillin"],
      "medical_history": "Hypertension, Diabetes Type 2"
    },
    "doctor": {
      "id": 789,
      "first_name": "Dr. Sarah",
      "last_name": "Smith",
      "speciality": "General Physician",
      "qualification": "MBBS, MD",
      "consultation_fee": 500,
      "experience_years": 8
    },
    "clinic": {
      "id": 101,
      "name": "City Health Clinic",
      "address": "123 Main St, Mumbai",
      "phone_number": "9888888888"
    },
    "vitals": {
      "weight": 70,
      "height": 175,
      "bp_systolic": 120,
      "bp_diastolic": 80,
      "pulse": 72,
      "temperature": 98.6
    },
    "prescriptions": [],
    "invoices": [],
    "created_at": "2025-01-10T08:30:00Z",
    "updated_at": "2025-01-12T14:20:00Z"
  }
}

Update Appointment

PUT /appointments/:id

Update appointment details.

Request Body

{
  "appointment": {
    "appointment_date": "2025-01-16",
    "appointment_time": "11:00",
    "reason": "Follow-up checkup",
    "notes": "Updated notes",
    "status": "confirmed"
  }
}

Example Request

curl -X PUT http://localhost:3000/appointments/123 \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "appointment": {
      "appointment_time": "11:00",
      "status": "confirmed"
    }
  }'

Cancel Appointment

DELETE /appointments/:id

Cancel an existing appointment.

Query Parameters

ParameterTypeDescription
reasonStringCancellation reason

Example Request

curl -X DELETE "http://localhost:3000/appointments/123?reason=Patient%20rescheduled" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Success Response

{
  "success": true,
  "message": "Appointment cancelled successfully"
}

Check In Patient

POST /appointments/:id/check_in

Mark patient as checked in when they arrive.

Request Body

{
  "check_in_time": "2025-01-15T09:55:00Z",
  "vitals": {
    "weight": 70,
    "height": 175,
    "bp_systolic": 120,
    "bp_diastolic": 80,
    "pulse": 72,
    "temperature": 98.6
  }
}

Example Request

curl -X POST http://localhost:3000/appointments/123/check_in \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "vitals": {
      "weight": 70,
      "bp_systolic": 120,
      "bp_diastolic": 80
    }
  }'

Start Consultation

POST /appointments/:id/start_consultation

Mark consultation as started.

Example Request

curl -X POST http://localhost:3000/appointments/123/start_consultation \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Success Response

{
  "success": true,
  "data": {
    "id": 123,
    "status": "in_progress",
    "consultation_started_at": "2025-01-15T10:05:00Z"
  },
  "message": "Consultation started"
}

Complete Appointment

POST /appointments/:id/complete

Mark appointment as completed with diagnosis and prescription.

Request Body

{
  "diagnosis": "Common cold with mild fever",
  "treatment_notes": "Prescribed antibiotics and rest",
  "next_visit_date": "2025-01-22",
  "prescriptions": [
    {
      "medicine_name": "Paracetamol",
      "dosage": "500mg",
      "frequency": "Twice daily",
      "duration": "5 days",
      "instructions": "Take after meals"
    }
  ],
  "investigations": [
    {
      "test_name": "Complete Blood Count",
      "notes": "Routine check"
    }
  ]
}

Example Request

curl -X POST http://localhost:3000/appointments/123/complete \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "diagnosis": "Common cold",
    "treatment_notes": "Rest and medication"
  }'

Get Available Slots

GET /appointments/slots

Get available appointment slots for a specific doctor and date.

Query Parameters

ParameterTypeRequiredDescription
doctor_idIntegerYesDoctor ID
dateStringYesDate (YYYY-MM-DD)
durationIntegerNoAppointment duration in minutes

Example Request

curl -X GET "http://localhost:3000/appointments/slots?doctor_id=789&date=2025-01-15" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Success Response

{
  "success": true,
  "data": {
    "date": "2025-01-15",
    "doctor": {
      "id": 789,
      "name": "Dr. Sarah Smith",
      "speciality": "General Physician"
    },
    "available_slots": [
      {
        "time": "09:00",
        "available": true
      },
      {
        "time": "09:30",
        "available": true
      },
      {
        "time": "10:00",
        "available": false,
        "reason": "Already booked"
      },
      {
        "time": "10:30",
        "available": true
      }
    ],
    "total_slots": 16,
    "available_count": 12,
    "booked_count": 4
  }
}

Today's Appointments

GET /appointments/today

Get all appointments for today.

Example Request

curl -X GET http://localhost:3000/appointments/today \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Upcoming Appointments

GET /appointments/upcoming

Get upcoming appointments (next 7 days by default).

Query Parameters

ParameterTypeDescription
daysIntegerNumber of days ahead (default: 7)

Example Request

curl -X GET "http://localhost:3000/appointments/upcoming?days=14" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Appointment Status Transitions

Valid status transitions:

scheduled → confirmed → checked_in → in_progress → completed
    ↓           ↓           ↓            ↓
cancelled   cancelled   cancelled    cancelled
    ↓           ↓           ↓
no_show     no_show     no_show

Error Codes

CodeDescription
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing token
403Forbidden - No permission to access appointment
404Not Found - Appointment doesn't exist
422Unprocessable Entity - Validation errors
409Conflict - Time slot not available

Common Error Messages

{
  "success": false,
  "error": "Time slot not available",
  "errors": {
    "appointment_time": ["Doctor is not available at this time"]
  }
}
{
  "success": false,
  "error": "Patient not found",
  "details": "No patient found with ID 456 in your clinic"
}
{
  "success": false,
  "error": "Invalid status transition",
  "details": "Cannot change status from 'completed' to 'scheduled'"
}

Webhooks

The system can send webhooks for appointment events:

Events

  • appointment.created
  • appointment.updated
  • appointment.cancelled
  • appointment.checked_in
  • appointment.completed

Webhook Payload Example

{
  "event": "appointment.created",
  "data": {
    "appointment_id": 123,
    "patient_id": 456,
    "doctor_id": 789,
    "clinic_id": 101,
    "appointment_date": "2025-01-15",
    "appointment_time": "10:00"
  },
  "timestamp": "2025-01-10T08:30:00Z"
}

On this page