diff --git a/src/main/java/com/reporting/controller/ReportingController.java b/src/main/java/com/reporting/controller/ReportingController.java index e4441e5..8126c85 100644 --- a/src/main/java/com/reporting/controller/ReportingController.java +++ b/src/main/java/com/reporting/controller/ReportingController.java @@ -1357,6 +1357,148 @@ public class ReportingController { } } + @RequestMapping(value = {"/laporan-rekap-resep-pasien-dokter"}, method = {RequestMethod.GET}) + public void handleLaporanRekapResepPasienDokter( + @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(value = "idRuangan", required = false, defaultValue = "") Integer idRuangan, + @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 { + + JasperPrint jasperPrint = null; + try { + // Generate report (common for both PDF/Excel) + jasperPrint = this.reportingService.exportRekapResepPasienDokter(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idKp, printBy); + + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Rekap_Resep_Pasien_Dokter.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_Rekap_Resep_Pasien_Dokter.pdf"); + + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; + } + } + + @RequestMapping(value = {"/laporan-rekap-kunjungan-pasien-rad"}, method = {RequestMethod.GET}) + public void handleLaporanRekapKunjunganPasienRad( + @RequestParam("tglAwal") Timestamp tglAwal, + @RequestParam("tglAkhir") Timestamp tglAkhir, + @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.exportRekapKunjunganPasienRadiologi(tglAwal, tglAkhir, printBy); + + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Rekap_Kunjungan_Pasien_Radiologi.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_Rekap_Kunjungan_Pasien_Radiologi.pdf"); + + JRPdfExporter exporter = new JRPdfExporter(); + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream())); + exporter.exportReport(); + } + } finally { + jasperPrint = null; + } + } + + @RequestMapping(value = {"/laporan-rekap-kunjungan-pasien-lab"}, method = {RequestMethod.GET}) + public void handleLaporanRekapKunjunganPasienLab( + @RequestParam("tglAwal") Timestamp tglAwal, + @RequestParam("tglAkhir") Timestamp tglAkhir, + @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.exportRekapKunjunganPasienLab(tglAwal, tglAkhir, printBy); + + if ("excel".equalsIgnoreCase(format)) { + // Handle Excel export + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename=Laporan_Rekap_Kunjungan_Pasien_Laboratorium.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_Rekap_Kunjungan_Pasien_Laboratorium.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 878a407..c4015df 100644 --- a/src/main/java/com/reporting/dao/ReportingDao.java +++ b/src/main/java/com/reporting/dao/ReportingDao.java @@ -1262,6 +1262,58 @@ public class ReportingDao { return null; } + public JasperPrint exportRekapResepPasienDokter(Timestamp tglAwal, Timestamp tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, Integer idKp, String printBy) { + try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { + String path = jaspersim2DirPath + "laporan_rekap_resep_pasien_dokter.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("idKp", idKp); + parameters.put("printBy", printBy); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exportRekapResepPasienDokter"); + LOG.error(ReportingDao.class, var15); + } + return null; + } + + public JasperPrint exportRekapKunjunganPasienRadiologi(Timestamp tglAwal, Timestamp tglAkhir, String printBy) { + try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { + String path = jaspersim2DirPath + "kunjungan_pasien_keradiologi.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + parameters.put("tglAwal", tglAwal); + parameters.put("tglAkhir", tglAkhir); + parameters.put("printBy", printBy); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exportRekapKunjunganPasienRadiologi"); + LOG.error(ReportingDao.class, var15); + } + return null; + } + + public JasperPrint exportRekapKunjunganPasienLab(Timestamp tglAwal, Timestamp tglAkhir, String printBy) { + try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) { + String path = jaspersim2DirPath + "kunjungan_pasien_kelab.jrxml"; + JasperReport jasperReport = JasperCompileManager.compileReport(path); + Map parameters = new HashMap<>(); + parameters.put("tglAwal", tglAwal); + parameters.put("tglAkhir", tglAkhir); + parameters.put("printBy", printBy); + return JasperFillManager.fillReport(jasperReport, parameters, conn); + } catch (Exception var15) { + LOG.error("Exception at exportRekapKunjunganPasienLab"); + 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 dcb4a2f..5036646 100644 --- a/src/main/java/com/reporting/service/ReportingService.java +++ b/src/main/java/com/reporting/service/ReportingService.java @@ -405,6 +405,21 @@ public class ReportingService { return this.reportingDao.exportKunjunganRawatJalanH(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, printBy); } + public JasperPrint exportRekapResepPasienDokter(Timestamp tglAwal, Timestamp tglAkhir, Integer idInstalasi, Integer idUnit, Integer idRuangan, Integer idKp, String printBy) { + log.info("Starting exportRekapResepPasienDokter with tglAwal: {}, tglAkhir: {}, idInstalasi: {}, idUnit: {}, idRuangan: {}, printBy: {}", tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idKp, printBy); + return this.reportingDao.exportRekapResepPasienDokter(tglAwal, tglAkhir, idInstalasi, idUnit, idRuangan, idKp, printBy); + } + + public JasperPrint exportRekapKunjunganPasienRadiologi(Timestamp tglAwal, Timestamp tglAkhir, String printBy) { + log.info("Starting exportRekapKunjunganPasienRadiologi with tglAwal: {}, tglAkhir: {}, printBy: {}", tglAwal, tglAkhir, printBy); + return this.reportingDao.exportRekapKunjunganPasienRadiologi(tglAwal, tglAkhir, printBy); + } + + public JasperPrint exportRekapKunjunganPasienLab(Timestamp tglAwal, Timestamp tglAkhir, String printBy) { + log.info("Starting exportRekapKunjunganPasienLab with tglAwal: {}, tglAkhir: {}, printBy: {}", tglAwal, tglAkhir, printBy); + return this.reportingDao.exportRekapKunjunganPasienLab(tglAwal, tglAkhir, 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 {