Definition
Information
Section titled “Information”The Bedmanagement Bed model holds bed details, including display names and numbers, recorded status and type, and ward information. It also stores an expected-sex value, colour and graphical-location identifiers, a PAS bed identifier and a deletion flag alongside the bed’s identifiers.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”bedmanagement.bed with bedmanagement.bedstatus, bedmanagement.bedtype and bedmanagement.colour details
Section titled “bedmanagement.bed with bedmanagement.bedstatus, bedmanagement.bedtype and bedmanagement.colour details”Return records alongside descriptive values from the related tables.
SELECT m."bedid", m."bedstatusid", p1."bedstatusdescription" AS "bedstatusdescription", m."bedtypeid", p2."description" AS "bedtype_description", m."colourid", p3."alpha" AS "colour_alpha"FROM bedmanagement.bed AS mLEFT JOIN bedmanagement.bedstatus AS p1 ON p1."bedstatusid" = m."bedstatusid" AND p1."organisation" = m."organisation"LEFT JOIN bedmanagement.bedtype AS p2 ON p2."bedtypeid" = m."bedtypeid" AND p2."organisation" = m."organisation"LEFT JOIN bedmanagement.colour AS p3 ON p3."colourid" = m."colourid" AND p3."organisation" = m."organisation";bedmanagement.bedaction count per bedmanagement.bed
Section titled “bedmanagement.bedaction count per bedmanagement.bed”Count related bedmanagement.bedaction records for each bedmanagement.bed record, joined on bedid.
SELECT m."bedid", m."beddisplayname", COUNT(c."bedid") AS bedaction_countFROM bedmanagement.bed AS mLEFT JOIN bedmanagement.bedaction AS c ON m."bedid" = c."bedid" AND m."organisation" = c."organisation"GROUP BY m."bedid", m."beddisplayname"ORDER BY bedaction_count DESC;Row count by bedmanagement.bedstatus bedstatusdescription
Section titled “Row count by bedmanagement.bedstatus bedstatusdescription”Count bedmanagement.bed records for each bedmanagement.bedstatus value, joined on bedstatusid.
SELECT p."bedstatusdescription" AS "bedstatusdescription", COUNT(*) AS row_countFROM bedmanagement.bed AS mINNER JOIN bedmanagement.bedstatus AS p ON p."bedstatusid" = m."bedstatusid" AND p."organisation" = m."organisation"GROUP BY p."bedstatusdescription"ORDER BY row_count DESC;