Skip to content

Commit

Permalink
Merge pull request #603 from basedosdados/br-sinan-dengue
Browse files Browse the repository at this point in the history
[table-approve] br_ms_sinan
  • Loading branch information
tricktx authored May 16, 2024
2 parents e83da3b + 5c31110 commit 6db6032
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 4 deletions.
2 changes: 2 additions & 0 deletions models/br_ms_sinan/br_ms_sinan__dicionario.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
schema="br_ms_sinan",
)
}}

select
safe_cast(id_tabela as string) id_tabela,
safe_cast(coluna as string) nome_coluna,
safe_cast(chave as string) chave,
safe_cast(replace(cobertura_temporal, '-1', '(1)') as string) cobertura_temporal,
safe_cast(valor as string) valor

from `basedosdados-staging.br_ms_sinan_staging.dicionario` as t
101 changes: 97 additions & 4 deletions models/br_ms_sinan/br_ms_sinan__microdados_dengue.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"range": {"start": 2000, "end": 2025, "interval": 1},
},
cluster_by=["sigla_uf_notificacao", "sigla_uf_residencia"],
labels={"project_id": "basedosdados"},
labels={"tema": "saude"},
)
}}
{%- set columns = adapter.get_columns_in_relation(this) -%}
Expand Down Expand Up @@ -310,6 +310,19 @@ with
safe_cast(outros as string) apresenta_sintoma_outro,
safe_cast(sin_out as string) apresenta_qual_sintoma,
safe_cast(laco_n as string) prova_laco,
case
when dt_choque = ''
then null
else
safe_cast(
format_date(
'%Y-%m-%d',
safe.parse_date(
'%Y%m%d', regexp_replace(dt_choque, r'[^0-9]', '')
)
) as date
)
end data_choque,
safe_cast(hospitaliz as string) internacao,
case
when dt_interna = ''
Expand All @@ -324,7 +337,6 @@ with
) as date
)
end data_internacao,

case
when uf = '11'
then 'RO'
Expand Down Expand Up @@ -427,6 +439,19 @@ with
safe_cast(grav_mioc as string) grave_miocardite,
safe_cast(grav_consc as string) grave_consciencia,
safe_cast(grav_orgao as string) grave_orgaos,
case
when dt_grav = ''
then null
else
safe_cast(
format_date(
'%Y-%m-%d',
safe.parse_date(
'%Y%m%d', regexp_replace(dt_grav, r'[^0-9]', '')
)
) as date
)
end data_sinais_gravidade,
case
when dt_col_hem = ''
then null
Expand Down Expand Up @@ -518,17 +543,54 @@ with
) as date
)
end data_resultado_sorologia1_chikungunya,

case
when dt_soror2 = ''
then null
else
safe_cast(
format_date(
'%Y-%m-%d',
safe.parse_date(
'%Y%m%d', regexp_replace(dt_soror2, r'[^0-9]', '')
)
) as date
)
end data_resultado_sorologia2_chikungunya,
safe_cast(res_chiks1 as string) resultado_sorologia1_chikungunya,
safe_cast(s1_igm as string) sorologia1_igm,
safe_cast(s1_igg as string) sorologia1_igg,
safe_cast(s1_tit1 as string) sorologia1_tit1,
case
when dt_chik_s2 = ''
then null
else
safe_cast(
format_date(
'%Y-%m-%d',
safe.parse_date(
'%Y%m%d', regexp_replace(dt_chik_s2, r'[^0-9]', '')
)
) as date
)
end data_sorologia2_chikungunya,
safe_cast(res_chiks2 as string) resultado_sorologia2_chikungunya,
safe_cast(s2_igm as string) sorologia2_igm,
safe_cast(s2_igg as string) sorologia2_igg,
safe_cast(s2_tit1 as string) sorologia2_tit1,
safe_cast(resul_prnt as string) resultado_prnt,

case
when dt_prnt = ''
then null
else
safe_cast(
format_date(
'%Y-%m-%d',
safe.parse_date(
'%Y%m%d', regexp_replace(dt_prnt, r'[^0-9]', '')
)
) as date
)
end data_prnt,
case
when dt_ns1 = ''
then null
Expand Down Expand Up @@ -879,6 +941,11 @@ with
apresenta_sintoma_outro,
apresenta_qual_sintoma,
prova_laco,
case
when extract(year from data_choque) > extract(year from current_date)
then null
else data_choque
end data_choque,
internacao,
data_internacao,
sigla_uf_internacao,
Expand Down Expand Up @@ -913,6 +980,13 @@ with
grave_consciencia,
grave_orgaos,
data_hematocrito,
case
when
extract(year from data_sinais_gravidade)
> extract(year from current_date)
then null
else data_sinais_gravidade
end data_sinais_gravidade,
hematocrito_maior,
case
when extract(year from data_plaquetas) > extract(year from current_date)
Expand Down Expand Up @@ -941,10 +1015,29 @@ with
sorologia1_igg,
sorologia1_tit1,
resultado_sorologia2_chikungunya,
case
when
extract(year from data_sorologia2_chikungunya)
> extract(year from current_date)
then null
else data_sorologia2_chikungunya
end data_sorologia2_chikungunya,
case
when
extract(year from data_resultado_sorologia2_chikungunya)
> extract(year from current_date)
then null
else data_resultado_sorologia2_chikungunya
end data_resultado_sorologia2_chikungunya,
sorologia2_igm,
sorologia2_igg,
sorologia2_tit1,
resultado_prnt,
case
when extract(year from data_prnt) > extract(year from current_date)
then null
else data_prnt
end data_prnt,
data_ns1,
resultado_ns1,
data_viral,
Expand Down

0 comments on commit 6db6032

Please sign in to comment.