rips: prevent reuse of already-consumed exam records

- Add turno_id column to rips_examenes_pendientes (already migrated)
- Filter turno_id IS NULL in get_examenes_rips.php query
- New marcar_rips_usado.php marks record as consumed when loaded
- cargarExamenesRips() calls marker after loading exams into the turn

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-21 16:39:22 -05:00
co-authored by Claude Sonnet 4.6
parent d46c983776
commit 26bb9e1844
3 changed files with 37 additions and 0 deletions
+10
View File
@@ -1707,6 +1707,16 @@ async function cargarExamenesRips() {
if (_ripsData.valor_total > 0) {
document.getElementById('inp-total').value = Math.round(_ripsData.valor_total);
}
// Marcar registro RIPS como consumido para no reutilizarlo en otro turno
const cedula = pacienteActivo?.numero_documento || pacienteActivo?.documento
|| turnoActivo?.paciente_nombre || '';
if (cedula && turnoActivo?.id) {
fetch(`${BASE_WA}api/lab/marcar_rips_usado.php`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ cedula, turno_id: turnoActivo.id }),
}).catch(() => {});
}
descartarRips();
}