use of org.openmrs.module.printer.PrinterModel in project openmrs-module-mirebalais by PIH.
the class ZlEmrIdCardPrinterTest method testZlEmrIdCardPrinting.
@Test
public void testZlEmrIdCardPrinting() throws Exception {
// Register printer model
PrinterModel model = new PrinterModel();
model.setName("Test Zebra P110i");
model.setType(PrinterType.ID_CARD);
model.setPrintHandler("p110iPrintHandler");
printerService.savePrinterModel(model);
// Register instance of this printer model
Printer printer = new Printer();
printer.setName("Test ZL EMR ID Card Printer");
printer.setType(PrinterType.ID_CARD);
printer.setModel(model);
printer.setPhysicalLocation(null);
printer.setIpAddress("127.0.0.1");
printer.setPort("9105");
printerService.savePrinter(printer);
// Set location for this printer
Location location = MetadataUtils.existing(Location.class, MirebalaisLocations.CLINIC_REGISTRATION.uuid());
printerService.setDefaultPrinter(location, PrinterType.ID_CARD, printer);
// Create a patient for whom to print an id card
PatientBuilder pb = testDataManager.patient().birthdate("1948-02-16").gender("M").name("Ringo", "Starr");
pb.identifier(MetadataUtils.existing(PatientIdentifierType.class, PihHaitiPatientIdentifierTypes.ZL_EMR_ID.uuid()), "X2ECEX", location);
pb.personAttribute(MetadataUtils.existing(PersonAttributeType.class, HaitiPersonAttributeTypes.TELEPHONE_NUMBER.uuid()), "555-1212");
pb.address("should be line 2", "should be line 1", "should be line 4", "should be line 5a", "should not exist", "should be line 5b");
Patient patient = pb.save();
TestPrinter testPrinter = new TestPrinter("127.0.0.1", 9105, "Windows-1252");
testPrinter.start();
zlEmrIdCardPrinter.print(patient, location);
// Pause up to 30 seconds for printing to happen
for (int i = 0; i < 30 && testPrinter.getNumPrintJobs() == 0; i++) {
Thread.sleep(1000);
}
Assert.assertEquals(1, testPrinter.getNumPrintJobs());
TestPrinter.PrintJob job = testPrinter.getLatestPrintJob();
Assert.assertTrue(job.containsData("B 75 550 0 0 0 3 100 0 X2ECEX"));
testPrinter.stop();
}
use of org.openmrs.module.printer.PrinterModel in project openmrs-module-pihcore by PIH.
the class ZlEmrIdCardPrinterTest method testZlEmrIdCardPrinting.
@Test
public void testZlEmrIdCardPrinting() throws Exception {
// Register printer model
PrinterModel model = new PrinterModel();
model.setName("Test Zebra P110i");
model.setType(PrinterType.ID_CARD);
model.setPrintHandler("p110iPrintHandler");
printerService.savePrinterModel(model);
// Register instance of this printer model
Printer printer = new Printer();
printer.setName("Test ZL EMR ID Card Printer");
printer.setType(PrinterType.ID_CARD);
printer.setModel(model);
printer.setPhysicalLocation(null);
printer.setIpAddress("127.0.0.1");
printer.setPort("9105");
printerService.savePrinter(printer);
// Set location for this printer
// Clinic Reception
Location location = locationService.getLocation("Biwo Resepsyon");
printerService.setDefaultPrinter(location, PrinterType.ID_CARD, printer);
// Create a patient for whom to print an id card
PatientBuilder pb = testDataManager.patient().birthdate("1948-02-16").gender("M").name("Ringo", "Starr");
pb.identifier(MetadataUtils.existing(PatientIdentifierType.class, ZlConfigConstants.PATIENTIDENTIFIERTYPE_ZLEMRID_UUID), "X2ECEX", location);
pb.personAttribute(Metadata.getPhoneNumberAttributeType(), "555-1212");
pb.address("should be line 2", "should be line 1", "should be line 4", "should be line 5a", "should not exist", "should be line 5b");
Patient patient = pb.save();
TestPrinter testPrinter = new TestPrinter("127.0.0.1", 9105, "Windows-1252");
testPrinter.start();
zlEmrIdCardPrinter.print(patient, location);
// Pause up to 30 seconds for printing to happen
for (int i = 0; i < 30 && testPrinter.getNumPrintJobs() == 0; i++) {
Thread.sleep(1000);
}
Assert.assertEquals(1, testPrinter.getNumPrintJobs());
TestPrinter.PrintJob job = testPrinter.getLatestPrintJob();
Assert.assertTrue(job.containsData("B 75 550 0 0 0 3 100 0 X2ECEX"));
testPrinter.stop();
}
Aggregations