diff --git a/src/main/java/com/reporting/controller/ReportingController.java b/src/main/java/com/reporting/controller/ReportingController.java index e0d52c8..124e9ee 100644 --- a/src/main/java/com/reporting/controller/ReportingController.java +++ b/src/main/java/com/reporting/controller/ReportingController.java @@ -613,10 +613,11 @@ public class ReportingController { @RequestParam(value = "idRuangan", required = false, defaultValue = "") 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, ModelAndView mv, HttpServletResponse response) throws Exception { // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportVisit(tglAwal, tglAkhir, idDokter, idRuangan); + JasperPrint jasperPrint = this.reportingService.exportVisit(tglAwal, tglAkhir, idDokter, idRuangan, printBy); if ("excel".equalsIgnoreCase(format)) { // Handle Excel export @@ -680,10 +681,54 @@ public class ReportingController { @RequestParam(value = "idRuangan", required = false, defaultValue = "") 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 { // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportWaktuRawatJalan(tglAwal, tglAkhir, idDokter, idRuangan); + JasperPrint jasperPrint = this.reportingService.exportWaktuRawatJalan(tglAwal, tglAkhir, idDokter, idRuangan, printBy); + + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=waktu_rawat_jalan.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=waktu_rawat_jalan.pdf"); + + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } + + + @RequestMapping(value = {"/laporan-kunjungan-pasien"}, method = {RequestMethod.GET}) + public void handleLaporanKunjunganPasienn( + @RequestParam("tglAwal") String tglAwal, + @RequestParam("tglAkhir") String tglAkhir, + @RequestParam(value = "idRuangan", required = false, defaultValue = "") 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 { + + // Generate report (common for both PDF/Excel) + JasperPrint jasperPrint = this.reportingService.exportKunjunganPasien(tglAwal, tglAkhir, idRuangan, printBy); if ("excel".equalsIgnoreCase(format)) { // Handle Excel export @@ -722,10 +767,11 @@ public class ReportingController { @RequestParam(value = "idRuangan", required = false, defaultValue = "") 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 { // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpPendaftaranOnline(tglAwal, tglAkhir, idUnit, idRuangan); + JasperPrint jasperPrint = this.reportingService.exportLpPendaftaranOnline(tglAwal, tglAkhir, idUnit, idRuangan, printBy); if ("excel".equalsIgnoreCase(format)) { // Handle Excel export @@ -767,10 +813,11 @@ public class ReportingController { @RequestParam(value = "idKp", required = false, defaultValue = "") Integer idKp, @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 { // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpVolumeTindakan(tglAwal, tglAkhir, idInstalasi, idRuangan, idProduk, idPegawai, idKp); + JasperPrint jasperPrint = this.reportingService.exportLpVolumeTindakan(tglAwal, tglAkhir, idInstalasi, idRuangan, idProduk, idPegawai, idKp, printBy); if ("excel".equalsIgnoreCase(format)) { // Handle Excel export @@ -806,14 +853,16 @@ public class ReportingController { @RequestParam("tglAwal") String tglAwal, @RequestParam("tglAkhir") String tglAkhir, @RequestParam(value = "idInstalasi", required = false, defaultValue = "") Integer idInstalasi, + @RequestParam(value = "idUnit", required = false, defaultValue = "") Integer idUnit, @RequestParam(value = "idRuangan", required = false, defaultValue = "") Integer idRuangan, @RequestParam(value = "idPegawai", required = false, defaultValue = "") Integer idPegawai, @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 { // Generate report (common for both PDF/Excel) - JasperPrint jasperPrint = this.reportingService.exportLpResumeMedis(tglAwal, tglAkhir, idInstalasi, idRuangan, idPegawai); + JasperPrint jasperPrint = this.reportingService.exportLpResumeMedis(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idPegawai, printBy); if ("excel".equalsIgnoreCase(format)) { // Handle Excel export diff --git a/src/main/java/com/reporting/dao/ReportingDao.java b/src/main/java/com/reporting/dao/ReportingDao.java index c425fd2..b1aefdc 100644 --- a/src/main/java/com/reporting/dao/ReportingDao.java +++ b/src/main/java/com/reporting/dao/ReportingDao.java @@ -1074,7 +1074,7 @@ public class ReportingDao { //Export Excel - public JasperPrint exportVisit(Date tglAwal, Date tglAkhir, Integer idDokter, Integer idRuangan) { + public JasperPrint exportVisit(Date tglAwal, Date tglAkhir, Integer idDokter, Integer idRuangan, String printBy) { try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { String path = jaspersim2DirPath + "visit.jrxml"; JasperReport jasperReport = JasperCompileManager.compileReport(path); @@ -1083,6 +1083,7 @@ public class ReportingDao { parameters.put("tglAkhir", tglAkhir); parameters.put("idDokter", idDokter); parameters.put("idRuangan", idRuangan); + parameters.put("printBy", printBy); return JasperFillManager.fillReport(jasperReport, parameters, conn); } catch (Exception var15) { LOG.error("Exception at exportVisit"); @@ -1091,7 +1092,7 @@ public class ReportingDao { return null; } - public JasperPrint exportWaktuRawatJalan(Date tglAwal, Date tglAkhir, Integer idDokter, Integer idRuangan) { + public JasperPrint exportWaktuRawatJalan(Date tglAwal, Date tglAkhir, Integer idDokter, Integer idRuangan, String printBy) { try (Connection conn = this.jdbcTemplate3.getDataSource().getConnection()) { String path = jaspersim2DirPath + "waktu_rawat_jalan.jrxml"; JasperReport jasperReport = JasperCompileManager.compileReport(path); @@ -1100,6 +1101,7 @@ public class ReportingDao { parameters.put("tglAkhir", tglAkhir); parameters.put("idDokter", idDokter); parameters.put("idRuangan", idRuangan); + parameters.put("printBy", printBy); return JasperFillManager.fillReport(jasperReport, parameters, conn); } catch (Exception var15) { LOG.error("Exception at exportWaktuRawatJalan"); @@ -1108,7 +1110,24 @@ public class ReportingDao { return null; } - public JasperPrint exportLpPendaftaranOnline(Date tglAwal, Date tglAkhir, Integer idUnit, Integer idRuangan) { + public JasperPrint exportKunjunganPasien(Date tglAwal, Date tglAkhir, Integer idRuangan, String printBy) { + try (Connection conn = this.jdbcTemplate3.getDataSource().getConnection()) { + String path = jaspersim2DirPath + "kunjungan_pasien.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + parameters.put("tglAwal", tglAwal); + parameters.put("tglAkhir", tglAkhir); + parameters.put("idRuangan", idRuangan); + parameters.put("printBy", printBy); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exportKunjunganPasien"); + 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()) { String path = jaspersim2DirPath + "Laporan_pemanfaatan_pendaftaran.jrxml"; JasperReport jasperReport = JasperCompileManager.compileReport(path); @@ -1117,6 +1136,7 @@ public class ReportingDao { parameters.put("tglAkhir", tglAkhir); 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 exportLpPendaftaranOnline"); @@ -1125,7 +1145,7 @@ public class ReportingDao { return null; } - public JasperPrint exportLpVolumeTindakan(Date tglAwal, Date tglAkhir, Integer idInstalasi, Integer idRuangan, Integer idProduk, Integer idPegawai, Integer idKp) { + public JasperPrint exportLpVolumeTindakan(Date tglAwal, Date tglAkhir, Integer idInstalasi, Integer idRuangan, Integer idProduk, Integer idPegawai, Integer idKp, String printBy) { try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { String path = jaspersim2DirPath + "laporan_volume_tindakan_pasien.jrxml"; JasperReport jasperReport = JasperCompileManager.compileReport(path); @@ -1137,6 +1157,7 @@ public class ReportingDao { parameters.put("idProduk", idProduk); parameters.put("idPegawai", idPegawai); parameters.put("idKp", idKp); + parameters.put("printBy", printBy); return JasperFillManager.fillReport(jasperReport, parameters, conn); } catch (Exception var15) { LOG.error("Exception at exportLpVolumeTindakan"); @@ -1145,7 +1166,7 @@ public class ReportingDao { return null; } - public JasperPrint exportLpResumeMedis(Date tglAwal, Date tglAkhir, Integer idInstalasi, Integer idRuangan, Integer idPegawai) { + public JasperPrint exportLpResumeMedis(Date tglAwal, Date tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, Integer idPegawai, String printBy) { try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { String path = jaspersim2DirPath + "LaporanResumeMedis.jrxml"; JasperReport jasperReport = JasperCompileManager.compileReport(path); @@ -1153,8 +1174,10 @@ public class ReportingDao { parameters.put("tglAwal", tglAwal); parameters.put("tglAkhir", tglAkhir); parameters.put("idInstalasi", idInstalasi); + parameters.put("idUnit", idUnit); parameters.put("idRuangan", idRuangan); parameters.put("idPegawai", idPegawai); + parameters.put("printBy", printBy); return JasperFillManager.fillReport(jasperReport, parameters, conn); } catch (Exception var15) { LOG.error("Exception at exportLpResumeMedis"); diff --git a/src/main/java/com/reporting/service/ReportingService.java b/src/main/java/com/reporting/service/ReportingService.java index 1469823..19db5d3 100644 --- a/src/main/java/com/reporting/service/ReportingService.java +++ b/src/main/java/com/reporting/service/ReportingService.java @@ -312,12 +312,12 @@ public class ReportingService { // Export Excel - public JasperPrint exportVisit(String tglAwal, String tglAkhir, Integer idDokter, Integer idRuangan) { + public JasperPrint exportVisit(String tglAwal, String tglAkhir, Integer idDokter, Integer idRuangan, String printBy) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date parse = formatter.parse(tglAwal); Date parse2 = formatter.parse(tglAkhir); - return this.reportingDao.exportVisit(parse, parse2, idDokter, idRuangan); + return this.reportingDao.exportVisit(parse, parse2, idDokter, idRuangan, printBy); } catch (ParseException e) { log.error(e.getMessage()); @@ -325,12 +325,12 @@ public class ReportingService { } } - public JasperPrint exportWaktuRawatJalan(String tglAwal, String tglAkhir, Integer idDokter, Integer idRuangan) { + public JasperPrint exportWaktuRawatJalan(String tglAwal, String tglAkhir, Integer idDokter, Integer idRuangan, String printBy) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date parse = formatter.parse(tglAwal); Date parse2 = formatter.parse(tglAkhir); - return this.reportingDao.exportWaktuRawatJalan(parse, parse2, idDokter, idRuangan); + return this.reportingDao.exportWaktuRawatJalan(parse, parse2, idDokter, idRuangan, printBy); } catch (ParseException e) { log.error(e.getMessage()); @@ -338,12 +338,12 @@ public class ReportingService { } } - public JasperPrint exportLpPendaftaranOnline(String tglAwal, String tglAkhir, Integer idUnit, Integer idRuangan) { + public JasperPrint exportKunjunganPasien(String tglAwal, String tglAkhir, Integer idRuangan, String printBy) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date parse = formatter.parse(tglAwal); Date parse2 = formatter.parse(tglAkhir); - return this.reportingDao.exportLpPendaftaranOnline(parse, parse2, idUnit, idRuangan); + return this.reportingDao.exportKunjunganPasien(parse, parse2, idRuangan, printBy); } catch (ParseException e) { log.error(e.getMessage()); @@ -351,12 +351,12 @@ public class ReportingService { } } - public JasperPrint exportLpVolumeTindakan(String tglAwal, String tglAkhir, Integer idInstalasi, Integer idRuangan, Integer idProduk, Integer idPegawai, Integer idKp) { + public JasperPrint exportLpPendaftaranOnline(String tglAwal, String tglAkhir, Integer idUnit, Integer idRuangan, String printBy) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date parse = formatter.parse(tglAwal); Date parse2 = formatter.parse(tglAkhir); - return this.reportingDao.exportLpVolumeTindakan(parse, parse2, idInstalasi, idRuangan, idProduk, idPegawai, idKp); + return this.reportingDao.exportLpPendaftaranOnline(parse, parse2, idUnit, idRuangan, printBy); } catch (ParseException e) { log.error(e.getMessage()); @@ -364,12 +364,25 @@ public class ReportingService { } } - public JasperPrint exportLpResumeMedis(String tglAwal, String tglAkhir, Integer idInstalasi, Integer idRuangan, Integer idPegawai) { + public JasperPrint exportLpVolumeTindakan(String tglAwal, String tglAkhir, Integer idInstalasi, Integer idRuangan, Integer idProduk, Integer idPegawai, Integer idKp, String printBy) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date parse = formatter.parse(tglAwal); Date parse2 = formatter.parse(tglAkhir); - return this.reportingDao.exportLpResumeMedis(parse, parse2, idInstalasi, idRuangan, idPegawai); + return this.reportingDao.exportLpVolumeTindakan(parse, parse2, idInstalasi, idRuangan, idProduk, idPegawai, idKp, printBy); + } catch (ParseException e) { + log.error(e.getMessage()); + + return null; + } + } + + public JasperPrint exportLpResumeMedis(String tglAwal, String tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, Integer idPegawai, String printBy) { + try { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + Date parse = formatter.parse(tglAwal); + Date parse2 = formatter.parse(tglAkhir); + return this.reportingDao.exportLpResumeMedis(parse, parse2, idInstalasi, idUnit, idRuangan, idPegawai, printBy); } catch (ParseException e) { log.error(e.getMessage());