Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] br_ms_cnes.estabelecimento #513

Merged
merged 6 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions models/br_ms_cnes/br_ms_cnes__estabelecimento.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ select
safe_cast(ano as int64) as ano,
safe_cast(mes as int64) as mes,
safe_cast(sigla_uf as string) sigla_uf,
cast(substr(cast(dt_atual as string), 1, 4) as int64) as ano_atualizacao,
cast(substr(cast(dt_atual as string), 5, 2) as int64) as mes_atualizacao,
safe_cast(substr(cast(dt_atual as string), 1, 4) as int64) as ano_atualizacao,
safe_cast(substr(cast(dt_atual as string), 5, 2) as int64) as mes_atualizacao,
safe_cast(id_municipio as string) id_municipio,
safe_cast(codufmun as string) id_municipio_6,
safe_cast({{ clean_cols("REGSAUDE") }} as string) id_regiao_saude,
Expand Down Expand Up @@ -79,28 +79,26 @@ select
safe_cast(c_corren as string) conta_corrente,
safe_cast(contratm as string) id_contrato_municipio_sus,
safe_cast(
parse_date('%Y%m%d', cast(dt_publm as string)) as date
safe.parse_date('%Y%m%d', cast(dt_publm as string)) as date
) data_publicacao_contrato_municipal,
safe_cast(
parse_date('%Y%m%d', cast(dt_puble as string)) as date
safe.parse_date('%Y%m%d', cast(dt_puble as string)) as date
) data_publicacao_contrato_estadual,
safe_cast(contrate as string) id_contrato_estado_sus,
safe_cast(alvara as string) numero_alvara,
safe_cast(
parse_date('%Y%m%d', cast(dt_exped as string)) as date
safe.parse_date('%Y%m%d', cast(dt_exped as string)) as date
) data_expedicao_alvara,
safe_cast({{ clean_cols("ORGEXPED") }} as string) tipo_orgao_expedidor,
safe_cast(
{{ clean_cols("AV_ACRED") }} as string
) tipo_avaliacao_acreditacao_hospitalar,
safe_cast(clasaval as string) tipo_classificacao_acreditacao_hospitalar,
cast(substr(cast(dt_acred as string), 1, 4) as int64) as ano_acreditacao,
cast(substr(cast(dt_acred as string), 5, 2) as int64) as mes_acreditacao,
safe_cast(
cast({{ clean_cols("AV_PNASS") }} as string) as int64
) tipo_avaliacao_pnass,
cast(substr(cast(dt_pnass as string), 1, 4) as int64) as ano_avaliacao_pnass,
cast(substr(cast(dt_pnass as string), 5, 2) as int64) as mes_avaliacao_pnass,
safe_cast(substr(cast(dt_acred as string), 1, 4) as int64) as ano_acreditacao,
safe_cast(substr(cast(dt_acred as string), 5, 2) as int64) as mes_acreditacao,
safe_cast({{ clean_cols("AV_PNASS") }} as int64) tipo_avaliacao_pnass,
safe_cast(substr(cast(dt_pnass as string), 1, 4) as int64) as ano_avaliacao_pnass,
safe_cast(substr(cast(dt_pnass as string), 5, 2) as int64) as mes_avaliacao_pnass,
safe_cast(nivate_a as int64) indicador_atencao_ambulatorial,
safe_cast(gesprg1e as int64) indicador_gestao_basica_ambulatorial_estadual,
safe_cast(gesprg1m as int64) indicador_gestao_basica_ambulatorial_municipal,
Expand Down Expand Up @@ -272,6 +270,7 @@ select
from cnes_add_muni
{% if is_incremental() %}
where

date(cast(ano as int64), cast(mes as int64), 1)
> (select max(date(cast(ano as int64), cast(mes as int64), 1)) from {{ this }})
{% endif %}
Loading