Skip to content

Commit bf2dc69

Browse files
committed
fix(IN-669):Obra Social: no se actualiza el ingreso en capa estadística
1 parent a1b10c4 commit bf2dc69

1 file changed

Lines changed: 27 additions & 8 deletions

File tree

modules/rup/internacion/camas.routes.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ router.patch('/camas/:id', Auth.authenticate(), capaMiddleware, asyncHandler(asy
161161
router.patch('/camaEstados/:idCama', Auth.authenticate(), capaMiddleware, asyncHandler(async (req: Request, res: Response, next) => {
162162
let result;
163163
try {
164-
if (req.body.extras?.ingreso) {
164+
const edicionFinanciador = req.query?.edicionFinanciador;
165+
if (edicionFinanciador) {
165166
// Si se editan los datos de cobertura, se actualiza la obra social del paciente
166167
const pacienteMPI = await PacienteCtr.findById(req.body.paciente.id);
167168
const obraSocialUpdated = await updateObraSocial(pacienteMPI);
@@ -177,14 +178,32 @@ router.patch('/camaEstados/:idCama', Auth.authenticate(), capaMiddleware, asyncH
177178
},
178179
{ arrayFilters: [{ 'elemento.valor.informeIngreso.fechaIngreso': moment(req.body.fechaIngreso).toDate() }] }
179180
);
181+
if (edicionFinanciador) {
182+
result = await CamaEstados.update(
183+
{
184+
'estados.idInternacion': Types.ObjectId(req.body.idInternacion)
185+
},
186+
{
187+
$set: {
188+
'estados.$[elemento].paciente.obraSocial': req.body.paciente.obraSocial
189+
}
190+
},
191+
{
192+
arrayFilters: [{ 'elemento.idInternacion': Types.ObjectId(req.body.idInternacion) }],
193+
multi: true
194+
}
195+
);
196+
}
197+
}
198+
if (!edicionFinanciador) {
199+
200+
const organizacion = {
201+
_id: Auth.getOrganization(req),
202+
nombre: Auth.getOrganization(req, 'nombre')
203+
};
204+
const data = { ...req.body, organizacion, id: req.params.idCama };
205+
result = await CamasController.patchEstados(data, req);
180206
}
181-
182-
const organizacion = {
183-
_id: Auth.getOrganization(req),
184-
nombre: Auth.getOrganization(req, 'nombre')
185-
};
186-
const data = { ...req.body, organizacion, id: req.params.idCama };
187-
result = await CamasController.patchEstados(data, req);
188207
} catch (err) {
189208
const dataErr = {
190209
ruta: '/camaEstados/:idCama',

0 commit comments

Comments
 (0)