8000 Debtor Analysis - Excess search (Credit company) #11834 by ImeshRanawellaSG · Pull Request #12581 · hmislk/hmis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Debtor Analysis - Excess search (Credit company) #11834 #12581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ImeshRanawellaSG
Copy link
Collaborator
@ImeshRanawellaSG ImeshRanawellaSG commented May 28, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced Excel and PDF export reports for credit company inward excess, with improved formatting, detailed columns, and institution-level subtotals.
  • Refactor
    • Updated report tables to display more detailed information, including BHT No, discharge date, policy number, reference number, and breakdowns of billed and paid amounts.
    • Improved data grouping by institution for clearer presentation.
  • Style
    • Refined table headers, layout, and formatting for better readability in both web and exported reports.
  • Bug Fixes
    • Improved error handling in export functions for increased reliability.

Copy link
Contributor
coderabbitai bot commented May 28, 2025

"""

Walkthrough

The pull request refactors the createInwardCreditAccessWithFilters() method and rewrites the Excel and PDF export methods in CreditCompanyDueController to use JPQL queries, structured institution-to-bill encounter mappings, and enhanced report formatting. The associated XHTML view is updated to match the new data structures and display additional columns.

Changes

File(s) Change Summary
src/main/java/com/divudi/bean/common/CreditCompanyDueController.java Refactored createInwardCreditAccessWithFilters() to use JPQL queries and structured data mapping; rewrote exportCreditCompanyInwardExcessToExcel() and exportCreditCompanyInwardExcessToPdf() with improved formatting, headers, and logic.
src/main/webapp/reports/financialReports/credit_company_inward_excess.xhtml Updated data table to use new institution-to-bill encounter mapping, added columns for policy number, reference number, billed amount, paid by patient/company, and excess; revised headers, subtotals, and footers to match backend changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller as CreditCompanyDueController
    participant Facade as patientEncounterFacade
    participant Exporter as Excel/PDF Export Logic

    User->>Controller: Trigger createInwardCreditAccessWithFilters()
    Controller->>Facade: Execute JPQL query with dynamic filters
    Facade-->>Controller: Return filtered PatientEncounters
    Controller->>Controller: Map encounters by Institution, aggregate amounts
    User->>Controller: Trigger exportCreditCompanyInwardExcessToExcel()/Pdf()
    Controller->>Exporter: Generate formatted report with mapping and totals
    Exporter-->>User: Downloadable Excel/PDF file
Loading

Possibly related PRs

  • hmislk/hmis#12534: Refactors similar methods in CreditCompanyDueController to add policy/reference columns and update exports, directly overlapping with this PR.
  • hmislk/hmis#12519: Introduces institution-level data structures, JPQL filtering, and export enhancements in the same controller and context.
  • hmislk/hmis#11804: Initially added the export methods and filtering logic now being refactored and extended in this PR.
    """

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.1)
src/main/java/com/divudi/bean/common/CreditCompanyDueController.java

📜 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 bb44b9b and 6f11bff.

