use of org.openmrs.module.reporting.report.ReportData in project openmrs-module-pihcore by PIH.
the class InpatientStatsDailyReportFragmentController method evaluate.
public SimpleObject evaluate(@RequestParam("day") Date day, UiUtils ui, @SpringBean ReportDefinitionService reportDefinitionService) throws EvaluationException {
EvaluationContext context = new EvaluationContext();
context.addParameterValue("day", day);
ReportDefinition reportDefinition = reportDefinitionService.getDefinitionByUuid(INPATIENT_STATS_DAILY_REPORT_DEFINITION_UUID);
ReportData data = reportDefinitionService.evaluate(reportDefinition, context);
SimpleObject cohortResults = new SimpleObject();
MapDataSet cohortDataSet = (MapDataSet) data.getDataSets().get("cohorts");
for (Map.Entry<String, Object> entry : cohortDataSet.getData().getColumnValuesByKey().entrySet()) {
cohortResults.put(entry.getKey(), simplify(entry.getValue()));
}
return SimpleObject.create("cohorts", cohortResults, "evaluationContext", SimpleObject.fromObject(context, ui, "evaluationDate", "parameterValues"));
}
use of org.openmrs.module.reporting.report.ReportData in project openmrs-module-pihcore by PIH.
the class NonCodedDiagnosesPageController method post.
public void post(@SpringBean ReportDefinitionService reportDefinitionService, @SpringBean CoreAppsProperties coreAppsProperties, @RequestParam(required = false, value = "fromDate") Date fromDate, @RequestParam(required = false, value = "toDate") Date toDate, @RequestParam(required = false, value = "nonCoded") String nonCoded, @RequestParam(required = false, value = "provider") Provider provider, PageModel model) throws EvaluationException, IOException {
if (fromDate == null) {
fromDate = DateUtils.addDays(new Date(), -21);
}
if (toDate == null) {
toDate = new Date();
}
fromDate = DateUtil.getStartOfDay(fromDate);
toDate = DateUtil.getEndOfDay(toDate);
Map<String, Object> params = new HashMap<String, Object>();
params.put("fromDate", fromDate);
params.put("toDate", toDate);
if (StringUtils.isBlank(nonCoded)) {
nonCoded = "";
}
params.put("nonCoded", nonCoded);
model.addAttribute("nonCoded", nonCoded);
Integer providerId = null;
if (provider != null) {
params.put("provider", provider);
providerId = provider.getId();
} else {
params.put("provider", null);
}
model.addAttribute("providerId", providerId);
EvaluationContext context = new EvaluationContext();
context.setParameterValues(params);
ReportDefinition reportDefinition = reportDefinitionService.getDefinitionByUuid(NON_CODED_DIAGNOSES_REPORT_DEFINITION_UUID);
ReportData reportData = reportDefinitionService.evaluate(reportDefinition, context);
model.addAttribute("nonCodedRows", reportData.getDataSets().get("data"));
model.addAttribute("reportDefinition", reportDefinition);
model.addAttribute("fromDate", fromDate);
model.addAttribute("toDate", DateUtil.getStartOfDay(toDate));
model.addAttribute("providers", getAllProviders());
model.addAttribute("dashboardUrl", coreAppsProperties.getDashboardUrl());
}
Aggregations