up
This commit is contained in:
@@ -583,8 +583,32 @@ function abrirFicha(turno) {
|
||||
document.getElementById('btn-guardar').disabled = false;
|
||||
desvincularPaciente();
|
||||
|
||||
// Buscar consentimientos si ya tiene solicitud
|
||||
verificarSolicitudExistente(turno.id);
|
||||
// Auto-vincular paciente si ya viene con ID desde el kiosko
|
||||
if (turno.paciente_id) {
|
||||
fetch(`${API_PAC}?id=${turno.paciente_id}`)
|
||||
.then(r => r.json())
|
||||
.then(json => {
|
||||
const data = (json.data || json.registros || [])[0];
|
||||
if (data && !pacienteActivo) seleccionarPaciente(data);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
// Cargar consentimientos anticipados (principal y otros ya creados)
|
||||
cargarConsentimientosTurno(turno.id);
|
||||
}
|
||||
|
||||
async function cargarConsentimientosTurno(turnoId) {
|
||||
try {
|
||||
const res = await fetch(`${API}get_consentimientos.php?turno_id=${turnoId}`);
|
||||
const json = await res.json();
|
||||
if (json.ok && json.consentimientos?.length) {
|
||||
consentimientos = json.consentimientos;
|
||||
renderConsentimientos(consentimientos);
|
||||
document.getElementById('sec-consentimientos').style.display = '';
|
||||
document.getElementById('btn-reenviar-consent').classList.remove('d-none');
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
async function verificarSolicitudExistente(turnoId) {
|
||||
|
||||
Reference in New Issue
Block a user