From b6a57fdecb24b409f3fb6e9e7e3bd55b505f73fe Mon Sep 17 00:00:00 2001 From: sonzsara Date: Mon, 29 Dec 2025 12:17:40 +0530 Subject: [PATCH] Add inventory stock list documentation for ssmm --- Care/Inventory/inventorystocklist_ssmm.md | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Care/Inventory/inventorystocklist_ssmm.md diff --git a/Care/Inventory/inventorystocklist_ssmm.md b/Care/Inventory/inventorystocklist_ssmm.md new file mode 100644 index 0000000..b9a3720 --- /dev/null +++ b/Care/Inventory/inventorystocklist_ssmm.md @@ -0,0 +1,45 @@ +# Inventory Stock List + +> Current inventory stock levels with location, expiry dates, and low stock alerts + +## Purpose + +This query provides a comprehensive view of inventory items across all locations, showing current stock quantities, expiration dates, and flagging low stock items. It's useful for inventory management, reordering decisions, and identifying items nearing expiration. + +## Parameters + +| Parameter | Type | Description | Example | +|-----------|------|-------------|---------| +| `stock_name` | TEXT | Filters by product name | `'bandage'` | + +--- + +## Query + +```sql +SELECT + pk.name AS stock_name, + fl.name AS location_name, + ii.net_content AS quantity, + p.expiration_date AS expiry_date, + CASE + WHEN ii.net_content < 100 THEN 'Low Stock' + ELSE ' ' + END AS stock_status +FROM emr_inventoryitem ii + JOIN emr_facilitylocation fl ON ii.location_id = fl.id +LEFT JOIN emr_product p ON ii.product_id = p.id +LEFT JOIN emr_productknowledge pk ON p.product_knowledge_id = pk.id +WHERE 1=1 +-- [[AND LOWER(pk.name) ILIKE '%' || LOWER({{stock_name}}) || '%']] +ORDER BY ii.net_content ASC; +``` + + +## Notes + +- Hardcoded at 100 units - items below this threshold are flagged as 'Low Stock' +- Results are ordered by quantity (lowest first) to prioritize low stock items +- Uses product knowledge table for standardized product names + +*Last updated: 2025-12-29*