Skip to content

Commit

Permalink
OP-1348 | Fix error on Laboratory report (#1468)
Browse files Browse the repository at this point in the history
* update file step_a104_add_inventory_in_pharmacy.sql

* update src/main/java/org/isf/serviceprinting/manager/PrintLabels.java

* Remove unused LOGGER

---------

Co-authored-by: ArnaudFofou <gui.fofou@umi2growcameroun.com>
Co-authored-by: Alessandro Domanico <alessandro.domanico@yahoo.it>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent 1337aa1 commit 125822a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion sql/step_a104_add_inventory_in_pharmacy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CREATE TABLE OH_MEDICALDSRINVENTORY (
MINVT_US_ID_A varchar (50) NOT NULL,
MINVT_REFERENCE varchar (50) NOT NULL,
MINVT_TYPE varchar(30) NOT NULL,
MINVT_WRD_ID_A varchar(1) NULL,
MINVT_WRD_ID_A char(3) NULL,
MINVT_CHARGE_TYPE varchar(10) NULL,
MINVT_DISCHARGE_TYPE varchar(10) NULL,
MINVT_SUPPLIER int NULL,
Expand Down
46 changes: 18 additions & 28 deletions src/main/java/org/isf/serviceprinting/manager/PrintLabels.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,31 @@
import java.util.Map;

import org.isf.utils.db.DbSingleJpaConn;
import org.isf.utils.exception.OHServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.isf.utils.exception.OHException;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperPrintManager;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;

public class PrintLabels {

private static final Logger LOGGER = LoggerFactory.getLogger(PrintLabels.class);

public PrintLabels(String filename, Integer patId) throws OHServiceException {
try {
Map<String, Object> parameters = new HashMap<>();

parameters.put("patientID", String.valueOf(patId == null ? "" : patId));

StringBuilder sbFilename = new StringBuilder();
sbFilename.append("rpt_base");
sbFilename.append(File.separator);

sbFilename.append(filename);
sbFilename.append(".jasper");
File jasperFile = new File(sbFilename.toString());
Connection conn = DbSingleJpaConn.getConnection();
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(jasperFile);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
JasperPrintManager.printReport(jasperPrint, true);

} catch (Exception exception) {
LOGGER.error(exception.getMessage(), exception);
}

public PrintLabels(String filename, Integer patId) throws OHException, JRException {
Map<String, Object> parameters = new HashMap<>();

parameters.put("patientID", String.valueOf(patId == null ? "" : patId));

StringBuilder sbFilename = new StringBuilder();
sbFilename.append("rpt_base");
sbFilename.append(File.separator);

sbFilename.append(filename);
sbFilename.append(".jasper");
File jasperFile = new File(sbFilename.toString());
Connection conn = DbSingleJpaConn.getConnection();
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(jasperFile);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
JasperPrintManager.printReport(jasperPrint, true);
}
}

0 comments on commit 125822a

Please sign in to comment.