From dba7492cd7ed62c6b4c0aff81f09bb9f491756c4 Mon Sep 17 00:00:00 2001 From: laucharin Date: Fri, 6 Feb 2026 10:57:11 -0300 Subject: [PATCH 1/2] ref(HUDS): incluye vinculaciones en la busqueda de prestaciones --- .../huds/export-huds/exportHuds.controller.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/huds/export-huds/exportHuds.controller.ts b/modules/huds/export-huds/exportHuds.controller.ts index 1f20a37264..0d37291a44 100644 --- a/modules/huds/export-huds/exportHuds.controller.ts +++ b/modules/huds/export-huds/exportHuds.controller.ts @@ -7,7 +7,7 @@ import { Prestacion } from '../../rup/schemas/prestacion'; import { exportHudsLog } from './exportHuds.log'; import { ExportHudsModel } from './exportHuds.schema'; import { getHUDSExportarModel } from './hudsFiles'; - +import { Paciente } from '../../../core-v2/mpi'; import moment = require('moment'); export async function createFile(idExportHuds) { @@ -19,14 +19,21 @@ export async function createFile(idExportHuds) { if (peticionExport.prestaciones.length) { prestaciones = await Prestacion.find({ _id: { $in: peticionExport.prestaciones } }); } else { + // recuperamos las posibles vinculaciones del paciente para traer también todas las prestaciones asociadas a esas vinculaciones + const paciente = await Paciente.findById(peticionExport.pacienteId); + const vinculacionesPaciente = paciente.identificadores + .filter(item => item.entidad === 'ANDES' && item.valor?.length) + .map(item => item.valor); + const idsPaciente = [...vinculacionesPaciente, peticionExport.pacienteId]; const query = { - 'paciente.id': peticionExport.pacienteId, + 'paciente.id': { $in: idsPaciente }, 'estadoActual.tipo': 'validada' }; + if (peticionExport.fechaDesde && peticionExport.fechaHasta) { fechaCondicion = { - $gte: moment(peticionExport.fechaDesde).startOf('day').toDate(), - $lte: moment(peticionExport.fechaHasta).endOf('day').toDate() + $gte: moment(peticionExport.fechaDesde), + $lte: moment(peticionExport.fechaHasta) }; query['ejecucion.fecha'] = fechaCondicion; } @@ -36,7 +43,7 @@ export async function createFile(idExportHuds) { prestaciones = await Prestacion.find(query); const queryCda = { - 'metadata.paciente': peticionExport.pacienteId, + 'metadata.paciente': { $in: idsPaciente }, 'metadata.prestacion.snomed.conceptId': { $ne: '2881000013106' }, }; if (fechaCondicion) { From 8d89c5c321c5afde4ae5645468dfc7e5eeb5b360 Mon Sep 17 00:00:00 2001 From: laucharin Date: Tue, 10 Feb 2026 13:01:21 -0300 Subject: [PATCH 2/2] considera pacientes con atributo "identificadores" en null --- modules/huds/export-huds/exportHuds.controller.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/huds/export-huds/exportHuds.controller.ts b/modules/huds/export-huds/exportHuds.controller.ts index 0d37291a44..490021ea33 100644 --- a/modules/huds/export-huds/exportHuds.controller.ts +++ b/modules/huds/export-huds/exportHuds.controller.ts @@ -22,9 +22,9 @@ export async function createFile(idExportHuds) { // recuperamos las posibles vinculaciones del paciente para traer también todas las prestaciones asociadas a esas vinculaciones const paciente = await Paciente.findById(peticionExport.pacienteId); const vinculacionesPaciente = paciente.identificadores - .filter(item => item.entidad === 'ANDES' && item.valor?.length) - .map(item => item.valor); - const idsPaciente = [...vinculacionesPaciente, peticionExport.pacienteId]; + ?.filter(item => item.entidad === 'ANDES' && item.valor?.length) + ?.map(item => item.valor); + const idsPaciente = vinculacionesPaciente?.length ? [...vinculacionesPaciente, peticionExport.pacienteId] : [peticionExport.pacienteId]; const query = { 'paciente.id': { $in: idsPaciente }, 'estadoActual.tipo': 'validada'