Search in sources :

Example 1 with AppDescriptor

use of org.openmrs.module.appframework.domain.AppDescriptor 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"));
}
Also used : AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor) Redirect(org.openmrs.ui.framework.page.Redirect) Test(org.junit.Test)

Example 2 with AppDescriptor

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

the class AwaitingAdmissionPageController method get.

public void get(PageModel model, @SpringBean AllDefinitionLibraries libraries, @SpringBean DataSetDefinitionService dsdService, @SpringBean CoreAppsProperties coreAppsProperties, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService) throws EvaluationException {
    EvaluationContext context = new EvaluationContext();
    List<Extension> admissionActions = appFrameworkService.getExtensionsForCurrentUser("coreapps.app.awaitingAdmissionActions");
    Collections.sort(admissionActions);
    model.addAttribute("admissionActions", admissionActions);
    DataSet dataSet = null;
    VisitDataSetDefinition dsd = new VisitDataSetDefinition();
    AwaitingAdmissionVisitQuery query = new AwaitingAdmissionVisitQuery();
    dsd.addRowFilter(query, null);
    dsd.addColumn("visitId", libraries.getDefinition(VisitDataDefinition.class, "reporting.library.visitDataDefinition.builtIn.visitId"), "");
    dsd.addColumn("patientId", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.patientId"), "");
    dsd.addColumn("patientLastName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.familyName"), "");
    dsd.addColumn("patientFirstName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.givenName"), "");
    dsd.addColumn("primaryIdentifier", libraries.getDefinition(PatientDataDefinition.class, "emrapi.patientDataDefinition.primaryIdentifier"), "", new PropertyConverter(String.class, "identifier"));
    dsd.addColumn("mostRecentAdmissionRequestFromLocation", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("fromLocation", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestToLocation", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("toLocation", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestDatetime", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("datetime", null));
    dsd.addColumn("mostRecentAdmissionRequestProvider", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("provider", new ObjectFormatter()));
    dsd.addColumn("mostRecentAdmissionRequestDiagnoses", libraries.getDefinition(VisitDataDefinition.class, "emrapi.visitDataDefinition.mostRecentAdmissionRequest"), "", new MapElementConverter("diagnoses", new AwaitingAdmissionDiagnosisFormatter()));
    // add the paper record identifier, if the definition is available (provided by the paper record module)
    PatientDataDefinition paperRecordIdentifierDefinition = libraries.getDefinition(PatientDataDefinition.class, "paperrecord.patientDataDefinition.paperRecordIdentifier");
    if (paperRecordIdentifierDefinition != null) {
        model.addAttribute("paperRecordIdentifierDefinitionAvailable", true);
        dsd.addColumn("paperRecordIdentifier", paperRecordIdentifierDefinition, "", new PropertyConverter(String.class, "identifier"));
    } else {
        model.addAttribute("paperRecordIdentifierDefinitionAvailable", false);
    }
    dsd.addSortCriteria("mostRecentAdmissionRequestDatetime", SortCriteria.SortDirection.ASC);
    dataSet = dsdService.evaluate(dsd, context);
    model.addAttribute("awaitingAdmissionList", DataSetUtil.simplify(dataSet));
    // add location tag constants
    model.addAttribute("supportsAdmissionLocationTag", EmrApiConstants.LOCATION_TAG_SUPPORTS_ADMISSION);
    model.addAttribute("supportsLoginLocationTag", EmrApiConstants.LOCATION_TAG_SUPPORTS_LOGIN);
    // used to determine whether or not we display a link to the patient in the results list
    model.addAttribute("privilegePatientDashboard", CoreAppsConstants.PRIVILEGE_PATIENT_DASHBOARD);
    AppDescriptor app = appFrameworkService.getApp(CoreAppsConstants.AWAITING_ADMISSION);
    String patientPageUrl = app.getConfig().get("patientPageUrl") != null ? app.getConfig().get("patientPageUrl").getTextValue() : coreAppsProperties.getDashboardUrl();
    model.addAttribute("patientPageUrl", patientPageUrl);
}
Also used : VisitDataSetDefinition(org.openmrs.module.reporting.dataset.definition.VisitDataSetDefinition) DataSet(org.openmrs.module.reporting.dataset.DataSet) Extension(org.openmrs.module.appframework.domain.Extension) AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor) AwaitingAdmissionVisitQuery(org.openmrs.module.emrapi.adt.reporting.query.AwaitingAdmissionVisitQuery) ObjectFormatter(org.openmrs.module.reporting.data.converter.ObjectFormatter) PatientDataDefinition(org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition) PropertyConverter(org.openmrs.module.reporting.data.converter.PropertyConverter) VisitDataDefinition(org.openmrs.module.reporting.data.visit.definition.VisitDataDefinition) EvaluationContext(org.openmrs.module.reporting.evaluation.EvaluationContext) MapElementConverter(org.openmrs.module.reporting.data.converter.MapElementConverter)

