Skip to content
Partner Developer Portal

Definition

The Carerecord Reportspecimen model records specimen details associated with patient reports, including specimen type, reference, anatomical origin and collection procedure. It also holds sampling, collection and laboratory-receipt times, fasting-status text, comments and volume information alongside patient, report and specimen identifiers.

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

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

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

Return records alongside descriptive values from the related tables.

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

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

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

Section titled “Row count by carerecord.report associatedtext”

Count carerecord.reportspecimen records for each carerecord.report value, joined on reportid.

SELECT
p."associatedtext" AS "report_associatedtext",
COUNT(*) AS row_count
FROM carerecord.reportspecimen AS m
INNER JOIN carerecord.report AS p
ON p."reportid" = m."reportid"
AND p."organisation" = m."organisation"
GROUP BY p."associatedtext"
ORDER BY row_count DESC;