From 9c989ce61632257bf5af06f5c7af2f3cbf8c72a0 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 25 Mar 2026 14:37:11 -0500 Subject: [PATCH] feat: incluir notas del enfermero en export CSV de domicilios (antecedentes, medicamentos, acudiente, notas libres) --- lab_reportes.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lab_reportes.php b/lab_reportes.php index 326c8d0..629f9a6 100644 --- a/lab_reportes.php +++ b/lab_reportes.php @@ -87,11 +87,22 @@ if ($tipo) { d.pago_modo, COALESCE(d.pago_monto,0) AS monto_recibido, d.observaciones, - d.created_at + d.created_at, + COALESCE(nc.antecedentes,'') AS antecedentes, + COALESCE(nc.medicamentos,'') AS medicamentos, + COALESCE(nc.acudiente_nombre,'') AS acudiente_nombre, + COALESCE(nc.acudiente_documento,'') AS acudiente_documento, + COALESCE( + (SELECT GROUP_CONCAT(CONCAT(COALESCE(nl.titulo,''), ': ', COALESCE(nl.cuerpo,'')) + ORDER BY nl.created_at ASC SEPARATOR ' | ') + FROM lab_domicilio_notas nl + WHERE nl.domicilio_id = d.id AND nl.tipo = 'libre'), + '') AS notas_libres FROM lab_domicilios d JOIN lab_pacientes p ON p.id = d.paciente_id LEFT JOIN lab_asignaciones a ON a.domicilio_id = d.id AND a.estado NOT IN ('liberada') LEFT JOIN lab_enfermeras e ON e.id = a.enfermera_id + LEFT JOIN lab_domicilio_notas nc ON nc.domicilio_id = d.id AND nc.tipo = 'clinica' WHERE $sqlWhere ORDER BY d.fecha_programada ASC, d.hora_programada ASC", $sqlParams @@ -106,6 +117,7 @@ if ($tipo) { 'Valor domicilio','Valor copago','Copago lab', 'Pago estado','Pago modo','Monto recibido', 'Observaciones','Registrado', + 'Antecedentes','Medicamentos','Acudiente nombre','Acudiente documento','Notas libres', ]; break;