From 0b72db70ee64840b7a5e5b70a66bc48737b95756 Mon Sep 17 00:00:00 2001 From: sonzsara Date: Fri, 19 Jun 2026 12:17:58 +0530 Subject: [PATCH 1/2] Add documentation for service requests missing location IDs at SSMM --- ...vice_requests_missing_location_ids_ssmm.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Care/Operations/service_requests_missing_location_ids_ssmm.md diff --git a/Care/Operations/service_requests_missing_location_ids_ssmm.md b/Care/Operations/service_requests_missing_location_ids_ssmm.md new file mode 100644 index 0000000..eb2381f --- /dev/null +++ b/Care/Operations/service_requests_missing_location_ids_ssmm.md @@ -0,0 +1,42 @@ + +# Service Requests Missing Location IDs - SSMM + +> Completed service requests that have no associated facility location IDs + +## Purpose + +Lists completed (`status = 'completed'`) service requests at SSMM where the `locations` array is empty / null. + +## Parameters + +| Parameter | Type | Description | Example | +|-----------|------|-------------|---------| +| `date` | DATE / range | Metabase date filter (typically bound to `sr.created_date`) | `'2026-06-01'` | + +--- + +## Query + +```sql +SELECT + sr.id, + sr.created_date, + sr.title, + sr.category, + sr.status, + sr.locations +FROM emr_servicerequest sr +WHERE sr.deleted = FALSE + AND sr.status = 'completed' + AND array_length(sr.locations, 1) IS NULL + --[[AND {{date}}]] +ORDER BY sr.created_date DESC; +``` + +## Notes + +- **Metabase filters:** + - `[[AND {{date}}]]` is a field filter — bind it to `sr.created_date` in the Metabase variable settings. +- Results are ordered by most recent `created_date` first so the latest data-quality issues surface at the top. + +*Last updated: 2026-06-19* From 9a49dde7c2908cdbd394ee6e15aad7c40bd0df0b Mon Sep 17 00:00:00 2001 From: sonzsara Date: Fri, 19 Jun 2026 12:43:21 +0530 Subject: [PATCH 2/2] Fix SQL query to check for empty locations array in service requests --- Care/Operations/service_requests_missing_location_ids_ssmm.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Care/Operations/service_requests_missing_location_ids_ssmm.md b/Care/Operations/service_requests_missing_location_ids_ssmm.md index eb2381f..688a399 100644 --- a/Care/Operations/service_requests_missing_location_ids_ssmm.md +++ b/Care/Operations/service_requests_missing_location_ids_ssmm.md @@ -5,7 +5,7 @@ ## Purpose -Lists completed (`status = 'completed'`) service requests at SSMM where the `locations` array is empty / null. +Lists completed (`status = 'completed'`) service requests at SSMM where the `locations` array is empty. ## Parameters @@ -28,7 +28,7 @@ SELECT FROM emr_servicerequest sr WHERE sr.deleted = FALSE AND sr.status = 'completed' - AND array_length(sr.locations, 1) IS NULL + AND sr.locations = '{}' --[[AND {{date}}]] ORDER BY sr.created_date DESC; ```