=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2004-2012, 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.program; + +import org.hisp.dhis.common.BaseNameableObject; + +/** + * @author Chau Thu Tran + * @version $ ProgramIndicator.java Apr 16, 2013 1:00:15 PM $ + */ +public class ProgramIndicator + extends BaseNameableObject +{ + private static final long serialVersionUID = 7920320128945484331L; + + public static final String VALUE_TYPE_DATE = "date"; + + public static final String VALUE_TYPE_INT = "int"; + + public static final String INCIDENT_DATE = "incident_date"; + + public static final String ENROLLEMENT_DATE = "enrollment_date"; + + public static final String CURRENT_DATE = "current_date"; + + private String valueType; + + private String expression; + + private String rootDate; + + private Program program; + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + public ProgramIndicator() + { + + } + + public ProgramIndicator( String name, String description, String valueType, String expression ) + { + this.name = name; + this.description = description; + this.valueType = valueType; + this.expression = expression; + } + + // ------------------------------------------------------------------------- + // Logical + // ------------------------------------------------------------------------- + + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + return true; + if ( !super.equals( obj ) ) + return false; + if ( getClass() != obj.getClass() ) + return false; + ProgramIndicator other = (ProgramIndicator) obj; + if ( name == null ) + { + if ( other.name != null ) + return false; + } + else if ( !name.equals( other.name ) ) + return false; + return true; + } + + // ------------------------------------------------------------------------- + // Getters && Setters + // ------------------------------------------------------------------------- + + public String getValueType() + { + return valueType; + } + + public void setValueType( String valueType ) + { + this.valueType = valueType; + } + + public String getExpression() + { + return expression; + } + + public void setExpression( String expression ) + { + this.expression = expression; + } + + public String getRootDate() + { + return rootDate; + } + + public void setRootDate( String rootDate ) + { + this.rootDate = rootDate; + } + + public Program getProgram() + { + return program; + } + + public void setProgram( Program program ) + { + this.program = program; + } + +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2004-2012, 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.program; + +import java.util.Collection; +import java.util.Map; + +/** + * @author Chau Thu Tran + * @version $ ProgramIndicatorService.java Apr 16, 2013 1:11:07 PM $ + */ +public interface ProgramIndicatorService +{ + int addProgramIndicator( ProgramIndicator programIndicator ); + + void updateProgramIndicator( ProgramIndicator programIndicator ); + + void deleteProgramIndicator( ProgramIndicator programIndicator ); + + ProgramIndicator getProgramIndicator( int id ); + + ProgramIndicator getProgramIndicator( String name ); + + ProgramIndicator getProgramIndicatorByShortName( String shortName ); + + ProgramIndicator getProgramIndicatorByUid( String uid ); + + Collection getAllProgramIndicators(); + + Collection getProgramIndicators( Program program ); + + String getProgramIndicatorValue( ProgramInstance programInstance, ProgramIndicator programIndicator ); + + Map getProgramIndicatorValues( ProgramInstance programInstance ); + +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorStore.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2004-2012, 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.program; + +import java.util.Collection; + +import org.hisp.dhis.common.GenericNameableObjectStore; + +/** + * @author Chau Thu Tran + * @version $ ProgramIndicatorStore.java Apr 16, 2013 1:15:12 PM $ + */ +public interface ProgramIndicatorStore + extends GenericNameableObjectStore +{ + Collection getByProgram( Program program ); +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramIndicatorComparator.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramIndicatorComparator.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/comparator/ProgramIndicatorComparator.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2004-2012, 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.program.comparator; + +import java.util.Comparator; + +import org.hisp.dhis.program.ProgramIndicator; + +/** + * @author Chau Thu Tran + * @version $ ProgramIndicatorComparator.java Apr 16, 2013 3:47:30 PM $ + */ +public class ProgramIndicatorComparator + implements Comparator +{ + public int compare( ProgramIndicator programIndicator0, ProgramIndicator programIndicator1 ) + { + return programIndicator0.getDisplayName().compareTo( programIndicator1.getDisplayName() ); + } +} === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionManager.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionManager.java 2013-04-05 04:23:25 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionManager.java 2013-04-17 07:58:14 +0000 @@ -58,7 +58,6 @@ * @param operator There are six operators, includes Number of persons, * Number of visits, Sum, Average, Minimum and Maximum of data * element values. - * @param deType Aggregate Data element type * @param deSumId The id of aggregate data element which used for aggregate * data values for operator Sum, Average, Minimum and Maximum of data * element values. This fill is null for other operators. @@ -66,7 +65,7 @@ * value * @param period The date range for aggregate data value */ - Double getAggregateValue( String caseExpression, String operator, String deType, Integer deSumId, + Double getAggregateValue( String caseExpression, String operator, Integer deSumId, Integer orgunitId, Period period ); /** @@ -76,7 +75,6 @@ * @param operator There are six operators, includes Number of persons, * Number of visits, Sum, Average, Minimum and Maximum of data * element values. - * @param deType Aggregate Data element type * @param deSumId The id of aggregate data element which used for aggregate * data values for operator Sum, Average, Minimum and Maximum of data * element values. This fill is null for other operators. @@ -85,7 +83,7 @@ * @param startDate Start date * @param endDate End date */ - String parseExpressionToSql( String aggregationExpression, String operator, String deType, Integer deSumId, + String parseExpressionToSql( String aggregationExpression, String operator, Integer deSumId, Integer orgunitId, String startDate, String endDate ); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2013-04-03 15:46:23 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2013-04-17 07:58:14 +0000 @@ -222,12 +222,11 @@ public Double getAggregateValue( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, Period period ) { - DataElement aggDataElement = aggregationCondition.getAggregationDataElement(); DataElement deSum = aggregationCondition.getDeSum(); Integer deSumId = (deSum == null) ? null : deSum.getId(); return aggregationConditionManager.getAggregateValue( aggregationCondition.getAggregationExpression(), - aggregationCondition.getOperator(), aggDataElement.getType(), deSumId, orgunit.getId(), period ); + aggregationCondition.getOperator(), deSumId, orgunit.getId(), period ); } @Override @@ -239,14 +238,13 @@ int orgunitId = orgunit.getId(); String startDate = DateUtils.getMediumDateString( period.getStartDate() ); String endDate = DateUtils.getMediumDateString( period.getEndDate() ); - DataElement aggDataElement = aggregationCondition.getAggregationDataElement(); DataElement deSum = aggregationCondition.getDeSum(); Integer deSumId = (deSum == null) ? null : deSum.getId(); Collection result = new HashSet(); String sql = aggregationConditionManager.parseExpressionToSql( aggregationCondition.getAggregationExpression(), - aggregationCondition.getOperator(), aggDataElement.getType(), deSumId, orgunitId, startDate, endDate ); + aggregationCondition.getOperator(), deSumId, orgunitId, startDate, endDate ); Collection dataElements = getDataElementsInCondition( aggregationCondition .getAggregationExpression() ); @@ -272,14 +270,12 @@ public Collection getPatients( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, Period period ) { - DataElement aggDataElement = aggregationCondition.getAggregationDataElement(); DataElement deSum = aggregationCondition.getDeSum(); Integer deSumId = (deSum == null) ? null : deSum.getId(); String sql = aggregationConditionManager .parseExpressionToSql( aggregationCondition.getAggregationExpression(), aggregationCondition.getOperator(), - aggDataElement.getType(), deSumId, orgunit.getId(), - DateUtils.getMediumDateString( period.getStartDate() ), + deSumId, orgunit.getId(), DateUtils.getMediumDateString( period.getStartDate() ), DateUtils.getMediumDateString( period.getEndDate() ) ); Collection result = new HashSet(); @@ -316,12 +312,11 @@ // get params - DataElement aggDataElement = aggregationCondition.getAggregationDataElement(); DataElement deSum = aggregationCondition.getDeSum(); Integer deSumId = (deSum == null) ? null : deSum.getId(); sql = aggregationConditionManager.parseExpressionToSql( aggregationCondition.getAggregationExpression(), - aggregationCondition.getOperator(), aggDataElement.getType(), deSumId, orgunitId, startDate, endDate ); + aggregationCondition.getOperator(), deSumId, orgunitId, startDate, endDate ); } else { @@ -340,14 +335,12 @@ // Get params - DataElement aggDataElement = aggregationCondition.getAggregationDataElement(); DataElement deSum = aggregationCondition.getDeSum(); Integer deSumId = (deSum == null) ? null : deSum.getId(); String conditionSql = aggregationConditionManager.parseExpressionToSql( - aggregationCondition.getAggregationExpression(), aggregationCondition.getOperator(), - aggDataElement.getType(), deSumId, orgunit.getId(), - DateUtils.getMediumDateString( period.getStartDate() ), + aggregationCondition.getAggregationExpression(), aggregationCondition.getOperator(), deSumId, + orgunit.getId(), DateUtils.getMediumDateString( period.getStartDate() ), DateUtils.getMediumDateString( period.getEndDate() ) ); sql += conditionSql + " ) "; === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java 2013-04-15 17:06:42 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java 2013-04-17 07:58:14 +0000 @@ -62,6 +62,7 @@ import org.hisp.dhis.caseaggregation.CaseAggregationCondition; import org.hisp.dhis.caseaggregation.CaseAggregationConditionManager; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.jdbc.StatementBuilder; import org.hisp.dhis.period.CalendarPeriodType; import org.hisp.dhis.period.Period; @@ -117,6 +118,13 @@ this.statementBuilder = statementBuilder; } + public DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + // ------------------------------------------------------------------------- // Implementation Methods // ------------------------------------------------------------------------- @@ -164,8 +172,8 @@ return null; } - public Double getAggregateValue( String caseExpression, String operator, String deType, Integer deSumId, - Integer orgunitId, Period period ) + public Double getAggregateValue( String caseExpression, String operator, Integer deSumId, Integer orgunitId, + Period period ) { String startDate = DateUtils.getMediumDateString( period.getStartDate() ); String endDate = DateUtils.getMediumDateString( period.getEndDate() ); @@ -173,7 +181,7 @@ if ( operator.equals( CaseAggregationCondition.AGGRERATION_COUNT ) || operator.equals( CaseAggregationCondition.AGGRERATION_SUM ) ) { - String sql = parseExpressionToSql( caseExpression, operator, deType, deSumId, orgunitId, startDate, endDate ); + String sql = parseExpressionToSql( caseExpression, operator, deSumId, orgunitId, startDate, endDate ); Collection ids = this.executeSQL( sql ); return (ids == null) ? null : ids.size() + 0.0; } @@ -189,15 +197,14 @@ if ( caseExpression != null && !caseExpression.isEmpty() ) { sql = sql + " AND pdv.programstageinstanceid in ( " - + parseExpressionToSql( caseExpression, operator, deType, deSumId, orgunitId, startDate, endDate ) - + " ) "; + + parseExpressionToSql( caseExpression, operator, deSumId, orgunitId, startDate, endDate ) + " ) "; } Collection ids = this.executeSQL( sql ); return (ids == null) ? null : ids.iterator().next() + 0.0; } - public String parseExpressionToSql( String aggregationExpression, String operator, String deType, Integer deSumId, + public String parseExpressionToSql( String aggregationExpression, String operator, Integer deSumId, Integer orgunitId, String startDate, String endDate ) { // Get operators between ( ) @@ -219,7 +226,7 @@ // Create SQL statement for the first condition String condition = conditions[0].replace( "(", "" ).replace( ")", "" ); - String sql = createSQL( condition, operator, deType, orgunitId, startDate, endDate ); + String sql = createSQL( condition, operator, orgunitId, startDate, endDate ); subSQL.add( sql ); @@ -228,13 +235,14 @@ { condition = conditions[index].replace( "(", "" ).replace( ")", "" ); - sql = "(" + createSQL( condition, operator, deType, orgunitId, startDate, endDate ) + ")"; + sql = "(" + createSQL( condition, operator, orgunitId, startDate, endDate ) + ")"; subSQL.add( sql ); } sql = getSQL( operator, subSQL, operators ).replace( IN_CONDITION_START_SIGN, "(" ).replaceAll( IN_CONDITION_END_SIGN, ")" ); + return sql; } @@ -249,7 +257,7 @@ */ private void runAggregate( Collection orgunitIds, CaseAggregateSchedule dataSet, Collection periods ) { - String sql = "select caseaggregationconditionid, aggregationdataelementid, optioncomboid, de.valuetype as deType, " + String sql = "select caseaggregationconditionid, aggregationdataelementid, optioncomboid, " + " cagg.aggregationexpression as caseexpression, cagg.\"operator\" as caseoperator, cagg.desum as desumid " + " from caseaggregationcondition cagg inner join datasetmembers dm " + " on cagg.aggregationdataelementid=dm.dataelementid " @@ -276,7 +284,6 @@ int optionComboId = rs.getInt( "optioncomboid" ); String caseExpression = rs.getString( "caseexpression" ); String caseOperator = rs.getString( "caseoperator" ); - String deType = rs.getString( "deType" ); int deSumId = rs.getInt( "desumid" ); Collection _orgunitIds = getServiceOrgunit( @@ -305,7 +312,7 @@ boolean hasValue = jdbcTemplate.queryForRowSet( dataValueSql ).next(); - Double resultValue = getAggregateValue( caseExpression, caseOperator, deType, deSumId, orgunitId, + Double resultValue = getAggregateValue( caseExpression, caseOperator, deSumId, orgunitId, period ); if ( resultValue != null && resultValue != 0 ) @@ -447,8 +454,7 @@ * @param startDate Start date * @param endDate End date */ - private String createSQL( String caseExpression, String operator, String deType, int orgunitId, String startDate, - String endDate ) + private String createSQL( String caseExpression, String operator, int orgunitId, String startDate, String endDate ) { // --------------------------------------------------------------------- // get operators @@ -501,7 +507,6 @@ { String propertyName = info[1]; condition = getConditionForPatientProperty( propertyName, operator, startDate, endDate ); - } else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) ) { @@ -515,6 +520,7 @@ int programId = Integer.parseInt( ids[0] ); String programStageId = ids[1]; int dataElementId = Integer.parseInt( ids[2] ); + DataElement dataElement = dataElementService.getDataElement( dataElementId ); String valueToCompare = expression[i].replace( "[" + match + "]", "" ).trim(); @@ -532,7 +538,7 @@ if ( !expression[i].contains( "+" ) ) { - if ( deType.equals( DataElement.VALUE_TYPE_INT ) ) + if ( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) ) { condition += " AND cast( pd.value as " + statementBuilder.getDoubleColumnType() + ") "; } @@ -904,7 +910,8 @@ } /** - * Return standard SQL by combining all sub-expressions of an aggregate query builder formula. + * Return standard SQL by combining all sub-expressions of an aggregate + * query builder formula. * */ private String getSQL( String aggregateOperator, List conditions, List operators ) @@ -943,7 +950,8 @@ } /** - * Return the Ids of organisation units which patients registered or events happened. + * Return the Ids of organisation units which patients registered or events + * happened. * */ private Collection getServiceOrgunit( String startDate, String endDate ) === added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2004-2012, 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.program; + +import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT; +import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID; +import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT; +import static org.hisp.dhis.i18n.I18nUtils.i18n; + +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.i18n.I18nService; +import org.hisp.dhis.patientdatavalue.PatientDataValue; +import org.hisp.dhis.patientdatavalue.PatientDataValueService; +import org.hisp.dhis.system.util.DateUtils; +import org.nfunk.jep.JEP; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Chau Thu Tran + * @version $ DefaultProgramIndicatorService.java Apr 16, 2013 1:29:00 PM $ + */ + +@Transactional +public class DefaultProgramIndicatorService + implements ProgramIndicatorService +{ + private final String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+[" + + SEPARATOR_ID + "[0-9]*]*)" + "\\]"; + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramIndicatorStore programIndicatorStore; + + public void setProgramIndicatorStore( ProgramIndicatorStore programIndicatorStore ) + { + this.programIndicatorStore = programIndicatorStore; + } + + private ProgramStageService programStageService; + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private PatientDataValueService patientDataValueService; + + public void setPatientDataValueService( PatientDataValueService patientDataValueService ) + { + this.patientDataValueService = patientDataValueService; + } + + private ProgramStageInstanceService programStageInstanceService; + + public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) + { + this.programStageInstanceService = programStageInstanceService; + } + + private I18nService i18nService; + + public void setI18nService( I18nService service ) + { + i18nService = service; + } + + // ------------------------------------------------------------------------- + // Implementation methods + // ------------------------------------------------------------------------- + + @Override + public int addProgramIndicator( ProgramIndicator programIndicator ) + { + return programIndicatorStore.save( programIndicator ); + } + + @Override + public void updateProgramIndicator( ProgramIndicator programIndicator ) + { + programIndicatorStore.update( programIndicator ); + } + + @Override + public void deleteProgramIndicator( ProgramIndicator programIndicator ) + { + programIndicatorStore.delete( programIndicator ); + } + + @Override + public ProgramIndicator getProgramIndicator( int id ) + { + return i18n( i18nService, programIndicatorStore.get( id ) ); + } + + @Override + public ProgramIndicator getProgramIndicator( String name ) + { + return i18n( i18nService, programIndicatorStore.getByName( name ) ); + } + + @Override + public ProgramIndicator getProgramIndicatorByUid( String uid ) + { + return i18n( i18nService, programIndicatorStore.getByUid( uid ) ); + } + + @Override + public ProgramIndicator getProgramIndicatorByShortName( String shortName ) + { + return i18n( i18nService, programIndicatorStore.getByShortName( shortName ) ); + } + + @Override + public Collection getAllProgramIndicators() + { + return i18n( i18nService, programIndicatorStore.getAll() ); + } + + @Override + public Collection getProgramIndicators( Program program ) + { + return i18n( i18nService, programIndicatorStore.getByProgram( program ) ); + } + + @Override + public String getProgramIndicatorValue( ProgramInstance programInstance, ProgramIndicator programIndicator ) + { + Double value = getValue( programInstance, programIndicator.getValueType(), programIndicator.getExpression() ); + + if ( value != null ) + { + if ( programIndicator.getValueType().equals( ProgramIndicator.VALUE_TYPE_DATE ) ) + { + Date rootDate = new Date(); + + if ( ProgramIndicator.INCIDENT_DATE.equals( programIndicator.getRootDate() ) ) + { + rootDate = programInstance.getDateOfIncident(); + } + else if ( ProgramIndicator.ENROLLEMENT_DATE.equals( programIndicator.getRootDate() ) ) + { + rootDate = programInstance.getEnrollmentDate(); + } + + Date date = DateUtils.getDateAfterAddition( rootDate, value.intValue() ); + + return DateUtils.getMediumDateString( date ); + } + + return Math.floor( value ) + ""; + } + + return null; + } + + @Override + public Map getProgramIndicatorValues( ProgramInstance programInstance ) + { + Map result = new HashMap(); + + Collection programIndicators = programIndicatorStore.getByProgram( programInstance + .getProgram() ); + + for ( ProgramIndicator programIndicator : programIndicators ) + { + result + .put( programIndicator.getDisplayName(), getProgramIndicatorValue( programInstance, programIndicator ) ); + } + + return result; + } + + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + + private Double getValue( ProgramInstance programInstance, String valueType, String expression ) + { + String value = ""; + + if ( valueType.equals( ProgramIndicator.VALUE_TYPE_INT ) ) + { + Date currentDate = new Date(); + expression = expression.replaceAll( ProgramIndicator.ENROLLEMENT_DATE, + DateUtils.daysBetween( programInstance.getEnrollmentDate(), currentDate ) + "" ); + expression = expression.replaceAll( ProgramIndicator.INCIDENT_DATE, + DateUtils.daysBetween( programInstance.getDateOfIncident(), currentDate ) + "" ); + expression = expression.replaceAll( ProgramIndicator.CURRENT_DATE, "0" ); + } + + StringBuffer description = new StringBuffer(); + + Pattern pattern = Pattern.compile( regExp ); + Matcher matcher = pattern.matcher( expression ); + while ( matcher.find() ) + { + DataElement dataElement = null; + + String key = matcher.group().replaceAll( "[\\[\\]]", "" ).split( SEPARATOR_OBJECT )[1]; + + Integer programStageId = Integer.parseInt( key.split( "." )[0] ); + ProgramStage programStage = programStageService.getProgramStage( programStageId ); + + ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( + programInstance, programStage ); + + Integer dataElementId = Integer.parseInt( key.split( "." )[1] ); + dataElement = dataElementService.getDataElement( dataElementId ); + + PatientDataValue dataValue = patientDataValueService + .getPatientDataValue( programStageInstance, dataElement ); + + if ( dataValue == null ) + { + return null; + } + + value = dataValue.getValue(); + + if ( valueType.equals( ProgramIndicator.VALUE_TYPE_INT ) + && (dataElement == null || dataElement.getType().equals( DataElement.VALUE_TYPE_DATE )) ) + { + value = DateUtils.daysBetween( new Date(), DateUtils.getDefaultDate( value ) ) + " "; + } + + matcher.appendReplacement( description, value ); + + } + matcher.appendTail( description ); + + final JEP parser = new JEP(); + parser.parseExpression( description.toString() ); + + return parser.getValue(); + + } +} === added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramIndicatorStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramIndicatorStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramIndicatorStore.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2004-2012, 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.program.hibernate; + +import java.util.Collection; + +import org.hibernate.criterion.Restrictions; +import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorStore; + +/** + * @author Chau Thu Tran + * @version $ HibernateProgramIndicatorStore.java Apr 16, 2013 1:39:19 PM $ + */ +public class HibernateProgramIndicatorStore + extends HibernateIdentifiableObjectStore + implements ProgramIndicatorStore +{ + + @SuppressWarnings( "unchecked" ) + @Override + public Collection getByProgram( Program program ) + { + return getCriteria( Restrictions.eq( "program", program ) ).list(); + } +} === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-11 06:26:56 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-17 07:58:14 +0000 @@ -5,11 +5,18 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd"> - + + + + + + + + + + + + + + + + +] + > + + + + + + + + &identifiableProperties; + + + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-04-10 03:13:47 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-04-17 07:58:14 +0000 @@ -45,6 +45,7 @@ import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramIndicatorService; import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramInstanceService; import org.hisp.dhis.program.ProgramService; @@ -80,6 +81,8 @@ private ProgramService programService; + private ProgramIndicatorService programIndicatorService; + // ------------------------------------------------------------------------- // Input && Output // ------------------------------------------------------------------------- @@ -102,15 +105,27 @@ private Collection relationships = new HashSet(); + private Map programIndicatorsMap = new HashMap(); + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- + public Map getProgramIndicatorsMap() + { + return programIndicatorsMap; + } + public void setPatientAuditService( PatientAuditService patientAuditService ) { this.patientAuditService = patientAuditService; } + public void setProgramIndicatorService( ProgramIndicatorService programIndicatorService ) + { + this.programIndicatorService = programIndicatorService; + } + public void setProgramService( ProgramService programService ) { this.programService = programService; @@ -185,7 +200,7 @@ { this.patientId = patientId; } - + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -233,6 +248,8 @@ if ( programInstance.getStatus() == ProgramInstance.STATUS_ACTIVE ) { activeProgramInstances.add( programInstance ); + + programIndicatorsMap.putAll( programIndicatorService.getProgramIndicatorValues( programInstance ) ); } else { @@ -242,6 +259,10 @@ } // --------------------------------------------------------------------- + // Get program-indicators + // --------------------------------------------------------------------- + + // --------------------------------------------------------------------- // Patient-Audit // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-04-16 05:41:25 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-04-17 07:58:14 +0000 @@ -62,6 +62,7 @@ + + + var i18n_run_success = '$encoder.jsEscape( $i18n.getString( "run_success" ) , "'" )'; + var i18n_run_fail = '$encoder.jsEscape( $i18n.getString( "run_fail" ) , "'" )'; + var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_item" ) , "'" )'; + var i18n_all = '[' + '$encoder.jsEscape( $i18n.getString( "all" ) , "'" )' + ']'; + + + + +

$i18n.getString( "create_new_aggregation_query_builder" )

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "case_aggregation_query_builder_detail" )
+ +
+ +
+ + + +
+ $i18n.getString('number_of_patients')
+ $i18n.getString('number_of_visits')
+ $i18n.getString('sum_dataelement_value')
+ $i18n.getString('avg_dataelement_value')
+ $i18n.getString('min_dataelement_value')
+ $i18n.getString('max_dataelement_value') +
+ + + +
+ + + +
+ + + +

