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

[HCI] Aplica regras de descarte Vitacare #222

Merged
merged 1 commit into from
Feb 21, 2025
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
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
Loading