Search in sources :

Example 11 with Extension

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);
    }
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) AppContextModel(org.openmrs.module.appframework.context.AppContextModel)

Example 12 with Extension

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));
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) Test(org.junit.Test)

Example 13 with Extension

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"));
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) Test(org.junit.Test)

Example 14 with Extension

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"));
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) Test(org.junit.Test)

Example 15 with Extension

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);
    }
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) ArrayNode(org.codehaus.jackson.node.ArrayNode) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Aggregations

Extension (org.openmrs.module.appframework.domain.Extension)40 Test (org.junit.Test)18 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)4 PatientContextModel (org.openmrs.module.coreapps.contextmodel.PatientContextModel)4 CustomAppLoaderUtil.addFeatureToggleToExtension (org.openmrs.module.pihcore.apploader.CustomAppLoaderUtil.addFeatureToggleToExtension)4 CustomAppLoaderUtil.containsExtension (org.openmrs.module.pihcore.apploader.CustomAppLoaderUtil.containsExtension)4 CustomAppLoaderUtil.fragmentExtension (org.openmrs.module.pihcore.apploader.CustomAppLoaderUtil.fragmentExtension)4 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)3 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)3 Redirect (org.openmrs.ui.framework.page.Redirect)3 Location (org.openmrs.Location)2 Patient (org.openmrs.Patient)2 AppDescriptor (org.openmrs.module.appframework.domain.AppDescriptor)2 SimpleObject (org.openmrs.ui.framework.SimpleObject)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1