From 5212d3849f165b65c4fad08967968789a632a644 Mon Sep 17 00:00:00 2001 From: aldoEMatamala Date: Tue, 21 Apr 2026 12:07:07 -0300 Subject: [PATCH] feat(CIT-403) Cargar solicitudes de pacientes unificados en punto de inicio --- modules/rup/routes/prestacion.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/rup/routes/prestacion.ts b/modules/rup/routes/prestacion.ts index febf893729..937629cbfe 100755 --- a/modules/rup/routes/prestacion.ts +++ b/modules/rup/routes/prestacion.ts @@ -258,7 +258,20 @@ router.get('/prestaciones/solicitudes', async (req: any, res, next) => { if (req.query.idPaciente) { indice = undefined; - match.$and.push({ 'paciente.id': Types.ObjectId(req.query.idPaciente) }); + if (String(req.query.agregarVinculados) === 'true') { + const paciente = await PacienteCtr.findById(req.query.idPaciente); + const idsAndes = [Types.ObjectId(req.query.idPaciente)]; + if (paciente && paciente.identificadores) { + paciente.identificadores.forEach((identificador: any) => { + if (identificador.entidad === 'ANDES' && Types.ObjectId.isValid(identificador.valor)) { + idsAndes.push(Types.ObjectId(identificador.valor)); + } + }); + } + match.$and.push({ 'paciente.id': { $in: idsAndes } }); + } else { + match.$and.push({ 'paciente.id': Types.ObjectId(req.query.idPaciente) }); + } } if (req.query.idProfesional) {