use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.
the class RegistrationDataSetManagerTest method testDataSet.
@Test
public void testDataSet() throws Exception {
DataSetDefinition dsd = registrationDataSetManager.constructDataSet();
EvaluationContext context = new EvaluationContext();
context.addParameterValue("startDate", DateUtil.getDateTime(2015, 1, 1));
context.addParameterValue("endDate", DateUtil.getDateTime(2015, 12, 31));
SimpleDataSet dataSet = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
DataSetRow row = dataSet.getRows().get(0);
Assert.assertEquals(1, dataSet.getRows().size());
Assert.assertEquals(29, dataSet.getMetaData().getColumnCount());
Assert.assertEquals("John", row.getColumnValue("GIVEN_NAME"));
Assert.assertEquals("Smitty", row.getColumnValue("NICKNAME"));
Assert.assertEquals("Smith", row.getColumnValue("FAMILY_NAME"));
Assert.assertEquals(DateUtil.getDateTime(1977, 11, 23), row.getColumnValue("BIRTHDATE"));
Assert.assertEquals(false, row.getColumnValue("BIRTHDATE_ESTIMATED"));
Assert.assertEquals(37.4, row.getColumnValue("AGE_AT_REGISTRATION"));
Assert.assertNull(row.getColumnValue("CHECK_IN_VISIT"));
Assert.assertEquals("M", row.getColumnValue("GENDER"));
Assert.assertEquals("555-1234", row.getColumnValue("TELEPHONE_NUMBER"));
Assert.assertEquals("Wichita", row.getColumnValue("BIRTHPLACE"));
Assert.assertEquals("Isabel", row.getColumnValue("MOTHERS_FIRST_NAME"));
Assert.assertEquals("MA", row.getColumnValue("HAITICORE.ADDRESS.STATEPROVINCE"));
Assert.assertEquals("Boston", row.getColumnValue("HAITICORE.ADDRESS.CITYVILLAGE"));
Assert.assertEquals("JP", row.getColumnValue("HAITICORE.ADDRESS.NEIGHBORHOODCELL"));
Assert.assertEquals("Pondside", row.getColumnValue("HAITICORE.ADDRESS.ADDRESS1"));
Assert.assertNull(row.getColumnValue("HAITICORE.ADDRESS.ADDRESS2"));
Assert.assertEquals("X3XK71", row.getColumnValue("EMR_ID"));
Assert.assertEquals(DateUtil.getDateTime(2015, 4, 15), row.getColumnValue("REGISTRATION_DATE"));
Assert.assertEquals(MirebalaisLocations.CLINIC_REGISTRATION.name(), row.getColumnValue("REGISTRATION_LOCATION"));
Assert.assertEquals("Married", row.getColumnValue("CIVIL_STATUS"));
Assert.assertEquals("true", row.getColumnValue("REGISTRATION_RETROSPECTIVE"));
Assert.assertEquals("true", row.getColumnValue("BIOMETRICS_COLLECTED"));
}
use of org.openmrs.module.reporting.evaluation.EvaluationContext 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.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.
the class DiagnosesDataSetManagerTest method testDataSet.
@Test
public void testDataSet() throws Exception {
DataSetDefinition dsd = diagnosesDataSetManager.constructDataSet();
EvaluationContext context = new EvaluationContext();
context.addParameterValue("startDate", DateUtil.getDateTime(2015, 1, 1));
context.addParameterValue("endDate", DateUtil.getDateTime(2015, 12, 31));
SimpleDataSet dataSet = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
// TODO: get this to test right parameters and work?
}
use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.
the class VitalsDataSetManagerTest method testDataSet.
@Test
public void testDataSet() throws Exception {
DataSetDefinition dsd = vitalsDataSetManager.constructDataSet();
EvaluationContext context = new EvaluationContext();
context.addParameterValue("startDate", DateUtil.getDateTime(2015, 1, 1));
Calendar c = Calendar.getInstance();
context.addParameterValue("endDate", DateUtil.getDateTime(c.get(Calendar.YEAR) + 1, 12, 31));
SimpleDataSet dataSet = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
DataSetRow row = dataSet.getRows().get(0);
Assert.assertEquals(1, dataSet.getRows().size());
Assert.assertEquals(24, dataSet.getMetaData().getColumnCount());
Assert.assertEquals(visit.getId(), row.getColumnValue("VITALS_VISIT"));
Assert.assertEquals(DateUtil.getDateTime(1977, 11, 23), row.getColumnValue("BIRTHDATE"));
Assert.assertEquals(false, row.getColumnValue("BIRTHDATE_ESTIMATED"));
// Assert.assertEquals(37.4, row.getColumnValue("AGE_AT_VITALS")); // we are testing real-time in this case, so ignore this parameter here
Assert.assertEquals("M", row.getColumnValue("GENDER"));
Assert.assertEquals(45.4, row.getColumnValue("WEIGHT_KG"));
Assert.assertEquals(152.4, row.getColumnValue("HEIGHT_CM"));
Assert.assertEquals(19.5, row.getColumnValue("BMI"));
Assert.assertEquals(65.0, row.getColumnValue("MUAC"));
Assert.assertEquals(35.5, row.getColumnValue("TEMP_C"));
Assert.assertEquals(120.0, row.getColumnValue("HEART_RATE"));
Assert.assertEquals(80.0, row.getColumnValue("RESP_RATE"));
Assert.assertEquals(90.0, row.getColumnValue("SYS_BP"));
Assert.assertEquals(110.0, row.getColumnValue("DIA_BP"));
Assert.assertEquals(95.0, row.getColumnValue("O2_SAT"));
Assert.assertEquals("headache", row.getColumnValue("CHIEF_COMPLAINT"));
Assert.assertEquals("false", row.getColumnValue("VITALS_RETROSPECTIVE"));
Assert.assertEquals("true", row.getColumnValue("BIOMETRICS_COLLECTED"));
}
use of org.openmrs.module.reporting.evaluation.EvaluationContext in project openmrs-module-pihcore by PIH.
the class DiagnosisCohortDefinitionEvaluatorTest method testEvaluateByAnyNonCoded.
@Test
public void testEvaluateByAnyNonCoded() throws Exception {
createDiagnosisObs();
DiagnosisCohortDefinition cd = new DiagnosisCohortDefinition();
cd.setIncludeAllNonCodedDiagnoses(true);
EvaluatedCohort cohort = evaluator.evaluate(cd, new EvaluationContext());
assertThat(cohort, hasExactlyIds(2, 7));
}
Aggregations