From a526a29a68a10a49a290088be2e8a44309846a42 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 3 Jul 2026 17:55:51 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20bot=C3=B3n=20Ver=20paciente=20con=20his?= =?UTF-8?q?torial=20en=20vista=20lugar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agrega botón "Ver" en la sección Paciente de la ficha del turno. Abre modal con datos completos del paciente (nombre, doc, fecha nac, celular, médico, embarazo) y timeline de historial de visitas anterior (misma lógica que recepción), cargado desde get_historial.php. El botón solo aparece cuando hay un paciente vinculado al turno. Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/views/lugar.php | 209 +++++++++++++++++++++++++++++++- 1 file changed, 208 insertions(+), 1 deletion(-) diff --git a/modules/turnero/views/lugar.php b/modules/turnero/views/lugar.php index 9b941bf..b6e97f3 100644 --- a/modules/turnero/views/lugar.php +++ b/modules/turnero/views/lugar.php @@ -319,6 +319,51 @@ $adminNombre = $_SESSION['admin_user']['full_name'] ?? $_SESSION['admin_user'][' } .selector-lugar-box h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; } + /* ── Modal paciente ── */ + #modal-pac-lugar { display:none; position:fixed; inset:0; z-index:9500; + background:rgba(0,0,0,.55); align-items:center; justify-content:center; padding:16px; } + #modal-pac-lugar.show { display:flex; } + .mpac-dialog { + background:#fff; border-radius:16px; width:min(96vw,540px); + max-height:90vh; display:flex; flex-direction:column; overflow:hidden; + box-shadow:0 8px 40px rgba(0,0,0,.22); + } + .mpac-hdr { + display:flex; align-items:center; justify-content:space-between; + padding:13px 18px; border-bottom:1px solid #e2e8f0; flex-shrink:0; background:#f8fafc; + } + .mpac-hdr-title { font-weight:700; font-size:.97rem; color:#1e293b; display:flex; align-items:center; gap:.5rem; } + .mpac-close { background:none; border:none; font-size:1.2rem; color:#94a3b8; cursor:pointer; padding:2px 6px; border-radius:6px; } + .mpac-close:hover { background:#f1f5f9; color:#475569; } + .mpac-body { overflow-y:auto; padding:18px; flex:1; } + .mpac-dato { display:flex; gap:.5rem; align-items:baseline; margin-bottom:.4rem; } + .mpac-dato .lbl { font-size:.72rem; color:#94a3b8; min-width:95px; flex-shrink:0; } + .mpac-dato .val { font-size:.88rem; color:#1e293b; font-weight:500; } + .mpac-sec-title { + font-size:.7rem; text-transform:uppercase; letter-spacing:.07em; + color:#475569; font-weight:700; margin:14px 0 8px; + display:flex; align-items:center; gap:.4rem; + } + /* Historial timeline */ + .mpac-timeline { padding: 0; } + .mtl-item { + display:flex; gap:10px; align-items:flex-start; + padding-bottom:12px; position:relative; + } + .mtl-item:not(:last-child)::before { + content:''; position:absolute; left:6px; top:14px; + width:2px; bottom:0; background:#e2e8f0; + } + .mtl-dot { + width:14px; height:14px; border-radius:50%; flex-shrink:0; + margin-top:2px; border:2px solid #fff; box-shadow:0 0 0 2px currentColor; + } + .mtl-content { flex:1; min-width:0; } + .mtl-fecha { font-size:.68rem; color:#94a3b8; } + .mtl-codigo { font-size:.82rem; font-weight:700; } + .mtl-lugar { font-size:.73rem; color:#64748b; } + .mtl-eb { font-size:.62rem; padding:1px 7px; border-radius:99px; font-weight:700; display:inline-block; margin-top:2px; } + /* ── Toast ── */ .rec-toast { position: fixed; bottom: 2rem; right: 2rem; z-index: 9999; @@ -448,7 +493,13 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
-
Paciente
+
+ Paciente + +
Nombre
Documento
@@ -561,6 +612,39 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
+ + + '; + document.getElementById('modal-pac-lugar').classList.add('show'); + + cargarHistorialModal(pac.id); +} + +function cerrarModalPaciente() { + document.getElementById('modal-pac-lugar').classList.remove('show'); +} + +async function cargarHistorialModal(pacienteId) { + const cont = document.getElementById('mpac-historial-content'); + try { + const res = await fetch(`${API}get_historial.php?paciente_id=${pacienteId}&per_page=10&page=1`); + const json = await res.json(); + if (!json.ok || !json.turnos || !json.turnos.length) { + cont.innerHTML = '
Sin visitas anteriores registradas
'; + return; + } + cont.innerHTML = renderHistorialTimeline(json.turnos, json.total); + } catch(_) { + cont.innerHTML = '
Error al cargar historial
'; + } +} + +function renderHistorialTimeline(turnos, total) { + const ESTADO_LBL = { + espera:'Espera', en_recepcion:'Recepción', en_espera_lugar:'Esp. lugar', + en_servicio:'En servicio', finalizado:'Finalizado', ausente:'Ausente', cancelado:'Cancelado', + }; + const ESTADO_STYLE = { + finalizado: 'background:#f1f5f9;color:#334155', + ausente: 'background:#fee2e2;color:#991b1b', + cancelado: 'background:#f1f5f9;color:#9ca3af', + en_servicio: 'background:#dcfce7;color:#166534', + en_espera_lugar:'background:#fde68a;color:#92400e', + en_recepcion: 'background:#dbeafe;color:#1e40af', + espera: 'background:#fef9c3;color:#78350f', + }; + const totalLabel = total > turnos.length + ? `
Mostrando ${turnos.length} de ${total} visitas
` : ''; + + const items = turnos.map(t => { + const color = t.prioridad_color || '#6366f1'; + const lugar = escHtml(t.lugar_nombre || 'Recepción'); + const fecha = escHtml(t.fecha_sesion || '—'); + const est = t.estado || ''; + const eStyle = ESTADO_STYLE[est] || 'background:#f1f5f9;color:#334155'; + const eLbl = escHtml(ESTADO_LBL[est] || est); + const mins = t.servicio_min != null + ? `${t.servicio_min} min` : ''; + + let examStr = ''; + if (t.examenes && t.examenes.length) { + examStr = `
+ Exámenes: + ${t.examenes.map(e => escHtml(e.nombre)).join(', ')} +
`; + } + let comStr = ''; + if (t.comentarios && t.comentarios.length) { + comStr = `
+ 📝 Comentarios: +
${t.comentarios.map(c => + `
${escHtml(c.usuario_nombre)}: ${escHtml(c.comentario)}
` + ).join('')}
+
`; + } + + return `
+
+
+
${fecha}
+
${escHtml(t.codigo)}
+
${lugar}
+ ${eLbl}${mins} + ${examStr}${comStr} +
+
`; + }).join(''); + + return `
${items}
${totalLabel}`; +} + // ── Helpers ─────────────────────────────────────────────────── function escHtml(str) { const d = document.createElement('div');