Skip to content

UHM-8462 add dup emr_ids #221

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions jobs/sql/derivations/append_data_warnings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ where not exists
and e2.encounter_datetime < e.encounter_datetime
and e2.encounter_type = 'Admission');

-- -------------------------------------------------- duplicate emr_id
insert into #temp_data_warnings (warning_type, event_type, patient_id, emr_id, encounter_datetime, datetime_created,
user_entered, site, partition_num)
select 'Duplicate emr_ids', 'patient_registration',p.patient_id, p.emr_id, p.registration_date, p.date_registration_entered,
p.user_entered, p.site, p.partition_num
from all_patients p
where exists
(select 1 from all_patients p2
where p2.emr_id = p.emr_id
and p2.patient_id <> p.patient_id);

-- -------------------------------------------------- visit details
update t
set t.visit_date_started = v.visit_date_started,
Expand Down