Skip to content
Partner Developer Portal

Definition

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.

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

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 m
LEFT 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_count
FROM dbo.location AS m
LEFT 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;

Count dbo.location records for each dbo.address value, joined on addressid.

SELECT
p."countrycode" AS "address_countrycode",
COUNT(*) AS row_count
FROM dbo.location AS m
INNER JOIN dbo.address AS p
ON p."addressid" = m."addressid"
AND p."organisation" = m."organisation"
GROUP BY p."countrycode"
ORDER BY row_count DESC;