Skip to content
Partner Developer Portal

Definition

The Bedmanagement Bedstatus model holds bed status definitions and their descriptions. Each entry records a bed-status identifier together with descriptive text and source organisation information.

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

bedmanagement.bed count per bedmanagement.bedstatus

Section titled “bedmanagement.bed count per bedmanagement.bedstatus”

Count related bedmanagement.bed records for each bedmanagement.bedstatus record, joined on bedstatusid.

SELECT
m."bedstatusid",
m."bedstatusdescription",
COUNT(c."bedstatusid") AS bed_count
FROM bedmanagement.bedstatus AS m
LEFT JOIN bedmanagement.bed AS c
ON m."bedstatusid" = c."bedstatusid"
AND m."organisation" = c."organisation"
GROUP BY m."bedstatusid", m."bedstatusdescription"
ORDER BY bed_count DESC;

bedmanagement.bed records with bedmanagement.bedstatus details

Section titled “bedmanagement.bed records with bedmanagement.bedstatus details”

List bedmanagement.bed records with the bedmanagement.bedstatus values they reference through bedstatusid.

SELECT
c."bedid",
m."bedstatusid",
m."bedstatusdescription" AS "bedstatusdescription"
FROM bedmanagement.bed AS c
INNER JOIN bedmanagement.bedstatus AS m
ON m."bedstatusid" = c."bedstatusid"
AND m."organisation" = c."organisation";

bedmanagement.bedstatushistory count per bedmanagement.bedstatus

Section titled “bedmanagement.bedstatushistory count per bedmanagement.bedstatus”

Count related bedmanagement.bedstatushistory records for each bedmanagement.bedstatus record, joined on bedstatusid.

SELECT
m."bedstatusid",
m."bedstatusdescription",
COUNT(c."bedstatusid") AS bedstatushistory_count
FROM bedmanagement.bedstatus AS m
LEFT JOIN bedmanagement.bedstatushistory AS c
ON m."bedstatusid" = c."bedstatusid"
AND m."organisation" = c."organisation"
GROUP BY m."bedstatusid", m."bedstatusdescription"
ORDER BY bedstatushistory_count DESC;