Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/15aozzz/Lab-Nova-Salud/llms.txt

Use this file to discover all available pages before exploring further.

The dashboard endpoint aggregates data from four stored procedures into a single response object. The frontend calls this once on page load to populate the KPI cards, the weekly bar chart, the stock alert list, and the recent-transactions table.
This endpoint requires a valid JWT in the Authorization: Bearer <token> header.

GET /api/dashboard/resumen

Returns a consolidated summary of pharmacy activity. Internally executes four stored procedures in sequence — sp_dashboard_kpis, sp_dashboard_ventas_semana, sp_dashboard_alertas, and sp_dashboard_ultimos_comprobantes — and combines their results into a single JSON object.

Parameters

No parameters required.

Response

200 OK
kpis
object[]
required
Today’s key performance indicators. Produced by sp_dashboard_kpis.
ventasSemana
object[]
required
Aggregated daily sales for the last 7 days. Produced by sp_dashboard_ventas_semana. Used to render the weekly bar chart.
alertas
object[]
required
Products currently at or below their minimum stock threshold. Produced by sp_dashboard_alertas. An empty array means no products are running low.
ultimosComprobantes
object[]
required
The most recent sales vouchers issued. Produced by sp_dashboard_ultimos_comprobantes.

Errors

StatusConditionBody
500Any stored procedure fails{ "error": "Error al obtener resumen del dashboard" }
Because all four stored procedures run sequentially in a single request, a failure in any one of them returns a 500 for the entire response. Individual procedure errors are logged server-side.

Example

curl --request GET \
  --url http://localhost:3000/api/dashboard/resumen \
  --header 'Authorization: Bearer <token>'
Response
{
  "kpis": [
    {
      "ventas_hoy": 12,
      "ingresos_hoy": 340.50,
      "ticket_promedio": 28.37,
      "productos_con_stock_bajo": 3
    }
  ],
  "ventasSemana": [
    { "fecha": "2024-01-09", "total_ventas": 210.00, "num_transacciones": 8 },
    { "fecha": "2024-01-10", "total_ventas": 185.75, "num_transacciones": 6 },
    { "fecha": "2024-01-11", "total_ventas": 320.00, "num_transacciones": 11 },
    { "fecha": "2024-01-12", "total_ventas": 95.50,  "num_transacciones": 4 },
    { "fecha": "2024-01-13", "total_ventas": 0,      "num_transacciones": 0 },
    { "fecha": "2024-01-14", "total_ventas": 415.00, "num_transacciones": 14 },
    { "fecha": "2024-01-15", "total_ventas": 340.50, "num_transacciones": 12 }
  ],
  "alertas": [
    {
      "id_producto": 7,
      "nombre_comercial": "Amoxicilina 500mg",
      "stock_actual_unidades": 5,
      "stock_minimo": 20
    }
  ],
  "ultimosComprobantes": [
    {
      "id_venta": 42,
      "serie": "B001",
      "numero_documento": "00000042",
      "tipo_comprobante": "BOLETA DE VENTA",
      "total": 28.00,
      "fecha_venta": "2024-01-15T14:22:00.000Z",
      "nombres_razon_social": "María García"
    }
  ]
}

Build docs developers (and LLMs) love