Definition
Information
Section titled “Information”The Dbo Patienthistory model records patient status and type information with the date it was recorded. Each entry holds status, type and subtype identifiers and status notes, together with patient and history identifiers, a record GUID 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.patienthistory with dbo.patient, dbo.patientstatus and dbo.patienttype details
Section titled “dbo.patienthistory with dbo.patient, dbo.patientstatus and dbo.patienttype details”Return records alongside descriptive values from the related tables.
SELECT m."patienthistoryid", m."patientid", p1."displayname" AS "patient_displayname", m."patientstatusid", p2."patientstatusdescription" AS "patientstatusdescription", m."patienttypeid", p3."patienttypedescription" AS "patienttypedescription"FROM dbo.patienthistory AS mLEFT JOIN dbo.patient AS p1 ON p1."patientid" = m."patientid" AND p1."organisation" = m."organisation"LEFT JOIN dbo.patientstatus AS p2 ON p2."patientstatusid" = m."patientstatusid" AND p2."organisation" = m."organisation"LEFT JOIN dbo.patienttype AS p3 ON p3."patienttypeid" = m."patienttypeid" AND p3."organisation" = m."organisation";Row count by dbo.patient displayname
Section titled “Row count by dbo.patient displayname”Count dbo.patienthistory records for each dbo.patient value, joined on patientid.
SELECT p."displayname" AS "patient_displayname", COUNT(*) AS row_countFROM dbo.patienthistory AS mINNER JOIN dbo.patient AS p ON p."patientid" = m."patientid" AND p."organisation" = m."organisation"GROUP BY p."displayname"ORDER BY row_count DESC;Row count by dbo.patientstatus patientstatusdescription
Section titled “Row count by dbo.patientstatus patientstatusdescription”Count dbo.patienthistory records for each dbo.patientstatus value, joined on patientstatusid.
SELECT p."patientstatusdescription" AS "patientstatusdescription", COUNT(*) AS row_countFROM dbo.patienthistory AS mINNER JOIN dbo.patientstatus AS p ON p."patientstatusid" = m."patientstatusid" AND p."organisation" = m."organisation"GROUP BY p."patientstatusdescription"ORDER BY row_count DESC;