Skip to content

Conversation

@ravishanigarapu
Copy link
Contributor

@ravishanigarapu ravishanigarapu commented May 28, 2025

πŸ“‹ Description

JIRA ID:

Please provide a summary of the change and the motivation behind it. Include relevant context and details.


βœ… Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • πŸ”₯ Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • πŸ›  Refactor (change that is neither a fix nor a new feature)
  • βš™οΈ Config change (configuration file or build script updates)
  • πŸ“š Documentation (updates to docs or readme)
  • πŸ§ͺ Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • πŸš€ Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.

Summary by CodeRabbit

  • New Features

    • Enhanced filtering of eligible call records by user role, allowing more tailored data retrieval for different user types.
    • Introduced the ability to distinguish between introductory and low-risk call types when viewing or counting records.
  • Bug Fixes

    • Improved validation for required fields when fetching eligible records to prevent incomplete data retrieval.

@coderabbitai
Copy link

coderabbitai bot commented May 28, 2025

Walkthrough

The changes introduce a role parameter to the eligible records language info retrieval flow, affecting the controller, service, and repository layers. Repository queries are split and updated to filter by the displayEcdCallType field, distinguishing between 'introductory' and other call types. The service now applies role-based logic for count retrieval.

Changes

File(s) Change Summary
.../controller/callallocation/CallAllocationController.java Updated controller method to accept a new role path variable and pass it to the service layer.
.../service/call_conf_allocation/CallAllocationImpl.java Modified service method to accept role, and added branching logic to fetch counts based on both role and type.
.../repo/call_conf_allocation/OutboundCallsRepo.java Updated and added repository methods to filter queries by displayEcdCallType, splitting logic for call types.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller
    participant Service
    participant Repository

    Client->>Controller: getEligibleRecordsLanguageInfo(psmId, ..., role)
    Controller->>Service: getEligibleRecordsLanguageInfo(psmId, ..., role)
    alt role == "ANM" and recordType == "MOTHER"/"CHILD"
        Service->>Repository: getMother/ChildUnAllocatedCountLRByLanguage(...)
        Service-->>Controller: Return count
    else role == "ASSOCIATE" and recordType == "MOTHER"/"CHILD"
        Service->>Repository: getMother/ChildUnAllocatedCountIntroductoryByLanguage(...)
        Service-->>Controller: Return count
    else
        Service-->>Controller: Return null
    end
    Controller-->>Client: Response
Loading

Possibly related PRs

Suggested reviewers

  • devikasuresh20
  • helenKaryamsetty

Poem

A hop and a skip, a role in the code,
Now "ANM" and "ASSOCIATE" each have their road.
Introductory calls, or low-risk in view,
The queries now filter, the counts are all new.
πŸ‡ With logic divided, the records alignβ€”
This rabbit approves of your method design!

✨ Finishing Touches
  • πŸ“ Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

πŸ”­ Outside diff range comments (1)
src/main/java/com/iemr/ecd/controller/callallocation/CallAllocationController.java (1)

145-158: ⚠️ Potential issue

Critical issue: Missing role parameter in URL mapping.

The method signature on line 156 expects role as a @PathVariable, but the URL mapping on line 145 doesn't include {role} in the path. This will cause a runtime exception when the endpoint is called.

Apply this fix to the URL mapping:

-@GetMapping(value = "/getEligibleRecordsLanguageInfo/{psmId}/{phoneNoType}/{recordType}/{fDate}/{tDate}/{preferredLanguage}", produces = MediaType.APPLICATION_JSON_VALUE)
+@GetMapping(value = "/getEligibleRecordsLanguageInfo/{psmId}/{phoneNoType}/{recordType}/{fDate}/{tDate}/{preferredLanguage}/{role}", produces = MediaType.APPLICATION_JSON_VALUE)
πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between d474810 and 2bef6ee.

