Collection center report print pdf excel improvements#19634
Collection center report print pdf excel improvements#19634denuwanhendalage wants to merge 7 commits intodevelopmentfrom
Conversation
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
WalkthroughAdds multi-report export and print support for Collection Center reports: new filter builders, Excel post-processors, PDF preprocessors/exporter in ReportController; updated JSF views to use dynamic filenames and processor hooks; and a new print-only Facelets view rendering printable report and filter summary. Changes
Sequence Diagram(s)sequenceDiagram
participant User as Browser/User
participant View as JSF View
participant ReportCtrl as ReportController
participant Pharmacy as PharmacyController
participant Response as HTTP Response
User->>View: Click "PDF" export / "Print" navigation
alt Print navigation
View->>View: Navigate to print view (render HTML)
View-->>User: Printable HTML (client-side print)
else PDF export
View->>ReportCtrl: exportCollectionCenterReportPrintToPDF()
ReportCtrl->>ReportCtrl: validate patientInvestigations, build filters
ReportCtrl->>Pharmacy: createInfoTablePdfExport(filters)
Pharmacy-->>ReportCtrl: info table (PDF element)
ReportCtrl->>ReportCtrl: build 13-column PDF table from patientInvestigations
ReportCtrl->>Response: write PDF bytes, set Content-Disposition (filename)
Response-->>User: Downloadable PDF
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.42.0)src/main/java/com/divudi/bean/report/ReportController.javaThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/webapp/reports/collectionCenterReports/collection_center_report_print.xhtml (1)
303-310:⚠️ Potential issue | 🟡 MinorRemove the stray
>from the print-preview button.That extra character becomes a text node inside the component body and can leak into the rendered button markup.
🛠️ Proposed fix
- action="collection_center_report_print_view?faces-redirect=true">> + action="collection_center_report_print_view?faces-redirect=true">🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/webapp/reports/collectionCenterReports/collection_center_report_print.xhtml` around lines 303 - 310, The p:commandButton declaration for the print preview (the element with icon="fa-solid fa-print", value="To Print" and action="collection_center_report_print_view?faces-redirect=true") contains a stray ">" after the start tag which creates a text node in the component body; remove that extra ">" so the tag ends cleanly as </p:commandButton> (i.e., ensure there is no extraneous character between the opening tag and the closing tag).
🤖 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/report/ReportController.java`:
- Around line 2517-2523: The current shiftRows call uses 7 rows but
pharmacyController.addMetaDataToExcelSheet(workbook, sheet, 0, "Collection
Center Report Print", filters) can write 8 rows when an institution row is
present; update the sheet.shiftRows(0, sheet.getLastRowNum(), 7) call to shift
by 8 instead so the metadata (institution row + title + filter rows + blank row)
does not overlap subsequent data when getFiltersForCollectionCenterReportPrint()
returns filters.
In
`@src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml`:
- Around line 193-195: The output text is reading
reportController.person.nameWithTitle while the filter binds to
reportController.doctor, causing a mismatch; update the summary binding to use
the same property as the filter (check empty reportController.doctor and render
reportController.doctor.nameWithTitle or fallback to 'All doctors') so both
display and filter use reportController.doctor instead of
reportController.person.
---
Outside diff comments:
In
`@src/main/webapp/reports/collectionCenterReports/collection_center_report_print.xhtml`:
- Around line 303-310: The p:commandButton declaration for the print preview
(the element with icon="fa-solid fa-print", value="To Print" and
action="collection_center_report_print_view?faces-redirect=true") contains a
stray ">" after the start tag which creates a text node in the component body;
remove that extra ">" so the tag ends cleanly as </p:commandButton> (i.e.,
ensure there is no extraneous character between the opening tag and the closing
tag).
🪄 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: 234218de-b7d4-4e68-b34e-3924ad416706
📒 Files selected for processing (3)
src/main/java/com/divudi/bean/report/ReportController.javasrc/main/webapp/reports/collectionCenterReports/collection_center_report_print.xhtmlsrc/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml
src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml
Outdated
Show resolved
Hide resolved
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml`:
- Line 230: Update the UI label in the report header where the h:outputText with
value="Reffered By" is defined by correcting the typo to value="Referred By";
locate the h:outputText element in collection_center_report_print_view.xhtml and
change the string literal to the correct spelling so the displayed column header
reads "Referred By".
- Around line 186-188: The view is binding to #{reportController.phn}, which
doesn't match the ReportController getter and can break EL resolution; change
the EL to the controller's actual MRN/PHN property (e.g., replace occurrences of
reportController.phn with reportController.phnNumber) so the outputText uses the
exact exposed property name; update both the label/value bindings in the
fragment referencing Patient MRN to use reportController.phnNumber (or the exact
getter name from ReportController) to ensure proper EL resolution at render
time.
- Around line 268-270: The report is binding "Order Date" to the investigation
master timestamp (patientInvestigation.investigation.createdAt) which is
incorrect; replace that EL with the patient order timestamp (for example
patientInvestigation.order.createdAt or
patientInvestigation.investigationOrder.createdAt — whichever model property
holds the patient’s order/request timestamp) and keep the existing
f:convertDateTime pattern; if no explicit order timestamp property exists,
fetch/populate and use the patientInvestigation.createdAt (order) field instead
of investigation.createdAt.
🪄 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: 1741198c-387d-4a3b-ba1f-8299279d0495
📒 Files selected for processing (1)
src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml
src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml
Show resolved
Hide resolved
src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml
Outdated
Show resolved
Hide resolved
src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml
Show resolved
Hide resolved
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml (1)
202-245: Add table-level accessible labeling for assistive technologies.The table headers are clear visually, but the table itself has no caption/explicit label. Add a caption (or aria-label) so screen-reader navigation is clearer.
As per coding guidelines: "Implement accessibility with proper tooltips and labeling".♿ Proposed improvement
- <table> + <table aria-label="Collection Center Report Results"> + <caption style="text-align:left; font-weight:600;"> + <h:outputText value="Collection Center Report Results"/> + </caption> <thead>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml` around lines 202 - 245, The table in the diff (the <table> containing header cells with h:outputText values like "S. No", "CC Code", "Leaf No.", etc.) lacks an accessible label; add a visible <caption> (e.g., "Collection Center Report - Print View") or an aria-label/aria-labelledby on that table element so screen readers can announce its purpose, and ensure the caption text matches the table content; if using aria-labelledby, add a hidden heading id near the table and reference it from the table's aria-labelledby attribute.
🤖 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/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml`:
- Around line 287-292: The template dereferences
patientInvestigation.printingUser.name (and prints printingAt) without null
checks, which can cause EL render failures if printingUser or printingAt is
null; update the JSF to guard these values — either wrap the name output in a
rendered="#{not empty patientInvestigation.printingUser}" (or render a
placeholder) or change the value to use a safe EL expression like
"#{patientInvestigation.printingUser != null ?
patientInvestigation.printingUser.name : ''}" and similarly guard
"#{patientInvestigation.printingAt}" (or only render the date converter when not
null) so the components (h:outputText) for printingUser.name and printingAt
cannot dereference null objects.
---
Nitpick comments:
In
`@src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml`:
- Around line 202-245: The table in the diff (the <table> containing header
cells with h:outputText values like "S. No", "CC Code", "Leaf No.", etc.) lacks
an accessible label; add a visible <caption> (e.g., "Collection Center Report -
Print View") or an aria-label/aria-labelledby on that table element so screen
readers can announce its purpose, and ensure the caption text matches the table
content; if using aria-labelledby, add a hidden heading id near the table and
reference it from the table's aria-labelledby attribute.
🪄 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: 14c708e0-445a-4111-b382-1e65d55c49ba
📒 Files selected for processing (1)
src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml
| <h:outputText value="#{patientInvestigation.printingUser.name}" style="margin-left: 1mm;"/> | ||
| </td> | ||
| <td> | ||
| <h:outputText value="#{patientInvestigation.printingAt}" style="margin-left: 1mm;"> | ||
| <f:convertDateTime pattern="#{sessionController.applicationPreference.longDateTimeFormat}"/> | ||
| </h:outputText> |
There was a problem hiding this comment.
Handle nullable print metadata safely to avoid render-time EL failures.
Line 287 dereferences patientInvestigation.printingUser.name directly. If printingUser is null, the row/page can fail to render.
💡 Proposed fix
<td>
- <h:outputText value="#{patientInvestigation.printingUser.name}" style="margin-left: 1mm;"/>
+ <h:outputText value="#{empty patientInvestigation.printingUser ? 'Not Printed' : patientInvestigation.printingUser.name}" style="margin-left: 1mm;"/>
</td>
<td>
- <h:outputText value="#{patientInvestigation.printingAt}" style="margin-left: 1mm;">
+ <h:outputText value="#{patientInvestigation.printingAt}" rendered="#{not empty patientInvestigation.printingAt}" style="margin-left: 1mm;">
<f:convertDateTime pattern="#{sessionController.applicationPreference.longDateTimeFormat}"/>
</h:outputText>
+ <h:outputText value="-" rendered="#{empty patientInvestigation.printingAt}" style="margin-left: 1mm;"/>
</td>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@src/main/webapp/reports/collectionCenterReports/collection_center_report_print_view.xhtml`
around lines 287 - 292, The template dereferences
patientInvestigation.printingUser.name (and prints printingAt) without null
checks, which can cause EL render failures if printingUser or printingAt is
null; update the JSF to guard these values — either wrap the name output in a
rendered="#{not empty patientInvestigation.printingUser}" (or render a
placeholder) or change the value to use a safe EL expression like
"#{patientInvestigation.printingUser != null ?
patientInvestigation.printingUser.name : ''}" and similarly guard
"#{patientInvestigation.printingAt}" (or only render the date converter when not
null) so the components (h:outputText) for printingUser.name and printingAt
cannot dereference null objects.
…ction center wise summary report Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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/report/ReportController.java`:
- Around line 785-789: The PDF header is hardcoded to "Laboratory Workload
Summary Report" in ReportController (the reportTitle Paragraph created with
reportFont), but this pre-processor generates a collection-center-wise summary;
replace the hardcoded string when constructing reportTitle with the
collection-center specific title (e.g., call or build from the collection center
name or a getCollectionCenterReportTitle() method / variable such as
collectionCenter.getName() + " Collection Center Summary Report") so the header
reflects the actual report; keep using reportFont and leave alignment/spacing
and pdf.add(reportTitle) unchanged.
- Around line 2648-2666: The exported header can drift because
getFiltersForCollectionCenterReportPrint() rebuilds filters from current form
fields while patientInvestigations is populated by listCcReportPrint(); fix by
snapshotting the filters when listCcReportPrint() successfully runs and use that
snapshot for exports: add a new field (e.g., Map<String,Object>
processedCcReportFilters) set inside listCcReportPrint() after the query
completes, populate it from the same values currently used in
getFiltersForCollectionCenterReportPrint(), and then change
getFiltersForCollectionCenterReportPrint() to return the snapshot if non-null
(fallback to rebuilding only if snapshot is null) so PDF/Excel output stays
consistent with the processed result set.
- Around line 2735-2742: The PDF rendering currently always uses
bill.getFromInstitution() for CC Code and CC Route which is wrong when the query
matched bill.getCollectingCentre(); update the rendering in ReportController to
resolve a local Centre source first (e.g., Institution centre =
row.getBillItem().getBill().getCollectingCentre() != null ?
row.getBillItem().getBill().getCollectingCentre() :
row.getBillItem().getBill().getFromInstitution()) and then use centre.getCode()
and (centre.getRoute() != null ? centre.getRoute().getName() : "-") when
creating the textCell for CC Code and CC Route; ensure you null-check centre
before calling methods and keep the existing fallback "-" for missing values.
- Around line 751-752: Short sheet names must be used before calling
workbook.setSheetName to avoid POI's 31-char limit; update the calls to
workbook.setSheetName(...) that currently use "Collection Center Wise Summary
Report" and "Collection Center Balance Report" (and the identical calls at the
other location around the second occurrence) to shorter names (e.g., "Collection
Center Summary" and "Collection Center Balance") and then proceed with
sheet.shiftRows(...) as before; ensure you change both occurrences where
setSheetName is invoked so no IllegalArgumentException is thrown.
🪄 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: ce93cda4-0281-47cd-8c6d-1c8c7f3dae60
📒 Files selected for processing (3)
src/main/java/com/divudi/bean/report/ReportController.javasrc/main/webapp/reports/collectionCenterReports/collection_center_balance_report.xhtmlsrc/main/webapp/reports/collectionCenterReports/collection_center_wise_summary_report.xhtml
| workbook.setSheetName(0, "Collection Center Wise Summary Report"); | ||
| sheet.shiftRows(0, sheet.getLastRowNum(), 7); |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
For Apache POI 5.2.5 / XSSFWorkbook.setSheetName, what is the maximum allowed Excel sheet name length, and what exception is thrown when the name exceeds that limit?
💡 Result:
The maximum allowed Excel sheet name length for Apache POI 5.2.5 / XSSFWorkbook.setSheetName is 31 characters. When the name exceeds this limit, an IllegalArgumentException is thrown.
Citations:
- 1: https://poi.apache.org/apidocs/5.0/org/apache/poi/ss/util/WorkbookUtil.html
- 2: https://jar-download.com/artifacts/org.apache.poi/poi/3.17/source-code/org/apache/poi/ss/util/WorkbookUtil.java
- 3: https://poi.apache.org/apidocs/5.0/org/apache/poi/ss/usermodel/Workbook.html
- 4: https://poi.apache.org/apidocs/dev/org/apache/poi/ss/util/WorkbookUtil.html
Shorten these Excel sheet names before calling setSheetName().
Excel/POI rejects sheet names longer than 31 characters. "Collection Center Wise Summary Report" is 37 characters and "Collection Center Balance Report" is 32 characters—both will throw IllegalArgumentException before the metadata rows are added.
Suggested fix
- workbook.setSheetName(0, "Collection Center Wise Summary Report");
+ workbook.setSheetName(0, "CC Wise Summary Report");
…
- workbook.setSheetName(0, "Collection Center Balance Report");
+ workbook.setSheetName(0, "CC Balance Report");Also applies to: 1788-1789
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/java/com/divudi/bean/report/ReportController.java` around lines 751
- 752, Short sheet names must be used before calling workbook.setSheetName to
avoid POI's 31-char limit; update the calls to workbook.setSheetName(...) that
currently use "Collection Center Wise Summary Report" and "Collection Center
Balance Report" (and the identical calls at the other location around the second
occurrence) to shorter names (e.g., "Collection Center Summary" and "Collection
Center Balance") and then proceed with sheet.shiftRows(...) as before; ensure
you change both occurrences where setSheetName is invoked so no
IllegalArgumentException is thrown.
| // ── Report title ────────────────────────────────────────────── | ||
| com.lowagie.text.Paragraph reportTitle = new com.lowagie.text.Paragraph("Laboratory Workload Summary Report", reportFont); | ||
| reportTitle.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); | ||
| reportTitle.setSpacingAfter(2f); | ||
| pdf.add(reportTitle); |
There was a problem hiding this comment.
Use the collection-center report title in the PDF header.
This pre-processor is for the collection center wise summary export, but the generated PDF is titled Laboratory Workload Summary Report. That makes the downloaded file look like the wrong report.
Suggested fix
- com.lowagie.text.Paragraph reportTitle = new com.lowagie.text.Paragraph("Laboratory Workload Summary Report", reportFont);
+ com.lowagie.text.Paragraph reportTitle = new com.lowagie.text.Paragraph("Collection Center Wise Summary Report", reportFont);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/java/com/divudi/bean/report/ReportController.java` around lines 785
- 789, The PDF header is hardcoded to "Laboratory Workload Summary Report" in
ReportController (the reportTitle Paragraph created with reportFont), but this
pre-processor generates a collection-center-wise summary; replace the hardcoded
string when constructing reportTitle with the collection-center specific title
(e.g., call or build from the collection center name or a
getCollectionCenterReportTitle() method / variable such as
collectionCenter.getName() + " Collection Center Summary Report") so the header
reflects the actual report; keep using reportFont and leave alignment/spacing
and pdf.add(reportTitle) unchanged.
| public Map<String, Object> getFiltersForCollectionCenterReportPrint() { | ||
| SimpleDateFormat sdf = new SimpleDateFormat(sessionController.getApplicationPreference().getLongDateTimeFormat()); | ||
| Map<String, Object> filters = new LinkedHashMap<>(); | ||
|
|
||
| filters.put("From Date", sdf.format(getFromDate())); | ||
| filters.put("To Date", sdf.format(getToDate())); | ||
| filters.put("Institution", institution != null ? institution.getName() : "All"); | ||
| filters.put("Site", site != null ? site.getName() : "All"); | ||
| filters.put("Department", department != null ? department.getName() : "All"); | ||
| filters.put("CC Route",route != null ? route.getName() : "All"); | ||
| filters.put("CC Name",collectingCentre != null ? collectingCentre.getName() : "All"); | ||
| filters.put("Category",category != null ? category.getName() : "All"); | ||
| filters.put("Investigation",investigation != null ? investigation.getName() : "All"); | ||
| filters.put("Result status",patientInvestigationStatus != null ? patientInvestigationStatus.getLabel() : "All"); | ||
| filters.put("Patient MRN",phn != null && !phn.trim().isEmpty() ? phn: "All"); | ||
| filters.put("Invoice No.",invoiceNumber != null && !invoiceNumber.trim().isEmpty() ? invoiceNumber : "All"); | ||
| filters.put("Referring Doctor",doctor != null ? doctor.getPerson().getNameWithTitle() : "All"); | ||
| return filters; | ||
| } |
There was a problem hiding this comment.
Export metadata can drift away from the processed result set.
patientInvestigations is session state populated by listCcReportPrint(), but getFiltersForCollectionCenterReportPrint() always rebuilds the header/filter block from the current form values. In src/main/webapp/reports/collectionCenterReports/collection_center_report_print.xhtml, Process and PDF/Excel are separate submits, so changing a filter and exporting without re-processing will produce old rows with a new header/filter summary. Re-run the query on export, or snapshot the processed filters when listCcReportPrint() succeeds and reuse that snapshot for PDF/Excel.
Also applies to: 2668-2710, 2778-2781
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/java/com/divudi/bean/report/ReportController.java` around lines 2648
- 2666, The exported header can drift because
getFiltersForCollectionCenterReportPrint() rebuilds filters from current form
fields while patientInvestigations is populated by listCcReportPrint(); fix by
snapshotting the filters when listCcReportPrint() successfully runs and use that
snapshot for exports: add a new field (e.g., Map<String,Object>
processedCcReportFilters) set inside listCcReportPrint() after the query
completes, populate it from the same values currently used in
getFiltersForCollectionCenterReportPrint(), and then change
getFiltersForCollectionCenterReportPrint() to return the snapshot if non-null
(fallback to rebuilding only if snapshot is null) so PDF/Excel output stays
consistent with the processed result set.
| table.addCell(textCell(row.getBillItem().getBill().getFromInstitution().getCode(),bodyFontSmall)); | ||
| table.addCell(textCell(row.getBillItem().getBill().getReferenceNumber(),bodyFontSmall)); | ||
| table.addCell(textCell(row.getBillItem().getBill().getPatient().getPhn(),bodyFontSmall)); | ||
| table.addCell(textCell(row.getBillItem().getBill().getPatient().getPerson().getNameWithTitle(),bodyFontSmall)); | ||
| table.addCell(textCell(row.getBillItem().getBill().getDeptId(),bodyFontSmall)); | ||
| table.addCell(textCell(row.getInvestigation().getCreatedAt() != null ? sdf.format(row.getInvestigation().getCreatedAt() ) : "-",bodyFontSmall)); | ||
| table.addCell(textCell(row.getBillItem().getBill().getFromInstitution().getRoute()!= null ? row.getBillItem().getBill().getFromInstitution().getRoute().getName() : "-",bodyFontSmall)); | ||
| table.addCell(textCell(row.getBillItem().getBill().getReferredInstituteOrDoctor()!=null ? row.getBillItem().getBill().getReferredInstituteOrDoctor().getName() : "-",bodyFontSmall)); |
There was a problem hiding this comment.
Resolve CC code/route from the same source combination the query uses.
The query at Line 2597 and Line 2605 accepts rows where either bill.collectingCentre or bill.fromInstitution matches the selected centre, but the PDF always renders CC Code and CC Route from bill.fromInstitution. Rows matched through bill.collectingCentre will therefore show the wrong centre, and can also hit a null dereference if fromInstitution is absent.
Suggested fix
+ Institution cc = row.getBillItem().getBill().getCollectingCentre() != null
+ ? row.getBillItem().getBill().getCollectingCentre()
+ : row.getBillItem().getBill().getFromInstitution();
- table.addCell(textCell(row.getBillItem().getBill().getFromInstitution().getCode(),bodyFontSmall));
+ table.addCell(textCell(cc != null ? cc.getCode() : "-", bodyFontSmall));
…
- table.addCell(textCell(row.getBillItem().getBill().getFromInstitution().getRoute()!= null ? row.getBillItem().getBill().getFromInstitution().getRoute().getName() : "-",bodyFontSmall));
+ table.addCell(textCell(cc != null && cc.getRoute() != null ? cc.getRoute().getName() : "-", bodyFontSmall));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/java/com/divudi/bean/report/ReportController.java` around lines 2735
- 2742, The PDF rendering currently always uses bill.getFromInstitution() for CC
Code and CC Route which is wrong when the query matched
bill.getCollectingCentre(); update the rendering in ReportController to resolve
a local Centre source first (e.g., Institution centre =
row.getBillItem().getBill().getCollectingCentre() != null ?
row.getBillItem().getBill().getCollectingCentre() :
row.getBillItem().getBill().getFromInstitution()) and then use centre.getCode()
and (centre.getRoute() != null ? centre.getRoute().getName() : "-") when
creating the textCell for CC Code and CC Route; ensure you null-check centre
before calling methods and keep the existing fallback "-" for missing values.
Improved collection center report print PDF, Excel, and Print Preview
Changed files
Summary by CodeRabbit
New Features
Improvements
Bug Fixes