Skip to content
Partner Developer Portal

Definition

The Appointment Assignmentlist model holds dated appointment assignment lists for an organisation and service. It records the list’s identifier and GUID alongside its date, organisation and service identifiers, retaining the source organisation information associated with the record.

The Deferred Visits Enhancements guide uses this model to obtain original and deferred-to assignment dates. Deferral state and the selected reason identifier belong to appointment.assignmentlistpatientschedule, not to the assignment list itself.

For the original date, join the schedule’s assignmentlistid to this model. For the target date, first follow assignmentlistpatientscheduledeferredto to another schedule record, then join that record’s assignmentlistid to this model. The deferred target identifier is not an assignmentlistid. Include organisation in every join.

The enhanced community/non-GP workflow requires the deferred date to differ from the original date. Missing target records in an extract can prevent retrieval of that date; retain the original event with a left join rather than discarding it. See the schedule model’s examples for this chain.

When reporting by month, state whether the month refers to the original assignment date or the target date. Counting deferred schedule rows measures deferral events, not distinct assignment lists, patients or complete chains.

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

Deferred assignment counts by original list date

Section titled “Deferred assignment counts by original list date”

Count deferred schedule rows against their original list. Retain lists without deferrals and scope the result by source organisation and list identifier.

SELECT
al."organisation",
al."assignmentlistid",
al."date" AS original_assignment_date,
COUNT(s."assignmentlistpatientscheduleid") AS deferred_count
FROM appointment.assignmentlist AS al
LEFT JOIN appointment.assignmentlistpatientschedule AS s
ON s."assignmentlistid" = al."assignmentlistid"
AND s."organisation" = al."organisation"
AND s."iscancelled" = TRUE
AND s."assignmentlistpatientscheduledeferredto" IS NOT NULL
GROUP BY al."organisation", al."assignmentlistid", al."date"
ORDER BY al."organisation", original_assignment_date, al."assignmentlistid";

appointment.assignmentlist with dbo.organisation details

Section titled “appointment.assignmentlist with dbo.organisation details”

Return records alongside descriptive values from the related dbo.organisation record.

SELECT
m."assignmentlistid",
m."organisationid",
p1."organisationdisplayname" AS "organisationdisplayname"
FROM appointment.assignmentlist AS m
LEFT JOIN dbo.organisation AS p1
ON p1."organisationid" = m."organisationid"
AND p1."organisation" = m."organisation";

appointment.assignmentlistpatientschedule count per appointment.assignmentlist

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

Count related appointment.assignmentlistpatientschedule records for each appointment.assignmentlist record, joined on assignmentlistid.

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

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

Count appointment.assignmentlist records for each dbo.organisation value, joined on organisationid.

SELECT
p."organisationdisplayname" AS "organisationdisplayname",
COUNT(*) AS row_count
FROM appointment.assignmentlist AS m
INNER JOIN dbo.organisation AS p
ON p."organisationid" = m."organisationid"
AND p."organisation" = m."organisation"
GROUP BY p."organisationdisplayname"
ORDER BY row_count DESC;