Skip to main content

Overview

The appointment reminders feature helps reduce no-shows by sending timely reminders to patients about their upcoming appointments. The system supports both WhatsApp and email delivery methods, allowing staff to reach patients through their preferred communication channel.

Features

WhatsApp Reminders

Send instant reminders via WhatsApp Web with pre-formatted messages

Email Reminders

Compose and send email reminders directly from the system

48-Hour Window

Automatically identifies appointments in the next 48 hours

Activity Logging

Track all reminder sends with timestamp and method

How It Works

Reminder Dashboard

The reminders management interface is located at /admin/reminders and provides:
  • List of confirmed appointments in the next 48 hours
  • Patient contact information (phone and email)
  • Quick-send buttons for WhatsApp and email
  • Visual indicators for same-day and next-day appointments
Implementation: /src/routes/admin/reminders/+page.svelte

Automatic Filtering

The system automatically filters appointments to show only:
  • Status: confirmed appointments
  • Timeframe: Next 2 days (today + tomorrow)
  • Contact Info: Patients with valid phone numbers or email addresses
  • Active Patients: Only active patients

API Endpoints

GET /api/appointments/reminders

Retrieve list of appointments requiring reminders.
const response = await fetch('/api/appointments/reminders');
const data = await response.json();
Implementation: /src/routes/api/appointments/reminders/+server.js:5
This endpoint calls the stored procedure sp_list_appointment_reminders() which returns appointments for the next 48 hours with confirmed status.

POST /api/appointments/reminders

Log a reminder send event.
const response = await fetch('/api/appointments/reminders', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    appointment_id: 145,
    method: 'whatsapp' // or 'email'
  })
});
Implementation: /src/routes/api/appointments/reminders/+server.js:21
This endpoint logs the reminder send to the audit log table for tracking purposes. The actual message delivery is handled client-side via WhatsApp Web or mailto links.

Message Templates

WhatsApp Message Format

The system generates a formatted message in Spanish:
Hola [Patient Name], le recordamos su cita dental programada para el 
[Day of week, Day Month] a las [HH:MM AM/PM]. 
Por favor confirme si asistirá vía llamada o por este medio de WhatsApp.
Example:
Hola Maria Rodriguez, le recordamos su cita dental programada para el 
viernes, 8 marzo a las 10:30 AM. 
Por favor confirme si asistirá vía llamada o por este medio de WhatsApp.

Email Format

Emails use the same message body with:
  • Subject: “Recordatorio de Cita Dental”
  • Body: Same format as WhatsApp message
Implementation: /src/routes/admin/reminders/+page.svelte:42

Delivery Methods

WhatsApp Integration

The system uses WhatsApp Web URL scheme for message delivery:
const cleanPhone = phone.replace(/[^0-9]/g, '');
const waUrl = `https://wa.me/${cleanPhone}?text=${encodeURIComponent(message)}`;
window.open(waUrl, '_blank');
1

Click Send

User clicks “WhatsApp” button on reminder card
2

Format Message

System formats appointment details into message template
3

Open WhatsApp

Opens WhatsApp Web/Desktop with pre-filled message
4

User Sends

Staff member reviews and sends the message
5

Log Activity

System logs the reminder send in audit trail
Implementation: /src/routes/admin/reminders/+page.svelte:103

Email Integration

Email reminders use the mailto: protocol:
const subject = encodeURIComponent('Recordatorio de Cita Dental');
const mailUrl = `mailto:${email}?subject=${subject}&body=${encodeURIComponent(message)}`;
window.location.href = mailUrl;
Implementation: /src/routes/admin/reminders/+page.svelte:108

User Interface

Reminder Cards

Each reminder is displayed as a card with:
  • Appointment Badge: Shows “Hoy” (Today) or “Mañana” (Tomorrow)
  • Branch Indicator: Hospital/clinic location
  • Patient Avatar: Initials of patient
  • Patient Name: Full name display
  • Doctor Assignment: Assigned dentist
  • Contact Info: Phone and email
  • Action Buttons: WhatsApp and Email send buttons

Visual Indicators

.tag-tomorrow {
  background: var(--amber-faint);
  color: var(--amber-dark);
}
Implementation: /src/routes/admin/reminders/+page.svelte:237

Stored Procedures

sp_list_appointment_reminders

