Hello all,
I need help in coming up with a script in SQL to find duplicate MRNS/Duplicate patients in the database. We on the CPS version 12.0.2. I know there is canned report for Duplicate patients but does not have the MRN table in it. Any help would help. Thanks.
Here you go:
This is for duplicate MRNs
SELECT *
FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY MedicalRecordNumber ORDER BY PID) DUP
FROM PatientProfile
WHERE MedicalRecordNumber IS NOT NULL ) CHK
WHERE DUP > 1
This is for duplicate patients based off name, dob
SELECT *
FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY First, Last, Birthdate ORDER BY PID) DUP
FROM PatientProfile
WHERE PatientStatusMId = -900) CHK
WHERE DUP > 1
Is there a way to show the actual duplicate MRNS? the scripts above are helpful but they dont show the actual duplicate patient account or the MRN. Thanks!
Sure, see the code below:
SELECT MedicalRecordNumber[MRN],*
FROM PatientProfile
WHERE MedicalRecordNumber IN (
SELECT DISTINCT MedicalRecordNumber
FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY MedicalRecordNumber ORDER BY PID) DUP
FROM PatientProfile
WHERE MedicalRecordNumber IS NOT NULL ) CHK
WHERE DUP > 1)