Definition
Information
Section titled “Information”The Episodemanagement Referralreason model records reasons associated with referrals, including a reason-code identifier and the recorded reason term. It also holds a primary-reason flag, referral-observation identifier and source organisation information, retaining the reason text and designation recorded against the referral.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”episodemanagement.referralreason with carerecord.referral and dbo.codelookup details
Section titled “episodemanagement.referralreason with carerecord.referral and dbo.codelookup details”Return records alongside descriptive values from the related tables.
:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::
SELECT m."_primary_key", m."referralobservationid", p1."referrerdisplayname" AS "referral_referrerdisplayname", m."referralreasoncodeid", p2."term" AS "codelookup_term"FROM episodemanagement.referralreason AS mLEFT JOIN carerecord.referral AS p1 ON p1."referralobservationid" = m."referralobservationid" AND p1."organisation" = m."organisation"LEFT JOIN dbo.codelookup AS p2 ON p2."emiscodeid" = m."referralreasoncodeid" AND p2."organisation" = m."organisation";Row count by carerecord.referral referrerdisplayname
Section titled “Row count by carerecord.referral referrerdisplayname”Count episodemanagement.referralreason records for each carerecord.referral value, joined on referralobservationid.
:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::
SELECT p."referrerdisplayname" AS "referral_referrerdisplayname", COUNT(*) AS row_countFROM episodemanagement.referralreason AS mINNER JOIN carerecord.referral AS p ON p."referralobservationid" = m."referralobservationid" AND p."organisation" = m."organisation"GROUP BY p."referrerdisplayname"ORDER BY row_count DESC;Row count by dbo.codelookup term
Section titled “Row count by dbo.codelookup term”Count episodemanagement.referralreason records for each dbo.codelookup value, joined on referralreasoncodeid.
:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::
SELECT p."term" AS "codelookup_term", COUNT(*) AS row_countFROM episodemanagement.referralreason AS mINNER JOIN dbo.codelookup AS p ON p."emiscodeid" = m."referralreasoncodeid" AND p."organisation" = m."organisation"GROUP BY p."term"ORDER BY row_count DESC;