Search in sources :

Example 1 with FollowupParams

use of org.hisp.dhis.dataanalysis.FollowupParams in project dhis2-core by dhis2.

the class DataAnalysisController method markDataValues.

@PostMapping(value = "/followup/mark", consumes = APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public void markDataValues(@RequestBody UpdateFollowUpForDataValuesRequest params) {
    log.info("markDataValues from DataAnalysisController input " + params);
    List<DataValue> dataValues = new ArrayList<>();
    for (FollowupParams followup : params.getFollowups()) {
        DataElement dataElement = dataElementService.getDataElement(followup.getDataElementId());
        Period period = periodService.getPeriod(followup.getPeriodId());
        OrganisationUnit source = organisationUnitService.getOrganisationUnit(followup.getOrganisationUnitId());
        CategoryOptionCombo categoryOptionCombo = categoryService.getCategoryOptionCombo(followup.getCategoryOptionComboId());
        CategoryOptionCombo attributeOptionCombo = categoryService.getCategoryOptionCombo(followup.getAttributeOptionComboId());
        DataValue dataValue = dataValueService.getDataValue(dataElement, period, source, categoryOptionCombo, attributeOptionCombo);
        if (dataValue != null) {
            dataValue.setFollowup(followup.isFollowup());
            dataValues.add(dataValue);
        }
    }
    if (dataValues.size() > 0) {
        dataValueService.updateDataValues(dataValues);
    }
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DeflatedDataValue(org.hisp.dhis.datavalue.DeflatedDataValue) DataValue(org.hisp.dhis.datavalue.DataValue) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) FollowupParams(org.hisp.dhis.dataanalysis.FollowupParams) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ArrayList (java.util.ArrayList)1 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)1 FollowupParams (org.hisp.dhis.dataanalysis.FollowupParams)1 DataElement (org.hisp.dhis.dataelement.DataElement)1 DataValue (org.hisp.dhis.datavalue.DataValue)1 DeflatedDataValue (org.hisp.dhis.datavalue.DeflatedDataValue)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Period (org.hisp.dhis.period.Period)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1