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