Search in sources :

Example 6 with Redirect

use of org.openmrs.ui.framework.page.Redirect in project openmrs-module-coreapps by openmrs.

the class SummaryDashboardPageController method controller.

public Object controller(@RequestParam("app") AppDescriptor app, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, PageModel model, UiSessionContext sessionContext) {
    if (!Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_SUMMARY_DASHBOARD)) {
        return new Redirect("coreapps", "noAccess", "");
    }
    model.addAttribute("app", app);
    AppContextModel contextModel = sessionContext.generateAppContextModel();
    model.addAttribute("appContextModel", contextModel);
    List<Extension> actions = appFrameworkService.getExtensionsForCurrentUser(app.getId() + ".actions", contextModel);
    Collections.sort(actions);
    model.addAttribute("actions", actions);
    List<Extension> includeFragments = appFrameworkService.getExtensionsForCurrentUser(app.getId() + ".includeFragments", contextModel);
    Collections.sort(includeFragments);
    model.addAttribute("includeFragments", includeFragments);
    List<Extension> firstColumnFragments = appFrameworkService.getExtensionsForCurrentUser(app.getId() + ".firstColumnFragments", contextModel);
    Collections.sort(firstColumnFragments);
    model.addAttribute("firstColumnFragments", firstColumnFragments);
    List<Extension> secondColumnFragments = appFrameworkService.getExtensionsForCurrentUser(app.getId() + ".secondColumnFragments", contextModel);
    Collections.sort(secondColumnFragments);
    model.addAttribute("secondColumnFragments", secondColumnFragments);
    return null;
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) Redirect(org.openmrs.ui.framework.page.Redirect)

Example 7 with Redirect

use of org.openmrs.ui.framework.page.Redirect in project openmrs-module-coreapps by openmrs.

the class MergeVisitsPageController method controller.

public Object controller(@RequestParam("patientId") Patient patient, @InjectBeans PatientDomainWrapper patientDomainWrapper, UiSessionContext sessionContext, PageModel model, @SpringBean AdtService service, @SpringBean("locationService") LocationService locationService, @RequestParam(value = "returnUrl", required = false) String returnUrl) {
    if (patient.isVoided() || patient.isPersonVoided()) {
        return new Redirect("coreapps", "patientdashboard/deletedPatient", "patientId=" + patient.getId());
    }
    patientDomainWrapper.setPatient(patient);
    model.addAttribute("patient", patientDomainWrapper);
    model.addAttribute("returnUrl", returnUrl);
    Location sessionLocation = sessionContext.getSessionLocation();
    Location visitLocation = null;
    if (sessionLocation != null) {
        visitLocation = service.getLocationThatSupportsVisits(sessionLocation);
    }
    if (visitLocation != null) {
        VisitDomainWrapper activeVisit = service.getActiveVisit(patient, visitLocation);
        model.addAttribute("activeVisit", activeVisit);
    } else {
        throw new IllegalStateException("Configuration required: no visit location found based on session location");
    }
    return null;
}
Also used : Redirect(org.openmrs.ui.framework.page.Redirect) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) Location(org.openmrs.Location)

Example 8 with Redirect

use of org.openmrs.ui.framework.page.Redirect in project openmrs-module-pihcore by PIH.

the class AppEntryRouterPageControllerTest method shouldRedirectToFindPatientPageAndSetAppSessionVariable.

@Test
public void shouldRedirectToFindPatientPageAndSetAppSessionVariable() {
    AppDescriptor app = new AppDescriptor();
    app.setId("mirebalais.liveCheckin");
    app.setUrl("coreapps/findpatient/findPatient.page?app=mirebalais.liveCheckin");
    Redirect redirect = new AppEntryRouterPageController().controller(request, null, app);
    verify(session).setAttribute(PihCoreConstants.CURRENT_APP_SESSION_VARIABLE, "mirebalais.liveCheckin");
    assertThat(redirect.getUrl(), is("coreapps/findpatient/findPatient.page?app=mirebalais.liveCheckin"));
}
Also used : AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor) Redirect(org.openmrs.ui.framework.page.Redirect) Test(org.junit.Test)

Aggregations

Redirect (org.openmrs.ui.framework.page.Redirect)8 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)4 Test (org.junit.Test)3 Location (org.openmrs.Location)3 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)3 Extension (org.openmrs.module.appframework.domain.Extension)3 AppDescriptor (org.openmrs.module.appframework.domain.AppDescriptor)2 PatientContextModel (org.openmrs.module.coreapps.contextmodel.PatientContextModel)2 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)2 ArrayList (java.util.ArrayList)1 Encounter (org.openmrs.Encounter)1 Patient (org.openmrs.Patient)1 SimpleObject (org.openmrs.ui.framework.SimpleObject)1