Skip to main content

Overview

The Patient Management module is the core of OdontologyApp, providing a centralized system for registering, searching, and managing patient information across your dental clinic.

Patient Registration

Creating a New Patient

Patients can be registered through the main patient listing page with comprehensive demographic and medical information. Required Fields:
  • First name (nombres)
  • Last name (apellidos)
  • Cedula (National ID) - Must be 11 digits in Dominican format
Optional Fields:
  • Birth date
  • Phone number
  • Email address
  • Sex (masculino, femenino, otro)
  • Blood group (e.g., O+, AB-, etc.)
  • Allergies / Medical notes
  • Branch assignment
Each patient is automatically assigned a unique medical record number (medrecno) starting from 260001. This number is used throughout the system for patient identification.

Database Schema

Patients are stored in the patients table:
CREATE TABLE patients (
    id INT AUTO_INCREMENT PRIMARY KEY,
    medrecno int NOT NULL,
    first_name VARCHAR(100) NOT NULL,
    last_name VARCHAR(100) NOT NULL,
    cedula VARCHAR(20) UNIQUE,
    birth_date DATE,
    phone VARCHAR(20),
    email VARCHAR(100),
    sex ENUM('masculino', 'femenino', 'otro'),
    blood_group VARCHAR(5),
    allergies TEXT,
    branch_id INT,
    status ENUM('active', 'inactive', 'on_hold') DEFAULT 'active',
    uuid CHAR(36) UNIQUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (branch_id) REFERENCES branches(id) ON DELETE SET NULL
);

Patient Search and Filtering

The patient list includes a powerful search feature that queries:
  • Patient name (first or last name)
  • Cedula (National ID)
  • Medical record number (medrecno)
Search results update automatically with a 300ms debounce for optimal performance.
// API endpoint for patient search
GET /api/patients?query={searchTerm}

Patient List Display

The patient table shows:
  • Paciente: Full name with medical record ID and cedula
  • Edad: Calculated age from birth date
  • Teléfono: Contact phone number
  • Última visita: Date of last appointment
  • Estado: Active/Inactive status badge
  • Acciones: View, Edit, Delete buttons (permission-based)

Patient ID Format

Display format: #PAC-{medrecno}Example: #PAC-260001

Status Colors

  • Green: Active patient
  • Slate: Inactive/On hold

Patient Details View

Patient Profile Page

Access a patient’s complete profile at /patients/{uuid} which includes:
View complete medical history with all clinical records, diagnoses, and treatments.

Patient Header

The patient detail page displays:
  • Full name and medical record number
  • Age calculated from birth date
  • Contact information (phone, email)
  • Blood group and allergies (highlighted for medical safety)
  • Current status
  • Edit profile button (permission-based)
Allergies are prominently displayed at the top of the patient profile with a warning icon. Always verify this information before prescribing medications.

Editing Patient Information

Update Patient Data

Patients can be edited by users with the EDIT_PATIENTS permission:
  1. Click the edit button (✏️) from the patient list or profile
  2. Modify any field in the modal form
  3. Click “Actualizar Paciente” to save changes
API Endpoint:
PUT /api/patients/{id}

Body: {
  first_name: string,
  last_name: string,
  cedula: string,
  birth_date: string,
  phone: string,
  email: string,
  sex: 'masculino' | 'femenino' | 'otro',
  blood_group: string,
  allergies: string,
  branch_id: number,
  status: 'active' | 'inactive' | 'on_hold'
}

Validation Rules

  • First name: Required, cannot be empty
  • Last name: Required, cannot be empty
  • Cedula: Required, must be exactly 11 digits (Dominican format)
  • Email: Must be valid email format if provided
  • Cedula uniqueness: System prevents duplicate cedulas

Deleting Patients

Patient deletion is permanent and irreversible. All associated data including medical records, appointments, and odontograms will be deleted.

Delete Process

Users with DELETE_PATIENTS permission can remove patients:
  1. Click the delete button (🗑️) from the patient list
  2. Confirm the action in the SweetAlert2 modal
  3. Patient and all related data are permanently removed
DELETE /api/patients?id={patientId}

Permissions

Patient management requires specific permissions:
Access the patient list and view patient profiles. Required for all staff members who need to access patient information.
Register new patients in the system. Typically granted to secretaries and administrative staff.
Modify existing patient information. Essential for keeping patient data up-to-date.
Permanently remove patient records. Should be restricted to administrators only.

Multi-Branch Support

Patients are assigned to a specific branch (sucursal) during registration:
  • Sucursal Central (Branch ID: 1)
  • Sucursal Norte (Branch ID: 2)
  • Sucursal Sur (Branch ID: 3)
Branch assignment helps organize patients across multiple clinic locations and can be changed when editing patient information.

Age Calculation

The system automatically calculates patient age from the birth date:
function calculateAge(birthday) {
  if (!birthday) return "N/A";
  const birthdayDate = new Date(birthday);
  const ageDifMs = Date.now() - birthdayDate.getTime();
  const ageDate = new Date(ageDifMs);
  return Math.abs(ageDate.getUTCFullYear() - 1970);
}
Age is displayed throughout the system (patient list, profile header, etc.) for quick reference.

Mobile Responsive View

The patient list includes a mobile-optimized grid view that displays:
  • Patient name and ID
  • Last visit and contact info
  • Age and quick actions
  • Status badge
This ensures staff can access patient information efficiently on tablets and mobile devices.

API Reference

List Patients

GET /api/patients?query={searchTerm}

Response: {
  success: true,
  patients: [
    {
      id: number,
      medrecno: number,
      uuid: string,
      first_name: string,
      last_name: string,
      cedula: string,
      birth_date: string,
      phone: string,
      email: string,
      sex: string,
      blood_group: string,
      allergies: string,
      branch_id: number,
      status: string,
      last_visit: string | null,
      created_at: string
    }
  ]
}

Get Patient Details

GET /api/patients/{id}

Response: {
  success: true,
  patient: { /* patient object */ }
}

Create Patient

POST /api/patients

Response: {
  success: true,
  id: number,
  medrecno: number
}

Best Practices

1

Verify Cedula

Always verify the patient’s national ID (cedula) to prevent duplicate registrations.
2

Record Allergies

Document all known allergies immediately during registration for patient safety.
3

Keep Contact Updated

Maintain current phone and email information for appointment reminders.
4

Review Before Deleting

Double-check patient records before deletion as this action cannot be undone.

Build docs developers (and LLMs) love