Skip to content

Commit

Permalink
Add startDate and endDate as configuration properties on RepeatPerTim…
Browse files Browse the repository at this point in the history
…ePeriodDataSetDefinition
  • Loading branch information
ODORA0 committed Nov 5, 2019
1 parent 7948915 commit ad7ad6c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,6 +57,12 @@ public class RepeatPerTimePeriodDataSetDefinition extends BaseDataSetDefinition
@ConfigurationProperty
private TimePeriod repeatPerTimePeriod;

@ConfigurationProperty
private DatasetDefinition endDate;

@ConfigurationProperty
private DataSetDefinition startDate;

public Mapped<? extends DataSetDefinition> getBaseDefinition() {
return baseDefinition;
}
Expand All @@ -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;
}

}
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 ad7ad6c

Please sign in to comment.