Search in sources :

Example 6 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-coreapps by openmrs.

the class PatientSearchWidgetFragmentController method controller.

public void controller(FragmentModel model, UiSessionContext sessionContext, HttpServletRequest request, @SpringBean("adminService") AdministrationService administrationService, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @FragmentParam(value = "showLastViewedPatients", required = false) Boolean showLastViewedPatients, @FragmentParam(value = "initialSearchFromParameter", required = false) String searchByParam, @FragmentParam(value = "registrationAppLink", required = false) String registrationAppLink) {
    showLastViewedPatients = showLastViewedPatients != null ? showLastViewedPatients : false;
    model.addAttribute("minSearchCharacters", administrationService.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MIN_SEARCH_CHARACTERS, "1"));
    model.addAttribute("searchDelayShort", administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_SHORT, "300"));
    model.addAttribute("searchDelayLong", administrationService.getGlobalProperty(CoreAppsConstants.GP_SEARCH_DELAY_LONG, "1000"));
    // TODO really should be driven by global property, but currently we only have a property for the java date format
    model.addAttribute("dateFormatJS", "DD MMM YYYY");
    model.addAttribute("locale", Context.getLocale().getLanguage());
    model.addAttribute("defaultLocale", new Locale(administrationService.getGlobalProperty((OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCALE), "en")).getLanguage());
    model.addAttribute("dateFormatter", new SimpleDateFormat(administrationService.getGlobalProperty(UiFrameworkConstants.GP_FORMATTER_DATE_FORMAT), Context.getLocale()));
    model.addAttribute("searchWidgetDateFormatter", new SimpleDateFormat("yyyy-MM-dd"));
    model.addAttribute("showLastViewedPatients", showLastViewedPatients);
    String doInitialSearch = null;
    if (searchByParam != null && StringUtils.isNotEmpty(request.getParameter(searchByParam))) {
        doInitialSearch = request.getParameter(searchByParam);
    }
    model.addAttribute("doInitialSearch", doInitialSearch);
    if (showLastViewedPatients) {
        List<Patient> patients = GeneralUtils.getLastViewedPatients(sessionContext.getCurrentUser());
        model.addAttribute("lastViewedPatients", patients);
    }
    String listingAttributeTypesStr = administrationService.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES, "");
    List<String> listingAttributeTypeNames = new ArrayList<String>();
    if (StringUtils.isNotBlank(listingAttributeTypesStr)) {
        String[] attTypeNames = StringUtils.split(listingAttributeTypesStr.trim(), ",");
        for (String name : attTypeNames) {
            if (StringUtils.isNotBlank(name.trim())) {
                listingAttributeTypeNames.add(name.trim());
            }
        }
    }
    model.addAttribute("listingAttributeTypeNames", listingAttributeTypeNames);
    model.addAttribute("registrationAppLink", registrationAppLink);
    List<Extension> patientSearchExtensions = appFrameworkService.getExtensionsForCurrentUser("coreapps.patientSearch.extension");
    Collections.sort(patientSearchExtensions);
    model.addAttribute("patientSearchExtensions", patientSearchExtensions);
}
Also used : Locale(java.util.Locale) Extension(org.openmrs.module.appframework.domain.Extension) ArrayList(java.util.ArrayList) Patient(org.openmrs.Patient) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-coreapps by openmrs.

the class VisitDetailsFragmentController method getVisitDetails.

