Skip to content
Partner Developer Portal

Definition

The Appointment Slot model records appointment slots, including their timing, patient details, booking information, reasons and notes. It also holds booked, blocked and urgent flags, recorded status information, external booking details, GP Connect bookability and SMS settings, alongside session and slot-type identifiers.

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

appointment.slot with appointment.assignmentlistpatientschedule, appointment.embargotype and dbo.patient details

Section titled “appointment.slot with appointment.assignmentlistpatientschedule, appointment.embargotype and dbo.patient details”

Return records alongside descriptive values from the related tables.

SELECT
m."slotid",
m."assignmentlistpatientscheduleid",
p1."assignmentlistpatientscheduledeferredto" AS "assignmentlistpatientscheduledeferredto",
m."embargotypeid",
p2."backgroundcolour" AS "embargotype_backgroundcolour",
m."patientid",
p3."displayname" AS "patient_displayname"
FROM appointment.slot AS m
LEFT JOIN appointment.assignmentlistpatientschedule AS p1
ON p1."assignmentlistpatientscheduleid" = m."assignmentlistpatientscheduleid"
AND p1."organisation" = m."organisation"
LEFT JOIN appointment.embargotype AS p2
ON p2."embargotypeid" = m."embargotypeid"
AND p2."organisation" = m."organisation"
LEFT JOIN dbo.patient AS p3
ON p3."patientid" = m."patientid"
AND p3."organisation" = m."organisation";

appointment.assignmentlistpatientscheduleslot count per appointment.slot

Section titled “appointment.assignmentlistpatientscheduleslot count per appointment.slot”

Count related appointment.assignmentlistpatientscheduleslot records for each appointment.slot record, joined on slotid.

SELECT
m."slotid",
m."patientname",
COUNT(c."slotid") AS assignmentlistpatientscheduleslot_count
FROM appointment.slot AS m
LEFT JOIN appointment.assignmentlistpatientscheduleslot AS c
ON m."slotid" = c."slotid"
AND m."organisation" = c."organisation"
GROUP BY m."slotid", m."patientname"
ORDER BY assignmentlistpatientscheduleslot_count DESC;

Row count by appointment.assignmentlistpatientschedule assignmentlistpatientscheduledeferredto

Section titled “Row count by appointment.assignmentlistpatientschedule assignmentlistpatientscheduledeferredto”

Count appointment.slot records for each appointment.assignmentlistpatientschedule value, joined on assignmentlistpatientscheduleid.

SELECT
p."assignmentlistpatientscheduledeferredto" AS "assignmentlistpatientscheduledeferredto",
COUNT(*) AS row_count
FROM appointment.slot AS m
INNER JOIN appointment.assignmentlistpatientschedule AS p
ON p."assignmentlistpatientscheduleid" = m."assignmentlistpatientscheduleid"
AND p."organisation" = m."organisation"
GROUP BY p."assignmentlistpatientscheduledeferredto"
ORDER BY row_count DESC;