Definition
Information
Section titled “Information”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.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”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 mLEFT 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";Row count by dbo.patient displayname
Section titled “Row count by dbo.patient displayname”Count childhealth.patienttreatmentcentre records for each dbo.patient value, joined on patientid.
SELECT p."displayname" AS "patient_displayname", COUNT(*) AS row_countFROM childhealth.patienttreatmentcentre AS mINNER 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_countFROM childhealth.patienttreatmentcentre AS mINNER JOIN childhealth.treatmentcentre AS p ON p."treatmentcentreid" = m."treatmentcentreid" AND p."organisation" = m."organisation"GROUP BY p."code"ORDER BY row_count DESC;