Skip to content
Partner Developer Portal

Definition

The Childhealth Patienttreatmentcentre model records dated associations between patients and treatment centres. Each record holds patient and treatment-centre identifiers, a patient-treatment-centre association identifier and from and to dates, together with the organisation information recorded for that association.

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

childhealth.patienttreatmentcentre with dbo.patient and childhealth.treatmentcentre details

Section titled “childhealth.patienttreatmentcentre with dbo.patient and childhealth.treatmentcentre details”

Return records alongside descriptive values from the related tables.

SELECT
m."patienttreatmentcentreid",
m."patientid",
p1."displayname" AS "patient_displayname",
m."treatmentcentreid",
p2."code" AS "treatmentcentre_code"
FROM childhealth.patienttreatmentcentre AS m
LEFT JOIN dbo.patient AS p1
ON p1."patientid" = m."patientid"
AND p1."organisation" = m."organisation"
LEFT JOIN childhealth.treatmentcentre AS p2
ON p2."treatmentcentreid" = m."treatmentcentreid"
AND p2."organisation" = m."organisation";

Count childhealth.patienttreatmentcentre records for each dbo.patient value, joined on patientid.

SELECT
p."displayname" AS "patient_displayname",
COUNT(*) AS row_count
FROM childhealth.patienttreatmentcentre AS m
INNER JOIN dbo.patient AS p
ON p."patientid" = m."patientid"
AND p."organisation" = m."organisation"
GROUP BY p."displayname"
ORDER BY row_count DESC;

Row count by childhealth.treatmentcentre code

Section titled “Row count by childhealth.treatmentcentre code”

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

SELECT
p."code" AS "treatmentcentre_code",
COUNT(*) AS row_count
FROM childhealth.patienttreatmentcentre AS m
INNER JOIN childhealth.treatmentcentre AS p
ON p."treatmentcentreid" = m."treatmentcentreid"
AND p."organisation" = m."organisation"
GROUP BY p."code"
ORDER BY row_count DESC;