Skip to content

If call disconnected call status open - #82

Merged
helenKaryamsetty merged 1 commit into
PSMRI:developfrom
ravishanigarapu:develop
May 26, 2025
Merged

If call disconnected call status open#82
helenKaryamsetty merged 1 commit into
PSMRI:developfrom
ravishanigarapu:develop

Conversation

@ravishanigarapu

@ravishanigarapu ravishanigarapu commented May 26, 2025

Copy link
Copy Markdown
Contributor

📋 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

  • Bug Fixes
    • Improved handling of call closure for introductory calls, ensuring correct status updates and allocation behavior, especially when preferred language is specified or language mapping is missing.
  • Style
    • Enhanced code readability with minor formatting adjustments.

@coderabbitai

coderabbitai Bot commented May 26, 2025

Copy link
Copy Markdown

Walkthrough

The closeCall method in CallClosureImpl.java was updated to refine the logic for handling call status, allocation, and language mapping, particularly for introductory calls. Changes include setting call status based on call type and language mapping, disabling an allocation status update, and resetting allocation fields under certain conditions.

Changes

File(s) Change Summary
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java Refined conditional logic in closeCall for call status, allocation, and language mapping, with a commented-out allocation update and minor formatting.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant CallClosureImpl
    participant Repository

    Client->>CallClosureImpl: closeCall(request)
    alt Call type is "introductory" and disconnected with preferred language
        CallClosureImpl->>CallClosureImpl: Set status to "OPEN"\n(Comment out allocation update)
    else Call is answered
        CallClosureImpl->>CallClosureImpl: Set status to "COMPLETED"
    end
    CallClosureImpl->>Repository: Update call record

    alt Language not mapped and call type is "introductory"
        CallClosureImpl->>CallClosureImpl: Reset allocated user ID\nSet status to "OPEN"\nReset attempt number\nSet allocation to "UNALLOCATED"
    end
    CallClosureImpl->>Repository: Finalize updates
    CallClosureImpl-->>Client: Return result
Loading

Possibly related PRs

Poem

A call can close, or maybe stay,
Depending on language, type, and day.
Allocation paused, a status set,
For introductory calls, the rules are met.
With logic refined and branching anew,
The code hops forward—rabbit-approved! 🐇

✨ 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 Markdown

@helenKaryamsetty
helenKaryamsetty merged commit 05e8236 into PSMRI:develop May 26, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (1)

87-297: 🛠️ Refactor suggestion

Consider refactoring this method for better maintainability

The closeCall method is over 200 lines long and handles multiple complex scenarios. This makes it difficult to understand, test, and maintain. Consider:

  1. Extract method for call status logic: Lines 160-212 contain complex logic for determining call status that could be extracted
  2. Extract method for allocation handling: The allocation status logic could be separated
  3. Extract method for language preference updates: Lines 299-329 already exist as a separate method, which is good
  4. Consider using a state machine pattern for managing the various call states and transitions

Example refactoring approach:

+private void updateCallStatusAndAllocation(OutboundCalls callObj, Bencall bencall, 
+                                          CallClosureDTO request, boolean isMaxCallsAttempted) {
+    // Extract lines 160-212 logic here
+}
+
+private boolean shouldUnallocateCall(OutboundCalls callObj, CallClosureDTO request, 
+                                    boolean isLanguageMapped) {
+    // Define clear rules for when to unallocate
+}
🧹 Nitpick comments (1)
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (1)

252-268: Fix error message formatting

The error messages in the catch blocks have improper string concatenation:

-throw new ECDException("Failed to update isFurtherCallRequired upcoming calls for child" + e);
+throw new ECDException("Failed to update isFurtherCallRequired upcoming calls for child: " + e.getMessage());

-throw new ECDException("Failed to update isFurtherCallRequired upcoming calls for mother" + e);
+throw new ECDException("Failed to update isFurtherCallRequired upcoming calls for mother: " + e.getMessage());
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ae43e03 and 8941559.

📒 Files selected for processing (1)
  • src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (1)
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (1)

205-207: Good formatting improvement

Adding a blank line after the isLanguageMapped assignment improves code readability by visually separating the variable assignment from the conditional logic.

