Skip to content

Conversation

@srishtigrp78
Copy link
Contributor

@srishtigrp78 srishtigrp78 commented May 24, 2025

📋 Description

JIRA ID: 1510
Disease summary under configuration is not reflecting in the list after saving
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 disease list retrieval to exclude deleted entries and display the newest diseases first.
    • Added validation for pagination parameters to ensure proper page navigation.
  • Chores

    • Enhanced internal logging for better query debugging.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 24, 2025

Walkthrough

The getDisease method in the disease service implementation was updated to validate input, exclude deleted diseases from counts and query results, sort results by descending diseasesummaryID, add debug logging for query predicates, and improve pagination validation and offset calculation. The method signature and public interface remain unchanged. The repository method for counting diseases was replaced with one excluding deleted records.

Changes

File Change Summary
src/main/java/com/iemr/helpline104/service/disease/DiseaseServiceImpl.java Added input validation, excluded deleted diseases in query and count, sorted results by descending ID, added debug logging of predicates, and improved pagination logic.
src/main/java/com/iemr/helpline104/repository/disease/DiseaseRepository.java Replaced getDiseaseCount() with getDiseaseCountExcludingDeleted() to exclude logically deleted diseases from count.

Poem

In the meadow of code, a filter appears,
Old diseases now vanish, the newest are near.
With logs for the burrows and order so neat,
The bunny hops forward, making queries complete.
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.

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

@srishtigrp78 srishtigrp78 requested a review from drtechie May 24, 2025 07:52
Copy link
Contributor

@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

🧹 Nitpick comments (2)
src/main/java/com/iemr/helpline104/service/disease/DiseaseServiceImpl.java (2)

120-120: Consider removing debug logging in production code.

Debug logging of predicates may clutter production logs and potentially expose internal query structure.

-logger.info("Executing disease fetch query with predicates: " + predicates);
+logger.debug("Executing disease fetch query with predicates: " + predicates);

Or remove entirely if not needed for ongoing debugging.


141-141: Improve response serialization format.

Using toString() on a Map may not produce proper JSON format for API responses. Consider using proper JSON serialization.

-return responseMap.toString();
+return InputMapper.gson().toJson(responseMap);

This ensures consistent JSON formatting across your API responses.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 170af88 and 5fa5a16.

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

110-118: LGTM! Excellent implementation of filtering and sorting logic.

The addition of soft delete filtering and sorting by newest entries first directly addresses the PR objective. The Criteria API usage is correct and will ensure deleted diseases don't appear in the list.

Comment on lines 103 to 104
Disease disease = InputMapper.gson().fromJson(request, Disease.class);
Integer totalCount = diseaseRepository.getDiseaseCount();
Copy link
Contributor

@coderabbitai coderabbitai bot May 24, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Fix pagination calculation for filtered results.

The total count is calculated from all diseases but the actual query filters out deleted records. This mismatch will cause incorrect pagination calculations.

Apply this fix to calculate the correct total count:

-Integer totalCount = diseaseRepository.getDiseaseCount();
+Integer totalCount = diseaseRepository.getDiseaseCountExcludingDeleted();

You'll also need to add this method to your repository:

@Query("SELECT COUNT(d) FROM Disease d WHERE d.deleted = false")
Integer getDiseaseCountExcludingDeleted();
🤖 Prompt for AI Agents
In src/main/java/com/iemr/helpline104/service/disease/DiseaseServiceImpl.java at
lines 103-104, the totalCount is currently fetched without excluding deleted
records, causing incorrect pagination. Modify the code to call a new repository
method that counts only non-deleted diseases. Add the method
getDiseaseCountExcludingDeleted() with the query "SELECT COUNT(d) FROM Disease d
WHERE d.deleted = false" to the diseaseRepository interface, then replace the
existing totalCount assignment with a call to this new method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed now.

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

@srishtigrp78 Perfect! I can see the fix has been properly implemented. The code now correctly uses diseaseRepository.getDiseaseCountExcludingDeleted() which ensures the pagination calculation matches the filtered query results. This will resolve the issue where the disease summary wasn't properly reflecting in the list after saving.

Great job addressing this critical pagination issue!


🏁 Script executed:

#!/bin/bash
# Check the current state of the getDisease method to verify the fix
ast-grep --pattern $'public String getDisease(String request) throws IEMRException {
  $$$
}'

# Also check if the new repository method was added
rg "getDiseaseCountExcludingDeleted" -A 2 -B 1

Length of output: 1056


@srishtigrp78 Excellent! I can confirm the fix has been properly implemented:

Repository Method Added: getDiseaseCountExcludingDeleted() with the correct query filtering out deleted records
Service Updated: The getDisease method now uses the new count method
Pagination Fixed: Total count now matches the filtered query results

This resolves the critical pagination issue and should fix the problem where disease summaries weren't properly reflecting in the list after saving. The pagination calculations will now be accurate for the filtered dataset.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@sonarqubecloud
Copy link

Copy link
Contributor

@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 (1)
src/main/java/com/iemr/helpline104/repository/disease/DiseaseRepository.java (1)

47-48: Fix query aliasing for consistency.

The query has an inconsistent aliasing pattern. Other methods in this repository use Disease disease consistently (see lines 62, 65).

Apply this diff to fix the aliasing:

-@Query("Select count(*) from Disease disease d where d.deleted = false")
+@Query("Select count(*) from Disease disease where disease.deleted = false")

The functionality correctly implements soft delete filtering to exclude deleted diseases from the count, which should help resolve the issue where disease summaries weren't reflecting in the list after saving.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ee8a993 and cf4c555.

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

@srishtigrp78 srishtigrp78 merged commit d8161cc into PSMRI:develop May 24, 2025
7 of 8 checks passed
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