+ +#parse( "/dhis-web-maintenance-patient/caseAggregationForm.vm" ) + +

+ + + +

+ +
+ + \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregation.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregation.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregation.vm 2013-04-17 07:58:14 +0000 @@ -0,0 +1,88 @@ +

$i18n.getString( 'patient_aggregation_query_builder_management' ) #openHelp( "patient_aggregation_query_builder" )

+ + + + + + +
+ + + + + + + + + + + +
$i18n.getString( "filter_by_data_set" ) + +
$i18n.getString( "filter_by_name" ) + + + +
+ + + + + + + + + + + + #set( $mark = true ) + #foreach( $aggregationCondition in $aggregationConditions ) + + + + + + #set( $mark = !$mark ) + #end + + +
$i18n.getString( "name" )$i18n.getString( "operations" )
$encoder.htmlEncode( $aggregationCondition.displayName ) + $i18n.getString( 'edit' ) + $i18n.getString( 'translation_translate' ) + $i18n.getString( 'remove' ) + $i18n.getString( 'show_details' ) +
+
+ + + +
+ + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm 2013-04-03 07:10:12 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm 2013-04-17 07:58:14 +0000 @@ -44,6 +44,14 @@ #end + + #foreach($key in $programIndicatorsMap.keySet()) + + $key + $programIndicatorsMap.get($key) + + #end + $i18n.getString("health_worker") === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramIndicator.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramIndicator.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonProgramIndicator.vm 2013-04-17 07:58:14 +0000 @@ -0,0 +1,11 @@ +{ "programIndicator": + { + "id": $!{programIndicator.id}, + "name": "$!encoder.jsonEncode( ${programIndicator.displayName} )", + "code": "$!encoder.jsonEncode( ${programIndicator.code} )", + "description": "$!encoder.xmlEncode( ${programIndicator.displayDescription} )", + "valueType": "$!{programIndicator.valueType}", + "rootDate" : "$!format.formatDate( $programIndicator.rootDate )", + "expression": "$!encoder.jsonEncode( $!{programIndicator.expression} )" + } +} === added directory 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator' === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/AddProgramIndicatorAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/AddProgramIndicatorAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/AddProgramIndicatorAction.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2004-2012, 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.patient.action.programtindicator; + +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; +import org.hisp.dhis.program.ProgramService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ AddProgramIndicatorAction.java Apr 16, 2013 3:24:51 PM $ + */ +public class AddProgramIndicatorAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private ProgramIndicatorService programIndicatorService; + + public void setProgramIndicatorService( ProgramIndicatorService programIndicatorService ) + { + this.programIndicatorService = programIndicatorService; + } + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + private Integer programId; + + public void setProgramId( Integer programId ) + { + this.programId = programId; + } + + public Integer getProgramId() + { + return programId; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String shortName; + + public void setShortName( String shortName ) + { + this.shortName = shortName; + } + + private String code; + + public void setCode( String code ) + { + this.code = code; + } + + private String description; + + public void setDescription( String description ) + { + this.description = description; + } + + private String valueType; + + public void setValueType( String valueType ) + { + this.valueType = valueType; + } + + private String expression; + + public void setExpression( String expression ) + { + this.expression = expression; + } + + private String rootDate; + + public void setRootDate( String rootDate ) + { + this.rootDate = rootDate; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + code = (code == null && code.trim().length() == 0) ? null : code; + + Program program = programService.getProgram( programId ); + ProgramIndicator programIndicator = new ProgramIndicator( name, description, valueType, expression ); + programIndicator.setShortName( shortName ); + programIndicator.setCode( code ); + programIndicator.setRootDate( rootDate ); + programIndicator.setProgram( program ); + + programIndicatorService.addProgramIndicator( programIndicator ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorAction.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2004-2012, 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.patient.action.programtindicator; + +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ DeleteProgramIndicatorAction Apr 16, 2013 3:24:51 PM $ + */ +public class GetProgramIndicatorAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramIndicatorService programIndicatorService; + + public void setProgramIndicatorService( ProgramIndicatorService programIndicatorService ) + { + this.programIndicatorService = programIndicatorService; + } + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private ProgramIndicator programIndicator; + + public ProgramIndicator getProgramIndicator() + { + return programIndicator; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + programIndicator = programIndicatorService.getProgramIndicator( id ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorListAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorListAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorListAction.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2004-2012, 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.patient.action.programtindicator; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.comparator.ProgramIndicatorComparator; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ UpdateProgramIndicatorAction Apr 16, 2013 3:24:51 PM $ + */ +public class GetProgramIndicatorListAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramIndicatorService programIndicatorService; + + public void setProgramIndicatorService( ProgramIndicatorService programIndicatorService ) + { + this.programIndicatorService = programIndicatorService; + } + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + private Integer programId; + + public void setProgramId( Integer programId ) + { + this.programId = programId; + } + + private List programIndicators; + + public List getProgramIndicators() + { + return programIndicators; + } + + private Program program; + + public Program getProgram() + { + return program; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + program = programService.getProgram( programId ); + + programIndicators = new ArrayList( programIndicatorService.getProgramIndicators( program ) ); + + Collections.sort( programIndicators, new ProgramIndicatorComparator() ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/RemoveProgramIndicatorAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/RemoveProgramIndicatorAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/RemoveProgramIndicatorAction.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2004-2012, 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.patient.action.programtindicator; + +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ RemoveProgramIndicatorAction Apr 16, 2013 3:24:51 PM $ + */ +public class RemoveProgramIndicatorAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramIndicatorService programIndicatorService; + + public void setProgramIndicatorService( ProgramIndicatorService programIndicatorService ) + { + this.programIndicatorService = programIndicatorService; + } + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramIndicator programIndicator = programIndicatorService.getProgramIndicator( id ); + + programIndicatorService.deleteProgramIndicator( programIndicator ); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/UpdateProgramIndicatorAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/UpdateProgramIndicatorAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/UpdateProgramIndicatorAction.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2004-2012, 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.patient.action.programtindicator; + +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ UpdateProgramIndicatorAction Apr 16, 2013 3:24:51 PM $ + */ +public class UpdateProgramIndicatorAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramIndicatorService programIndicatorService; + + public void setProgramIndicatorService( ProgramIndicatorService programIndicatorService ) + { + this.programIndicatorService = programIndicatorService; + } + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String code; + + public void setCode( String code ) + { + this.code = code; + } + + private String description; + + public void setDescription( String description ) + { + this.description = description; + } + + private String valueType; + + public void setValueType( String valueType ) + { + this.valueType = valueType; + } + + private String expression; + + public void setExpression( String expression ) + { + this.expression = expression; + } + + private String rootDate; + + public void setRootDate( String rootDate ) + { + this.rootDate = rootDate; + } + + private String shortName; + + public void setShortName( String shortName ) + { + this.shortName = shortName; + } + + private Integer programId; + + public Integer getProgramId() + { + return programId; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + code = (code == null && code.trim().length() == 0) ? null : code; + + ProgramIndicator programIndicator = programIndicatorService.getProgramIndicator( id ); + + programIndicator.setName( name ); + programIndicator.setShortName( shortName ); + programIndicator.setCode( code ); + programIndicator.setDescription( description ); + programIndicator.setExpression( expression ); + programIndicator.setValueType( valueType ); + programIndicator.setRootDate( rootDate ); + + programIndicatorService.updateProgramIndicator( programIndicator ); + + programId = programIndicator.getProgram().getId(); + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/ValidateProgramIndicatorAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/ValidateProgramIndicatorAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/ValidateProgramIndicatorAction.java 2013-04-17 07:58:14 +0000 @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2004-2012, 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.patient.action.programtindicator; + +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.program.ProgramIndicator; +import org.hisp.dhis.program.ProgramIndicatorService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * @version $ ValidateProgramIndicatorAction.java Apr 16, 2013 3:29:11 PM $ + */ +public class ValidateProgramIndicatorAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramIndicatorService programIndicatorService; + + public void setProgramIndicatorService( ProgramIndicatorService programIndicatorService ) + { + this.programIndicatorService = programIndicatorService; + } + + // ------------------------------------------------------------------------- + // Setters + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String shortName; + + public void setShortName( String shortName ) + { + this.shortName = shortName; + } + + private String code; + + public void setCode( String code ) + { + this.code = code; + } + + private String message; + + public String getMessage() + { + return message; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + ProgramIndicator match = null; + + if ( name != null ) + { + name = name.trim(); + + match = programIndicatorService.getProgramIndicator( name ); + } + else if ( shortName != null ) + { + shortName = shortName.trim(); + + match = programIndicatorService.getProgramIndicatorByShortName( shortName ); + } + else if ( code != null ) + { + code = code.trim(); + + match = programIndicatorService.getProgramIndicator( code ); + } + + if ( match != null && (id == null || match.getId() != id.intValue()) ) + { + message = i18n.getString( "name_exists" ); + + return ERROR; + } + + message = i18n.getString( "everything_is_ok" ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-11 06:26:56 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-17 07:58:14 +0000 @@ -370,8 +370,7 @@ scope="prototype"> - +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-04-11 03:23:04 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-04-17 07:58:14 +0000 @@ -380,4 +380,11 @@ days_before_after_comparison_date = Days before/after comparison date enrollment_date = Enrollment date incident_date = Incident date -date_to_compare = Date to compare \ No newline at end of file +date_to_compare = Date to compare +program_indicator_management = Program Indicator Management +program_indicator_management_form = Program indicator management +confirm_delete_prorgam_indicator=Are you sure you want to delete this program indicator? +program_indicator_details = Program indicator details +date_for_calculating = Date for calculating +create_new_program_indicator = Create new program indicator +update_program_indicator = Edit program indicator \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2013-04-11 06:26:56 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2013-04-17 07:58:14 +0000 @@ -498,7 +498,7 @@ programStage.action?id=${programId} - + @@ -537,7 +537,7 @@ /dhis-web-maintenance-patient/dataEntryFormCode.vm - + @@ -573,7 +573,7 @@ patientRegistrationForm.action - + @@ -587,10 +587,11 @@ /dhis-web-commons/ajax/jsonResponseSuccess.vm - + - patientRegistrationForm.action + patientRegistrationForm.action + - + @@ -1083,5 +1084,73 @@ F_SCHEDULING_CASE_AGGREGATE_QUERY_BUILDER + + + + /main.vm + /dhis-web-maintenance-patient/programIndicator.vm + /dhis-web-maintenance-patient/menu.vm + javascript/programIndicator.js + F_PROGRAM_INDICATOR_MANAGEMENT + + + + + /dhis-web-commons/ajax/jsonProgramIndicator.vm + + plainTextError + + + + /main.vm + /dhis-web-maintenance-patient/addProgramIndicator.vm + javascript/programIndicator.js + F_ADD_PROGRAM_INDICATOR + + + + programIndicator.action?programId=${programId} + + F_ADD_PROGRAM_INDICATOR + + + + /main.vm + /dhis-web-maintenance-patient/updateProgramIndicator.vm + javascript/programIndicator.js + F_UPDATE_PROGRAM_INDICATOR + + + + programIndicator.action?programId=${programId} + + F_UPDATE_PROGRAM_INDICATOR + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + F_ADD_PROGRAM_INDICATOR + + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + + + /dhis-web-commons/ajax/jsonResponseError.vm + + plainTextError + + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramIndicator.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramIndicator.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramIndicator.vm 2013-04-17 07:58:14 +0000 @@ -0,0 +1,94 @@ + + +

