feat(stoptb): record whether AMRIT created each Nikshay ID or already existed. - #185
Conversation
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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|



What
stopTb/nikshay/importResultsCsvnow 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:Changes
NikshayExportRepository—updateNikshayIdandinsertSuspectedWithNikshayIdtake acreatedByAmritflag and write it totb_suspected.nikshay_created_by_amrit.NikshayImportService— derives the flag from the CSV row status:success→true(portal generated it),skipped→false(ID already on the portal, duplicate detected).ImportSummary— gainscreatedByAmrit/alreadyOnNikshaycounts, a breakdown of the existingupdatedtotal 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:
failedmaps tofalsein the mapping for completeness only; it's unreachable in practice, so in real datafalsecomes fromskipped.Rows written before the column existed stay
NULL— deliberately distinct from an explicitfalse, since "we don't know" is not the same as "it already existed".Storage
The DB column is
TINYINT(1), so values on disk are1/0/NULL. The JSON response field is a real JSONtrue/false(Javaboolean) — worth knowing if anything compares the API response against the DB value directly.Depends on
PSMRI/AMRIT-DB#169 — adds the
nikshay_created_by_amritcolumn (V107). Merge that first; without it these writes fail on an unknown column.Known gap (not addressed here)
tb_suspecteddoes sync van→central, but the sync column list comes fromm_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-DBV105pattern. Left alone rather than guessed, since it's live per-server config outside this API.Testing
writeNikshayId, and the singleImportSummaryconstruction), 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