use of org.openmrs.module.reporting.dataset.DataSet in project openmrs-module-pihcore by PIH.
the class DailyClinicalEncountersDataSetManagerTest method testReport.
@Test
public void testReport() throws Exception {
EvaluationContext context = new EvaluationContext();
context.addParameterValue("day", DateUtil.parseDate("2013-10-01", "yyyy-MM-dd"));
DataSetDescriptor byLocationDescriptor = new DataSetDescriptor();
byLocationDescriptor.setKey("byLocation");
DataSetDefinition dataSetDefinition = manager.constructDataSetDefinition(byLocationDescriptor, null);
DataSet byLocation = dataSetDefinitionService.evaluate(dataSetDefinition, context);
for (DataSetRow row : byLocation) {
if (row.getColumnValue("rowLabel").equals("Klinik Ekstèn")) {
assertThat((Cohort) row.getColumnValue("clinicalCheckIns"), isCohortWithExactlyMembers(p2, p4));
assertThat((Cohort) row.getColumnValue("vitals"), isCohortWithExactlyMembers(p2, p3));
assertThat((Cohort) row.getColumnValue("consults"), isCohortWithExactlyMembers(p2, p4));
assertThat((Cohort) row.getColumnValue("consultWithoutVitals"), isCohortWithExactlyMembers(p4));
} else {
assertThat((Cohort) row.getColumnValue("clinicalCheckIns"), isCohortWithExactlyMembers());
assertThat((Cohort) row.getColumnValue("vitals"), isCohortWithExactlyMembers());
assertThat((Cohort) row.getColumnValue("consults"), isCohortWithExactlyMembers());
assertThat((Cohort) row.getColumnValue("consultWithoutVitals"), isCohortWithExactlyMembers());
}
}
}
use of org.openmrs.module.reporting.dataset.DataSet in project openmrs-module-pihcore by PIH.
the class InpatientListPageController method get.
public void get(PageModel model, @SpringBean CoreAppsProperties coreAppsProperties, @SpringBean AllDefinitionLibraries libraries, @SpringBean DataSetDefinitionService dsdService) throws EvaluationException {
EvaluationContext context = new EvaluationContext();
Date today = new Date();
context.addParameterValue("day", today);
DataSet result = null;
PatientDataSetDefinition dsd = new PatientDataSetDefinition();
InpatientLocationCohortDefinition inpatientLocationCohortDefinition = new InpatientLocationCohortDefinition();
dsd.addRowFilter(inpatientLocationCohortDefinition, null);
dsd.addColumn("patientId", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.patientId"), "");
dsd.addColumn("familyName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.familyName"), "");
dsd.addColumn("givenName", libraries.getDefinition(PatientDataDefinition.class, "reporting.library.patientDataDefinition.builtIn.preferredName.givenName"), "");
dsd.addColumn("zlEmrId", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.preferredZlEmrId.identifier"), "");
dsd.addColumn("dossierNumber", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.mostRecentDossierNumber.identifier"), "");
dsd.addColumn("firstAdmittedLocation", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.admission.location"), "");
dsd.addColumn("admissionDateTime", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.admission.encounterDatetime"), "");
dsd.addColumn("inpatientLocation", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.inpatient.location"), "");
dsd.addColumn("inpatientDateTime", libraries.getDefinition(PatientDataDefinition.class, "mirebalais.patientDataCalculation.inpatient.encounterDatetime"), "");
result = dsdService.evaluate(dsd, context);
model.addAttribute("inpatientsList", DataSetUtil.simplify(result));
model.addAttribute("dashboardUrl", coreAppsProperties.getDashboardUrl());
// used to determine if we display links to patient dashboard)
model.put("privilegePatientDashboard", PihEmrConfigConstants.PRIVILEGE_APP_COREAPPS_PATIENT_DASHBOARD);
}
use of org.openmrs.module.reporting.dataset.DataSet 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.reporting.dataset.DataSet in project openmrs-module-pihcore by PIH.
the class DailyRegistrationsDataSetManagerTest method testReport.
@Test
public void testReport() throws Exception {
EvaluationContext context = new EvaluationContext();
context.addParameterValue("day", DateUtil.parseDate("2013-10-01", "yyyy-MM-dd"));
DataSetDescriptor byLocationDescriptor = new DataSetDescriptor();
byLocationDescriptor.setKey("byLocation");
DataSetDefinition byLocationDsd = manager.constructDataSetDefinition(byLocationDescriptor, null);
DataSet byLocation = dataSetDefinitionService.evaluate(byLocationDsd, context);
for (DataSetRow row : byLocation) {
if (row.getColumnValue("rowLabel").equals("Biwo Resepsyon")) {
assertThat((Cohort) row.getColumnValue("registrations"), isCohortWithExactlyMembers(p1));
} else {
assertThat((Cohort) row.getColumnValue("registrations"), isCohortWithExactlyMembers());
}
}
DataSetDescriptor overallDescriptor = new DataSetDescriptor();
overallDescriptor.setKey("overall");
DataSetDefinition overallDsd = manager.constructDataSetDefinition(overallDescriptor, null);
DataSet overall = dataSetDefinitionService.evaluate(overallDsd, context);
assertThat(overall.getMetaData().getColumnCount(), is(1));
DataSetRow overallRow = overall.iterator().next();
assertThat((Cohort) overallRow.getColumnValue("mirebalaisreports.dailyRegistrations.overall"), isCohortWithExactlyMembers(p1));
}
use of org.openmrs.module.reporting.dataset.DataSet in project openmrs-module-pihcore by PIH.
the class DailyCheckInsDataSetManagerTest method testReport.
@Test
public void testReport() throws Exception {
EvaluationContext context = new EvaluationContext();
context.addParameterValue("day", DateUtil.parseDate("2013-10-01", "yyyy-MM-dd"));
DataSetDescriptor byLocationDescriptor = new DataSetDescriptor();
byLocationDescriptor.setKey("byLocation");
DataSetDefinition byLocationDsd = manager.constructDataSetDefinition(byLocationDescriptor, null);
DataSet byLocation = dataSetDefinitionService.evaluate(byLocationDsd, context);
for (DataSetRow row : byLocation) {
if (row.getColumnValue("rowLabel").equals("Klinik Ekstèn")) {
for (Map.Entry<String, Object> e : row.getColumnValuesByKey().entrySet()) {
if ("mirebalaisreports.dailyCheckInEncounters.CLINICAL_new".equals(e.getKey())) {
assertThat((Cohort) e.getValue(), isCohortWithExactlyMembers(p2));
} else if ("mirebalaisreports.dailyCheckInEncounters.CLINICAL_return".equals(e.getKey())) {
assertThat((Cohort) e.getValue(), isCohortWithExactlyMembers(p4));
} else if ("Pharmacy only".equals(e.getKey())) {
assertThat((Cohort) e.getValue(), isCohortWithExactlyMembers(p3));
} else if (!"rowLabel".equals(e.getKey())) {
assertThat((Cohort) e.getValue(), isCohortWithExactlyIds());
}
}
} else {
// everything else should be empty
for (Map.Entry<String, Object> e : row.getColumnValuesByKey().entrySet()) {
if (!"rowLabel".equals(e.getKey())) {
assertThat((Cohort) e.getValue(), isCohortWithExactlyIds());
}
}
}
}
}
Aggregations