Definition
Information
Section titled “Information”The Dbo Patient model holds patient demographics and registration details, including names, age, sex, dates of birth and death, and registration status. It also records the registration organisation, registered and usual GP assignments, and flags such as whether the record is archived or an interpreter is required.
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.patient with dbo.patientstatus and dbo.patienttype details
Section titled “dbo.patient with dbo.patientstatus and dbo.patienttype details”Return records alongside descriptive values from the related tables.
SELECT m."patientid", m."patientstatusid", p1."patientstatusdescription" AS "patientstatusdescription", m."patienttypeid", p2."patienttypedescription" AS "patienttypedescription"FROM dbo.patient AS mLEFT JOIN dbo.patientstatus AS p1 ON p1."patientstatusid" = m."patientstatusid" AND p1."organisation" = m."organisation"LEFT JOIN dbo.patienttype AS p2 ON p2."patienttypeid" = m."patienttypeid" AND p2."organisation" = m."organisation";admin.patientwarning count per dbo.patient
Section titled “admin.patientwarning count per dbo.patient”Count related admin.patientwarning records for each dbo.patient record, joined on patientid.
SELECT m."patientid", m."displayname", COUNT(c."patientid") AS patientwarning_countFROM dbo.patient AS mLEFT JOIN admin.patientwarning AS c ON m."patientid" = c."patientid" AND m."organisation" = c."organisation"GROUP BY m."patientid", m."displayname"ORDER BY patientwarning_count DESC;Row count by dbo.patientstatus patientstatusdescription
Section titled “Row count by dbo.patientstatus patientstatusdescription”Count dbo.patient records for each dbo.patientstatus value, joined on patientstatusid.
SELECT p."patientstatusdescription" AS "patientstatusdescription", COUNT(*) AS row_countFROM dbo.patient 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;