diff --git a/api/src/main/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManager.java b/api/src/main/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManager.java index 51d65ba..a3fdb66 100644 --- a/api/src/main/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManager.java +++ b/api/src/main/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManager.java @@ -129,7 +129,7 @@ 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 caScreeningAnswers = new ArrayList(); caScreeningAnswers.add(cs.getConceptByUuid("165619AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); // Cervical cancer screening performed diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java index d519b0f..cc4a969 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java @@ -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); @@ -62,7 +62,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCARTTransferOutReport() { + public void setupReport_shouldSetupDRCArtDeathReportReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtHepatitisReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtHepatitisReportManagerTest.java index 143e003..c3d8d6e 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtHepatitisReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtHepatitisReportManagerTest.java @@ -101,7 +101,7 @@ public void setUp() throws Exception { } @Test - public void setupReport_shouldCreateExcelTemplateDesign() throws Exception { + public void setupReport_shouldCreateCsvDesign() throws Exception { // setup // replay diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java index 7a0a8fb..dd076de 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java @@ -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); @@ -101,7 +101,7 @@ public void setUp() throws Exception { } @Test - public void setupReport_shouldCreateExcelTemplateDesign() throws Exception { + public void setupReport_shouldCreateCsvDesign() throws Exception { // setup // replay diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java index 73f064b..40ef895 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java @@ -61,7 +61,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCARTTransferOutReport() { + public void setupReport_shouldSetupDRCArtTransferInReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferOutReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferOutReportManagerTest.java index 5aa175e..b8dac0a 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferOutReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferOutReportManagerTest.java @@ -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); @@ -62,7 +62,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCARTTransferOutReport() { + public void setupReport_shouldSetupDRCArtTransferOutReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java new file mode 100644 index 0000000..240dea3 --- /dev/null +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java @@ -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 itr = data.getDataSets().get(rd.getName()).iterator(); itr.hasNext();) { + DataSetRow row = itr.next(); + Map columnValuePairs = getColumnValues(); + for (String column : columnValuePairs.keySet()) { + assertThat(column, ((Cohort) row.getColumnValue(column)).getSize(), is(columnValuePairs.get(column))); + } + } + } + + private Map getColumnValues() { + Map map = new HashMap(); + map.put("DRC HIV+ women who received cervical cancer screening.30-49 years", 1); + + return map; + + } +} diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml new file mode 100644 index 0000000..3251f1a --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml new file mode 100644 index 0000000..4987e53 --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml new file mode 100644 index 0000000..d2a8bcc --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml new file mode 100644 index 0000000..8d46fdf --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml new file mode 100644 index 0000000..8d46fdf --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file