feat: CRUD de ciudades + select en modal de paciente
- Tabla lab_ciudades creada y poblada con 86 ciudades existentes - Módulo lab_ciudades: listado, crear, editar, activar/desactivar, eliminar - API /api/lab/ciudades.php: GET list, POST save/toggle/delete - Modal paciente: campo ciudad cambiado a select, cargado junto con EPS en un solo Promise.all al iniciar; Cúcuta preseleccionada por defecto Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
da2bfde38f
commit
4cb1a135b3
@@ -1008,7 +1008,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control form-control-sm" id="mpac-ciudad" placeholder="Ciudad" value="Cúcuta">
|
||||
<select class="form-select form-select-sm" id="mpac-ciudad">
|
||||
<option value="Cúcuta">Cúcuta</option>
|
||||
</select>
|
||||
<label>Ciudad</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2326,17 +2328,29 @@ function fmt(n) {
|
||||
|
||||
const BASE_URL_API_LAB = '<?= BASE_URL ?>/api/lab/';
|
||||
|
||||
// ── Cargar EPS una vez al inicio ─────────────────────────────
|
||||
// ── Cargar EPS y ciudades una vez al inicio ───────────────────
|
||||
(async function() {
|
||||
try {
|
||||
const r = await fetch(BASE_URL_API_LAB + 'eps.php?action=list&solo_activas=1');
|
||||
const j = await r.json();
|
||||
if (!j.ok) return;
|
||||
const sel = document.getElementById('mpac-eps');
|
||||
(j.eps || []).forEach(e => {
|
||||
const [rEps, rCiu] = await Promise.all([
|
||||
fetch(BASE_URL_API_LAB + 'eps.php?action=list&solo_activas=1'),
|
||||
fetch(BASE_URL_API_LAB + 'ciudades.php?action=list&solo_activas=1'),
|
||||
]);
|
||||
const [jEps, jCiu] = await Promise.all([rEps.json(), rCiu.json()]);
|
||||
|
||||
const selEps = document.getElementById('mpac-eps');
|
||||
(jEps.eps || []).forEach(e => {
|
||||
const o = document.createElement('option');
|
||||
o.value = e.nombre; o.textContent = e.nombre;
|
||||
sel.appendChild(o);
|
||||
selEps.appendChild(o);
|
||||
});
|
||||
|
||||
const selCiu = document.getElementById('mpac-ciudad');
|
||||
selCiu.innerHTML = '<option value="">— Seleccionar —</option>';
|
||||
(jCiu.ciudades || []).forEach(c => {
|
||||
const o = document.createElement('option');
|
||||
o.value = c.nombre; o.textContent = c.nombre;
|
||||
if (c.nombre === 'Cúcuta') o.selected = true;
|
||||
selCiu.appendChild(o);
|
||||
});
|
||||
} catch(_) {}
|
||||
})();
|
||||
@@ -2572,7 +2586,8 @@ async function abrirModalPaciente(id, nombrePrefill) {
|
||||
document.getElementById('mpac-avatar').textContent = '?';
|
||||
document.getElementById('mpac-wa-badge').innerHTML = '';
|
||||
document.getElementById('mpac-user-id').value = '';
|
||||
document.getElementById('mpac-ciudad').value = 'Cúcuta';
|
||||
document.getElementById('mpac-ciudad').value = 'Cúcuta';
|
||||
document.getElementById('mpac-eps').value = '';
|
||||
|
||||
if (id) {
|
||||
document.getElementById('mpac-titulo').textContent = 'Cargando…';
|
||||
|
||||
Reference in New Issue
Block a user