Skip to content
Partner Developer Portal

Definition

The Carerecord Reportconsultation model links patient reports with consultation sections through their recorded identifiers. Each association holds a report identifier, consultation-section identifier and patient identifier together with source organisation information, describing the consultation-section association recorded against the patient’s report.

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

carerecord.reportconsultation with carerecord.consultationsection, dbo.patient and carerecord.report details

Section titled “carerecord.reportconsultation with carerecord.consultationsection, dbo.patient and carerecord.report details”

Return records alongside descriptive values from the related tables.

SELECT
m."_primary_key",
m."consultationsectionid",
p1."originalheading" AS "consultationsection_originalheading",
m."patientid",
p2."displayname" AS "patient_displayname",
m."reportid",
p3."associatedtext" AS "report_associatedtext"
FROM carerecord.reportconsultation AS m
LEFT JOIN carerecord.consultationsection AS p1
ON p1."consultationsectionid" = m."consultationsectionid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.patient AS p2
ON p2."patientid" = m."patientid"
AND p2."organisation" = m."organisation"
LEFT JOIN carerecord.report AS p3
ON p3."reportid" = m."reportid"
AND p3."organisation" = m."organisation";

Row count by carerecord.consultationsection originalheading

Section titled “Row count by carerecord.consultationsection originalheading”

Count carerecord.reportconsultation records for each carerecord.consultationsection value, joined on consultationsectionid.

SELECT
p."originalheading" AS "consultationsection_originalheading",
COUNT(*) AS row_count
FROM carerecord.reportconsultation AS m
INNER JOIN carerecord.consultationsection AS p
ON p."consultationsectionid" = m."consultationsectionid"
AND p."organisation" = m."organisation"
GROUP BY p."originalheading"
ORDER BY row_count DESC;

Count carerecord.reportconsultation records for each dbo.patient value, joined on patientid.

SELECT
p."displayname" AS "patient_displayname",
COUNT(*) AS row_count
FROM carerecord.reportconsultation 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;