Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/huds/hudsAccesos.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export async function search(filtros) {
motivoAcceso: '$accesos.motivoAcceso',
organizacion: '$accesos.organizacion',
detalleMotivo: '$accesos.detalleMotivo',
modulo: '$accesos.modulo',
}
}
];
Expand Down
2 changes: 1 addition & 1 deletion modules/huds/hudsAccesos.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ router.post('/accesos/token', asyncHandler(async (req: any, res) => {
const datosProfesional: any = await search({ id: idProfesional }, { matricula: 1 });
matricula = (datosProfesional.length && datosProfesional[0].matricula && datosProfesional[0].matricula.length) ? datosProfesional[0].matricula[0] : null;
}
logAcceso(req, req.body.paciente.id, matricula, req.body.motivo, req.body.idTurno, req.body.idPrestacion, req.body.detalleMotivo);
logAcceso(req, req.body.paciente.id, matricula, req.body.motivo, req.body.idTurno, req.body.idPrestacion, req.body.detalleMotivo, req.body.modulo);
return res.json({ token: Auth.generateHudsToken(req.body.usuario, organizacionId, req.body.paciente) });
}));

Expand Down
2 changes: 2 additions & 0 deletions modules/huds/hudsAccesos.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const HudsAccesoSchema = new Schema({
matricula: String,
motivoAcceso: String,
detalleMotivo: String,
modulo: String,
turno: SchemaTypes.ObjectId,
prestacion: SchemaTypes.ObjectId,
organizacion: SchemaTypes.Mixed,
Expand Down Expand Up @@ -55,6 +56,7 @@ export interface IHudsAccesos extends Document {
matricula: string;
motivoAcceso: string;
detalleMotivo: string;
modulo: string;
turno: Types.ObjectId;
prestacion: Types.ObjectId;
organizacion: any;
Expand Down
7 changes: 4 additions & 3 deletions modules/huds/hudsAccesos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { HudsAcceso } from './hudsAccesos.schema';
import * as moment from 'moment';


export async function logAcceso(req, paciente, matricula, motivo, idTurno, idPrestacion, detalleMotivo) {
export async function logAcceso(req, paciente, matricula, motivo, idTurno, idPrestacion, detalleMotivo, modulo) {
let bucketNumber = 0;
let retry = true;
while (retry) {
try {
await execLog(req, paciente, matricula, motivo, idTurno, idPrestacion, bucketNumber, detalleMotivo);
await execLog(req, paciente, matricula, motivo, idTurno, idPrestacion, bucketNumber, detalleMotivo, modulo);
retry = false;
} catch (err) {
if (err.code === 17419) {
Expand All @@ -20,7 +20,7 @@ export async function logAcceso(req, paciente, matricula, motivo, idTurno, idPre
}
}

async function execLog(req, paciente, matricula, motivoAcceso, turno, prestacion, bucketNumber, detalleMotivo) {
async function execLog(req, paciente, matricula, motivoAcceso, turno, prestacion, bucketNumber, detalleMotivo, modulo) {
const now = new Date();
const start = moment(now).startOf('year') as unknown as number;
return HudsAcceso.update(
Expand All @@ -43,6 +43,7 @@ async function execLog(req, paciente, matricula, motivoAcceso, turno, prestacion
matricula,
motivoAcceso,
detalleMotivo,
modulo,
turno,
prestacion,
organizacion: organizacion(req),
Expand Down
Loading