Skip to content
Partner Developer Portal

Definition

The Unscheduledcare Attendancedetail model holds detailed circumstances recorded for an unscheduled-care attendance, including the complaint, arrival and departure times, companions, ambulance and incident information. It also records triage, clinician, referral-source and patient-group details, alongside discharge destination, follow-up, disposal information and notes.

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

unscheduledcare.attendancedetail with unscheduledcare.conveyingambulancetrust, unscheduledcare.dischargedestination and appointment.status details

Section titled “unscheduledcare.attendancedetail with unscheduledcare.conveyingambulancetrust, unscheduledcare.dischargedestination and appointment.status details”

Return records alongside descriptive values from the related tables.

SELECT
m."attendancedetailid",
m."conveyingambulancetrustid",
p1."displayname" AS "conveyingambulancetrust_displayname",
m."dischargedestinationid",
p2."organisationname" AS "dischargedestination_organisationname",
m."statusid",
p3."description" AS "status_description"
FROM unscheduledcare.attendancedetail AS m
LEFT JOIN unscheduledcare.conveyingambulancetrust AS p1
ON p1."conveyingambulancetrustid" = m."conveyingambulancetrustid"
AND p1."organisation" = m."organisation"
LEFT JOIN unscheduledcare.dischargedestination AS p2
ON p2."dischargedestinationid" = m."dischargedestinationid"
AND p2."organisation" = m."organisation"
LEFT JOIN appointment.status AS p3
ON p3."statusid" = m."statusid"
AND p3."organisation" = m."organisation";

unscheduledcare.attendanceaction count per unscheduledcare.attendancedetail

Section titled “unscheduledcare.attendanceaction count per unscheduledcare.attendancedetail”

Count related unscheduledcare.attendanceaction records for each unscheduledcare.attendancedetail record, joined on attendancedetailid.

SELECT
m."attendancedetailid",
m."accompaniedbyname",
COUNT(c."attendancedetailid") AS attendanceaction_count
FROM unscheduledcare.attendancedetail AS m
LEFT JOIN unscheduledcare.attendanceaction AS c
ON m."attendancedetailid" = c."attendancedetailid"
AND m."organisation" = c."organisation"
GROUP BY m."attendancedetailid", m."accompaniedbyname"
ORDER BY attendanceaction_count DESC;

Row count by unscheduledcare.conveyingambulancetrust displayname

Section titled “Row count by unscheduledcare.conveyingambulancetrust displayname”

Count unscheduledcare.attendancedetail records for each unscheduledcare.conveyingambulancetrust value, joined on conveyingambulancetrustid.

SELECT
p."displayname" AS "conveyingambulancetrust_displayname",
COUNT(*) AS row_count
FROM unscheduledcare.attendancedetail AS m
INNER JOIN unscheduledcare.conveyingambulancetrust AS p
ON p."conveyingambulancetrustid" = m."conveyingambulancetrustid"
AND p."organisation" = m."organisation"
GROUP BY p."displayname"
ORDER BY row_count DESC;