Skip to content

Merge release-3.12.2 into release-3.13.0 (STOP-765, STOP-774) - #409

Merged
sehjotsinghunthinkable merged 10 commits into
release-3.13.0from
merge/release-3.12.2-into-3.13.0
Nov 9, 2026
Merged

sehjotsinghunthinkable merged 10 commits into
release-3.13.0from
merge/release-3.12.2-into-3.13.0

Conversation

@drtechie

@drtechie drtechie commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Brings the release-3.12.2 hotfixes forward into release-3.13.0.

Tickets

  • STOP-765: faster changes-feed first download
  • STOP-774: camp hub creates the X-ray / TrueNat orders a screening refers for

Commits from 3.12.2

Conflict resolution

One conflict, imports only, in TBConfirmedCaseServiceImpl.java: 3.13.0 added explicit follow-up imports, 3.12.2 switched to wildcard domain.iemr.* / repo.iemr.* and added java.time.ZoneId / java.util.*. Kept the 3.12.2 imports, which cover the 3.13.0 ones (checked no simple-name clashes with java.util).

Tests

  • mvn compile passes.
  • StopTB referral, sync, TB confirmed and diagnostic order tests pass, except StopTBSyncCoverageTest, which fails with the same table list on release-3.12.2 alone (badge, notification, tb_referral_follow_up, tb_tpt_follow_up, user_fcm_tokens not classified). Not introduced by this merge.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • TB screening referrals can now trigger chest X-ray and sputum diagnostic orders when eligible, with checks to avoid duplicate or outdated orders.
    • Incentive eligibility now reflects treatment completion, follow-up dates, and applicable treatment outcomes.
  • Bug Fixes
    • Beneficiary records are matched to the correct registration when addresses are shared, improving worklist accuracy.

SauravBizbRolly and others added 10 commits November 6, 2026 13:58
(cherry picked from commit 3379e00)
fix: restore code lost when release 3.12.0 was merged to main
Bring main into release-3.12.2 (restores code lost in the 3.12.0 merge)
The changes-feed snapshot capped beneficiaries at 25 per page because each one
used to cost several identity lookups and a FHIR call. Records are now built
with one query per table for the whole page (WorklistPagePrefetch, health IDs
read locally); the remaining per-beneficiary mapping and address lookups in
getBeneficiaryRecordsByRegIds are batched too, with the old per-row queries as
the fallback. Raise the cap to 100 so a new tablet needs a quarter of the
pages for its first download.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…refers for (STOP-774)

The tablet placed these orders with its own order/push right after saving the
screening. When it could not reach the hub at that moment the order was marked
FAILED on the tablet only and never retried, and the registrar has no access to
the X-ray/TrueNat screens to retry it.

- After a screening save commits, the hub creates XRAY_CHEST / MTB orders for
  today's referred screenings on a single background thread.
- A sweep every 2 minutes (diagnostic.referral-sweep.tick-ms) covers referred
  screenings from today that still have no order.
- Skips beneficiaries with an order of that type created today (any status, so
  a FAILED device push stays with the nurse's Retry) or an open/completed one.
- Only on a camp hub (stoptb.van.id set); central never sends device orders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d (STOP-774)

Each feed page now carries createsReferralOrders (true on a camp hub). The
tablet stops placing screening referral orders itself only after it sees this
flag, so a hub older than this release keeps getting the tablet's push and no
referral is lost if the app is updated first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion

Feed beneficiary records were built from the newest mapping at each address.
When two registrations share an address ID, that mapping could belong to the
other registration, so the requested record was missing and the feed moved
past it. The registration ID now travels with its address, the record is built
from that registration's mapping, and the prefetch loads that mapping's rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(sync): faster changes-feed first download; camp hub creates referral orders (STOP-765, STOP-774)
Brings the 3.12.2 hotfixes forward (STOP-765 faster changes-feed first
download, STOP-774 camp hub creates referral orders, feed beneficiary record
fixes, code merge fix).

Conflict: TBConfirmedCaseServiceImpl imports only. Kept 3.12.2's wildcard
domain/repo imports plus java.time.ZoneId and java.util.*, which cover the
explicit follow-up imports 3.13.0 added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request adds asynchronous orders for TB screening referrals, updates beneficiary address mapping for requested registrations, and changes TB incentive date and outcome checks. It also updates sync-page settings and adds referral-order tests.

Changes: TB referral orders

Layer / File(s) Summary
Referral and duplicate-order queries
src/main/java/com/iemr/flw/repo/iemr/DiagnosticOrderRepo.java, src/main/java/com/iemr/flw/repo/iemr/TBScreeningRepo.java
The repositories now find recent referred screenings and check for a matching order created today or with an open status.
Referral processing and order creation
src/main/java/com/iemr/flw/service/impl/StopTBReferralOrderService.java
The service queues referrals after commit or processes them in a scheduled sweep. It checks screening dates, beneficiary details, and existing orders before creating requested orders.
Screening integration and sync settings
src/main/java/com/iemr/flw/service/impl/StopTBServiceImpl.java, src/main/java/com/iemr/flw/service/impl/StopTBSyncServiceImpl.java, src/test/java/com/iemr/flw/service/impl/StopTBReferralOrderServiceTest.java
Saved screenings pass referral flags to the order service. Sync pages include camp configuration and use a beneficiary page limit of 100. Tests cover order creation and skip conditions.

Beneficiary address mapping

Layer / File(s) Summary
Registration-aware address prefetch
src/main/java/com/iemr/flw/service/impl/WorklistPagePrefetch.java
Worklist prefetch accepts requested registration IDs and returns usable addresses keyed by registration ID.
Registration-aware beneficiary records
src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java
Beneficiary record lookup batches address retrieval, falls back to per-registration lookups, and selects the mapping associated with each requested registration.

TB incentive eligibility

Layer / File(s) Summary
Incentive date and outcome checks
src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java
The incentive check uses the follow-up date and calls the DR-TB incentive only for cured outcomes. The new eligibility method checks the minimum treatment duration.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Scheduler
  participant StopTBReferralOrderService
  participant TBScreeningRepo
  participant DiagnosticOrderRepo
  Scheduler->>StopTBReferralOrderService: invoke scheduled sweep
  StopTBReferralOrderService->>TBScreeningRepo: findReferredSince for configured van and today
  TBScreeningRepo-->>StopTBReferralOrderService: return referred screenings
  StopTBReferralOrderService->>DiagnosticOrderRepo: check for matching order today or open order
Loading

Possibly related PRs

  • PSMRI/FLW-API#405: Contains the same STOP-765 and STOP-774 changes and is described as the release-branch merge of this change set.
  • PSMRI/FLW-API#393: Changes the beneficiary record-building contract and related prefetch behavior that this pull request also updates.
  • PSMRI/FLW-API#407: Adds the same incentive eligibility method and changes incentive handling in the same service.

Suggested reviewers: vishwab1, sehjotsinghunthinkable, sauravbizbrolly

Merge Risk: Low · up to 97c90

Referral order creation could occasionally be delayed until the next two-minute sweep if queuing fails after a save. The impact is small and self-recovering, so the change is mergeable with minor follow-up.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@sehjotsinghunthinkable
sehjotsinghunthinkable merged commit ada9b00 into release-3.13.0 Nov 9, 2026
3 of 5 checks passed
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.

3 participants