Skip to content

Logic change for isCallDisconnected and preferredLanguage in close call API#78

Closed
srishtigrp78 wants to merge 6 commits intoPSMRI:developfrom
srishtigrp78:feature/version/upgrade
Closed

Logic change for isCallDisconnected and preferredLanguage in close call API#78
srishtigrp78 wants to merge 6 commits intoPSMRI:developfrom
srishtigrp78:feature/version/upgrade

Conversation

@srishtigrp78
Copy link
Copy Markdown
Contributor

@srishtigrp78 srishtigrp78 commented May 26, 2025

📋 Description

JIRA ID:

Please provide a summary of the change and the motivation behind it. Include relevant context and details.
Logic change for isCallDisconnected and preferredLanguage in close call API

✅ 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 introductory calls that are disconnected, ensuring such calls are correctly marked as open and unallocated for reassignment.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2025

Walkthrough

The change updates the call closure logic by adding a condition to check if an introductory call has been disconnected. If so, it resets the call's allocation, status, and attempt number, ensuring that only disconnected introductory calls are marked as open and unallocated for reassignment.

Changes

File(s) Change Summary
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java Added a condition to handle disconnected introductory calls; resets allocation, status, and attempts.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CallClosureImpl
    participant CallObj

    User->>CallClosureImpl: closeCall(request)
    CallClosureImpl->>CallObj: getCallType(), getIsCallDisconnected()
    alt Call is introductory AND disconnected
        CallClosureImpl->>CallObj: setAllocatedUserId(null)
        CallClosureImpl->>CallObj: setCallStatus("OPEN")
        CallClosureImpl->>CallObj: setCallAttemptNo(0)
    end
    CallClosureImpl-->>User: return result
Loading

Possibly related PRs

Suggested reviewers

  • devikasuresh20

Poem

A hop, a skip, a call reset anew,
When intro calls drop, we know what to do.
Disconnected and open, the status is clear,
Ready for reassignment, no need to fear.
With logic improved, the code’s in the groove—
A rabbit’s delight in each careful move! 🐇

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

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (2)
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (2)

207-210: The logic enhancement looks correct but consider using consistent null-safe checking pattern.

The addition of the disconnection check aligns well with the PR objectives. However, for consistency with line 160, consider using Boolean.TRUE.equals() for null-safe boolean checking:

