From 05d5248514d9c976bb63aee4368ba6ac3daf40bd Mon Sep 17 00:00:00 2001 From: imexh Date: Fri, 20 Dec 2024 10:49:01 +0530 Subject: [PATCH 1/2] UI Refactor --- ...ction_center_bill_wise_detail_report.xhtml | 99 +++++++++---------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/src/main/webapp/reports/collectionCenterReports/collection_center_bill_wise_detail_report.xhtml b/src/main/webapp/reports/collectionCenterReports/collection_center_bill_wise_detail_report.xhtml index e04eb06e47..9eb87bf227 100644 --- a/src/main/webapp/reports/collectionCenterReports/collection_center_bill_wise_detail_report.xhtml +++ b/src/main/webapp/reports/collectionCenterReports/collection_center_bill_wise_detail_report.xhtml @@ -14,7 +14,6 @@ - @@ -290,55 +289,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f02a4bbe0fa1beb2842761556fc830506ce6d6c9 Mon Sep 17 00:00:00 2001 From: imexh Date: Mon, 23 Dec 2024 16:10:47 +0530 Subject: [PATCH 2/2] Collection Center Bill Wise Detail Report #9680 --- .../divudi/bean/common/ReportsController.java | 162 +++++++++++++- ...ction_center_bill_wise_detail_report.xhtml | 197 +++++++++--------- 2 files changed, 259 insertions(+), 100 deletions(-) diff --git a/src/main/java/com/divudi/bean/common/ReportsController.java b/src/main/java/com/divudi/bean/common/ReportsController.java index 288fd1cd20..514666b52c 100644 --- a/src/main/java/com/divudi/bean/common/ReportsController.java +++ b/src/main/java/com/divudi/bean/common/ReportsController.java @@ -30,15 +30,26 @@ import com.divudi.light.common.BillSummaryRow; import com.divudi.service.BillService; import com.divudi.service.PatientInvestigationService; +import com.itextpdf.text.Document; +import com.itextpdf.text.FontFactory; +import com.itextpdf.text.Paragraph; +import com.itextpdf.text.Phrase; +import com.itextpdf.text.pdf.PdfPCell; +import com.itextpdf.text.pdf.PdfPTable; +import com.itextpdf.text.pdf.PdfWriter; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.primefaces.model.StreamedContent; -import org.primefaces.model.charts.line.LineChartModel; import org.primefaces.model.file.UploadedFile; import javax.ejb.EJB; import javax.enterprise.context.SessionScoped; +import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.persistence.TemporalType; +import javax.servlet.http.HttpServletResponse; import java.io.*; import java.time.YearMonth; import java.time.LocalDate; @@ -390,6 +401,7 @@ public String getSelectedDateType() { public void setSelectedDateType(String selectedDateType) { this.selectedDateType = selectedDateType; + } public Investigation getInvestigation() { return investigation; @@ -3774,4 +3786,152 @@ public ReportTemplateRowBundle generateDiscountBillItems(List bt b.calculateTotalsWithCredit(); return b; } + + public void exportCollectionCenterBillWiseDetailReportToPDF() { + FacesContext context = FacesContext.getCurrentInstance(); + HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); + + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "attachment; filename=Collection_Center_Report.pdf"); + + try (OutputStream out = response.getOutputStream()) { + Document document = new Document(); + PdfWriter.getInstance(document, out); + + document.open(); + + document.add(new Paragraph("Collection Center Bill Wise Detail Report", + FontFactory.getFont(FontFactory.HELVETICA_BOLD, 18))); + + PdfPTable table = new PdfPTable(7); + float[] columnWidths = {1f, 1f, 1f, 1f, 1f, 1f, 3f}; + table.setWidths(columnWidths); + table.setWidthPercentage(100); + + table.addCell("CC Code"); + table.addCell("Leaf No."); + table.addCell("MRN"); + table.addCell("Patient Name"); + table.addCell("Invoice Date"); + table.addCell("Invoice No"); + table.addCell("Details"); + + for (Map.Entry> entry : bundle.getGroupedBillItems().entrySet()) { + List billItems = entry.getValue(); + + if (billItems == null || billItems.isEmpty()) { + table.addCell("N/A"); + table.addCell("N/A"); + table.addCell("N/A"); + table.addCell("N/A"); + table.addCell("N/A"); + table.addCell(entry.getKey()); + PdfPCell emptyCell = new PdfPCell(new Phrase("No Details Available")); + emptyCell.setColspan(7); + table.addCell(emptyCell); + continue; + } + + BillItem firstItem = billItems.get(0); + + table.addCell(firstItem.getBill().getCollectingCentre().getCode()); + table.addCell(firstItem.getBill().getReferenceNumber()); + table.addCell(firstItem.getBill().getPatient().getPhn()); + table.addCell(firstItem.getBill().getPatient().getPerson().getName()); + table.addCell(firstItem.getBill().getCreatedAt().toString()); + table.addCell(entry.getKey()); + + PdfPTable detailsTable = new PdfPTable(5); + float[] columnWidthsInner = {2f, 1f, 1f, 1f, 1f}; + detailsTable.setWidths(columnWidthsInner); + + detailsTable.addCell("Service Name"); + detailsTable.addCell("Hos Fee"); + detailsTable.addCell("Staff Fee"); + detailsTable.addCell("CC Fee"); + detailsTable.addCell("Net Amount"); + + for (BillItem bi : billItems) { + detailsTable.addCell(bi.getItem().getName()); + detailsTable.addCell(String.valueOf(bi.getHospitalFee())); + detailsTable.addCell(String.valueOf(bi.getStaffFee())); + detailsTable.addCell(String.valueOf(bi.getCollectingCentreFee())); + detailsTable.addCell(String.valueOf(bi.getNetValue())); + } + PdfPCell nestedCell = new PdfPCell(detailsTable); + nestedCell.setColspan(7); + table.addCell(nestedCell); + } + + document.add(table); + document.close(); + context.responseComplete(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void exportCollectionCenterBillWiseDetailReportToExcel() { + FacesContext context = FacesContext.getCurrentInstance(); + HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); + + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Collection_Center_Report.xlsx"); + + try (XSSFWorkbook workbook = new XSSFWorkbook(); + OutputStream out = response.getOutputStream()) { + + XSSFSheet sheet = workbook.createSheet("Report"); + int rowIndex = 0; + + Row headerRow = sheet.createRow(rowIndex++); + headerRow.createCell(0).setCellValue("CC Code"); + headerRow.createCell(1).setCellValue("Leaf No."); + headerRow.createCell(2).setCellValue("MRN"); + headerRow.createCell(3).setCellValue("Patient Name"); + headerRow.createCell(4).setCellValue("Invoice Date"); + headerRow.createCell(5).setCellValue("Invoice No"); + headerRow.createCell(6).setCellValue("Details"); + + for (Map.Entry> entry : bundle.getGroupedBillItems().entrySet()) { + List billItems = entry.getValue(); + + if (billItems == null || billItems.isEmpty()) { + Row emptyRow = sheet.createRow(rowIndex++); + emptyRow.createCell(0).setCellValue("N/A"); + emptyRow.createCell(1).setCellValue("N/A"); + emptyRow.createCell(2).setCellValue("N/A"); + emptyRow.createCell(3).setCellValue("N/A"); + emptyRow.createCell(4).setCellValue("N/A"); + emptyRow.createCell(5).setCellValue(entry.getKey()); + emptyRow.createCell(6).setCellValue("No Details Available"); + continue; + } + + BillItem firstItem = billItems.get(0); + Row row = sheet.createRow(rowIndex++); + + row.createCell(0).setCellValue(firstItem.getBill().getCollectingCentre().getCode()); + row.createCell(1).setCellValue(firstItem.getBill().getReferenceNumber()); + row.createCell(2).setCellValue(firstItem.getBill().getPatient().getPhn()); + row.createCell(3).setCellValue(firstItem.getBill().getPatient().getPerson().getName()); + row.createCell(4).setCellValue(firstItem.getBill().getCreatedAt().toString()); + row.createCell(5).setCellValue(entry.getKey()); + + for (BillItem bi : billItems) { + Row detailRow = sheet.createRow(rowIndex++); + detailRow.createCell(6).setCellValue(bi.getItem().getName()); + detailRow.createCell(7).setCellValue(bi.getHospitalFee()); + detailRow.createCell(8).setCellValue(bi.getStaffFee()); + detailRow.createCell(9).setCellValue(bi.getCollectingCentreFee()); + detailRow.createCell(10).setCellValue(bi.getNetValue()); + } + } + + workbook.write(out); + context.responseComplete(); + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/src/main/webapp/reports/collectionCenterReports/collection_center_bill_wise_detail_report.xhtml b/src/main/webapp/reports/collectionCenterReports/collection_center_bill_wise_detail_report.xhtml index 9eb87bf227..1ed0e563c9 100644 --- a/src/main/webapp/reports/collectionCenterReports/collection_center_bill_wise_detail_report.xhtml +++ b/src/main/webapp/reports/collectionCenterReports/collection_center_bill_wise_detail_report.xhtml @@ -206,18 +206,30 @@ style="width: 150px" ajax="false" value="Print"> - + + + + + @@ -226,10 +238,20 @@ icon="fa-solid fa-file-pdf" style="width: 150px" ajax="false" + action="#{reportsController.exportCollectionCenterBillWiseDetailReportToPDF()}" + rendered="#{reportsController.reportType eq 'Report'}" + value="PDF"> + + + @@ -247,99 +269,76 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Collection Center Bill Wise Detail Report +
CC CodeLeaf No.MRNPatient NameInvoice DateInvoice NoDetails
#{entry.value[0].bill.collectingCentre.code}#{entry.value[0].bill.referenceNumber}#{entry.value[0].bill.patient.phn}#{entry.value[0].bill.patient.person.name} + #{entry.value[0].bill.createdAt} + #{entry.key} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Service NameHos Fee.Staff Fee.CC Fee.Net Amount
#{bi.item.name}#{bi.hospitalFee}#{bi.staffFee}#{bi.collectingCentreFee}#{bi.netValue}
Total#{entry.value[0].bill.totalHospitalFee}#{entry.value[0].bill.totalStaffFee}#{entry.value[0].bill.totalCenterFee}#{entry.value[0].bill.netTotal}
+
+