docs: ADR for querystore indexing decisions - #176
Open
dkayiwa wants to merge 4 commits into
Open
Conversation
Records the load-bearing decisions behind the four querystore resource types this module exposes (bill, bill_refund, bill_discount, timesheet) plus the explicit non-decision to skip BillableService — the querystore SPI is BaseOpenmrsData-bounded and catalog metadata doesn't fit. The file lives at docs/adr/0001-querystore-indexing.md so future contributors planning a new field, a new resource type, or a new consumer have one place to start. It also catalogues the deferred items with their failure-mode sentences so the next maintainer can judge urgency without rediscovering the same trade-offs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sixteen decision sections plus open issues and consequences is too much to scan linearly — anchor links let a reader jump straight to the specific decision they're checking on. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #176 +/- ##
=========================================
Coverage 34.37% 34.37%
Complexity 800 800
=========================================
Files 212 212
Lines 5144 5144
Branches 620 620
=========================================
Hits 1768 1768
Misses 3184 3184
Partials 192 192 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Four more load-bearing decisions surfaced while re-reading the slice: the refund's deliberate audit-trail divergence on voided line items (D17), the touchParentBill cross-resource propagation contract (D18), the defensive null-guards that exist because AbstractIndexingAdvice swallows RuntimeException per entity (D19), and the deliberate rejection of a shared abstract serializer base (D20). D18 is particularly load-bearing for anyone adding a new child resource type that affects bill-level aggregates — without it, the parent bill's index goes stale on every child save. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Four more decisions surfaced on a fresh pass: the billing_* namespacing convention that prevents cross-module document collisions (D21), the text-vs-metadata contract that protects consumers from parsing the prose blob (D22), the deliberate asymmetric denormalization boundary (cashier/cashpoint names yes, patient/visit names no) so future contributors don't chase false consistency at the cost of lazy fetches on every save (D23), and the explicit "voided rows stay in the index" default so audit queries keep working (D24). D21 and D22 prevent specific failure modes (silent overwrites, parsing-based coupling). D23 documents a real architectural boundary. D24 is an affirmation of behavior consumers depend on. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This was referenced May 20, 2026
| | `RESOURCE_TYPE_BILL` | `billing_bill` | Yes | `BillService` | | ||
| | `RESOURCE_TYPE_BILL_REFUND` | `billing_bill_refund` | Yes | `BillRefundService` | | ||
| | `RESOURCE_TYPE_BILL_DISCOUNT`| `billing_bill_discount` | Yes | `BillDiscountService` | | ||
| | `RESOURCE_TYPE_TIMESHEET` | `billing_timesheet` | No (provider) | `ITimesheetService` | |
Contributor
|
|
||
| ## Context | ||
|
|
||
| The billing module persists `Bill`, `BillLineItem`, `Payment`, `BillDiscount`, `BillRefund`, `Timesheet`, `BillableService` and related entities. Free-text and structured search across this data — "find bills paid by Mobile Money", "approval queue for pending discounts", "find the bill for this lab order", "who was on duty between 2pm and 3pm" — was previously not feasible without scanning the persistence layer one row at a time. |
Contributor
There was a problem hiding this comment.
One thing that I think would be helpful was if we could get an answer for a question like, "what was the patient billed for during the last visit” or “was this patient billed for an xray during their last visit"?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Summary
docs/adr/0001-querystore-indexing.mddocumenting the load-bearing decisions behind the billing module's participation in the querystore SPI.BillingAuditFieldsandBillingDisplayNameshelpers, trigger naming,lazy-initrationale, and intentional non-decisions.OLD bill status drift on adjustment,closeOpenTimesheets bypasses indexing, lazy walks per save, percentage discount lazy nav, rename staleness, text-blob comma conflation).Test plan
AbstractIndexingAdvice<T extends BaseOpenmrsData>— type bound matches.VisitRecordSerializer.FIELD_ENCOUNTER_UUIDS/AllergyRecordSerializer.FIELD_REACTIONS.BaseEntityDataServiceImpl.voidEntitycallingsave()internally.🤖 Generated with Claude Code