Search in sources :

Example 1 with PatientBuilder

use of org.openmrs.contrib.testdata.builder.PatientBuilder in project openmrs-module-pihcore by PIH.

the class BaseReportTest method createPatient.

protected Patient createPatient() {
    PatientBuilder pb = data.patient();
    pb.name(new PersonName("John", "Smitty", "Smith"));
    pb.birthdate("1977-11-23").birthdateEstimated(false);
    pb.male();
    pb.identifier(Metadata.lookup(PihHaitiPatientIdentifierTypes.ZL_EMR_ID), "X3XK71", Metadata.lookup(MirebalaisLocations.MIREBALAIS_CDI_PARENT));
    return pb.save();
}
Also used : PatientBuilder(org.openmrs.contrib.testdata.builder.PatientBuilder) PersonName(org.openmrs.PersonName)

Example 2 with PatientBuilder

use of org.openmrs.contrib.testdata.builder.PatientBuilder 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();
}
Also used : PatientBuilder(org.openmrs.contrib.testdata.builder.PatientBuilder) PrinterModel(org.openmrs.module.printer.PrinterModel) PersonAttributeType(org.openmrs.PersonAttributeType) Patient(org.openmrs.Patient) Printer(org.openmrs.module.printer.Printer) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 3 with PatientBuilder

use of org.openmrs.contrib.testdata.builder.PatientBuilder in project openmrs-module-pihcore by PIH.

the class BaseReportTest method createPatient.

protected Patient createPatient(String identifier) {
    PatientBuilder pb = data.patient();
    pb.name(new PersonName("John", "Smitty", "Smith"));
    pb.birthdate("1977-11-23").birthdateEstimated(false);
    pb.male();
    pb.personAttribute(Metadata.lookup(HaitiPersonAttributeTypes.TELEPHONE_NUMBER), "555-1234");
    pb.personAttribute(Metadata.lookup(HaitiPersonAttributeTypes.UNKNOWN_PATIENT), "false");
    pb.personAttribute(Metadata.lookup(HaitiPersonAttributeTypes.MOTHERS_FIRST_NAME), "Isabel");
    address(pb, haitiAddressBundle.getAddressComponents(), "USA", "MA", "Boston", "JP", "Pondside", "");
    pb.identifier(Metadata.lookup(PihHaitiPatientIdentifierTypes.ZL_EMR_ID), identifier, Metadata.lookup(MirebalaisLocations.MIREBALAIS_CDI_PARENT));
    pb.identifier(Metadata.lookup(HaitiPatientIdentifierTypes.BIOMETRIC_REF_NUMBER), UUID.randomUUID().toString(), Metadata.lookup(MirebalaisLocations.MIREBALAIS_CDI_PARENT));
    return pb.save();
}
Also used : PatientBuilder(org.openmrs.contrib.testdata.builder.PatientBuilder) PersonName(org.openmrs.PersonName)

Aggregations

PatientBuilder (org.openmrs.contrib.testdata.builder.PatientBuilder)3 PersonName (org.openmrs.PersonName)2 Test (org.junit.Test)1 Location (org.openmrs.Location)1 Patient (org.openmrs.Patient)1 PatientIdentifierType (org.openmrs.PatientIdentifierType)1 PersonAttributeType (org.openmrs.PersonAttributeType)1 Printer (org.openmrs.module.printer.Printer)1 PrinterModel (org.openmrs.module.printer.PrinterModel)1 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)1