-
Type:
Bug
-
Resolution: Done
-
Priority:
High
-
Affects Version/s: 2.3, 2.3.1
Summary
The tablet keeps re-sending General OPD visits that the hub has already accepted. The hub isn't idempotent for visits that have instructions but no medicines, so every resend writes a new prescription and soft-deletes the previous one. A resend on a later day also creates a new visit for that day. All of these rows sync to central.
Evidence
Tablet (counter 2, app 2.3.1 (25), sync logs for 11 and 12 Nov)
- Every push run logs General OPD push complete: 66 succeeded, 9 failed out of 75. That's 62 runs, and the 75 never drops.
- The hub returns 200 for these 66, but the rows stay UNSYNCED.
- The 9 failures are tracked separately.
Camp 467 hub (Fleet queries 41-43, read-only)
- Since 10 Nov, db_iemr.t_prescription holds 4,184 rows for 192 beneficiaries. 3,734 of them are soft-deleted and 450 are active.
- All 192 beneficiaries have more than one visit (3 each: 10, 11 and 12 Nov) for what was one consultation.
- There are no t_patientissue rows and no t_benchiefcomplaint rows for them.
- Example: beneficiary 421366 has 60 prescriptions, all with Instruction "good", no drugs, and visit 2053. They alternate CreatedBy/ModifiedBy between KA-203 and KA-252, starting 6 Nov.
- Hourly volume is about 66 new rows per resend, matching counter 2's 66 records. KA-252's tablet shows the same pattern.
Causes
- The app never marks these visits as synced. TBRepo.pushUnSyncedRecordsGeneralOpd gets HTTP 200 / statusCode 200, but updateSyncStatusGeneralOpd only sets SYNCED when the re-read row and the rebuilt payload equal what was sent. For these records that check fails every time, so they're sent again on every cycle. Not yet confirmed which field differs; check current == pushed and currentPayload == request.
- The hub isn't idempotent for visits without medicines.
- StopTBServiceImpl (new OPD payload) detects a repeat only through StopTBPrescriptionService.findPreviousSubmission, which looks for a t_patientissue row with Reference = 'StopTB:' + submissionId.
- A visit with no drugs (instruction only), or a camp with dispensing off (prescribeWithoutDispensing), never writes that row, so every resend inserts a new prescription.
- getOrCreateVisitForToday puts a resend made on a later day into a new visit dated that day.
Expected
- *App:* after a 200 response, the visit is marked SYNCED and isn't sent again (unless the user edits it).
- *Hub:* a save with a submissionId that has already been processed returns the earlier result and writes nothing, whether or not the visit has drugs or dispensing is on. For example, record the submissionId on the prescription or in its own table. It must not create a new visit.
- *Clean-up:* decide how to handle the duplicate visits and prescriptions already on the camp hubs and central. They're soft-deleted except for one active prescription per beneficiary per day.
Test
- Save an OPD visit with an instruction and no medicines, and sync twice on the same day and once the next day. The hub should have one visit and one prescription, and the tablet should show the visit as synced after the first push.
- Repeat with medicines, with dispensing on and off.
- blocks
-
STOP-814 General OPD visits with unresolved complaints or medicines stay on the tablet forever without telling the user
-
- Closed
-