class DHIS2ReportingServiceImpl extends BaseOpenmrsService implements
			DHIS2ReportingService {

	@Override
	public DataValueSet evaluateReportDefinition(
			ReportDefinition reportDefinition, Period period,
			Location location, boolean priority) {
		Collection<DataValueTemplate> templates = reportDefinition
				.getDataValueTemplates();
		DataValueSet dataValueSet = new DataValueSet();
		dataValueSet.setDataElementIdScheme("code");
		dataValueSet.setOrgUnitIdScheme("code");
		dataValueSet.setPeriod(period.getAsIsoString());
		// dataValueSet.setOrgUnit( "OU_" + location.getId() ); /* Removed
		// because will set directly from the controller */
		dataValueSet.setDataSet(reportDefinition.getCode());

		Collection<DataValue> dataValues = dataValueSet.getDataValues();

		for (DataValueTemplate dvt : templates) {
			DataValue dataValue = new DataValue();
			dataValue.setDataElement(dvt.getDataelement().getCode());
			dataValue.setCategoryOptionCombo(dvt.getDisaggregation().getCode());

			try {
				String value = dao.evaluateDataValueTemplate(dvt, period,
						location, priority);
				if (value != null) {
					dataValue.setValue(value);
					dataValues.add(dataValue);
				}
			} catch (DHIS2ReportingException ex) {
				// TODO: percolate this through to UI
				log.warn(ex.getMessage());
			}
		}

		return dataValueSet;
	}

}