Skip to main content
The Patient Controller handles all CRUD operations for patient records. Access is restricted to authenticated users with admin, doctor, or receptionist roles.

Authentication

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

Endpoints

List Patients

GET /patients
Returns a paginated list of patients with optional search filtering.

Query Parameters

Search term to filter patients by full name, document ID, phone, or email
page
integer
default:"1"
Page number for pagination

Response

Returns an Inertia render with:
patients
object
Paginated collection of patient records
data
array
Array of patient objects
id
integer
Patient ID
full_name
string
Patient’s full name
document_id
string
Patient’s identification document number
phone
string
Contact phone number
email
string
Email address
birth_date
date
Date of birth
gender
string
Gender: male, female, or other
current_page
integer
Current page number
per_page
integer
Items per page (10)
total
integer
Total number of patients
filters
object
Active search filters

Create Patient Form

GET /patients/create
Displays the form for creating a new patient.

Response

Returns an Inertia render of the patient creation form.

Store Patient

POST /patients
Creates a new patient record.

Request Body

Validated by StorePatientRequest:
full_name
string
required
Patient’s full name (max 255 characters)
document_id
string
Identification document number (max 50 characters, must be unique)
birth_date
date
Date of birth (format: YYYY-MM-DD)
gender
string
Gender: male, female, or other
phone
string
Contact phone number (max 20 characters)
email
email
Email address (max 255 characters)
address
string
Physical address
medical_antecedents
string
Medical history and antecedents
allergies
string
Known allergies
chronic_diseases
string
Chronic diseases and conditions
current_medication
string
Current medications
notes
string
Additional notes

Response

Redirects to /patients with success message: “Paciente registrado exitosamente.”

Show Patient

GET /patients/{patient}
Displays a single patient’s details including attachments and consultation history.

Path Parameters

patient
integer
required
Patient ID

Response

patient
object
Patient record with relationships
id
integer
Patient ID
full_name
string
Patient’s full name
document_id
string
Identification document
medical_antecedents
string
Medical history
allergies
string
Known allergies
attachments
array
Array of file attachments
consultations
array
Array of consultation records with doctor information (latest first)

Edit Patient Form

GET /patients/{patient}/edit
Displays the form for editing a patient.

Path Parameters

patient
integer
required
Patient ID

Response

Returns an Inertia render with the patient data.

Update Patient

PUT /patients/{patient}
Updates an existing patient record.

Path Parameters

patient
integer
required
Patient ID

Request Body

Validated by UpdatePatientRequest. All fields are optional (use sometimes rule):
full_name
string
Patient’s full name (max 255 characters)
document_id
string
Identification document number (max 50 characters, must be unique)
birth_date
date
Date of birth
gender
string
Gender: male, female, or other
phone
string
Contact phone number (max 20 characters)
email
email
Email address (max 255 characters)
address
string
Physical address
medical_antecedents
string
Medical history
allergies
string
Known allergies
chronic_diseases
string
Chronic diseases
current_medication
string
Current medications
notes
string
Additional notes

Response

Redirects to /patients with success message: “Datos del paciente actualizados.”

Delete Patient

DELETE /patients/{patient}
Soft deletes a patient record. Only admins can delete patients.

Path Parameters

patient
integer
required
Patient ID

Authorization

Returns 403 error if the authenticated user does not have the admin role.

Response

Redirects back with success message: “Paciente eliminado.”

Implementation Details

  • Source: app/Http/Controllers/PatientController.php
  • Search functionality queries: full_name, document_id, phone, email
  • Pagination: 10 records per page
  • Uses action classes: CreatePatientAction, UpdatePatientAction
  • Soft deletes enabled (records marked as deleted but preserved in database)

Build docs developers (and LLMs) love