diff --git a/src/libs/convert/ageRangeEntity.js b/src/libs/convert/ageRangeEntity.js
new file mode 100644
index 0000000000000000000000000000000000000000..f9ca149b249603d1928cb01f7938e5b4837eab33
--- /dev/null
+++ b/src/libs/convert/ageRangeEntity.js
@@ -0,0 +1,40 @@
+/*
+Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre
+Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+   
+This file is part of simcaq-node.
+
+simcaq-node is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+simcaq-node is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+module.exports = function ageRangeEntity(id) {
+    switch (id) {
+        case 1:
+        return 'Até 24 anos';
+        case 2:
+        return '25 a 29 anos';
+        case 3:
+        return '30 a 39 anos';
+        case 4:
+        return '40 a 49 anos';
+        case 5:
+        return '50 a 54 anos';
+        case 6:
+        return '55 a 59 anos';
+        case 7:
+        return '60 anos ou mais';
+        default:
+        return 'Não declarada';
+    }
+};
diff --git a/src/libs/convert/diffLocation.js b/src/libs/convert/diffLocation.js
index 16441ca7209987bdf941634fd39a3660a083c59d..aadc9cf6fd341dc51214c58682b8ded5e371a055 100644
--- a/src/libs/convert/diffLocation.js
+++ b/src/libs/convert/diffLocation.js
@@ -30,5 +30,7 @@ module.exports = function location(id) {
             return 'Área remanescente de quilombos';
 		case 8:
 			return 'Área onde se localizam povos e comunidades tradicionais';
+        default:
+            return 'Não definido';
     }
 };
diff --git a/src/libs/convert/educationLevelModEntityAgg.js b/src/libs/convert/educationLevelModEntityAgg.js
new file mode 100644
index 0000000000000000000000000000000000000000..a9fb4fbcf6c53d8a683e8bdf6ecd1f90b61ce3b3
--- /dev/null
+++ b/src/libs/convert/educationLevelModEntityAgg.js
@@ -0,0 +1,56 @@
+/*
+Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre
+Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+   
+This file is part of simcaq-node.
+
+simcaq-node is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+simcaq-node is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+module.exports = function educationLevelShort(id) {
+    switch (id) {
+        case 1:
+        return 'Creche';
+        case 2:
+        return 'Pré-Escola';
+        case 3:
+        return 'Ensino Fundamental - anos iniciais';
+        case 4:
+        return 'Ensino Fundamental - anos finais';
+        case 5:
+        return 'Ensino Médio Propedêutico';
+        case 6:
+        return 'Ensino Médio Normal Magistério';
+        case 7:
+        return 'Ensino Médio Integrado';
+        case 8:
+        return 'Educação Profissional Técnica - Associado ao Nível Médio';
+        case 9:
+        return 'Educação Profissional Técnica - Concomitante';
+        case 10:
+        return 'Educação Profissional Técnica - Subsequente';
+        case 11:
+        return 'Educação Profissional - Misto';
+        case 12:
+        return 'Educação Profissional FIC Concomitante';
+        case 13:
+        return 'Educacao Profissional FIC Integrado EJA';
+        case 14:
+        return 'EJA Ensino Fundamental';
+        case 15:
+        return 'EJA Ensino Médio';
+        default:
+        return 'Não classificada';
+    }
+};
diff --git a/src/libs/convert/educationLevelModEntitySeg.js b/src/libs/convert/educationLevelModEntitySeg.js
new file mode 100644
index 0000000000000000000000000000000000000000..fedf7d562230a31f35e235d0523c8281f99e4f94
--- /dev/null
+++ b/src/libs/convert/educationLevelModEntitySeg.js
@@ -0,0 +1,40 @@
+/*
+Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre
+Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+   
+This file is part of simcaq-node.
+
+simcaq-node is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+simcaq-node is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+module.exports = function educationLevelShort(id) {
+    switch (id) {
+        case 1:
+        return 'Educação Infantil';
+        case 2:
+        return 'Ensino Fundamental';
+        case 3:
+        return 'Ensino Médio';
+        case 4:
+        return 'Educação Profissional';
+        case 5:
+        return 'Educação Profissional Técnica de Nível Médio';
+        case 6:
+        return 'Educação Profissional FIC';
+        case 7:
+        return 'EJA';
+        default:
+        return 'Não classificada';
+    }
+};
diff --git a/src/libs/convert/postGraduationEntity.js b/src/libs/convert/postGraduationEntity.js
new file mode 100644
index 0000000000000000000000000000000000000000..49e8d08af7f0eaafe9cd5a14d0482b0accf9b337
--- /dev/null
+++ b/src/libs/convert/postGraduationEntity.js
@@ -0,0 +1,32 @@
+/*
+Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre
+Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+   
+This file is part of simcaq-node.
+
+simcaq-node is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+simcaq-node is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+module.exports = function ageRange(id) {
+    switch (id) {
+        case 1:
+        return 'Pós-Graduação Especialização';
+        case 2:
+        return 'Pós-Graduação Mestrado';
+        case 3:
+        return 'Pós-Graduação Doutorado';
+        default:
+        return '';
+    }
+};
diff --git a/src/libs/convert/specialEducationEntity.js b/src/libs/convert/specialEducationEntity.js
new file mode 100644
index 0000000000000000000000000000000000000000..b358c4edaba32b3c18220a73279a74568aa59a97
--- /dev/null
+++ b/src/libs/convert/specialEducationEntity.js
@@ -0,0 +1,31 @@
+/*
+Copyright (C) 2022 Centro de Computacao Cientifica e Software Livre
+Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+
+This file is part of simcaq-node.
+
+simcaq-node is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+simcaq-node is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+module.exports = function specialEducation(id) {
+    switch (id) {
+        case 1:
+        return 'Classe Comum';
+        case 2:
+        return 'Classe Exclusiva';
+        default:
+        return 'Não definido';
+    }
+};
+  
diff --git a/src/libs/middlewares/aggregateData.js b/src/libs/middlewares/aggregateData.js
index 3ea93de36e317413eb7a1c956ae80f9b66f7732b..aaa1ede48ce37f977f11e45b38e5dd87d4f8f5e6 100644
--- a/src/libs/middlewares/aggregateData.js
+++ b/src/libs/middlewares/aggregateData.js
@@ -22,7 +22,17 @@ const convert = {
     modality_integral_time: 'educationLevelBasic',
     special_education: 'specialEducation',
     special_education_doc: 'specialEducationDoc',
-    education_level_mod_doc: 'educationLevelModDoc'
+    special_education_entity: 'specialEducationEntity',
+    education_level_mod_doc: 'educationLevelModDoc',
+    education_level_mod_entity_seg: 'educationLevelModEntitySeg',
+    education_level_mod_entity_agg: 'educationLevelModEntityAgg',
+    adm_dependency_entity_agg: 'newPnadAdmDependency',
+    adm_dependency_entity: 'admDependency',
+    location_entity: 'location',
+    gender_entity: 'gender',
+    age_range_entity: 'ageRangeEntity',
+    post_graduation_entity: 'postGraduationEntity',
+    contract_type_entity: 'contractType'
 }
 
 function aggregateData(req, res, next) {
@@ -38,7 +48,17 @@ function aggregateData(req, res, next) {
             'period_agg', 
             'modality_integral_time', 
             'special_education',
-            'special_education_doc'
+            'special_education_doc',
+            'special_education_entity',
+            'education_level_mod_entity_seg',
+            'education_level_mod_entity_agg',
+            'adm_dependency_entity_agg',
+            'adm_dependency_entity',
+            'location_entity',
+            'gender_entity',
+            'age_range_entity',
+            'post_graduation_entity',
+            'contract_type_entity'
         ]
         let id;
         const fields = req.query.dims.split(',');
diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js
index 1971d0a014e5d744e64b3497ba1cf335b306dafe..078df393ba871ad00ad9d39baa1e5d4d3282aa21 100644
--- a/src/libs/middlewares/id2str.js
+++ b/src/libs/middlewares/id2str.js
@@ -118,8 +118,12 @@ const incomeRange = require(`${libs}/convert/incomeRange`);
 const ageRangeAggregate = require(`${libs}/convert/ageRangeAggregate`);
 const specialEducation = require(`${libs}/convert/specialEducation`);
 const specialEducationDoc = require(`${libs}/convert/specialEducationDoc`);
+const specialEducationEntity = require(`${libs}/convert/specialEducationEntity`);
 const educationLevelModDoc = require(`${libs}/convert/educationLevelModDoc`);
-
+const educationLevelModEntitySeg = require(`${libs}/convert/educationLevelModEntitySeg`);
+const educationLevelModEntityAgg = require(`${libs}/convert/educationLevelModEntityAgg`);
+const ageRangeEntity = require(`${libs}/convert/ageRangeEntity`);
+const postGraduationEntity = require(`${libs}/convert/postGraduationEntity`);
 
 const ids = {
     gender_id: gender,
@@ -231,7 +235,12 @@ const ids = {
     income_range_id: incomeRange,
     special_education: specialEducation,
     special_education_doc: specialEducationDoc,
-    education_level_mod_doc: educationLevelModDoc
+    education_level_mod_doc: educationLevelModDoc,
+    education_level_mod_entity_seg: educationLevelModEntitySeg,
+    education_level_mod_entity_agg: educationLevelModEntityAgg,
+    age_range_entity: ageRangeEntity,
+    post_graduation_entity: postGraduationEntity,
+    special_education_entity: specialEducationEntity
 };
 
 function transform(removeId=false) {
@@ -365,5 +374,10 @@ module.exports = {
     incomeRange,
     specialEducation,
     specialEducationDoc,
-    educationLevelModDoc
+    educationLevelModDoc,
+    educationLevelModEntitySeg,
+    educationLevelModEntityAgg,
+    ageRangeEntity,
+    postGraduationEntity,
+    specialEducationEntity
 };
diff --git a/src/libs/routes_v1/api.js b/src/libs/routes_v1/api.js
index ba0369516e4f200dffe6a384d97b5776247fe0ee..e9fbd8fda1cf3898ff77f49cefb6c1f358898019 100644
--- a/src/libs/routes_v1/api.js
+++ b/src/libs/routes_v1/api.js
@@ -149,6 +149,8 @@ const enrollmentAggregate = require(`${libs}/routes_v1/enrollmentAggregate`);
 
 const employeesAggregate = require(`${libs}/routes_v1/employeesAggregate`);
 
+const federativeEntity = require(`${libs}/routes_v1/federativeEntity`);
+
 const email = require(`${libs}/routes_v1/email`);
 
 api.get('/', (req, res) => {
@@ -214,6 +216,7 @@ api.use('/new_pnad', newPnad);
 api.use('/rate_school_new', rateSchoolNew)
 api.use('/enrollmentAggregate', enrollmentAggregate);
 api.use('/employeesAggregate', employeesAggregate);
+api.use('/federativeEntity', federativeEntity);
 
 
 //Publication 
diff --git a/src/libs/routes_v1/enrollmentAggregate.js b/src/libs/routes_v1/enrollmentAggregate.js
index d266d2403c00b742c3329fc871d863b9cf986842..08d55ddba8787ba9906a722ab2d6ca98e011e58f 100644
--- a/src/libs/routes_v1/enrollmentAggregate.js
+++ b/src/libs/routes_v1/enrollmentAggregate.js
@@ -114,7 +114,7 @@ enrollmentAggregateApp.get('/location', (req, res, next) => {
 enrollmentAggregateApp.get('/diff_location', (req, res, next) => {
     req.result = []
 
-    for (let i = 0; i <= 4; i++) {
+    for (let i = 0; i < 4; i++) {
         req.result.push({
             id: i, name: id2str.diffLocation(i)
         });
@@ -587,7 +587,7 @@ enrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
         .field('SUM(escola.qt_mat_bas)', 'total')
         .field('escola.ano_censo', 'year')
         .group('escola.ano_censo')
-        .order('escola.ano_censo');
+        .order('escola.ano_censo')
     }
     next();
 }, query, aggregateData, id2str.transform(false), response('enrollment_aggregate'));
diff --git a/src/libs/routes_v1/federativeEntity.js b/src/libs/routes_v1/federativeEntity.js
new file mode 100644
index 0000000000000000000000000000000000000000..0b0c2b5c8230709ed81bbbddfb7fbd38dfc73d11
--- /dev/null
+++ b/src/libs/routes_v1/federativeEntity.js
@@ -0,0 +1,587 @@
+/*
+Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre
+Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
+
+This file is part of simcaq-node.
+
+simcaq-node is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+simcaq-node is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
+*/
+
+const express = require('express');
+const { result } = require('lodash');
+
+const federativeEntityApp = express.Router();
+
+const libs = `${process.cwd()}/libs`;
+
+const log = require(`${libs}/log`)(module);
+
+const squel = require('squel');
+
+const query = require(`${libs}/middlewares/query`).query;
+
+const response = require(`${libs}/middlewares/response`);
+
+const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
+
+const aggregateData = require(`${libs}/middlewares/aggregateData`);
+
+const id2str = require(`${libs}/middlewares/id2str`);
+
+const config = require(`${libs}/config`);
+
+const addMissing = require(`${libs}/middlewares/addMissing`);
+
+const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
+
+federativeEntityApp.use(cache('15 day'));
+
+let rqf = new ReqQueryFields();
+
+federativeEntityApp.get('/years', (req, res, next) => {
+    req.sql.from('escola')
+    .field('DISTINCT escola.ano_censo', 'year')
+    .where('escola.ano_censo >= 2021')
+    next();
+}, query, response('years'));
+
+federativeEntityApp.get('/adm_dependency', (req, res, next) => {
+    req.result = []
+
+    for (let i = 1; i <= 5; i++) {
+        req.result.push({
+            id: i, name: id2str.admDependency(i)
+        });
+    }
+    next();
+}, response('adm_dependency'));
+
+federativeEntityApp.get('/adm_dependency_detailed', (req, res, next) => {
+    req.result = []
+
+    for (let i = 1; i <= 9; i++) {
+        req.result.push({
+            id: i, name: id2str.admDependencyPriv(i)
+        });
+    }
+    next();
+}, response('adm_dependency_detailed'));
+
+federativeEntityApp.get('/education_level_mod_agg', (req, res, next) => {
+    req.result = []
+
+    for (let i = 1; i <= 13; i++) {
+        req.result.push({
+            id: i, name: id2str.educationLevelMod(i)
+        });
+    }
+    next();
+}, response('education_level_mod_agg'));
+
+federativeEntityApp.get('/integral_time_agg', (req, res, next) => {
+    req.result = []
+
+    for (let i = 0; i <= 3; i++) {
+        req.result.push({
+            id: i, name: id2str.integralTime(i)
+        });
+    }
+    next();
+}, response('integral_time_agg')); 
+
+federativeEntityApp.get('/location', (req, res, next) => {
+    req.result = []
+
+    for (let i = 1; i <= 2; i++) {
+        req.result.push({
+            id: i, name: id2str.location(i)
+        });
+    }
+    next();
+}, response('location'));
+
+federativeEntityApp.get('/diff_location', (req, res, next) => {
+    req.result = []
+
+    for (let i = 0; i <= 4; i++) {
+        req.result.push({
+            id: i, name: id2str.diffLocation(i)
+        });
+    }
+
+    req.result.push({
+        id: 8, name: 'Área onde se localizam povos e comunidades tradicionais'
+    })
+
+    next();
+}, response('diff_location'));
+
+federativeEntityApp.get('/modality_integral_time', (req, res, next) => {
+    req.result = []
+
+    for (let i = 0; i <= 7; i++) {
+        req.result.push({
+            id: i, name: id2str.educationLevelBasic(i)
+        });
+    }
+
+    next();
+}, response('modality_integral_time'));
+
+federativeEntityApp.get('/gender', (req, res, next) => {
+    req.result = []
+
+    for (let i = 1; i <= 2; i++) {
+        req.result.push({
+            id: i, name: id2str.gender(i)
+        });
+    }
+
+    next();
+}, response('gender'));
+
+federativeEntityApp.get('/age_range', (req, res, next) => {
+    req.result = []
+
+    for (let i = 1; i <= 7; i++) {
+        req.result.push({
+            id: i, name: id2str.ageRangeAggregate(i)
+        });
+    }
+
+    next();
+}, response('age_range'));
+
+federativeEntityApp.get('/ethnic_group', (req, res, next) => {
+    req.result = []
+
+    for (let i = 0; i <= 6; i++) {
+        req.result.push({
+            id: i, name: id2str.ethnicGroup(i)
+        });
+    }
+
+    next();
+}, response('ethnic_group'));
+
+federativeEntityApp.get('/period_agg', (req, res, next) => {
+    req.result = []
+
+    for (let i = 0; i <= 5; i++) {
+        req.result.push({
+            id: i, name: id2str.period(i)
+        });
+    }
+
+    next();
+}, response('period_agg'));
+
+federativeEntityApp.get('/region', (req, res, next) => {
+    req.result = []
+
+    for (let i = 0; i <= 5; i++) {
+        req.result.push({
+            id: i, name: id2str.regionCode(i)
+        });
+    }
+
+    next();
+}, response('period_agg'));
+
+federativeEntityApp.get('/state', (req, res, next) => {
+    req.result = []
+    for (let i = 11; i < 54; i++) {
+        if (id2str.stateName(i) !== 'Não declarada') {
+            req.result.push({
+                id: i, name: id2str.stateName(i)
+            });
+        }
+    }
+
+    next();
+}, response('state'));
+
+federativeEntityApp.get('/special_education_entity', (req, res, next) => {
+    req.result = []
+
+    for (let i = 1; i <= 2; i++) {
+        req.result.push({
+            id: i, name: id2str.specialEducationEntity(i)
+        });
+    }
+
+    next();
+}, response('special_education_entity'));
+
+
+rqf.addField({
+    name: 'filter',
+    field: false,
+    where: true
+}).addField({
+    name: 'dims',
+    field: true,
+    where: false
+}).addValue({
+    name: 'region',
+    table: 'regiao',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'cod_reg',
+        foreignTable: 'docentes_sinopse'
+    }
+}).addValue({
+    name: 'mesoregion',
+    table: 'municipio',
+    tableField: ['nome_mesorregiao', 'mesorregiao_id'],
+    resultField: ['mesoregion_name', 'mesoregion_id'],
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'mesorregiao_id',
+        table: 'municipio'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'municipio_id',
+        foreignTable: 'escola'
+    }
+}).addValue({
+    name: 'microregion',
+    table: 'municipio',
+    tableField: ['nome_microrregiao', 'microrregiao_id'],
+    resultField: ['microregion_name', 'microregion_id'],
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'microrregiao_id',
+        table: 'municipio'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'municipio_id',
+        foreignTable: 'escola'
+    }
+}).addValue({
+    name: 'min_year',
+    table: 'docentes_sinopse',
+    tableField: 'ano_censo',
+    resultField: 'year',
+    where: {
+        relation: '>=',
+        type: 'integer',
+        field: 'ano_censo',
+    },
+}).addValue({
+    name: 'max_year',
+    table: 'docentes_sinopse',
+    tableField: 'ano_censo',
+    resultField: 'year',
+    where: {
+        relation: '<=',
+        type: 'integer',
+        field: 'ano_censo',
+    },
+}).addValueToField({
+    name: 'state',
+    table: 'estado',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'cod_uf',
+        foreignTable: 'docentes_sinopse'
+    }
+}, 'dims').addValueToField({
+    name: 'state',
+    table: 'estado',
+    tableField: 'nome',
+    resultField: 'state_name',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'cod_uf',
+        foreignTable: 'docentes_sinopse'
+    }
+}, 'filter').addValueToField({
+    name: 'city',
+    table: 'municipio',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'municipio_id',
+        foreignTable: 'escola'
+    }
+}, 'dims').addValueToField({
+    name: 'city',
+    table: 'municipio',
+    tableField: 'nome',
+    resultField: 'city_name',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'municipio_id',
+        foreignTable: 'escola'
+    }
+}, 'filter').addValueToField({
+    name: 'school',
+    table: 'docentes_sinopse',
+    tableField: ['nome_escola', 'id'],
+    resultField: ['school_name', 'school_id'],
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: ['id', 'ano_censo'],
+        foreign: ['escola_id', 'ano_censo'],
+        foreignTable: 'escola'
+    }
+}, 'dims').addValueToField({
+    name: 'locale_id',
+    table: 'docentes_sinopse',
+    tableField: 'localizacao_id',
+    resultField: 'locale_id',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'localizacao_id'
+    }
+}, 'dims').addValueToField({
+    name: 'school_id',
+    table: 'docentes_sinopse',
+    tableField: 'id',
+    resultField: 'school_id',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: ['id', 'ano_censo'],
+        foreign: ['escola_id', 'ano_censo'],
+        foreignTable: 'escola'
+    }
+}, 'dims').addValueToField({
+    name: 'school',
+    table: 'docentes_sinopse',
+    tableField: 'nome_escola',
+    resultField: 'school_name',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: ['id', 'ano_censo'],
+        foreign: ['escola_id', 'ano_censo'],
+        foreignTable: 'escola'
+    }
+}, 'filter').addValue({
+    name: 'location',
+    table: 'docentes_sinopse',
+    tableField: 'localizacao_id',
+    resultField: 'location_id',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'localizacao_id'
+    }
+});
+
+federativeEntityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
+
+    if (req.query.dims && req.query.dims.includes('education_level_mod_entity_seg'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_ed_inf_total)', 'total_doc_ed_inf_total')
+        .field('SUM(docentes_sinopse.num_doc_en_fund_total)', 'total_doc_en_fund_total')
+        .field('SUM(docentes_sinopse.num_doc_en_medio_total)', 'total_doc_en_medio_total')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_total)', 'total_doc_ed_prof_total')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_tec_total)', 'total_doc_ed_prof_tec_total')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_fic_total)', 'total_doc_ed_prof_fic_total')
+        .field('SUM(docentes_sinopse.num_doc_eja_total)', 'total_doc_eja_total')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('education_level_mod_entity_agg'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_ed_inf_creche)', 'total_doc_ed_inf_creche')
+        .field('SUM(docentes_sinopse.num_doc_ed_inf_pre_escola)', 'total_doc_ed_inf_pre_escola')
+        .field('SUM(docentes_sinopse.num_doc_en_fund_anos_iniciais)', 'total_doc_en_fund_anos_iniciais')
+        .field('SUM(docentes_sinopse.num_doc_en_fund_anos_finais)', 'total_doc_en_fund_anos_finais')
+        .field('SUM(docentes_sinopse.num_doc_en_medio_propedeutico)', 'total_doc_en_medio_propedeutico')
+        .field('SUM(docentes_sinopse.num_doc_en_medio_normal_magisterio)', 'total_doc_en_medio_normal_magisterio')
+        .field('SUM(docentes_sinopse.num_doc_en_medio_integrado)', 'total_doc_en_medio_integrado')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_en_medio)', 'total_doc_ed_prof_en_medio')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_tec_concomitante)', 'total_doc_ed_prof_tec_concomitante')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_tec_subsequente)', 'total_doc_ed_prof_tec_subsequente')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_tec_misto)', 'total_doc_ed_prof_tec_misto')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_fic_concomitante)', 'total_doc_ed_prof_fic_concomitante')
+        .field('SUM(docentes_sinopse.num_doc_ed_prof_fic_integrado_eja)', 'total_doc_ed_prof_fic_integrado_eja')
+        .field('SUM(docentes_sinopse.num_doc_eja_en_fund)', 'total_doc_eja_en_fund')
+        .field('SUM(docentes_sinopse.num_doc_eja_en_medio)', 'total_doc_eja_en_medio')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('special_education_entity'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_ed_especial_classe_comum)', 'total_doc_ed_especial_classe_comum')
+        .field('SUM(docentes_sinopse.num_doc_ed_especial_classe_exclusiva)', 'total_doc_ed_especial_classe_exclusiva')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('adm_dependency_entity_agg'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_dependencia_adm_pub)', 'total_doc_dependencia_adm_pub')
+        .field('SUM(docentes_sinopse.num_doc_dependencia_adm_priv)', 'total_doc_dependencia_adm_priv')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('adm_dependency_entity'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_dependencia_adm_federal)', 'total_doc_dependencia_adm_federal')
+        .field('SUM(docentes_sinopse.num_doc_dependencia_adm_estadual)', 'total_doc_dependencia_adm_estadual')
+        .field('SUM(docentes_sinopse.num_doc_dependencia_adm_municipal)', 'total_doc_dependencia_adm_municipal')
+        .field('SUM(docentes_sinopse.num_doc_dependencia_adm_priv)', 'total_doc_dependencia_adm_priv')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('location_entity'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_loc_urbana_total)', 'total_doc_loc_urbana_total')
+        .field('SUM(docentes_sinopse.num_doc_loc_rural_total)', 'total_doc_loc_rural_total')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('gender_entity'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_masc_total)', 'total_doc_masc_total')
+        .field('SUM(docentes_sinopse.num_doc_fem_total)', 'total_doc_fem_total')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('age_range_entity'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_fem_24 + docentes_sinopse.num_doc_masc_24)', 'total_doc_24')
+        .field('SUM(docentes_sinopse.num_doc_fem_25_29 + docentes_sinopse.num_doc_masc_25_29)', 'total_doc_25_29')
+        .field('SUM(docentes_sinopse.num_doc_fem_30_39 + docentes_sinopse.num_doc_masc_30_39)', 'total_doc_30_39')
+        .field('SUM(docentes_sinopse.num_doc_fem_40_49 + docentes_sinopse.num_doc_masc_40_49)', 'total_doc_40_49')
+        .field('SUM(docentes_sinopse.num_doc_fem_50_54 + docentes_sinopse.num_doc_masc_50_54)', 'total_doc_50_54')
+        .field('SUM(docentes_sinopse.num_doc_fem_55_59 + docentes_sinopse.num_doc_masc_55_59)', 'total_doc_55_59')
+        .field('SUM(docentes_sinopse.num_doc_fem_60_mais + docentes_sinopse.num_doc_masc_60_mais)', 'total_doc_60_mais')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('post_graduation_entity'))
+    {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_esc_pos_grad_especializacao)', 'total_doc_esc_pos_grad_especializacao')
+        .field('SUM(docentes_sinopse.num_doc_esc_pos_grad_mestrado)', 'total_doc_esc_pos_grad_mestrado')
+        .field('SUM(docentes_sinopse.num_doc_esc_pos_grad_doutorado)', 'total_doc_esc_pos_grad_doutorado')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if (req.query.dims && req.query.dims.includes('contract_type_entity'))
+    {
+            req.sql.from('docentes_sinopse')
+            .field('SUM(docentes_sinopse.num_doc_vinc_concursado_efetivo_estavel_total)', 'total_doc_vinc_concursado_efetivo_estavel_total')
+            .field('SUM(docentes_sinopse.num_doc_vinc_contrato_temp_total)', 'total_doc_vinc_contrato_temp_total')
+            .field('SUM(docentes_sinopse.num_doc_vinc_contrato_terceirizado_total)', 'total_doc_vinc_contrato_terceirizado_total')
+            .field('SUM(docentes_sinopse.num_doc_vinc_contrato_clt_total)', 'total_doc_vinc_contrato_clt_total')
+            .field('docentes_sinopse.ano_censo', 'year')
+            .group('docentes_sinopse.ano_censo')
+            .order('docentes_sinopse.ano_censo')
+            .where('docentes_sinopse.cod_reg = 0');
+    }
+    else if ((req.query.dims && req.query.dims.includes('state')) || (req.query.filter && req.query.filter.includes('state'))) {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_ed_bas_total)', 'total')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_mun = 0');
+    }
+    else if ((req.query.dims && req.query.dims.includes('region')) || (req.query.filter && req.query.filter.includes('region'))) {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_ed_bas_total)', 'total')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_uf = 0');
+    }
+    else {
+        req.sql.from('docentes_sinopse')
+        .field('SUM(docentes_sinopse.num_doc_ed_bas_total)', 'total')
+        .field('docentes_sinopse.ano_censo', 'year')
+        .group('docentes_sinopse.ano_censo')
+        .order('docentes_sinopse.ano_censo')
+        .where('docentes_sinopse.cod_reg = 0');
+    }
+    next();
+}, query, aggregateData, id2str.transform(false), response('federative_entity'));
+
+module.exports = federativeEntityApp;