Skip to content
Partner Developer Portal

Definition

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.

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

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 m
LEFT JOIN dbo.caseloadpatientstatus AS p1
ON p1."caseloadpatientstatusid" = m."caseloadpatientstatusid"
AND p1."organisation" = m."organisation";

Count related dbo.patient records for each dbo.patientstatus record, joined on patientstatusid.

SELECT
m."patientstatusid",
m."patientstatusdescription",
COUNT(c."patientstatusid") AS patient_count
FROM dbo.patientstatus AS m
LEFT 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_count
FROM dbo.patientstatus AS m
INNER JOIN dbo.caseloadpatientstatus AS p
ON p."caseloadpatientstatusid" = m."caseloadpatientstatusid"
AND p."organisation" = m."organisation"
GROUP BY p."caseloadpatientstatusdescription"
ORDER BY row_count DESC;