Skip to content

ECD Reports and highrisk#50

Merged
helenKaryamsetty merged 6 commits into
PSMRI:developfrom
ravishanigarapu:develop
Jan 17, 2025
Merged

ECD Reports and highrisk#50
helenKaryamsetty merged 6 commits into
PSMRI:developfrom
ravishanigarapu:develop

Conversation

@ravishanigarapu

@ravishanigarapu ravishanigarapu commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

📋 Description

JIRA ID: AMM-1067

Beneficiary record appearing in worklist After Not Interested in further call section


✅ 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 report generation methods to include role-based filtering for abortion, stillbirth, baby death, and miscarriage reports.
    • Added functionality to manage follow-up calls based on whether previous calls were answered.
    • New field introduced to track if further calls are required.
  • Bug Fixes

    • Simplified method signatures for counting unallocated high-risk mothers and children, improving usability.
  • Refactor

    • Consolidated logic for report retrieval to streamline processing and improve clarity.
    • Updated method signatures to remove unnecessary parameters, simplifying calls to the repository.
    • Simplified authorization handling in the HTTP interceptor.
  • Chores

    • Minor adjustments in comments and formatting for better code readability.

@coderabbitai

coderabbitai Bot commented Dec 4, 2024

Copy link
Copy Markdown

Walkthrough

This pull request introduces several modifications across multiple repository interfaces and service classes. Key changes include the simplification of method signatures in the OutboundCallsRepo by removing date parameters and adding new methods for updating call requirements. The EcdReportRepo interface has been updated to include role-based parameters for report methods, consolidating previous role-specific methods. Additionally, the ReportServiceImpl class simplifies report generation logic by consistently using role parameters. These adjustments aim to streamline method calls and enhance clarity without altering the underlying logic or control flow.

Changes

File Change Summary
src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java Updated method getMotherRecordsForMO to remove date parameters; added methods updateIsFurtherCallRequiredForUpcomingCallForChild and updateIsFurtherCallRequiredForUpcomingCallForMother.
src/main/java/com/iemr/ecd/repository/masters/AgentsViewMasterRepo.java Updated method findByRoleId to include a custom JPQL query with @Query annotation; findByRoleIdAndLanguage remains unchanged.
src/main/java/com/iemr/ecd/repository/report/EcdReportRepo.java Added role parameter to methods: getAbortionReport, getStillBirthReport, getBabyDeathReport, and getMiscarriageReport, while removing the previous role-specific methods.
src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java Modified getEligibleRecordsInfo to call outboundCallsRepo.getMotherUnAllocatedCountHR with three parameters, removing date range parameters; updated allocateMotherRecordsToMO to remove date parameters.
src/main/java/com/iemr/ecd/service/report/ReportServiceImpl.java Consolidated report generation methods to always include the role parameter, removing conditional logic for role checks in methods: getAbortionReport, getStillBirthReport, getBabyDeathReport, and getMiscarriageReport.
src/main/java/com/iemr/ecd/dao/associate/OutboundCalls.java Added new field isFurtherCallRequired of type Boolean to the OutboundCalls class.
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java Enhanced closeCall method to manage unanswered calls, including logic for isFurtherCallRequired and tracking maximum call attempts; updated call status handling.
src/main/java/com/iemr/ecd/utils/constants/Constants.java Added new public static final variable REASONFORCALLNOTANSWERED to the Constants class, initialized with a list of reasons for calls not being answered.

Possibly related PRs

  • Update ecd_ci.properties #51: The changes in this PR are unrelated to the modifications in the OutboundCallsRepo interface and do not involve any relevant code changes.

Suggested reviewers

  • drtechie

🐰 In the meadow, changes bloom,
Methods simplified, dispelling gloom.
Roles now guide the reports we seek,
With clearer paths, no more mystique.
Hopping forward, let’s embrace the new,
In code we trust, our vision true! 🌼


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c6acf19 and f281bc8.

📒 Files selected for processing (1)
  • src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (java)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

@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 and nitpick comments (4)
src/main/java/com/iemr/ecd/repository/masters/AgentsViewMasterRepo.java (1)

36-37: LGTM! Consider adding an index for roleId.

The JPQL query with DISTINCT is well-structured and properly parameterized. For optimal performance, consider adding a database index on the roleId column if not already present.

src/main/java/com/iemr/ecd/service/report/ReportServiceImpl.java (3)

772-775: Remove unnecessary blank lines

Consider removing the extra blank lines to maintain consistent code formatting.

-			
-			result = ecdReportRepo.getStillBirthReport(startDate, endDate, stillBirthReport.getAgentId(),
-					stillBirthReport.getPsmId(),stillBirthReport.getRole());
-			
+			result = ecdReportRepo.getStillBirthReport(startDate, endDate, stillBirthReport.getAgentId(),
+					stillBirthReport.getPsmId(),stillBirthReport.getRole());