Comment on lines 160 to 165
if ("introductory".equalsIgnoreCase(callObj.getEcdCallType()) && Boolean.TRUE.equals(obj.getIsCallDisconnected()) && StringUtils.hasText(request.getPreferredLanguage())) {
callObj.setCallStatus(Constants.OPEN);
callObj.setAllocationStatus(Constants.UNALLOCATED);
//callObj.setAllocationStatus(Constants.UNALLOCATED);
}else if(Boolean.TRUE.equals(obj.getIsCallAnswered())){
callObj.setCallStatus(Constants.COMPLETED);
}

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

Potential inconsistency in allocation status handling

The allocation status update has been commented out for introductory calls that are disconnected with a preferred language. However, this creates an inconsistency with the logic at lines 207-212, where allocation status IS set to UNALLOCATED for introductory calls when language is not mapped.

This could lead to scenarios where:

  • Disconnected introductory calls with preferred language remain allocated to the original user
  • But similar calls without language mapping get unallocated

Consider either:

  1. Uncommenting this line to maintain consistency
  2. Documenting why allocation status should remain unchanged in this specific scenario

🏁 Script executed:

#!/bin/bash
# Description: Check for other occurrences of allocation status updates to understand the pattern

# Search for all occurrences of setAllocationStatus to understand the allocation logic
echo "=== Searching for setAllocationStatus usage patterns ==="
rg -A 3 -B 3 "setAllocationStatus" --type java

# Search for Constants.UNALLOCATED usage
echo -e "\n=== Searching for UNALLOCATED constant usage ==="
rg -A 2 -B 2 "Constants\.UNALLOCATED" --type java

# Check if there are any other places where allocation status is managed for introductory calls
echo -e "\n=== Searching for introductory call handling ==="
rg -A 5 -B 5 "introductory.*allocation|allocation.*introductory" --type java -i

Length of output: 18963


Ensure consistent allocation status for disconnected introductory calls

In CallClosureImpl.java (around lines 160–165), the callObj.setAllocationStatus(Constants.UNALLOCATED); line is commented out for disconnected introductory calls with a preferred language. Later in the same method, introductory calls without a language mapping do get unallocated, leading to inconsistent behavior.

Please address this by either:

  • Re-enabling the unallocation for disconnected introductory calls:
    @@ src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java:160
     if ("introductory".equalsIgnoreCase(callObj.getEcdCallType())
         && Boolean.TRUE.equals(obj.getIsCallDisconnected())
         && StringUtils.hasText(request.getPreferredLanguage())) {
       callObj.setCallStatus(Constants.OPEN);
    -  //callObj.setAllocationStatus(Constants.UNALLOCATED);
    +  callObj.setAllocationStatus(Constants.UNALLOCATED);
     } else if (Boolean.TRUE.equals(obj.getIsCallAnswered())) {
       callObj.setCallStatus(Constants.COMPLETED);
     }
  • Or add a clear comment explaining why allocation must remain unchanged when a preferred language is present.
📝 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 ("introductory".equalsIgnoreCase(callObj.getEcdCallType()) && Boolean.TRUE.equals(obj.getIsCallDisconnected()) && StringUtils.hasText(request.getPreferredLanguage())) {
callObj.setCallStatus(Constants.OPEN);
callObj.setAllocationStatus(Constants.UNALLOCATED);
//callObj.setAllocationStatus(Constants.UNALLOCATED);
}else if(Boolean.TRUE.equals(obj.getIsCallAnswered())){
callObj.setCallStatus(Constants.COMPLETED);
}
if ("introductory".equalsIgnoreCase(callObj.getEcdCallType())
&& Boolean.TRUE.equals(obj.getIsCallDisconnected())
&& StringUtils.hasText(request.getPreferredLanguage())) {
callObj.setCallStatus(Constants.OPEN);
callObj.setAllocationStatus(Constants.UNALLOCATED);
} else if (Boolean.TRUE.equals(obj.getIsCallAnswered())) {
callObj.setCallStatus(Constants.COMPLETED);
}
🤖 Prompt for AI Agents
In src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java between
lines 160 and 165, the line that sets the call's allocation status to
UNALLOCATED for disconnected introductory calls with a preferred language is
commented out, creating inconsistency with other parts of the code where similar
calls are unallocated. To fix this, uncomment the line to ensure consistent
allocation handling for such cases or add a comment explaining why the
allocation status should remain unchanged when a preferred language is present,
maintaining clarity and consistency in call state management.

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