Skip to content
Partner Developer Portal

Definition

The Episodemanagement Onwardreferral model records onward-referral details, including a referral-observation identifier and a recorded reason identifier. It also holds an onward-referral identifier and GUID, together with source organisation information describing the organisational context of the onward-referral record.

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

episodemanagement.onwardreferral with carerecord.referral and dbo.codelookup details

Section titled “episodemanagement.onwardreferral 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."onwardreferralid",
m."referralobservationid",
p1."referrerdisplayname" AS "referral_referrerdisplayname",
m."referonreasonid",
p2."term" AS "codelookup_term"
FROM episodemanagement.onwardreferral AS m
LEFT 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."referonreasonid"
AND p2."organisation" = m."organisation";

Row count by carerecord.referral referrerdisplayname

Section titled “Row count by carerecord.referral referrerdisplayname”

Count episodemanagement.onwardreferral 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_count
FROM episodemanagement.onwardreferral AS m
INNER JOIN carerecord.referral AS p
ON p."referralobservationid" = m."referralobservationid"
AND p."organisation" = m."organisation"
GROUP BY p."referrerdisplayname"
ORDER BY row_count DESC;

Count episodemanagement.onwardreferral records for each dbo.codelookup value, joined on referonreasonid.

:::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_count
FROM episodemanagement.onwardreferral AS m
INNER JOIN dbo.codelookup AS p
ON p."emiscodeid" = m."referonreasonid"
AND p."organisation" = m."organisation"
GROUP BY p."term"
ORDER BY row_count DESC;