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 @@ -64,7 +64,7 @@ public List<MotherRecord> 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);
Comment on lines 66 to 69
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Verification agent

🧩 Analysis chain

Verify the business logic change for record filtering

The query modification adds filtering for isFurtherCallRequired field, excluding records where this flag is explicitly set to false. While the syntax is correct, please ensure:

  1. This business logic change is intended and documented
  2. All consumers of getRecordCount method are aware of this behavioral change
  3. This aligns with similar filtering in other repository methods

Run the following script to verify consistent filtering across related repositories:


🏁 Script executed:

#!/bin/bash
# Description: Check if similar isFurtherCallRequired filtering is applied consistently across other repository methods

# Search for other queries with isFurtherCallRequired conditions
rg -A 3 -B 3 "isFurtherCallRequired" --type java

# Search for other uses of getRecordCount to understand impact
ast-grep --pattern 'getRecordCount($$$)'

Length of output: 24457


Review update: Filter consistency verified
The added filter for isFurtherCallRequired in MotherRecordRepo#getRecordCount matches the same condition used throughout OutboundCallsRepo, so the technical change is correct.

Please address the following:

  • Document this business logic change (that records with isFurtherCallRequired = false are now excluded) in your API/repo documentation.
  • Communicate the updated behavior to all consumers of getRecordCount.

Affected location:

  • src/main/java/com/iemr/ecd/repo/call_conf_allocation/MotherRecordRepo.java (lines 66–69)
πŸ€– Prompt for AI Agents
In src/main/java/com/iemr/ecd/repo/call_conf_allocation/MotherRecordRepo.java
between lines 66 and 69, the query now filters records where
isFurtherCallRequired is true or null, excluding false values. This change
affects the business logic by omitting records with isFurtherCallRequired set to
false. Add documentation to clarify that getRecordCount now only counts records
with isFurtherCallRequired true or null, and ensure all consumers are aware of
this behavioral change to prevent misunderstandings.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Page<OutboundCalls> 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);

Expand All @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/iemr/ecd/utils/constants/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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 {
Expand All @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -39,7 +41,9 @@ public static HttpEntity<Object> 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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Fix inconsistent string literal usage.

Line 48 still uses a hardcoded string "Jwttoken=" instead of using the constant. For consistency with the refactoring effort, this should use the constant as well.

Apply this diff to maintain consistency:

-        	headers.add(HttpHeaders.COOKIE, "Jwttoken=" + jwtTokenFromCookie);
+        	headers.add(HttpHeaders.COOKIE, Constants.JWT_TOKEN + "=" + jwtTokenFromCookie);
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
headers.add(HttpHeaders.COOKIE, "Jwttoken=" + jwtTokenFromCookie);
headers.add(HttpHeaders.COOKIE, Constants.JWT_TOKEN + "=" + jwtTokenFromCookie);
πŸ€– Prompt for AI Agents
In src/main/java/com/iemr/ecd/utils/mapper/RestTemplateUtil.java at line 48,
replace the hardcoded string "Jwttoken=" with the appropriate constant defined
for this token to maintain consistency with the rest of the code. Identify the
constant representing the JWT token prefix and use it in the headers.add method
instead of the literal string.

}
Expand Down
Loading