Skip to main content
The Consultation Controller handles medical consultation records including vital signs, diagnosis, treatment plans, and prescriptions. Access is restricted to authenticated users with admin or doctor roles.

Authentication

All endpoints require:
  • Middleware: auth, verified
  • Role: admin or doctor only

Endpoints

Create Consultation Form

GET /consultations/create
Displays the form for creating a new consultation.

Query Parameters

patient_id
integer
Pre-select a patient for the consultation
appointment_id
integer
Link consultation to a specific appointment. Automatically loads the associated patient.

Response

Returns an Inertia render with:
patient
object
Patient information (if patient_id or appointment_id provided)
appointment
object
Appointment information with patient relationship (if appointment_id provided)

Store Consultation

POST /consultations
Creates a new consultation record with vital signs, diagnosis, treatment, and optional prescription.

Request Body

Required Fields
patient_id
integer
required
Patient ID (must exist in patients table)
doctor_id
integer
required
Doctor ID (must exist in users table). Note: This is automatically overridden to the authenticated user’s ID for security.
reason_for_visit
string
required
Reason for the patient’s visit
diagnosis
string
required
Medical diagnosis
Optional Fields - Vital Signs
weight
number
Patient weight in kg (0-500)
height
number
Patient height in cm (0-300)
temperature
number
Body temperature in Celsius (30-45)
bp_systolic
integer
Systolic blood pressure in mmHg (40-250)
bp_diastolic
integer
Diastolic blood pressure in mmHg (30-150)
heart_rate
integer
Heart rate in beats per minute (30-220)
respiratory_rate
integer
Respiratory rate in breaths per minute (8-60)
oxygen_saturation
integer
Blood oxygen saturation percentage (50-100)
Optional Fields - Clinical Information
appointment_id
integer
Link to existing appointment (must exist in appointments table)
clinical_findings
string
Clinical observations and findings
treatment_plan
string
Recommended treatment plan
Optional Fields - Prescription
prescription_items
array
Array of medications to prescribe
prescription_items[].medication
string
required
Medication name (required if prescription_items provided)
prescription_items[].dosage
string
required
Dosage instructions (required if prescription_items provided)
prescription_items[].frequency
string
Frequency of administration (e.g., “3 times daily”)
prescription_items[].duration
string
Treatment duration (e.g., “7 days”)
prescription_instructions
string
General prescription instructions
Optional Fields - Payment
payment_amount
number
Consultation fee (minimum: 0)
payment_method
string
Payment method: cash, card, or transfer

Security

The doctor_id field is automatically overridden with the authenticated user’s ID to prevent impersonation:
$validated['doctor_id'] = $request->user()->id;

Response

Redirects to /patients/{patient_id} with success message: “Consulta registrada exitosamente.”

Show Consultation

GET /consultations/{consultation}
Displays a single consultation’s details.

Path Parameters

consultation
integer
required
Consultation ID

Authorization

  • Admins: Can view any consultation
  • Doctors: Can only view their own consultations (where doctor_id matches authenticated user)
Returns 403 error with message “No tienes acceso a esta consulta.” if a doctor attempts to access another doctor’s consultation.

Response

consultation
object
Consultation record with relationships
id
integer
Consultation ID
patient_id
integer
Patient ID
patient
object
Patient information
doctor_id
integer
Doctor ID
doctor
object
Doctor information
appointment_id
integer
Associated appointment ID (if linked)
weight
number
Weight in kg
height
number
Height in cm
temperature
number
Temperature in Celsius
bp_systolic
integer
Systolic blood pressure
bp_diastolic
integer
Diastolic blood pressure
heart_rate
integer
Heart rate (bpm)
respiratory_rate
integer
Respiratory rate (breaths/min)
oxygen_saturation
integer
O2 saturation percentage
reason_for_visit
string
Reason for visit
clinical_findings
string
Clinical findings
diagnosis
string
Medical diagnosis
treatment_plan
string
Treatment plan
prescription
object
Associated prescription (if created)

Implementation Details

  • Source: app/Http/Controllers/ConsultationController.php
  • Route: /consultations
  • Uses action class: CreateConsultationAction
  • Soft deletes enabled
  • Relationships: patient, doctor, appointment, prescription

Vital Signs Validation Ranges

All vital sign fields are validated with medically appropriate ranges:
FieldRangeUnit
Weight0-500kg
Height0-300cm
Temperature30-45°C
BP Systolic40-250mmHg
BP Diastolic30-150mmHg
Heart Rate30-220bpm
Respiratory Rate8-60breaths/min
O2 Saturation50-100%

Workflow Integration

  1. From Appointment: Consultations can be linked to appointments via appointment_id query parameter
  2. Prescription Creation: Prescription data can be submitted alongside consultation data
  3. Payment Recording: Payment information can be captured during consultation creation
  4. Security: Doctor ID is enforced server-side to prevent impersonation

Build docs developers (and LLMs) love