SQL: Name Alerts - Potential Duplicate Charts

About

This report identifies pairs of charts where the first name, last name, and date of birth are the same.

A sample image of this SQL report run in the Database Viewer is shown below:

Caveats

  • It is quite possible that you will have NO results here, which is a good thing, not a bug in the report.
  • While OP alerts you to the creation of a new chart when an existing chart exists for a patient with the same demographic data, it can be overridden.
  •  Not all potential duplicates are true duplicates!  It’s quite possible for a patient with a common first and last name to have the same birthdate and name as another patient, particularly in a large practice.
  • This report excludes charts which were duplicated but the error has been corrected, one of the two charts have status = MERGED.

Code

To highlight and copy the code below to your clipboard, simply click the Copy button.

select * from (
select r1.patno as pat_a, r1.fname as first_a, r1.mi as mi_a, r1.lname as last_a, r1.birthdat as dob_a, r1.patssno as ssn_a,  r1.status_pat as status_a,  r2.patno as pat_b, r2.fname as first_b, r2.mi as mi_b, r2.lname as last_b, r2.status_pat as status_b, r2.birthdat as dob_b, r2.patssno as ssn_b
 from register r1
left outer join register r2 on 
r1.fname = r2.fname and r1.lname = r2.lname and r1.birthdat = r2.birthdat)  t1
where pat_a <> pat_b and status_a <> 'MERGED' and status_b <> 'MERGED'