Skip to content
Partner Developer Portal

Definition

The Episodemanagement Rttperiod model records RTT periods, including their start and end dates and times. It also holds start-code and end-code identifiers, episode identifiers and RTT record identifiers, together with source organisation information describing the context of the recorded period.

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

episodemanagement.rttperiod with patientadmin.episode, episodemanagement.rttstatuscodes and episodemanagement.rttstatuscodes details

Section titled “episodemanagement.rttperiod with patientadmin.episode, episodemanagement.rttstatuscodes and episodemanagement.rttstatuscodes 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."paepisodeid",
p1."dischargereasonterm" AS "episode_dischargereasonterm",
m."rttstartcodeid",
p2."impactonclock" AS "rttstatuscodes_impactonclock",
m."rttendcodeid",
p3."impactonclock" AS "rttstatuscodes_impactonclock"
FROM episodemanagement.rttperiod AS m
LEFT JOIN patientadmin.episode AS p1
ON p1."episodeid" = m."paepisodeid"
AND p1."organisation" = m."organisation"
LEFT JOIN episodemanagement.rttstatuscodes AS p2
ON p2."statuscodeid" = m."rttstartcodeid"
AND p2."organisation" = m."organisation"
LEFT JOIN episodemanagement.rttstatuscodes AS p3
ON p3."statuscodeid" = m."rttendcodeid"
AND p3."organisation" = m."organisation";

Row count by patientadmin.episode dischargereasonterm

Section titled “Row count by patientadmin.episode dischargereasonterm”

Count episodemanagement.rttperiod records for each patientadmin.episode value, joined on paepisodeid.

:::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."dischargereasonterm" AS "episode_dischargereasonterm",
COUNT(*) AS row_count
FROM episodemanagement.rttperiod AS m
INNER JOIN patientadmin.episode AS p
ON p."episodeid" = m."paepisodeid"
AND p."organisation" = m."organisation"
GROUP BY p."dischargereasonterm"
ORDER BY row_count DESC;

Row count by episodemanagement.rttstatuscodes impactonclock

Section titled “Row count by episodemanagement.rttstatuscodes impactonclock”

Count episodemanagement.rttperiod records for each episodemanagement.rttstatuscodes value, joined on rttstartcodeid.

:::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."impactonclock" AS "rttstatuscodes_impactonclock",
COUNT(*) AS row_count
FROM episodemanagement.rttperiod AS m
INNER JOIN episodemanagement.rttstatuscodes AS p
ON p."statuscodeid" = m."rttstartcodeid"
AND p."organisation" = m."organisation"
GROUP BY p."impactonclock"
ORDER BY row_count DESC;