Skip to content
Partner Developer Portal

Definition

The Dbo Caseloadpatientstatus model holds descriptions of patient statuses within the caseload domain. Each entry records a status identifier and description, together with organisation information.

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

dbo.patientstatus count per dbo.caseloadpatientstatus

Section titled “dbo.patientstatus count per dbo.caseloadpatientstatus”

Count related dbo.patientstatus records for each dbo.caseloadpatientstatus record, joined on caseloadpatientstatusid.

SELECT
m."caseloadpatientstatusid",
m."caseloadpatientstatusdescription",
COUNT(c."caseloadpatientstatusid") AS patientstatus_count
FROM dbo.caseloadpatientstatus AS m
LEFT JOIN dbo.patientstatus AS c
ON m."caseloadpatientstatusid" = c."caseloadpatientstatusid"
AND m."organisation" = c."organisation"
GROUP BY m."caseloadpatientstatusid", m."caseloadpatientstatusdescription"
ORDER BY patientstatus_count DESC;

dbo.patientstatus records with dbo.caseloadpatientstatus details

Section titled “dbo.patientstatus records with dbo.caseloadpatientstatus details”

List dbo.patientstatus records with the dbo.caseloadpatientstatus values they reference through caseloadpatientstatusid.

SELECT
c."patientstatusid",
m."caseloadpatientstatusid",
m."caseloadpatientstatusdescription" AS "caseloadpatientstatusdescription"
FROM dbo.patientstatus AS c
INNER JOIN dbo.caseloadpatientstatus AS m
ON m."caseloadpatientstatusid" = c."caseloadpatientstatusid"
AND m."organisation" = c."organisation";

dbo.caseloadpatientstatus records not used by dbo.patientstatus

Section titled “dbo.caseloadpatientstatus records not used by dbo.patientstatus”

Find dbo.caseloadpatientstatus records that no dbo.patientstatus record references.

SELECT
m."caseloadpatientstatusid",
m."caseloadpatientstatusdescription"
FROM dbo.caseloadpatientstatus AS m
WHERE NOT EXISTS (
SELECT 1
FROM dbo.patientstatus AS c
WHERE m."caseloadpatientstatusid" = c."caseloadpatientstatusid"
AND m."organisation" = c."organisation"
);