Definition
Information
Section titled “Information”The Referralmanagement Referralmanagementstatus model holds descriptions of referral-management statuses. Each entry records a status identifier and description, together with organisation information.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”referralmanagement.referralmanagementstatus with appointment.status details
Section titled “referralmanagement.referralmanagementstatus with appointment.status details”Return records alongside descriptive values from the related appointment.status record.
SELECT m."_primary_key", m."statusid", p1."description" AS "status_description"FROM referralmanagement.referralmanagementstatus AS mLEFT JOIN appointment.status AS p1 ON p1."statusid" = m."statusid" AND p1."organisation" = m."organisation";Row count by appointment.status description
Section titled “Row count by appointment.status description”Count referralmanagement.referralmanagementstatus records for each appointment.status value, joined on statusid.
SELECT p."description" AS "status_description", COUNT(*) AS row_countFROM referralmanagement.referralmanagementstatus AS mINNER JOIN appointment.status AS p ON p."statusid" = m."statusid" AND p."organisation" = m."organisation"GROUP BY p."description"ORDER BY row_count DESC;Records without a matching appointment.status
Section titled “Records without a matching appointment.status”Find referralmanagement.referralmanagementstatus records whose statusid has no matching appointment.status record.
SELECT COUNT(*) AS unmatched_countFROM referralmanagement.referralmanagementstatus AS mLEFT JOIN appointment.status AS p ON p."statusid" = m."statusid" AND p."organisation" = m."organisation"WHERE m."statusid" IS NOT NULL AND p."statusid" IS NULL;