diff --git a/src/libs/convert/attendedModality.js b/src/libs/convert/attendedModality.js index be06810ecc0bf861454dc364af7543ae3f700bbb..fd6162a5d5e690fd865c1614af0cb29ab40b5211 100644 --- a/src/libs/convert/attendedModality.js +++ b/src/libs/convert/attendedModality.js @@ -18,7 +18,7 @@ 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 modality(id) { +module.exports = function attendedModality(id) { switch (id) { case 1: return 'Creche'; diff --git a/src/libs/convert/attendsSchool.js b/src/libs/convert/attendsSchool.js index 836e9fbd7dbd455d7c781785d40a76fe7857f1b8..c5192999af083af6b66bc17f0c2b3e0a9ebf20c9 100644 --- a/src/libs/convert/attendsSchool.js +++ b/src/libs/convert/attendsSchool.js @@ -18,11 +18,14 @@ You should have received a copy of the GNU General Public License along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ +// This file is used to convert the attendsSchool AND 'bolsa_familia' variable to a human-readable format. module.exports = function attendsSchool(id) { switch (id) { case 1: return 'Sim'; case 2: return 'Não'; + case 9: + return 'Sem informação'; } }; diff --git a/src/libs/convert/capitalCode.js b/src/libs/convert/capitalCode.js new file mode 100644 index 0000000000000000000000000000000000000000..2e4774f53cd92e9b6f69360b8664b538b2fe6b63 --- /dev/null +++ b/src/libs/convert/capitalCode.js @@ -0,0 +1,81 @@ +/* +Copyright (C) 2024 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 capitalCode(id) { + switch (id) { + case 11: + return 'Porto Velho'; + case 12: + return 'Rio Branco'; + case 13: + return 'Manaus'; + case 14: + return 'Boa Vista'; + case 15: + return 'Belém'; + case 16: + return 'Macapá'; + case 17: + return 'Palmas'; + case 21: + return 'São LuÃs'; + case 22: + return 'Teresina'; + case 23: + return 'Fortaleza'; + case 24: + return 'Natal'; + case 25: + return 'João Pessoa'; + case 26: + return 'Recife'; + case 27: + return 'Maceió'; + case 28: + return 'Aracaju'; + case 29: + return 'Salvador'; + case 31: + return 'Belo Horizonte'; + case 32: + return 'Vitória'; + case 33: + return 'Rio de Janeiro'; + case 35: + return 'São Paulo'; + case 41: + return 'Curitiba'; + case 42: + return 'Florianópolis'; + case 43: + return 'Porto Alegre'; + case 50: + return 'Campo Grande'; + case 51: + return 'Cuiabá'; + case 52: + return 'Goiânia'; + case 53: + return 'BrasÃlia'; + default: + return 'Não é capital'; + } +}; + diff --git a/src/libs/convert/ethnicGroupNewPnad.js b/src/libs/convert/ethnicGroupNewPnad.js new file mode 100644 index 0000000000000000000000000000000000000000..cfbd60e176b014a66fc2ba2dd681cb5203320e38 --- /dev/null +++ b/src/libs/convert/ethnicGroupNewPnad.js @@ -0,0 +1,36 @@ +/* +Copyright (C) 2024 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 ethnicGroupNewPnad(id) { + switch (id) { + case 1: + return 'Branca'; + case 2: + return 'Preta'; + case 3: + return 'Amarela'; + case 4: + return 'Parda'; + case 5: + return 'IndÃgena'; + case 9: + return 'Sem declaração'; + } +}; diff --git a/src/libs/convert/metroCode.js b/src/libs/convert/metroCode.js new file mode 100644 index 0000000000000000000000000000000000000000..e7729bb454e0c6b5a8785a84c22d1cb9c59b0d3a --- /dev/null +++ b/src/libs/convert/metroCode.js @@ -0,0 +1,68 @@ +/* +Copyright (C) 2024 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 metroCode(id) { + switch (id) { + case 13: + return 'Região Metropolitana de Manaus'; + case 15: + return 'Região Metropolitana de Belém'; + case 16: + return 'Região Metropolitana de Macapá'; + case 21: + return 'Região Metropolitana de Grande São LuÃs'; + case 22: + return 'Região Administrativa Integrada de Desenvolvimento de Grande Teresina' + case 23: + return 'Região Metropolitana de Fortaleza'; + case 24: + return 'Região Metropolitana de Natal'; + case 25: + return 'Região Metropolitana de João Pessoa'; + case 26: + return 'Região Metropolitana de Recife'; + case 27: + return 'Região Metropolitana de Maceió'; + case 28: + return 'Região Metropolitana de Aracaju'; + case 29: + return 'Região Metropolitana de Salvador'; + case 31: + return 'Região Metropolitana de Belo Horizonte'; + case 32: + return 'Região Metropolitana de Grande Vitória'; + case 33: + return 'Região Metropolitana do Rio de Janeiro'; + case 35: + return 'Região Metropolitana de São Paulo'; + case 41: + return 'Região Metropolitana de Curitiba'; + case 42: + return 'Região Metropolitana de Florianópolis'; + case 43: + return 'Região Metropolitana de Porto Alegre'; + case 51: + return 'Região Metropolitana de Vale do Rio Cuiabá'; + case 52: + return 'Região Metropolitana de Goiânia'; + default: + return 'Não é região metropolitana ou região administrativa integrada'; + } +}; diff --git a/src/libs/convert/regionCode.js b/src/libs/convert/regionCode.js new file mode 100644 index 0000000000000000000000000000000000000000..fd21550366426a1a3ef8d1def4c6520a870a9ec6 --- /dev/null +++ b/src/libs/convert/regionCode.js @@ -0,0 +1,34 @@ +/* +Copyright (C) 2024 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 regionCode(id) { + switch (id) { + case 1: + return 'Norte'; + case 2: + return 'Nordeste'; + case 3: + return 'Sudeste'; + case 4: + return 'Sul' + case 5: + return 'Centro-Oeste'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index e47b068382400905aded93a385fb1e19b77dad99..268df2a95aca24741461a21da681abbe5366541c 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -108,6 +108,10 @@ const instructionLevel = require(`${libs}/convert/instructionLevel`); const attendsSchool = require(`${libs}/convert/attendsSchool`); const modality = require(`${libs}/convert/modality`); const attendedModality = require(`${libs}/convert/attendedModality`); +const ethnicGroupNewPnad = require(`${libs}/convert/ethnicGroupNewPnad`); +const capitalCode = require(`${libs}/convert/capitalCode`); +const regionCode = require(`${libs}/convert/regionCode`); +const metroCode = require(`${libs}/convert/metroCode`); const ids = { gender_id: gender, @@ -207,7 +211,12 @@ const ids = { instruction_level_id: instructionLevel, attends_school_id: attendsSchool, modality_id: modality, - attended_modality_id: attendedModality + attended_modality_id: attendedModality, + bolsa_familia_id: attendsSchool, + new_pnad_ethnic_group_id: ethnicGroupNewPnad, + cap_code_id: capitalCode, + reg_code_id: regionCode, + metro_code_id: metroCode }; function transform(removeId=false) { @@ -330,5 +339,9 @@ module.exports = { instructionLevel, attendsSchool, modality, - attendedModality + attendedModality, + ethnicGroupNewPnad, + capitalCode, + regionCode, + metroCode }; diff --git a/src/libs/routes_v1/newPnad.js b/src/libs/routes_v1/newPnad.js index 449d9cc4b5c0586db2263ce9d84662b8e2e36ce1..4f25783049618e93c27e24e52346d6e4b968da77 100644 --- a/src/libs/routes_v1/newPnad.js +++ b/src/libs/routes_v1/newPnad.js @@ -219,17 +219,17 @@ rqf.addField({ name: 'bolsa_familia', table: 'pnad_novo', tableField: 'recebeu_rendimentos_de_programa_bolsa_familia', - resultField: 'bolsa_familia', + resultField: 'bolsa_familia_id', where: { relation: '=', type: 'integer', field: 'recebeu_rendimentos_de_programa_bolsa_familia' } }).addValue({ - name: 'race', + name: 'new_pnad_ethnic_group', table: 'pnad_novo', tableField: 'cor_raca', - resultField: 'race', + resultField: 'new_pnad_ethnic_group_id', where: { relation: '=', type: 'integer', @@ -249,7 +249,7 @@ rqf.addField({ name: 'gender', table: 'pnad_novo', tableField: 'sexo', - resultField: 'gender', + resultField: 'gender_id', where: { relation: '=', type: 'integer', @@ -259,7 +259,7 @@ rqf.addField({ name: 'cap_code', table: 'pnad_novo', tableField: 'cod_cap', - resultField: 'cap_code', + resultField: 'cap_code_id', where: { relation: '=', type: 'integer', @@ -269,7 +269,7 @@ rqf.addField({ name: 'reg_code', table: 'pnad_novo', tableField: 'cod_regiao', - resultField: 'reg_code', + resultField: 'reg_code_id', where: { relation: '=', type: 'integer', @@ -279,7 +279,7 @@ rqf.addField({ name: 'metro_code', table: 'pnad_novo', tableField: 'cod_rm_ride', - resultField: 'metro_code', + resultField: 'metro_code_id', where: { relation: '=', type: 'integer',