814-815: Remove unnecessary blank line

Consider removing the extra blank line to maintain consistent code formatting.

-			
-			result = ecdReportRepo.getBabyDeathReport(startDate, endDate, babyDeathReport.getAgentId(),
+			result = ecdReportRepo.getBabyDeathReport(startDate, endDate, babyDeathReport.getAgentId(),

936-938: Remove unnecessary blank lines

Consider removing the extra blank lines to maintain consistent code formatting.

-			
-			result = ecdReportRepo.getMiscarriageReport(startDate, endDate, miscarriageReport.getAgentId(),
-					miscarriageReport.getPsmId(), miscarriageReport.getRole());
+			result = ecdReportRepo.getMiscarriageReport(startDate, endDate, miscarriageReport.getAgentId(),
+					miscarriageReport.getPsmId(), miscarriageReport.getRole());
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 71fb761 and e6252e3.

📒 Files selected for processing (5)
  • src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java (1 hunks)
  • src/main/java/com/iemr/ecd/repository/masters/AgentsViewMasterRepo.java (1 hunks)
  • src/main/java/com/iemr/ecd/repository/report/EcdReportRepo.java (3 hunks)
  • src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java (1 hunks)
  • src/main/java/com/iemr/ecd/service/report/ReportServiceImpl.java (4 hunks)
🔇 Additional comments (8)
src/main/java/com/iemr/ecd/repository/report/EcdReportRepo.java (3)

143-146: Verify role parameter handling in stored procedure.

The addition of the role parameter to getMiscarriageReport needs verification in the corresponding stored procedure Pr_ECDMiscarriageReport.


128-131: Verify role parameter handling in stored procedure.

The addition of the role parameter to getBabyDeathReport needs verification in the corresponding stored procedure Pr_ECDBabyDeathReport.


99-101: Verify role parameter handling in stored procedure.

The addition of the role parameter to getAbortionReport needs verification in the corresponding stored procedure Pr_ECDAbortionReport.

src/main/java/com/iemr/ecd/service/report/ReportServiceImpl.java (4)

573-574: LGTM: Role parameter addition to abortion report

The addition of the role parameter to ecdReportRepo.getAbortionReport() enables role-based filtering of report data, which is consistent with the repository interface changes.


772-774: LGTM: Role parameter addition to still birth report

The addition of the role parameter to ecdReportRepo.getStillBirthReport() enables role-based filtering of report data, which is consistent with the repository interface changes.


814-815: LGTM: Role parameter addition to baby death report

The addition of the role parameter to ecdReportRepo.getBabyDeathReport() enables role-based filtering of report data, which is consistent with the repository interface changes.


936-938: LGTM: Role parameter addition to miscarriage report

The addition of the role parameter to ecdReportRepo.getMiscarriageReport() enables role-based filtering of report data, which is consistent with the repository interface changes.

src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java (1)

519-519: LGTM: Simplified method signature

The removal of date parameters from getMotherUnAllocatedCountHR() call aligns with the repository interface changes to simplify the method signature. This change streamlines the counting of high-risk mother records without date filtering.

Comment on lines +102 to +106
+ " 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 ")
int getMotherUnAllocatedCountHR(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId,
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("phoneNoType") String phoneNoType);
@Param("phoneNoType") String phoneNoType);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Verify impact of removing date filtering.

The removal of date parameters (fDate and tDate) from getMotherUnAllocatedCountHR could lead to:

  1. Counting outdated high-risk mother records
  2. Including future scheduled calls
  3. Performance issues with large datasets

Consider keeping date filtering to ensure accurate counts within relevant time periods.

Apply this diff to restore date filtering:

@Query(value = " SELECT count(1) FROM OutboundCalls AS t WHERE t.allocationStatus =:allocationStatus AND "
-           + " t.psmId=:psmId 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 = true "
            + " AND t.phoneNumberType=:phoneNoType AND t.deleted = false ")
int getMotherUnAllocatedCountHR(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId,
+           @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate,
            @Param("phoneNoType") String phoneNoType);

Committable suggestion skipped: line range outside the PR's diff.

@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

🧹 Nitpick comments (5)
src/main/java/com/iemr/ecd/utils/constants/Constants.java (1)

18-18: Consider using an enum for call not answered reasons.

The current implementation uses hardcoded strings which could be prone to typos and make maintenance difficult. Consider using an enum for better type safety and maintainability.

