From 5740eb6e1f079b6d67b204723e198d0a2548deaf Mon Sep 17 00:00:00 2001 From: aldoEMatamala Date: Wed, 4 Feb 2026 15:45:27 -0300 Subject: [PATCH] =?UTF-8?q?fix(IN-669):Obra=20Social:=20no=20se=20actualiz?= =?UTF-8?q?a=20el=20ingreso=20en=20capa=20estad=C3=ADstica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/rup/internacion/camas.routes.ts | 35 +++++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/modules/rup/internacion/camas.routes.ts b/modules/rup/internacion/camas.routes.ts index aa3ea0510..de46c0e49 100644 --- a/modules/rup/internacion/camas.routes.ts +++ b/modules/rup/internacion/camas.routes.ts @@ -161,7 +161,8 @@ router.patch('/camas/:id', Auth.authenticate(), capaMiddleware, asyncHandler(asy router.patch('/camaEstados/:idCama', Auth.authenticate(), capaMiddleware, asyncHandler(async (req: Request, res: Response, next) => { let result; try { - if (req.body.extras?.ingreso) { + const edicionFinanciador = req.query?.edicionFinanciador; + if (edicionFinanciador) { // Si se editan los datos de cobertura, se actualiza la obra social del paciente const pacienteMPI = await PacienteCtr.findById(req.body.paciente.id); const obraSocialUpdated = await updateObraSocial(pacienteMPI); @@ -177,14 +178,32 @@ router.patch('/camaEstados/:idCama', Auth.authenticate(), capaMiddleware, asyncH }, { arrayFilters: [{ 'elemento.valor.informeIngreso.fechaIngreso': moment(req.body.fechaIngreso).toDate() }] } ); + if (edicionFinanciador) { + result = await CamaEstados.update( + { + 'estados.idInternacion': Types.ObjectId(req.body.idInternacion) + }, + { + $set: { + 'estados.$[elemento].paciente.obraSocial': req.body.paciente.obraSocial + } + }, + { + arrayFilters: [{ 'elemento.idInternacion': Types.ObjectId(req.body.idInternacion) }], + multi: true + } + ); + } + } + if (!edicionFinanciador) { + + const organizacion = { + _id: Auth.getOrganization(req), + nombre: Auth.getOrganization(req, 'nombre') + }; + const data = { ...req.body, organizacion, id: req.params.idCama }; + result = await CamasController.patchEstados(data, req); } - - const organizacion = { - _id: Auth.getOrganization(req), - nombre: Auth.getOrganization(req, 'nombre') - }; - const data = { ...req.body, organizacion, id: req.params.idCama }; - result = await CamasController.patchEstados(data, req); } catch (err) { const dataErr = { ruta: '/camaEstados/:idCama',