Role Mapping Not Saving When Updating Multiple Roles (Registrar/Nurse/Counsellor) - #148
Conversation
…roles Two related bugs in the user-role-work-location mapping endpoints, both confirmed via live DB timestamp inspection against a real StopTB user with multiple roles (Registration Officer/Nurse/Counsellor). 1. UserRoleMappings() (POST userRoleMappings, create): the loop built one M_UserServiceRoleMapping2 object across all iterations of the per-role loop and only added it to the save list once, after the loop closed - so a batched request carrying multiple roles (e.g. Nurse + Counsellor together) silently discarded every role but the last one. Object creation and resList1.add() now happen once per role, inside the loop. 2. softDeleteOldMappings (called from updateUserRoleMapping): scoped only by userID + providerServiceMapID, so saving/updating ANY one role's mapping soft-deleted every OTHER active role that user held under the same service line, even roles never mentioned in that request and saved in a completely separate, earlier call. Added roleID to the WHERE clause (and threaded it through EmployeeMasterInter/EmployeeMasterServiceImpl/the controller call site) so it only cleans up true duplicates of the same role. Verified live: after this fix, a user's Registration Officer + Nurse + Counsellor mappings all stay simultaneously active across separate saves, with Registration Officer + Nurse created together in one batched call (matching CreatedDate) and Counsellor from an earlier save left untouched by later, unrelated saves. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|


📋 Description
JIRA ID: AMM-2471
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.