Skip to content

Add documentation for laboratory service requests and their charge items - #158

Open
sonzsara wants to merge 1 commit into
mainfrom
ENG-972
Open

Add documentation for laboratory service requests and their charge items#158
sonzsara wants to merge 1 commit into
mainfrom
ENG-972

Conversation

@sonzsara

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id filter on either table despite the _ssmm suffix — 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 — an entered_in_error/voided charge item will still appear as a valid mapping. Only the service request's status is checked.
  • Minor: deleted = FALSE is 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

emr_chargeitem.title AS charge_item_title
FROM emr_servicerequest
JOIN emr_chargeitem
ON emr_chargeitem.service_resource = 'service_request'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[High] emr_chargeitem.status is not filtered.

ChargeItem has its own status field (see care/emr/models/charge_item.py) independent of the service request's status. The query excludes entered_in_error on emr_servicerequest but not on emr_chargeitem — a charge item entered in error (or voided/cancelled) will still show up here as if it were a valid charge tied to the lab request. Add AND emr_chargeitem.status != 'entered_in_error' (and any other terminal status this report should exclude) alongside the existing service-request filter.

Also, neither table filters deleted = FALSE. It's rarely set, but it's free and matches repo convention — worth adding on both tables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant