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));
}
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));
}
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);
}
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"));
}
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"));
}
Aggregations