Skip to content
Partner Developer Portal

Definition

The Dbo Patientcontact model holds contact information recorded for patients, together with contact-type and associated primary-contact-type identifiers. It also records a contact-verification identifier and notes, alongside the patient identifier and organisation information associated with that contact entry.

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

dbo.patientcontact with dbo.contacttype and dbo.patient details

Section titled “dbo.patientcontact with dbo.contacttype and dbo.patient details”

Return records alongside descriptive values from the related tables.

SELECT
m."_primary_key",
m."contacttypeid",
p1."contacttypedescription" AS "contacttypedescription",
m."patientid",
p2."displayname" AS "patient_displayname"
FROM dbo.patientcontact AS m
LEFT JOIN dbo.contacttype AS p1
ON p1."contacttypeid" = m."contacttypeid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.patient AS p2
ON p2."patientid" = m."patientid"
AND p2."organisation" = m."organisation";

Row count by dbo.contacttype contacttypedescription

Section titled “Row count by dbo.contacttype contacttypedescription”

Count dbo.patientcontact records for each dbo.contacttype value, joined on contacttypeid.

SELECT
p."contacttypedescription" AS "contacttypedescription",
COUNT(*) AS row_count
FROM dbo.patientcontact AS m
INNER JOIN dbo.contacttype AS p
ON p."contacttypeid" = m."contacttypeid"
AND p."organisation" = m."organisation"
GROUP BY p."contacttypedescription"
ORDER BY row_count DESC;

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

SELECT
p."displayname" AS "patient_displayname",
COUNT(*) AS row_count
FROM dbo.patientcontact 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;