Skip to content
Partner Developer Portal

Definition

The Carerecord Report model records patient clinical reports, including summary text, coded terms, urgency and abnormal or provisional flags. It also holds issue, receipt and original-request dates, original report and request identifiers, service details and file-status information alongside entering and authorising user identifiers.

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

carerecord.report with dbo.organisation and dbo.patient details

Section titled “carerecord.report with dbo.organisation and dbo.patient details”

Return records alongside descriptive values from the related tables.

SELECT
m."reportid",
m."organisationid",
p1."organisationdisplayname" AS "organisationdisplayname",
m."patientid",
p2."displayname" AS "patient_displayname"
FROM carerecord.report AS m
LEFT JOIN dbo.organisation AS p1
ON p1."organisationid" = m."organisationid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.patient AS p2
ON p2."patientid" = m."patientid"
AND p2."organisation" = m."organisation";

carerecord.problemreport count per carerecord.report

Section titled “carerecord.problemreport count per carerecord.report”

Count related carerecord.problemreport records for each carerecord.report record, joined on reportid.

SELECT
m."reportid",
m."associatedtext",
COUNT(c."reportid") AS problemreport_count
FROM carerecord.report AS m
LEFT JOIN carerecord.problemreport AS c
ON m."reportid" = c."reportid"
AND m."organisation" = c."organisation"
GROUP BY m."reportid", m."associatedtext"
ORDER BY problemreport_count DESC;

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

Count carerecord.report records for each dbo.organisation value, joined on organisationid.

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