Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ public ReportDefinition constructReportDefinition() {
caScreening.addParameter(new Parameter("onOrAfter", "On Or After", Date.class));
caScreening.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class));
caScreening.setOperator(SetComparator.IN);
caScreening.setQuestion(cs.getConceptByUuid("e5e99fc7-ff2d-4306-aefd-b87a07fc9ab4")); // Screened for cervical cancer during this visit
caScreening.setQuestion(cs.getConceptByUuid("e5e99fc7-ff2d-4306-aefd-b87a07fc9ab4")); // Cervical cancer screening status
caScreening.setTimeModifier(TimeModifier.LAST);
List<Concept> caScreeningAnswers = new ArrayList<Concept>();
caScreeningAnswers.add(cs.getConceptByUuid("165619AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); // Cervical cancer screening performed
caScreening.setValueList(caScreeningAnswers);

SqlCohortDefinition ptLivingWithHIVsqd = new SqlCohortDefinition();

//What do you want to do? ---> Enroll new Pt in HIV Care
//Patient Type at Enrolment ---> Enroll new Pt in HIV Care
String sql = "SELECT DISTINCT p.patient_id FROM patient p WHERE p.voided = 0 "
+ "AND EXISTS (SELECT 1 FROM obs o JOIN concept c_question ON o.concept_id = c_question.concept_id JOIN concept c_answer ON o.value_coded = c_answer.concept_id WHERE o.person_id = p.patient_id AND c_question.uuid = '83e40f2c-c316-43e6-a12e-20a338100281' AND c_answer.uuid = '164144AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' AND o.voided = 0);";
ptLivingWithHIVsqd.setQuery(sql);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class DRCArtDeathReportManagerTest extends BaseModuleContextSensitiveTest
@Before
public void setup() throws Exception {
executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml");
executeDataSet("org/openmrs/module/drcreports/include/DRCARTDeathReportTestDataset.xml");
executeDataSet("org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml");

String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator;
System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path);
Expand All @@ -62,7 +62,7 @@ public void setup() throws Exception {
}

@Test
public void setupReport_shouldSetupDRCARTTransferOutReport() {
public void setupReport_shouldSetupDRCArtDeathReportReport() {

// replay
ReportManagerUtil.setupReport(manager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void setUp() throws Exception {
}

@Test
public void setupReport_shouldCreateExcelTemplateDesign() throws Exception {
public void setupReport_shouldCreateCsvDesign() throws Exception {
// setup

// replay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private IDatabaseConnection setupDatabaseConnection(Connection connection) throw
public void setUp() throws Exception {
updateDatabase("org/openmrs/module/drcreports/liquibase/test-liquibase.xml");
executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml");
executeDataSet("org/openmrs/module/drcreports/include/DRCARTSecondLineReportTestDataset.xml");
executeDataSet("org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml");

String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator;
System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path);
Expand All @@ -101,7 +101,7 @@ public void setUp() throws Exception {
}

@Test
public void setupReport_shouldCreateExcelTemplateDesign() throws Exception {
public void setupReport_shouldCreateCsvDesign() throws Exception {
// setup

// replay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void setup() throws Exception {
}

@Test
public void setupReport_shouldSetupDRCARTTransferOutReport() {
public void setupReport_shouldSetupDRCArtTransferInReport() {

// replay
ReportManagerUtil.setupReport(manager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class DRCArtTransferOutReportManagerTest extends BaseModuleContextSensiti
@Before
public void setup() throws Exception {
executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml");
executeDataSet("org/openmrs/module/drcreports/include/DRCARTTransferOutTestDataset.xml");
executeDataSet("org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml");

String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator;
System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path);
Expand All @@ -62,7 +62,7 @@ public void setup() throws Exception {
}

@Test
public void setupReport_shouldSetupDRCARTTransferOutReport() {
public void setupReport_shouldSetupDRCArtTransferOutReport() {

// replay
ReportManagerUtil.setupReport(manager);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package org.openmrs.module.drcreports.reports;

import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.openmrs.Cohort;
import org.openmrs.api.ConceptService;
import org.openmrs.module.initializer.Domain;
import org.openmrs.module.initializer.api.InitializerService;
import org.openmrs.module.initializer.api.loaders.Loader;
import org.openmrs.module.reporting.common.DateUtil;
import org.openmrs.module.reporting.dataset.DataSetRow;
import org.openmrs.module.reporting.evaluation.EvaluationContext;
import org.openmrs.module.reporting.report.ReportData;
import org.openmrs.module.reporting.report.definition.ReportDefinition;
import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService;
import org.openmrs.module.reporting.report.manager.ReportManagerUtil;
import org.openmrs.module.reporting.report.service.ReportService;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

public class DRCHivCaScreeningReportManagerTest extends BaseModuleContextSensitiveTest {

@Autowired
private InitializerService iniz;

@Autowired
private ReportService rs;

@Autowired
private ReportDefinitionService rds;

@Autowired
@Qualifier("conceptService")
private ConceptService cs;

@Autowired
private DRCHivCaScreeningReportManager manager;

@Before
public void setup() throws Exception {
executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml");
executeDataSet("org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml");

String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator;
System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path);

for (Loader loader : iniz.getLoaders()) {
if (loader.getDomainName().equals(Domain.JSON_KEY_VALUES.getName())) {
loader.load();
}
}
}

@Test
public void setupReport_shouldSetupDRCHivCaScreeningReport() {

// replay
ReportManagerUtil.setupReport(manager);

// verify
assertThat(rs.getReportDesignByUuid("8fd7b2bb-94b4-4e69-8839-95cb4de1b4c2"), is(notNullValue()));
}

@Test
public void testReport() throws Exception {

EvaluationContext context = new EvaluationContext();
context.addParameterValue("startDate", DateUtil.parseDate("2025-06-01", "yyyy-MM-dd"));
context.addParameterValue("endDate", DateUtil.parseDate("2025-06-30", "yyyy-MM-dd"));

ReportDefinition rd = manager.constructReportDefinition();
ReportData data = rds.evaluate(rd, context);

for (Iterator<DataSetRow> itr = data.getDataSets().get(rd.getName()).iterator(); itr.hasNext();) {
DataSetRow row = itr.next();
Map<String, Integer> columnValuePairs = getColumnValues();
for (String column : columnValuePairs.keySet()) {
assertThat(column, ((Cohort) row.getColumnValue(column)).getSize(), is(columnValuePairs.get(column)));
}
}
}

private Map<String, Integer> getColumnValues() {
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("DRC HIV+ women who received cervical cancer screening.30-49 years", 1);

return map;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<dataset>

<person person_id="15" gender="F" birthdate="2000-04-08 00:00:00.0" birthdate_estimated="0" dead="true" creator="1" date_created="2021-04-10 00:00:00.0" voided="false" uuid="9e6065af-bb72-4950-9cbe-3485ede16a61" />
<patient patient_id="15" creator="1" date_created="2005-09-22 00:00:00.0" changed_by="1" date_changed="2021-06-02 12:29:59.0" voided="false" void_reason="" />

<visit_type visit_type_id="11" name="General" description="General Visit Description" creator="1" date_created="2021-05-05 00:00:00.0" retired="false" uuid="34b74c43-8beb-4c29-95f3-e9f8d7a11bc4" />
<visit visit_id="16" patient_id="15" visit_type_id="11" date_started="2024-05-05 00:00:00.0" location_id="1" indication_concept_id="5497" creator="1" date_created="2024-01-01 00:00:00.0" voided="0" uuid="082a25c6-6fdc-4c33-85c7-e8faded20596" />
<visit visit_id="17" patient_id="15" visit_type_id="11" date_started="2025-06-26 00:00:00.0" location_id="1" indication_concept_id="5497" creator="1" date_created="2025-06-26 00:00:00.0" voided="0" uuid="082a25c6-6fdc-4c33-85c7-e8faded20597" />

<encounter encounter_id="16" encounter_type="2" visit_id="16" patient_id="15" location_id="1" form_id="2" encounter_datetime="2024-06-05 00:00:00.0" creator="1" date_created="2024-06-02 14:09:05.0" voided="false" void_reason="" uuid="37ec8a29-dba1-455a-a808-794ec883fcc8" />
<encounter encounter_id="17" encounter_type="2" visit_id="17" patient_id="15" location_id="1" form_id="2" encounter_datetime="2025-06-05 00:00:00.0" creator="1" date_created="2025-06-26 14:09:05.0" voided="false" void_reason="" uuid="37ec8a29-dba1-455a-a808-794ec883fcc9" />

<concept concept_id="862" retired="false" datatype_id="6" class_id="7" is_set="false" creator="1" date_created="2021-06-02 06:17:32.0" version="" uuid="159599AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
<concept concept_id="863" retired="false" datatype_id="6" class_id="7" is_set="false" creator="1" date_created="2021-06-02 06:17:32.0" version="" uuid="1543AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />


<concept_name concept_id="862" name="Antiretroviral treatment start date" locale="en" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="9036" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="false" uuid="666947cb-18da-4287-b579-15023917b6b3" />
<concept_name concept_id="863" name="Date of death" locale="en" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="9037" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="false" uuid="666947cb-18da-4287-b579-15023917b6b4" />

<!-- Antiretroviral treatment start date -->
<obs obs_id="4003" person_id="15" concept_id="862" encounter_id="16" obs_group_id="[NULL]" obs_datetime="2024-06-26 00:00:00.0" location_id="1" value_coded="[NULL]" comments="" creator="1" date_created="2024-06-26 14:09:35.0" voided="false" value_coded_name_id="[NULL]" value_complex="[NULL]" value_text="[NULL]" value_numeric="[NULL]" value_datetime="2024-06-23 00:00:00.0" value_drug="[NULL]" uuid="90b6abe2-eef9-4d03-aba7-5363a591cb1a" />
<!-- Date of death -->
<obs obs_id="4004" person_id="15" concept_id="863" encounter_id="17" obs_group_id="[NULL]" obs_datetime="2025-06-26 00:00:00.0" location_id="1" value_coded="[NULL]" comments="" creator="1" date_created="2025-06-26 14:09:35.0" voided="false" value_coded_name_id="[NULL]" value_complex="[NULL]" value_text="[NULL]" value_numeric="[NULL]" value_datetime="2025-06-20 00:00:00.0" value_drug="[NULL]" uuid="90b6abe2-eef9-4d03-aba7-5363a591cb1b" />

</dataset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>

<dataset>

<person person_id="15" gender="F" birthdate="1994-04-08 00:00:00.0" birthdate_estimated="0" dead="false" creator="1" date_created="2021-04-10 00:00:00.0" voided="false" uuid="9e6065af-bb72-4950-9cbe-3485ede16a61" />
<patient patient_id="15" creator="1" date_created="2005-09-22 00:00:00.0" changed_by="1" date_changed="2021-06-02 12:29:59.0" voided="false" void_reason="" />

<person person_id="16" gender="M" birthdate="2013-04-08 00:00:00.0" birthdate_estimated="0" dead="false" creator="1" date_created="2021-04-10 00:00:00.0" voided="false" uuid="4f895f0e-ac1f-46b9-a91d-8855d556672c" />
<patient patient_id="16" creator="1" date_created="2005-09-22 00:00:00.0" changed_by="1" date_changed="2021-06-02 12:29:59.0" voided="false" void_reason="" />

<visit_type visit_type_id="11" name="General" description="General Visit Description" creator="1" date_created="2021-05-05 00:00:00.0" retired="false" uuid="34b74c43-8beb-4c29-95f3-e9f8d7a11bc4" />
<visit visit_id="15" patient_id="15" visit_type_id="11" date_started="2025-06-26 00:00:00.0" location_id="1" indication_concept_id="5497" creator="1" date_created="2025-06-26 00:00:00.0" voided="0" uuid="082a25c6-6fdc-4c33-85c7-e8faded20597" />
<visit visit_id="16" patient_id="16" visit_type_id="11" date_started="2025-06-05 00:00:00.0" location_id="1" indication_concept_id="5497" creator="1" date_created="2024-01-01 00:00:00.0" voided="0" uuid="082a25c6-6fdc-4c33-85c7-e8faded20596" />

<encounter encounter_id="15" encounter_type="2" visit_id="15" patient_id="15" location_id="1" form_id="2" encounter_datetime="2025-06-05 00:00:00.0" creator="1" date_created="2025-06-26 14:09:05.0" voided="false" void_reason="" uuid="37ec8a29-dba1-455a-a808-794ec883fcc9" />
<encounter encounter_id="16" encounter_type="2" visit_id="16" patient_id="16" location_id="1" form_id="2" encounter_datetime="2025-06-05 00:00:00.0" creator="1" date_created="2024-06-02 14:09:05.0" voided="false" void_reason="" uuid="37ec8a29-dba1-455a-a808-794ec883fcc8" />

<!-- ARV regimen/code for drugs collected -->
<concept concept_id="862" retired="false" datatype_id="2" class_id="5" is_set="false" creator="1" date_created="2021-06-02 06:17:32.0" version="" uuid="164432AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />
<!-- AZT + 3TC + LPV/r -->
<concept concept_id="863" retired="false" datatype_id="3" class_id="11" is_set="false" creator="1" date_created="2021-06-02 06:17:32.0" version="" uuid="d2b1d784-a880-42a9-b0a6-19de2db7afd6" />
<!-- AZT + 3TC + ATV/r -->
<concept concept_id="864" retired="false" datatype_id="3" class_id="11" is_set="false" creator="1" date_created="2021-06-02 06:17:32.0" version="" uuid="62243dfe-6284-48a9-afcc-63149ac6d709" />

<concept_name concept_id="862" name="ARV regimen/code for drugs collected" locale="en" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="9036" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="false" uuid="666947cb-18da-4287-b579-15023917b6b3" />
<concept_name concept_id="863" name="AZT + 3TC + LPV/r" locale="en" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="9037" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="false" uuid="037ba287-69b2-4329-863e-7fdec85b6977" />
<concept_name concept_id="864" name="AZT + 3TC + ATV/r" locale="en" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="9037" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="false" uuid="037ba287-69b2-4329-863e-7fdec85b6977" />

<!-- Antiretroviral treatment refill model -> AZT + 3TC + LPV/r -->
<obs obs_id="4003" person_id="15" concept_id="862" encounter_id="15" obs_group_id="[NULL]" obs_datetime="2025-06-26 00:00:00.0" location_id="1" value_coded="863" comments="" creator="1" date_created="2025-06-26 14:09:35.0" voided="false" value_coded_name_id="[NULL]" value_complex="[NULL]" value_text="[NULL]" value_numeric="[NULL]" value_datetime="[NULL]" value_drug="[NULL]" uuid="76121c76-5cef-4f74-8dc2-838c80101841" />

<!-- Antiretroviral treatment refill model -> AZT + 3TC + ATV/r -->
<obs obs_id="4004" person_id="16" concept_id="862" encounter_id="16" obs_group_id="[NULL]" obs_datetime="2025-06-26 00:00:00.0" location_id="1" value_coded="864" comments="" creator="1" date_created="2025-06-26 14:09:35.0" voided="false" value_coded_name_id="[NULL]" value_complex="[NULL]" value_text="[NULL]" value_numeric="[NULL]" value_datetime="[NULL]" value_drug="[NULL]" uuid="c09769e5-7d0b-45d5-a731-ac06d694c37a" />

</dataset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<dataset>

<person person_id="15" gender="F" birthdate="2000-04-08 00:00:00.0" birthdate_estimated="0" dead="false" creator="1" date_created="2021-04-10 00:00:00.0" voided="false" uuid="9e6065af-bb72-4950-9cbe-3485ede16a61" />
<patient patient_id="15" creator="1" date_created="2005-09-22 00:00:00.0" changed_by="1" date_changed="2021-06-02 12:29:59.0" voided="false" void_reason="" />

<visit_type visit_type_id="11" name="General" description="General Visit Description" creator="1" date_created="2021-05-05 00:00:00.0" retired="false" uuid="34b74c43-8beb-4c29-95f3-e9f8d7a11bc4" />
<visit visit_id="16" patient_id="15" visit_type_id="11" date_started="2021-05-05 00:00:00.0" location_id="1" indication_concept_id="5497" creator="1" date_created="2005-01-01 00:00:00.0" voided="0" uuid="082a25c6-6fdc-4c33-85c7-e8faded20596" />

<encounter encounter_id="16" encounter_type="2" visit_id="16" patient_id="15" location_id="1" form_id="2" encounter_datetime="2021-05-05 00:00:00.0" creator="1" date_created="2021-06-02 14:09:05.0" voided="false" void_reason="" uuid="37ec8a29-dba1-455a-a808-794ec883fcc8" />

<concept concept_id="862" retired="false" datatype_id="6" class_id="11" is_set="false" creator="1" date_created="2021-06-02 06:17:32.0" version="" uuid="160649AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />

<concept_name concept_id="862" name="Date transferred out" locale="en" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="9036" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="false" uuid="666947cb-18da-4287-b579-15023917b6b3" />

<!-- Date transferred out date -->
<obs obs_id="4003" person_id="15" concept_id="862" encounter_id="16" obs_group_id="[NULL]" obs_datetime="2021-06-02 00:00:00.0" location_id="1" value_coded="[NULL]" comments="" creator="1" date_created="2021-06-02 14:09:35.0" voided="false" value_coded_name_id="[NULL]" value_complex="[NULL]" value_text="[NULL]" value_numeric="[NULL]" value_datetime="2025-06-23 00:00:00.0" value_drug="[NULL]" uuid="90b6abe2-eef9-4d03-aba7-5363a591cb1a" />

</dataset>
Loading