@@ -176,6 +176,16 @@ export async function buscarRecetas(req) {
176176 }
177177 recetas = recetasActualizadas ;
178178
179+ // Redactar información de recetas con diagnóstico confidencial
180+ const recetasRedactadas = [ ] ;
181+ for ( const receta of recetas ) {
182+ if ( receta . diagnosticoConfidencial ) {
183+ receta . diagnostico = { descripcion : 'Confidencial por Ley 27.675' } ;
184+ }
185+ recetasRedactadas . push ( receta ) ;
186+ }
187+ recetas = recetasRedactadas ;
188+
179189 if ( user . type === 'app-token' ) {
180190 // si es un usuario de app y no tiene nombre de sistema asignado, no se envia recetas
181191 const sistema = user . app . nombre . toLowerCase ( ) ;
@@ -537,9 +547,7 @@ export async function create(req) {
537547 paciente : null ,
538548 profesional : null ,
539549 organizacion : req . body . organizacion ,
540- diagnostoco : null ,
541550 origenExterno : null
542-
543551 } ;
544552 try {
545553 dataReceta . fechaRegistro = dataReceta . fechaRegistro ? moment ( dataReceta . fechaRegistro ) . toDate ( ) : moment ( ) . toDate ( ) ;
@@ -620,8 +628,17 @@ export async function crearReceta(dataReceta, req) {
620628 receta = new Receta ( ) ;
621629 receta . idPrestacion = dataReceta . idPrestacion ;
622630 receta . idRegistro = dataReceta . idRegistro ;
623- const diag = medicamento . diagnostico ;
624- receta . diagnostico = ( typeof diag === 'string' ) ? { descripcion : diag } : diag ;
631+ let diag = medicamento . diagnostico ;
632+ if ( typeof diag === 'string' ) {
633+ const contieneConfidencial = / ( V I H | H I V ) / i. test ( diag ) ;
634+ receta . diagnosticoConfidencial = contieneConfidencial ;
635+ diag = { descripcion : diag } ;
636+ } else if ( diag && typeof diag . term === 'string' ) {
637+ if ( / ( V I H | H I V ) / i. test ( diag . term ) ) {
638+ receta . diagnosticoConfidencial = true ;
639+ }
640+ }
641+ receta . diagnostico = diag ;
625642 receta . medicamento = {
626643 concepto : medicamento . concepto || medicamento . generico ,
627644 presentacion : medicamento . presentacion ?. term || medicamento . presentacion ,
0 commit comments