$i18n.getString( "create_new_program_indicator" )

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "program_indicator_details" )
+ +
+ +
+
+ +#parse( "/dhis-web-maintenance-patient/programIndicatorForm.vm" ) + +

+ + +

+ +
+ + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm 2013-03-08 14:07:03 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm 2013-04-17 07:58:14 +0000 @@ -1,7 +1,6 @@
@@ -110,7 +109,7 @@     - + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/images/program_indicator.png' Binary files dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/images/program_indicator.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/images/program_indicator.png 2013-04-17 07:58:14 +0000 differ === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js 2013-04-08 04:21:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js 2013-04-17 07:58:14 +0000 @@ -32,6 +32,7 @@ typeMap['combo'] = i18n_attribute_combo_type; return typeMap; } + // ----------------------------------------------------------------------------- // Remove Patient Attribute // ----------------------------------------------------------------------------- === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programIndicator.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programIndicator.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programIndicator.js 2013-04-17 07:58:14 +0000 @@ -0,0 +1,116 @@ + +// ----------------------------------------------------------------------------- +// View details +// ----------------------------------------------------------------------------- + +function showProgramIndicatorDetails( programIndicatorId ) +{ + jQuery.getJSON( 'getProgramIndicator.action', { id: programIndicatorId }, function ( json ) { + setInnerHTML( 'nameField', json.programIndicator.name ); + setInnerHTML( 'codeField', json.programIndicator.code ); + setInnerHTML( 'descriptionField', json.programIndicator.description ); + setInnerHTML( 'valueTypeField', json.programIndicator.valueType ); + setInnerHTML( 'rootDateField', json.programIndicator.rootDate ); + setInnerHTML( 'expressionField', json.programIndicator.expression ); + + showDetails(); + }); +} + +// ----------------------------------------------------------------------------- +// Remove Program Indicator +// ----------------------------------------------------------------------------- + +function removeProgramIndicator( programIndicatorId, name ) +{ + removeItem( programIndicatorId, name, i18n_confirm_delete, 'removeProgramIndicator.action' ); +} + +function getPatientDataElements() +{ + clearListById( 'dataElements' ); + clearListById( 'deSumId' ); + var programStageId = getFieldValue('programStageId'); + + jQuery.getJSON( 'getPatientDataElements.action', + { + programId:getFieldValue( 'programId' ), + programStageId:programStageId + } + ,function( json ) + { + if( programStageId!='' ){ + enable('programStageProperty'); + } + else{ + disable('programStageProperty'); + } + var dataElements = jQuery('#dataElements'); + var deSumId = jQuery('#deSumId'); + for ( i in json.dataElements ) + { + dataElements.append( "" ); + if( json.dataElements[i].type=='int') + { + deSumId.append( "" ); + } + } + + }); +} + +function insertDataElement( element ) +{ + var programStageId = getFieldValue('programStageId'); + var dataElementId = element.options[element.selectedIndex].value; + + insertTextCommon( 'expression', "[DE:" + programStageId + "." + dataElementId + "]" ); + getConditionDescription(); +} + +function insertInfo( element, isProgramStageProperty ) +{ + var id = ""; + if( isProgramStageProperty ) + { + id = getFieldValue('programStageId'); + } + else + { + id = getFieldValue('programId'); + } + + value = element.options[element.selectedIndex].value.replace( '*', id ); + insertTextCommon('expression', value ); + getConditionDescription(); +} + +function insertOperator( value ) +{ + insertTextCommon('expression', ' ' + value + ' ' ); + getConditionDescription(); +} + +function getConditionDescription () +{ + var valueType = getFieldValue('valueType'); + if( valueType == 'int' ){ + hideById('rootDateTR'); + } + else{ + showById('rootDateTR'); + } +} + +function programIndicatorOnChange() +{ + var valueType = getFieldValue('valueType'); + if(valueType=='int'){ + hideById('rootDateTR'); + disable('rootDate'); + } + else{ + showById('rootDateTR'); + enable('rootDate'); + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programIndicator.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programIndicator.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programIndicator.vm 2013-04-17 07:58:14 +0000 @@ -0,0 +1,65 @@ +

