Skip to content

Commit

Permalink
feat(ep): nuevo search con detalles de paginacion
Browse files Browse the repository at this point in the history
  • Loading branch information
negro89 committed Apr 6, 2022
1 parent 2215658 commit ff8fcfb
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion modules/seguimiento-paciente/seguimiento-paciente.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ class SeguimientoPacienteResource extends ResourceBase {
}
}

const search = async (req, res, next) => {
const options = req.apiOptions();
const conditions = { ...req.query };
Object.keys(options).map(opt => delete conditions[opt]);
const [results, total] = await Promise.all([
SeguimientoPacienteCtr.search(conditions, options),
SeguimientoPacienteCtr.search(conditions)
]);
res.json({
pagination: {
offset: options.skip,
limit: options.limit,
total: total.length,
},
data: results
});
};

const patchAsignacion = async (req, res, next) => {
try {
const { seguimientos, profesional } = req.body;
Expand All @@ -74,5 +92,7 @@ const patchAsignacion = async (req, res, next) => {

export const SeguimientoPacienteCtr = new SeguimientoPacienteResource({});
const seguimientoPacienteRouter = SeguimientoPacienteCtr.makeRoutes();
seguimientoPacienteRouter.post('/seguimientoPaciente/asignaciones', Auth.authenticate(), asyncHandler(patchAsignacion));
export const SeguimientoPacienteRouter = seguimientoPacienteRouter;

seguimientoPacienteRouter.get('/seguimientoPaciente/search/v2', Auth.authenticate(), asyncHandler(search));
seguimientoPacienteRouter.post('/seguimientoPaciente/asignaciones', Auth.authenticate(), asyncHandler(patchAsignacion));

0 comments on commit ff8fcfb

Please sign in to comment.