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"));
}
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);
}
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"));
}
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());
}
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;
}
Aggregations