Search in sources :

Example 16 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class MergeServiceTest method testIndicatorClone.

@Test
public void testIndicatorClone() {
    IndicatorType indicatorType = createIndicatorType('A');
    Indicator indicator = createIndicator('A', indicatorType);
    Indicator clone = mergeService.clone(indicator);
    assertEquals(indicator.getName(), clone.getName());
    assertEquals(indicator.getUid(), clone.getUid());
    assertEquals(indicator.getCode(), clone.getCode());
    assertEquals(indicator.getIndicatorType(), clone.getIndicatorType());
}
Also used : IndicatorType(org.hisp.dhis.indicator.IndicatorType) Indicator(org.hisp.dhis.indicator.Indicator) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 17 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class ObjectBundleServiceTest method testCreateMetadataWithIndicator.

@Test
public void testCreateMetadataWithIndicator() throws IOException {
    Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/metadata_with_indicators.json").getInputStream(), RenderFormat.JSON);
    ObjectBundleParams params = new ObjectBundleParams();
    params.setObjectBundleMode(ObjectBundleMode.COMMIT);
    params.setImportStrategy(ImportStrategy.CREATE);
    params.setObjects(metadata);
    ObjectBundle bundle = objectBundleService.create(params);
    ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle);
    assertTrue(validate.getErrorReports().isEmpty());
    objectBundleService.commit(bundle);
    List<OrganisationUnit> organisationUnits = manager.getAll(OrganisationUnit.class);
    List<DataElement> dataElements = manager.getAll(DataElement.class);
    List<Indicator> indicators = manager.getAll(Indicator.class);
    assertFalse(organisationUnits.isEmpty());
    assertEquals(3, dataElements.size());
    assertEquals(1, indicators.size());
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ObjectBundleValidationReport(org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport) ClassPathResource(org.springframework.core.io.ClassPathResource) Indicator(org.hisp.dhis.indicator.Indicator) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) DataElement(org.hisp.dhis.dataelement.DataElement) List(java.util.List) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 18 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class ExpressionServiceTest method testGetIndicatorValue.

@Test
public void testGetIndicatorValue() {
    IndicatorType indicatorType = new IndicatorType("A", 100, false);
    Indicator indicatorA = createIndicator('A', indicatorType);
    indicatorA.setNumerator(expressionE);
    indicatorA.setDenominator(expressionF);
    Indicator indicatorB = createIndicator('B', indicatorType);
    indicatorB.setNumerator(expressionN);
    indicatorB.setDenominator(expressionF);
    Map<DataElementOperand, Double> valueMap = new HashMap<>();
    valueMap.put(new DataElementOperand(deA, coc), 12d);
    valueMap.put(new DataElementOperand(deB, coc), 34d);
    valueMap.put(new DataElementOperand(deA, cocA, cocB), 46d);
    valueMap.put(new DataElementOperand(deB, cocA), 10d);
    Map<String, Double> constantMap = new HashMap<>();
    constantMap.put(constantA.getUid(), 2.0);
    assertEquals(200d, expressionService.getIndicatorValue(indicatorA, period, valueMap, constantMap, null), DELTA);
    assertEquals(300d, expressionService.getIndicatorValue(indicatorB, period, valueMap, constantMap, null), DELTA);
}
Also used : IndicatorType(org.hisp.dhis.indicator.IndicatorType) Indicator(org.hisp.dhis.indicator.Indicator) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 19 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class ExpressionServiceTest method testGetIndicatorValueObject.

