Skip to content

Commit

Permalink
feat(PRIV-70): Agregar campo observación en motivos (#1901)
Browse files Browse the repository at this point in the history
Co-authored-by: aldoEMatamala <aldo.emanuel.matamla@gmail.com>
  • Loading branch information
aldoEMatamala and aldoEMatamala committed Jun 3, 2024
1 parent 4e7a13a commit fe63c17
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions modules/huds/hudsAccesos.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export async function search(filtros) {
matricula: '$accesos.matricula',
motivoAcceso: '$accesos.motivoAcceso',
organizacion: '$accesos.organizacion',
detalleMotivo: '$accesos.detalleMotivo',
}
}
];
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 @@ -25,7 +25,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);
logAcceso(req, req.body.paciente.id, matricula, req.body.motivo, req.body.idTurno, req.body.idPrestacion, req.body.detalleMotivo);
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 @@ -21,6 +21,7 @@ export const HudsAccesoSchema = new Schema({
},
matricula: String,
motivoAcceso: String,
detalleMotivo: String,
turno: SchemaTypes.ObjectId,
prestacion: SchemaTypes.ObjectId,
organizacion: SchemaTypes.Mixed,
Expand Down Expand Up @@ -53,6 +54,7 @@ export interface IHudsAccesos extends Document {
usuario: any;
matricula: string;
motivoAcceso: string;
detalleMotivo: 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) {
export async function logAcceso(req, paciente, matricula, motivo, idTurno, idPrestacion, detalleMotivo) {
let bucketNumber = 0;
let retry = true;
while (retry) {
try {
await execLog(req, paciente, matricula, motivo, idTurno, idPrestacion, bucketNumber);
await execLog(req, paciente, matricula, motivo, idTurno, idPrestacion, bucketNumber, detalleMotivo);
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) {
async function execLog(req, paciente, matricula, motivoAcceso, turno, prestacion, bucketNumber, detalleMotivo) {
const now = new Date();
const start = moment(now).startOf('year') as unknown as number;
return HudsAcceso.update(
Expand All @@ -42,6 +42,7 @@ async function execLog(req, paciente, matricula, motivoAcceso, turno, prestacion
usuario: user(req),
matricula,
motivoAcceso,
detalleMotivo,
turno,
prestacion,
organizacion: organizacion(req),
Expand Down

0 comments on commit fe63c17

Please sign in to comment.