fix: selects de EPS/ciudad no pierden valor si el paciente tiene texto fuera del catálogo
Si eps o ciudad del paciente no existe en el select, se agrega como opción temporal para no sobrescribir con vacío al guardar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
4cb1a135b3
commit
1237552cb2
@@ -2630,6 +2630,16 @@ async function abrirModalPaciente(id, nombrePrefill) {
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function _selectOrAdd(selId, val) {
|
||||
const sel = document.getElementById(selId);
|
||||
if (!val) { sel.value = ''; return; }
|
||||
if ([...sel.options].some(o => o.value === val)) { sel.value = val; return; }
|
||||
const o = document.createElement('option');
|
||||
o.value = val; o.textContent = val;
|
||||
sel.appendChild(o);
|
||||
sel.value = val;
|
||||
}
|
||||
|
||||
function mpacRellenar(p) {
|
||||
document.getElementById('mpac-id').value = p.id;
|
||||
document.getElementById('mpac-nombre').value = p.nombre_completo || '';
|
||||
@@ -2638,8 +2648,8 @@ function mpacRellenar(p) {
|
||||
document.getElementById('mpac-fnac').value = (p.fecha_nacimiento || '').slice(0, 10);
|
||||
document.getElementById('mpac-email').value = p.email || '';
|
||||
document.getElementById('mpac-genero').value = p.genero || '';
|
||||
document.getElementById('mpac-eps').value = p.eps || '';
|
||||
document.getElementById('mpac-ciudad').value = p.ciudad || 'Cúcuta';
|
||||
_selectOrAdd('mpac-eps', p.eps || '');
|
||||
_selectOrAdd('mpac-ciudad', p.ciudad || 'Cúcuta');
|
||||
document.getElementById('mpac-barrio').value = p.barrio || '';
|
||||
document.getElementById('mpac-dir').value = p.direccion || '';
|
||||
document.getElementById('mpac-notas').value = p.notas_admin || '';
|
||||
|
||||
Reference in New Issue
Block a user