Example 3 with AppDescriptor

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

the class AppTest method testFindPatientAppHasHomepageExtension.

@Test
public void testFindPatientAppHasHomepageExtension() throws Exception {
    AppDescriptor app = AppTestUtil.getAppDescriptor("coreapps.findPatient");
    assertThat(app.getExtensions(), hasSize(1));
    assertThat(app.getExtensions().get(0).getExtensionPointId(), is("org.openmrs.referenceapplication.homepageLink"));
}
Also used : AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor) Test(org.junit.Test)

Example 4 with AppDescriptor

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

the class VisitsSectionFragmentController method controller.

public void controller(FragmentConfiguration config, PageModel pageModel, FragmentModel model, UiUtils ui, UiSessionContext sessionContext, @SpringBean("appframeworkTemplateFactory") TemplateFactory templateFactory, @SpringBean("coreAppsProperties") CoreAppsProperties coreAppsProperties, @InjectBeans PatientDomainWrapper patientWrapper, @SpringBean("adtService") AdtService adtService, @SpringBean("visitTypeHelper") VisitTypeHelper visitTypeHelper) {
    config.require("patient");
    Object patient = config.get("patient");
    if (patient instanceof Patient) {
        patientWrapper.setPatient((Patient) patient);
        config.addAttribute("patient", patientWrapper);
    } else if (patient instanceof PatientDomainWrapper) {
        patientWrapper = (PatientDomainWrapper) patient;
    }
    AppContextModel contextModel = sessionContext.generateAppContextModel();
    contextModel.put("patient", new PatientContextModel(patientWrapper.getPatient()));
    // backwards-compatible for links that still specify patient uuid substitution with "{{patientId}}"
    contextModel.put("patientId", patientWrapper.getPatient().getUuid());
    AppDescriptor app = (AppDescriptor) pageModel.get("app");
    String visitsPageWithSpecificVisitUrl = null;
    String visitsPageUrl = null;
    // see if the app specifies urls to use
    if (app != null) {
        try {
            visitsPageWithSpecificVisitUrl = app.getConfig().get("visitUrl").getTextValue();
        } catch (Exception ex) {
        }
        try {
            visitsPageUrl = app.getConfig().get("visitsUrl").getTextValue();
        } catch (Exception ex) {
        }
    }
    if (visitsPageWithSpecificVisitUrl == null) {
        visitsPageWithSpecificVisitUrl = coreAppsProperties.getVisitsPageWithSpecificVisitUrl();
    }
    visitsPageWithSpecificVisitUrl = "/" + ui.contextPath() + "/" + visitsPageWithSpecificVisitUrl;
    if (visitsPageUrl == null) {
        visitsPageUrl = coreAppsProperties.getVisitsPageUrl();
    }
    // hack fix for RA-1002--if there is an active visit, and we are using the "regular" visit dashboard we actually want to link to the specific visit
    Location visitLocation = adtService.getLocationThatSupportsVisits(sessionContext.getSessionLocation());
    VisitDomainWrapper activeVisit = adtService.getActiveVisit(patientWrapper.getPatient(), visitLocation);
    if (visitsPageUrl.contains("/coreapps/patientdashboard/patientDashboard.page?") && activeVisit != null) {
        visitsPageUrl = coreAppsProperties.getVisitsPageWithSpecificVisitUrl();
        contextModel.put("visit", activeVisit.getVisit());
    }
    visitsPageUrl = "/" + ui.contextPath() + "/" + visitsPageUrl;
    model.addAttribute("visitsUrl", templateFactory.handlebars(visitsPageUrl, contextModel));
    List<VisitDomainWrapper> recentVisits = patientWrapper.getAllVisitsUsingWrappers();
    if (recentVisits.size() > 5) {
        recentVisits = recentVisits.subList(0, 5);
    }
    Map<VisitDomainWrapper, String> recentVisitsWithLinks = new LinkedHashMap<VisitDomainWrapper, String>();
    for (VisitDomainWrapper recentVisit : recentVisits) {
        contextModel.put("visit", new VisitContextModel(recentVisit));
        // since the "recentVisit" isn't part of the context module, we bind it first to the visit url, before doing the handlebars binding against the context
        recentVisitsWithLinks.put(recentVisit, templateFactory.handlebars(ui.urlBind(visitsPageWithSpecificVisitUrl, recentVisit.getVisit()), contextModel));
    }
    Map<Integer, Map<String, Object>> recentVisitsWithAttr = visitTypeHelper.getVisitColorAndShortName(recentVisits);
    model.addAttribute("recentVisitsWithAttr", recentVisitsWithAttr);
    model.addAttribute("recentVisitsWithLinks", recentVisitsWithLinks);
    config.addAttribute("showVisitTypeOnPatientHeaderSection", visitTypeHelper.showVisitTypeOnPatientHeaderSection());
}
Also used : PatientDomainWrapper(org.openmrs.module.emrapi.patient.PatientDomainWrapper) Patient(org.openmrs.Patient) LinkedHashMap(java.util.LinkedHashMap) VisitContextModel(org.openmrs.module.coreapps.contextmodel.VisitContextModel) AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor) PatientContextModel(org.openmrs.module.coreapps.contextmodel.PatientContextModel) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Location(org.openmrs.Location)

