Skip to content

Fix: Discharge Duplicate Encounters groups by physical room, not assignment ID#19676

Merged
buddhika75 merged 1 commit intodevelopmentfrom
19675-fix-discharge-duplicate-encounters
Apr 3, 2026
Merged

Fix: Discharge Duplicate Encounters groups by physical room, not assignment ID#19676
buddhika75 merged 1 commit intodevelopmentfrom
19675-fix-discharge-duplicate-encounters

Conversation

@buddhika75
Copy link
Copy Markdown
Member

@buddhika75 buddhika75 commented Apr 2, 2026

Summary

  • dischargeOldDuplicateEncounters() was grouping by currentPatientRoom_id (PatientRoom assignment entity), causing it to treat each admission as a unique room even when multiple admissions targeted the same physical room
  • Fixed to join patientroom and group by roomFacilityCharge_id so only the latest encounter per physical room is kept

Test plan

  • Run Discharge Duplicate Encounters on admin_functions.xhtml
  • Click Clear JPA Shared Cache
  • Verify nurse/index.xhtml shows at most one entry per room (no duplicate room buttons)

Closes #19675

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced duplicate patient encounter discharge process to organize encounters by physical room location rather than assignment ID for improved accuracy in identifying and discharging old duplicate records.

The admin function was grouping by currentPatientRoom_id (PatientRoom
assignment entity ID). Each new admission creates a new PatientRoom
record, so multiple admissions to the same physical room had different
currentPatientRoom_id values and were all retained.

Fix: join the patientroom table and group by roomFacilityCharge_id
(the actual physical room) so only the latest encounter per room
is kept and all older ones are discharged.

Closes #19675

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 978d387d-0a1c-4ed5-92cb-c5d7bd889477

📥 Commits

Reviewing files that changed from the base of the PR and between 39b8169 and efc2013.

📒 Files selected for processing (1)
  • src/main/java/com/divudi/bean/common/DataAdministrationController.java

Walkthrough

The dischargeOldDuplicateEncounters() method's SQL query was modified to identify and discharge duplicate PatientEncounter records by physical room. The change joins the patientroom table and groups by roomFacilityCharge_id instead of currentPatientRoom_id, selecting the highest encounter ID to keep per room.

Changes

Cohort / File(s) Summary
Duplicate Encounter Discharge Logic
src/main/java/com/divudi/bean/common/DataAdministrationController.java
Updated bulk SQL query in dischargeOldDuplicateEncounters() to join patientroom table and group by roomFacilityCharge_id (physical room) instead of currentPatientRoom_id. Retains encounter with highest ID per room while marking duplicates for discharge.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: fixing the duplicate encounters discharge logic to group by physical room (roomFacilityCharge_id) instead of assignment ID (currentPatientRoom_id).
Linked Issues check ✅ Passed The code changes directly address all coding requirements from issue #19675: the query now joins patientroom table, groups by roomFacilityCharge_id, keeps MAX(pe.id) per room, and updates matching records via the joined table.
Out of Scope Changes check ✅ Passed All changes are within scope, limited to the dischargeOldDuplicateEncounters() SQL logic modification in DataAdministrationController to resolve the duplicate encounters issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 19675-fix-discharge-duplicate-encounters

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.0)
src/main/java/com/divudi/bean/common/DataAdministrationController.java

[]


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@buddhika75 buddhika75 merged commit a0c7e19 into development Apr 3, 2026
3 checks passed
@buddhika75 buddhika75 deleted the 19675-fix-discharge-duplicate-encounters branch April 3, 2026 00:01
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.

Fix: Discharge Duplicate Encounters admin function groups by wrong column

1 participant