=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2013-06-18 02:41:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2013-07-05 07:05:20 +0000 @@ -89,6 +89,8 @@ public static String MINUS_OPERATOR = "DATEDIFF"; + public static String MINUS_DATAELEMENT_OPERATOR = "DEDATEDIFF"; + public static String AUTO_STORED_BY = "DHIS-SYSTEM"; public static final String regExp = "\\[(" + OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE + "|" + OBJECT_PATIENT + "|" @@ -102,6 +104,11 @@ + "[0-9]+)+\\])\\s*(,)+\\s*(" + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_REPORT_DATE_DATE + "|" + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + ")+\\s*\\)\\s*"; + public static final String minusDataelementRegExp = MINUS_DATAELEMENT_OPERATOR + "{1}\\s*\\(\\s*(\\[" + + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+" + SEPARATOR_ID + "[0-9]+" + SEPARATOR_ID + + "[0-9]+)+\\])\\s*(,)\\s*(\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+" + + SEPARATOR_ID + "[0-9]+" + SEPARATOR_ID + "[0-9]+)+\\])\\s*\\)\\s*(>=|<=|!=|>|<|=){1}\\s*([0-9]+)"; + // ------------------------------------------------------------------------- // Fields // ------------------------------------------------------------------------- === 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-06-18 03:33:56 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java 2013-07-05 07:05:20 +0000 @@ -346,7 +346,7 @@ if ( hasPatients ) { sql += "INNER JOIN programinstance as pi ON pi.programinstanceid = psi.programinstanceid "; - sql += "INNER JOIN patient p on p.patientid=pi.patientid "; + sql += "INNER JOIN patient p on p.patientid=pi.patientid "; } else if ( (hasProgramInstances && !hasPatients) || operator.equals( CaseAggregationCondition.AGGRERATION_COUNT ) ) @@ -607,7 +607,31 @@ String sqlOrgunitCompleted = ""; - // Get minus(date, date) out from the expression and run them later + // Get minus(date dataelement, date dataelement) out from the expression + // and run them later + + Map minus2SQLMap = new HashMap(); + int idx2 = 0; + Pattern patternMinus2 = Pattern.compile( CaseAggregationCondition.minusDataelementRegExp ); + Matcher matcherMinus2 = patternMinus2.matcher( caseExpression ); + while ( matcherMinus2.find() ) + { + String[] ids1 = matcherMinus2.group( 2 ).split( SEPARATOR_ID ); + String[] ids2 = matcherMinus2.group( 5 ).split( SEPARATOR_ID ); + + minus2SQLMap.put( + idx2, + getConditionForMisus2DataElement( orgunitIds, ids1[1], ids1[2], ids2[1], ids2[2], + matcherMinus2.group( 6 ) + matcherMinus2.group( 7 ), startDate, endDate ) ); + + caseExpression = caseExpression.replace( matcherMinus2.group( 0 ), + CaseAggregationCondition.MINUS_DATAELEMENT_OPERATOR + "_" + idx2 ); + + idx2++; + } + + // Get minus(date dataelement, date) out from the expression and run + // them later Map minusSQLMap = new HashMap(); int idx = 0; @@ -746,6 +770,12 @@ sql = sql.replace( CaseAggregationCondition.MINUS_OPERATOR + "_" + key, minusSQLMap.get( key ) ); } + for ( int key = 0; key < idx2; key++ ) + { + sql = sql + .replace( CaseAggregationCondition.MINUS_DATAELEMENT_OPERATOR + "_" + key, minus2SQLMap.get( key ) ); + } + return sql + " ) "; } @@ -984,6 +1014,28 @@ + " AND ( DATE(_pdv.value) - DATE(" + compareSide + ") ) "; } + private String getConditionForMisus2DataElement( Collection orgunitIds, String programStageId1, + String dataElementId1, String programStageId2, String dataElementId2, String compareSide, String startDate, + String endDate ) + { + return " EXISTS ( SELECT * FROM ( SELECT * FROM patientdatavalue _pdv INNER JOIN programstageinstance _psi " + + " ON _pdv.programstageinstanceid=_psi.programstageinstanceid " + + " JOIN programinstance _pi ON _pi.programinstanceid=_psi.programinstanceid " + + " WHERE psi.programstageinstanceid=_pdv.programstageinstanceid and _pdv.dataelementid= " + dataElementId1 + + " AND _psi.organisationunitid in ("+ TextUtils.getCommaDelimitedString( orgunitIds )+") " + + " AND _psi.programstageid = " + programStageId1 + + " AND _psi.executionDate>='" + startDate + "' " + + " AND _psi.executionDate <= '" + endDate + "' ) AS d1 cross join " + + " ( SELECT * FROM patientdatavalue _pdv INNER JOIN programstageinstance _psi " + + " ON _pdv.programstageinstanceid=_psi.programstageinstanceid " + + " JOIN programinstance _pi ON _pi.programinstanceid=_psi.programinstanceid " + + " WHERE psi.programstageinstanceid=_pdv.programstageinstanceid and _pdv.dataelementid= " + dataElementId2 + + " AND _psi.organisationunitid in ("+ TextUtils.getCommaDelimitedString( orgunitIds )+") " + + " AND _psi.programstageid = " + programStageId2 + + " AND _psi.executionDate>='" + startDate + "' " + + " AND _psi.executionDate <= '" + endDate + "' ) AS d2 WHERE DATE(d1.value ) - DATE(d2.value) " + compareSide; + } + /** * Return the Ids of organisation units which patients registered or events * happened. === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm 2013-06-12 04:19:18 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm 2013-07-05 07:05:20 +0000 @@ -12,12 +12,11 @@ $encoder.htmlEncode( $patient.getFullName() ) - ( #if($patient.gender=='F') - - #else - - #end - ) + #if($patient.gender=='F') + + #else + + #end $i18n.getString('program'): $program.displayName === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetAllCaseAggregationConditionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetAllCaseAggregationConditionAction.java 2013-05-30 09:42:05 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetAllCaseAggregationConditionAction.java 2013-07-05 07:05:20 +0000 @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import org.hisp.dhis.caseaggregation.CaseAggregationCondition; @@ -105,16 +106,17 @@ public String execute() throws Exception { - dataSets = new ArrayList( dataSetService.getAllDataSets() ); + Collection _datasets = new HashSet(); aggregationConditions = aggregationConditionService.getAllCaseAggregationCondition(); for ( CaseAggregationCondition aggCondition : aggregationConditions ) { DataElement dataElement = aggCondition.getAggregationDataElement(); - dataSets.addAll( dataElement.getDataSets() ); + _datasets.addAll( dataElement.getDataSets() ); } + dataSets = new ArrayList( _datasets ); Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE ); if ( dataSetId != null ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2013-07-02 14:26:44 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2013-07-05 07:05:20 +0000 @@ -347,6 +347,7 @@ programStage.setDescription( description ); programStage.setProgram( program ); programStage.setMinDaysFromStart( 0 ); + programStage.setAutoGenerateEvent( true ); programStage.setReportDateDescription( REPORT_DATE_DESCRIPTION ); programStageService.saveProgramStage( programStage ); === 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-07-04 05:57:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-07-05 07:05:20 +0000 @@ -440,4 +440,5 @@ deathDate = Date of death isDead = Is dead healthWorker = Health worker -create_default_registration_form = Create default registration form \ No newline at end of file +create_default_registration_form = Create default registration form +minus_with_dataelement = Data Element Date Diff \ No newline at end of file === 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-07-04 13:09:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm 2013-07-05 07:05:20 +0000 @@ -146,6 +146,7 @@ + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm 2013-05-17 08:24:11 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm 2013-07-05 07:05:20 +0000 @@ -1,5 +1,6 @@ +#set($mark=false) #foreach( $aggregationCondition in $aggregationConditions ) - + $encoder.htmlEncode( $aggregationCondition.displayName ) $i18n.getString( 'edit' ) @@ -8,4 +9,5 @@ $i18n.getString( 'show_details' ) + #set($mark=!$mark) #end \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2013-07-04 13:09:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2013-07-05 07:05:20 +0000 @@ -423,6 +423,7 @@ } , function( html ) { + setTableStyles(); setInnerHTML('list', html ); } ); } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatientIdentifierType.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatientIdentifierType.vm 2013-07-03 15:40:29 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatientIdentifierType.vm 2013-07-05 07:05:20 +0000 @@ -23,7 +23,7 @@ $encoder.htmlEncode( $identifierType.displayName ) - + $i18n.getString( 'edit' ) $i18n.getString( 'translation_translate' ) $i18n.getString( 'remove' )