πŸ“’ Files selected for processing (3)
  • src/main/java/com/iemr/ecd/controller/callallocation/CallAllocationController.java (1 hunks)
  • src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java (3 hunks)
  • src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java (1)
src/main/java/com/iemr/ecd/utils/constants/Constants.java (1)
  • Constants (5-24)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (java)
πŸ”‡ Additional comments (4)
src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java (4)

69-72: Good implementation of call type filtering.

The query modification correctly adds filtering by displayEcdCallType = 'introductory' for associate role records. This properly separates introductory calls from other call types.


357-363: Well-designed separation of concerns for introductory call counts.

The new method getMotherUnAllocatedCountIntroductoryByLanguage provides a clean separation between introductory and non-introductory call counting, supporting the role-based logic in the service layer.


375-381: Consistent implementation across mother and child record types.

The child record introductory count method follows the same pattern as the mother record method, ensuring consistency across the codebase.


352-353:

Details

❓ Verification inconclusive

Verify the impact of excluding introductory calls on existing functionality.

The existing methods getMotherUnAllocatedCountLRByLanguage and getChildUnAllocatedCountLRByLanguage now exclude introductory calls with the condition t.displayEcdCallType != 'introductory'. Ensure this change doesn't break existing functionality that might depend on the previous behavior.

Also applies to: 369-370


🏁 Script executed:

#!/bin/bash
# Search for existing usages of these modified methods to assess impact
echo "Searching for usages of getMotherUnAllocatedCountLRByLanguage:"
rg "getMotherUnAllocatedCountLRByLanguage" -A 3 -B 3

echo -e "\nSearching for usages of getChildUnAllocatedCountLRByLanguage:"
rg "getChildUnAllocatedCountLRByLanguage" -A 3 -B 3

Length of output: 4887


Validate exclusion of β€˜introductory’ calls

We’ve confirmed that both getMotherUnAllocatedCountLRByLanguage and getChildUnAllocatedCountLRByLanguage are only invoked in CallAllocationImpl.java to set the low-risk call counts:

  • src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java
    β€’ Line where getMotherUnAllocatedCountLRByLanguage(...) is called
  • src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java
    β€’ Line where getChildUnAllocatedCountLRByLanguage(...) is called

Please verify that excluding calls with t.displayEcdCallType = 'introductory' aligns with business requirements and doesn’t inadvertently drop valid records in these use cases.

throw new ECDException(e);
}

return null;
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Remove unreachable null return statement.

With the suggested exception handling above, this null return becomes unreachable and should be removed.

		} catch (Exception e) {
			throw new ECDException(e);
		}
-		return null;
	}
πŸ“ 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
return null;
} catch (Exception e) {
throw new ECDException(e);
}
}
πŸ€– Prompt for AI Agents
In
src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java
at line 1105, remove the return null statement because with the updated
exception handling it is unreachable and unnecessary.

