Repository navigation
fix(datasync): link van rows to old central rows saved without VanSerialNo (STOP-862) - #215
Merged
Merged
Conversation
…ialNo (STOP-862) Central 3.8.x / 3.9.x saved van visits and prescriptions without VanSerialNo. Since translateVanLinks (PR #201) links child rows by VanID + VanSerialNo, a drug or refer of such an old prescription/visit was rejected on every upload ("Linked t_prescription ... not on central yet"), blocking the table's queue. When the lookup by VanSerialNo finds nothing, central now looks for the one row of the same VanID + VisitCode + BeneficiaryRegID whose VanSerialNo is empty, writes the van's ID into it (and, for a prescription, the central ID of its visit) and links the child to it. Several such rows: nothing is written and the reason is returned. A re-sent visit/prescription is synced onto that old row instead of inserted as another copy. Switch: dataSync.claimEmptyVanLabels (default true, only with translateVanLinks). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
Comment on lines
+215
to
+217
| List<Long> ids = getJdbcTemplate().queryForList("SELECT " + idColumn + " FROM " + table | ||
| + " WHERE VanID = ? AND VisitCode = ? AND BeneficiaryRegID = ? AND VanSerialNo IS NULL" | ||
| + " AND (Deleted IS NULL OR Deleted = 0)", Long.class, |
| + " WHERE " + idColumn + " = ? AND VanSerialNo IS NULL"; | ||
| Object[] params = setVisit ? new Object[] { String.valueOf(vanSerialNo), centralBenVisitID, centralId } | ||
| : new Object[] { String.valueOf(vanSerialNo), centralId }; | ||
| int updated = getJdbcTemplate().update(update, params); |
vanitha1822
approved these changes
Dec 1, 2026
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.




📋 Description
Since PR #201 (in release-3.13.0), central links a van's child rows (drugs, refers, vitals, …) to their
parent visit / prescription by VanID + VanSerialNo (
translateVanLinks). If the parent is not found,the child is rejected with "Linked t_prescription (van ID 556) not on central yet" and sent again next sync.
Rows uploaded while central ran 3.8.x / 3.9.x (before 31 Oct 2026) were saved without VanSerialNo
(commit 604bd64, name-based column fill). Their parents are on central, but cannot be found by VanSerialNo,
so their children are rejected on every sync. The laptop stops that table at the first rejected batch
of 30, so all newer rows wait behind them.
Example (STOP-862, Subir Van2 / VanID 525): 30 drugs of 24 Oct prescriptions rejected, 343 waiting
since 24 Oct. On central, 18,776 prescriptions on 99 vans still have no VanSerialNo.
Until now each camp needed a manual SQL fix (fill VanSerialNo from a Fleet export of the laptop).
What this PR does
When the lookup by VanID + VanSerialNo finds nothing, central looks for the old row by
VanID + VisitCode + BeneficiaryRegID with VanSerialNo IS NULL:
ID of its visit) and links the child to it;
A visit / prescription that the van re-sends is synced onto that old row instead of being inserted as
another copy.
VisitCode and BeneficiaryRegID were stored correctly by the old code; only VanSerialNo and the visit
pointer were wrong, so the match cannot attach a row to another patient.
Switch
dataSync.claimEmptyVanLabels(defaulttrue), used only whendataSync.translateVanLinks=true(Stop TB central). Set to
falseto turn it off.Not covered
changed: stay rejected, need the central data correction.
a per-laptop fix.
Tests
DataSyncRepositoryCentralEmptyLabelTest(new, 6): single match filled; prescription also gets itsvisit; lookup only on VanID + VisitCode + patient + empty label; several matches not guessed; row
changed meanwhile reported; no VisitCode → nothing done.
GetDataFromVanAndSyncToDBVanLinksTest(+3): drug of an old prescription linked; several copiesreported; switch off → not used.
JIRA ID: STOP-862
Please provide a summary of the change and the motivation behind it. Include relevant context and details.
✅ Type of Change
ℹ️ Additional Information
Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.