From b6c2c53bfb47dfde9fecab9bfa4f498672ddb9a7 Mon Sep 17 00:00:00 2001 From: sonzsara Date: Fri, 22 May 2026 17:06:23 +0530 Subject: [PATCH] Add documentation for Laboratory Service Requests by Patient Count at SSMM --- ...atory_service_req_by_patient_count_ssmm.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Care/Operations/laboratory_service_req_by_patient_count_ssmm.md diff --git a/Care/Operations/laboratory_service_req_by_patient_count_ssmm.md b/Care/Operations/laboratory_service_req_by_patient_count_ssmm.md new file mode 100644 index 0000000..28f01ba --- /dev/null +++ b/Care/Operations/laboratory_service_req_by_patient_count_ssmm.md @@ -0,0 +1,45 @@ + +# Laboratory Service Requests by Patient Count - SSMM + +> Number of completed laboratory service requests per patient per day. + +## Purpose + +Identifies patients with the highest volume of laboratory service requests at SSMM. + +## Parameters + +*No parameters — the query returns all completed laboratory service requests.* + +--- + +## Query + +```sql +SELECT + DATE(sr.created_date) AS created_date, + p.name AS patient_name, + pi.value AS ssmm_id, + COUNT(*) AS request_count +FROM emr_servicerequest sr +JOIN emr_patient p ON sr.patient_id = p.id +LEFT JOIN emr_patientidentifier pi ON p.id = pi.patient_id AND pi.config_id = 21 +WHERE sr.status = 'completed' + AND sr.category = 'laboratory' +GROUP BY DATE(sr.created_date), p.name, pi.value +ORDER BY request_count DESC; +``` + + +## Notes + +- Only service requests with `status = 'completed'` and `category = 'laboratory'` are counted. +- **Hardcoded values:** + - `pi.config_id = 21` — the identifier config representing the SSMM ID. Update if the config ID changes. + - `sr.category = 'laboratory'` — restricts to lab requests; change to widen/narrow the scope (e.g. `'imaging'`). +- Results are ordered by highest `request_count` first, so top lab consumers surface at the top. +- No date filter is applied — the result spans all history. Add a `[[AND {{created_date}}]]` clause if a Metabase date filter is needed. + +*Last updated: 2026-05-22* + +