Skip to content
Partner Developer Portal

Definition

The Appointment Session model records appointment sessions, including their description, start and end times, location and notes. It also holds default slot duration and type, session category and type identifiers, recurrence information, and recorded settings for timing, privacy, slot-number display and EMIS Access visibility.

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

appointment.session with dbo.location, dbo.organisation and appointment.sessioncategory details

Section titled “appointment.session with dbo.location, dbo.organisation and appointment.sessioncategory details”

Return records alongside descriptive values from the related tables.

SELECT
m."sessionid",
m."locationid",
p1."locationname" AS "locationname",
m."organisationid",
p2."organisationdisplayname" AS "organisationdisplayname",
m."sessioncategoryid",
p3."displayname" AS "sessioncategory_displayname"
FROM appointment.session AS m
LEFT JOIN dbo.location AS p1
ON p1."locationid" = m."locationid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.organisation AS p2
ON p2."organisationid" = m."organisationid"
AND p2."organisation" = m."organisation"
LEFT JOIN appointment.sessioncategory AS p3
ON p3."sessioncategoryid" = m."sessioncategoryid"
AND p3."organisation" = m."organisation";

appointment.sessionlocation count per appointment.session

Section titled “appointment.sessionlocation count per appointment.session”

Count related appointment.sessionlocation records for each appointment.session record, joined on sessionid.

SELECT
m."sessionid",
m."description",
COUNT(c."sessionid") AS sessionlocation_count
FROM appointment.session AS m
LEFT JOIN appointment.sessionlocation AS c
ON m."sessionid" = c."sessionid"
AND m."organisation" = c."organisation"
GROUP BY m."sessionid", m."description"
ORDER BY sessionlocation_count DESC;

Count appointment.session records for each dbo.location value, joined on locationid.

SELECT
p."locationname" AS "locationname",
COUNT(*) AS row_count
FROM appointment.session AS m
INNER JOIN dbo.location AS p
ON p."locationid" = m."locationid"
AND p."organisation" = m."organisation"
GROUP BY p."locationname"
ORDER BY row_count DESC;