public SimpleObject getVisitDetails(@SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @InjectBeans CoreAppsProperties coreAppsProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @SpringBean("encounterService") EncounterService encounterService, @RequestParam("visitId") Visit visit, @RequestParam(value = "fromEncounter", required = false) Integer encounterIndex, @RequestParam(value = "encounterCount", required = false) Integer encounterCount, UiUtils uiUtils, UiSessionContext sessionContext) throws ParseException {
    if (encounterIndex == null)
        encounterIndex = 0;
    if (encounterCount == null) {
        encounterCount = coreAppsProperties.getPatientDashboardEncounterCount();
    }
    ParseEncounterToJson parseEncounterToJson = new ParseEncounterToJson(appFrameworkService, uiUtils, encounterService);
    SimpleObject simpleObject = SimpleObject.fromObject(visit, uiUtils, "id", "uuid", "location");
    User authenticatedUser = sessionContext.getCurrentUser();
    boolean canDeleteVisit = authenticatedUser.hasPrivilege(EmrApiConstants.PRIVILEGE_DELETE_VISIT);
    Date startDatetime = visit.getStartDatetime();
    Date stopDatetime = visit.getStopDatetime();
    simpleObject.put("startDatetime", uiUtils.format(startDatetime));
    if (stopDatetime != null) {
        simpleObject.put("stopDatetime", uiUtils.format(stopDatetime));
    } else {
        simpleObject.put("stopDatetime", null);
    }
    VisitDomainWrapper visitWrapper = new VisitDomainWrapper(visit, emrApiProperties);
    List<SimpleObject> encounters = getEncounterListAsJson(parseEncounterToJson, visitWrapper, authenticatedUser, encounterIndex, encounterCount);
    simpleObject.put("encounters", encounters);
    simpleObject.put("admitted", visitWrapper.isAdmitted());
    simpleObject.put("canDeleteVisit", verifyIfUserHasPermissionToDeleteVisit(visit, authenticatedUser, canDeleteVisit));
    AppContextModel contextModel = sessionContext.generateAppContextModel();
    contextModel.put("patient", new PatientContextModel(visit.getPatient()));
    contextModel.put("visit", new VisitContextModel(new VisitDomainWrapper(visit, emrApiProperties)));
    List<Extension> visitActions = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.visitActions", contextModel);
    Collections.sort(visitActions);
    simpleObject.put("availableVisitActions", convertVisitActionsToSimpleObject(visitActions));
    return simpleObject;
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) ParseEncounterToJson(org.openmrs.module.coreapps.parser.ParseEncounterToJson) User(org.openmrs.User) PatientContextModel(org.openmrs.module.coreapps.contextmodel.PatientContextModel) SimpleObject(org.openmrs.ui.framework.SimpleObject) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) Date(java.util.Date) VisitContextModel(org.openmrs.module.coreapps.contextmodel.VisitContextModel)

Example 8 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-mirebalais by PIH.

the class CustomAppLoaderFactory method enableHIV.

