Conversation
There was a problem hiding this comment.
Pull request overview
Adds SSMM-facing documentation for an inventory SQL query that computes per-product stock balances and valuation for a single location at a selected snapshot date, split across incoming, outgoing (normal vs error/consumption destinations), and dispensed quantities.
Changes:
- Introduces a new markdown document describing the “Total Stock Value with Location Split” query (purpose, parameters, SQL, notes).
- Includes a full SQL statement that aggregates incoming supplies, outgoing transfers (normal/error buckets), and medication dispenses into a net stock and total value output.
Suppressed comments (1)
Care/Inventory/total_stock_value_with_location_split_ssmm.md:125
dispensesis FULL OUTER JOINed onincoming.id, which can leave dispense counts in a separate row when the product is present only inoutgoing_*joins. Use the coalesced key from all prior joins to keep per-product rows merged.
) dispenses ON dispenses.id = incoming.id
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (3)
Care/Inventory/total_stock_value_with_location_split_ssmm.md:139
- Notes line has a few avoidable grammar issues ("hard coded", "id's") and inconsistent hyphenation ("entered in error" vs "entered-in-error"). This reads more clearly as "hardcoded destination IDs" and consistent hyphenation.
- The hard coded destination id's refer to the entered in error and consumption locations, update if needed
Care/Inventory/total_stock_value_with_location_split_ssmm.md:16
- Parameter description uses "id" in prose; elsewhere in docs this is typically written as "ID" (e.g., "location ID") for readability/consistency.
This issue also appears on line 139 of the same file.
| `location_id` | INTEGER | Facility location id to compute stock for | `239` |
Care/Inventory/total_stock_value_with_location_split_ssmm.md:98
- The long destination_id list is duplicated in both
outgoing_normal(NOT IN) andoutgoing_error(IN). Keeping these in sync is error-prone; consider factoring the IDs into a single CTE (or a temp table/view) and referencing it from both clauses (e.g.,destination_id IN (SELECT id FROM error_destinations)andNOT IN (...)).
WHERE esd.status IN ('completed', 'in_progress')
AND esd.deleted = FALSE AND edo.deleted = FALSE
AND DATE(esd.created_date) <= {{selected_date}}
AND origin_id = {{location_id}}
AND destination_id NOT IN (264, 270, 280, 274, 273, 275, 276, 266, 279, 36, 265, 278, 297, 238, 298, 27, 481, 17, 32, 277)
GROUP BY ep.id
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
Care/Inventory/total_stock_value_with_location_split_ssmm.md:106
- The error/consumption branch has the same direct-product gap: a delivery with
supplied_item_idbut nosupplied_inventory_item_idcannot resolveep.id, so its outgoing quantity is not subtracted from the product's stock. Use the direct product ID with the inventory product as fallback, matching the incoming paths.
SELECT ep.id AS id, SUM(supplied_item_quantity) AS count
FROM emr_supplydelivery esd
LEFT JOIN emr_deliveryorder edo ON esd.order_id = edo.id
LEFT JOIN emr_inventoryitem eii ON esd.supplied_inventory_item_id = eii.id
LEFT JOIN emr_product ep ON eii.product_id = ep.id
Care/Inventory/total_stock_value_with_location_split_ssmm.md:139
- Use “hard-coded” and the plural “IDs”;
id'sis possessive rather than plural. The sentence also needs terminal punctuation.
- The hard coded destination id's refer to the entered in error and consumption locations, update if needed
| SELECT ep.id AS id, SUM(supplied_item_quantity) AS count | ||
| FROM emr_supplydelivery esd | ||
| LEFT JOIN emr_deliveryorder edo ON esd.order_id = edo.id | ||
| LEFT JOIN emr_inventoryitem eii ON esd.supplied_inventory_item_id = eii.id | ||
| LEFT JOIN emr_product ep ON eii.product_id = ep.id | ||
| WHERE esd.status IN ('completed', 'in_progress') | ||
| AND esd.deleted = FALSE AND edo.deleted = FALSE | ||
| AND DATE(esd.created_date) <= {{selected_date}} | ||
| AND origin_id = {{location_id}} | ||
| AND destination_id NOT IN (264, 270, 280, 274, 273, 275, 276, 266, 279, 36, 265, 278, 297, 238, 298, 27, 481, 17, 32, 277) | ||
| GROUP BY ep.id |
…NT on toolcache hit) First workflow_dispatch dry-run (run 32010839654, PR #146) failed at "Execute GitHub Copilot CLI" with `spawn /usr/local/bin/copilot ENOENT`: the v0.85.4 harness hardcoded /usr/local/bin/copilot, but the install step hit the runner toolcache (/opt/hostedtoolcache/copilot-cli) and only appended to GITHUB_PATH. Known upstream bug, fixed in gh-aw v0.86.2 (github/gh-aw#52464): the execute step now resolves the binary via `command -v copilot` and stages it to ${RUNNER_TEMP}/gh-aw/bin/copilot before invoking the harness. Generated files only — source .md workflow/agent files unchanged (frontmatter/body hashes identical in the lock metadata). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…NT on toolcache hit) (#151) First workflow_dispatch dry-run (run 32010839654, PR #146) failed at "Execute GitHub Copilot CLI" with `spawn /usr/local/bin/copilot ENOENT`: the v0.85.4 harness hardcoded /usr/local/bin/copilot, but the install step hit the runner toolcache (/opt/hostedtoolcache/copilot-cli) and only appended to GITHUB_PATH. Known upstream bug, fixed in gh-aw v0.86.2 (github/gh-aw#52464): the execute step now resolves the binary via `command -v copilot` and stages it to ${RUNNER_TEMP}/gh-aw/bin/copilot before invoking the harness. Generated files only — source .md workflow/agent files unchanged (frontmatter/body hashes identical in the lock metadata). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…o the agent Dry-run 32015295640 (PR #146) went green end-to-end after the v0.86.2 recompile, but the agent posted nothing: the resolve pre-step's AW_PR_NUMBER/AW_HEAD_REF land in step env only, which never reaches the agent sandbox, and on workflow_dispatch the event payload has no PR object. The agent concluded "no associated pull request ... nothing to review" and noop'd. Fix 1: the resolve step (now id: resolve_pr) also writes step outputs and /tmp/gh-aw/context/run-context.md — the context dir is the one channel proven to reach the agent (it read jira-ticket.md in the same run). The prompt body names run-context.md as the source of truth for PR identity, treats a dispatch run with a resolved PR as a normal review, and reserves noop for runs where no PR resolves at all. (${{ steps.* }} interpolation into the body cannot work: the prompt is rendered in the activation job, the steps run in the agent job.) Fix 2: the same run showed "JIRA returned HTTP 404 for ENG-909" — ambiguous, since JIRA answers 404 for missing ticket, missing project permission, AND bad credentials. On any non-200 the step now probes /rest/api/3/myself and writes an auth diagnosis into the marker (credentials rejected vs authenticated-but-cannot-see vs unreachable), reporting HTTP codes only, never credential values. Still never fails the job. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…o the agent (#152) * Fix analytics-review on workflow_dispatch: pass resolved PR context to the agent Dry-run 32015295640 (PR #146) went green end-to-end after the v0.86.2 recompile, but the agent posted nothing: the resolve pre-step's AW_PR_NUMBER/AW_HEAD_REF land in step env only, which never reaches the agent sandbox, and on workflow_dispatch the event payload has no PR object. The agent concluded "no associated pull request ... nothing to review" and noop'd. Fix 1: the resolve step (now id: resolve_pr) also writes step outputs and /tmp/gh-aw/context/run-context.md — the context dir is the one channel proven to reach the agent (it read jira-ticket.md in the same run). The prompt body names run-context.md as the source of truth for PR identity, treats a dispatch run with a resolved PR as a normal review, and reserves noop for runs where no PR resolves at all. (${{ steps.* }} interpolation into the body cannot work: the prompt is rendered in the activation job, the steps run in the agent job.) Fix 2: the same run showed "JIRA returned HTTP 404 for ENG-909" — ambiguous, since JIRA answers 404 for missing ticket, missing project permission, AND bad credentials. On any non-200 the step now probes /rest/api/3/myself and writes an auth diagnosis into the marker (credentials rejected vs authenticated-but-cannot-see vs unreachable), reporting HTTP codes only, never credential values. Still never fails the job. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * JIRA step: support scoped Atlassian tokens (accessible-resources probe + auto-recovery) Root cause of the ENG-909 404: JIRA_API_TOKEN is a scoped Atlassian API token, and scoped tokens must target https://api.atlassian.com/ex/jira/<cloudId> instead of https://<site>.atlassian.net. Atlassian answers 404 (not 403) when a scoped token hits the site-host form, which mimics a missing issue. - Replace the /rest/api/3/myself probe (not callable with granular read:issue scopes -> would false-report valid credentials as broken) with GET https://api.atlassian.com/oauth/token/accessible-resources, which works for both token types and returns each site's cloudId. - Auto-recovery: when the issue fetch fails and the probe can resolve a cloudId (configured URL matches a site, cloudId embedded in an ex/jira URL, or single-site token), retry via the scoped-token endpoint - so either token type works with either JIRA_BASE_URL form. - Self-diagnosing markers on hard failure: credentials rejected (401/403, mentions <=365-day scoped-token expiry), base URL matches none of the token's sites (lists reachable site URLs + cloudIds and the exact value to set), ticket not visible/nonexistent (tried both endpoints), or api.atlassian.com unreachable. HTTP codes, site URLs and cloudIds only; never credential values. - Comments fetch now uses the possibly-recovered base URL. - README: JIRA_BASE_URL form guidance per token type. - New helper .github/scripts/jira_sites.py (cloud-id resolution + site summary; always exits 0). All six failure/recovery branches exercised locally against a mock Atlassian server using the step script extracted verbatim from the workflow; every path exits 0 and writes the marker. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
No description provided.