portal enfermero: ver formularios paciente + fix orden médica .bin via descargar_orden.php
This commit is contained in:
+109
-5
@@ -531,14 +531,19 @@ const portal = {
|
|||||||
<!-- Cobro y pago -->
|
<!-- Cobro y pago -->
|
||||||
${cobroHtml}
|
${cobroHtml}
|
||||||
|
|
||||||
<!-- Orden médica (imagen) -->
|
<!-- Orden médica -->
|
||||||
${item.orden_local_file ? `
|
${item.orden_local_file ? `
|
||||||
<div class="mt-2 mb-2">
|
<div class="mt-2 mb-2">
|
||||||
<a href="${resImg(item.orden_local_file)}" target="_blank"
|
<a href="${resOrden(item.orden_local_file)}" target="_blank" title="Ver / descargar orden médica">
|
||||||
title="Ver orden médica">
|
<img src="${resOrden(item.orden_local_file)}"
|
||||||
<img src="${resImg(item.orden_local_file)}"
|
|
||||||
style="max-width:100%;max-height:180px;border-radius:8px;border:1px solid #ddd;cursor:zoom-in"
|
style="max-width:100%;max-height:180px;border-radius:8px;border:1px solid #ddd;cursor:zoom-in"
|
||||||
alt="Orden médica #${item.orden_id_display || item.orden_id}">
|
alt="Orden médica #${item.orden_id_display || item.orden_id}"
|
||||||
|
onerror="this.style.display='none';document.getElementById('ord-icon-${item.orden_id}').style.display=''">
|
||||||
|
<div id="ord-icon-${item.orden_id}" style="display:none;"
|
||||||
|
class="text-center py-3 border rounded">
|
||||||
|
<i class="fas fa-file-medical fa-2x text-danger"></i>
|
||||||
|
<p class="small mt-1 mb-0 text-muted">Toca para ver / descargar</p>
|
||||||
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="small text-muted mt-1"><i class="fas fa-file-medical me-1"></i>Orden #${item.orden_id_display || item.orden_id}</div>
|
<div class="small text-muted mt-1"><i class="fas fa-file-medical me-1"></i>Orden #${item.orden_id_display || item.orden_id}</div>
|
||||||
</div>` : ''}
|
</div>` : ''}
|
||||||
@@ -567,6 +572,11 @@ const portal = {
|
|||||||
data-pac-id="${item.paciente_id||0}">
|
data-pac-id="${item.paciente_id||0}">
|
||||||
<i class="fas fa-file-medical me-1"></i>Formulario
|
<i class="fas fa-file-medical me-1"></i>Formulario
|
||||||
</button>
|
</button>
|
||||||
|
${item.paciente_id ? `
|
||||||
|
<button class="btn btn-outline-info btn-accion"
|
||||||
|
onclick="formVer.abrir(${item.paciente_id}, '${esc(item.paciente_nombre||'')}')">
|
||||||
|
<i class="fas fa-folder-open me-1"></i>Ver llenados
|
||||||
|
</button>` : ''}
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
},
|
},
|
||||||
@@ -690,10 +700,18 @@ function resImg(f) {
|
|||||||
return `uploads/media/${esc(f)}`;
|
return `uploads/media/${esc(f)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rutar archivos de orden médica a través de descargar_orden.php
|
||||||
|
// (detecta MIME real y convierte .bin a extensión correcta)
|
||||||
|
function resOrden(f) {
|
||||||
|
if (!f) return '';
|
||||||
|
return `api/lab/descargar_orden.php?file=${encodeURIComponent(f)}`;
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
portal.init();
|
portal.init();
|
||||||
agendaNueva.init();
|
agendaNueva.init();
|
||||||
formEnvio.cargarPlantillas();
|
formEnvio.cargarPlantillas();
|
||||||
|
formVer.init();
|
||||||
|
|
||||||
// Delegated: botones Formulario generados dinámicamente
|
// Delegated: botones Formulario generados dinámicamente
|
||||||
document.getElementById('portal-lista').addEventListener('click', e => {
|
document.getElementById('portal-lista').addEventListener('click', e => {
|
||||||
@@ -709,6 +727,92 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- ═══════════ MODAL: Ver Formularios Paciente ═══════════ -->
|
||||||
|
<div class="modal fade" id="modalVerForms" tabindex="-1">
|
||||||
|
<div class="modal-dialog modal-dialog-scrollable">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header text-white py-2" style="background:#0891b2">
|
||||||
|
<h6 class="modal-title mb-0" id="ver-forms-titulo">
|
||||||
|
<i class="fas fa-folder-open me-2"></i>Formularios del paciente
|
||||||
|
</h6>
|
||||||
|
<button class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="ver-forms-body">
|
||||||
|
<div class="text-center py-3">
|
||||||
|
<div class="spinner-border spinner-border-sm text-info"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const ESTADO_FORM_BADGE = {
|
||||||
|
pendiente: 'bg-secondary',
|
||||||
|
enviado: 'bg-primary',
|
||||||
|
completado: 'bg-success',
|
||||||
|
firmado: 'bg-info',
|
||||||
|
};
|
||||||
|
|
||||||
|
const formVer = {
|
||||||
|
_modal: null,
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this._modal = new bootstrap.Modal('#modalVerForms');
|
||||||
|
},
|
||||||
|
|
||||||
|
async abrir(pacienteId, nombre) {
|
||||||
|
document.getElementById('ver-forms-titulo').innerHTML =
|
||||||
|
`<i class="fas fa-folder-open me-2"></i>${esc(nombre) || 'Formularios del paciente'}`;
|
||||||
|
document.getElementById('ver-forms-body').innerHTML =
|
||||||
|
'<div class="text-center py-3"><div class="spinner-border spinner-border-sm text-info"></div></div>';
|
||||||
|
this._modal.show();
|
||||||
|
|
||||||
|
if (!pacienteId) {
|
||||||
|
document.getElementById('ver-forms-body').innerHTML =
|
||||||
|
'<p class="text-muted small text-center py-3">Sin paciente vinculado.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const r = await fetch(`api/lab/get_formularios.php?envios=1&paciente_id=${pacienteId}`);
|
||||||
|
const d = await r.json();
|
||||||
|
const items = d.data || [];
|
||||||
|
if (!items.length) {
|
||||||
|
document.getElementById('ver-forms-body').innerHTML =
|
||||||
|
'<div class="text-center py-4"><i class="fas fa-inbox fa-2x text-muted"></i>' +
|
||||||
|
'<p class="mt-2 text-muted small mb-0">Sin formularios para este paciente.</p></div>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.getElementById('ver-forms-body').innerHTML = items.map(e => {
|
||||||
|
const badge = ESTADO_FORM_BADGE[e.estado] || 'bg-secondary';
|
||||||
|
const fecha = e.created_at ? e.created_at.slice(0, 10) : '—';
|
||||||
|
const diligenciado = ['completado', 'firmado'].includes(e.estado);
|
||||||
|
return `<div class="border rounded p-2 mb-2">
|
||||||
|
<div class="d-flex justify-content-between align-items-start gap-2">
|
||||||
|
<div class="fw-semibold small">${esc(e.form_nombre)}</div>
|
||||||
|
<span class="badge ${badge} text-nowrap">${esc(e.estado)}</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-muted small mt-1">
|
||||||
|
<i class="fas fa-calendar me-1"></i>${fecha}
|
||||||
|
${e.enviado_por_nombre ? `· ${esc(e.enviado_por_nombre)}` : ''}
|
||||||
|
</div>
|
||||||
|
${ diligenciado
|
||||||
|
? `<a href="ver_formulario_enviado.php?id=${e.id}" target="_blank"
|
||||||
|
class="btn btn-sm btn-outline-success mt-2 w-100">
|
||||||
|
<i class="fas fa-eye me-1"></i>Ver respuesta
|
||||||
|
</a>`
|
||||||
|
: `<div class="small text-muted mt-1"><i class="fas fa-clock me-1"></i>Pendiente de completar</div>`
|
||||||
|
}
|
||||||
|
</div>`;
|
||||||
|
}).join('');
|
||||||
|
} catch (err) {
|
||||||
|
document.getElementById('ver-forms-body').innerHTML =
|
||||||
|
`<div class="alert alert-danger small">${esc(err.message)}</div>`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- ══════════════ FAB: Nueva Agenda ══════════════ -->
|
<!-- ══════════════ FAB: Nueva Agenda ══════════════ -->
|
||||||
<button class="fab-agenda" title="Agendar nuevo domicilio" onclick="agendaNueva.abrir()">
|
<button class="fab-agenda" title="Agendar nuevo domicilio" onclick="agendaNueva.abrir()">
|
||||||
<i class="fas fa-calendar-plus"></i>
|
<i class="fas fa-calendar-plus"></i>
|
||||||
|
|||||||
Reference in New Issue
Block a user