diff --git a/src/main/java/com/iemr/ecd/repo/call_conf_allocation/MotherRecordRepo.java b/src/main/java/com/iemr/ecd/repo/call_conf_allocation/MotherRecordRepo.java index 784e8ac..22bde02 100644 --- a/src/main/java/com/iemr/ecd/repo/call_conf_allocation/MotherRecordRepo.java +++ b/src/main/java/com/iemr/ecd/repo/call_conf_allocation/MotherRecordRepo.java @@ -64,7 +64,7 @@ public List getMotherRecordForAllocation(@Param("fDate") Timestamp // get eligible introductory Records @Query(value = " SELECT COUNT(1) FROM MotherRecord as t WHERE t.isAllocated=:isAllocated AND " - + " t.createdDate >=:fDate AND t.createdDate <=:tDate AND t.whomPhoneNo=:whomPhoneNo ") + + " t.createdDate >=:fDate AND t.createdDate <=:tDate AND t.whomPhoneNo=:whomPhoneNo AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL ) ") public int getRecordCount(@Param("isAllocated") Boolean isAllocated, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("whomPhoneNo") String whomPhoneNo); diff --git a/src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java b/src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java index f992d36..f5a96f3 100644 --- a/src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java +++ b/src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java @@ -95,7 +95,7 @@ Page getChildRecordsForMO(Pageable pageable, @Param("allocationSt @Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t WHERE t.allocationStatus =:allocationStatus AND " + " t.psmId=:psmId AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND " + " t.childId IS NULL AND t.motherId IS NOT NULL AND (t.isHighRisk = false OR t.isHighRisk IS NULL ) " - + " AND t.phoneNumberType=:phoneNoType AND t.deleted = false ") + + " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL ) ") int getMotherUnAllocatedCountLR(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("phoneNoType") String phoneNoType); @@ -111,7 +111,7 @@ int getChildUnAllocatedCountLR(@Param("allocationStatus") String allocationStatu @Query(value = " SELECT count(1) FROM OutboundCalls AS t WHERE t.allocationStatus =:allocationStatus AND " + " t.psmId=:psmId AND " + " t.childId IS NULL AND t.motherId IS NOT NULL AND t.isHighRisk = true " - + " AND t.phoneNumberType=:phoneNoType AND t.deleted = false ") + + " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL )") int getMotherUnAllocatedCountHR(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId, @Param("phoneNoType") String phoneNoType); diff --git a/src/main/java/com/iemr/ecd/utils/constants/Constants.java b/src/main/java/com/iemr/ecd/utils/constants/Constants.java index 7b73728..57fed6b 100644 --- a/src/main/java/com/iemr/ecd/utils/constants/Constants.java +++ b/src/main/java/com/iemr/ecd/utils/constants/Constants.java @@ -16,6 +16,9 @@ public class Constants { public static final String T = "T"; public static final String FROM_DATE_TO_DATE_IS_NULL = "from date / to date is null"; public static final List REASONFORCALLNOTANSWERED = List.of("Invalid number","Out of service","Out of Reach","Switched off","No reply","Number busy","Call not connected"); +public static final String JWT_TOKEN = "Jwttoken"; +public static final String USER_AGENT = "User-Agent"; +public static final String OKHTTP = "okhttp"; private Constants() {} } diff --git a/src/main/java/com/iemr/ecd/utils/mapper/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/ecd/utils/mapper/JwtUserIdValidationFilter.java index abee182..3bc18ee 100644 --- a/src/main/java/com/iemr/ecd/utils/mapper/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/ecd/utils/mapper/JwtUserIdValidationFilter.java @@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import com.iemr.ecd.utils.constants.Constants; import com.iemr.ecd.utils.http_request_interceptor.AuthorizationHeaderRequestWrapper; import jakarta.servlet.Filter; @@ -51,7 +52,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } // Log headers for debugging - String jwtTokenFromHeader = request.getHeader("Jwttoken"); logger.info("JWT token from header: "); // Skip login and public endpoints @@ -68,7 +68,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo try { String jwtFromCookie = getJwtTokenFromCookies(request); - String jwtFromHeader = request.getHeader("JwtToken"); + String jwtFromHeader = request.getHeader(Constants.JWT_TOKEN); String authHeader = request.getHeader("Authorization"); if (jwtFromCookie != null) { @@ -88,7 +88,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo return; } } else { - String userAgent = request.getHeader("User-Agent"); + String userAgent = request.getHeader(Constants.USER_AGENT); logger.info("User-Agent: " + userAgent); if (userAgent != null && isMobileClient(userAgent) && authHeader != null) { try { @@ -113,13 +113,13 @@ private boolean isMobileClient(String userAgent) { if (userAgent == null) return false; userAgent = userAgent.toLowerCase(); - return userAgent.contains("okhttp"); + return userAgent.contains(Constants.OKHTTP); } private String getJwtTokenFromCookies(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { - if (cookie.getName().equals("Jwttoken")) { + if (cookie.getName().equalsIgnoreCase(Constants.JWT_TOKEN)) { return cookie.getValue(); } } diff --git a/src/main/java/com/iemr/ecd/utils/mapper/RestTemplateUtil.java b/src/main/java/com/iemr/ecd/utils/mapper/RestTemplateUtil.java index 90ac1ca..3f7bf5b 100644 --- a/src/main/java/com/iemr/ecd/utils/mapper/RestTemplateUtil.java +++ b/src/main/java/com/iemr/ecd/utils/mapper/RestTemplateUtil.java @@ -10,6 +10,8 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import com.iemr.ecd.utils.constants.Constants; + import jakarta.servlet.http.HttpServletRequest; public class RestTemplateUtil { @@ -39,7 +41,9 @@ public static HttpEntity createRequestEntity(Object body, String authori headers.add(HttpHeaders.USER_AGENT, UserAgentContext.getUserAgent()); } headers.add(HttpHeaders.AUTHORIZATION, authorization); - headers.add("JwtToken",requestHeader.getHeader("JwtToken")); + if(null != requestHeader.getHeader(Constants.JWT_TOKEN)) { + headers.add(Constants.JWT_TOKEN,requestHeader.getHeader(Constants.JWT_TOKEN)); + } if(null != jwtTokenFromCookie) { headers.add(HttpHeaders.COOKIE, "Jwttoken=" + jwtTokenFromCookie); }