diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 26e1cb3026eb9de8e51d28236762e214a316c189..52788490ce594bdfb94faab39bc15bb18cf2e2c6 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -19,6 +19,7 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ const express = require('express'); +const { result } = require('lodash'); const enrollmentApp = express.Router(); @@ -811,7 +812,29 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); } next(); -}, rqf.build(), query, id2str.transform(false), response('enrollment')); +}, rqf.build(), query, id2str.transform(false), (req, res, next) => { + if('pee_por_categoria' in req.dims){ + let result_total = []; + for (var j = 0;j < result.result.length;j++){ + let result_parcial = result.result[j]; + for (var i in result_parcial){ + if(i !== 'year'){ + let obj = { + category_name: '', + year: 0, + total: 0 + }; + obj.category_name = i; + obj.total = result_parcial[i]; + obj.year = result_parcial.year; + result_total.push(obj); + } + } + } + req.result = result_total; + } + next(); +}, response('enrollment')); enrollmentApp.get('/diagnosis', rqf.parse(), (req, res, next) => { req.dims = {};