You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason will be displayed to describe this comment to others. Learn more.
Analytics SQL Review — SSMM report of invoices with duplicate charge-item discounts
Ticket: The PR isn't linked to a verifiable JIRA ticket. The branch is ENG-1068, but the lookup failed (HTTP 404, then 401 on the scoped endpoint). That means either the ticket is inaccessible to the bot or the ID is wrong, so I couldn't review requirement fidelity. If the ticket is real, please make sure it's visible to the integration.
SQL: It parses cleanly (lint report has no findings). The EXISTS with GROUP BY eci.id HAVING COUNT(*) > 1 does count discount components per charge item correctly, and there is no fan-out because of DISTINCT. Open questions:
Cancelled and entered_in_error invoices aren't excluded (inline comment).
The link hardcodes one facility while the query is unscoped (inline comment).
Docs: The Notes section is missing the hardcoded host and facility ID, and it doesn't explain what counts as a "discount" component. Copilot already raised the Notes point.
Verdict: Not yet safe to publish until the status filter and facility scoping are settled.
The reason will be displayed to describe this comment to others. Learn more.
The link hardcodes a single facility UUID, but the query has no facility filter. If the DB holds more than one facility, invoices from the others get a link pointing at the wrong facility. Either join emr_facility and build the link from the invoice's own facility (i.facility_id), or add an explicit facility filter. Then document the host and UUID in Notes (Copilot raised the Notes point too, so I'm not repeating it).
The reason will be displayed to describe this comment to others. Learn more.
At head 5d3cfb1 the facility-UUID link column is gone, so the wrong-facility link problem and the Notes point no longer apply. Resolving. The query still has no facility predicate, which I've noted in the summary.
The reason will be displayed to describe this comment to others. Learn more.
Only deleted = FALSE is filtered. Invoices with status of cancelled / entered_in_error still show up, so they will be flagged as duplicate-discount problems even though they no longer count. Please confirm intent. If they shouldn't count, add e.g. AND i.status NOT IN ('cancelled', 'entered_in_error'). I couldn't check the ticket, so I'm assuming the report is about live invoices. Verify the exact status values against care/emr/models/invoice.py first.
The repository template says to delete the Parameters section when a query has no parameters (TEMPLATE.md:15). Keeping a placeholder row here diverges from that documented format; remove this section and retain only the divider before the query.
The reason will be displayed to describe this comment to others. Learn more.
Analytics SQL Review — invoices with duplicate discounts on charge items (SSMM)
Ticket: none found. JIRA returned 404 for ENG-1068 (the branch name), possibly an access problem with the token. I can't check requirement fidelity, so I'm assuming the report is meant to cover live invoices only.
Fixed since last round: the hardcoded facility URL and UUID column has been removed. I replied to that thread and resolved it.
Still open:
The i.status exclusion thread (cancelled / entered_in_error) is not addressed. The query still filters only on deleted = FALSE, so voided invoices will be reported as duplicate-discount problems. The same goes for charge items: emr_chargeitem has a status, and the report probably shouldn't count entered_in_error rows. Please confirm the exact values in care/emr/models/.
New:
The file is named _ssmm, but no facility predicate is in the SQL. If the database holds more than one facility, other facilities' invoices will leak in. Add a facility filter (for example i.facility_id = <ssmm id>), or drop the suffix if the report is meant to span all facilities. Any hardcoded ID needs a line in Notes.
The Notes should describe the "duplicate discount" definition (more than one monetary_component_type = 'discount' component on a single charge item), and the output columns table is missing.
The parse is clean (lint report: 0 findings). The EXISTS with GROUP BY ... HAVING avoids fan-out, so DISTINCT is redundant but harmless. The numbers aren't safe to publish until the status and facility scoping are settled.
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
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.
No description provided.