@Test
public void testGetIndicatorValueObject() {
    IndicatorType indicatorType = new IndicatorType("A", 100, false);
    Indicator indicatorA = createIndicator('A', indicatorType);
    indicatorA.setNumerator(expressionE);
    indicatorA.setDenominator(expressionF);
    Indicator indicatorB = createIndicator('B', indicatorType);
    indicatorB.setNumerator(expressionN);
    indicatorB.setDenominator(expressionF);
    Map<DataElementOperand, Double> valueMap = new HashMap<>();
    valueMap.put(new DataElementOperand(deA, coc), 12d);
    valueMap.put(new DataElementOperand(deB, coc), 34d);
    valueMap.put(new DataElementOperand(deA, cocA, cocB), 46d);
    valueMap.put(new DataElementOperand(deB, cocA), 10d);
    Map<String, Double> constantMap = new HashMap<>();
    constantMap.put(constantA.getUid(), 2.0);
    IndicatorValue value = expressionService.getIndicatorValueObject(indicatorA, period, valueMap, constantMap, null);
    assertEquals(24d, value.getNumeratorValue(), DELTA);
    assertEquals(12d, value.getDenominatorValue(), DELTA);
    assertEquals(100, value.getFactor());
    assertEquals(200d, value.getValue(), DELTA);
    value = expressionService.getIndicatorValueObject(indicatorB, period, valueMap, constantMap, null);
    assertEquals(36d, value.getNumeratorValue(), DELTA);
    assertEquals(12d, value.getDenominatorValue(), DELTA);
    assertEquals(100, value.getFactor());
    assertEquals(300d, value.getValue(), DELTA);
}
Also used : IndicatorType(org.hisp.dhis.indicator.IndicatorType) IndicatorValue(org.hisp.dhis.indicator.IndicatorValue) Indicator(org.hisp.dhis.indicator.Indicator) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 20 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class ChartStoreTest method setUpTest.

// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@Override
public void setUpTest() {
    // ---------------------------------------------------------------------
    // Indicator
    // ---------------------------------------------------------------------
    IndicatorType indicatorType = createIndicatorType('A');
    indicatorA = createIndicator('A', indicatorType);
    indicatorB = createIndicator('B', indicatorType);
    indicatorC = createIndicator('C', indicatorType);
    indicatorService.addIndicatorType(indicatorType);
    indicatorService.addIndicator(indicatorA);
    indicatorService.addIndicator(indicatorB);
    indicatorService.addIndicator(indicatorC);
    List<Indicator> indicators = new ArrayList<>();
    indicators.add(indicatorA);
    indicators.add(indicatorB);
    indicators.add(indicatorC);
    // ---------------------------------------------------------------------
    // Period
    // ---------------------------------------------------------------------
    PeriodType periodType = new MonthlyPeriodType();
    periodA = createPeriod(periodType, getDate(2000, 1, 1), getDate(2000, 1, 2));
    periodB = createPeriod(periodType, getDate(2000, 1, 3), getDate(2000, 1, 4));
    periodC = createPeriod(periodType, getDate(2000, 1, 5), getDate(2000, 1, 6));
    periodService.addPeriod(periodA);
    periodService.addPeriod(periodB);
    periodService.addPeriod(periodC);
    List<Period> periods = new ArrayList<>();
    periods.add(periodA);
    periods.add(periodB);
    periods.add(periodC);
    // ---------------------------------------------------------------------
    // OrganisationUnit
    // ---------------------------------------------------------------------
    unitA = createOrganisationUnit('A');
    unitB = createOrganisationUnit('B');
    organisationUnitService.addOrganisationUnit(unitA);
    organisationUnitService.addOrganisationUnit(unitB);
    List<OrganisationUnit> units = new ArrayList<>();
    units.add(unitA);
    units.add(unitB);
    // units.add( unitC );
    chartA = createChart('A', indicators, periods, units);
    chartB = createChart('B', indicators, periods, units);
    chartC = createChart('C', indicators, periods, units);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) IndicatorType(org.hisp.dhis.indicator.IndicatorType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) Indicator(org.hisp.dhis.indicator.Indicator)

Aggregations

Indicator (org.hisp.dhis.indicator.Indicator)23 Test (org.junit.Test)8 DataElement (org.hisp.dhis.dataelement.DataElement)7 IndicatorType (org.hisp.dhis.indicator.IndicatorType)7 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)7 ProgramIndicator (org.hisp.dhis.program.ProgramIndicator)7 DhisSpringTest (org.hisp.dhis.DhisSpringTest)5 Period (org.hisp.dhis.period.Period)5 DataSet (org.hisp.dhis.dataset.DataSet)4 ArrayList (java.util.ArrayList)3 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)3 DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)2 DimensionalObject (org.hisp.dhis.common.DimensionalObject)2 IndicatorGroupSet (org.hisp.dhis.indicator.IndicatorGroupSet)2 IndicatorValue (org.hisp.dhis.indicator.IndicatorValue)2