Search in sources :

Example 66 with SimpleObject

use of org.openmrs.ui.framework.SimpleObject 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));
}
Also used : SimpleObject(org.openmrs.ui.framework.SimpleObject) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Location(org.openmrs.Location) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 67 with SimpleObject

use of org.openmrs.ui.framework.SimpleObject 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));
}
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)

Aggregations

SimpleObject (org.openmrs.ui.framework.SimpleObject)67 Test (org.junit.Test)37 Location (org.openmrs.Location)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)29 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)26 ArrayList (java.util.ArrayList)18 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)17 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)13 Config (org.openmrs.module.pihcore.config.Config)12 DateTime (org.joda.time.DateTime)11 Date (java.util.Date)9 Encounter (org.openmrs.Encounter)9 Concept (org.openmrs.Concept)6 Patient (org.openmrs.Patient)6 Obs (org.openmrs.Obs)5 Visit (org.openmrs.Visit)5 LinkedHashMap (java.util.LinkedHashMap)4 List (java.util.List)3 ConceptSearchResult (org.openmrs.ConceptSearchResult)3 Form (org.openmrs.Form)3