use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-mirebalais by PIH.
the class HomePageController method controller.
public void controller(PageModel model, UiSessionContext sessionContext, @SpringBean("config") Config config, @SpringBean("featureToggles") FeatureToggleProperties featureToggleProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService) {
sessionContext.requireAuthentication();
AppContextModel appContextModel = sessionContext.generateAppContextModel();
List<Extension> extensions = appFrameworkService.getExtensionsForCurrentUser(HOME_PAGE_EXTENSION_POINT, appContextModel);
for (int i = 0; i < extensions.size(); i++) {
Extension extension = extensions.get(i);
if (extensionFeatureToggledOff(extension, featureToggleProperties)) {
extensions.remove(i);
i--;
}
}
Collections.sort(extensions);
model.addAttribute("extensions", extensions);
model.addAttribute("privilegeSearchForPatients", Privileges.APP_COREAPPS_FIND_PATIENT.privilege());
if (Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_PATIENT_DASHBOARD)) {
if (StringUtils.isNotBlank(config.getDashboardUrl())) {
model.addAttribute("dashboardUrl", config.getDashboardUrl());
} else {
model.addAttribute("dashboardUrl", "/coreapps/patientdashboard/patientDashboard.page?patientId={{patientId}}");
}
} else // if the user doesn't have permission to view patient dashboard, we redirect to registration dashboard
{
model.addAttribute("dashboardUrl", "/registrationapp/registrationSummary.page?patientId={{patientId}}&appId=" + CustomAppLoaderConstants.Apps.PATIENT_REGISTRATION);
}
}
use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-pihcore by PIH.
the class CustomAppLoaderTest method shouldCreateVisitActionsExtension.
@Test
public void shouldCreateVisitActionsExtension() {
Extension extension = CustomAppLoaderUtil.visitAction(CustomAppLoaderConstants.Extensions.ORDER_XRAY_VISIT_ACTION, "label", "icon", "link", "url", "privilege", "require");
assertThat(extension.getId(), is(CustomAppLoaderConstants.Extensions.ORDER_XRAY_VISIT_ACTION));
assertThat(extension.getLabel(), is("label"));
assertThat(extension.getIcon(), is("icon"));
assertThat(extension.getUrl(), is("url"));
assertThat(extension.getScript(), nullValue());
assertThat(extension.getRequiredPrivilege(), is("privilege"));
assertThat(extension.getRequire(), is("require"));
assertThat(extension.getType(), is("link"));
assertThat(extension.getExtensionPointId(), is(CustomAppLoaderConstants.ExtensionPoints.VISIT_ACTIONS));
}
use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-pihcore by PIH.
the class CustomAppLoaderTest method shouldCreateEncounterTemplateExtension.
@Test
public void shouldCreateEncounterTemplateExtension() {
Extension extension = CustomAppLoaderUtil.encounterTemplate("id", "provider", "fragment");
assertThat(extension.getId(), is("id"));
assertThat(extension.getExtensionPointId(), is("org.openmrs.referenceapplication.encounterTemplate"));
assertThat(extension.getType(), is("fragment"));
assertThat((String) extension.getExtensionParams().get("templateId"), is("id"));
assertThat((String) extension.getExtensionParams().get("templateFragmentProviderName"), is("provider"));
assertThat((String) extension.getExtensionParams().get("templateFragmentId"), is("fragment"));
assertThat((String) extension.getExtensionParams().get("templateFragmentProviderName"), is("provider"));
}
use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-pihcore by PIH.
the class CustomAppLoaderTest method shouldCreateDashboardTab.
@Test
public void shouldCreateDashboardTab() {
Extension extension = CustomAppLoaderUtil.dashboardTab("id", "label", "privilege", "provider", "fragment");
assertThat(extension.getId(), is("id"));
assertThat(extension.getExtensionPointId(), is("patientDashboard.tabs"));
assertThat(extension.getType(), is("link"));
assertThat(extension.getLabel(), is("label"));
assertThat(extension.getRequiredPrivilege(), is("privilege"));
assertThat((String) extension.getExtensionParams().get("provider"), is("provider"));
assertThat((String) extension.getExtensionParams().get("fragment"), is("fragment"));
}
use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-pihcore by PIH.
the class HomePageController method controller.
public void controller(PageModel model, UiSessionContext sessionContext, @SpringBean("config") Config config, @SpringBean("featureToggles") FeatureToggleProperties featureToggleProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService) {
sessionContext.requireAuthentication();
AppContextModel appContextModel = sessionContext.generateAppContextModel();
String findPatientColumnConfigJson = null;
try {
ArrayNode findPatientColumnConfig = config.getFindPatientColumnConfig();
if (findPatientColumnConfig != null) {
findPatientColumnConfigJson = new ObjectMapper().writeValueAsString(findPatientColumnConfig);
}
} catch (Exception e) {
log.warn("Error parsing find patient column configuration", e);
}
model.addAttribute("findPatientColumnConfig", findPatientColumnConfigJson);
List<Extension> extensions = appFrameworkService.getExtensionsForCurrentUser(HOME_PAGE_EXTENSION_POINT, appContextModel);
for (int i = 0; i < extensions.size(); i++) {
Extension extension = extensions.get(i);
if (extensionFeatureToggledOff(extension, featureToggleProperties)) {
extensions.remove(i);
i--;
}
}
Collections.sort(extensions);
model.addAttribute("extensions", extensions);
model.addAttribute("privilegeSearchForPatients", PihEmrConfigConstants.PRIVILEGE_APP_COREAPPS_FIND_PATIENT);
if (Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_PATIENT_DASHBOARD)) {
if (StringUtils.isNotBlank(config.getDashboardUrl())) {
model.addAttribute("dashboardUrl", config.getDashboardUrl());
} else {
model.addAttribute("dashboardUrl", "/coreapps/patientdashboard/patientDashboard.page?patientId={{patientId}}");
}
} else // if the user doesn't have permission to view patient dashboard, we redirect to registration dashboard
{
model.addAttribute("dashboardUrl", "/registrationapp/registrationSummary.page?patientId={{patientId}}&appId=" + CustomAppLoaderConstants.Apps.PATIENT_REGISTRATION);
}
}
Aggregations