Skip to content
Partner Developer Portal

Definition

The Patientadmin Dischargeorrejectionreason model holds discharge and referral-rejection reason definitions. It records reason text, a code and reason identifiers, alongside discharge, referral-rejection and active flags, together with the organisation identifier and organisation information associated with that reason entry.

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

patientadmin.dischargeorrejectionreason with dbo.organisation details

Section titled “patientadmin.dischargeorrejectionreason with dbo.organisation details”

Return records alongside descriptive values from the related dbo.organisation record.

SELECT
m."dischargeorrejectionreasonid",
m."organisationid",
p1."organisationdisplayname" AS "organisationdisplayname"
FROM patientadmin.dischargeorrejectionreason AS m
LEFT JOIN dbo.organisation AS p1
ON p1."organisationid" = m."organisationid"
AND p1."organisation" = m."organisation";

bedmanagement.wardpatientassignmenthistory count per patientadmin.dischargeorrejectionreason

Section titled “bedmanagement.wardpatientassignmenthistory count per patientadmin.dischargeorrejectionreason”

Count related bedmanagement.wardpatientassignmenthistory records for each patientadmin.dischargeorrejectionreason record, joined on dischargeorrejectionreasonid.

SELECT
m."dischargeorrejectionreasonid",
m."reason",
COUNT(c."dischargeorrejectionreasonid") AS wardpatientassignmenthistory_count
FROM patientadmin.dischargeorrejectionreason AS m
LEFT JOIN bedmanagement.wardpatientassignmenthistory AS c
ON m."dischargeorrejectionreasonid" = c."dischargeorrejectionreasonid"
AND m."organisation" = c."organisation"
GROUP BY m."dischargeorrejectionreasonid", m."reason"
ORDER BY wardpatientassignmenthistory_count DESC;

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

Count patientadmin.dischargeorrejectionreason records for each dbo.organisation value, joined on organisationid.

SELECT
p."organisationdisplayname" AS "organisationdisplayname",
COUNT(*) AS row_count
FROM patientadmin.dischargeorrejectionreason AS m
INNER JOIN dbo.organisation AS p
ON p."organisationid" = m."organisationid"
AND p."organisation" = m."organisation"
GROUP BY p."organisationdisplayname"
ORDER BY row_count DESC;