Skip to content
Partner Developer Portal

Definition

The Appointment Assignmentlistpatientschedule model links a patient schedule to an assignment list. It also records deferral: when a schedule is deferred, the row is marked cancelled, points to the assignment list patient schedule it was deferred to, and holds the reason selected for the deferral.

In the enhanced community/non-GP workflow, the user must select a configured deferral reason and a deferred date that differs from the original assignment date. The action stores both the selected reason text and its identifier. This extract exposes deferralreasonid, not a separate captured reason-text column; retrieve the description from appointment.deferralreason.

For reporting, identify a deferred assignment using both:

  • iscancelled = TRUE
  • assignmentlistpatientscheduledeferredto IS NOT NULL

A cancellation alone does not establish that an assignment was deferred. The deferralreasonid may be null for older records, cancellations without deferral, or records outside the enhanced flow. Do not exclude deferred assignments solely because their reason identifier is null.

  • Join deferralreasonid to appointment.deferralreason to retrieve the stored reason’s description.
  • Join assignmentlistpatientscheduledeferredto back to assignmentlistpatientscheduleid in this model to find the target assignment. Join each assignment’s assignmentlistid to appointment.assignmentlist to retrieve its original and deferred-to dates.
  • Include organisation in every join so identifiers from different source organisations are not combined.

Used deferral reasons can be replaced or soft-deleted in configuration without changing historical assignments. Join by the stored reason identifier, not by description or only the current active reason list. A left join retains assignments whose reason is unavailable in the extract.

Each deferred row represents one step in the chain. If an assignment is deferred again, counting deferred rows counts deferral events, not distinct patients or complete chains.

The Deferred Visits Enhancements guide also describes configuration audit activity (context 436, with Appointments Configuration item type 383) and slot deferral activity (context 437). See audit.activitycontext and audit.itemtype for these reference classifications. They are not additional columns in this model, and this model alone does not provide the audit event history.

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

Deferral reason completeness by source organisation

Section titled “Deferral reason completeness by source organisation”

Count deferral events with and without a configured reason identifier. A missing identifier can reflect legacy or non-enhanced workflows; it is not, by itself, evidence of a validation failure. A populated identifier whose reference row is absent is a separate extract completeness issue.

SELECT
m."organisation",
COUNT(*) AS deferred_count,
SUM(CASE WHEN m."deferralreasonid" IS NULL THEN 1 ELSE 0 END) AS without_reason_id,
SUM(CASE WHEN m."deferralreasonid" IS NOT NULL THEN 1 ELSE 0 END) AS with_reason_id,
SUM(CASE
WHEN m."deferralreasonid" IS NOT NULL AND dr."deferralreasonid" IS NULL
THEN 1 ELSE 0
END) AS missing_reason_reference
FROM appointment.assignmentlistpatientschedule AS m
LEFT JOIN appointment.deferralreason AS dr
ON dr."deferralreasonid" = m."deferralreasonid"
AND dr."organisation" = m."organisation"
WHERE m."iscancelled" = TRUE
AND m."assignmentlistpatientscheduledeferredto" IS NOT NULL
GROUP BY m."organisation"
ORDER BY m."organisation";

appointment.assignmentlistpatientschedule with appointment.assignmentlist, appointment.deferralreason and appointment.patientschedule details

Section titled “appointment.assignmentlistpatientschedule with appointment.assignmentlist, appointment.deferralreason and appointment.patientschedule details”

Return records alongside descriptive values from the related tables.

SELECT
m."assignmentlistpatientscheduleid",
m."assignmentlistid",
p1."date" AS "assignmentlist_date",
m."deferralreasonid",
p2."description" AS "deferralreason_description",
m."patientscheduleid",
p3."cancelreason" AS "patientschedule_cancelreason"
FROM appointment.assignmentlistpatientschedule AS m
LEFT JOIN appointment.assignmentlist AS p1
ON p1."assignmentlistid" = m."assignmentlistid"
AND p1."organisation" = m."organisation"
LEFT JOIN appointment.deferralreason AS p2
ON p2."deferralreasonid" = m."deferralreasonid"
AND p2."organisation" = m."organisation"
LEFT JOIN appointment.patientschedule AS p3
ON p3."patientscheduleid" = m."patientscheduleid"
AND p3."organisation" = m."organisation";

appointment.assignmentlistpatientscheduleslot count per appointment.assignmentlistpatientschedule

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

Count related appointment.assignmentlistpatientscheduleslot records for each appointment.assignmentlistpatientschedule record, joined on assignmentlistpatientscheduleid.

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

Row count by appointment.assignmentlist date

Section titled “Row count by appointment.assignmentlist date”

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

SELECT
p."date" AS "assignmentlist_date",
COUNT(*) AS row_count
FROM appointment.assignmentlistpatientschedule AS m
INNER JOIN appointment.assignmentlist AS p
ON p."assignmentlistid" = m."assignmentlistid"
AND p."organisation" = m."organisation"
GROUP BY p."date"
ORDER BY row_count DESC;

Count only cancelled assignments with a deferred target. Keep the source organisation and reason identifier in the grouping so similarly named reasons are not merged.

SELECT
m."organisation",
DATE_TRUNC('month', al."date") AS assignment_month,
m."deferralreasonid",
dr."description" AS deferral_reason,
COUNT(*) AS deferred_count
FROM appointment.assignmentlistpatientschedule AS m
INNER JOIN appointment.assignmentlist AS al
ON al."assignmentlistid" = m."assignmentlistid"
AND al."organisation" = m."organisation"
LEFT JOIN appointment.deferralreason AS dr
ON dr."deferralreasonid" = m."deferralreasonid"
AND dr."organisation" = m."organisation"
WHERE m."iscancelled" = TRUE
AND m."assignmentlistpatientscheduledeferredto" IS NOT NULL
GROUP BY
m."organisation",
DATE_TRUNC('month', al."date"),
m."deferralreasonid",
dr."description"
ORDER BY assignment_month, m."organisation", m."deferralreasonid";

Follow one step of the deferred chain. A missing target in the extract leaves the target date null rather than removing the original assignment.

SELECT
m."organisation",
m."assignmentlistpatientscheduleid",
original_list."date" AS original_assignment_date,
m."assignmentlistpatientscheduledeferredto",
target_list."date" AS deferred_to_date,
m."deferralreasonid",
dr."description" AS deferral_reason
FROM appointment.assignmentlistpatientschedule AS m
LEFT JOIN appointment.assignmentlist AS original_list
ON original_list."assignmentlistid" = m."assignmentlistid"
AND original_list."organisation" = m."organisation"
LEFT JOIN appointment.assignmentlistpatientschedule AS target
ON target."assignmentlistpatientscheduleid" = m."assignmentlistpatientscheduledeferredto"
AND target."organisation" = m."organisation"
LEFT JOIN appointment.assignmentlist AS target_list
ON target_list."assignmentlistid" = target."assignmentlistid"
AND target_list."organisation" = target."organisation"
LEFT JOIN appointment.deferralreason AS dr
ON dr."deferralreasonid" = m."deferralreasonid"
AND dr."organisation" = m."organisation"
WHERE m."iscancelled" = TRUE
AND m."assignmentlistpatientscheduledeferredto" IS NOT NULL
ORDER BY m."organisation", original_assignment_date, m."assignmentlistpatientscheduleid";