From ad7ad6cff15793c386574f8b96c72fc2b44b2975 Mon Sep 17 00:00:00 2001 From: ODORA0 Date: Tue, 5 Nov 2019 08:28:03 +0300 Subject: [PATCH] Add startDate and endDate as configuration properties on RepeatPerTimePeriodDataSetDefinition --- .../RepeatPerTimePeriodDataSetDefinition.java | 30 +++++++++++++++++++ .../RepeatPerTimePeriodDataSetEvaluator.java | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/openmrs/module/reporting/dataset/definition/RepeatPerTimePeriodDataSetDefinition.java b/api/src/main/java/org/openmrs/module/reporting/dataset/definition/RepeatPerTimePeriodDataSetDefinition.java index b39240cc8e..22ca988811 100644 --- a/api/src/main/java/org/openmrs/module/reporting/dataset/definition/RepeatPerTimePeriodDataSetDefinition.java +++ b/api/src/main/java/org/openmrs/module/reporting/dataset/definition/RepeatPerTimePeriodDataSetDefinition.java @@ -9,9 +9,14 @@ */ package org.openmrs.module.reporting.dataset.definition; +import java.util.Date; + import org.openmrs.module.reporting.common.TimePeriod; import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty; import org.openmrs.module.reporting.evaluation.parameter.Mapped; +import org.openmrs.reporting.data.DatasetDefinition; +import org.openmrs.module.reporting.dataset.definition.RepeatPerTimePeriodDataSetDefinition; + /** * Will dynaically generate a list of iterations, and delegate to @@ -52,6 +57,12 @@ public class RepeatPerTimePeriodDataSetDefinition extends BaseDataSetDefinition @ConfigurationProperty private TimePeriod repeatPerTimePeriod; + @ConfigurationProperty + private DatasetDefinition endDate; + + @ConfigurationProperty + private DataSetDefinition startDate; + public Mapped getBaseDefinition() { return baseDefinition; } @@ -68,4 +79,23 @@ public void setRepeatPerTimePeriod(TimePeriod repeatPerTimePeriod) { this.repeatPerTimePeriod = repeatPerTimePeriod; } + /** + * @return the endDate + */ + public DataSetDefinition getendDate() { + return endDate; + } + + public void setEndDate(DataSetDefinition endDate){ + this.endDate = endDate; + } + + public DataSetDefinition getstartDate(){ + return startDate; + } + + public void setStartDate(DataSetDefinition startDate){ + this.startDate = startDate; + } + } diff --git a/api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluator.java b/api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluator.java index e51b99ca3b..ca9df31392 100644 --- a/api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluator.java +++ b/api/src/main/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluator.java @@ -56,7 +56,7 @@ public DataSet evaluate(DataSetDefinition dataSetDefinition, EvaluationContext e } DateTime thisPeriodStart = new DateTime(((Date) evalContext.getParameterValue("startDate")).getTime()); - DateTime end = new DateTime(DateUtil.getEndOfDayIfTimeExcluded((Date) evalContext.getParameterValue("endDate")).getTime()); + DateTime end = new DateTime(DateUtil.getEndOfDayIfTimeExcluded((Date) dsd.getendDate()).getTime()); while (thisPeriodStart.isBefore(end)) { DateTime nextPeriodStart = thisPeriodStart.plus(period.getJodaPeriod());