Definition
Information
Section titled “Information”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.
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.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 mLEFT 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";Row count by dbo.patient displayname
Section titled “Row count by dbo.patient displayname”Count carerecord.reportspecimen records for each dbo.patient value, joined on patientid.
SELECT p."displayname" AS "patient_displayname", COUNT(*) AS row_countFROM carerecord.reportspecimen 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 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_countFROM carerecord.reportspecimen 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;