Definition
Information
Section titled “Information”The Carerecord Reporthcp model holds healthcare-provider details associated with reports, including descriptive text and a recorded identifier. It also stores party-type and provider-type values alongside the report identifier and source organisation information, retaining the provider information recorded against the report.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”carerecord.reporthcp with carerecord.report details
Section titled “carerecord.reporthcp with carerecord.report details”Return records alongside descriptive values from the related carerecord.report record.
SELECT m."_primary_key", m."reportid", p1."associatedtext" AS "report_associatedtext"FROM carerecord.reporthcp AS mLEFT JOIN carerecord.report AS p1 ON p1."reportid" = m."reportid" AND p1."organisation" = m."organisation";Row count by carerecord.report associatedtext
Section titled “Row count by carerecord.report associatedtext”Count carerecord.reporthcp records for each carerecord.report value, joined on reportid.
SELECT p."associatedtext" AS "report_associatedtext", COUNT(*) AS row_countFROM carerecord.reporthcp AS mINNER JOIN carerecord.report AS p ON p."reportid" = m."reportid" AND p."organisation" = m."organisation"GROUP BY p."associatedtext"ORDER BY row_count DESC;Records without a matching carerecord.report
Section titled “Records without a matching carerecord.report”Find carerecord.reporthcp records whose reportid has no matching carerecord.report record.
SELECT COUNT(*) AS unmatched_countFROM carerecord.reporthcp AS mLEFT JOIN carerecord.report AS p ON p."reportid" = m."reportid" AND p."organisation" = m."organisation"WHERE m."reportid" IS NOT NULL AND p."reportid" IS NULL;