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
21 changes: 21 additions & 0 deletions src/main/java/com/iemr/flw/domain/iemr/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ public class User {
@Column(name = "ServiceProviderID")
private Integer serviceProviderID;

@Expose
@Column(name = "gamificationEnabled")
private Boolean gamificationEnabled;

@Expose
@Column(name = "badgesMechanics")
private Boolean badgesMechanics;

@Expose
@Column(name = "monthlyRecapMechanics")
private Boolean monthlyRecapMechanics;

@Expose
@Column(name = "eveningNotifications")
private Boolean eveningNotifications;

@Expose
@Column(name = "consistencyDashboard")
private Boolean consistencyDashboard;


@Expose
@Column(name = "failed_attempt", insertable = false)
private Integer failedAttempt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class UserServiceRoleDTO {
private String villageId;
private String villageName;
private Map<String, Object> facilityData;
private Map<String,Object> gamification;

// Stop TB / Nikshay location scope β€” populated only when serviceName = "Stop TB".
// Set via setters after construction (additive, not part of the base constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ public String saveAllAssessment(UserDataDTO<HRNonPregnantAssessDTO> requestDTO)
requestDTO.getEntries().forEach(dto ->
{
NonPregnantWomanHighRiskAssess assess = assessRepo
.getByUserIdAndBenId(modelMapper.map(dto, HRPregnantAssessDTO.class).getBenId()
.getByUserIdAndBenId(modelMapper.map(dto, HRNonPregnantAssessDTO.class).getBenId()
, requestDTO.getUserId());


if (assess == null) {
assess = new NonPregnantWomanHighRiskAssess();
modelMapper.map(dto, assess);
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/iemr/flw/service/impl/UserServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.iemr.flw.service.impl;

import com.iemr.flw.domain.iemr.User;
import com.iemr.flw.dto.iemr.UserServiceRoleDTO;
import com.iemr.flw.repo.iemr.EmployeeMasterRepo;
import com.iemr.flw.repo.iemr.UserServiceRoleRepo;
import com.iemr.flw.service.UserService;
import org.slf4j.Logger;
Expand All @@ -23,7 +25,10 @@
@Autowired
private UserServiceRoleRepo userServiceRoleRepo;

@Autowired
private EmployeeMasterRepo employeeMasterRepo;

@Autowired

Check warning on line 31 in src/main/java/com/iemr/flw/service/impl/UserServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this field injection and use constructor injection instead.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-API&issues=AaIH9wfwD4SnkBGa-djR&open=AaIH9wfwD4SnkBGa-djR&pullRequest=416
private FacilityDataService facilityDataService;

public UserServiceRoleDTO getUserDetail(Integer userId) {
Expand All @@ -38,6 +43,7 @@
UserServiceRoleDTO userRole = primaryRole(userId, roles);
mergeVillages(userRole, roles);
userRole.setFacilityData(facilityDataService.buildFacilityData(userId, userRole.getRoleName()));
userRole.setGamification(getGamification(userId));

// Two different villages can legitimately share the same name (confirmed live:
// Nikshay village IDs 275135 and 275136 are both named "Sanapindapadar", under
Expand Down Expand Up @@ -111,6 +117,37 @@
return userRole;
}


private Map<String, Object> getGamification(Integer userID) {
User user = employeeMasterRepo.findUserByUserID(userID);

if (user == null) {
new RuntimeException("User not found") ;

Check warning on line 125 in src/main/java/com/iemr/flw/service/impl/UserServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Throw this exception or remove this useless statement.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-API&issues=AaIH9wfwD4SnkBGa-djS&open=AaIH9wfwD4SnkBGa-djS&pullRequest=416
}

Map<String, Object> gamification = new HashMap<>();
Map<String, Object> mechanics = new HashMap<>();

gamification.put("enabled",
user != null && Boolean.TRUE.equals(user.getGamificationEnabled()));

mechanics.put("badges",
user != null && Boolean.TRUE.equals(user.getBadgesMechanics()));

mechanics.put("monthlyRecap",
user != null && Boolean.TRUE.equals(user.getMonthlyRecapMechanics()));

mechanics.put("eveningNotifications",
user != null && Boolean.TRUE.equals(user.getEveningNotifications()));

mechanics.put("consistencyDashboard",
user != null && Boolean.TRUE.equals(user.getConsistencyDashboard()));

gamification.put("mechanics", mechanics);

return gamification;
}

private UserServiceRoleDTO primaryRole(Integer userId, List<UserServiceRoleDTO> roles) {
if (roles.size() == 1) return roles.get(0);
for (UserServiceRoleDTO role : roles) {
Expand Down
Loading