Skip to content

feat(stoptb): record whether AMRIT created each Nikshay ID or already existed. - #185

Merged
vishwab1 merged 2 commits into
release-3.9.0from
sn/3.9.0
Sep 11, 2026
Merged

feat(stoptb): record whether AMRIT created each Nikshay ID or already existed.#185
vishwab1 merged 2 commits into
release-3.9.0from
sn/3.9.0

Conversation

@snehar-nd

Copy link
Copy Markdown
Contributor

What

stopTb/nikshay/importResultsCsv now also records whether each Nikshay ID it writes was generated for us by the portal, or already existed there.

Why

The import already wrote the portal's Nikshay ID onto tb_suspected, but nothing distinguished the two cases. Counting "IDs created by this application" therefore meant inferring it from the ID's presence, which over-counts every pre-existing ID. The programme can now get an exact count:

SELECT COUNT(*) FROM tb_suspected WHERE nikshay_created_by_amrit = 1;

Changes

  • NikshayExportRepositoryupdateNikshayId and insertSuspectedWithNikshayId take a createdByAmrit flag and write it to tb_suspected.nikshay_created_by_amrit.
  • NikshayImportService — derives the flag from the CSV row status: successtrue (portal generated it), skippedfalse (ID already on the portal, duplicate detected).
  • ImportSummary — gains createdByAmrit / alreadyOnNikshay counts, a breakdown of the existing updated total that always sums to it, so the figure is available from the response without a query. Purely additive; no existing field changes meaning.

Current flow is unchanged

This was the explicit constraint on the change, so to be concrete about what was not touched:

  • Rows left for manual review (ambiguous phone+name match, multiple candidate IDs) still write nothing at all.
  • Rows that genuinely failed still write nothing — they have no ID to write. failed maps to false in the mapping for completeness only; it's unreachable in practice, so in real data false comes from skipped.
  • Beneficiary matching, the review/failure reporting, and the export side are untouched.

Rows written before the column existed stay NULL — deliberately distinct from an explicit false, since "we don't know" is not the same as "it already existed".

Storage

The DB column is TINYINT(1), so values on disk are 1 / 0 / NULL. The JSON response field is a real JSON true/false (Java boolean) — worth knowing if anything compares the API response against the DB value directly.

Depends on

PSMRI/AMRIT-DB#169 — adds the nikshay_created_by_amrit column (V107). Merge that first; without it these writes fail on an unknown column.

Known gap (not addressed here)

tb_suspected does sync van→central, but the sync column list comes from m_synctabledetail.ServerColumnName / VanColumnName — live DB config, not code. Until that row includes the new column, the flag stays van-local. If the count is meant to run on central, that needs a follow-up on the AMRIT-DB V105 pattern. Left alone rather than guessed, since it's live per-server config outside this API.

Testing

⚠️ Not compiled or run — no Maven or JDK available in the environment this was written in. Every signature and call site was checked by hand (both repository methods, their sole caller writeNikshayId, and the single ImportSummary construction), and the SQL placeholder counts match the bound arguments in both statements, but this has not been through a compiler. Please build before merging. There is no existing test coverage for this import path.

🤖 Generated with Claude Code

The results-CSV import already wrote the portal's Nikshay ID onto
tb_suspected, but nothing distinguished an ID the portal generated for us
from one that already existed there and was only matched back. Counting
"IDs created by this application" therefore meant inferring it from the
ID's presence, which over-counts every pre-existing ID.

Each written row now also sets tb_suspected.nikshay_created_by_amrit --
true for a "success" row, false for a "skipped" row (portal-detected
duplicate). Rows left for manual review or genuinely failed still write
nothing at all, so the existing matching, review and failure behaviour is
unchanged; "failed" maps to false for completeness only, as those rows
have no ID to write.

The import response gains createdByAmrit/alreadyOnNikshay counts, a
breakdown of the existing `updated` total that always sums to it, so the
figure is available without a query. Additive -- no existing field
changes meaning.

Requires AMRIT-DB V107 for the column. Note the flag is not yet in the
van<->central sync column mapping, so it stays van-local until that row
is updated.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b2844866-ab2d-4eb4-90f1-7c20a057b0c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@snehar-nd snehar-nd changed the title feat(stoptb): record whether AMRIT caused each Nikshay ID to be created feat(stoptb): record whether AMRIT created each Nikshay ID or already existed. Sep 11, 2026
@vishwab1
vishwab1 merged commit 7668f80 into release-3.9.0 Sep 11, 2026
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.

2 participants