Skip to content
Partner Developer Portal

Definition

The Childhealth Treatmentcentre model holds treatment-centre details, including a centre code, correspondence telephone number and correspondence-address identifier. It also records location and treatment-centre identifiers, a centre GUID and active and deleted flags, together with the organisation information for the centre.

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

childhealth.treatmentcentre with dbo.location details

Section titled “childhealth.treatmentcentre with dbo.location details”

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

SELECT
m."treatmentcentreid",
m."locationid",
p1."locationname" AS "locationname"
FROM childhealth.treatmentcentre AS m
LEFT JOIN dbo.location AS p1
ON p1."locationid" = m."locationid"
AND p1."organisation" = m."organisation";

childhealth.patienttreatmentcentre count per childhealth.treatmentcentre

Section titled “childhealth.patienttreatmentcentre count per childhealth.treatmentcentre”

Count related childhealth.patienttreatmentcentre records for each childhealth.treatmentcentre record, joined on treatmentcentreid.

SELECT
m."treatmentcentreid",
m."code",
COUNT(c."treatmentcentreid") AS patienttreatmentcentre_count
FROM childhealth.treatmentcentre AS m
LEFT JOIN childhealth.patienttreatmentcentre AS c
ON m."treatmentcentreid" = c."treatmentcentreid"
AND m."organisation" = c."organisation"
GROUP BY m."treatmentcentreid", m."code"
ORDER BY patienttreatmentcentre_count DESC;

Count childhealth.treatmentcentre records for each dbo.location value, joined on locationid.

SELECT
p."locationname" AS "locationname",
COUNT(*) AS row_count
FROM childhealth.treatmentcentre AS m
INNER JOIN dbo.location AS p
ON p."locationid" = m."locationid"
AND p."organisation" = m."organisation"
GROUP BY p."locationname"
ORDER BY row_count DESC;