Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
3c2135e
Bulk registration
SauravBizbRolly Mar 4, 2025
23cccac
Bulk registration
SauravBizbRolly Mar 11, 2025
83f693e
Bulk registration
SauravBizbRolly Mar 13, 2025
8ae4c09
Merge pull request #69 from toarunmishra/bulk_registration
sushant-bizbrolly Mar 13, 2025
cdd7b2a
add userName and password in Bulk registration
SauravBizbRolly Mar 31, 2025
128c8f9
add userName and password in Bulk registration
SauravBizbRolly Jun 19, 2025
a069382
Merge pull request #88 from toarunmishra/bulk_registration
SauravBizbRolly Jun 19, 2025
3fd079a
Merge remote-tracking branch 'upstream/develop' into enhancement
SauravBizbRolly Jun 19, 2025
fcbc3da
Merge pull request #90 from toarunmishra/3.3.0
drtechie Jun 19, 2025
5cd719d
remove unwanted line
SauravBizbRolly Jun 19, 2025
2a55c54
Merge pull request #91 from toarunmishra/3.3.0
SauravBizbRolly Jun 19, 2025
110fa59
fix code
SauravBizbRolly Jun 21, 2025
83d3387
Merge pull request #92 from toarunmishra/3.3.0
SauravBizbRolly Jun 21, 2025
b1a893f
fix code
SauravBizbRolly Aug 21, 2025
b67332f
fix code
SauravBizbRolly Aug 21, 2025
bdde896
fix code
SauravBizbRolly Aug 21, 2025
5315e05
fix code
SauravBizbRolly Aug 21, 2025
486d412
fix code
SauravBizbRolly Aug 21, 2025
4e5dab6
fix code
SauravBizbRolly Aug 21, 2025
cd7f567
fix code
SauravBizbRolly Aug 21, 2025
f06d077
fix code
SauravBizbRolly Aug 28, 2025
84b679a
fix code
SauravBizbRolly Aug 28, 2025
7b123e9
fix code
SauravBizbRolly Aug 28, 2025
a28294f
fix code
SauravBizbRolly Aug 28, 2025
093ba26
fix code
SauravBizbRolly Aug 28, 2025
8820fe2
Httpheader content disposition changed
ravishanigarapu Sep 2, 2025
2aab70e
Coderabbitai comments adrressed
ravishanigarapu Sep 2, 2025
20eaaed
Httpheader content disposition changed (#100)
ravishanigarapu Sep 2, 2025
e04b9e5
Compile error resolved
ravishanigarapu Sep 2, 2025
bd11453
Merge pull request #101 from PSMRI/feature/signaturerelease
SauravBizbRolly Sep 2, 2025
0addca8
fix code
SauravBizbRolly Sep 2, 2025
b313e03
Merge remote-tracking branch 'upstream/release-3.6.0' into release-3.6.0
SauravBizbRolly Sep 2, 2025
adc946d
Main branch changes missed (#102)
ravishanigarapu Sep 2, 2025
4e3a304
Feature/signaturerelease (#103)
ravishanigarapu Sep 2, 2025
875e40a
Feature/signaturerelease (#104)
ravishanigarapu Sep 10, 2025
41162a4
Update pom.xml
5Amogh Sep 25, 2025
27241e1
Cherry-pick the commits related to 3.5.0 form 3.6.0 (#106)
snehar-nd Sep 26, 2025
8fb55ce
fix:casesheet signature
vishwab1 Oct 29, 2025
45250ea
fix:pom file change
vishwab1 Oct 30, 2025
c824879
API changes in Signature enhancement for Casesheet (#107)
vishwab1 Oct 30, 2025
7231794
fix: pom version
vishwab1 Oct 30, 2025
e763f9f
Merge pull request #108 from PSMRI/vb/sign
snehar-nd Oct 30, 2025
3d22060
fix code
SauravBizbRolly Nov 7, 2025
226c101
Merge remote-tracking branch 'upstream/release-3.6.0' into release-3.6.0
SauravBizbRolly Nov 7, 2025
74cd354
fix code
SauravBizbRolly Nov 10, 2025
f719ba5
fix code
SauravBizbRolly Nov 10, 2025
bb00223
fix code
SauravBizbRolly Nov 10, 2025
d52c950
fix code
SauravBizbRolly Nov 10, 2025
86ed8cb
fix code
SauravBizbRolly Nov 10, 2025
3ae6436
fix code
SauravBizbRolly Nov 10, 2025
67a4240
fix code
SauravBizbRolly Nov 10, 2025
f8e646e
fix code
SauravBizbRolly Nov 10, 2025
8c48069
fix code
SauravBizbRolly Nov 11, 2025
5f8dcf2
fix code
SauravBizbRolly Nov 11, 2025
30d3317
fix code
SauravBizbRolly Nov 11, 2025
6f5a101
fix code
SauravBizbRolly Nov 11, 2025
1d45257
Merge branch 'release-3.6.1' into release-3.6.0
5Amogh Nov 17, 2025
0acb505
Merge pull request #109 from PSMRI/release-3.6.0
5Amogh Nov 17, 2025
608773a
fix: amm-1927 send headers only if the request is from the allowed or…
5Amogh Nov 17, 2025
5a7c6bf
fix: amm-1927 coderabbit fixes
5Amogh Nov 17, 2025
ad6ff5e
Update regex handling for localhost URLs
5Amogh Nov 18, 2025
eb98a5a
Enhance regex pattern for URL matching
5Amogh Nov 18, 2025
bffa971
Merge pull request #110 from PSMRI/amm-1927
5Amogh Nov 20, 2025
c6ded08
Merge branch 'release-3.6.0' into release-3.5.0
5Amogh Dec 3, 2025
2a04bfb
Merge pull request #111 from PSMRI/release-3.5.0
5Amogh Dec 3, 2025
75d06ca
Merge pull request #112 from PSMRI/release-3.6.1
5Amogh Dec 3, 2025
b421d8b
fix code
SauravBizbRolly Dec 3, 2025
9c206a4
Merge remote-tracking branch 'upstream/release-3.6.0' into release-3.6.0
SauravBizbRolly Dec 3, 2025
76db67c
fix code
SauravBizbRolly Dec 3, 2025
d5b3e20
Merge branch 'main' into release-3.6.0
SauravBizbRolly Jan 14, 2026
711128e
fix vulnerabilitie code
SauravBizbRolly Jan 14, 2026
091bd75
Merge pull request #115 from PSMRI/fix/vulnerabilitie
SauravBizbRolly Jan 14, 2026
f76f68c
fix security hotspots
SauravBizbRolly Jan 14, 2026
a52081b
Merge pull request #116 from PSMRI/fix/remove_log
SauravBizbRolly Jan 14, 2026
ea22db4
fixed conflicts
vishwab1 Feb 27, 2026
68e4130
Add facility hierarchy creation with village and parent-child mapping…
vishwab1 Mar 2, 2026
c701ce9
fix: facility hierarchy and facility type management (#125)
vishwab1 Mar 18, 2026
7f10a54
Facility hierarchy inventory mapping and store field management (#128)
vishwab1 Mar 26, 2026
1c6a062
merge 3.6.2 to release 3.8.1 (#132)
vishwab1 May 21, 2026
e95a5c8
fix: merge to main
vanitha1822 May 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ mvnw.cmd
# Properties
src/main/environment/admin_local.properties

node_modules
node_modules

# Logs
logs/
163 changes: 0 additions & 163 deletions logs/admin-api.log.json

This file was deleted.

Binary file removed logs/admin-api.log.json.2025-06-13.gz
Binary file not shown.
Binary file added logs/admin-api.log.json.2026-02-26.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.iemr.admin</groupId>
<artifactId>admin-api</artifactId>
<version>3.6.1</version>
<version>3.8.1</version>
<packaging>war</packaging>
<name>Admin-API</name>
<description>Admin Page</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,7 @@ public class BulkRegistrationController {
public ResponseEntity<Map<String, Object>> registerBulkUser(@RequestBody String m_user, @RequestHeader String authorization, @RequestParam String userName,
HttpServletRequest request, @RequestParam Integer serviceProviderID
) {
String jwtToken = null;

Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
if ("jwt".equalsIgnoreCase(cookie.getName())) { // Cookie name == jwt
jwtToken = cookie.getValue();
break;
}
}
}

logger.info("JWT Token From Cookie: " + jwtToken);
logger.info("M_user Request: " + m_user);

String authHeader = request.getHeader("Authorization");
logger.info("Authorization Token: " + authHeader);

logger.info("M_user Request: " + m_user);
bulkRegistrationServiceimpl.bulkRegistrationErrors.clear();
logger.info("Bulk registration request received. Request payload is omitted from logs.");
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
package com.iemr.admin.controller.employeemaster;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.iemr.admin.data.employeemaster.AshaSupervisorMapping;
import com.iemr.admin.data.employeemaster.M_UserServiceRoleMapping2;
import com.iemr.admin.data.store.M_Facility;
import com.iemr.admin.repo.employeemaster.EmployeeMasterRepo;
import com.iemr.admin.repository.store.MainStoreRepo;
import com.iemr.admin.service.employeemaster.AshaSupervisorMappingService;
import com.iemr.admin.utils.mapper.InputMapper;
import com.iemr.admin.utils.response.OutputResponse;

import io.swagger.v3.oas.annotations.Operation;

@RestController
public class AshaSupervisorMappingController {

private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());

@Autowired
private AshaSupervisorMappingService ashaSupervisorMappingService;

@Autowired
private EmployeeMasterRepo employeeMasterRepo;

@Autowired
private MainStoreRepo mainStoreRepo;

@Operation(summary = "Get ASHA users by facility IDs")
@RequestMapping(value = "/userFacilityMapping/getAshasByFacility", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
public String getAshasByFacility(@RequestBody String request) {
OutputResponse response = new OutputResponse();
try {
AshaSupervisorMapping reqObj = InputMapper.gson().fromJson(request, AshaSupervisorMapping.class);
List<Integer> facilityIDs = reqObj.getFacilityIDs();
if (facilityIDs == null || facilityIDs.isEmpty()) {
if (reqObj.getFacilityID() != null) {

Check warning on line 70 in src/main/java/com/iemr/admin/controller/employeemaster/AshaSupervisorMappingController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this if statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5ORWuHqJQ-O8gW-0Tv&open=AZ5ORWuHqJQ-O8gW-0Tv&pullRequest=134
facilityIDs = Arrays.asList(reqObj.getFacilityID());
}
}
ArrayList<M_UserServiceRoleMapping2> ashaUsers = ashaSupervisorMappingService
.getAshasByFacility(facilityIDs);
response.setResponse(ashaUsers.toString());
} catch (Exception e) {
logger.error("Unexpected error:", e);

Check failure on line 78 in src/main/java/com/iemr/admin/controller/employeemaster/AshaSupervisorMappingController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Unexpected error:" 7 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5ORWuHqJQ-O8gW-0Tw&open=AZ5ORWuHqJQ-O8gW-0Tw&pullRequest=134
response.setError(e);
}
return response.toString();
}

@Operation(summary = "Save ASHA supervisor mappings")
@RequestMapping(value = "/userFacilityMapping/ashaSupervisorMapping/save", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
public String saveAshaSupervisorMapping(@RequestBody String request) {
OutputResponse response = new OutputResponse();
try {
AshaSupervisorMapping[] reqArray = InputMapper.gson().fromJson(request, AshaSupervisorMapping[].class);
List<AshaSupervisorMapping> mappings = Arrays.asList(reqArray);
ArrayList<AshaSupervisorMapping> savedMappings = ashaSupervisorMappingService
.saveAshaSupervisorMappings(mappings);
response.setResponse(savedMappings.toString());
} catch (Exception e) {
logger.error("Unexpected error:", e);
response.setError(e);
}
return response.toString();
}

@Operation(summary = "Get supervisor mappings by facility ID")
@RequestMapping(value = "/userFacilityMapping/ashaSupervisorMapping/getByFacility", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
public String getSupervisorMappingByFacility(@RequestBody String request) {
OutputResponse response = new OutputResponse();
try {
AshaSupervisorMapping reqObj = InputMapper.gson().fromJson(request, AshaSupervisorMapping.class);
ArrayList<AshaSupervisorMapping> mappings = ashaSupervisorMappingService
.getSupervisorMappingByFacility(reqObj.getFacilityID());
response.setResponse(mappings.toString());
} catch (Exception e) {
logger.error("Unexpected error:", e);
response.setError(e);
}
return response.toString();
}

@Operation(summary = "Delete ASHA supervisor mappings by supervisor and facility IDs")
@RequestMapping(value = "/userFacilityMapping/ashaSupervisorMapping/delete", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
public String deleteAshaSupervisorMapping(@RequestBody String request) {
OutputResponse response = new OutputResponse();
try {
AshaSupervisorMapping reqObj = InputMapper.gson().fromJson(request, AshaSupervisorMapping.class);
Integer supervisorUserID = reqObj.getSupervisorUserID();
List<Integer> facilityIDs = reqObj.getFacilityIDs();
if (supervisorUserID != null && facilityIDs != null && !facilityIDs.isEmpty()) {
ashaSupervisorMappingService.deleteBySupervisorAndFacilities(supervisorUserID, facilityIDs, "Admin");

Check failure on line 129 in src/main/java/com/iemr/admin/controller/employeemaster/AshaSupervisorMappingController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Admin" 3 times.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5ORWuHqJQ-O8gW-0Tx&open=AZ5ORWuHqJQ-O8gW-0Tx&pullRequest=134
response.setResponse("Deleted successfully");
} else {
response.setError(5000, "supervisorUserID and facilityIDs are required");
}
} catch (Exception e) {
logger.error("Unexpected error:", e);
response.setError(e);
}
return response.toString();
}

@Operation(summary = "Atomically delete old and save new ASHA supervisor mappings (Fix 7)")
@RequestMapping(value = "/userFacilityMapping/ashaSupervisorMapping/updateAtomically", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
public String updateAshaSupervisorMappingAtomically(@RequestBody String request) {
OutputResponse response = new OutputResponse();
try {
com.google.gson.JsonObject reqObj = InputMapper.gson().fromJson(request, com.google.gson.JsonObject.class);
Integer supervisorUserID = reqObj.get("supervisorUserID").getAsInt();
String modifiedBy = reqObj.has("modifiedBy") ? reqObj.get("modifiedBy").getAsString() : "Admin";
List<Integer> facilityIDs = new ArrayList<>();
if (reqObj.has("facilityIDs")) {
for (com.google.gson.JsonElement el : reqObj.getAsJsonArray("facilityIDs")) {
facilityIDs.add(el.getAsInt());
}
}
List<AshaSupervisorMapping> newMappings = new ArrayList<>();
if (reqObj.has("newMappings")) {
AshaSupervisorMapping[] arr = InputMapper.gson().fromJson(
reqObj.getAsJsonArray("newMappings").toString(), AshaSupervisorMapping[].class);
newMappings = Arrays.asList(arr);
}
ArrayList<AshaSupervisorMapping> saved = ashaSupervisorMappingService
.updateAshaMappingsAtomically(supervisorUserID, facilityIDs, newMappings, modifiedBy);
response.setResponse(saved.toString());
} catch (Exception e) {
logger.error("Unexpected error:", e);
response.setError(e);
}
return response.toString();
}

@Operation(summary = "Restore soft-deleted ASHA supervisor mappings by IDs")
@RequestMapping(value = "/userFacilityMapping/ashaSupervisorMapping/restore", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
public String restoreAshaSupervisorMapping(@RequestBody String request) {
OutputResponse response = new OutputResponse();
try {
AshaSupervisorMapping reqObj = InputMapper.gson().fromJson(request, AshaSupervisorMapping.class);
List<Long> ids = reqObj.getIds();
if (ids != null && !ids.isEmpty()) {
ashaSupervisorMappingService.restoreMappings(ids, "Admin");
response.setResponse("Restored successfully");
} else {
response.setError(5000, "ids are required");
}
} catch (Exception e) {
logger.error("Unexpected error:", e);
response.setError(e);
}
return response.toString();
}

@Operation(summary = "Get facility details by USR mapping ID")
@RequestMapping(value = "/userFacilityMapping/getFacilityByMappingID", headers = "Authorization", method = {
RequestMethod.POST }, produces = { "application/json" })
public String getFacilityByMappingID(@RequestBody String request) {

Check failure on line 196 in src/main/java/com/iemr/admin/controller/employeemaster/AshaSupervisorMappingController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_Admin-API&issues=AZ5ORWuHqJQ-O8gW-0Ty&open=AZ5ORWuHqJQ-O8gW-0Ty&pullRequest=134
OutputResponse response = new OutputResponse();
try {
M_UserServiceRoleMapping2 reqObj = InputMapper.gson().fromJson(request, M_UserServiceRoleMapping2.class);
Integer mappingID = reqObj.getuSRMappingID();
if (mappingID != null) {
M_UserServiceRoleMapping2 mapping = employeeMasterRepo.findById(mappingID).orElse(null);
// Skip if mapping is soft-deleted or has no facility
if (mapping != null && Boolean.TRUE.equals(mapping.getDeleted())) {
mapping = null;
}
if (mapping != null && mapping.getFacilityID() != null) {
// Use deleted filter to exclude soft-deleted facilities
M_Facility facility = mainStoreRepo.findByFacilityIDAndDeleted(mapping.getFacilityID(), false);
StringBuilder json = new StringBuilder("{");
json.append("\"facilityID\": ").append(mapping.getFacilityID());
if (facility != null) {
json.append(", \"facilityName\": \"").append(facility.getFacilityName() != null ? facility.getFacilityName() : "").append("\"");
json.append(", \"facilityTypeID\": ").append(facility.getFacilityTypeID());
json.append(", \"ruralUrban\": \"").append(facility.getRuralUrban() != null ? facility.getRuralUrban() : "").append("\"");
} else {
// Facility was deleted β€” return null so frontend knows
json = new StringBuilder("{\"facilityID\": null, \"facilityDeleted\": true");
}
json.append("}");
response.setResponse(json.toString());
} else {
response.setResponse("{\"facilityID\": null}");
}
} else {
response.setResponse("{\"facilityID\": null}");
}
} catch (Exception e) {
logger.error("Unexpected error:", e);
response.setError(e);
}
return response.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1804,12 +1804,15 @@ public String UserRoleMappings(@RequestBody String userRoleMapping, HttpServletR
resDataMap1.setUserID(employeeMaster.get(x).getUserID());
resDataMap1.setProviderServiceMapID(previl.getProviderServiceMapID());
resDataMap1.setWorkingLocationID(previl.getWorkingLocationID());
resDataMap1.setStateID(previl.getStateID());
resDataMap1.setDistrictID(previl.getDistrictID());
resDataMap1.setCreatedBy(employeeMaster.get(x).getCreatedBy());
resDataMap1.setServiceProviderID(employeeMaster.get(x).getServiceProviderID());
resDataMap1.setBlockID(previl.getBlockID());
resDataMap1.setBlockName(previl.getBlockName());
resDataMap1.setVillageID(previl.getVillageID());
resDataMap1.setVillageName(previl.getVillageName());
resDataMap1.setFacilityID(previl.getFacilityID());
resList1.add(resDataMap1);

}
Expand Down Expand Up @@ -1845,16 +1848,32 @@ public String updateUserRoleMapping(@RequestBody String updateUserRoleMapping, H

M_UserServiceRoleMapping2 usrRole = employeeMasterInter.getDataUsrId(pre.getuSRMappingID());

// Fix 1/3: cascade asha_supervisor_mapping BEFORE modifying entity to avoid JPA L1 cache issue
if (usrRole != null && usrRole.getUserID() != null) {
boolean roleChanged = pre.getRoleID() != null && usrRole.getRoleID() != null
&& !usrRole.getRoleID().equals(pre.getRoleID());
boolean facilityChanged = usrRole.getFacilityID() != null && pre.getFacilityID() != null
&& !usrRole.getFacilityID().equals(pre.getFacilityID());
if (roleChanged || facilityChanged) {
logger.info("Fix1/3: cascading asha_supervisor_mapping for userID={}, roleChanged={}, facilityChanged={}",
usrRole.getUserID(), roleChanged, facilityChanged);
employeeMasterInter.cascadeDeleteAshaMappingsForUser(usrRole.getUserID());
}
}

usrRole.setUserID(pre.getUserID());
usrRole.setRoleID(pre.getRoleID());
usrRole.setAgentPassword(pre.getAgentPassword());
usrRole.setProviderServiceMapID(pre.getProviderServiceMapID());
usrRole.setWorkingLocationID(pre.getWorkingLocationID());
usrRole.setStateID(pre.getStateID());
usrRole.setDistrictID(pre.getDistrictID());
usrRole.setModifiedBy(pre.getModifiedBy());
usrRole.setBlockID(pre.getBlockID());
usrRole.setBlockName(pre.getBlockName());
usrRole.setVillageID(pre.getVillageID());
usrRole.setVillageName(pre.getVillageName());
usrRole.setFacilityID(pre.getFacilityID());

if (pre.getTeleConsultation() != null) {
usrRole.setTeleConsultation(pre.getTeleConsultation());
Expand Down Expand Up @@ -1897,6 +1916,17 @@ public String deleteUserRoleMapping(@RequestBody String deletedUserRoleMapping,

M_UserServiceRoleMapping2 usrRole = employeeMasterInter.getDataUsrId(pre.getuSRMappingID());

// Fix 2: cascade asha_supervisor_mapping BEFORE setDeleted() to avoid JPA L1 cache issue.
// After setDeleted(true), findById() in saveRoleMappingeditedData hits the L1 cache
// returning the already-modified entity, so the "old vs new deleted" check always fails.
// For ASHA Supervisor with multiple facilities: only delete mappings for this facilityID
if (Boolean.TRUE.equals(pre.getDeleted()) && !Boolean.TRUE.equals(usrRole.getDeleted())
&& usrRole.getUserID() != null) {
logger.info("Fix2: cascading asha_supervisor_mapping soft-delete for userID={}, uSRMappingID={}",
usrRole.getUserID(), pre.getuSRMappingID());
employeeMasterInter.cascadeDeleteAshaMappingsForDeactivation(usrRole);
}

usrRole.setDeleted(pre.getDeleted());

M_UserServiceRoleMapping2 savedata = employeeMasterInter.saveRoleMappingeditedData(usrRole,
Expand Down
Loading
Loading