Skip to main content

Overview

The Consultations module is the clinical core of Nguhöe EHR. It captures complete medical encounters including vital signs, clinical findings, diagnosis, and treatment plans. Consultations can be created from appointments and automatically support prescription and payment creation.
Consultations are restricted to Admin and Doctor roles. Only the assigned doctor or an admin can view consultation details.

Consultation Data Model

FieldTypeDescription
patient_idforeign keyReference to patient
doctor_idforeign keyReference to doctor (users table)
appointment_idforeign key (nullable)Optional link to appointment

Vital Signs

All vital signs are optional but recommended for complete clinical documentation:
FieldTypeUnitRange
weightdecimal(5,2)kg0-500
heightdecimal(5,2)cm0-300
temperaturedecimal(4,1)°C30-45
bp_systolicintegermmHg40-250
bp_diastolicintegermmHg30-150
heart_rateintegerbpm30-220
respiratory_rateintegerbreaths/min8-60
oxygen_saturationinteger%50-100

Clinical Documentation

FieldTypeRequiredDescription
reason_for_visittextYesChief complaint or reason for consultation
clinical_findingstextNoPhysical examination findings
diagnosistextYesMedical diagnosis
treatment_plantextNoRecommended treatment and follow-up

Creating a Consultation

From an Appointment

1

Access Appointment

Navigate to the appointment details or calendar
2

Start Consultation

Click “Create Consultation” from the appointment
3

Record Vital Signs

Enter patient’s vital signs (weight, BP, temperature, etc.)
4

Document Clinical Findings

Record reason for visit, physical findings, and diagnosis
5

Add Treatment Plan

Specify recommended treatment and follow-up
6

Optional: Add Prescription

Include prescription items and instructions
7

Optional: Record Payment

Add payment information if applicable
8

Save

Submit the consultation
Route: consultations.storeConsultationController@store
Action: CreateConsultationAction

Direct Consultation (No Appointment)

Consultations can also be created directly for walk-in patients: Route: consultations.create?patient_id={id}
Endpoint: GET /consultations/create?patient_id=123
// Creating a consultation with all components (ConsultationController.php:40-77)
$validated = $request->validate([
    'patient_id' => 'required|exists:patients,id',
    'doctor_id' => 'required|exists:users,id',
    'appointment_id' => 'nullable|exists:appointments,id',
    
    // Vital Signs
    'weight' => 'nullable|numeric|between:0,500',
    'height' => 'nullable|numeric|between:0,300',
    'temperature' => 'nullable|numeric|between:30,45',
    'bp_systolic' => 'nullable|integer|between:40,250',
    'bp_diastolic' => 'nullable|integer|between:30,150',
    'heart_rate' => 'nullable|integer|between:30,220',
    'respiratory_rate' => 'nullable|integer|between:8,60',
    'oxygen_saturation' => 'nullable|integer|between:50,100',
    
    // Clinical Documentation
    'reason_for_visit' => 'required|string',
    'clinical_findings' => 'nullable|string',
    'diagnosis' => 'required|string',
    'treatment_plan' => 'nullable|string',
    
    // Prescription Data (optional)
    'prescription_items' => 'nullable|array',
    'prescription_items.*.medication' => 'required_with:prescription_items|string',
    'prescription_items.*.dosage' => 'required_with:prescription_items|string',
    'prescription_items.*.frequency' => 'nullable|string',
    'prescription_items.*.duration' => 'nullable|string',
    'prescription_instructions' => 'nullable|string',
    
    // Payment Data (optional)
    'payment_amount' => 'nullable|numeric|min:0',
    'payment_method' => 'nullable|string|in:cash,card,transfer',
]);
The doctor_id is automatically set to the authenticated user to prevent impersonation (ConsultationController.php:71).

Vital Signs Documentation

Weight and Height

// Example: Recording basic vitals
[
    'weight' => 72.5,  // kg
    'height' => 175.0, // cm
]
These allow automatic BMI calculation if needed.

Blood Pressure

// Example: Recording blood pressure
[
    'bp_systolic' => 120,  // mmHg
    'bp_diastolic' => 80,  // mmHg
]
Stored as separate systolic and diastolic values.

Other Vital Signs

// Complete vital signs example
[
    'temperature' => 37.2,       // °C
    'heart_rate' => 75,          // bpm
    'respiratory_rate' => 16,    // breaths per minute
    'oxygen_saturation' => 98,   // %
]

