Skip to content

Commit 320389c

Browse files
Constants added and null check (#77)
* Constants added and null check * Allacation count mismatch
1 parent 19c2552 commit 320389c

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/main/java/com/iemr/ecd/repo/call_conf_allocation/MotherRecordRepo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public List<MotherRecord> getMotherRecordForAllocation(@Param("fDate") Timestamp
6464

6565
// get eligible introductory Records
6666
@Query(value = " SELECT COUNT(1) FROM MotherRecord as t WHERE t.isAllocated=:isAllocated AND "
67-
+ " t.createdDate >=:fDate AND t.createdDate <=:tDate AND t.whomPhoneNo=:whomPhoneNo ")
67+
+ " t.createdDate >=:fDate AND t.createdDate <=:tDate AND t.whomPhoneNo=:whomPhoneNo AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL ) ")
6868
public int getRecordCount(@Param("isAllocated") Boolean isAllocated, @Param("fDate") Timestamp fDate,
6969
@Param("tDate") Timestamp tDate, @Param("whomPhoneNo") String whomPhoneNo);
7070

src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Page<OutboundCalls> getChildRecordsForMO(Pageable pageable, @Param("allocationSt
9595
@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t WHERE t.allocationStatus =:allocationStatus AND "
9696
+ " t.psmId=:psmId AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND "
9797
+ " t.childId IS NULL AND t.motherId IS NOT NULL AND (t.isHighRisk = false OR t.isHighRisk IS NULL ) "
98-
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false ")
98+
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL ) ")
9999
int getMotherUnAllocatedCountLR(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId,
100100
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("phoneNoType") String phoneNoType);
101101

@@ -111,7 +111,7 @@ int getChildUnAllocatedCountLR(@Param("allocationStatus") String allocationStatu
111111
@Query(value = " SELECT count(1) FROM OutboundCalls AS t WHERE t.allocationStatus =:allocationStatus AND "
112112
+ " t.psmId=:psmId AND "
113113
+ " t.childId IS NULL AND t.motherId IS NOT NULL AND t.isHighRisk = true "
114-
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false ")
114+
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL )")
115115
int getMotherUnAllocatedCountHR(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId,
116116
@Param("phoneNoType") String phoneNoType);
117117

src/main/java/com/iemr/ecd/utils/constants/Constants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public class Constants {
1616
public static final String T = "T";
1717
public static final String FROM_DATE_TO_DATE_IS_NULL = "from date / to date is null";
1818
public static final List<String> REASONFORCALLNOTANSWERED = List.of("Invalid number","Out of service","Out of Reach","Switched off","No reply","Number busy","Call not connected");
19+
public static final String JWT_TOKEN = "Jwttoken";
20+
public static final String USER_AGENT = "User-Agent";
21+
public static final String OKHTTP = "okhttp";
1922

2023
private Constants() {}
2124
}

src/main/java/com/iemr/ecd/utils/mapper/JwtUserIdValidationFilter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.slf4j.LoggerFactory;
77
import org.springframework.stereotype.Component;
88

9+
import com.iemr.ecd.utils.constants.Constants;
910
import com.iemr.ecd.utils.http_request_interceptor.AuthorizationHeaderRequestWrapper;
1011

1112
import jakarta.servlet.Filter;
@@ -51,7 +52,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
5152
}
5253

5354
// Log headers for debugging
54-
String jwtTokenFromHeader = request.getHeader("Jwttoken");
5555
logger.info("JWT token from header: ");
5656

5757
// Skip login and public endpoints
@@ -68,7 +68,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
6868

6969
try {
7070
String jwtFromCookie = getJwtTokenFromCookies(request);
71-
String jwtFromHeader = request.getHeader("JwtToken");
71+
String jwtFromHeader = request.getHeader(Constants.JWT_TOKEN);
7272
String authHeader = request.getHeader("Authorization");
7373

7474
if (jwtFromCookie != null) {
@@ -88,7 +88,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
8888
return;
8989
}
9090
} else {
91-
String userAgent = request.getHeader("User-Agent");
91+
String userAgent = request.getHeader(Constants.USER_AGENT);
9292
logger.info("User-Agent: " + userAgent);
9393
if (userAgent != null && isMobileClient(userAgent) && authHeader != null) {
9494
try {
@@ -113,13 +113,13 @@ private boolean isMobileClient(String userAgent) {
113113
if (userAgent == null)
114114
return false;
115115
userAgent = userAgent.toLowerCase();
116-
return userAgent.contains("okhttp");
116+
return userAgent.contains(Constants.OKHTTP);
117117
}
118118
private String getJwtTokenFromCookies(HttpServletRequest request) {
119119
Cookie[] cookies = request.getCookies();
120120
if (cookies != null) {
121121
for (Cookie cookie : cookies) {
122-
if (cookie.getName().equals("Jwttoken")) {
122+
if (cookie.getName().equalsIgnoreCase(Constants.JWT_TOKEN)) {
123123
return cookie.getValue();
124124
}
125125
}

src/main/java/com/iemr/ecd/utils/mapper/RestTemplateUtil.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import org.springframework.web.context.request.RequestContextHolder;
1111
import org.springframework.web.context.request.ServletRequestAttributes;
1212

13+
import com.iemr.ecd.utils.constants.Constants;
14+
1315
import jakarta.servlet.http.HttpServletRequest;
1416

1517
public class RestTemplateUtil {
@@ -39,7 +41,9 @@ public static HttpEntity<Object> createRequestEntity(Object body, String authori
3941
headers.add(HttpHeaders.USER_AGENT, UserAgentContext.getUserAgent());
4042
}
4143
headers.add(HttpHeaders.AUTHORIZATION, authorization);
42-
headers.add("JwtToken",requestHeader.getHeader("JwtToken"));
44+
if(null != requestHeader.getHeader(Constants.JWT_TOKEN)) {
45+
headers.add(Constants.JWT_TOKEN,requestHeader.getHeader(Constants.JWT_TOKEN));
46+
}
4347
if(null != jwtTokenFromCookie) {
4448
headers.add(HttpHeaders.COOKIE, "Jwttoken=" + jwtTokenFromCookie);
4549
}

0 commit comments

Comments
 (0)