diff --git a/src/main/java/com/reporting/controller/ReportingController.java b/src/main/java/com/reporting/controller/ReportingController.java index 161a868..e4441e5 100644 --- a/src/main/java/com/reporting/controller/ReportingController.java +++ b/src/main/java/com/reporting/controller/ReportingController.java @@ -1308,6 +1308,55 @@ public class ReportingController { } } + @RequestMapping(value = {"/laporan-rawat-jalan-perhari"}, method = {RequestMethod.GET}) + public void handleLaporanKunjunganRawatJalanH( + @RequestParam("tglAwal") Timestamp tglAwal, + @RequestParam("tglAkhir") Timestamp tglAkhir, + @RequestParam(value = "idInstalasi", required = false, defaultValue = "") Integer idInstalasi, + @RequestParam(value = "idUnit", required = false, defaultValue = "") Integer idUnit, + @RequestParam("idRuangan") Integer idRuangan, + @RequestParam(value = "format", required = false, defaultValue = "pdf") String format, + @RequestParam(value = "mode", required = false, defaultValue = "download") String mode, + @RequestParam(value = "printBy", required = false, defaultValue = "") String printBy, + HttpServletResponse response) throws Exception { + + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportKunjunganRawatJalanH(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, printBy); + + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Kunjungan_Rawat_Jalan_PerHari.xlsx"); + + JRXlsxExporter exporter = new JRXlsxExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + SimpleXlsxReportConfiguration config = new SimpleXlsxReportConfiguration(); + config.setOnePagePerSheet(false); + config.setDetectCellType(true); + config.setCollapseRowSpan(false); + config.setRemoveEmptySpaceBetweenRows(true); + config.setWhitePageBackground(false); + exporter.setConfiguration(config); + exporter.exportReport(); + + } else { + // Handle PDF preview + response.setContentType("application/pdf"); + response.setHeader("Content-Disposition", "inline; filename=Laporan_Kunjungan_Rawat_Jalan_PerHari.pdf"); + + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; + } + } + @RequestMapping(value = {"/laporan-pendaftaran-online"}, method = {RequestMethod.GET}) public void handleLpPendaftaranOnline( @RequestParam("tglAwal") String tglAwal, diff --git a/src/main/java/com/reporting/dao/ReportingDao.java b/src/main/java/com/reporting/dao/ReportingDao.java index f9c7cc6..878a407 100644 --- a/src/main/java/com/reporting/dao/ReportingDao.java +++ b/src/main/java/com/reporting/dao/ReportingDao.java @@ -1243,6 +1243,25 @@ public class ReportingDao { return null; } + public JasperPrint exportKunjunganRawatJalanH(Timestamp tglAwal, Timestamp tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, String printBy) { + try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { + String path = jaspersim2DirPath + "Laporan_kunjungan_rawat_jalan_perhari.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + parameters.put("tglAwal", tglAwal); + parameters.put("tglAkhir", tglAkhir); + parameters.put("idInstalasi", idInstalasi); + parameters.put("idUnit", idUnit); + parameters.put("idRuangan", idRuangan); + parameters.put("printBy", printBy); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exportKunjunganRawatJalanH"); + LOG.error(ReportingDao.class, var15); + } + return null; + } + public JasperPrint exportLpPendaftaranOnline(Date tglAwal, Date tglAkhir, Integer idUnit, Integer idRuangan, String printBy) { try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { diff --git a/src/main/java/com/reporting/service/ReportingService.java b/src/main/java/com/reporting/service/ReportingService.java index 9de9a60..dcb4a2f 100644 --- a/src/main/java/com/reporting/service/ReportingService.java +++ b/src/main/java/com/reporting/service/ReportingService.java @@ -400,6 +400,11 @@ public class ReportingService { return this.reportingDao.exportRekapResepPasien(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idKp, printBy); } + public JasperPrint exportKunjunganRawatJalanH(Timestamp tglAwal, Timestamp tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, String printBy) { + log.info("Starting exportRekapResepPasien with tglAwal: {}, tglAkhir: {}, idInstalasi: {}, idUnit: {}, idRuangan: {}, printBy: {}", tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, printBy); + return this.reportingDao.exportKunjunganRawatJalanH(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, printBy); + } + public JasperPrint exportLpPendaftaranOnline(String tglAwal, String tglAkhir, Integer idUnit, Integer idRuangan, String printBy) { log.info("Starting exportLpPendaftaranOnline with tglAwal: {}, tglAkhir: {}, idUnit: {}, idRuangan: {}, printBy: {}", tglAwal, tglAkhir, idUnit, idRuangan, printBy); try {