Definition
Information
Section titled “Information”The Pds Patientmergearchive model records patient-merge archive references, including a document identifier and availability timestamp. Each entry holds an old person GUID and old registration-organisation GUID, together with the patient identifier and the organisation information recorded for that archive entry.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”pds.patientmergearchive with dbo.patient details
Section titled “pds.patientmergearchive with dbo.patient details”Return records alongside descriptive values from the related dbo.patient record.
SELECT m."_primary_key", m."patientid", p1."displayname" AS "patient_displayname"FROM pds.patientmergearchive AS mLEFT JOIN dbo.patient AS p1 ON p1."patientid" = m."patientid" AND p1."organisation" = m."organisation";Row count by dbo.patient displayname
Section titled “Row count by dbo.patient displayname”Count pds.patientmergearchive records for each dbo.patient value, joined on patientid.
SELECT p."displayname" AS "patient_displayname", COUNT(*) AS row_countFROM pds.patientmergearchive AS mINNER JOIN dbo.patient AS p ON p."patientid" = m."patientid" AND p."organisation" = m."organisation"GROUP BY p."displayname"ORDER BY row_count DESC;Records without a matching dbo.patient
Section titled “Records without a matching dbo.patient”Find pds.patientmergearchive records whose patientid has no matching dbo.patient record.
SELECT COUNT(*) AS unmatched_countFROM pds.patientmergearchive AS mLEFT JOIN dbo.patient AS p ON p."patientid" = m."patientid" AND p."organisation" = m."organisation"WHERE m."patientid" IS NOT NULL AND p."patientid" IS NULL;