From 65362447bb3df5e1c60856454fa92e95d47ac8ae Mon Sep 17 00:00:00 2001 From: AgustinRodriguez-Andes <63318331+agustin1996ra@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:09:18 -0300 Subject: [PATCH] (fix): Limpiar campo nota --- sip-plus-perinatal/controller/sip-plus.ts | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sip-plus-perinatal/controller/sip-plus.ts b/sip-plus-perinatal/controller/sip-plus.ts index a93249a..6e1c79f 100644 --- a/sip-plus-perinatal/controller/sip-plus.ts +++ b/sip-plus-perinatal/controller/sip-plus.ts @@ -252,7 +252,7 @@ async function completeData(allData, dataInit = {}, newData) { if (valor) { const type = data.sipPlus.type.toUpperCase(); datos[data.sipPlus.code] = (type === 'TEXT') - ? valor.toString() : + ? valor.toString().normalize("NFD").replace(/[\u0300-\u036f]/g, ""): (type === 'NUMERIC') ? parseInt(valor, 10) : (type === 'DATE') ? moment(valor).format('DD/MM/YY') : valor; } @@ -390,12 +390,22 @@ async function createMatchControl(registros: any[], embActual, newDatosEmb, fech return newDatosEmb; } +function sanitizeText(input: string): string { + return input + .normalize("NFD") + .replace(/[\u0300-\u036f]/g, '') + .replace(/<[^>]*>/g, ' ') + .replace(/ |&|<|>|"|'/g, ' ') + .replace(/\s+/g, ' ') + .trim(); +} + async function mappingSnomed(matchPrenatal: IPerinatal[], registros: any[], newData) { matchPrenatal.forEach(idMatch => { const reg = registros.find(reg => reg.concepto.conceptId === idMatch.concepto.conceptId); if (reg && reg.valor) { const type = idMatch.sipPlus.type.toUpperCase(); - let valorSP = null; + let valorSP: string | number | null = null; if (type === 'DATE') { valorSP = moment(reg.valor.toString()).format('DD/MM/YY'); } @@ -405,18 +415,12 @@ async function mappingSnomed(matchPrenatal: IPerinatal[], registros: any[], newD if (type === 'TEXT') { let arrayKeyValor = Object.keys(reg.valor); if ((typeof reg.valor !== 'string') && arrayKeyValor.length) { - const valor = idMatch.sipPlus.valor ? idMatch.sipPlus.valor.find(v => v.id === reg.valor.id) : null; valorSP = valor ? valor.label.toString() : null; } else { - // eliminamos texto HTML si lo tiene - valorSP = reg.valor.replace(/(<([^>]+)>)/gi, ''); - if (idMatch.sipPlus.extra) { - // verificamos si se restringe por longitud de caracteres - const length = idMatch.sipPlus.extra.length || valorSP.length; - valorSP = valorSP.substr(0, length); - } + const limpio = sanitizeText(reg.valor.toString()); + valorSP = idMatch.sipPlus.extra?.length ? limpio.slice(0, idMatch.sipPlus.extra.length) : limpio; } } if (valorSP) {