Definition
Information
Section titled “Information”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.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”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 mLEFT 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_countFROM patientadmin.dischargeorrejectionreason AS mLEFT 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_countFROM patientadmin.dischargeorrejectionreason AS mINNER JOIN dbo.organisation AS p ON p."organisationid" = m."organisationid" AND p."organisation" = m."organisation"GROUP BY p."organisationdisplayname"ORDER BY row_count DESC;