Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simcaq-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simcaq
simcaq-node
Commits
67d966e5
Commit
67d966e5
authored
3 months ago
by
tgcl21
Browse files
Options
Downloads
Patches
Plain Diff
Starded fixes
parent
9c9b68cd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/routes_v1/enrollmentRate.js
+61
-21
61 additions, 21 deletions
src/libs/routes_v1/enrollmentRate.js
with
61 additions
and
21 deletions
src/libs/routes_v1/enrollmentRate.js
+
61
−
21
View file @
67d966e5
...
@@ -110,6 +110,25 @@ EnrollmentRateApp.get('/state', (req, res, next) => {
...
@@ -110,6 +110,25 @@ EnrollmentRateApp.get('/state', (req, res, next) => {
next
();
next
();
},
response
(
'
state
'
));
},
response
(
'
state
'
));
EnrollmentRateApp
.
get
(
'
/age_range
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[]
for
(
let
i
=
1
;
i
<
6
;
i
++
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
ageRange
(
i
)
});
}
next
();
},
response
(
'
age_range
'
));
EnrollmentRateApp
.
get
(
'
/attended_modality
'
,
(
req
,
res
,
next
)
=>
{
req
.
result
=
[]
for
(
let
i
=
1
;
i
<
8
;
i
++
)
{
req
.
result
.
push
({
id
:
i
,
name
:
id2str
.
attendedModality
(
i
)
});
}
next
();
},
response
(
'
attended_modality
'
));
rqf
.
addField
({
rqf
.
addField
({
...
@@ -121,7 +140,7 @@ rqf.addField({
...
@@ -121,7 +140,7 @@ rqf.addField({
field
:
true
,
field
:
true
,
where
:
false
where
:
false
}).
addValue
({
}).
addValue
({
name
:
'
locat
io
n
'
,
name
:
'
situacao_domicil
io
'
,
table
:
'
pnad_novo
'
,
table
:
'
pnad_novo
'
,
tableField
:
'
situacao_domicilio
'
,
tableField
:
'
situacao_domicilio
'
,
resultField
:
'
location_id
'
,
resultField
:
'
location_id
'
,
...
@@ -141,10 +160,10 @@ rqf.addField({
...
@@ -141,10 +160,10 @@ rqf.addField({
field
:
'
localizacao_id
'
field
:
'
localizacao_id
'
}
}
}).
addValue
({
}).
addValue
({
name
:
'
c
ap_code
'
,
name
:
'
c
od_cap
'
,
table
:
'
pnad_novo
'
,
table
:
'
pnad_novo
'
,
tableField
:
'
cod_cap
'
,
tableField
:
'
cod_cap
'
,
resultField
:
'
c
ap_code
_id
'
,
resultField
:
'
c
od_cap
_id
'
,
where
:
{
where
:
{
relation
:
'
=
'
,
relation
:
'
=
'
,
type
:
'
integer
'
,
type
:
'
integer
'
,
...
@@ -161,7 +180,7 @@ rqf.addField({
...
@@ -161,7 +180,7 @@ rqf.addField({
field
:
'
municipio_id
'
field
:
'
municipio_id
'
}
}
}).
addValue
({
}).
addValue
({
name
:
'
regio
n
'
,
name
:
'
cod_
regi
a
o
'
,
table
:
'
pnad_novo
'
,
table
:
'
pnad_novo
'
,
tableField
:
'
cod_regiao
'
,
tableField
:
'
cod_regiao
'
,
resultField
:
'
region_id
'
,
resultField
:
'
region_id
'
,
...
@@ -181,10 +200,10 @@ rqf.addField({
...
@@ -181,10 +200,10 @@ rqf.addField({
field
:
'
regiao_id
'
field
:
'
regiao_id
'
}
}
}).
addValue
({
}).
addValue
({
name
:
'
state
'
,
name
:
'
cod_uf
'
,
table
:
'
pnad_novo
'
,
table
:
'
pnad_novo
'
,
tableField
:
'
cod_uf
'
,
tableField
:
'
cod_uf
'
,
resultField
:
'
cod_uf
'
,
resultField
:
'
cod_uf
_id
'
,
where
:
{
where
:
{
relation
:
'
=
'
,
relation
:
'
=
'
,
type
:
'
integer
'
,
type
:
'
integer
'
,
...
@@ -213,7 +232,6 @@ rqf.addField({
...
@@ -213,7 +232,6 @@ rqf.addField({
})
})
function
matchQueries
(
queryPartial
,
queryTotal
)
{
function
matchQueries
(
queryPartial
,
queryTotal
)
{
let
match
=
[];
let
match
=
[];
console
.
log
(
queryPartial
,
queryTotal
)
console
.
log
(
queryPartial
,
queryTotal
)
...
@@ -222,46 +240,60 @@ function matchQueries(queryPartial, queryTotal) {
...
@@ -222,46 +240,60 @@ function matchQueries(queryPartial, queryTotal) {
queryPartial
.
forEach
((
partial
)
=>
{
queryPartial
.
forEach
((
partial
)
=>
{
console
.
log
(
result
.
year
,
partial
.
year
)
console
.
log
(
result
.
year
,
partial
.
year
)
if
(
result
.
year
===
partial
.
year
)
{
if
(
result
.
year
===
partial
.
year
)
{
switch
(
result
.
age_range
)
{
case
1
:
console
.
log
(
"
é 1
"
)
match
.
push
({
match
.
push
({
year
:
result
.
year
,
year
:
result
.
year
,
age_range
:
result
.
age_range
,
age_range
:
result
.
age_range
,
age_range_name
:
id2str
.
ageRange
(
result
.
age_range
),
location
:
result
.
location
,
location_name
:
id2str
.
location
(
result
.
location
),
cap_code
:
result
.
cap_code
,
cap_code_name
:
id2str
.
capitalCode
(
result
.
cap_code
),
region
:
result
.
region
,
region_name
:
id2str
.
regionCode
(
result
.
region
),
state
:
result
.
state
,
state_name
:
id2str
.
stateName
(
result
.
state
)
});
switch
(
result
.
age_range
)
{
case
1
:
match
.
push
({
// total: result.total,
// total: result.total,
// total_partial: partial.total_inf_cre,
// total_partial: partial.total_inf_cre,
attended_modality_id
:
1
,
attended_modality_name
:
id2str
.
attendedModality
(
1
),
total
:
((
partial
.
total_inf_cre
/
result
.
total
)
*
100
).
toFixed
(
2
),
total
:
((
partial
.
total_inf_cre
/
result
.
total
)
*
100
).
toFixed
(
2
),
});
});
found
=
true
;
found
=
true
;
break
;
break
;
case
2
:
case
2
:
match
.
push
({
match
.
push
({
year
:
result
.
year
,
attended_modality_id
:
2
,
a
ge_range
:
result
.
age_range
,
a
ttended_modality_name
:
id2str
.
attendedModality
(
2
)
,
total
:
((
partial
.
total_inf_pre
/
result
.
total
)
*
100
).
toFixed
(
2
),
total
:
((
partial
.
total_inf_pre
/
result
.
total
)
*
100
).
toFixed
(
2
),
});
});
found
=
true
;
found
=
true
;
break
;
break
;
case
3
:
case
3
:
match
.
push
({
match
.
push
({
year
:
result
.
year
,
attended_modality_id
:
4
,
a
ge_range
:
result
.
age_range
,
a
ttended_modality_name
:
id2str
.
attendedModality
(
4
)
,
total
:
((
partial
.
total_fund_ai
/
result
.
total
)
*
100
).
toFixed
(
2
),
total
:
((
partial
.
total_fund_ai
/
result
.
total
)
*
100
).
toFixed
(
2
),
});
});
found
=
true
;
found
=
true
;
break
;
break
;
case
4
:
case
4
:
match
.
push
({
match
.
push
({
year
:
result
.
year
,
attended_modality_id
:
5
,
a
ge_range
:
result
.
age_range
,
a
ttended_modality_name
:
id2str
.
attendedModality
(
5
)
,
total
:
((
partial
.
total_fund_af
/
result
.
total
)
*
100
).
toFixed
(
2
),
total
:
((
partial
.
total_fund_af
/
result
.
total
)
*
100
).
toFixed
(
2
),
});
});
found
=
true
;
found
=
true
;
break
;
break
;
case
5
:
case
5
:
match
.
push
({
match
.
push
({
year
:
result
.
year
,
attended_modality_id
:
7
,
a
ge_range
:
result
.
age_range
,
a
ttended_modality
:
id2str
.
attendedModality
(
7
)
,
total
:
((
partial
.
total_med
/
result
.
total
)
*
100
).
toFixed
(
2
),
total
:
((
partial
.
total_med
/
result
.
total
)
*
100
).
toFixed
(
2
),
});
});
found
=
true
;
found
=
true
;
...
@@ -275,8 +307,8 @@ function matchQueries(queryPartial, queryTotal) {
...
@@ -275,8 +307,8 @@ function matchQueries(queryPartial, queryTotal) {
});
});
if
(
!
found
)
{
if
(
!
found
)
{
match
.
push
({
match
.
push
({
year
:
result
.
year
,
attended_modality_id
:
0
,
a
ge_range
:
result
.
age_range
,
a
ttended_modality_name
:
'
Não informado
'
,
total
:
result
.
total
,
total
:
result
.
total
,
total_taxa
:
0
,
total_taxa
:
0
,
});
});
...
@@ -307,10 +339,18 @@ req.querySet = [];
...
@@ -307,10 +339,18 @@ req.querySet = [];
.
from
(
'
pnad_novo
'
)
.
from
(
'
pnad_novo
'
)
.
field
(
'
round(sum(pnad_novo.peso_domicilio_pessoas_com_cal), 0)
'
,
'
total
'
)
.
field
(
'
round(sum(pnad_novo.peso_domicilio_pessoas_com_cal), 0)
'
,
'
total
'
)
.
field
(
'
pnad_novo.faixa_etaria
'
,
'
age_range
'
)
.
field
(
'
pnad_novo.faixa_etaria
'
,
'
age_range
'
)
.
field
(
'
pnad_novo.cod_uf
'
,
'
state
'
)
.
field
(
'
pnad_novo.situacao_domicilio
'
,
'
location
'
)
.
field
(
'
pnad_novo.cod_cap
'
,
'
cap_code
'
)
.
field
(
'
pnad_novo.cod_regiao
'
,
'
region
'
)
.
field
(
'
pnad_novo.ano_ref
'
,
'
year
'
)
.
field
(
'
pnad_novo.ano_ref
'
,
'
year
'
)
.
where
(
'
pnad_novo.ano_ref IN (2019, 2022, 2023) AND pnad_novo.faixa_etaria IN (1, 2, 3, 4, 5)
'
)
.
where
(
'
pnad_novo.ano_ref IN (2019, 2022, 2023) AND pnad_novo.faixa_etaria IN (1, 2, 3, 4, 5)
'
)
.
group
(
'
pnad_novo.ano_ref
'
)
.
group
(
'
pnad_novo.ano_ref
'
)
.
group
(
'
pnad_novo.faixa_etaria
'
)
.
group
(
'
pnad_novo.faixa_etaria
'
)
.
group
(
'
pnad_novo.cod_uf
'
)
.
group
(
'
pnad_novo.situacao_domicilio
'
)
.
group
(
'
pnad_novo.cod_cap
'
)
.
group
(
'
pnad_novo.cod_regiao
'
)
.
order
(
'
pnad_novo.ano_ref
'
)
.
order
(
'
pnad_novo.ano_ref
'
)
.
order
(
'
pnad_novo.faixa_etaria
'
);
.
order
(
'
pnad_novo.faixa_etaria
'
);
...
@@ -324,6 +364,6 @@ next();
...
@@ -324,6 +364,6 @@ next();
let
newObj
=
matchQueries
(
req
.
result
[
0
],
req
.
result
[
1
]);
let
newObj
=
matchQueries
(
req
.
result
[
0
],
req
.
result
[
1
]);
req
.
result
=
newObj
;
req
.
result
=
newObj
;
next
();
next
();
},
id2str
.
transform
(
false
),
response
(
'
enrollmentRate
'
));
},
response
(
'
enrollmentRate
'
));
module
.
exports
=
EnrollmentRateApp
;
module
.
exports
=
EnrollmentRateApp
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment