Skip to content

Commit

Permalink
REPORT-635: Add startDate and endDate as configuration properties on …
Browse files Browse the repository at this point in the history
…RepeatPerTimePeriodDataSetDefinition
  • Loading branch information
ODORA0 committed Dec 12, 2019
1 parent de48eac commit 84091e1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<? extends DataSetDefinition> getBaseDefinition() {
return baseDefinition;
}
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 84091e1

Please sign in to comment.