From 8f363729d81b5d1841a721a1783e4835de3bae05 Mon Sep 17 00:00:00 2001 From: ODORA0 Date: Thu, 12 Dec 2019 14:41:11 +0300 Subject: [PATCH] REPORT-635: Add startDate and endDate as configuration properties on RepeatPerTimePeriodDataSetDefinition --- .../RepeatPerTimePeriodDataSetDefinition.java | 24 +++++++++++++++++++ .../RepeatPerTimePeriodDataSetEvaluator.java | 2 +- 2 files changed, 25 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..d9af050217 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,6 +9,8 @@ */ 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; @@ -52,6 +54,12 @@ public class RepeatPerTimePeriodDataSetDefinition extends BaseDataSetDefinition @ConfigurationProperty private TimePeriod repeatPerTimePeriod; + @ConfigurationProperty(group = "obsDateTimeGroup") + private Date startDate; + + @ConfigurationProperty(group = "obsDateTimeGroup") + private Date endDate; + public Mapped getBaseDefinition() { return baseDefinition; } @@ -68,4 +76,20 @@ public void setRepeatPerTimePeriod(TimePeriod repeatPerTimePeriod) { this.repeatPerTimePeriod = repeatPerTimePeriod; } + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate){ + this.startDate = startDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate){ + this.endDate = endDate; + } + } 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..5e9da42b66 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());