use of org.openmrs.module.mirebalais.printer.template.ZplCardTemplate in project openmrs-module-mirebalais by PIH.
the class ZlEmrIdCardPrinter method print.
/**
* Prints a ZL EMR ID Card for the given patient at the given location
*/
public void print(Patient patient, Location location) throws UnableToPrintException {
Location issuingLocation;
try {
issuingLocation = paperRecordService.getMedicalRecordLocationAssociatedWith(location);
} catch (Exception e) {
throw new UnableToPrintException(getMessage("zl.registration.patient.idcard.locationNotAssociatedWithMedicalRecordLocation", location.getName()));
}
Printer printer = printerService.getDefaultPrinter(location, PrinterType.ID_CARD);
if (printer == null) {
throw new UnableToPrintException(getMessage("zl.registration.patient.idcard.noPrinterConfiguredForLocation", location.getName()));
}
DateFormat df = new SimpleDateFormat("dd MMM yyyy", Context.getLocale());
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("name", getName(patient));
paramMap.put("patientIdentifier", getIdentifier(patient));
paramMap.put("gender", patient.getGender());
paramMap.put("birthdate", df.format(patient.getBirthdate()));
paramMap.put("birthdateEstimated", patient.getBirthdateEstimated());
paramMap.put("issuingLocation", getIssuingLocationName(issuingLocation));
paramMap.put("issuedDate", df.format(new Date()));
paramMap.put("telephoneNumber", getTelephoneNumber(patient));
paramMap.put("customCardLabel", config.getIdCardLabel());
paramMap.put("addressLines", getAddressLines(patient));
paramMap.put("locale", config.getIdCardLocale());
// but if it is a GX430t, it's just a simple socket print with raw ZPL code, so we need to generate the data using the label template
if (printer.getModel().getPrintHandler().equals("gx430tPrintHandler")) {
ZplCardTemplate zlCardTemplate = Context.getRegisteredComponent("zplCardTemplate", ZplCardTemplate.class);
paramMap.put("data", zlCardTemplate.generateLabel(paramMap));
paramMap.put("encoding", zlCardTemplate.getEncoding());
paramMap.put("wait", 500);
}
printerService.print(paramMap, printer, false);
}
Aggregations