Retrieves appointments needing reminders.
CALL sp_list_appointment_reminders();
Expected to return:
  • Patient ID, first name, last name
  • Contact information (phone, email)
  • Appointment date, time, and ID
  • Doctor name
  • Branch name
  • Filtered for next 48 hours with confirmed status
The stored procedure sp_list_appointment_reminders is referenced in the code but may need to be created. It should query the appointments table joined with patients, doctors, users, and branches tables.

Example Implementation

DROP PROCEDURE IF EXISTS sp_list_appointment_reminders;

CREATE PROCEDURE sp_list_appointment_reminders()
BEGIN
  SELECT 
    a.id,
    a.appointment_date,
    a.appointment_time,
    p.id as patient_id,
    p.first_name,
    p.last_name,
    p.phone,
    p.email,
    u.name as doctor_name,
    b.name as branch_name
  FROM appointments a
  JOIN patients p ON a.patient_id = p.id
  JOIN doctors d ON a.doctor_id = d.id
  JOIN users u ON d.user_id = u.id
  JOIN branches b ON a.branch_id = b.id
  WHERE a.status = 'confirmed'
    AND a.appointment_date >= CURDATE()
    AND a.appointment_date <= DATE_ADD(CURDATE(), INTERVAL 2 DAY)
    AND p.status = 'active'
    AND (p.phone IS NOT NULL OR p.email IS NOT NULL)
  ORDER BY a.appointment_date ASC, a.appointment_time ASC;
END;

Activity Logging

All reminder sends are logged to the logs table:
await pool.query('CALL sp_create_log(?, ?, ?, ?, ?)', [
  user.id,
  'Reminder',
  'Appointments',
  `Recordatorio enviado por ${method} para la cita #${appointment_id}`,
  ip_address
]);
Log Fields:
  • user_id: Who sent the reminder
  • action: “Reminder”
  • entity: “Appointments”
  • description: Method and appointment ID
  • ip_address: Client IP
Implementation: /src/routes/api/appointments/reminders/+server.js:31

Permissions

Reminder access is controlled by permissions:
VIEW_REMINDERS
permission
Required to access the reminders dashboard at /admin/reminders
SEND_REMINDERS
permission
Required to send reminders via WhatsApp or email
Default Access:
  • Admin: Full access
  • Secretary: Full access
  • Doctor: No access (can be granted)

Setup Instructions

1

Verify Tables

Ensure required tables exist:
  • appointments
  • patients
  • doctors
  • users
  • branches
  • logs
2

Create Stored Procedure

Create the sp_list_appointment_reminders stored procedure (see example above)
3

Grant Permissions

Assign VIEW_REMINDERS and SEND_REMINDERS permissions to appropriate users
4

Test Integration

  • Create a test appointment for tomorrow
  • Navigate to /admin/reminders
  • Verify appointment appears
  • Test WhatsApp and email buttons

Best Practices

Send reminders 24 hours before the appointment for best results. The system highlights tomorrow’s appointments with a special badge.
Some patients prefer WhatsApp while others prefer email. Always check patient preferences before sending.
The message template asks patients to confirm attendance. Follow up with patients who don’t confirm.
Use the “Actualizar Lista” button to refresh the list periodically throughout the day as new appointments are confirmed.

Advanced Features

Automatic Reminder System

For fully automated reminders, you can extend the system with:
// Example cron job or scheduled task
import { pool } from '$lib/server/db';
import { sendWhatsAppMessage } from './whatsapp-api';

export async function sendAutomatedReminders() {
  const [results] = await pool.query('CALL sp_list_appointment_reminders()');
  const reminders = results[0];
  
  for (const reminder of reminders) {
    if (reminder.phone && shouldSendReminder(reminder)) {
      await sendWhatsAppMessage({
        to: reminder.phone,
        message: formatMessage(reminder)
      });
      
      // Log the send
      await pool.query('CALL sp_create_log(?, ?, ?, ?, ?)', [
        1, // System user
        'Reminder',
        'Appointments',
        `Auto-reminder sent via WhatsApp for appointment #${reminder.id}`,
        'system'
      ]);
    }
  }
}
Implementing automated reminders requires integration with WhatsApp Business API or email service provider (e.g., SendGrid, Mailgun).

Notifications

In-app notification system for staff alerts

Webhooks

Trigger external systems when reminders are sent

Build docs developers (and LLMs) love