Comment on lines +1057 to +1058
public ResponseEligibleCallRecordsDTO getEligibleRecordsLanguageInfo(int psmId, String phoneNoType,
String recordType, String fDate, String tDate, String preferredLanguage, String role) {
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Add input validation for the role parameter.

The method should validate that the role parameter is not null or empty before proceeding with the logic.

Add validation at the beginning of the method:

public ResponseEligibleCallRecordsDTO getEligibleRecordsLanguageInfo(int psmId, String phoneNoType,
		String recordType, String fDate, String tDate, String preferredLanguage, String role) {
	try {
+		if (role == null || role.trim().isEmpty()) {
+			throw new InvalidRequestException("role is required");
+		}
		if (preferredLanguage == null || preferredLanguage.trim().isEmpty()) {
			throw new InvalidRequestException("preferred language is required");
		}
πŸ“ 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
public ResponseEligibleCallRecordsDTO getEligibleRecordsLanguageInfo(int psmId, String phoneNoType,
String recordType, String fDate, String tDate, String preferredLanguage, String role) {
public ResponseEligibleCallRecordsDTO getEligibleRecordsLanguageInfo(int psmId, String phoneNoType,
String recordType, String fDate, String tDate, String preferredLanguage, String role) {
try {
if (role == null || role.trim().isEmpty()) {
throw new InvalidRequestException("role is required");
}
if (preferredLanguage == null || preferredLanguage.trim().isEmpty()) {
throw new InvalidRequestException("preferred language is required");
}
// ... rest of existing logic ...
} catch (Exception e) {
// existing exception handling
}
}
πŸ€– Prompt for AI Agents
In
src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java
around lines 1057 to 1058, add input validation for the role parameter by
checking if it is null or empty at the start of the
getEligibleRecordsLanguageInfo method. If the role is invalid, handle it
appropriately, such as returning an error response or throwing an exception,
before proceeding with the rest of the method logic.

Comment on lines +1076 to 1100
if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)
&& role.equalsIgnoreCase(Constants.ANM)) {
totalLowRisk = outboundCallsRepo.getMotherUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId,
tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
&& role.equalsIgnoreCase(Constants.ANM)) {
totalLowRisk = outboundCallsRepo.getChildUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId,
tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)
&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
totalIntroductoryCount = outboundCallsRepo.getMotherUnAllocatedCountIntroductoryByLanguage(
Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
totalIntroductoryCount = outboundCallsRepo.getChildUnAllocatedCountIntroductoryByLanguage(
Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
return responseEligibleCallRecordsDTO;
}
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Improve error handling for unsupported role and record type combinations.

The method returns null for unsupported role and record type combinations, which could lead to unexpected behavior. Consider throwing a descriptive exception instead.

Replace the implicit null return with explicit exception handling:

		} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
				&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
			totalIntroductoryCount = outboundCallsRepo.getChildUnAllocatedCountIntroductoryByLanguage(
					Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
			responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
			return responseEligibleCallRecordsDTO;
+		} else {
+			throw new InvalidRequestException("Unsupported combination of role '" + role + "' and recordType '" + recordType + "'");
		}
-
πŸ“ 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
if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)
&& role.equalsIgnoreCase(Constants.ANM)) {
totalLowRisk = outboundCallsRepo.getMotherUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId,
tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
&& role.equalsIgnoreCase(Constants.ANM)) {
totalLowRisk = outboundCallsRepo.getChildUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId,
tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)
&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
totalIntroductoryCount = outboundCallsRepo.getMotherUnAllocatedCountIntroductoryByLanguage(
Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
totalIntroductoryCount = outboundCallsRepo.getChildUnAllocatedCountIntroductoryByLanguage(
Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
return responseEligibleCallRecordsDTO;
}
if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)
&& role.equalsIgnoreCase(Constants.ANM)) {
totalLowRisk = outboundCallsRepo.getMotherUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId,
tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
&& role.equalsIgnoreCase(Constants.ANM)) {
totalLowRisk = outboundCallsRepo.getChildUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId,
tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)
&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
totalIntroductoryCount = outboundCallsRepo.getMotherUnAllocatedCountIntroductoryByLanguage(
Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
return responseEligibleCallRecordsDTO;
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
totalIntroductoryCount = outboundCallsRepo.getChildUnAllocatedCountIntroductoryByLanguage(
Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
return responseEligibleCallRecordsDTO;
} else {
throw new InvalidRequestException(
"Unsupported combination of role '" + role + "' and recordType '" + recordType + "'");
}
πŸ€– Prompt for AI Agents
In
src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java
around lines 1076 to 1100, the method currently returns null for unsupported
combinations of role and recordType, which can cause unexpected behavior. To fix
this, add explicit error handling by throwing a descriptive exception when the
role and recordType combination is not supported, instead of returning null.
This will make the method's behavior clearer and safer.

@devikasuresh20 devikasuresh20 merged commit b574751 into PSMRI:develop May 28, 2025
7 checks passed
This was referenced May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants