Search in sources :

Example 11 with Config

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

the class RequireUtilTest method shouldReturnTrueIfProperLocationTagAndUserHasConsultPrivilegeAndActiveVisit.

@Test
public void shouldReturnTrueIfProperLocationTagAndUserHasConsultPrivilegeAndActiveVisit() {
    user.addRole(doctor);
    Location sessionLocation = new Location();
    SimpleObject sessionLocationRestRep = new SimpleObject();
    sessionLocationRestRep.put("uuid", "123abc");
    SimpleObject admitTag = new SimpleObject();
    admitTag.put("display", LocationTags.CONSULT_NOTE_LOCATION.name());
    sessionLocationRestRep.put("tags", Arrays.asList(admitTag));
    PowerMockito.mockStatic(ConversionUtil.class);
    when(ConversionUtil.convertToRepresentation(sessionLocation, Representation.DEFAULT)).thenReturn(sessionLocationRestRep);
    VisitContextModel visit = mock(VisitContextModel.class);
    when(visit.getStopDatetimeInMilliseconds()).thenReturn(null);
    when(visit.isActive()).thenReturn(true);
    uiSessionContext.setSessionLocation(sessionLocation);
    AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
    appContextModel.put("visit", visit);
    Config config = mock(Config.class);
    when(config.isComponentEnabled("visitNote")).thenReturn(false);
    assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(and(sessionLocationHasTag(LocationTags.CONSULT_NOTE_LOCATION), or(and(userHasPrivilege(Privileges.TASK_EMR_ENTER_CONSULT_NOTE), patientHasActiveVisit()), userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE), and(userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE_THIS_PROVIDER_ONLY), patientVisitWithinPastThirtyDays(config))))), appContextModel), is(true));
}
Also used : SimpleObject(org.openmrs.ui.framework.SimpleObject) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Config(org.openmrs.module.pihcore.config.Config) Location(org.openmrs.Location) VisitContextModel(org.openmrs.module.coreapps.contextmodel.VisitContextModel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with Config

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

the class RequireUtilTest method shouldReturnFalseIfProperLocationTagAndUserHasConsultPrivilegeButNoActiveVisit.

@Test
public void shouldReturnFalseIfProperLocationTagAndUserHasConsultPrivilegeButNoActiveVisit() {
    user.addRole(doctor);
    Location sessionLocation = new Location();
    SimpleObject sessionLocationRestRep = new SimpleObject();
    sessionLocationRestRep.put("uuid", "123abc");
    SimpleObject admitTag = new SimpleObject();
    admitTag.put("display", LocationTags.CONSULT_NOTE_LOCATION.name());
    sessionLocationRestRep.put("tags", Arrays.asList(admitTag));
    PowerMockito.mockStatic(ConversionUtil.class);
    when(ConversionUtil.convertToRepresentation(sessionLocation, Representation.DEFAULT)).thenReturn(sessionLocationRestRep);
    VisitContextModel visit = mock(VisitContextModel.class);
    when(visit.getStopDatetimeInMilliseconds()).thenReturn(null);
    when(visit.isActive()).thenReturn(false);
    uiSessionContext.setSessionLocation(sessionLocation);
    AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
    appContextModel.put("visit", visit);
    Config config = mock(Config.class);
    when(config.isComponentEnabled("visitNote")).thenReturn(false);
    assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(and(sessionLocationHasTag(LocationTags.CONSULT_NOTE_LOCATION), or(and(userHasPrivilege(Privileges.TASK_EMR_ENTER_CONSULT_NOTE), patientHasActiveVisit()), userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE), and(userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE_THIS_PROVIDER_ONLY), patientVisitWithinPastThirtyDays(config))))), appContextModel), is(false));
}
Also used : SimpleObject(org.openmrs.ui.framework.SimpleObject) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Config(org.openmrs.module.pihcore.config.Config) Location(org.openmrs.Location) VisitContextModel(org.openmrs.module.coreapps.contextmodel.VisitContextModel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with Config

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

the class WristbandComponentTest method setup.

@Before
public void setup() throws Exception {
    executeDataSet("wristbandTestDataset.xml");
    EmrApiActivator emrApiActivator = new EmrApiActivator();
    emrApiActivator.started();
    Config config = mock(Config.class);
    when(config.getCountry()).thenReturn(ConfigDescriptor.Country.HAITI);
    when(config.getSite()).thenReturn(ConfigDescriptor.Site.MIREBALAIS);
    MetadataMappingsSetup.setupPrimaryIdentifierTypeBasedOnCountry(metadataMappingService, patientService, config);
}
Also used : EmrApiActivator(org.openmrs.module.emrapi.EmrApiActivator) Config(org.openmrs.module.pihcore.config.Config) Before(org.junit.Before)

Example 14 with Config

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

the class CustomAppUtilTest method shouldFindResourceAtSiteLevel.

@Test
public void shouldFindResourceAtSiteLevel() {
    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);
    when(resourceFactory.getResource("pihcore", "htmlforms/other/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/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 15 with Config

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

the class CustomAppUtilTest method shouldFindHtmlResourcePathAtCountryLevel.

@Test
public void shouldFindHtmlResourcePathAtCountryLevel() {
    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.determineHtmlFormPath(config, "checkin");
    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)

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