use of org.openmrs.module.appframework.context.AppContextModel in project openmrs-module-pihcore by PIH.
the class RequireUtilTest method shouldReturnFalseIfLocationDoesNotHaveTag.
@Test
public void shouldReturnFalseIfLocationDoesNotHaveTag() {
Location sessionLocation = new Location();
SimpleObject sessionLocationRestRep = new SimpleObject();
sessionLocationRestRep.put("uuid", "123abc");
SimpleObject admitTag = new SimpleObject();
admitTag.put("display", "Admission Location");
sessionLocationRestRep.put("tags", Arrays.asList(admitTag));
PowerMockito.mockStatic(ConversionUtil.class);
when(ConversionUtil.convertToRepresentation(sessionLocation, Representation.DEFAULT)).thenReturn(sessionLocationRestRep);
uiSessionContext.setSessionLocation(sessionLocation);
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(sessionLocationHasTag("Archives Location")), appContextModel), is(false));
}
use of org.openmrs.module.appframework.context.AppContextModel in project openmrs-module-pihcore by PIH.
the class RequireUtilTest method shouldReturnFalseIfImproperLocationTagEventThoughUserHasConsultPrivilegeAndActiveVisit.
@Test
public void shouldReturnFalseIfImproperLocationTagEventThoughUserHasConsultPrivilegeAndActiveVisit() {
user.addRole(doctor);
Location sessionLocation = new Location();
SimpleObject sessionLocationRestRep = new SimpleObject();
sessionLocationRestRep.put("uuid", "123abc");
SimpleObject admitTag = new SimpleObject();
admitTag.put("display", "Check-In Location");
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("Consult Note Location"), or(and(userHasPrivilege(PihEmrConfigConstants.PRIVILEGE_TASK_EMR_ENTER_CONSULT_NOTE), patientHasActiveVisit()), userHasPrivilege(PihEmrConfigConstants.PRIVILEGE_TASK_EMR_RETRO_CLINICAL_NOTE), and(userHasPrivilege(PihEmrConfigConstants.PRIVILEGE_TASK_EMR_RETRO_CLINICAL_NOTE_THIS_PROVIDER_ONLY), patientVisitWithinPastThirtyDays(config))))), appContextModel), is(false));
}
use of org.openmrs.module.appframework.context.AppContextModel in project openmrs-module-pihcore by PIH.
the class RequireUtilTest method shouldReturnTrueIfVisitActive.
@Test
public void shouldReturnTrueIfVisitActive() {
VisitDomainWrapper visit = mock(VisitDomainWrapper.class);
when(visit.isActive()).thenReturn(true);
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
appContextModel.put("visit", visit);
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(patientHasActiveVisit()), appContextModel), is(true));
}
Aggregations