private void enableHIV() {
    // ZL HIV forms
    Extension hivInitial = visitAction(Extensions.HIV_ZL_INITIAL_VISIT_ACTION, "pih.task.hivIntake.label", "icon-asterisk", "link", enterStandardHtmlFormLink("pihcore:htmlforms/haiti/hiv/zl/hiv-intake.xml&returnUrl=/" + WebConstants.CONTEXT_PATH + "/" + patientVisitsPageUrl), Privileges.TASK_EMR_ENTER_HIV_CONSULT_NOTE.privilege(), and(sessionLocationHasTag(LocationTags.HIV_CONSULT_LOCATION), or(and(userHasPrivilege(Privileges.TASK_EMR_ENTER_HIV_CONSULT_NOTE), patientHasActiveVisit()), userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE), and(userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE_THIS_PROVIDER_ONLY), patientVisitWithinPastThirtyDays(config)))));
    extensions.add(hivInitial);
    extensions.add(cloneAsHivVisitAction(hivInitial));
    Extension hivFollowup = visitAction(Extensions.HIV_ZL_FOLLOWUP_VISIT_ACTION, "pih.task.hivFollowup.label", "icon-asterisk", "link", enterStandardHtmlFormLink("pihcore:htmlforms/haiti/hiv/zl/hiv-followup.xml&returnUrl=/" + WebConstants.CONTEXT_PATH + "/" + patientVisitsPageUrl), Privileges.TASK_EMR_ENTER_HIV_CONSULT_NOTE.privilege(), and(sessionLocationHasTag(LocationTags.HIV_CONSULT_LOCATION), or(and(userHasPrivilege(Privileges.TASK_EMR_ENTER_HIV_CONSULT_NOTE), patientHasActiveVisit()), userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE), and(userHasPrivilege(Privileges.TASK_EMR_RETRO_CLINICAL_NOTE_THIS_PROVIDER_ONLY), patientVisitWithinPastThirtyDays(config)))));
    extensions.add(hivFollowup);
    extensions.add(cloneAsHivVisitAction(hivFollowup));
    // this provides the javascript & dialogs the backs the overall action buttons (to start/end visits, etc)
    extensions.add(fragmentExtension(Extensions.HIV_DASHBOARD_VISIT_INCLUDES, "coreapps", "patientdashboard/visitIncludes", null, HIVProgram.HIV.uuid() + ".includeFragments", map("patientVisitsPage", patientVisitsPageWithSpecificVisitUrl)));
    addFeatureToggleToExtension(findExtensionById(Extensions.HIV_ZL_INITIAL_VISIT_ACTION), "hiv");
    addFeatureToggleToExtension(findExtensionById(Extensions.HIV_ZL_FOLLOWUP_VISIT_ACTION), "hiv");
    // HIV dashboard configuration
    apps.add(addToHivDashboardFirstColumn(app(Apps.HIV_PATIENT_PROGRAM_SUMMARY, "coreapps.currentEnrollmentDashboardWidget.label", // TODO figure out right icon
    "icon-stethoscope", null, // TODO restrict by privilege or location)
    null, objectNode("widget", "programstatus", "icon", "icon-stethoscope", "label", "coreapps.currentEnrollmentDashboardWidget.label", "dateFormat", "dd MMM yyyy", "program", HIVProgram.HIV.uuid(), // TODO what should this be
    "locationTag", // TODO what should this be
    LocationTags.VISIT_LOCATION.uuid())), "coreapps", "dashboardwidgets/dashboardWidget"));
    addFeatureToggleToApp(findAppById(Apps.HIV_PATIENT_PROGRAM_SUMMARY), "hiv");
    apps.add(addToHivDashboardFirstColumn(app(Apps.HIV_OBS_CHART, "pih.app.hivObsChart.title", "icon-list-alt", null, null, objectNode("widget", "obsacrossencounters", "icon", "icon-list-alt", "label", "pih.app.hivObsChart.title", "concepts", MirebalaisConstants.WEIGHT_CONCEPT_UUID + "," + MirebalaisConstants.CD4_COUNT_UUID + "," + MirebalaisConstants.VIRAL_LOAD_UUID, // TODO what should this be?
    "maxResults", // TODO what should this be?
    "6")), "coreapps", "dashboardwidgets/dashboardWidget"));
    addFeatureToggleToApp(findAppById(Apps.HIV_OBS_CHART), "hiv");
    apps.add(addToHivDashboardSecondColumn(app(Apps.HIV_PATIENT_PROGRAM_HISTORY, "coreapps.programHistoryDashboardWidget.label", // TODO figure out right icon
    "icon-stethoscope", null, // TODO restrict by privilege or location)
    null, objectNode("icon", "icon-stethoscope", "label", "coreapps.programHistoryDashboardWidget.label", "dateFormat", "dd MMM yyyy", "program", HIVProgram.HIV.uuid(), "includeActive", false, // TODO what should this be
    "locationTag", // TODO what should this be
    LocationTags.VISIT_LOCATION.uuid())), "coreapps", "program/programHistory"));
    addFeatureToggleToApp(findAppById(Apps.HIV_PATIENT_PROGRAM_HISTORY), "hiv");
    apps.add(addToHivDashboardSecondColumn(app(Apps.HIV_CD4_GRAPH, "pih.app.hivcd4Graph.title", "icon-bar-chart", null, null, objectNode("widget", "obsgraph", "icon", "icon-bar-chart", "label", "pih.app.hivcd4Graph.title", "conceptId", MirebalaisConstants.CD4_COUNT_UUID, // TODO what should this be?
    "maxResults", // TODO what should this be?
    "20")), "coreapps", "dashboardwidgets/dashboardWidget"));
    addFeatureToggleToApp(findAppById(Apps.HIV_CD4_GRAPH), "hiv");
    apps.add(addToHivDashboardSecondColumn(app(Apps.HIV_WEIGHT_GRAPH, "pih.app.hivWeightGraph.title", "icon-bar-chart", null, null, objectNode("widget", "obsgraph", "icon", "icon-bar-chart", "label", "pih.app.hivWeightGraph.title", "conceptId", MirebalaisConstants.WEIGHT_CONCEPT_UUID, // TODO what should this be?
    "maxResults", // TODO what should this be?
    "20")), "coreapps", "dashboardwidgets/dashboardWidget"));
    addFeatureToggleToApp(findAppById(Apps.HIV_WEIGHT_GRAPH), "hiv");
    extensions.add(hivOverallAction(Extensions.CREATE_HIV_VISIT_OVERALL_ACTION, "coreapps.task.startVisit.label", "icon-check-in", "script", "visit.showQuickVisitCreationDialog({{patient.patientId}})", "Task: coreapps.createVisit", and(patientDoesNotActiveVisit(), patientNotDead())));
    // TODO correct the privilege
    apps.add(addToProgramSummaryListPage(app(Apps.HIV_PROGRAM_SUMMARY_DASHBOARD, "pih.app.hiv.programSummary.dashboard", "icon-list-alt", "/coreapps/summarydashboard/summaryDashboard.page?app=" + Apps.HIV_PROGRAM_SUMMARY_DASHBOARD, Privileges.APP_COREAPPS_SUMMARY_DASHBOARD.privilege(), objectNode("program", HIVProgram.HIV.uuid())), null));
    apps.add(addToHivSummaryDashboardFirstColumn(app(Apps.HIV_PROGRAM_STATISTICS, "pih.app.hivProgramStatistics.title", // TODO figure out right icon
    "icon-stethoscope", null, // TODO restrict by privilege or location)
    null, objectNode("widget", "programstatistics", "icon", "icon-stethoscope", "label", "pih.app.hivProgramStatistics.title", "dateFormat", "dd MMM yyyy", "program", HIVProgram.HIV.uuid())), "coreapps", "dashboardwidgets/dashboardWidget"));
}
Also used : CustomAppLoaderUtil.fragmentExtension(org.openmrs.module.mirebalais.apploader.CustomAppLoaderUtil.fragmentExtension) CustomAppLoaderUtil.addFeatureToggleToExtension(org.openmrs.module.mirebalais.apploader.CustomAppLoaderUtil.addFeatureToggleToExtension) Extension(org.openmrs.module.appframework.domain.Extension) CustomAppLoaderUtil.containsExtension(org.openmrs.module.mirebalais.apploader.CustomAppLoaderUtil.containsExtension)

Example 9 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-mirebalais by PIH.

the class CustomAppLoaderTest method shouldCreateHeader.

@Test
public void shouldCreateHeader() {
    Extension extension = CustomAppLoaderUtil.header("id", "logo");
    assertThat(extension.getId(), is("id"));
    assertThat(extension.getExtensionPointId(), is(AppUiExtensions.HEADER_CONFIG_EXTENSION));
    assertThat(extension.getType(), is("config"));
    assertThat((String) extension.getExtensionParams().get("logo-icon-url"), is("logo"));
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) Test(org.junit.Test)

Example 10 with Extension

use of org.openmrs.module.appframework.domain.Extension in project openmrs-module-mirebalais 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)

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