feat: preview muestra lista de pre-servicios con JSON expandible
- Agrega preservicios_preview al endpoint /preview con el JSON generado por cada RCXC/SC - Muestra sección naranja debajo de pacientes con factura, fecha, paciente y exámenes - Clic en cada fila despliega el JSON completo que se enviará a TNS Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c2a092c0e7
commit
648a0a1910
@@ -208,6 +208,30 @@ async def preview_automation(
|
|||||||
grupos_ps = {k: v for k, v in grupos_ps_all.items()
|
grupos_ps = {k: v for k, v in grupos_ps_all.items()
|
||||||
if str(v[0].get("CODCONTRATO") or "").strip() not in excluded}
|
if str(v[0].get("CODCONTRATO") or "").strip() not in excluded}
|
||||||
|
|
||||||
|
contrato_map = load_contrato_map()
|
||||||
|
prof_def = configs.get("profesional_defecto", "")
|
||||||
|
esp_def = configs.get("especialidad_defecto", "")
|
||||||
|
remis_def = configs.get("remisionante_defecto", "00")
|
||||||
|
prefijo_def = configs.get("prefijo_defecto", "00")
|
||||||
|
|
||||||
|
preservicios_preview = []
|
||||||
|
for id_ps, grupo_rows in grupos_ps.items():
|
||||||
|
ps_prefijo = str(grupo_rows[0].get("PS_PREFIJO") or "SC").strip()
|
||||||
|
ps_numero = str(grupo_rows[0].get("PS_NUMERO") or "").strip()
|
||||||
|
rda_json = generar_rda_paciente(
|
||||||
|
grupo_rows, prof_def, esp_def, remis_def, prefijo_def,
|
||||||
|
numero_override=ps_numero,
|
||||||
|
contrato_map=contrato_map,
|
||||||
|
prefijo_override=ps_prefijo,
|
||||||
|
)
|
||||||
|
preservicios_preview.append({
|
||||||
|
"factura": f"{ps_prefijo}-{ps_numero.zfill(5)}",
|
||||||
|
"paciente": str(grupo_rows[0].get("COD_PACIENTE", "")),
|
||||||
|
"fecha": str(grupo_rows[0].get("FECHA_RECEPCION", ""))[:10],
|
||||||
|
"examenes": len(grupo_rows),
|
||||||
|
"json": rda_json,
|
||||||
|
})
|
||||||
|
|
||||||
# Agrupar RDA por COD_PACIENTE
|
# Agrupar RDA por COD_PACIENTE
|
||||||
rda_por_pac = {}
|
rda_por_pac = {}
|
||||||
for id_rec, filas in grupos.items():
|
for id_rec, filas in grupos.items():
|
||||||
@@ -245,6 +269,7 @@ async def preview_automation(
|
|||||||
"excluidos": excluidos_count,
|
"excluidos": excluidos_count,
|
||||||
"preservicios": len(grupos_ps),
|
"preservicios": len(grupos_ps),
|
||||||
"pacientes_preview": pacientes_preview,
|
"pacientes_preview": pacientes_preview,
|
||||||
|
"preservicios_preview": preservicios_preview,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,10 @@
|
|||||||
<p class="text-xs font-medium text-gray-600 mb-2">Pacientes — clic para ver sus recepciones:</p>
|
<p class="text-xs font-medium text-gray-600 mb-2">Pacientes — clic para ver sus recepciones:</p>
|
||||||
<div id="preview-table" class="border border-gray-100 rounded-lg overflow-hidden text-sm"></div>
|
<div id="preview-table" class="border border-gray-100 rounded-lg overflow-hidden text-sm"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="preservicios-section" class="hidden">
|
||||||
|
<p class="text-xs font-medium text-orange-600 mb-2 mt-2">Pre-servicios RCXC / SC — clic para ver JSON:</p>
|
||||||
|
<div id="preview-ps-table" class="border border-orange-100 rounded-lg overflow-hidden text-sm"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -206,6 +210,26 @@ async function previewAutomation() {
|
|||||||
document.getElementById('cnt-preservicios').textContent = data.preservicios || 0;
|
document.getElementById('cnt-preservicios').textContent = data.preservicios || 0;
|
||||||
document.getElementById('preview-fecha').textContent = data.fecha;
|
document.getElementById('preview-fecha').textContent = data.fecha;
|
||||||
|
|
||||||
|
const psTable = document.getElementById('preview-ps-table');
|
||||||
|
const psSection = document.getElementById('preservicios-section');
|
||||||
|
if (data.preservicios_preview && data.preservicios_preview.length > 0) {
|
||||||
|
psTable.innerHTML = data.preservicios_preview.map((ps, i) => `
|
||||||
|
<div class="divide-y divide-orange-50">
|
||||||
|
<div class="flex items-center gap-3 px-4 py-2.5 hover:bg-orange-50 cursor-pointer select-none"
|
||||||
|
onclick="togglePs('ps-json-${i}', this)">
|
||||||
|
<i class="fas fa-chevron-right text-orange-300 text-xs transition-transform duration-150" id="pschev-${i}"></i>
|
||||||
|
<span class="font-mono text-orange-700 font-medium w-32">${ps.factura}</span>
|
||||||
|
<span class="text-gray-500 w-24 text-xs">${ps.fecha}</span>
|
||||||
|
<span class="text-gray-600 flex-1 text-xs">Pac. ${ps.paciente}</span>
|
||||||
|
<span class="text-xs text-orange-500">${ps.examenes} examen(es)</span>
|
||||||
|
</div>
|
||||||
|
<div id="ps-json-${i}" class="hidden bg-gray-900 text-green-300 text-xs font-mono p-4 overflow-x-auto whitespace-pre">${JSON.stringify(ps.json, null, 2)}</div>
|
||||||
|
</div>`).join('');
|
||||||
|
psSection.classList.remove('hidden');
|
||||||
|
} else {
|
||||||
|
psSection.classList.add('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
const table = document.getElementById('preview-table');
|
const table = document.getElementById('preview-table');
|
||||||
if (data.pacientes === 0) {
|
if (data.pacientes === 0) {
|
||||||
table.innerHTML = '<div class="p-4 text-gray-400 text-center">No hay pacientes para esta fecha</div>';
|
table.innerHTML = '<div class="p-4 text-gray-400 text-center">No hay pacientes para esta fecha</div>';
|
||||||
@@ -340,6 +364,14 @@ function toggleRda(id, row) {
|
|||||||
if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : '';
|
if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function togglePs(id, row) {
|
||||||
|
const div = document.getElementById(id);
|
||||||
|
const chev = row.querySelector('[id^="pschev-"]');
|
||||||
|
const hidden = div.classList.contains('hidden');
|
||||||
|
div.classList.toggle('hidden', !hidden);
|
||||||
|
if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : '';
|
||||||
|
}
|
||||||
|
|
||||||
function renderBadge(id, enviados, errores) {
|
function renderBadge(id, enviados, errores) {
|
||||||
const el = document.getElementById(id);
|
const el = document.getElementById(id);
|
||||||
if (errores === 0) {
|
if (errores === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user