-if (!isLanguageMapped 
-        && callObj.getEcdCallType().equalsIgnoreCase("introductory") 
-        && obj.getIsCallDisconnected() != null 
-        && obj.getIsCallDisconnected()) {
+if (!isLanguageMapped 
+        && callObj.getEcdCallType().equalsIgnoreCase("introductory") 
+        && Boolean.TRUE.equals(obj.getIsCallDisconnected())) {

This pattern is already used elsewhere in the code (line 160) and provides cleaner null-safe checking.


87-300: Consider refactoring this method for better maintainability.

The closeCall method is handling multiple responsibilities and has grown to over 300 lines. For future improvements, consider:

  • Extracting the call status update logic into separate methods
  • Creating dedicated methods for handling different call types (introductory, follow-up, etc.)
  • Consolidating the duplicate disconnection handling logic

This would make the code more testable and easier to maintain.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 19c2552 and 3e241df.

📒 Files selected for processing (1)
  • src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (1 hunks)

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@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: 0

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

208-216: 💡 Verification agent

🧩 Analysis chain

Potential logic conflict with existing introductory call handling.

The new conditional block adds logic for handling disconnected introductory calls when language is not mapped. However, there's similar logic at lines 160-163 that also handles introductory calls that are disconnected. This could lead to conflicting state changes or redundant processing.

Additionally, the Boolean comparison obj.getIsCallDisconnected() should use Boolean.TRUE.equals() for safer null handling, consistent with the pattern used at line 160.

Consider consolidating the introductory call logic or ensuring clear separation of concerns:

-if (!isLanguageMapped 
-        && callObj.getEcdCallType().equalsIgnoreCase("introductory") 
-        && obj.getIsCallDisconnected() != null 
-        && obj.getIsCallDisconnected()) {
+if (!isLanguageMapped 
+        && callObj.getEcdCallType().equalsIgnoreCase("introductory") 
+        && Boolean.TRUE.equals(obj.getIsCallDisconnected())) {

Let me verify if there are other similar patterns in the codebase and check for potential conflicts:


🏁 Script executed:

#!/bin/bash
# Description: Check for other introductory call handling patterns and potential conflicts

# Search for other introductory call handling logic
rg -A 10 -B 2 "introductory.*getIsCallDisconnected|getIsCallDisconnected.*introductory"

# Search for other Boolean.TRUE.equals patterns
rg "Boolean\.TRUE\.equals"

# Look for other call status setting patterns
rg -A 3 "setCallStatus.*OPEN"

Length of output: 4601


Clarify and unify introductory‐call disconnection handling

  • The two blocks in CallClosureImpl.java handle disconnected “introductory” calls in complementary scenarios (mapped vs. unmapped language) and are not duplicates—but they share the same state changes.
  • The unmapped block (lines 208–216) uses obj.getIsCallDisconnected() != null && obj.getIsCallDisconnected(), whereas the mapped block (around line 160) uses Boolean.TRUE.equals(obj.getIsCallDisconnected()).
  • To prevent NPEs and reduce duplication, extract the shared state changes into a helper and align null‐safety checks.

Locations to address:

  • src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java
    • Mapped case: ~lines 159–165
    • Unmapped case: lines 208–216

Proposed diff for the unmapped block:

-if (!isLanguageMapped
-        && callObj.getEcdCallType().equalsIgnoreCase("introductory")
-        && obj.getIsCallDisconnected() != null
-        && obj.getIsCallDisconnected()) {
+if (!isLanguageMapped
+        && "introductory".equalsIgnoreCase(callObj.getEcdCallType())
+        && Boolean.TRUE.equals(obj.getIsCallDisconnected())) {
     callObj.setAllocatedUserId(null);
     callObj.setCallStatus(Constants.OPEN);
     callObj.setCallAttemptNo(0);
     callObj.setAllocationStatus(Constants.UNALLOCATED);
}

Consider extracting into a helper to DRY up both branches:

private void openUnallocatedIntroCall(CallObj callObj) {
    callObj.setAllocatedUserId(null);
    callObj.setCallStatus(Constants.OPEN);
    callObj.setCallAttemptNo(0);
    callObj.setAllocationStatus(Constants.UNALLOCATED);
}
🧹 Nitpick comments (2)
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (2)

160-165: Review interaction with new language mapping logic.

This existing logic for introductory calls that are disconnected might interact unexpectedly with the new language mapping logic added later (lines 208-216). Both conditions could potentially apply to the same call, leading to multiple state changes.

Consider consolidating both introductory call handling blocks into a single, more comprehensive condition that handles all scenarios:

-if ("introductory".equalsIgnoreCase(callObj.getEcdCallType()) && Boolean.TRUE.equals(obj.getIsCallDisconnected()) && StringUtils.hasText(request.getPreferredLanguage())) {
-    callObj.setCallStatus(Constants.OPEN);
-    callObj.setAllocationStatus(Constants.UNALLOCATED);
-}
+if ("introductory".equalsIgnoreCase(callObj.getEcdCallType()) && Boolean.TRUE.equals(obj.getIsCallDisconnected())) {
+    callObj.setCallStatus(Constants.OPEN);
+    callObj.setAllocationStatus(Constants.UNALLOCATED);
+    // Additional logic for language mapping will be handled later
+}

207-207: Consider moving language mapping check closer to usage.

The isLanguageMapped variable is calculated here but only used in the condition below. For better code readability and performance, consider moving this check directly into the conditional or storing it in a more descriptive variable name.

-isLanguageMapped = isLanguageMappedWithUser(request);
+boolean isLanguageMapped = isLanguageMappedWithUser(request);

Or move it directly into the condition if not used elsewhere.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3e241df and aaa54ff.

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

@srishtigrp78
Copy link
Copy Markdown
Contributor Author

not required anymore.

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