Skip to content
Partner Developer Portal

Definition

The Unscheduledcare Attendance model records patient attendances in the unscheduled-care domain. Each entry holds an attendance identifier and GUID, together with patient, episode and service-organisation identifiers and the organisation information recorded for that attendance, establishing its recorded patient and service context.

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

unscheduledcare.attendance with patientadmin.episode and dbo.patient details

Section titled “unscheduledcare.attendance with patientadmin.episode and dbo.patient details”

Return records alongside descriptive values from the related tables.

SELECT
m."attendanceid",
m."episodeid",
p1."dischargereasonterm" AS "episode_dischargereasonterm",
m."patientid",
p2."displayname" AS "patient_displayname"
FROM unscheduledcare.attendance AS m
LEFT JOIN patientadmin.episode AS p1
ON p1."episodeid" = m."episodeid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.patient AS p2
ON p2."patientid" = m."patientid"
AND p2."organisation" = m."organisation";

unscheduledcare.attendanceaction count per unscheduledcare.attendance

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

Count related unscheduledcare.attendanceaction records for each unscheduledcare.attendance record, joined on attendanceid.

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

Row count by patientadmin.episode dischargereasonterm

Section titled “Row count by patientadmin.episode dischargereasonterm”

Count unscheduledcare.attendance records for each patientadmin.episode value, joined on episodeid.

SELECT
p."dischargereasonterm" AS "episode_dischargereasonterm",
COUNT(*) AS row_count
FROM unscheduledcare.attendance AS m
INNER JOIN patientadmin.episode AS p
ON p."episodeid" = m."episodeid"
AND p."organisation" = m."organisation"
GROUP BY p."dischargereasonterm"
ORDER BY row_count DESC;