Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPORT-635: Add startDate and endDate as configuration properties on … #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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