Skip to content

Commit

Permalink
applying discart rules for vitacare specific cnes
Browse files Browse the repository at this point in the history
  • Loading branch information
vitmesquita committed Feb 6, 2025
1 parent bd87564 commit e0dba26
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,22 @@ with
select *, 'historico' as origem
from {{ ref("base_prontuario_vitacare__atendimento_historico") }}
),
atendimentos_teste_duplicados as (
select id_hci, count(*) as qtd
from atendimentos
where cnes_unidade in ('6922031', '9391983', '7856954', '7414226')
and datahora_inicio > '2024-11-06'
group by 1
),
atendimentos_sem_teste_duplicados as (
select *
from atendimentos
where id_hci not in (select id_hci from atendimentos_teste_duplicados)
),

atendimentos_deduplicados as (
select *
from atendimentos
from atendimentos_sem_teste_duplicados
qualify row_number() over (partition by id_prontuario_global order by updated_at desc) = 1
),

Expand Down

0 comments on commit e0dba26

Please sign in to comment.