Conversation
There was a problem hiding this comment.
Analytics SQL Review — Laboratory service requests mapped to charge items (SSMM)
Ticket: No linked ticket — JIRA lookup for ENG-972 returned HTTP 404/401 (see prep step). Branch name should resolve to a real ticket; without it I can't verify this query matches an actual requirement (metric, grain, facility scope). Continuing with Lenses 2–4.
Numbers — not yet trustworthy for the _ssmm dashboard:
- Critical: No
facility_idfilter on either table despite the_ssmmsuffix — this returns/aggregates across every facility, not just SSMM. That's a cross-tenant leak, not just an inefficiency. - High:
emr_chargeitem.status(independent from the service request's status) isn't filtered — anentered_in_error/voided charge item will still appear as a valid mapping. Only the service request's status is checked. - Minor:
deleted = FALSEis missing on both tables (low-signal since it's rarely set, but free and matches repo convention).
No join-fan-out risk here since there's no aggregate/money rollup, and the DISTINCT is reasonable given the intended 1-service-request-to-many-charge-items grain the Purpose describes.
Docs: Notes section correctly explains the lab-only filter; Parameters table is fine as-is (no params). Once the facility scope is added, document the facility id there too.
Hygiene: Correct domain folder (Care/Clinical/), filename convention followed, one file for one PR — no issues.
Verdict: Hold before publishing — the missing facility scope on a facility-suffixed query is the kind of bug that quietly leaks data across tenants on a shared dashboard.
Generated by Analytics SQL Reviewer for #158 · auto · 44.1 AIC · ⌖ 4.75 AIC · ⊞ 14.7K
There was a problem hiding this comment.
Analytics SQL Review — laboratory service requests with their charge items (SSMM)
This is a re-review triggered by a reply on my prior High-severity finding.
Fixed: emr_chargeitem.status != 'entered_in_error' has been added, closing the main gap (a voided/errored charge item no longer masquerades as a valid one). Confirmed at the current head SHA.
Still open on that same thread: neither emr_servicerequest nor emr_chargeitem filters deleted = FALSE. Low risk since the flag is rarely set in practice, but it's free and matches repo convention (see sibling _ssmm docs) — worth adding before merge. Left the thread open for this.
The facility-scoping thread was already resolved in an earlier round (SSMM is single-facility by convention, matching every other _ssmm query in the repo).
No new findings — the ticket link (JIRA 404 for ENG-972) and everything else already covered stands as previously reported.
Generated by Analytics SQL Reviewer for #158 · auto · 21.8 AIC · ⌖ 2.4 AIC · ⊞ 14.7K
No description provided.