diff --git a/app/templates/automation.html b/app/templates/automation.html
index 5f68cef..00c3283 100644
--- a/app/templates/automation.html
+++ b/app/templates/automation.html
@@ -218,18 +218,22 @@ async function previewAutomation() {
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) => `
+ psTable.innerHTML = data.preservicios_preview.map((ps, i) => {
+ const key = `ps-json-${i}`;
+ _rdaJsonStore[key] = ps.json;
+ return `
+ onclick="togglePs('${key}', this)">
${ps.factura}
${ps.fecha}
Pac. ${ps.paciente}
${ps.examenes} examen(es)
-
${JSON.stringify(ps.json, null, 2)}
-
`).join('');
+
+ `;
+ }).join('');
psSection.classList.remove('hidden');
} else {
psSection.classList.add('hidden');
@@ -394,6 +398,9 @@ function togglePs(id, row) {
const div = document.getElementById(id);
const chev = row.querySelector('[id^="pschev-"]');
const hidden = div.classList.contains('hidden');
+ if (hidden && _rdaJsonStore[id]) {
+ div.textContent = JSON.stringify(_rdaJsonStore[id], null, 2);
+ }
div.classList.toggle('hidden', !hidden);
if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : '';
}