Skip to content
Partner Developer Portal

Definition

The Dbo Externalusualgpdetails model holds identifying and name details for external usual GPs. Each record includes a title, forenames, surname and display name, alongside GP identifiers and a GP organisation identifier, together with the recorded organisation information.

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

dbo.externalusualgpdetails with dbo.organisation details

Section titled “dbo.externalusualgpdetails with dbo.organisation details”

Return records alongside descriptive values from the related dbo.organisation record.

:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::

SELECT
m."_primary_key",
m."gporganisationid",
p1."organisationdisplayname" AS "organisationdisplayname"
FROM dbo.externalusualgpdetails AS m
LEFT JOIN dbo.organisation AS p1
ON p1."organisationid" = m."gporganisationid"
AND p1."organisation" = m."organisation";

dbo.patient count per dbo.externalusualgpdetails

Section titled “dbo.patient count per dbo.externalusualgpdetails”

Count related dbo.patient records for each dbo.externalusualgpdetails record, joined on externalusualgpid.

:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::

SELECT
m."externalusualgpid",
m."displayname",
COUNT(c."externalusualgpid") AS patient_count
FROM dbo.externalusualgpdetails AS m
LEFT JOIN dbo.patient AS c
ON m."externalusualgpid" = c."externalusualgpid"
AND m."organisation" = c."organisation"
GROUP BY m."externalusualgpid", m."displayname"
ORDER BY patient_count DESC;

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

Count dbo.externalusualgpdetails records for each dbo.organisation value, joined on gporganisationid.

:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::

SELECT
p."organisationdisplayname" AS "organisationdisplayname",
COUNT(*) AS row_count
FROM dbo.externalusualgpdetails AS m
INNER JOIN dbo.organisation AS p
ON p."organisationid" = m."gporganisationid"
AND p."organisation" = m."organisation"
GROUP BY p."organisationdisplayname"
ORDER BY row_count DESC;