Skip to content

Commit

Permalink
correcciones
Browse files Browse the repository at this point in the history
  • Loading branch information
negro89 authored and silviroa committed Nov 28, 2023
1 parent db39cd8 commit 7ddf91a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
15 changes: 13 additions & 2 deletions modules/rup/internacion/camas.controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,17 @@ describe('Internacion - camas', () => {
expect(maquinaEstados.createdAt).toBeDefined();
expect(maquinaEstados.createdBy.nombre).toBe(REQMock.user.usuario.nombre);

let camaEncontrada = await findById({ organizacion: organizacion._id, capa, ambito }, idCama, moment().subtract(1, 'minutes').toDate());
const estados = await patchEstados({
organizacion: cama.organizacion,
id: idCama,
esMovimiento: true,
ambito,
capa,
estado: 'inactiva',
fecha: moment().subtract(3, 'minute').toDate()
}, REQMock);

let camaEncontrada: any = await findById({ organizacion: organizacion._id, capa, ambito }, idCama, moment().subtract(1, 'minutes').toDate());
expect(camaEncontrada.estado).toBe('inactiva');

const resultNull = await patchEstados({
Expand Down Expand Up @@ -303,7 +313,8 @@ describe('Internacion - camas', () => {
term: 'servicio de adicciones',
conceptId: '4561000013103',
semanticTag: 'medio ambiente'
}
},
idInternacion: '57f67a7ad86d9f64130a138d'
}, REQMock);


Expand Down
2 changes: 1 addition & 1 deletion modules/rup/internacion/camas.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export async function patchEstados(data: Partial<ICama>, req: Request) {
}
return nuevoEstado;
}
await logger.info('patchEstados', { info: 'cambio no permitido', fecha: moment().toDate(), estadoAnterior: estadoCama, nuevoEstado: data }, req);
logger.info('patchEstados', { info: 'cambio no permitido', fecha: moment().toDate(), estadoAnterior: estadoCama, nuevoEstado: data }, req);

return null;
}
Expand Down
5 changes: 3 additions & 2 deletions modules/rup/internacion/camas.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ router.get('/camas', Auth.authenticate(), capaMiddleware, asyncHandler(async (re
const { capa, fecha } = req.query;

let salas = [];
if (capa !== 'estadistica' && !req.query.cama && !req.query.idInternacion) {
if (capa !== 'estadistica' && !req.query.idInternacion) {
salas = await SalaComunController.listarSalaComun({
organizacion: organizacion._id,
fecha: moment(fecha).toDate(),
ambito: req.query.ambito
ambito: req.query.ambito,
id: req.query.cama
});
salas = populateSalaComun(salas);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/rup/internacion/estados.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const EstadoSchema = new Schema({
EstadoSchema.methods.check = function (origen, destino, idInternacionOrigen, idInternacionDestino) {
if (origen === destino) {
// true en caso de cambio de UO o cama (no)censable. De lo contrario debería tratarse de estados (y camas) distintos.
return (!idInternacionOrigen && !idInternacionDestino) || idInternacionOrigen && idInternacionDestino && idInternacionOrigen === idInternacionDestino;
return (!idInternacionOrigen && !idInternacionDestino) || idInternacionOrigen && idInternacionDestino && idInternacionOrigen.toString() === idInternacionDestino.toString();
}

for (const relacion of this.relaciones) {
Expand Down
11 changes: 3 additions & 8 deletions packages/unit-testing/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import { Request } from '@andes/api-tool';
import { MongoMemoryServer } from 'mongodb-memory-server-global';
import * as mongoose from 'mongoose';
import { Types } from 'mongoose';

const sha1 = require('sha1');

export const getObjectId = (name: string): Types.ObjectId => {
export const getObjectId = (name: string): mongoose.Types.ObjectId => {
if (name === '') {
throw new Error('Name cannot be empty');
}
const hash = sha1(name);
return new Types.ObjectId(hash.substring(0, 24));
return new mongoose.Types.ObjectId(hash.substring(0, 24));
};

export function getFakeRequest(): Request {
return {
user: {
usuario: { nombre: 'JUAN' },
organizacion: { nombre: 'CASTRO' }
},
ip: '0.0.0.0',
connection: {
localAddress: '0.0.0.0'
}
} as any;
}
Expand All @@ -35,7 +30,7 @@ export function setupUpMongo() {
beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();
mongoose.connect(mongoUri);
await mongoose.connect(mongoUri);
});

afterAll(async () => {
Expand Down

0 comments on commit 7ddf91a

Please sign in to comment.