Skip to content

Fix SiteLocation Step Trial - #216

Open
Philoul wants to merge 3 commits into
andyrozman:andy_tandem_dev4from
Philoul:andy_tandem_dev4
Open

Fix SiteLocation Step Trial#216
Philoul wants to merge 3 commits into
andyrozman:andy_tandem_dev4from
Philoul:andy_tandem_dev4

Conversation

@Philoul

@Philoul Philoul commented Aug 6, 2026

Copy link
Copy Markdown

Could you please check with this modification ?

Blind coding, so I was just able to check build works but no more

  • Change Cannula within T:Mobi
  • Check if now SiteLocation picker works with the graphical view
  • If yes select a location and select an Arrow and validate
  • Finish Canula Change steps
  • And at the end open SiteRotation UI to check if latest "Cannula change" is correctly recorded with the selected Location / Arrow

@Philoul

Philoul commented Aug 7, 2026

Copy link
Copy Markdown
Author

2 commits added (done by Claude Code Opus 5.0, guided by me):

  • first one to fix the screens
  • second one to record SiteLocation in database

How it works
On Done (CoreCartridgeActionsModel.completeSiteLocation) — the selection is parked in three new Tandem non-preference keys rather than written to the database, because no CANNULA_CHANGE event exists yet.
Preferences rather than in-memory state, so it survives a process restart while waiting. Nothing pending is written if the user picked neither location nor arrow, and Skip clears any stale pending value.

On the next history sync (HistoryPostProcessor.applyPendingSiteLocation) — when a CannulaFilledHistoryLog produces a CANNULA_CHANGE, the parked location/arrow are attached via persistenceLayer.insertOrUpdateTherapyEvent, then the pending slot is cleared.

T.hours(6) / T.hours(1) live in HistoryPostProcessor's companion, so the ViewModel just records when the user chose and the post-processor owns the policy.

Also removed the dead commented-out saveSiteLocationToTherapyEvent(), and downgraded the two aapsLogger.error calls in that region to info — they were logging normal flow at error level.

Two things to know when you test

  • The location only lands if a cannula fill actually follows. Per your choice, CannulaFilledHistoryLog is the carrier. If the user stops after fill-tubing and never fills the cannula, nothing is tagged and the selection expires silently after 6 h. It is also not instant — it appears whenever the next history pull processes that log, not when Done is pressed.
  • The duplicate CANNULA_CHANGE remains. TubingFilledHistoryLog still creates its own, untouched — that was the option you didn't pick. So a full workflow still yields two CANNULA_CHANGE events, and only the cannula-fill one carries a location. In the site-rotation list you'll see one entry with a site and one without, minutes apart. Say the word if you want to revisit that.

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.

1 participant