Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public interface FacilityLoginRepo extends CrudRepository<AshaSupervisorMapping,

// ASHA login: get peers at same facility (ANM, CHO, etc.)
@Query(value = "SELECT DISTINCT usrm.UserID, u.FirstName, u.LastName, r.RoleName, "
+ "COALESCE(u.EmployeeID,'') AS employeeID "
+ "COALESCE(u.EmployeeID,'') AS employeeID, "
+ "COALESCE(u.ContactNo,'') AS mobile "
+ "FROM m_UserServiceRoleMapping usrm "
+ "JOIN m_User u ON u.UserID = usrm.UserID "
+ "JOIN m_Role r ON r.RoleID = usrm.RoleID "
Expand All @@ -69,7 +70,8 @@ List<Object[]> getPeersAtFacility(@Param("facilityIDs") List<Integer> facilityID
@Query(value = "SELECT DISTINCT u.UserID, u.FirstName, u.LastName, "
+ "COALESCE(u.EmployeeID,'') AS employeeID, "
+ "f.FacilityID, f.FacilityName, "
+ "COALESCE(ft.FacilityTypeName,'') AS facilityTypeName "
+ "COALESCE(ft.FacilityTypeName,'') AS facilityTypeName, "
+ "COALESCE(u.ContactNo,'') AS mobile "
+ "FROM asha_supervisor_mapping asm "
+ "JOIN m_User u ON u.UserID = asm.ashaUserID "
+ "JOIN m_facility f ON f.FacilityID = asm.facilityID "
Expand All @@ -82,7 +84,8 @@ List<Object[]> getPeersAtFacility(@Param("facilityIDs") List<Integer> facilityID
@Query(value = "SELECT DISTINCT u.UserID, u.FirstName, u.LastName, "
+ "COALESCE(u.EmployeeID,'') AS employeeID, "
+ "f.FacilityID, f.FacilityName, "
+ "COALESCE(ft.FacilityTypeName,'') AS facilityTypeName "
+ "COALESCE(ft.FacilityTypeName,'') AS facilityTypeName, "
+ "COALESCE(u.ContactNo,'') AS mobile "
+ "FROM m_UserServiceRoleMapping usrm "
+ "JOIN m_User u ON u.UserID = usrm.UserID "
+ "JOIN m_Role r ON r.RoleID = usrm.RoleID "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

// ==================== ASHA ====================

private void enrichAshaData(JSONObject result, Integer ashaUserID) {

Check failure on line 62 in src/main/java/com/iemr/common/service/users/AshaSupervisorLoginService.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZ4-kzrHBSDa9FlKRW5h&open=AZ4-kzrHBSDa9FlKRW5h&pullRequest=417
List<Integer> facilityIDs = facilityLoginRepo.getUserFacilityIDs(ashaUserID);
if (facilityIDs == null || facilityIDs.isEmpty())
return;
Expand All @@ -85,7 +85,7 @@
JSONObject supervisor = new JSONObject();
supervisor.put("userId", sRow[0]);
supervisor.put("fullName", fullName(sRow[1], sRow[2]));
supervisor.put("mobile", str(sRow[3]));

Check failure on line 88 in src/main/java/com/iemr/common/service/users/AshaSupervisorLoginService.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=PSMRI_Common-API&issues=AZ4-kzrHBSDa9FlKRW5g&open=AZ4-kzrHBSDa9FlKRW5g&pullRequest=417
supervisor.put("employeeId", str(sRow[4]).isEmpty() ? JSONObject.NULL : str(sRow[4]));
result.put("supervisor", supervisor);
} else {
Expand All @@ -102,6 +102,7 @@
peer.put("fullName", fullName(pRow[1], pRow[2]));
peer.put("role", str(pRow[3]));
peer.put("employeeId", str(pRow[4]).isEmpty() ? JSONObject.NULL : str(pRow[4]));
peer.put("mobile", str(pRow[5]).isEmpty() ? JSONObject.NULL : str(pRow[5]));
peers.put(peer);
}
}
Expand Down Expand Up @@ -193,6 +194,7 @@
asha.put("facilityId", row[4]);
asha.put("facilityName", str(row[5]));
asha.put("facilityType", str(row[6]));
asha.put("mobile", str(row[7]).isEmpty() ? JSONObject.NULL : str(row[7]));
list.put(asha);
}
return list;
Expand Down
Loading