diff --git a/src/main/java/org/hisp/dhis/api/ApiFields.java b/src/main/java/org/hisp/dhis/api/ApiFields.java index fed3910d..0513a23d 100644 --- a/src/main/java/org/hisp/dhis/api/ApiFields.java +++ b/src/main/java/org/hisp/dhis/api/ApiFields.java @@ -332,7 +332,10 @@ public class ApiFields { ID_EXT_FIELDS); /** Program indicator fields. */ - public static final String PROGRAM_INDICATOR_FIELDS = NAME_FIELDS; + public static final String PROGRAM_INDICATOR_FIELDS = + String.format( + "%1$s,program[%1$s],expression,filter,decimals,aggregationType,analyticsType", + NAME_FIELDS); /** Program section fields. */ public static final String PROGRAM_SECTION_FIELDS = diff --git a/src/main/java/org/hisp/dhis/model/AnalyticsType.java b/src/main/java/org/hisp/dhis/model/AnalyticsType.java new file mode 100644 index 00000000..947b6d32 --- /dev/null +++ b/src/main/java/org/hisp/dhis/model/AnalyticsType.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2004-2026, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.hisp.dhis.model; + +public enum AnalyticsType { + EVENT, + ENROLLMENT; +} diff --git a/src/main/java/org/hisp/dhis/model/ProgramIndicator.java b/src/main/java/org/hisp/dhis/model/ProgramIndicator.java index d5741c2d..59a47ce4 100644 --- a/src/main/java/org/hisp/dhis/model/ProgramIndicator.java +++ b/src/main/java/org/hisp/dhis/model/ProgramIndicator.java @@ -27,6 +27,7 @@ */ package org.hisp.dhis.model; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -37,6 +38,18 @@ @Setter @NoArgsConstructor public class ProgramIndicator extends DimensionItem { + @JsonProperty private Program program; + + @JsonProperty private String expression; + + @JsonProperty private String filter; + + @JsonProperty private Integer decimals; + + @JsonProperty private AggregationType aggregationType; + + @JsonProperty private AnalyticsType analyticsType; + @Override public DimensionItemType getDimensionItemType() { return DimensionItemType.PROGRAM_INDICATOR; diff --git a/src/test/java/org/hisp/dhis/ProgramIndicatorApiTest.java b/src/test/java/org/hisp/dhis/ProgramIndicatorApiTest.java new file mode 100644 index 00000000..94a1e098 --- /dev/null +++ b/src/test/java/org/hisp/dhis/ProgramIndicatorApiTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2004-2026, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.hisp.dhis; + +import static org.hisp.dhis.support.Assertions.assertNotBlank; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.hisp.dhis.model.ProgramIndicator; +import org.hisp.dhis.support.TestTags; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag(TestTags.INTEGRATION) +class ProgramIndicatorApiTest { + @Test + void testGetProgramIndicator() { + Dhis2 dhis2 = new Dhis2(TestFixture.DEFAULT_CONFIG); + + ProgramIndicator programIndicator = dhis2.getProgramIndicator("GSae40Fyppf"); + + assertNotNull(programIndicator); + assertNotNull("GSae40Fyppf", programIndicator.getId()); + assertNotBlank(programIndicator.getName()); + assertNotBlank(programIndicator.getShortName()); + assertNotNull(programIndicator.getProgram()); + assertEquals("uy2gU8kT1jF", programIndicator.getProgram().getId()); + assertNotBlank(programIndicator.getExpression()); + assertNotBlank(programIndicator.getFilter()); + assertNotNull(programIndicator.getAggregationType()); + assertNotNull(programIndicator.getAnalyticsType()); + } +}