fix: add db() to ingest_paciente; get_examenes_rips and recepcion updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-17 15:43:08 -05:00
co-authored by Claude Sonnet 4.6
parent 6bba6c6165
commit e595f5e569
4 changed files with 138 additions and 29 deletions
+25 -5
View File
@@ -1633,8 +1633,6 @@ async function consultarExamenesRips(cedula) {
if (!d.ok || !d.encontrados?.length) return;
_ripsData = d;
const hora = d.hora ? ' (' + String(d.hora).slice(0, 5) + ')' : '';
document.getElementById('banner-rips-txt').textContent =
`${d.encontrados.length} examen(es) de RIPS${hora} — ¿Cargar?`;
const warn = document.getElementById('banner-rips-warn');
if (d.no_mapeados?.length) {
warn.textContent = `⚠ Sin mapeo: ${d.no_mapeados.join(', ')}`;
@@ -1642,14 +1640,36 @@ async function consultarExamenesRips(cedula) {
} else {
warn.classList.add('d-none');
}
document.getElementById('banner-rips').classList.remove('d-none');
// Si los exámenes vienen del cache local (enviados por RIPS scheduler) se cargan
// automáticamente. Si vienen del pull en vivo se muestra el banner para confirmación.
if (d.fuente === 'cache') {
await cargarExamenesRips();
} else {
document.getElementById('banner-rips-txt').textContent =
`${d.encontrados.length} examen(es) de RIPS${hora} — ¿Cargar?`;
document.getElementById('banner-rips').classList.remove('d-none');
}
} catch (_) {}
}
function cargarExamenesRips() {
async function cargarExamenesRips() {
if (!_ripsData?.encontrados?.length || !examTS) return;
_ripsData.encontrados.forEach(e => examTS.addItem(String(e.exam_tipo_id), true));
recalcularPrecios();
if (_ripsData.diagnostico_cod) {
document.getElementById('inp-diag').value = _ripsData.diagnostico_cod;
}
if (_ripsData.medico) {
const m = _ripsData.medico;
seleccionarMedico(m.id, m.codigo, m.nombre, m.especialidad || '');
}
if (_ripsData.empresa) {
await seleccionarEmpresa(_ripsData.empresa);
} else {
recalcularPrecios();
}
if (_ripsData.valor_total > 0) {
document.getElementById('inp-total').value = Math.round(_ripsData.valor_total);
}
descartarRips();
}