Search in sources :

Example 1 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-pihcore by PIH.

the class PihRadiologyOrdersMergeActionsComponentTest method shouldMergePatientsWhenNonPreferredPatientHasRadiologyOrdersInOverlappingVisit.

// TODO un-ignore once we have the EMR API module updated
@Test
@Ignore
public void shouldMergePatientsWhenNonPreferredPatientHasRadiologyOrdersInOverlappingVisit() throws Exception {
    PihRadiologyOrdersMergeActions pihRadiologyOrdersMergeActions = Context.getRegisteredComponent("pihRadiologyOrdersMergeActions", PihRadiologyOrdersMergeActions.class);
    Config config = mock(Config.class);
    runtimeProperties.setProperty(ConfigLoader.PIH_CONFIGURATION_RUNTIME_PROPERTY, "mirebalais");
    config = new Config(ConfigLoader.loadFromRuntimeProperties());
    pihRadiologyOrdersMergeActions.setConfig(config);
    Patient preferredPatient = patientService.getPatient(6);
    Patient nonPreferredPatient = patientService.getPatient(10004);
    List<Encounter> encountersByPatient = encounterService.getEncountersByPatient(nonPreferredPatient);
    // patient has 1 Radiology Encounter
    Assert.assertEquals(1, encountersByPatient.size());
    Assert.assertEquals("RadiologyOrder", encountersByPatient.get(0).getEncounterType().getName());
    Set<Order> orders = encountersByPatient.get(0).getOrders();
    Assert.assertEquals(1, orders.size());
    Order radiologyOrder = null;
    for (Order order : orders) {
        radiologyOrder = order;
    }
    Assert.assertEquals("RadiologyOrder", radiologyOrder.getOrderType().getName());
    adtService.mergePatients(preferredPatient, nonPreferredPatient);
    assertTrue("RadiologyOrder was not merged", orderService.getAllOrdersByPatient(preferredPatient).contains(radiologyOrder));
}
Also used : Order(org.openmrs.Order) Config(org.openmrs.module.pihcore.config.Config) Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) Ignore(org.junit.Ignore) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 2 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-pihcore by PIH.

the class BaseReportTest method getConfig.

protected Config getConfig() {
    ConfigDescriptor d = new ConfigDescriptor();
    d.setCountry(ConfigDescriptor.Country.HAITI);
    d.setSite(ConfigDescriptor.Site.MIREBALAIS);
    return new Config(d);
}
Also used : Config(org.openmrs.module.pihcore.config.Config) ConfigDescriptor(org.openmrs.module.pihcore.config.ConfigDescriptor)

Example 3 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-pihcore by PIH.

the class PihCloseStaleVisitsTaskTest method getConfig.

protected Config getConfig() {
    ConfigDescriptor d = new ConfigDescriptor();
    d.setCountry(ConfigDescriptor.Country.HAITI);
    d.setSite(ConfigDescriptor.Site.MIREBALAIS);
    return new Config(d);
}
Also used : Config(org.openmrs.module.pihcore.config.Config) ConfigDescriptor(org.openmrs.module.pihcore.config.ConfigDescriptor)

Example 4 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.

the class CustomAppUtilTest method shouldFindResourceAtCountryLevel.

@Test
public void shouldFindResourceAtCountryLevel() {
    File file = mock(File.class);
    ResourceFactory resourceFactory = mock(ResourceFactory.class);
    when(resourceFactory.getResource("pihcore", "htmlforms/checkin.xml")).thenReturn(file);
    when(resourceFactory.getResource("pihcore", "htmlforms/other/checkin.xml")).thenReturn(file);
    Config config = mock(Config.class);
    when(config.getCountry()).thenReturn(ConfigDescriptor.Country.OTHER);
    when(config.getSite()).thenReturn(ConfigDescriptor.Site.OTHER);
    String resourcePath = CustomAppLoaderUtil.determineResourcePath(config, "pihcore", "htmlforms", "checkin.xml");
    assertThat(resourcePath, is("pihcore:htmlforms/other/checkin.xml"));
}
Also used : Config(org.openmrs.module.pihcore.config.Config) ResourceFactory(org.openmrs.ui.framework.resource.ResourceFactory) File(java.io.File) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with Config

use of org.openmrs.module.pihcore.config.Config in project openmrs-module-mirebalais by PIH.

the class CustomAppUtilTest method shouldFindResourceAtTopLevel.

@Test
public void shouldFindResourceAtTopLevel() {
    URL url = mock(URL.class);
    when(moduleClassLoader.getResource("web/module/resources/htmlforms/checkin.xml")).thenReturn(url);
    Config config = mock(Config.class);
    when(config.getCountry()).thenReturn(ConfigDescriptor.Country.OTHER);
    when(config.getSite()).thenReturn(ConfigDescriptor.Site.OTHER);
    String resourcePath = CustomAppLoaderUtil.determineResourcePath(config, "pihcore", "htmlforms", "checkin.xml");
    assertThat(resourcePath, is("pihcore:htmlforms/checkin.xml"));
}
Also used : Config(org.openmrs.module.pihcore.config.Config) URL(java.net.URL) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Config (org.openmrs.module.pihcore.config.Config)26 Test (org.junit.Test)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)8 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)8 Location (org.openmrs.Location)6 SimpleObject (org.openmrs.ui.framework.SimpleObject)6 Before (org.junit.Before)5 DateTime (org.joda.time.DateTime)4 EmrApiActivator (org.openmrs.module.emrapi.EmrApiActivator)4 BiometricsConfigDescriptor (org.openmrs.module.pihcore.config.registration.BiometricsConfigDescriptor)4 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)4 File (java.io.File)3 ResourceFactory (org.openmrs.ui.framework.resource.ResourceFactory)3 Encounter (org.openmrs.Encounter)2 Order (org.openmrs.Order)2 Patient (org.openmrs.Patient)2 Module (org.openmrs.module.Module)2 MirebalaisHospitalActivator (org.openmrs.module.mirebalais.MirebalaisHospitalActivator)2 PihCoreActivator (org.openmrs.module.pihcore.PihCoreActivator)2