up laporan pasien pulang

This commit is contained in:
ridwan 2026-01-06 11:06:33 +07:00
parent 1395da9441
commit b90d647edd
3 changed files with 85 additions and 4 deletions

View File

@ -172,8 +172,9 @@ public class ReportingController {
}
@RequestMapping(value = {"/lap-bedah"}, method = {RequestMethod.GET})
public void exportLapBedahPasien(@RequestParam("noregis") String noregis,
ModelAndView mv, HttpServletResponse response) throws Exception {
public void exportLapBedahPasien(
@RequestParam("noregis") String noregis,
ModelAndView mv, HttpServletResponse response) throws Exception {
JasperPrint jasperPrint = null;
try {
jasperPrint = this.reportingService.printReportLapBedah(noregis);
@ -1662,4 +1663,52 @@ public class ReportingController {
}
}
@RequestMapping(value = {"/laporan-pasien-pulang"}, method = {RequestMethod.GET})
public void handleLpPasienPulang(
@RequestParam("tglAwal") String tglAwal,
@RequestParam("tglAkhir") String tglAkhir,
@RequestParam(value = "unitKerja", required = false, defaultValue = "") Integer unitKerja,
@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 {
JasperPrint jasperPrint = null;
try {
// Generate report (common for both PDF/Excel)
jasperPrint = this.reportingService.exportLpPasienPulang(tglAwal, tglAkhir, unitKerja, idruangan, printBy);
if ("excel".equalsIgnoreCase(format)) {
// Handle Excel export
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=Laporan_Pasien_Pulang.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_Pasien_Pulang.pdf");
JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));
exporter.exportReport();
}
} finally {
jasperPrint = null;
}
}
}

View File

@ -1389,4 +1389,23 @@ public class ReportingDao {
return null;
}
public JasperPrint exportLpPasienPulang(Timestamp tglAwal, Timestamp tglAkhir, Integer unitKerja, Integer idruangan, String printBy) {
try (Connection conn = this.jdbcTemplate1.getDataSource().getConnection()) {
String path = jasperDirPath + "laporan_pasien_pulang.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(path);
Map<String, Object> parameters = new HashMap<>();
parameters.put("tglAwal", tglAwal);
parameters.put("tglAkhir", tglAkhir);
parameters.put("unitKerja", unitKerja);
parameters.put("idruangan", idruangan);
parameters.put("printBy", printBy);
return JasperFillManager.fillReport(jasperReport, parameters, conn);
} catch (Exception var15) {
LOG.error("Exception at exportLpPasienPulang");
LOG.error(ReportingDao.class, var15);
}
return null;
}
}

View File

@ -65,8 +65,8 @@ public class ReportingService {
return this.reportingDao.exportPdfKartuPasien(nocm);
}
public JasperPrint printReportLapBedah(String noregis) {
log.info("Starting printReportLapBedah with noregis: {}", noregis);
public JasperPrint printReportLapBedah(String noregis ) {
log.info("Starting printReportLapBedah with noregis: {}",noregis);
return this.reportingDao.exportPdfLapBedah(noregis);
}
@ -474,4 +474,17 @@ public class ReportingService {
}
}
public JasperPrint exportLpPasienPulang(String tglAwal, String tglAkhir, Integer unitKerja, Integer idruangan, String printBy) {
log.info("Starting exportLpPendapatanPoli with tglAwal: {}, tglAkhir: {}, unitKerja: {}, idruangan: {}, printBy: {}", tglAwal, tglAkhir, unitKerja, idruangan, printBy);
try {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Timestamp parse = new Timestamp(formatter.parse(tglAwal).getTime());
Timestamp parse2 = new Timestamp(formatter.parse(tglAkhir).getTime());
return this.reportingDao.exportLpPasienPulang(parse, parse2, unitKerja, idruangan, printBy);
} catch (ParseException e) {
log.error(e.getMessage());
return null;
}
}
}