Skip to content
Partner Developer Portal

Definition

The Appointment Sessionuser model links appointment sessions with users identified in their recorded roles. Each association stores the session identifier and user-in-role identifier together with source organisation information, describing the user association recorded against the appointment session.

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

appointment.sessionuser with appointment.session and dbo.userinrole details

Section titled “appointment.sessionuser with appointment.session and dbo.userinrole details”

Return records alongside descriptive values from the related tables.

SELECT
m."_primary_key",
m."sessionid",
p1."description" AS "session_description",
m."userinroleid",
p2."contractualrelationship" AS "userinrole_contractualrelationship"
FROM appointment.sessionuser AS m
LEFT JOIN appointment.session AS p1
ON p1."sessionid" = m."sessionid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.userinrole AS p2
ON p2."userinroleid" = m."userinroleid"
AND p2."organisation" = m."organisation";

Row count by appointment.session description

Section titled “Row count by appointment.session description”

Count appointment.sessionuser records for each appointment.session value, joined on sessionid.

SELECT
p."description" AS "session_description",
COUNT(*) AS row_count
FROM appointment.sessionuser AS m
INNER JOIN appointment.session AS p
ON p."sessionid" = m."sessionid"
AND p."organisation" = m."organisation"
GROUP BY p."description"
ORDER BY row_count DESC;

Row count by dbo.userinrole contractualrelationship

Section titled “Row count by dbo.userinrole contractualrelationship”

Count appointment.sessionuser records for each dbo.userinrole value, joined on userinroleid.

SELECT
p."contractualrelationship" AS "userinrole_contractualrelationship",
COUNT(*) AS row_count
FROM appointment.sessionuser AS m
INNER JOIN dbo.userinrole AS p
ON p."userinroleid" = m."userinroleid"
AND p."organisation" = m."organisation"
GROUP BY p."contractualrelationship"
ORDER BY row_count DESC;