Skip to content

19655 inward reports rename charge type summary add bht level charge type breakdown detail report#19656

Merged
buddhika75 merged 6 commits intodevelopmentfrom
19655-inward-reports-rename-charge-type-summary-add-bht-level-charge-type-breakdown-detail-report
Apr 2, 2026
Merged

19655 inward reports rename charge type summary add bht level charge type breakdown detail report#19656
buddhika75 merged 6 commits intodevelopmentfrom
19655-inward-reports-rename-charge-type-summary-add-bht-level-charge-type-breakdown-detail-report

Conversation

@buddhika75
Copy link
Copy Markdown
Member

@buddhika75 buddhika75 commented Apr 2, 2026

Summary by CodeRabbit

  • New Features

    • Added "Inward Charge Type Breakdown by BHT" report with filters (date range, date basis, admission status/type, institution, site, department), generate/print and per-BHT totals.
    • Charge types now mapped to calculation methods to support multiple data sources for accurate breakdowns.
    • Added report entry in Inward Reports menu.
  • UI

    • Renamed "Inward Charge Type Detail Report" to "Inward Charge Type Summary by BHT Report".
    • Improved autocomplete layout in the breakdown view.
  • Bug Fixes

    • BHT Payment Summary now omits payment-method columns with zero totals.

…-level-charge-type-breakdown-detail-report' of https://github.com/hmislk/hmis.git into 19655-inward-reports-rename-charge-type-summary-add-bht-level-charge-type-breakdown-detail-report
  Complete — 6 files changed

  Step 1 — CalculationMethod.java (NEW)
  6-value enum: BILL_ITEM, PHARMACY_BILL, STORE_BILL, PATIENT_ROOM, BILL_FEE, ADMISSION_FEE

  Step 2 — InwardChargeType.java (MODIFIED)
  - Added private CalculationMethod calculationMethod field
  - Added new 2-arg constructor (existing 1-arg untouched)
  - Added getCalculationMethod() with null-safe default → BILL_ITEM
  - Updated 12 constants: RoomCharges, MOCharges, NursingCharges, LinenCharges, AdministrationCharge, MedicalCareICU,
  MaintainCharges → PATIENT_ROOM; Medicine → PHARMACY_BILL; GeneralIssuing → STORE_BILL; ProfessionalCharge,
  DoctorAndNurses → BILL_FEE; AdmissionFee → ADMISSION_FEE

  Step 3 — InwardChargeTypeBreakdownController.java (NEW)
  Branches on selectedChargeType.getCalculationMethod() across 6 cases, each producing a List<BhtBreakdownRow> +
  columnKeys/columnLabels/columnTotals.

  Step 4 — inward_report_inward_charge_type_breakdown.xhtml (NEW)
  ui:repeat-based HTML pivot table — dynamic columns for items/staff, blank cells for missing values, footer totals.

  Step 5 — inward_report_inward_charge_type_detail.xhtml (MODIFIED)
  Panel header renamed to "Inward Charge Type Summary by BHT Report".

  Step 6 — inward_reports.xhtml (MODIFIED)
  Button renamed to "Inward Charge Type Summary by BHT"; new "Inward Charge Type Breakdown by BHT" button added
  immediately below it.

Signed-off-by: Dr M H B Ariyaratne <buddhika.ari@gmail.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

Warning

Rate limit exceeded

@buddhika75 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 55 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 18 minutes and 55 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d947c66-75d9-482a-aade-04b587810626

📥 Commits

Reviewing files that changed from the base of the PR and between 8aeccd7 and 0eb60f9.

📒 Files selected for processing (2)
  • src/main/java/com/divudi/bean/inward/InwardChargeTypeBreakdownController.java
  • src/main/webapp/inward/inward_report_inward_charge_type_breakdown.xhtml

Walkthrough

Adds a new session-scoped report controller that generates an "Inward Charge Type Breakdown by BHT" pivot report, introduces a CalculationMethod enum, augments InwardChargeType with calculation methods, adds a new JSF view for the breakdown, and updates navigation and a small panelGrid attribute.

Changes

