-
Notifications
You must be signed in to change notification settings - Fork 1
Add documentation for Stock in Air query at SSMM #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sonzsara
wants to merge
2
commits into
main
Choose a base branch
from
ENG-886
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+58
−0
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
sonzsara marked this conversation as resolved.
|
||
| ON origin.id = edo.origin_id | ||
| AND origin.deleted = FALSE | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirm this with product |
||
| 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}}]] | ||
|
sonzsara marked this conversation as resolved.
Outdated
|
||
| 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* | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.