Clinical Documentation Workflow

Reason for Visit

The chief complaint or presenting problem (required):
'reason_for_visit' => 'Dolor de cabeza persistente por 3 días'

Clinical Findings

Physical examination results (optional):
'clinical_findings' => 'Paciente alerta y orientado. Signos vitales estables. 
No signos de fiebre. Pupilas reactivas a la luz.'

Diagnosis

Medical diagnosis (required):
'diagnosis' => 'Migraña sin aura'

Treatment Plan

Recommended treatment and follow-up (optional):
'treatment_plan' => 'Ibuprofeno 400mg cada 8 horas. Reposo en lugar oscuro. 
Control en 7 días si síntomas persisten.'

Integrated Prescription Creation

Prescriptions can be created directly from the consultation form:
// Prescription items structure
'prescription_items' => [
    [
        'medication' => 'Ibuprofeno 400mg',
        'dosage' => '1 tableta',
        'frequency' => 'Cada 8 horas',
        'duration' => '5 días',
    ],
    [
        'medication' => 'Paracetamol 500mg',
        'dosage' => '1-2 tabletas',
        'frequency' => 'Cada 6-8 horas si dolor',
        'duration' => '3 días',
    ],
],
'prescription_instructions' => 'Tomar con alimentos. Evitar alcohol.',
The CreateConsultationAction handles automatic prescription creation if items are provided.

Integrated Payment Recording

Payments can also be recorded during consultation:
// Payment information
'payment_amount' => 500.00,
'payment_method' => 'cash', // or 'card', 'transfer'
The system automatically creates a payment record linked to the consultation.

Viewing Consultation Details

Route: consultations.showConsultationController@show
Access Control: Only the assigned doctor or admin can view
// Access validation (ConsultationController.php:84-89)
if ($user->hasRole('doctor') && $consultation->doctor_id !== $user->id) {
    abort(403, 'No tienes acceso a esta consulta.');
}

// Load related data
$consultation->load(['patient', 'doctor', 'prescription']);

Relationships

// Consultation.php relationships

// Belongs to Patient
public function patient(): BelongsTo
{
    return $this->belongsTo(Patient::class);
}

// Belongs to Doctor
public function doctor(): BelongsTo
{
    return $this->belongsTo(User::class, 'doctor_id');
}

// Optional: Belongs to Appointment
public function appointment(): BelongsTo
{
    return $this->belongsTo(Appointment::class);
}

// Has One Prescription
public function prescription(): HasOne
{
    return $this->hasOne(Prescription::class);
}

// Has One Payment
public function payment(): HasOne
{
    return $this->hasOne(Payment::class);
}

Access Control

  • View all consultations
  • Create consultations for any doctor
  • Full access to consultation details
  • Create consultations (auto-assigned to themselves)
  • View only their own consultations
  • Cannot view other doctors’ consultations
No access to consultation creation or viewing

Database Schema

CREATE TABLE consultations (
    id BIGINT PRIMARY KEY,
    patient_id BIGINT NOT NULL REFERENCES patients(id) ON DELETE CASCADE,
    doctor_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    appointment_id BIGINT REFERENCES appointments(id) ON DELETE SET NULL,
    
    -- Vital Signs
    weight DECIMAL(5,2),
    height DECIMAL(5,2),
    temperature DECIMAL(4,1),
    bp_systolic INTEGER,
    bp_diastolic INTEGER,
    heart_rate INTEGER,
    respiratory_rate INTEGER,
    oxygen_saturation INTEGER,
    
    -- Clinical Documentation
    reason_for_visit TEXT NOT NULL,
    clinical_findings TEXT,
    diagnosis TEXT NOT NULL,
    treatment_plan TEXT,
    
    created_at TIMESTAMP,
    updated_at TIMESTAMP,
    deleted_at TIMESTAMP
);

Best Practices

Complete Vital Signs

Record all relevant vital signs for comprehensive documentation

Detailed Findings

Document clinical findings thoroughly for medical-legal protection

Clear Diagnosis

Use specific diagnoses rather than symptoms when possible

Treatment Plans

Include clear follow-up instructions and when to return
Consultations use soft deletes to maintain medical history integrity. Deleted consultations remain in the database for audit purposes.

Build docs developers (and LLMs) love