diff --git a/CHANGELOG.md b/CHANGELOG.md
index 972e6ac789f3f546a94a373e0b7dc97dafcd5001..47d5a30c8665716330c32682c55f3013232ebe53 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 - Updated education level mod
 - Updated adm_dependency_detailed filter
 - Updated rural_location filter
+- Updated period labels
+- AddMissing will now force ordination by id
+- Updated all routes to contain id in region, state and city dims
 
 ## 1.12.6 - 2020-02-02
 ## Changed
diff --git a/src/libs/convert/educationLevelMod.js b/src/libs/convert/educationLevelMod.js
index e659517307f425170f8b5b5f0801388c4c2b55ae..0cdfbeee4bc80b4e4307d5d43dc167ba79dd4ac7 100644
--- a/src/libs/convert/educationLevelMod.js
+++ b/src/libs/convert/educationLevelMod.js
@@ -1,7 +1,7 @@
 /*
 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
@@ -25,21 +25,25 @@ module.exports = function educationLevelMod(id) {
         case 2:
         return 'Pré-Escola';
         case 3:
-        return 'Educação Infantil Unificada';
+        return 'Educacao Infantil Unificada';
         case 4:
         return 'Ensino Fundamental - anos iniciais';
         case 5:
         return 'Ensino Fundamental - anos finais';
         case 6:
-        return 'Ensino Médio';
+        return 'Turmas multisseriadas e multietapas';
         case 7:
-        return 'Turmas multisseriadas e multieatapas';
+        return 'Ensino Médio';
         case 8:
-        return 'EJA - Ensino Fundamental';
+        return 'Ensino Medio Integrado ou Normal - tecnico';
         case 9:
-        return 'EJA - Ensino Médio';
+        return 'EJA - Ensino Fundamental';
         case 10:
-        return 'Educação Profissional';
+        return 'EJA - Ensino Médio';
+        case 11:
+        return 'EJA - EF e EM Integrado - tecnico';
+        case 12:
+        return 'Educacao Profissional - concomitante e subsequente.'
         default:
         return 'Não classificada';
     }
diff --git a/src/libs/convert/educationProfessional.js b/src/libs/convert/educationProfessional.js
new file mode 100644
index 0000000000000000000000000000000000000000..4906d2ec7d070b0f4f4bf11f4fd67f63e2b33504
--- /dev/null
+++ b/src/libs/convert/educationProfessional.js
@@ -0,0 +1,33 @@
+/*
+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 names = ["CRE", "PRE", "EF-AI", "EF-AF", "MULTIETAPA", "EM", "EJA", "PROF", "EE"]
+module.exports = function educationProfessional(id) {
+    let binaryId = id.toString(2)
+
+    let str = ''
+    for (let i = 0; i <= binaryId.length; i++) {
+        if (binaryId.charAt(i) === "1") {
+            str += names[ i + (names.length - binaryId.length) ] + '/';
+        }
+    }
+
+    return str.slice(0, -1);
+}
\ No newline at end of file
diff --git a/src/libs/convert/period.js b/src/libs/convert/period.js
index 8e15e74cb8b89a2ba62f07e379d2c76866260b65..76d7ca91719b9fa24e86750da847f72daac6d6ec 100644
--- a/src/libs/convert/period.js
+++ b/src/libs/convert/period.js
@@ -21,11 +21,13 @@ along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
 module.exports = function period(id) {
     switch(id) {
         case 1:
-        return 'Matutino';
+        return 'Parcial - Matutino';
         case 2:
-        return 'Vespertino';
+        return 'Parcial - Vespertino';
         case 3:
-        return 'Noturno';
+        return 'Parcial - Noturno';
+        case 4:
+        return 'Integral';
         default:
         return 'Não se aplica (semi presencial e EaD)';
     }
diff --git a/src/libs/convert/ruralLocation.js b/src/libs/convert/ruralLocation.js
index 1c1bbc5ab41e86f2f39e1ff56a278ac7e4714728..ab60f412eb79c4b6456f9f40bda53a6de86c9c39 100644
--- a/src/libs/convert/ruralLocation.js
+++ b/src/libs/convert/ruralLocation.js
@@ -32,5 +32,9 @@ module.exports = function ruralLocation(id) {
         return 'Rural - Área remanescente de quilombos';
         case 6:
         return 'Rural - Unidade de uso sustentável';
+        case 7:
+        return 'Rural - Unidade de uso sustentavel em terra indígena';
+        case 8:
+        return 'Rural - Unidade de uso sustentável em área remanescente de quilombos.';
     }
 };
diff --git a/src/libs/middlewares/addMissing.js b/src/libs/middlewares/addMissing.js
index e9c231c0bdacc0801a4eff2408472bc5741a5891..1050a1df0332f922313dadcc51d10ae84bcb41d8 100644
--- a/src/libs/middlewares/addMissing.js
+++ b/src/libs/middlewares/addMissing.js
@@ -20,12 +20,18 @@ along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
 
 function binarySearch(value, vector, a, b) {
     // Search for a value in a vector returning an object with a boolean 'found' and the the position of where the element is/should be at.
+
+    if (value === null) {       // null should be last in the vector
+        if (vector[b-1] === null) return {found: true, pos: b-1}
+        else return {found: false, pos: b}
+    }
+
     while (a < b) {
         let mid = Math.floor((b-a)/2) + a
 
         if (vector[mid] === value)
             return {found: true, pos: mid}
-        else if (vector[mid] > value)
+        else if (vector[mid] > value || vector[mid] === null)       // null should be the last element of the vector
             b = mid
         else
             a = mid+1
@@ -38,8 +44,6 @@ module.exports = function addMissing(rqf) {
     return (req, res, next) => {
         let dims = Object.keys(req.dims).filter(i => { return i !== 'size'; });
         // FIXME: No momento, só funciona para duas dimensões (padrão para o LDE)
-        // if((dims.length != 2) && (dims.length == 1 && req.filter.min_year == req.filter.max_year)) return next();
-        // if(req.filter.min_year != req.filter.max_year) return next();
         if (req.result.length === 0 || dims.length === 0) return next();
 
         if (dims.length === 1)      // If there is only one dimension we add year as a dimension, since it is the standard dim.
@@ -49,7 +53,7 @@ module.exports = function addMissing(rqf) {
 
         let dimsValues = {};        // Object with the id's of dims
         let dimsNames = {}          // Object the names of the dims
-        resultOriginal.forEach((r) => {
+        resultOriginal.forEach((r) => {         // First pass to get all the dimensions fields
             dims.forEach((dim) => {
                 let rqfName = rqf.fieldValues[dim].resultField;             // rqf with the id value
                 let secondaryRqfName = rqfName.slice(0, -2) + 'name'        // rqf with the 'name' value
@@ -62,20 +66,21 @@ module.exports = function addMissing(rqf) {
                     })
                 }
 
-                if (typeof dimsValues[rqfName] === 'undefined') {
+                if (typeof dimsValues[rqfName] === 'undefined') {       // dim wasn't added yet, so we create a new array for it.
                     dimsValues[rqfName] = [];
                     dimsNames[secondaryRqfName] = [];
                 }
 
                 if (dimsValues[rqfName].indexOf(r[rqfName]) === -1) {
-                    if (['school', 'city', 'state', 'region'].includes(dim)) {      // those should be ordered by its name
+                    if (['school', 'city', 'state', 'region', 'arrangement'].includes(dim)) {      // those should be ordered by its name
                         let namePosition = binarySearch(r[secondaryRqfName], dimsNames[secondaryRqfName], 0, dimsNames[secondaryRqfName].length)    // find the position of the name in alphabetical order and keep the names vector ordered
                         dimsValues[rqfName].splice(namePosition.pos, 0, r[rqfName]);
                         dimsNames[secondaryRqfName].splice(namePosition.pos, 0, r[secondaryRqfName]);
                     }
-                    else {                                                  
-                        dimsValues[rqfName].push(r[rqfName]);
-                        dimsNames[secondaryRqfName].push(r[secondaryRqfName])
+                    else {          // order by id
+                        let idPosition = binarySearch(r[rqfName], dimsValues[rqfName], 0, dimsValues[rqfName].length)
+                        dimsValues[rqfName].splice(idPosition.pos, 0, r[rqfName]);
+                        dimsNames[secondaryRqfName].splice(idPosition.pos, 0, r[secondaryRqfName])
                     }
 
                 }
@@ -84,7 +89,7 @@ module.exports = function addMissing(rqf) {
 
         if (dims[0] === 'min_year')         // year should be sorted by its value
             dimsValues['year'].sort();
-        
+
         let newResult = [];
         let rqfName = Object.keys(dimsValues)[0];
         let rqfName2 = Object.keys(dimsValues)[1];
@@ -105,7 +110,7 @@ module.exports = function addMissing(rqf) {
                     newEntry.first_qt = 0;
                 if (newEntry.hasOwnProperty("third_qt"))
                     newEntry.third_qt = 0;
-                
+
                 newEntry[nameDim1] = dimsNames[nameDim1][i]
                 newEntry[nameDim2] = dimsNames[nameDim2][j]
 
diff --git a/src/libs/routes/auxiliar.js b/src/libs/routes/auxiliar.js
index 114c8958aa90404ecc65edadabdcc3a72c2cac59..209f75a6aa88ac636d70b10368d881631177d0b0 100644
--- a/src/libs/routes/auxiliar.js
+++ b/src/libs/routes/auxiliar.js
@@ -1,3 +1,23 @@
+/*
+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 auxiliarApp = express.Router();
@@ -18,10 +38,6 @@ const id2str = require(`${libs}/middlewares/id2str`);
 
 const config = require(`${libs}/config`);
 
-const passport = require('passport');
-
-const download = require(`${libs}/middlewares/downloadDatabase`);
-
 const addMissing = require(`${libs}/middlewares/addMissing`);
 
 const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]}  }).middleware;
@@ -39,7 +55,7 @@ auxiliarApp.get('/year_range', (req, res, next) => {
 
 auxiliarApp.get('/years', (req, res, next) => {
     req.sql.from('docente').
-    field('DISTINCT docente.ano_censo', 'year');
+    field('DISTINCT docente.ano_censo', 'year')
     next();
 }, query, response('years'));
 
@@ -50,6 +66,18 @@ auxiliarApp.get('/source', (req, res, next) => {
     next();
 }, query, response('source'))
 
+auxiliarApp.get('/education_type', (req, res, next) => {
+    req.sql.from('docente')
+    .field('DISTINCT nivel_tipo_formacao', 'id')
+    .order('id');
+    next();
+}, query, (req, res, next) => {
+    req.result.forEach((result) => {
+        result.name = id2str.educationType(result.id);
+    });
+    next();
+}, response('education_type'));
+
 auxiliarApp.get('/adm_dependency_detailed', (req, res, next) => {
     req.result = [];
     for(let i = 1; i <= 6; ++i) {
@@ -158,6 +186,16 @@ rqf.addField({
         type: 'integer',
         field: 'dependencia_adm_priv'
     }
+}).addValue({
+    name: 'education_type',
+    table: 'docente',
+    tableField: 'nivel_tipo_formacao',
+    resultField: 'education_type_id',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'nivel_tipo_formacao'
+    }
 }).addValue({
     name: 'education_level_mod',
     table: 'docente',
@@ -171,8 +209,8 @@ rqf.addField({
 }).addValue({
   name: 'region',
   table: 'regiao',
-  tableField: 'nome',
-  resultField: 'region_name',
+  tableField: ['nome', 'id'],
+  resultField: ['region_name', 'region_id'],
   where: {
       relation: '=',
       type: 'integer',
@@ -186,8 +224,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -326,9 +364,13 @@ auxiliarApp.get('/', rqf.parse(), (req, res, next) => {
   .field("'Brasil'", 'name')
   .field('docente.ano_censo', 'year')
   .from('docente')
+  .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo')
   .group('docente.ano_censo')
   .order('docente.ano_censo')
-  .where('(docente.tipo_turma_id <= 3 AND docente.tipo_docente = 2)');
+  .where('(docente.tipo_docente = 2) AND \
+    ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \
+    OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \
+    AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)');     // não devemos trazer SC em 2009.
   next();
 }, rqf.build(), query, addMissing(rqf), id2str.transform(), response('auxiliar'));
 
@@ -340,10 +382,10 @@ auxiliarApp.get('/count', rqf.parse(), (req, res, next) => {
   .from('docente')
   .group('docente.ano_censo')
   .order('docente.ano_censo')
-  .where('(docente.tipo_turma_id <= 3 AND docente.dependencia_adm_id <= 3 AND docente.tipo_docente = 2)');
+  .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \
+    ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \
+    OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL))');
   next();
 }, rqf.build(), query, addMissing(rqf), id2str.transform(), response('auxiliar'));
 
-auxiliarApp.get('/download', passport.authenticate('bearer', { session: false }), rqf.parse(), rqf.build(), download('docente', 'mapping_docente'));
-
 module.exports = auxiliarApp;
diff --git a/src/libs/routes/city.js b/src/libs/routes/city.js
index 09a2763050a7897829a6c249fc538c3afb947610..4249487876a24ee3788160f1676e33207cf6d3a6 100644
--- a/src/libs/routes/city.js
+++ b/src/libs/routes/city.js
@@ -56,8 +56,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/classCount.js b/src/libs/routes/classCount.js
index a68675b5d58f3f379b00a26d1e20dce0b666b8e6..efa330119c0804720eab15756d186faec4b42ad4 100644
--- a/src/libs/routes/classCount.js
+++ b/src/libs/routes/classCount.js
@@ -86,8 +86,8 @@ rqf.addField({
 .addValue({
   name: 'state',
   table: 'estado',
-  tableField: 'nome',
-  resultField: 'state_name',
+  tableField: ['nome', 'id'],
+  resultField: ['state_name', 'state_id'],
   where: {
     relation: '=',
     type: 'integer',
@@ -102,8 +102,8 @@ rqf.addField({
 }).addValue({
   name: 'region',
   table: 'regiao',
-  tableField: 'nome',
-  resultField: 'region_name',
+  tableField: ['nome', 'id'],
+  resultField: ['region_name', 'region_id'],
   where: {
     relation: '=',
     type: 'integer',
diff --git a/src/libs/routes/classroom.js b/src/libs/routes/classroom.js
index 553dbe50de4c917109a2e14390d4b93de273b2ac..538ca7b066b3ef08d6ef3e53508d6e234341c3b9 100644
--- a/src/libs/routes/classroom.js
+++ b/src/libs/routes/classroom.js
@@ -162,8 +162,8 @@ rqf.addField({
 }, 'filter').addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -178,8 +178,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -260,6 +260,7 @@ classroomApp.get('/', cache('15 day'), rqf.parse(), rqf.build(), (req, res, next
                 let newObj = Object.assign({}, req.result[0]);
                 newObj.location_id = i;
                 newObj.total = 0;
+                newObj.location_name = (i == 1) ? "Urbana" : "Rural";
                 result.push(newObj);
             }
             else {
diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js
index 60b222f09267837ab5ad5d49682c5b19a0627bd5..bf447a3ba3924b6bf8a1b7f17c732119d4a21448 100644
--- a/src/libs/routes/classroomCount.js
+++ b/src/libs/routes/classroomCount.js
@@ -116,8 +116,8 @@ rqf.addField({
 }, 'dims').addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/dailyChargeAmount.js b/src/libs/routes/dailyChargeAmount.js
index d9a02d779ad0355683769910b40780d8bac77c3d..4eef5dcd17670c39c0fa1521fdf99dc8f09ece28 100644
--- a/src/libs/routes/dailyChargeAmount.js
+++ b/src/libs/routes/dailyChargeAmount.js
@@ -1,3 +1,23 @@
+/*
+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 dailyChargeAmountApp = express.Router();
@@ -20,17 +40,16 @@ const request = require(`request`);
 
 const config = require(`${libs}/config`);
 
-const passport = require('passport');
-
-const download = require(`${libs}/middlewares/downloadDatabase`);
-
 const addMissing = require(`${libs}/middlewares/addMissing`);
 
 const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
 
 let rqf = new ReqQueryFields();
+
 let rqfCount = new ReqQueryFields();
 
+//dailyChargeAmountApp.use(cache('15 day'));
+
 dailyChargeAmountApp.get('/year_range', (req, res, next) => {
     req.sql.from('turma')
     .field('MIN(turma.ano_censo)', 'start_year')
@@ -159,8 +178,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -174,8 +193,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -407,21 +426,23 @@ dailyChargeAmountApp.get('/average', rqf.parse(), rqf.build(), (req, res, next)
         let tableR = baseQ.clone();
         tableR.from('turma')
         .field('duracao_turma')
+        .field('etapas_mod_ensino_segmento_id')
         .field('ROW_NUMBER() OVER(PARTITION BY etapas_mod_ensino_segmento_id ORDER BY duracao_turma)', 'rowno')
         .where('tipo_turma_id <= 3')
 
         let tableG = baseQ.clone();
         tableG.from('turma')
         .field('1+COUNT(*)', 'counter')
+        .field('etapas_mod_ensino_segmento_id')
         .where('tipo_turma_id <= 3')
         .group('etapas_mod_ensino_segmento_id')
 
         let joinRG = squel.select();
         joinRG.from(tableR, 'R')
-        .field('R.education_level_mod_id')
+        .field('R.etapas_mod_ensino_segmento_id')
         .field('AVG(1.0*R.duracao_turma)/60', 'median_value')
-        .join(tableG, 'G', 'R.education_level_mod_id = G.education_level_mod_id AND R.rowNo BETWEEN G.counter/2 AND G.counter/2+G.counter%2')
-        .group('R.education_level_mod_id')
+        .join(tableG, 'G', 'R.etapas_mod_ensino_segmento_id = G.etapas_mod_ensino_segmento_id AND R.rowNo BETWEEN G.counter/2 AND G.counter/2+G.counter%2')
+        .group('R.etapas_mod_ensino_segmento_id')
 
         req.sql
         .from('turma')
@@ -437,7 +458,7 @@ dailyChargeAmountApp.get('/average', rqf.parse(), rqf.build(), (req, res, next)
         .group('turma.etapas_mod_ensino_segmento_id')
         .order('turma.ano_censo')
         .order('turma.etapas_mod_ensino_segmento_id')
-        .where('turma.tipo_turma_id <= 3 and m.education_level_mod_id = turma.etapas_mod_ensino_segmento_id')
+        .where('turma.tipo_turma_id <= 3 and m.etapas_mod_ensino_segmento_id = turma.etapas_mod_ensino_segmento_id')
     } else {
         res.status(400);
         next({
diff --git a/src/libs/routes/distributionFactor.js b/src/libs/routes/distributionFactor.js
index df4d84b797884f71f92e55456ed365317d98679a..8a7b0e28b8bd3f1678cf9721e4e54c67edfe029c 100644
--- a/src/libs/routes/distributionFactor.js
+++ b/src/libs/routes/distributionFactor.js
@@ -1,3 +1,23 @@
+/*
+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 distributionApp = express.Router();
@@ -67,8 +87,8 @@ rqf.addField({
 }, 'filter').addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -83,8 +103,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js
index e61c44cfd2c049cb484230958a404703642ce1a1..1e119d1f99a2ca872b8d63934c483a233c8cbbad 100644
--- a/src/libs/routes/employees.js
+++ b/src/libs/routes/employees.js
@@ -1,3 +1,23 @@
+/*
+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 employeesApp = express.Router();
@@ -18,8 +38,6 @@ const id2str = require(`${libs}/middlewares/id2str`);
 
 const config = require(`${libs}/config`);
 
-const passport = require('passport');
-
 const addMissing = require(`${libs}/middlewares/addMissing`);
 
 const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]}  }).middleware;
@@ -128,8 +146,8 @@ rqfSchool.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -143,8 +161,8 @@ rqfSchool.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -278,8 +296,8 @@ rqfTeacher.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -293,8 +311,8 @@ rqfTeacher.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js
index 695d624bd1bb9903248e15e603a8fe1e14211ca2..87083fcf8d38eeca2b75eafc9b68e84a1dd3f096 100644
--- a/src/libs/routes/enrollment.js
+++ b/src/libs/routes/enrollment.js
@@ -80,14 +80,13 @@ enrollmentApp.get('/location', (req, res, next) => {
 }, response('location'));
 
 enrollmentApp.get('/rural_location', (req, res, next) => {
-    req.result = [
-        {id: 1, name: "Urbana"},
-        {id: 2, name: "Rural"},
-        {id: 3, name: "Rural - Área de assentamento"},
-        {id: 4, name: "Rural - Terra indígena"},
-        {id: 5, name: "Rural - Área remanescente de quilombos"},
-        {id: 6, name: "Rural - Unidade de uso sustentável"}
-    ];
+    req.result = [];
+    for (let i = 1; i <= 8; i++) {
+        req.result.push({
+            id: i,
+            name: id2str.ruralLocation(i)
+        });
+    };
     next();
 }, response('rural_location'));
 
@@ -134,7 +133,10 @@ enrollmentApp.get('/education_level', (req, res, next) => {
 // Returns all school years available
 enrollmentApp.get('/education_level_mod', (req, res, next) => {
     req.result = [];
-    for(let i = 1; i <= 10; ++i) {
+    for(let i = 1; i <= 12; ++i) {
+        if (i == 3 || i == 6)
+            continue;
+        
         req.result.push({
             id: i,
             name: id2str.educationLevelMod(i)
@@ -175,7 +177,7 @@ enrollmentApp.get('/adm_dependency', (req, res, next) => {
 
 enrollmentApp.get('/adm_dependency_detailed', (req, res, next) => {
     req.result = [];
-    for(let i = 1; i <= 6; ++i) {
+    for(let i = 1; i <= 8; ++i) {
         req.result.push({
             id: i,
             name: id2str.admDependencyPriv(i)
@@ -207,7 +209,7 @@ enrollmentApp.get('/ethnic_group', (req, res, next) => {
 
 enrollmentApp.get('/period', (req, res, next) => {
     req.result = [];
-    for(let i = 1; i <= 3; ++i) {
+    for(let i = 1; i <= 4; ++i) {
         req.result.push({
             id: i,
             name: id2str.period(i)
@@ -327,8 +329,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -562,9 +564,9 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => {
     .from('matricula')
     .group('matricula.ano_censo')
     .order('matricula.ano_censo')
-    .where('matricula.tipo<=3');
+    .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), /*addMissing(rqf),*/ response('enrollment'));
+}, rqf.build(), query, id2str.transform(false), addMissing(rqf), response('enrollment'));
 
 enrollmentApp.get('/diagnosis', rqf.parse(), (req, res, next) => {
     req.dims = {};
diff --git a/src/libs/routes/glossEnrollmentRatio.js b/src/libs/routes/glossEnrollmentRatio.js
index 041a93ad4d025cd835066b60783d386acd13d0f9..6e100b0611bcf31a268d4c597568b5323101fff4 100644
--- a/src/libs/routes/glossEnrollmentRatio.js
+++ b/src/libs/routes/glossEnrollmentRatio.js
@@ -1,3 +1,23 @@
+/*
+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 glossEnrollmentRatioApp = express.Router();
@@ -22,10 +42,6 @@ const addMissing = require(`${libs}/middlewares/addMissing`);
 
 const config = require(`${libs}/config`);
 
-const download = require(`${libs}/middlewares/downloadDatabase`);
-
-const passport = require('passport');
-
 const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
 
 let rqf = new ReqQueryFields();
@@ -144,8 +160,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -159,8 +175,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/idhm.js b/src/libs/routes/idhm.js
index 45a193e7750aab100b417a25affae69b0678ea71..5b941793f366742ff6dd43278046f4c5717f6441 100644
--- a/src/libs/routes/idhm.js
+++ b/src/libs/routes/idhm.js
@@ -1,3 +1,23 @@
+/*
+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 idhmApp = express.Router();
@@ -95,8 +115,8 @@ rqf.addField({
 }).addValue({
     name: 'city',
     table: 'municipio',
-    tableField: 'nome',
-    resultField: 'city_name',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -111,8 +131,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/idhme.js b/src/libs/routes/idhme.js
index 2a1f4d033fc61b8f96a50d4a42001fca4da52b60..1b492c610de2c79ecf77b5b378d2e72616536fd6 100644
--- a/src/libs/routes/idhme.js
+++ b/src/libs/routes/idhme.js
@@ -1,3 +1,23 @@
+/*
+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 idhmeApp = express.Router();
@@ -81,8 +101,8 @@ rqf.addField({
 }).addValue({
     name: 'city',
     table: 'municipio',
-    tableField: 'nome',
-    resultField: 'city_name',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -119,8 +139,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/idhml.js b/src/libs/routes/idhml.js
index 1fddee79146257c2f837a937bb5864fcdbab20af..eee89ddf8c0f918db089ab5f5f5e3249f15d05d0 100644
--- a/src/libs/routes/idhml.js
+++ b/src/libs/routes/idhml.js
@@ -1,3 +1,23 @@
+/*
+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 idhmlApp = express.Router();
@@ -81,8 +101,8 @@ rqf.addField({
 }).addValue({
     name: 'city',
     table: 'municipio',
-    tableField: 'nome',
-    resultField: 'city_name',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -119,8 +139,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/idhmr.js b/src/libs/routes/idhmr.js
index 938d58a93db62f00185c08a22a75f34403541c27..a9117cb4180bf2b5ffc17084ddf65c7febcdbc47 100644
--- a/src/libs/routes/idhmr.js
+++ b/src/libs/routes/idhmr.js
@@ -1,3 +1,23 @@
+/*
+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 idhmrApp = express.Router();
@@ -83,8 +103,8 @@ rqf.addField({
 }).addValue({
     name: 'city',
     table: 'municipio',
-    tableField: 'nome',
-    resultField: 'city_name',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -99,8 +119,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/infrastructure.js b/src/libs/routes/infrastructure.js
index 9b929312d7d66f47641f263d69c0c5f4b914a90e..1ececa918e451d702b1319511a8dca0230e3eae8 100644
--- a/src/libs/routes/infrastructure.js
+++ b/src/libs/routes/infrastructure.js
@@ -1,3 +1,23 @@
+/*
+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 infrastructureApp = express.Router();
@@ -163,8 +183,8 @@ rqf.addField({
 }, 'filter').addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/liquidEnrollmentRatio.js b/src/libs/routes/liquidEnrollmentRatio.js
index 7324709e8eaed83481466c555d519a4e3554277e..103b7fb769dfa8352b69083324d2bf44a037ecc4 100644
--- a/src/libs/routes/liquidEnrollmentRatio.js
+++ b/src/libs/routes/liquidEnrollmentRatio.js
@@ -1,3 +1,23 @@
+/*
+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 liquidEnrollmentRatioApp = express.Router();
@@ -22,10 +42,6 @@ const addMissing = require(`${libs}/middlewares/addMissing`);
 
 const config = require(`${libs}/config`);
 
-const download = require(`${libs}/middlewares/downloadDatabase`);
-
-const passport = require('passport');
-
 const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
 
 let rqf = new ReqQueryFields();
@@ -144,8 +160,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -159,8 +175,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -398,7 +414,7 @@ liquidEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
     next();
 }, rqf.build(), query, id2str.transform(), (req, res, next) => {
     req.denominator = req.result;
-
+    
     //division to generate req.result final
     req.result = []
     let liquidEnrollment = matchQueries(req.denominator, req.numerator);
diff --git a/src/libs/routes/outOfSchool.js b/src/libs/routes/outOfSchool.js
index 3d8f33d9959d70906877f767ef242685f54f6350..91bac8dda9bb3a4057f0a3aa892899e99e94bd61 100644
--- a/src/libs/routes/outOfSchool.js
+++ b/src/libs/routes/outOfSchool.js
@@ -1,3 +1,23 @@
+/*
+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 outOfSchoolApp = express.Router();
@@ -118,8 +138,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -133,8 +153,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -252,14 +272,44 @@ simcaqRqf.addField({
     field: true,
     where: false
 }).addValue({
-    name: 'state',
+    name: 'brazil_total',
     table: 'populacao_fora_da_escola',
-    tableField: 'unidade_federativa',
-    resultField: 'state_id',
+    tableField: 'brasil',
+    resultField: 'brazil_total_id',
+    where: {
+        relation: '=',
+        type: 'boolean',
+        field: 'brasil'
+    }
+}).addValue({
+    name: 'state',
+    table: 'estado',
+    tableField: 'nome',
+    resultField: 'state_name',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'id'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'estado_id',
+        foreignTable: 'populacao_fora_da_escola'
+    }
+}).addValue({
+    name: 'city',
+    table: 'municipio',
+    tableField: 'nome',
+    resultField: 'city_name',
     where: {
         relation: '=',
         type: 'integer',
-        field: 'unidade_federativa'
+        field: 'id'
+    },
+    join: {
+        primary: 'id',
+        foreign: 'municipio_id',
+        foreignTable: 'populacao_fora_da_escola'
     }
 }).addValue({
     name: 'pfe',
@@ -307,7 +357,6 @@ outOfSchoolApp.get('/simcaq', simcaqRqf.parse(), simcaqRqf.build(), (req, res, n
 }, query, (req, res, next) => {
 	req.result.forEach((i) => {
 		i.total = parseInt(i.total);
-		console.log(i.total);
 	});
 	next();
 }, addMissing(simcaqRqf), id2str.transform(), response('out_of_school'));
diff --git a/src/libs/routes/pibpercapita.js b/src/libs/routes/pibpercapita.js
index de1ec7d60b1699675701ac8c7906a6b24052eaff..a98386df3afbd6200a100e6d33a5bd56f6244ac6 100644
--- a/src/libs/routes/pibpercapita.js
+++ b/src/libs/routes/pibpercapita.js
@@ -1,3 +1,23 @@
+/*
+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 pibpercapitaApp = express.Router();
@@ -102,8 +122,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
       relation: '=',
       type: 'integer',
diff --git a/src/libs/routes/population.js b/src/libs/routes/population.js
index f0402daa73c13eb6453b4e3d584bfe11b8145a01..9488570010d0ecc8783cd9bf32b45ffac1be8367 100644
--- a/src/libs/routes/population.js
+++ b/src/libs/routes/population.js
@@ -1,3 +1,23 @@
+/*
+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 populationApp = express.Router();
@@ -79,8 +99,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -95,8 +115,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/rateSchool.js b/src/libs/routes/rateSchool.js
index a45865a9337e027cdbec45bd8b0163bd4477112c..a6a91b7be08919cc1ab12a304ee1832cfddfc84e 100644
--- a/src/libs/routes/rateSchool.js
+++ b/src/libs/routes/rateSchool.js
@@ -1,3 +1,23 @@
+/*
+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 rateSchoolApp = express.Router();
@@ -20,10 +40,6 @@ const id2str = require(`${libs}/middlewares/id2str`);
 
 const config = require(`${libs}/config`);
 
-const download = require(`${libs}/middlewares/downloadDatabase`);
-
-const passport = require('passport');
-
 const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
 
 rateSchoolApp.use(cache('15 day'));
@@ -122,8 +138,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -137,8 +153,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -318,6 +334,4 @@ rateSchoolApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
     next();
 }, id2str.transform(false), response('rateSchool'));
 
-rateSchoolApp.get('/download', passport.authenticate('bearer', { session: false }), rqf.parse(), rqf.build(), download('pnad', 'mapping_pnad'));
-
 module.exports = rateSchoolApp;
diff --git a/src/libs/routes/schoolInfrastructure.js b/src/libs/routes/schoolInfrastructure.js
index 226535fd0edea23458164261f11fba7199ba098e..32f316a4bff24d78a893ddc60f39e8381e4b64c4 100644
--- a/src/libs/routes/schoolInfrastructure.js
+++ b/src/libs/routes/schoolInfrastructure.js
@@ -183,8 +183,8 @@ rqf.addField({
 }, 'filter').addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/siope.js b/src/libs/routes/siope.js
index 51c1c36833b99ff097cf8a85a0c90c20598f737b..1ef9f1010c69179db623a60c74623c85be9a9215 100644
--- a/src/libs/routes/siope.js
+++ b/src/libs/routes/siope.js
@@ -1,3 +1,23 @@
+/*
+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 siopeApp = express.Router();
@@ -55,8 +75,8 @@ rqf.addField({
 }).addValue({
     name: 'city',
     table: 'municipio',
-    tableField: 'nome',
-    resultField: 'city_name',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/spatial.js b/src/libs/routes/spatial.js
index 865be3070103b05b382545d2c82c8d547c42eff9..d4f48fe8eda00fe562b60e83bf69416c81694d33 100644
--- a/src/libs/routes/spatial.js
+++ b/src/libs/routes/spatial.js
@@ -1,3 +1,23 @@
+/*
+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 libs = `${process.cwd()}/libs`;
@@ -52,8 +72,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -66,8 +86,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -80,8 +100,8 @@ rqf.addField({
 }).addValue({
     name: 'city',
     table: 'municipio',
-    tableField: 'nome',
-    resultField: 'city_name',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/state.js b/src/libs/routes/state.js
index 6fab1fc811baebc1a6b779f22f2985cd7354a290..7ee322867863d0381b49c2221dbf342f860ab4b7 100644
--- a/src/libs/routes/state.js
+++ b/src/libs/routes/state.js
@@ -56,8 +56,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/transport.js b/src/libs/routes/transport.js
index 8327c4f6db58bd6ff49a0ed7221e0a4e529b475d..afe7049a624c043b052ed650f59056962c6cd5ff 100644
--- a/src/libs/routes/transport.js
+++ b/src/libs/routes/transport.js
@@ -171,8 +171,8 @@ rqf.addField({
 }).addValue({
     name: 'region',
     table: 'regiao',
-    tableField: 'nome',
-    resultField: 'region_name',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -186,8 +186,8 @@ rqf.addField({
 }).addValue({
     name: 'city',
     table: 'municipio',
-    tableField: 'nome',
-    resultField: 'city_name',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
     where: {
         relation: '=',
         type: 'integer',
diff --git a/src/libs/routes/university.js b/src/libs/routes/university.js
index 959f4adb331344515f139582014150cebbe43749..be7fe771609b5c4e6a89d98217724c60d0436a5d 100644
--- a/src/libs/routes/university.js
+++ b/src/libs/routes/university.js
@@ -113,8 +113,8 @@ rqf.addField({
 }).addValue({
     name: 'city',
     table: 'municipio',
-    tableField: 'nome',
-    resultField: 'city_name',
+    tableField: ['nome', 'id'],
+    resultField: ['city_name', 'city_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -129,8 +129,8 @@ rqf.addField({
 }).addValue({
     name: 'state',
     table: 'estado',
-    tableField: 'nome',
-    resultField: 'state_name',
+    tableField: ['nome', 'id'],
+    resultField: ['state_name', 'state_id'],
     where: {
         relation: '=',
         type: 'integer',
@@ -142,6 +142,21 @@ rqf.addField({
         foreign: 'cod_uf_ies',
         foreignTable: 'ies_ens_superior'
     }
+}).addValue({
+    name: 'region',
+    table: 'regiao',
+    tableField: ['nome', 'id'],
+    resultField: ['region_name', 'region_id'],
+    where: {
+        relation: 'LIKE',
+        type: 'string',
+        field: 'id'
+    },
+    join: {
+        primary: 'nome',
+        foreign: 'nome_regiao_ies',
+        foreignTable: 'ies_ens_superior'
+    }
 }).addValue({
     name: 'year',
     table: 'ies_ens_superior',
@@ -312,7 +327,8 @@ universityApp.get('/', rqf.parse(),  rqf.build(), (req, res, next) => {
         .field('ies_ens_superior.ano_censo', 'year')
         .field('ies_ens_superior.nome_ies', 'name')
         .field('ies_ens_superior.cod_uf_ies', 'state_id')
-        .field('ies_ens_superior.cod_municipio_ies', 'city_id');
+        .field('ies_ens_superior.cod_municipio_ies', 'city_id')
+        .field('ies_ens_superior.cod_uf_ies/10', 'region_id');
     next();
 
 }, query, response('university'));