diff --git a/api/lab/get_examenes_rips.php b/api/lab/get_examenes_rips.php index 16e464a..fdc3c37 100644 --- a/api/lab/get_examenes_rips.php +++ b/api/lab/get_examenes_rips.php @@ -20,6 +20,7 @@ $cacheRow = db()->prepare( WHERE numero_documento = ? AND DATE(created_at) = CURDATE() AND created_at >= NOW() - INTERVAL 30 MINUTE + AND turno_id IS NULL ORDER BY created_at DESC LIMIT 1" ); diff --git a/api/lab/marcar_rips_usado.php b/api/lab/marcar_rips_usado.php new file mode 100644 index 0000000..10b3137 --- /dev/null +++ b/api/lab/marcar_rips_usado.php @@ -0,0 +1,26 @@ +prepare( + "UPDATE rips_examenes_pendientes + SET turno_id = ? + WHERE numero_documento = ? + AND DATE(created_at) = CURDATE() + AND turno_id IS NULL + ORDER BY created_at DESC + LIMIT 1" +)->execute([$turnoId, $cedula]); + +jsonOk(['marcado' => true]); diff --git a/modules/turnero/views/recepcion.php b/modules/turnero/views/recepcion.php index fc1cbdf..54d15cf 100644 --- a/modules/turnero/views/recepcion.php +++ b/modules/turnero/views/recepcion.php @@ -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(); }