Skip to content

Commit

Permalink
Merge pull request #217 from basedosdados/staging/br_ms_cnes
Browse files Browse the repository at this point in the history
br_ms_cnes
  • Loading branch information
folhesgabriel authored Aug 7, 2023
2 parents 86c0162 + 004a88f commit 3df4f4c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions models/br_ms_cnes/estabelecimento.sql
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,5 @@ cnes_add_muni AS (
SAFE_CAST(AP07CV05 AS INT64) indicador_atendimento_regulacao_plano_saude_publico,
SAFE_CAST(AP07CV06 AS INT64) indicador_atendimento_regulacao_plano_saude_privado
FROM cnes_add_muni AS t
WHERE (DATE_DIFF(CURRENT_DATE(),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 6
OR DATE_DIFF(DATE(2023,5,1),DATE(CAST(ano AS INT64),CAST(mes AS INT64),1), MONTH) > 0)
2 changes: 1 addition & 1 deletion models/br_ms_cnes/leito_atualizado.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ leito_x_estabelecimento as(
SELECT *
FROM cnes_leito_without_duplicates as lt
LEFT JOIN (SELECT id_municipio, CAST(ano as STRING) ano1,CAST(mes as STRING) mes1, id_estabelecimento_cnes,id_municipio AS IDDD from `basedosdados-dev.br_ms_cnes.estabelecimento`) as st
ON lt.id_estabelecimento_cnes = st.IDDD AND lt.ano = st.ano1 AND lt.mes = st.mes1
ON lt.CNES = st.IDDD AND lt.ano = st.ano1 AND lt.mes = st.mes1
)

SELECT
Expand Down
2 changes: 1 addition & 1 deletion models/br_ms_cnes/profissional.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ SAFE_CAST(VINCULAC AS STRING) id_vinculo,
SAFE_CAST(REGISTRO AS STRING) id_registro_conselho,
SAFE_CAST(CONSELHO AS STRING) id_conselho,
-- replace de valores de linha com 15 zeros para null. 15 zeros é valor do campo CNS_PROF que indica null
SAFE_CAST(regexp_replace(CNS_PROF,'0{15}', '') A\S STRING) cartao_nacional_saude,
SAFE_CAST(regexp_replace(CNS_PROF,'0{15}', '') AS STRING) cartao_nacional_saude,
SAFE_CAST(CBO AS STRING) cbo_2002,
SAFE_CAST(TERCEIRO AS STRING) indicador_estabelecimento_terceiro,
SAFE_CAST(VINCUL_C AS STRING) indicador_vinculo_contratado_sus,
Expand Down
2 changes: 1 addition & 1 deletion models/br_ms_cnes/profissional_atualizado.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ SAFE_CAST(VINCULAC AS STRING) id_vinculo,
SAFE_CAST(REGISTRO AS STRING) id_registro_conselho,
SAFE_CAST(CONSELHO AS STRING) id_conselho,
-- replace de valores de linha com 15 zeros para null. 15 zeros é valor do campo CNS_PROF que indica null
SAFE_CAST(regexp_replace(CNS_PROF,'0{15}', '') A\S STRING) cartao_nacional_saude,
SAFE_CAST(regexp_replace(CNS_PROF,'0{15}', '') AS STRING) cartao_nacional_saude,
SAFE_CAST(CBO AS STRING) cbo_2002,
SAFE_CAST(TERCEIRO AS STRING) indicador_estabelecimento_terceiro,
SAFE_CAST(VINCUL_C AS STRING) indicador_vinculo_contratado_sus,
Expand Down

0 comments on commit 3df4f4c

Please sign in to comment.