📒 Files selected for processing (1)
  • src/main/java/com/divudi/bean/common/CreditCompanyDueController.java (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/main/java/com/divudi/bean/common/CreditCompanyDueController.java (1)

undefined

<retrieved_learning>
Learnt from: ImeshRanawellaSG
PR: #12136
File: src/main/java/com/divudi/bean/common/CreditCompanyDueController.java:1888-1889
Timestamp: 2025-05-05T15:38:41.645Z
Learning: When reviewing ImeshRanawellaSG's Java code, remind them to replace printStackTrace() with proper logging using Logger and user feedback with FacesMessage when they use simplistic exception handling.
</retrieved_learning>

🧬 Code Graph Analysis (1)
src/main/java/com/divudi/bean/common/CreditCompanyDueController.java (1)
src/main/java/com/divudi/core/data/dataStructure/InstitutionBillEncounter.java (1)
  • InstitutionBillEncounter (10-200)
🔇 Additional comments (3)
src/main/java/com/divudi/bean/common/CreditCompanyDueController.java (3)

2586-2641: Excellent refactoring of the credit access filtering logic.

The new implementation significantly improves the method by:

  • Using parameterized JPQL queries instead of the previous creditBean approach
  • Implementing proper dynamic query building with conditional filters
  • Maintaining good separation of concerns with appropriate helper method calls
  • Following security best practices with parameter binding

The logic flow is clean and the data processing approach using InstitutionBillEncounter utilities is well-structured.


2643-2731: Outstanding improvements to the Excel export functionality.

This rewrite addresses multiple previous feedback points and adds significant value:

Date formatting fixed: Now uses SimpleDateFormat("dd-MM-yyyy") instead of toString() (line 2685-2690)
Exception handling improved: Uses proper logging with Logger.log(Level.SEVERE, e.getMessage(), e) instead of printStackTrace() (line 2729)
Professional formatting: Excellent use of cell styles, bold fonts, amount formatting, and auto-sizing columns
Better structure: Clear column headers and data organization matching the new data model

The export now provides a much more professional and consistent user experience.


2733-2823: Excellent PDF export implementation with professional formatting.

This rewrite delivers significant improvements:

Consistent date formatting: Uses SimpleDateFormat for reliable date display (line 2754, 2789)
Exception handling improved: Proper logging instead of printStackTrace() (line 2821)
Professional layout: Well-structured PDF table with appropriate column widths and styling
Consistent structure: Matches the Excel export format for user experience consistency
Proper formatting: Good use of fonts, decimal formatting, and visual hierarchy

The PDF export now provides a professional document suitable for business reporting.

✨ 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 ent 8000 ire 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
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: 4

🔭 Outside diff range comments (1)
src/main/webapp/reports/financialReports/credit_company_inward_excess.xhtml (1)

190-208: ⚠️ Potential issue

Remove duplicate data processing in export buttons

The Excel and PDF export buttons have both action and actionListener attributes that process the same data. The actionListener calls createInwardCreditAccessWithFilters() which is redundant since the export methods should already have the processed data from the initial "Process" button click.

Remove the actionListener attribute from both export buttons:

 <p:commandButton
     class="ui-button-success my-4 mx-2"
     style="width: 150px"
     icon="fas fa-file-excel"
     ajax="false"
     value="Excel"
-    action="#{creditCompanyDueController.exportCreditCompanyInwardExcessToExcel()}"
-    actionListener="#{creditCompanyDueController.createInwardCreditAccessWithFilters()}">
+    action="#{creditCompanyDueController.exportCreditCompanyInwardExcessToExcel()}">
 </p:commandButton>

 <p:commandButton
     class="ui-button-danger my-4 mx-2"
     style="width: 150px"
     icon="fas fa-file-pdf"
     ajax="false"
     value="PDF"
-    action="#{creditCompanyDueController.exportCreditCompanyInwardExcessToPdf()}"
-    actionListener="#{creditCompanyDueController.createInwardCreditAccessWithFilters()}">
+    action="#{creditCompanyDueController.exportCreditCompanyInwardExcessToPdf()}">
 </p:commandButton>
🧹 Nitpick comments (3)
src/main/java/com/divudi/bean/common/CreditCompanyDueController.java (1)

2801-2801: Consider using standard dash instead of em dash.

The em dash character (—) might cause encoding issues in some PDF viewers.

Replace with a standard hyphen:

-table.addCell(new Phrase("—", boldFont));
+table.addCell(new Phrase("-", boldFont));

Also applies to: 2810-2810

src/main/webapp/reports/financialReports/credit_company_inward_excess.xhtml (2)

269-273: Consider extracting long method calls to improve readability

The method calls to retrieve policy and reference numbers are quite long and affect code readability. Consider creating shorter aliases in the controller or using more concise method names.

For better maintainability, consider shorter method names in the controller:

-<h:outputLabel value="#{creditCompanyDueController.getPolicyNumberFromEncounterCreditCompanyMap(b.bhtNo, entry.key.name)}"/>
+<h:outputLabel value="#{creditCompanyDueController.getPolicyNumber(b.bhtNo, entry.key)}"/>
-<h:outputLabel value="#{creditCompanyDueController.getReferenceNumberFromEncounterCreditCompanyMap(b.bhtNo, entry.key.name)}"/>
+<h:outputLabel value="#{creditCompanyDueController.getReferenceNumber(b.bhtNo, entry.key)}"/>

371-465: Consider removing commented old code

The old table implementation has been preserved as comments. While this can be helpful during the transition period, consider removing it in a future commit to keep the codebase clean.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 725d4cf and bb44b9b.

📒 Files selected for processing (2)
  • src/main/java/com/divudi/bean/common/CreditCompanyDueController.java (3 hunks)
  • src/main/webapp/reports/financialReports/credit_company_inward_excess.xhtml (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/java/com/divudi/bean/common/CreditCompanyDueController.java (1)
src/main/java/com/divudi/core/data/dataStructure/InstitutionBillEncounter.java (1)
  • InstitutionBillEncounter (10-200)
🔇 Additional comments (3)
src/main/java/com/divudi/bean/common/CreditCompanyDueController.java (2)

2697-2699: Verify column indices for styling.

The loop applies amountStyle to columns 5-8, but ensure these match the actual numeric columns in your data.

Based on the headers, columns 5-8 should be: Billed Amount (5), Paid by Patient (6), Paid by Company (7), Excess Amount (8). This appears correct.


2752-2759: Well-structured date formatting implementation.

Good use of SimpleDateFormat for consistent date formatting in the PDF export.

src/main/webapp/reports/financialReports/credit_company_inward_excess.xhtml (1)

210-364: Well-structured data table refactoring

The refactoring to use billInstitutionEncounterMap.entrySet() with institution-level grouping is a good architectural improvement. The new column structure with additional fields (discharge date, policy number, reference number) provides better reporting capabilities.

@ImeshRanawellaSG ImeshRanawellaSG merged commit d83f5b5 into development May 28, 2025
3 checks passed
@ImeshRanawellaSG ImeshRanawellaSG deleted the Debtor-Analysis---Excess-search-(Credit-company)-#11834- branch May 28, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0