Skip to main content

Overview

The Patient Management module provides a complete CRUD system for managing patient records in Nguhöe EHR. It includes demographic information, medical history, attachments, and powerful search capabilities.
Patient management is accessible to Admin, Doctor, and Receptionist roles. Only admins can delete patient records.

Patient Data Model

Personal Information

Patients are managed through the Patient model with the following core fields:
FieldTypeDescription
full_namestringPatient’s complete name
document_idstring (unique)National ID/DNI/CURP
birth_datedateDate of birth
genderenummale, female, or other
phonestringContact phone number
emailstringEmail address
addresstextPhysical address

Medical History

FieldTypeDescription
medical_antecedentstextPrevious medical conditions and history
allergiestextKnown allergies
chronic_diseasestextOngoing chronic conditions
current_medicationtextCurrent medications being taken
notestextAdditional clinical notes

Key Features

CRUD Operations

Creating a Patient

1

Navigate to Patients

Access the patients list from the main navigation
2

Click Create

Click the “Create Patient” button
3

Fill Patient Information

Complete the form with personal and medical information
4

Save

Submit to create the patient record
Route: patients.createPatientController@create
Form Request: StorePatientRequest
Action: CreatePatientAction
// Example patient creation
$patient = Patient::create([
    'full_name' => 'Juan Pérez',
    'document_id' => 'DNI12345678',
    'birth_date' => '1985-03-15',
    'gender' => 'male',
    'phone' => '+1234567890',
    'email' => '[email protected]',
    'address' => 'Calle Principal 123',
    'allergies' => 'Penicillin',
    'chronic_diseases' => 'Diabetes Type 2',
]);

Viewing Patient Details

The patient detail view (routes/web.php:27) loads comprehensive information including:
  • All patient demographic and medical data
  • Attached files and documents
  • Consultation history with doctor information
// Patient relationships loaded on show
$patient->load([
    'attachments', 
    'consultations' => function($q) {
        $q->with('doctor')->latest();
    }
]);
Route: patients.showPatientController@show

Updating Patient Records

Patient information can be updated through the edit form: Route: patients.updatePatientController@update
Form Request: UpdatePatientRequest
Action: UpdatePatientAction

Deleting Patients (Admin Only)

Patient records use soft deletes to maintain data integrity:
// Only admins can delete (PatientController.php:93)
if (!request()->user()->hasRole('admin')) {
    abort(403, 'Solo el administrador puede eliminar pacientes.');
}

$patient->delete(); // Soft delete
Deleted patients are soft-deleted and can be restored. This preserves historical consultation and prescription data.

Search and Filtering

The patient index page (routes/web.php:14-32) supports multi-field search:
// Search across multiple fields
$query->where(function ($q) use ($search) {
    $q->where('full_name', 'like', "%{$search}%")
      ->orWhere('document_id', 'like', "%{$search}%")
      ->orWhere('phone', 'like', "%{$search}%")
      ->orWhere('email', 'like', "%{$search}%");
});
Search terms match against:
  • Full name
  • Document ID (national ID)
  • Phone number
  • Email address

Attachments System

Patients can have multiple file attachments using a polymorphic relationship:
// Patient.php:36-39
public function attachments(): MorphMany
{
    return $this->morphMany(Attachment::class, 'attachable');
}

Uploading Attachments

Route: patients.attachments.storeAttachmentController@storePatient
Endpoint: POST /patients/{patient}/attachments
Attachments can include:
  • Lab results
  • Medical imaging
  • Insurance documents
  • ID copies
  • Previous medical records

Deleting Attachments

Route: attachments.destroyAttachmentController@destroy
Endpoint: DELETE /attachments/{attachment}

Relationships

The Patient model has the following relationships:
// One-to-Many: Consultations
public function consultations(): HasMany
{
    return $this->hasMany(Consultation::class);
}

// One-to-Many: Prescriptions
public function prescriptions(): HasMany
{
    return $this->hasMany(Prescription::class);
}

// One-to-Many: Payments
public function payments(): HasMany
{
    return $this->hasMany(Payment::class);
}

// Polymorphic: Attachments
public function attachments(): MorphMany
{
    return $this->morphMany(Attachment::class, 'attachable');
}

UI Workflow

1

List View

View all patients in a paginated table with search functionality
2

Search

Use the search bar to find patients by name, ID, phone, or email
3

Patient Details

Click a patient to view complete medical history and consultations
4

Edit or Manage

Update patient information or manage attachments from the detail view

Access Control

  • Full CRUD access
  • Can delete patient records
  • View all patients
  • Create, read, and update patients
  • Cannot delete patients
  • View all patients
  • Create, read, and update patients
  • Cannot delete patients
  • View all patients

Database Schema

CREATE TABLE patients (
    id BIGINT PRIMARY KEY,
    full_name VARCHAR(255) NOT NULL,
    document_id VARCHAR(255) UNIQUE,
    birth_date DATE,
    gender ENUM('male', 'female', 'other'),
    phone VARCHAR(255),
    email VARCHAR(255),
    address TEXT,
    medical_antecedents TEXT,
    allergies TEXT,
    chronic_diseases TEXT,
    current_medication TEXT,
    notes TEXT,
    created_at TIMESTAMP,
    updated_at TIMESTAMP,
    deleted_at TIMESTAMP
);

Best Practices

Complete Medical History

Always fill out allergies and chronic diseases to prevent medical errors

Verify Contact Info

Ensure phone and email are current for appointment reminders

Attach Documents

Upload important medical documents for easy reference

Regular Updates

Keep medical information current as patient conditions change

Build docs developers (and LLMs) love