diff --git a/api/src/main/java/org/openmrs/module/drcreports/reports/DRCTxCurrReportManager.java b/api/src/main/java/org/openmrs/module/drcreports/reports/DRCTxCurrReportManager.java index 3f55673..7c7e41d 100644 --- a/api/src/main/java/org/openmrs/module/drcreports/reports/DRCTxCurrReportManager.java +++ b/api/src/main/java/org/openmrs/module/drcreports/reports/DRCTxCurrReportManager.java @@ -221,6 +221,8 @@ public ReportDefinition constructReportDefinition() { SqlCohortDefinition liveSqlCD = new SqlCohortDefinition(); String liveSql = getStringFromResource("org/openmrs/module/drcreports/sql/DRCLivePatients.sql"); liveSqlCD.setQuery(liveSql); + liveSqlCD.addParameter(new Parameter("onOrAfter", "On Or After", Date.class)); + liveSqlCD.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class)); // Not stopped ART in date range SqlCohortDefinition notStoppedARTSqlCD = new SqlCohortDefinition(); diff --git a/api/src/main/resources/org/openmrs/module/drcreports/sql/DRCLivePatients.sql b/api/src/main/resources/org/openmrs/module/drcreports/sql/DRCLivePatients.sql index c3a5db8..fb5d046 100644 --- a/api/src/main/resources/org/openmrs/module/drcreports/sql/DRCLivePatients.sql +++ b/api/src/main/resources/org/openmrs/module/drcreports/sql/DRCLivePatients.sql @@ -4,12 +4,13 @@ INNER JOIN person pe ON p.patient_id = pe.person_id WHERE pe.voided = 0 AND p.voided = 0 AND NOT EXISTS ( - -- Check that patient does NOT have death date observation + -- Check that patient does NOT have death date observation in the date range SELECT 1 FROM obs o INNER JOIN concept c ON o.concept_id = c.concept_id WHERE o.person_id = p.patient_id AND o.voided = 0 AND c.uuid = '1543AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + AND DATE(o.value_datetime) BETWEEN :onOrAfter AND :onOrBefore ) ORDER BY p.patient_id; \ No newline at end of file