use of org.openmrs.module.coreapps.contextmodel.VisitContextModel in project openmrs-module-mirebalais by PIH.
the class RequireUtilTest method shouldReturnTrueIfProperLocationTagAndUserHasRetroPrivilege.
@Test
public void shouldReturnTrueIfProperLocationTagAndUserHasRetroPrivilege() {
user.addRole(admin);
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(new DateTime(2014, 1, 1, 1, 1).getMillis());
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.coreapps.contextmodel.VisitContextModel in project openmrs-module-pihcore by PIH.
the class RequireUtilTest method shouldReturnTrueIfProperLocationTagAndUserHasRetroPrivilege.
@Test
public void shouldReturnTrueIfProperLocationTagAndUserHasRetroPrivilege() {
user.addRole(admin);
Location sessionLocation = new Location();
SimpleObject sessionLocationRestRep = new SimpleObject();
sessionLocationRestRep.put("uuid", "123abc");
SimpleObject admitTag = new SimpleObject();
admitTag.put("display", "Consult Note 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(new DateTime(2014, 1, 1, 1, 1).getMillis());
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(true));
}
use of org.openmrs.module.coreapps.contextmodel.VisitContextModel in project openmrs-module-pihcore by PIH.
the class RequireUtilTest method shouldReturnTrueIfVisitWithinPastThirtyDays.
@Test
public void shouldReturnTrueIfVisitWithinPastThirtyDays() {
VisitContextModel visit = mock(VisitContextModel.class);
when(visit.getStopDatetimeInMilliseconds()).thenReturn(new Date().getTime());
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
appContextModel.put("visit", visit);
Config config = mock(Config.class);
when(config.isComponentEnabled("visitNote")).thenReturn(false);
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(patientVisitWithinPastThirtyDays(config)), appContextModel), is(true));
}
use of org.openmrs.module.coreapps.contextmodel.VisitContextModel in project openmrs-module-pihcore by PIH.
the class RequireUtilTest method shouldReturnFalseIfVisitNotWithinPastThirtyDays.
@Test
public void shouldReturnFalseIfVisitNotWithinPastThirtyDays() {
VisitContextModel visit = mock(VisitContextModel.class);
when(visit.getStopDatetimeInMilliseconds()).thenReturn(new DateTime(2014, 1, 1, 1, 1).getMillis());
AppContextModel appContextModel = uiSessionContext.generateAppContextModel();
appContextModel.put("visit", visit);
Config config = mock(Config.class);
when(config.isComponentEnabled("visitNote")).thenReturn(false);
assertThat(appFrameworkService.checkRequireExpression(extensionRequiring(patientVisitWithinPastThirtyDays(config)), appContextModel), is(false));
}
use of org.openmrs.module.coreapps.contextmodel.VisitContextModel 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));
}
Aggregations