Example 5 with AppDescriptor

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

the class PatientRegistrationApp method getAppDescriptor.

public AppDescriptor getAppDescriptor(Config config) {
    AppDescriptor d = new AppDescriptor();
    d.setId(CustomAppLoaderConstants.Apps.PATIENT_REGISTRATION);
    d.setDescription("registrationapp.registerPatient");
    d.setLabel("registrationapp.app.registerPatient.label");
    d.setIcon("icon-user");
    d.setUrl("registrationapp/findPatient.page?appId=" + CustomAppLoaderConstants.Apps.PATIENT_REGISTRATION);
    d.setRequiredPrivilege("App: registrationapp.registerPatient");
    d.setConfig(toObjectNode(getRegistrationAppConfig(config)));
    return d;
}
Also used : AppDescriptor(org.openmrs.module.appframework.domain.AppDescriptor)

Aggregations

AppDescriptor (org.openmrs.module.appframework.domain.AppDescriptor)15 Test (org.junit.Test)10 Redirect (org.openmrs.ui.framework.page.Redirect)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 JsonNode (org.codehaus.jackson.JsonNode)1 Location (org.openmrs.Location)1 Patient (org.openmrs.Patient)1 AppContextModel (org.openmrs.module.appframework.context.AppContextModel)1 Extension (org.openmrs.module.appframework.domain.Extension)1 PatientContextModel (org.openmrs.module.coreapps.contextmodel.PatientContextModel)1 VisitContextModel (org.openmrs.module.coreapps.contextmodel.VisitContextModel)1 AwaitingAdmissionVisitQuery (org.openmrs.module.emrapi.adt.reporting.query.AwaitingAdmissionVisitQuery)1 PatientDomainWrapper (org.openmrs.module.emrapi.patient.PatientDomainWrapper)1 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)1 Config (org.openmrs.module.pihcore.config.Config)1 MapElementConverter (org.openmrs.module.reporting.data.converter.MapElementConverter)1 ObjectFormatter (org.openmrs.module.reporting.data.converter.ObjectFormatter)1 PropertyConverter (org.openmrs.module.reporting.data.converter.PropertyConverter)1 PatientDataDefinition (org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition)1