From 43e9cf1694c50301e6831e4a0ffd957c39c94536 Mon Sep 17 00:00:00 2001 From: aldoEMatamala Date: Wed, 4 Feb 2026 15:45:27 -0300 Subject: [PATCH 1/2] =?UTF-8?q?fix(IN-669):Obra=20Social:=20no=20se=20actu?= =?UTF-8?q?aliza=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 aa3ea0510e..de46c0e49d 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', From 623f0256a559a26ab31d8535e68e6a6cdf7d91b7 Mon Sep 17 00:00:00 2001 From: laucharin Date: Fri, 11 Sep 2026 13:10:38 -0300 Subject: [PATCH 2/2] elimina condicion redundante --- modules/rup/internacion/camas.routes.ts | 38 ++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/rup/internacion/camas.routes.ts b/modules/rup/internacion/camas.routes.ts index de46c0e49d..d42f3b41cc 100644 --- a/modules/rup/internacion/camas.routes.ts +++ b/modules/rup/internacion/camas.routes.ts @@ -178,30 +178,30 @@ 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 + result = await CamaEstados.update( + { + 'estados.idInternacion': Types.ObjectId(req.body.idInternacion) + }, + { + $set: { + 'estados.$[elemento].paciente.obraSocial': req.body.paciente.obraSocial } - ); - } - } - if (!edicionFinanciador) { - + }, + { + arrayFilters: [{ 'elemento.idInternacion': Types.ObjectId(req.body.idInternacion) }], + multi: true + } + ); + } else { const organizacion = { _id: Auth.getOrganization(req), nombre: Auth.getOrganization(req, 'nombre') }; - const data = { ...req.body, organizacion, id: req.params.idCama }; + const data = { + ...req.body, + organizacion, + id: req.params.idCama + }; result = await CamasController.patchEstados(data, req); } } catch (err) {