The appointments module (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Nieto2020/portalhub/llms.txt
Use this file to discover all available pages before exploring further.
modules/citas/) lets clients and advisors collaborate on scheduling sessions. Every operation is gated by checkAuth(), and ownership checks ensure that a client can only act on their own appointments while an advisor can only act on appointments assigned to them. Creating a new appointment also triggers an automatic in-app notification to the assigned advisor.
Appointment State Machine
Each appointment (cita) moves through a well-defined lifecycle. The estado column is an ENUM with the following values:
| State | Meaning |
|---|---|
Programada | Default state when the appointment is first created |
Reprogramada | Reserved ENUM value for a rescheduled appointment; defined in the database schema |
Cancelada | Terminal state set by cancelar.php; no further edits are allowed |
A cancelled appointment is immutable — neither
modificar.php nor cancelar.php will process a request for a cita already in the Cancelada state. Note that modificar.php updates only the fecha_hora column; it does not automatically transition estado to Reprogramada.Creating an Appointment
Endpoint:POST modules/citas/crear.php
Before inserting the new row, crear.php queries for any existing non-cancelled appointment held by the target advisor at the exact same fecha_hora. If a conflict exists, 409 Conflict is returned. On success, NotificationService::notify() is called to alert the advisor.
Required fields:
| Field | Type | Description |
|---|---|---|
id_cliente | int | ID of the client requesting the appointment |
id_asesor | int | ID of the advisor to assign |
fecha_hora | string | ISO-8601 datetime (YYYY-MM-DD HH:MM:SS) |
- Request
- Success Response (201)
- Conflict Response (409)
crear.php):
Rescheduling an Appointment
Endpoint:POST modules/citas/modificar.php
modificar.php updates the fecha_hora to a new value. The advisor conflict check is repeated (excluding the current id_cita), and ownership is enforced: clients may only reschedule their own appointments, and advisors may only reschedule appointments assigned to them.
Required fields:
| Field | Type | Description |
|---|---|---|
id_cita | int | Primary key of the appointment to reschedule |
fecha_hora | string | New ISO-8601 datetime |
- Request
- Success Response (200)
- Permission Denied (403)
Cancelling an Appointment
Endpoint:POST modules/citas/cancelar.php
Sets estado = 'Cancelada' and records the reason in motivo_cancelacion. Both fields are required.
Required fields:
| Field | Type | Description |
|---|---|---|
id_cita | int | Primary key of the appointment to cancel |
motivo_cancelacion | string | Free-text explanation for the cancellation |
- Request
- Success Response (200)
Listing Appointments
Endpoint:GET modules/citas/listar.php
The result set is automatically scoped based on the session role:
| Role | Filter Applied |
|---|---|
ROL_CLIENTE (3) | Only appointments where id_cliente = id_usuario |
ROL_ASESOR (2) | Only appointments where id_asesor = id_usuario |
ROL_ADMIN (1) | All appointments, unfiltered |
fecha_hora DESC.
Response fields:
Role-based SQL filtering (listar.php)
Role-based SQL filtering (listar.php)
Notifications on Appointment Creation
When a new appointment is saved successfully,crear.php uses NotificationService to push an in-app notification to the assigned advisor:
NotificationService works and how notification events are consumed.