Skip to content
Partner Developer Portal

Definition

The Appointment Patientschedule model records a patient’s scheduled appointment activity, including its date range, reason, notes and recorded location. It also holds predicted travel time and visit duration, cancellation details, and identifiers for the schedule, service, care episode, planned event and slot type.

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

appointment.patientschedule with dbo.location, dbo.locationtype and dbo.organisation details

Section titled “appointment.patientschedule with dbo.location, dbo.locationtype and dbo.organisation details”

Return records alongside descriptive values from the related tables.

SELECT
m."patientscheduleid",
m."locationid",
p1."locationname" AS "locationname",
m."locationtypeid",
p2."locationtypedescription" AS "locationtypedescription",
m."organisationid",
p3."organisationdisplayname" AS "organisationdisplayname"
FROM appointment.patientschedule AS m
LEFT JOIN dbo.location AS p1
ON p1."locationid" = m."locationid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.locationtype AS p2
ON p2."locationtypeid" = m."locationtypeid"
AND p2."organisation" = m."organisation"
LEFT JOIN dbo.organisation AS p3
ON p3."organisationid" = m."organisationid"
AND p3."organisation" = m."organisation";

appointment.assignmentlistpatientschedule count per appointment.patientschedule

Section titled “appointment.assignmentlistpatientschedule count per appointment.patientschedule”

Count related appointment.assignmentlistpatientschedule records for each appointment.patientschedule record, joined on patientscheduleid.

SELECT
m."patientscheduleid",
m."cancelreason",
COUNT(c."patientscheduleid") AS assignmentlistpatientschedule_count
FROM appointment.patientschedule AS m
LEFT JOIN appointment.assignmentlistpatientschedule AS c
ON m."patientscheduleid" = c."patientscheduleid"
AND m."organisation" = c."organisation"
GROUP BY m."patientscheduleid", m."cancelreason"
ORDER BY assignmentlistpatientschedule_count DESC;

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

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