Skip to content
Partner Developer Portal

Definition

The Professionalcontact Contact model holds identifying details for professional contacts, including their title, forename and surname. It records contact identifiers, an active flag, organisation and user-role identifiers, and a user-identifier type and value, together with the recorded organisation information.

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

professionalcontact.contact with dbo.organisation, dbo.useridentifiertype and dbo.userinrole details

Section titled “professionalcontact.contact with dbo.organisation, dbo.useridentifiertype and dbo.userinrole details”

Return records alongside descriptive values from the related tables.

SELECT
m."contactid",
m."organisationid",
p1."organisationdisplayname" AS "organisationdisplayname",
m."useridentifiertypeid",
p2."description" AS "useridentifiertype_description",
m."userinroleid",
p3."contractualrelationship" AS "userinrole_contractualrelationship"
FROM professionalcontact.contact AS m
LEFT JOIN dbo.organisation AS p1
ON p1."organisationid" = m."organisationid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.useridentifiertype AS p2
ON p2."useridentifiertypeid" = m."useridentifiertypeid"
AND p2."organisation" = m."organisation"
LEFT JOIN dbo.userinrole AS p3
ON p3."userinroleid" = m."userinroleid"
AND p3."organisation" = m."organisation";

professionalcontact.patientprofessionalcontact count per professionalcontact.contact

Section titled “professionalcontact.patientprofessionalcontact count per professionalcontact.contact”

Count related professionalcontact.patientprofessionalcontact records for each professionalcontact.contact record, joined on contactid.

SELECT
m."contactid",
m."title",
COUNT(c."contactid") AS patientprofessionalcontact_count
FROM professionalcontact.contact AS m
LEFT JOIN professionalcontact.patientprofessionalcontact AS c
ON m."contactid" = c."contactid"
AND m."organisation" = c."organisation"
GROUP BY m."contactid", m."title"
ORDER BY patientprofessionalcontact_count DESC;

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

Count professionalcontact.contact records for each dbo.organisation value, joined on organisationid.

SELECT
p."organisationdisplayname" AS "organisationdisplayname",
COUNT(*) AS row_count
FROM professionalcontact.contact AS m
INNER JOIN dbo.organisation AS p
ON p."organisationid" = m."organisationid"
AND p."organisation" = m."organisation"
GROUP BY p."organisationdisplayname"
ORDER BY row_count DESC;