Skip to content
Partner Developer Portal

Definition

The Pds Patientflags model holds PDS-related flags and synchronisation information recorded for patients. It includes decoupled, invalid, potential-duplicate and sensitive flags, alongside current and previous SCN values, the local record at the last synchronisation and the corresponding Spine SCN value.

_deleted indicates whether the record has been deleted in the source system.

Return records alongside descriptive values from the related dbo.patient record.

SELECT
m."_primary_key",
m."patientid",
p1."displayname" AS "patient_displayname"
FROM pds.patientflags AS m
LEFT JOIN dbo.patient AS p1
ON p1."patientid" = m."patientid"
AND p1."organisation" = m."organisation";

Count pds.patientflags records for each dbo.patient value, joined on patientid.

SELECT
p."displayname" AS "patient_displayname",
COUNT(*) AS row_count
FROM pds.patientflags AS m
INNER JOIN dbo.patient AS p
ON p."patientid" = m."patientid"
AND p."organisation" = m."organisation"
GROUP BY p."displayname"
ORDER BY row_count DESC;

Find pds.patientflags records whose patientid has no matching dbo.patient record.

SELECT
COUNT(*) AS unmatched_count
FROM pds.patientflags AS m
LEFT 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;