fix: re-fetch PatientRoom from DB to fix stale session cache blocking admin discharge#21481
Conversation
BhtSummeryController is @SessionScoped, so patientEncounter.currentPatientRoom is a stale in-memory entity loaded at page-open time. After the user performs room discharge, the DB record is updated but the session-held Java object still has dischargedAt=null, causing the discharge() guard to block administrative discharge even when the room is fully discharged in the DB. Fix: call patientRoomFacade.find() to get a fresh PatientRoom before checking dischargedAt, bypassing the stale session-scoped reference. Closes #21480 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughIn ChangesDischarge Guard DB Re-fetch
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f23e613b08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…m FK Previous fix re-fetched the PatientRoom by the session-cached FK, but that FK itself can be stale when a room change happens after the Interim Bill page loads: RoomChangeController updates PatientEncounter.currentPatientRoom in the DB, but the session-scoped object still holds the old room reference. Checking the old room (which is already discharged) lets the guard pass while the new current room is still active. Fix: fetch a fresh PatientEncounter via patientEncounterFacade.find() to obtain the authoritative currentPatientRoom FK from the DB/L2 cache, then check that room's dischargedAt. This covers both the simple room-discharge-before-admin- discharge scenario and the room-change-then-admin-discharge scenario. Addresses Codex review comment on PR #21481. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
BhtSummeryControlleris@SessionScoped, sopatientEncounter.currentPatientRoomis a stale Java object loaded at page-open time — after room discharge updates the DB, the session-held reference still hasdischargedAt = nullpatientRoomFacade.find(currentRoom.getId())to re-fetch a freshPatientRoomfrom the database before the discharge guard checkCloses #21480
Test plan
roomChargesAllowed = true🤖 Generated with Claude Code
Summary by CodeRabbit