-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 enum ReasonForCallNotAnswered {
+    INVALID_NUMBER("Invalid number"),
+    OUT_OF_SERVICE("Out of service"),
+    OUT_OF_REACH("Out of Reach"),
+    SWITCHED_OFF("Switched off"),
+    NO_REPLY("No reply"),
+    NUMBER_BUSY("Number busy"),
+    CALL_NOT_CONNECTED("Call not connected");
+
+    private final String reason;
+
+    ReasonForCallNotAnswered(String reason) {
+        this.reason = reason;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public static boolean contains(String reason) {
+        for (ReasonForCallNotAnswered value : values()) {
+            if (value.getReason().equals(reason)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
src/main/java/com/iemr/ecd/dao/associate/OutboundCalls.java (1)

120-121: Add documentation for the new field.

Consider adding Javadoc to explain the purpose and behavior of the isFurtherCallRequired field, including when it's set to true/false/null.

+    /**
+     * Indicates whether additional calls are required for this outbound call record.
+     * Set to true when the call was not answered and requires follow-up.
+     * Set to false when no further calls are needed.
+     * Can be null when the status is undetermined.
+     */
     @Column(name = "isFurtherCallRequired")
     private Boolean isFurtherCallRequired;
src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (3)

169-174: Remove commented code.

The commented code block should be removed as it's no longer needed. If this code needs to be referenced later, it should be tracked in version control history.

-                    /*
-                     * if (null != obj.getReceivedRoleName() &&
-                     * (obj.getReceivedRoleName().equalsIgnoreCase(Constants.ANM) ||
-                     * obj.getReceivedRoleName().equalsIgnoreCase(Constants.ASSOCIATE))) {
-                     * callObj.setCallStatus(Constants.OPEN); }
-                     */

132-135: Consolidate call status logic.

The logic for handling unanswered calls is spread across multiple locations. Consider consolidating this logic into a private method for better maintainability.

+    private void handleUnansweredCall(Bencall bencall, OutboundCalls callObj, String reasonForCallNotAnswered, boolean isMaxcallsAttempted) {
+        if(null != reasonForCallNotAnswered && Constants.REASONFORCALLNOTANSWERED.contains(reasonForCallNotAnswered)) {
+            bencall.setIsFurtherCallRequired(true);
+            bencall.setIsCallDisconnected(true);
+            
+            if (!isMaxcallsAttempted) {
+                callObj.setCallStatus(Constants.OPEN);
+            }
+        }
+    }

Also applies to: 200-202


141-141: Fix variable naming convention.

The variable isMaxcallsAttempted doesn't follow the camelCase naming convention. Rename it to isMaxCallsAttempted.

-            boolean isMaxcallsAttempted=false;
+            boolean isMaxCallsAttempted = false;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9deaed0 and 3ed80e2.

📒 Files selected for processing (4)
  • src/main/java/com/iemr/ecd/dao/associate/OutboundCalls.java (1 hunks)
  • src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java (3 hunks)
  • src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java (5 hunks)
  • src/main/java/com/iemr/ecd/utils/constants/Constants.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (java)

Comment on lines +221 to +227
if(null != obj.getIsFurtherCallRequired() && !obj.getIsFurtherCallRequired()) {
if (callObj.getMotherId() != null && callObj.getChildId() != null) {
outboundCallsRepo.updateIsFurtherCallRequiredForUpcomingCallForChild(callObj.getChildId(), obj.getIsFurtherCallRequired());
} else if (callObj.getMotherId() != null && callObj.getChildId() == null) {
outboundCallsRepo.updateIsFurtherCallRequiredForUpcomingCallForMother(callObj.getMotherId(), obj.getIsFurtherCallRequired());
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for repository calls.

The repository calls for updating isFurtherCallRequired should include error handling to manage potential database exceptions.

     if(null != obj.getIsFurtherCallRequired() && !obj.getIsFurtherCallRequired()) {
         if (callObj.getMotherId() != null && callObj.getChildId() != null) {
-            outboundCallsRepo.updateIsFurtherCallRequiredForUpcomingCallForChild(callObj.getChildId(), obj.getIsFurtherCallRequired());
+            try {
+                outboundCallsRepo.updateIsFurtherCallRequiredForUpcomingCallForChild(callObj.getChildId(), obj.getIsFurtherCallRequired());
+            } catch (Exception e) {
+                logger.error("Failed to update isFurtherCallRequired for child: " + callObj.getChildId(), e);
+                throw new ECDException("Failed to update upcoming calls for child", e);
+            }
         } else if (callObj.getMotherId() != null && callObj.getChildId() == null) {
-            outboundCallsRepo.updateIsFurtherCallRequiredForUpcomingCallForMother(callObj.getMotherId(), obj.getIsFurtherCallRequired());
+            try {
+                outboundCallsRepo.updateIsFurtherCallRequiredForUpcomingCallForMother(callObj.getMotherId(), obj.getIsFurtherCallRequired());
+            } catch (Exception e) {
+                logger.error("Failed to update isFurtherCallRequired for mother: " + callObj.getMotherId(), e);
+                throw new ECDException("Failed to update upcoming calls for mother", e);
+            }
         }
     }

Committable suggestion skipped: line range outside the PR's diff.

@sonarqubecloud

Copy link
Copy Markdown

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