Definition
Information
Section titled “Information”The Dbo Location model holds named location details, including address identifiers, telephone numbers, email addresses, a fax number and main contact name. It also records location classification and parent identifiers, opening and closing dates, notes and administrative flags, together with 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.location with dbo.address and dbo.locationtype details
Section titled “dbo.location with dbo.address and dbo.locationtype details”Return records alongside descriptive values from the related tables.
SELECT m."locationid", m."addressid", p1."countrycode" AS "address_countrycode", m."locationtypeid", p2."locationtypedescription" AS "locationtypedescription"FROM dbo.location AS mLEFT JOIN dbo.address AS p1 ON p1."addressid" = m."addressid" AND p1."organisation" = m."organisation"LEFT JOIN dbo.locationtype AS p2 ON p2."locationtypeid" = m."locationtypeid" AND p2."organisation" = m."organisation";appointment.patientschedule count per dbo.location
Section titled “appointment.patientschedule count per dbo.location”Count related appointment.patientschedule records for each dbo.location record, joined on locationid.
SELECT m."locationid", m."locationname", COUNT(c."locationid") AS patientschedule_countFROM dbo.location AS mLEFT JOIN appointment.patientschedule AS c ON m."locationid" = c."locationid" AND m."organisation" = c."organisation"GROUP BY m."locationid", m."locationname"ORDER BY patientschedule_count DESC;Row count by dbo.address countrycode
Section titled “Row count by dbo.address countrycode”Count dbo.location records for each dbo.address value, joined on addressid.
SELECT p."countrycode" AS "address_countrycode", COUNT(*) AS row_countFROM dbo.location AS mINNER JOIN dbo.address AS p ON p."addressid" = m."addressid" AND p."organisation" = m."organisation"GROUP BY p."countrycode"ORDER BY row_count DESC;