use of org.openmrs.ui.framework.page.Redirect in project openmrs-module-pihcore by PIH.
the class CheckinPageController method controller.
public Object controller(@RequestParam("patientId") Patient patient, @RequestParam(value = "closeVisit", required = false) Boolean closeVisit, UiUtils ui, UiSessionContext uiSessionContext, PageModel model, EmrApiProperties emrApiProperties, @SpringBean AdtService adtService, @InjectBeans PatientDomainWrapper patientDomainWrapper) {
patientDomainWrapper.setPatient(patient);
VisitDomainWrapper activeVisit = patientDomainWrapper.getActiveVisit(uiSessionContext.getSessionLocation());
if (closeVisit != null && closeVisit && activeVisit != null) {
adtService.closeAndSaveVisit(activeVisit.getVisit());
activeVisit = null;
}
// if there is no active visit, redirect directly to the form
if (activeVisit == null) {
return new Redirect("/registrationapp/registrationSummary.page?patientId=" + patient.getId() + "&appId=registrationapp.registerPatient" + "&breadcrumbOverrideProvider=coreapps&breadcrumbOverridePage=findpatient%2FfindPatient&breadcrumbOverrideApp=mirebalais.liveCheckin&breadcrumbOverrideLabel=mirebalais.app.patientRegistration.checkin.label");
} else // prompt the user to see if they want close the existing visit
{
List<Encounter> existingEncounters = new ArrayList<Encounter>();
if (activeVisit != null) {
for (Encounter encounter : activeVisit.getVisit().getEncounters()) {
if (!encounter.isVoided() && emrApiProperties.getCheckInEncounterType().equals(encounter.getEncounterType())) {
existingEncounters.add(encounter);
}
}
}
SimpleObject appHomepageBreadcrumb = SimpleObject.create("label", ui.escapeJs(ui.message("mirebalais.checkin.title")));
SimpleObject patientPageBreadcrumb = SimpleObject.create("label", ui.escapeJs(patient.getFamilyName()) + ", " + ui.escapeJs(patient.getGivenName()), "link", ui.thisUrlWithContextPath());
model.addAttribute("breadcrumbOverride", ui.toJson(Arrays.asList(appHomepageBreadcrumb, patientPageBreadcrumb)));
model.addAttribute("activeVisit", activeVisit);
model.addAttribute("existingEncounters", existingEncounters);
model.addAttribute("patient", patientDomainWrapper);
model.addAttribute("appName", "mirebalais.liveCheckin");
return null;
}
}
use of org.openmrs.ui.framework.page.Redirect in project openmrs-module-pihcore by PIH.
the class AppEndRouterPageControllerTest method shouldRedirectToStartOfApp.
@Test
public void shouldRedirectToStartOfApp() {
AppDescriptor app = new AppDescriptor();
app.setId("mirebalais.liveCheckin");
app.setUrl("coreapps/findpatient/findPatient.page?app=mirebalais.liveCheckin");
when(appFrameworkService.getApp("mirebalais.liveCheckin")).thenReturn(app);
when(session.getAttribute(PihCoreConstants.CURRENT_APP_SESSION_VARIABLE)).thenReturn("mirebalais.liveCheckin");
Redirect redirect = new AppEndRouterPageController().controller(request, appFrameworkService, null);
assertThat(redirect.getUrl(), is("coreapps/findpatient/findPatient.page?app=mirebalais.liveCheckin"));
}
use of org.openmrs.ui.framework.page.Redirect in project openmrs-module-pihcore by PIH.
the class AppEndRouterPageControllerTest method shouldRedirectToRegistrationSummaryfApp.
@Test
public void shouldRedirectToRegistrationSummaryfApp() {
Patient patient = new Patient(1);
when(session.getAttribute(PihCoreConstants.CURRENT_APP_SESSION_VARIABLE)).thenReturn("");
Redirect redirect = new AppEndRouterPageController().controller(request, appFrameworkService, patient);
assertThat(redirect.getUrl(), is("registrationapp/registrationSummary.page?patientId=1&appId=registrationapp.registerPatient"));
}
use of org.openmrs.ui.framework.page.Redirect in project openmrs-module-coreapps by openmrs.
the class PatientPageController method controller.
public Object controller(@RequestParam("patientId") Patient patient, PageModel model, @RequestParam(required = false, value = "app") AppDescriptor app, @RequestParam(required = false, value = "dashboard") String dashboard, @InjectBeans PatientDomainWrapper patientDomainWrapper, @SpringBean("adtService") AdtService adtService, @SpringBean("visitService") VisitService visitService, @SpringBean("encounterService") EncounterService encounterService, @SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @SpringBean("applicationEventService") ApplicationEventService applicationEventService, @SpringBean("coreAppsProperties") CoreAppsProperties coreAppsProperties, UiSessionContext sessionContext) {
if (!Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_PATIENT_DASHBOARD)) {
return new Redirect("coreapps", "noAccess", "");
} else if (patient.isVoided() || patient.isPersonVoided()) {
return new Redirect("coreapps", "patientdashboard/deletedPatient", "patientId=" + patient.getId());
}
if (StringUtils.isEmpty(dashboard)) {
dashboard = "patientDashboard";
}
patientDomainWrapper.setPatient(patient);
model.addAttribute("patient", patientDomainWrapper);
model.addAttribute("app", app);
Location visitLocation = null;
try {
visitLocation = adtService.getLocationThatSupportsVisits(sessionContext.getSessionLocation());
} catch (IllegalArgumentException ex) {
// location does not support visits
}
VisitDomainWrapper activeVisit = null;
if (visitLocation != null) {
activeVisit = adtService.getActiveVisit(patient, visitLocation);
}
model.addAttribute("activeVisit", activeVisit);
AppContextModel contextModel = sessionContext.generateAppContextModel();
contextModel.put("patient", new PatientContextModel(patient));
contextModel.put("visit", activeVisit == null ? null : new VisitContextModel(activeVisit));
model.addAttribute("appContextModel", contextModel);
List<Extension> overallActions = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".overallActions", contextModel);
Collections.sort(overallActions);
model.addAttribute("overallActions", overallActions);
List<Extension> visitActions;
if (activeVisit == null) {
visitActions = new ArrayList<Extension>();
} else {
visitActions = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".visitActions", contextModel);
Collections.sort(visitActions);
}
model.addAttribute("visitActions", visitActions);
List<Extension> includeFragments = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".includeFragments", contextModel);
Collections.sort(includeFragments);
model.addAttribute("includeFragments", includeFragments);
List<Extension> firstColumnFragments = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".firstColumnFragments", contextModel);
Collections.sort(firstColumnFragments);
model.addAttribute("firstColumnFragments", firstColumnFragments);
List<Extension> secondColumnFragments = appFrameworkService.getExtensionsForCurrentUser(dashboard + ".secondColumnFragments", contextModel);
Collections.sort(secondColumnFragments);
model.addAttribute("secondColumnFragments", secondColumnFragments);
List<Extension> otherActions = appFrameworkService.getExtensionsForCurrentUser((dashboard == "patientDashboard" ? "clinicianFacingPatientDashboard" : dashboard) + ".otherActions", contextModel);
Collections.sort(otherActions);
model.addAttribute("otherActions", otherActions);
// used for breadcrumbs to link back to the base dashboard in the case when this is used to render a context-specific dashboard
model.addAttribute("baseDashboardUrl", coreAppsProperties.getDashboardUrl());
model.addAttribute("dashboard", dashboard);
applicationEventService.patientViewed(patient, sessionContext.getCurrentUser());
return null;
}
use of org.openmrs.ui.framework.page.Redirect in project openmrs-module-coreapps by openmrs.
the class PatientDashboardPageController method controller.
public Object controller(@RequestParam("patientId") Patient patient, @RequestParam(value = "visitId", required = false) Visit visit, @RequestParam(value = "tab", defaultValue = "visits") String selectedTab, PageModel model, @InjectBeans PatientDomainWrapper patientDomainWrapper, @SpringBean("orderService") OrderService orderService, @SpringBean("adtService") AdtService adtService, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @SpringBean("coreAppsProperties") CoreAppsProperties coreAppsProperties, @SpringBean("applicationEventService") ApplicationEventService applicationEventService, UiSessionContext sessionContext) {
if (!Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_PATIENT_VISITS)) {
return new Redirect("coreapps", "noAccess", "");
} else if (patient.isVoided() || patient.isPersonVoided()) {
return new Redirect("coreapps", "patientdashboard/deletedPatient", "patientId=" + patient.getId());
}
patientDomainWrapper.setPatient(patient);
model.addAttribute("patient", patientDomainWrapper);
model.addAttribute("selectedTab", selectedTab);
model.addAttribute("selectedVisit", visit);
Location visitLocation = null;
try {
visitLocation = adtService.getLocationThatSupportsVisits(sessionContext.getSessionLocation());
} catch (IllegalArgumentException ex) {
// location does not support visits
}
VisitDomainWrapper activeVisit = null;
if (visitLocation != null) {
activeVisit = adtService.getActiveVisit(patient, visitLocation);
}
model.addAttribute("activeVisit", activeVisit);
List<Extension> encounterTemplateExtensions = appFrameworkService.getExtensionsForCurrentUser(CoreAppsConstants.ENCOUNTER_TEMPLATE_EXTENSION);
model.addAttribute("encounterTemplateExtensions", encounterTemplateExtensions);
AppContextModel contextModel = sessionContext.generateAppContextModel();
contextModel.put("patient", new PatientContextModel(patient));
contextModel.put("visit", activeVisit == null ? null : new VisitContextModel(activeVisit));
model.addAttribute("appContextModel", contextModel);
List<Extension> overallActions = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.overallActions", contextModel);
Collections.sort(overallActions);
model.addAttribute("overallActions", overallActions);
List<Extension> includeFragments = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.includeFragments");
Collections.sort(includeFragments);
model.addAttribute("includeFragments", includeFragments);
List<Extension> visitActions = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.visitActions");
Collections.sort(visitActions);
model.addAttribute("visitActions", visitActions);
model.addAttribute("patientTabs", appFrameworkService.getExtensionsForCurrentUser("patientDashboard.tabs"));
model.addAttribute("dashboardUrl", coreAppsProperties.getDashboardUrl());
model.addAttribute("encounterCount", coreAppsProperties.getPatientDashboardEncounterCount());
applicationEventService.patientViewed(patient, sessionContext.getCurrentUser());
return null;
}
Aggregations