Skip to content
Partner Developer Portal

Definition

The Appointment Slothistory model records historical appointment slot details, including timing, patient information, booking details and notes. It also stores the history date, the user recorded as making a change, cancellation reasons and slot-move flags, together with booking availability and SMS information.

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

appointment.slothistory with episodemanagement.carecontact, dbo.patient and appointment.session details

Section titled “appointment.slothistory with episodemanagement.carecontact, dbo.patient and appointment.session details”

Return records alongside descriptive values from the related tables.

SELECT
m."slothistoryid",
m."carecontactid",
p1."cancellationdate" AS "carecontact_cancellationdate",
m."patientid",
p2."displayname" AS "patient_displayname",
m."sessionid",
p3."description" AS "session_description"
FROM appointment.slothistory AS m
LEFT JOIN episodemanagement.carecontact AS p1
ON p1."carecontactid" = m."carecontactid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.patient AS p2
ON p2."patientid" = m."patientid"
AND p2."organisation" = m."organisation"
LEFT JOIN appointment.session AS p3
ON p3."sessionid" = m."sessionid"
AND p3."organisation" = m."organisation";

Row count by episodemanagement.carecontact cancellationdate

Section titled “Row count by episodemanagement.carecontact cancellationdate”

Count appointment.slothistory records for each episodemanagement.carecontact value, joined on carecontactid.

SELECT
p."cancellationdate" AS "carecontact_cancellationdate",
COUNT(*) AS row_count
FROM appointment.slothistory AS m
INNER JOIN episodemanagement.carecontact AS p
ON p."carecontactid" = m."carecontactid"
AND p."organisation" = m."organisation"
GROUP BY p."cancellationdate"
ORDER BY row_count DESC;

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

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