From 1593cc1896daea8b99c41b3379f6ddd8d9fa54d0 Mon Sep 17 00:00:00 2001 From: sonzsara Date: Thu, 13 Aug 2026 11:34:22 +0530 Subject: [PATCH 1/2] Add documentation for Stock in Air query at SSMM --- Care/Operations/stock_in_air_ssmm.md | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Care/Operations/stock_in_air_ssmm.md diff --git a/Care/Operations/stock_in_air_ssmm.md b/Care/Operations/stock_in_air_ssmm.md new file mode 100644 index 0000000..44349cd --- /dev/null +++ b/Care/Operations/stock_in_air_ssmm.md @@ -0,0 +1,59 @@ + +# Stock in Air - SSMM + +> In-transit stock deliveries (in-progress) with product, quantity, route, and creator details + +## Purpose + +Lists stock deliveries that are currently `in_progress` ("stock in air") at SSMM, showing what product is moving, quantity, delivery/order status, movement date, origin and destination locations, and the user who created the delivery record. + +## Parameters + +| Parameter | Type | Description | Example | +|-----------|------|-------------|---------| +| `date` | DATE / range | Metabase date filter (typically bound to `esd.created_date`) | `'2026-08-01'` | + +--- + +## Query + +```sql +SELECT + epk.name AS product_name, + esd.supplied_item_quantity AS supplied_qty, + esd.status AS delivery_status, + edo.status AS order_status, + esd.created_date AS delivery_date, + origin.name AS origin, + destination.name AS destination, + CONCAT(uu.first_name, ' ', uu.last_name) AS delivery_created_by +FROM emr_supplydelivery esd +JOIN emr_deliveryorder edo + ON esd.order_id = edo.id +JOIN emr_inventoryitem eii + ON esd.supplied_inventory_item_id = eii.id +JOIN emr_product ep + ON eii.product_id = ep.id +JOIN emr_productknowledge epk + ON ep.product_knowledge_id = epk.id + JOIN emr_facilitylocation origin + ON origin.id = edo.origin_id + AND origin.deleted = FALSE + JOIN emr_facilitylocation destination + ON destination.id = edo.destination_id + AND destination.deleted = FALSE +LEFT JOIN users_user uu + ON uu.id = esd.created_by_id +WHERE edo.origin_id IS NOT NULL + AND esd.status = 'in_progress' + --[[AND {{date}}]] +ORDER BY epk.name; +``` + +## Notes + +- **"Stock in air" definition:** This query treats any supply delivery with `esd.status = 'in_progress'` as in-transit stock. +- **Metabase filter:** `[[AND {{date}}]]` is a field filter — bind it to `esd.created_date`. +- Results are ordered alphabetically by `product_name`. + +*Last updated: 2026-08-13* From 7da9331e21d2f8b95e7292443fd0618b0b0300bb Mon Sep 17 00:00:00 2001 From: Sona Sara Shibu Date: Fri, 14 Aug 2026 11:14:18 +0530 Subject: [PATCH 2/2] Update stock_in_air_ssmm.md --- Care/Operations/stock_in_air_ssmm.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Care/Operations/stock_in_air_ssmm.md b/Care/Operations/stock_in_air_ssmm.md index 44349cd..5a6fcc8 100644 --- a/Care/Operations/stock_in_air_ssmm.md +++ b/Care/Operations/stock_in_air_ssmm.md @@ -5,7 +5,7 @@ ## Purpose -Lists stock deliveries that are currently `in_progress` ("stock in air") at SSMM, showing what product is moving, quantity, delivery/order status, movement date, origin and destination locations, and the user who created the delivery record. +Lists stock deliveries that are currently `in_progress` ("stock in air") at SSMM, showing what product is moving, quantity, delivery/order status, delivery record created date, origin and destination locations, and the user who created the delivery record. ## Parameters @@ -44,8 +44,7 @@ JOIN emr_productknowledge epk AND destination.deleted = FALSE LEFT JOIN users_user uu ON uu.id = esd.created_by_id -WHERE edo.origin_id IS NOT NULL - AND esd.status = 'in_progress' +WHERE esd.status = 'in_progress' --[[AND {{date}}]] ORDER BY epk.name; ```