Skip to content
Partner Developer Portal

Definition

The Appointment Deferralreason model holds the deferral reasons configured by an organisation in Appointments Configuration. A deferral reason is an organisation-defined value that classifies why an assignment was deferred. It is reference data, used alongside appointment.assignmentlistpatientschedule to report on deferred assignments.

Deferral reasons are managed in Appointments Configuration under Reasons > Deferral Reasons. They are specific to an organisation, and duplicate active descriptions are prevented.

  • Adding a reason creates a reference record.
  • Editing an unused reason updates its description.
  • Editing a reason already in use can, after user confirmation, soft-delete the old reason and create a new record. Existing assignments keep the old reason identifier.
  • Deleting a reason soft-deletes it rather than removing historical references.

In the enhanced community/non-GP deferral workflow, a configured reason and a deferred date are mandatory. The selected identifier is recorded in appointment.assignmentlistpatientschedule.deferralreasonid.

Use deferralreasonid and organisation when joining assignments to reasons. Descriptions are not stable identifiers: an edit can create a new reason, and different organisations can use the same description.

The source isdeleted flag distinguishes active configuration from soft-deleted reasons. It is separate from the platform _deleted metadata column. For a current configuration report, select active reasons. For historical deferral reports, do not restrict the reason join to active configuration; retain the stored reason identifier and use a left join if its reference record is unavailable in the extract.

The guide describes SQL Server source types. This view exposes some source fields, including isdeleted and lastupdateddatetime, as text; use the types on the schema page when querying.

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

appointment.deferralreason with dbo.organisation details

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

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

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

appointment.assignmentlistpatientschedule count per appointment.deferralreason

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

Count related appointment.assignmentlistpatientschedule records for each appointment.deferralreason record, joined on deferralreasonid.

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

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

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

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

The source flag is exposed as text. This example recognises 0 and false (ignoring case) as active values; null or unrecognised values are not treated as active.

SELECT
dr."organisation",
dr."organisationid",
dr."deferralreasonid",
dr."description",
dr."lastupdateddatetime"
FROM appointment.deferralreason AS dr
WHERE LOWER(TRIM(dr."isdeleted")) IN ('0', 'false')
ORDER BY dr."organisation", dr."organisationid", dr."description";

Deferred assignments using each configured reason

Section titled “Deferred assignments using each configured reason”

Count deferral events rather than all related assignments. Keep the deferral conditions in the join so reasons with no matching deferrals remain visible. Do not filter out soft-deleted reasons from a historical usage report.

SELECT
dr."organisation",
dr."organisationid",
dr."deferralreasonid",
dr."description",
dr."isdeleted",
COUNT(m."assignmentlistpatientscheduleid") AS deferred_count
FROM appointment.deferralreason AS dr
LEFT JOIN appointment.assignmentlistpatientschedule AS m
ON m."deferralreasonid" = dr."deferralreasonid"
AND m."organisation" = dr."organisation"
AND m."iscancelled" = TRUE
AND m."assignmentlistpatientscheduledeferredto" IS NOT NULL
GROUP BY
dr."organisation",
dr."organisationid",
dr."deferralreasonid",
dr."description",
dr."isdeleted"
ORDER BY deferred_count DESC, dr."organisation", dr."deferralreasonid";

Based on the Deferred Visits Enhancements Reporting Guide, sections 3-7. The examples use Explorer IQ view names and exported column types rather than the guide’s source SQL Server syntax.