$i18n.getString( "program_indicator_management_form" )

+ +

$program.displayName

+ + + + + + + + + + + + +
+
+ +
+ + + + + + + + + + + + + + #set( $mark = false ) + #foreach( $programIndicator in $programIndicators ) + + + + + + #set( $mark = !$mark ) + #end + +
$i18n.getString( "name" )$i18n.getString( "description" )$i18n.getString( "operations" )
$encoder.htmlEncode( $programIndicator.displayName )$encoder.htmlEncode( $programIndicator.description ) + $i18n.getString( 'edit' ) + $i18n.getString( 'translation_translate' ) + $i18n.getString( 'remove' ) + $i18n.getString( 'show_details' ) +
+
+ +
+ + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programIndicatorForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programIndicatorForm.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programIndicatorForm.vm 2013-04-17 07:58:14 +0000 @@ -0,0 +1,80 @@ +
+ + +
+ + + + + + + + + + +
+ + +
+ +
+
+ +
+ + + + + + + +
+ +
+
+
+ + + + + + + +     + + + + + +

+ + + + + + + + + +
+
+ $i18n.getString( "expression" ) + +
+
+
+ $i18n.getString( "description" ) +
$!description
+
+
+ + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm 2013-04-10 04:22:14 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programList.vm 2013-04-17 07:58:14 +0000 @@ -11,7 +11,7 @@ - + @@ -45,6 +45,10 @@ #end + #if( $auth.hasAccess( "dhis-web-maintenance-patient", "programIndicator" ) ) + + #end + #if ( $security.canManage( $program ) ) $i18n.getString( 'sharing_settings' ) #else @@ -79,19 +83,11 @@ $i18n.getString( 'hide_details' )


+



-


-


-


-


-


-


-


-


-


-


-


-


+


+


+


=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramIndicator.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramIndicator.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramIndicator.vm 2013-04-17 07:58:14 +0000 @@ -0,0 +1,95 @@ + + +

$i18n.getString( "update_program_indicator" )

+ + + + + +
$i18n.getString( "name" )
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$i18n.getString( "program_indicator_details" )
+ +
+
+ +#parse( "/dhis-web-maintenance-patient/programIndicatorForm.vm" ) + +

+ + +

+ + + +