Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Care/Operations/userbycount_samplecollected_ssmm.md
Original file line number Diff line number Diff line change
@@ -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*
41 changes: 41 additions & 0 deletions Care/Operations/usersbycount_diagnosticreport_ssmm.md
Original file line number Diff line number Diff line change
@@ -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*