agendar domicilio: inputs editables para nombre y cédula del paciente
This commit is contained in:
+69
-26
@@ -6686,13 +6686,27 @@ if (!isUserLoggedIn()) {
|
||||
|
||||
<!-- Tarjeta paciente seleccionado (visible cuando SÍ hay paciente) -->
|
||||
<div id="labdom-pac-card" class="d-none">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<div class="rounded-circle bg-primary text-white d-flex align-items-center justify-content-center flex-shrink-0" style="width:36px;height:36px;font-size:1rem">
|
||||
<div class="d-flex align-items-start gap-2">
|
||||
<div class="rounded-circle bg-primary text-white d-flex align-items-center justify-content-center flex-shrink-0 mt-1" style="width:36px;height:36px;font-size:1rem">
|
||||
<i class="fas fa-user"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p class="mb-0 fw-bold" id="labdom-pac-nombre"></p>
|
||||
<small id="labdom-pac-info" class="text-muted"></small>
|
||||
<div class="flex-grow-1">
|
||||
<input type="text" class="form-control form-control-sm fw-semibold mb-1" id="labdom-pac-nombre" placeholder="Nombre completo *" autocomplete="off">
|
||||
<div class="row g-1">
|
||||
<div class="col-5">
|
||||
<select class="form-select form-select-sm" id="labdom-pac-tipodoc" title="Tipo de documento">
|
||||
<option value="CC">CC - Cédula</option>
|
||||
<option value="TI">TI - Tarjeta</option>
|
||||
<option value="CE">CE - Extran.</option>
|
||||
<option value="PA">PA - Pasap.</option>
|
||||
<option value="NIT">NIT</option>
|
||||
<option value="RC">RC - Nac.</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-7">
|
||||
<input type="text" class="form-control form-control-sm" id="labdom-pac-cedula" placeholder="N.° documento" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Datos de contacto del paciente -->
|
||||
@@ -6975,6 +6989,9 @@ const labDomicilio = (() => {
|
||||
$('labdom-hist-cont').classList.add('d-none');
|
||||
$('labdom-hist-chips').innerHTML = '';
|
||||
$('labdom-header-pac').textContent = '';
|
||||
if ($('labdom-pac-nombre')) $('labdom-pac-nombre').value = '';
|
||||
if ($('labdom-pac-cedula')) $('labdom-pac-cedula').value = '';
|
||||
if ($('labdom-pac-tipodoc')) $('labdom-pac-tipodoc').value = 'CC';
|
||||
// Resetear tipo cliente a "particular" por defecto
|
||||
const tc = document.getElementById('tc-particular');
|
||||
if (tc) tc.checked = true;
|
||||
@@ -7117,6 +7134,8 @@ const labDomicilio = (() => {
|
||||
data-dir="${escAtr(p.direccion||'')}"
|
||||
data-ciudad="${escAtr(p.ciudad||'')}"
|
||||
data-info="${escAtr((p.tipo_documento||'') + ' ' + (p.numero_documento||''))}"
|
||||
data-tipodoc="${escAtr(p.tipo_documento||'')}"
|
||||
data-numdoc="${escAtr(p.numero_documento||'')}"
|
||||
data-tel="${escAtr(p.telefono||'')}"
|
||||
data-email="${escAtr(p.email||'')}"
|
||||
data-eps="${escAtr(p.eps||'')}"
|
||||
@@ -7138,24 +7157,32 @@ const labDomicilio = (() => {
|
||||
btn.dataset.dir,
|
||||
btn.dataset.ciudad,
|
||||
btn.dataset.info,
|
||||
btn.dataset.tel || '',
|
||||
btn.dataset.email || '',
|
||||
btn.dataset.eps || '',
|
||||
btn.dataset.fnac || ''
|
||||
btn.dataset.tel || '',
|
||||
btn.dataset.email || '',
|
||||
btn.dataset.eps || '',
|
||||
btn.dataset.fnac || '',
|
||||
btn.dataset.tipodoc || '',
|
||||
btn.dataset.numdoc || ''
|
||||
);
|
||||
},
|
||||
|
||||
selPaciente(id, nombre, direccion, ciudad, info, tel = '', email = '', eps = '', fechaNac = '') {
|
||||
selPaciente(id, nombre, direccion, ciudad, info, tel = '', email = '', eps = '', fechaNac = '', tipoDoc = '', numDoc = '') {
|
||||
_pacienteId = id;
|
||||
_pacNombre = nombre;
|
||||
|
||||
// Extraer tipo/num del campo 'info' como fallback si no se pasan explícitamente
|
||||
const _infoMatch = (info||'').match(/^([A-Z]+)\s*(.*)/);
|
||||
const _tipoFinal = tipoDoc || (_infoMatch?.[1] || 'CC');
|
||||
const _numFinal = numDoc || (_infoMatch?.[2]?.trim() || '');
|
||||
|
||||
// Ocultar buscador, mostrar tarjeta
|
||||
$('labdom-pac-list').style.display = 'none';
|
||||
$('labdom-pac-buscar').classList.add('d-none');
|
||||
$('labdom-pac-card').classList.remove('d-none');
|
||||
$('labdom-btn-cambiar-pac').classList.remove('d-none');
|
||||
$('labdom-pac-nombre').textContent = nombre;
|
||||
$('labdom-pac-info').textContent = info || '';
|
||||
if ($('labdom-pac-nombre')) $('labdom-pac-nombre').value = nombre;
|
||||
if ($('labdom-pac-cedula')) $('labdom-pac-cedula').value = _numFinal;
|
||||
if ($('labdom-pac-tipodoc')) $('labdom-pac-tipodoc').value = _tipoFinal;
|
||||
$('labdom-header-pac').textContent = nombre;
|
||||
|
||||
// Mostrar datos de contacto
|
||||
@@ -7197,6 +7224,9 @@ const labDomicilio = (() => {
|
||||
$('labdom-header-pac').textContent = '';
|
||||
if ($('labdom-pac-fnac')) $('labdom-pac-fnac').value = '';
|
||||
if ($('labdom-pac-correo')) $('labdom-pac-correo').value = '';
|
||||
if ($('labdom-pac-nombre')) $('labdom-pac-nombre').value = '';
|
||||
if ($('labdom-pac-cedula')) $('labdom-pac-cedula').value = '';
|
||||
if ($('labdom-pac-tipodoc')) $('labdom-pac-tipodoc').value = 'CC';
|
||||
// Mantener dirección/notas para no perder lo escrito
|
||||
},
|
||||
|
||||
@@ -7247,7 +7277,9 @@ const labDomicilio = (() => {
|
||||
d.paciente.telefono || '',
|
||||
d.paciente.email || '',
|
||||
d.paciente.eps || '',
|
||||
d.paciente.fecha_nacimiento || ''
|
||||
d.paciente.fecha_nacimiento || '',
|
||||
d.paciente.tipo_documento || '',
|
||||
d.paciente.numero_documento || ''
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -7337,13 +7369,23 @@ const labDomicilio = (() => {
|
||||
const d = await r.json();
|
||||
|
||||
if (d.success) {
|
||||
// Actualizar datos del paciente (fecha nacimiento / correo) si se completaron
|
||||
const updFnac = fv('labdom-pac-fnac');
|
||||
const updCorreo = fv('labdom-pac-correo');
|
||||
if (_pacienteId && (updFnac || updCorreo)) {
|
||||
// Actualizar _pacNombre si el usuario editó el nombre en el input
|
||||
const _editedNombre = fv('labdom-pac-nombre');
|
||||
if (_editedNombre) _pacNombre = _editedNombre;
|
||||
|
||||
// Actualizar datos del paciente (nombre, cédula, fecha nacimiento, correo)
|
||||
const updFnac = fv('labdom-pac-fnac');
|
||||
const updCorreo = fv('labdom-pac-correo');
|
||||
const updNombre = fv('labdom-pac-nombre');
|
||||
const updCedula = fv('labdom-pac-cedula');
|
||||
const updTipodoc = $('labdom-pac-tipodoc')?.value || '';
|
||||
if (_pacienteId && (updFnac || updCorreo || updNombre || updCedula)) {
|
||||
const patch = { id: _pacienteId };
|
||||
if (updFnac) patch.fecha_nacimiento = updFnac;
|
||||
if (updCorreo) patch.email = updCorreo;
|
||||
if (updFnac) patch.fecha_nacimiento = updFnac;
|
||||
if (updCorreo) patch.email = updCorreo;
|
||||
if (updNombre) patch.nombre_completo = updNombre;
|
||||
if (updCedula) patch.numero_documento = updCedula;
|
||||
if (updTipodoc) patch.tipo_documento = updTipodoc;
|
||||
fetch('api/lab/save_paciente.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -7440,7 +7482,7 @@ const labDomicilio = (() => {
|
||||
getPacienteId() { return _pacienteId || 0; },
|
||||
getPacienteNombre() {
|
||||
const el = document.getElementById('labdom-pac-nombre');
|
||||
return el ? el.textContent.trim() : '';
|
||||
return el ? (el.value !== undefined ? el.value.trim() : el.textContent.trim()) : '';
|
||||
},
|
||||
|
||||
/* ─────────────────────────────────────────────────────────────────
|
||||
@@ -7473,8 +7515,8 @@ const labDomicilio = (() => {
|
||||
newOrderFile: _newOrderFile,
|
||||
cardVisible: !document.getElementById('labdom-pac-card')?.classList.contains('d-none'),
|
||||
pacInfo: {
|
||||
nombre: document.getElementById('labdom-pac-nombre')?.textContent || '',
|
||||
info: document.getElementById('labdom-pac-info')?.textContent || '',
|
||||
nombre: document.getElementById('labdom-pac-nombre')?.value || '',
|
||||
info: [document.getElementById('labdom-pac-tipodoc')?.value, document.getElementById('labdom-pac-cedula')?.value].filter(Boolean).join(' ') || '',
|
||||
tel: document.getElementById('labdom-pac-tel')?.textContent || '',
|
||||
email: document.getElementById('labdom-pac-email')?.textContent || '',
|
||||
eps: document.getElementById('labdom-pac-eps')?.textContent || '',
|
||||
@@ -7487,7 +7529,8 @@ const labDomicilio = (() => {
|
||||
'labdom-ciudad','labdom-indicaciones','labdom-examenes','labdom-notas',
|
||||
'labdom-seguro-nombre','labdom-autorizacion','labdom-copago',
|
||||
'labdom-valor-domicilio','labdom-valor-copago','labdom-pac-fnac',
|
||||
'labdom-pac-correo','labdom-pac-busq'].forEach(id => {
|
||||
'labdom-pac-correo','labdom-pac-busq','labdom-pac-nombre','labdom-pac-cedula',
|
||||
'labdom-pac-tipodoc'].forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) sesion.fields[id] = el.value;
|
||||
});
|
||||
@@ -7566,7 +7609,8 @@ const labDomicilio = (() => {
|
||||
'labdom-ciudad','labdom-indicaciones','labdom-examenes','labdom-notas',
|
||||
'labdom-seguro-nombre','labdom-autorizacion','labdom-copago',
|
||||
'labdom-valor-domicilio','labdom-valor-copago','labdom-pac-fnac',
|
||||
'labdom-pac-correo','labdom-pac-busq'].forEach(id => {
|
||||
'labdom-pac-correo','labdom-pac-busq','labdom-pac-nombre','labdom-pac-cedula',
|
||||
'labdom-pac-tipodoc'].forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el && f[id] !== undefined) el.value = f[id];
|
||||
});
|
||||
@@ -7580,8 +7624,7 @@ const labDomicilio = (() => {
|
||||
$('labdom-pac-buscar')?.classList.add('d-none');
|
||||
$('labdom-pac-card')?.classList.remove('d-none');
|
||||
$('labdom-btn-cambiar-pac')?.classList.remove('d-none');
|
||||
if ($('labdom-pac-nombre')) $('labdom-pac-nombre').textContent = sesion.pacInfo.nombre;
|
||||
if ($('labdom-pac-info')) $('labdom-pac-info').textContent = sesion.pacInfo.info;
|
||||
if ($('labdom-pac-nombre')) $('labdom-pac-nombre').value = sesion.pacInfo.nombre || f['labdom-pac-nombre'] || '';
|
||||
if ($('labdom-header-pac')) $('labdom-header-pac').textContent = sesion.pacNombre;
|
||||
if ($('labdom-pac-tel')) $('labdom-pac-tel').textContent = sesion.pacInfo.tel;
|
||||
if ($('labdom-pac-email')) $('labdom-pac-email').textContent = sesion.pacInfo.email;
|
||||
|
||||
Reference in New Issue
Block a user