Definition
Information
Section titled “Information”The Dbo Patientstatus model holds patient-status definitions. Each entry records a status identifier, description and mnemonic, alongside a caseload-patient-status identifier and organisation information.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”dbo.patientstatus with dbo.caseloadpatientstatus details
Section titled “dbo.patientstatus with dbo.caseloadpatientstatus details”Return records alongside descriptive values from the related dbo.caseloadpatientstatus record.
SELECT m."patientstatusid", m."caseloadpatientstatusid", p1."caseloadpatientstatusdescription" AS "caseloadpatientstatusdescription"FROM dbo.patientstatus AS mLEFT JOIN dbo.caseloadpatientstatus AS p1 ON p1."caseloadpatientstatusid" = m."caseloadpatientstatusid" AND p1."organisation" = m."organisation";dbo.patient count per dbo.patientstatus
Section titled “dbo.patient count per dbo.patientstatus”Count related dbo.patient records for each dbo.patientstatus record, joined on patientstatusid.
SELECT m."patientstatusid", m."patientstatusdescription", COUNT(c."patientstatusid") AS patient_countFROM dbo.patientstatus AS mLEFT JOIN dbo.patient AS c ON m."patientstatusid" = c."patientstatusid" AND m."organisation" = c."organisation"GROUP BY m."patientstatusid", m."patientstatusdescription"ORDER BY patient_count DESC;Row count by dbo.caseloadpatientstatus caseloadpatientstatusdescription
Section titled “Row count by dbo.caseloadpatientstatus caseloadpatientstatusdescription”Count dbo.patientstatus records for each dbo.caseloadpatientstatus value, joined on caseloadpatientstatusid.
SELECT p."caseloadpatientstatusdescription" AS "caseloadpatientstatusdescription", COUNT(*) AS row_countFROM dbo.patientstatus AS mINNER JOIN dbo.caseloadpatientstatus AS p ON p."caseloadpatientstatusid" = m."caseloadpatientstatusid" AND p."organisation" = m."organisation"GROUP BY p."caseloadpatientstatusdescription"ORDER BY row_count DESC;