Cohort / File(s) Summary
Report Controller
src/main/java/com/divudi/bean/inward/InwardChargeTypeBreakdownController.java
New @Named @SessionScoped`` controller implementing filter state, validation, multiple calculation strategies (bill items, pharmacy, store, patient-room, bill-fee, admission-fee), pivot building, DTO BhtBreakdownRow, helpers, and `makeNull()` reset.
Enums / Domain
src/main/java/com/divudi/core/data/inward/CalculationMethod.java, src/main/java/com/divudi/core/data/inward/InwardChargeType.java
Added CalculationMethod enum; extended InwardChargeType with a calculationMethod field, overloaded constructor, and getter; assigned specific calculation methods to several charges.
New UI View
src/main/webapp/inward/inward_report_inward_charge_type_breakdown.xhtml
New JSF page providing filters (dates, date-basis, admission status/type, institution/site/department), mandatory charge-type picker, generate/print actions, error messaging, and a dynamic pivot table driven by controller outputs.
Navigation & Minor View Edits
src/main/webapp/inward/inward_reports.xhtml, src/main/webapp/inward/inward_report_inward_charge_type_detail.xhtml, src/main/webapp/inward/inward_bill_final_break_down.xhtml
Added navigation button for the new breakdown report, renamed one page title to "Summary by BHT", and changed a p:panelGrid to layout="tabular".
Related Report Fix
src/main/java/com/divudi/bean/inward/BhtPaymentSummaryReportController.java
Adjusted allPaymentMethods to be computed per-run (cleared and populated based on actual non-zero totals) and reset in makeNull(); minor generateReport() behavior changes.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant UI as Inward Report Page
    participant Controller as InwardChargeTypeBreakdownController
    participant Strategy as Calculation Method Handler
    participant Facade as Data Facade(s)
    participant DB as Database

    User->>UI: Select filters & charge type
    User->>UI: Click Generate
    UI->>Controller: generateReport()
    Controller->>Controller: validate inputs (dates, required charge type, discharge-date rules)
    alt validation fails
        Controller->>UI: set errorMessage
        UI-->>User: display error
    else
        Controller->>Strategy: select strategy by selectedChargeType.getCalculationMethod()
        Strategy->>Facade: execute JPQL queries (appendEncounterFilters)
        Facade->>DB: run queries
        DB-->>Facade: return rows
        Facade-->>Strategy: return results
        Strategy->>Strategy: group by BHT, aggregate per-column, compute totals
        Strategy-->>Controller: return columnKeys,columnLabels,rows,columnTotals
        Controller->>UI: populate report fields
        UI-->>User: render pivot table
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: renaming the charge type detail report to summary and adding a new BHT-level breakdown report.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 19655-inward-reports-rename-charge-type-summary-add-bht-level-charge-type-breakdown-detail-report

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f64912fc22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/com/divudi/bean/inward/InwardChargeTypeBreakdownController.java`:
- Around line 633-642: In completeInwardChargeType, getInwardChargeTypeLabel(ct)
can return null leading to NPE when calling label.toLowerCase(); fix by
null-safing the label lookup (e.g., treat null as "" or skip the label-based
check), compute a safe lower-case string (labelLower) before using contains, and
then continue to check ct.name().toLowerCase() — update references in the method
(completeInwardChargeType and getInwardChargeTypeLabel usage) so no direct calls
to toLowerCase() on a possibly null label remain.

In `@src/main/webapp/inward/inward_report_inward_charge_type_breakdown.xhtml`:
- Around line 290-303: The footer is missing the grand total for the "Total"
column; update the final empty <td> in the tfoot row to render the grand total
using a controller property or computed value (e.g., expose
inwardChargeTypeBreakdownController.grandTotal or getGrandTotal()) and format it
with <f:convertNumber minFractionDigits="2" maxFractionDigits="2" /> to match
other column totals; ensure the value corresponds to the per-row rowTotal
aggregation used in the rows so the footer shows the sum of all rowTotal values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 005f8926-9424-42f5-aea2-937b2f9d018b

📥 Commits

Reviewing files that changed from the base of the PR and between 6ce1cd4 and f64912f.

📒 Files selected for processing (7)
  • src/main/java/com/divudi/bean/inward/InwardChargeTypeBreakdownController.java
  • src/main/java/com/divudi/core/data/inward/CalculationMethod.java
  • src/main/java/com/divudi/core/data/inward/InwardChargeType.java
  • src/main/webapp/inward/inward_bill_final_break_down.xhtml
  • src/main/webapp/inward/inward_report_inward_charge_type_breakdown.xhtml
  • src/main/webapp/inward/inward_report_inward_charge_type_detail.xhtml
  • src/main/webapp/inward/inward_reports.xhtml

Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/com/divudi/bean/inward/InwardChargeTypeBreakdownController.java`:
- Around line 191-206: The switch in InwardChargeTypeBreakdownController on
admissionStatus is missing the
AdmissionStatus.DISCHARGED_BUT_FINAL_BILL_NOT_COMPLETED branch; add a case for
DISCHARGED_BUT_FINAL_BILL_NOT_COMPLETED that appends the same predicates as the
DISCHARGED_AND_FINAL_BILL_COMPLETED branch but sets params.put("dis", true) and
params.put("pf", false) (use encAlias when building jpql and the existing params
map) so discharged=true and paymentFinalized=false are applied to the query.
- Around line 488-503: The JPQL in buildFromBillFees() selects BillFee rows for
InwardProfessional bills but lacks the inwardChargeType filter used elsewhere;
update the jpql StringBuilder (in buildFromBillFees) to include "and
bf.billItem.inwardChargeType = :ct" and add the parameter to the params map
(params.put("ct", selectedChargeType)) so the query filters by the currently
selectedChargeType before calling billFeeFacade.findByJpql(...).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bb5f5ea7-f288-43a9-88ca-ff4105ad831f

📥 Commits

Reviewing files that changed from the base of the PR and between e1a9e9f and 8aeccd7.

📒 Files selected for processing (2)
  • src/main/java/com/divudi/bean/inward/BhtPaymentSummaryReportController.java
  • src/main/java/com/divudi/bean/inward/InwardChargeTypeBreakdownController.java

- Null-safe label lookup in completeInwardChargeType (Comment 1)
- Add grandTotal field and expose getter; show grand total in XHTML footer (Comment 2)
- Add DISCHARGED_BUT_FINAL_BILL_NOT_COMPLETED case in appendEncounterFilters (Comment 3)

Closes #19655
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@buddhika75 buddhika75 merged commit 962b84d into development Apr 2, 2026
3 checks passed
@buddhika75 buddhika75 deleted the 19655-inward-reports-rename-charge-type-summary-add-bht-level-charge-type-breakdown-detail-report branch April 2, 2026 22:55
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.

Inward Reports: Rename charge type summary; add BHT-level charge type breakdown detail report

1 participant