From c00fc83cd32f92e7a3876b2857162080351d482b Mon Sep 17 00:00:00 2001 From: sonzsara Date: Tue, 6 Jan 2026 11:47:40 +0530 Subject: [PATCH] Add user activity tracking queries for specimen collection and diagnostic reports for ssmm --- .../userbycount_samplecollected_ssmm.md | 43 +++++++++++++++++++ .../usersbycount_diagnosticreport_ssmm.md | 41 ++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 Care/Operations/userbycount_samplecollected_ssmm.md create mode 100644 Care/Operations/usersbycount_diagnosticreport_ssmm.md diff --git a/Care/Operations/userbycount_samplecollected_ssmm.md b/Care/Operations/userbycount_samplecollected_ssmm.md new file mode 100644 index 0000000..a45293c --- /dev/null +++ b/Care/Operations/userbycount_samplecollected_ssmm.md @@ -0,0 +1,43 @@ +# User by Count - Sample Collected + +> Number of specimens collected by each user, ordered by activity level + +## Purpose + +This query tracks specimen collection activity by user, showing how many available specimens each staff member has collected. It's useful for measuring lab staff productivity, collection workload distribution, and identifying the most active specimen collectors in the system. + +## Parameters + +| Parameter | Type | Description | Example | +|-----------|------|-------------|---------| +| `specimen_date` | DATE | Filters specimens by creation date | `DATE(emr_specimen.created_date) = '2026-01-06'` | +| `user_name` | TEXT | Filters by user name | `'John'` | + +--- + +## Query + +```sql +SELECT + CONCAT(u.first_name, ' ', u.last_name) AS user_name, + COUNT(sp.id) AS total_specimen +FROM emr_specimen sp +JOIN users_user u ON sp.created_by_id = u.id +WHERE sp.deleted = FALSE + AND sp.status = 'available' +-- [[AND {{specimen_date}}]] +-- [[AND CONCAT(u.first_name, ' ', u.last_name) = {{user_name}}]] +GROUP BY u.first_name, u.last_name +ORDER BY total_specimen DESC; +``` + + + +## Notes + +- Only includes active specimens (deleted = FALSE) +- Query only counts specimens with status = 'available' +- Results are ordered by specimen count (highest to lowest) to show most active collectors first + + +*Last updated: 2026-01-06* diff --git a/Care/Operations/usersbycount_diagnosticreport_ssmm.md b/Care/Operations/usersbycount_diagnosticreport_ssmm.md new file mode 100644 index 0000000..d03276d --- /dev/null +++ b/Care/Operations/usersbycount_diagnosticreport_ssmm.md @@ -0,0 +1,41 @@ +# Users by Count - Diagnostic Report + +> Number of diagnostic reports created by each user, ordered by activity level + +## Purpose + +This query tracks diagnostic report creation activity by user, showing how many diagnostic reports each staff member has created. It's useful for measuring lab staff productivity, reporting workload distribution, and identifying the most active report creators in the system. + +## Parameters + +| Parameter | Type | Description | Example | +|-----------|------|-------------|---------| +| `servicerequest_date` | DATE | Filters diagnostic reports by creation date | `DATE(emr_diagnosticreport.created_date) = '2026-01-06'` | +| `user_name` | TEXT | Filters by user name | `'John'` | + +--- + +## Query + +```sql +SELECT + CONCAT(u.first_name, ' ', u.last_name) AS user_name, + COUNT(dr.id) AS total_diagnosticrequest +FROM emr_diagnosticreport dr +JOIN users_user u ON dr.created_by_id = u.id +WHERE dr.deleted = FALSE +-- [[AND {{servicerequest_date}}]] +-- [[AND CONCAT(u.first_name, ' ', u.last_name) = {{user_name}}]] +GROUP BY u.first_name, u.last_name +ORDER BY total_diagnosticrequest DESC; +``` + + + +## Notes + +- Only includes active diagnostic reports (deleted = FALSE) +- Results are ordered by report count (highest to lowest) to show most active users first + + +*Last updated: 2026-01-06*