=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-12-14 07:29:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-12-17 02:42:30 +0000 @@ -105,4 +105,7 @@ Grid getStatisticalReport( Program program, Collection orgunitIds, Date startDate, Date endDate, I18n i18n, I18nFormat format ); + + List getStatisticalProgramStageDetailsReport( ProgramStage programStage, Collection orgunitIds, + Date startDate, Date endDate, int status, Integer max, Integer min ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-12-14 07:29:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-12-17 02:42:30 +0000 @@ -95,4 +95,7 @@ int getStatisticalProgramStageReport( ProgramStage programStage, Collection orgunitIds, Date startDate, Date endDate, int status ); + List getStatisticalProgramStageDetailsReport( ProgramStage programStage, Collection orgunitIds, + Date startDate, Date endDate, int status, Integer min, Integer max ); + } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-12-14 08:41:56 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-12-17 02:42:30 +0000 @@ -295,12 +295,13 @@ if ( total > 0 ) { + grid.addHeader( new GridHeader( i18n.getString( "id" ), true, true ) ); grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, true ) ); grid.addHeader( new GridHeader( i18n.getString( "completed" ), false, false ) ); grid.addHeader( new GridHeader( i18n.getString( "percent_completed" ), false, false ) ); grid.addHeader( new GridHeader( i18n.getString( "incomplete" ), false, false ) ); grid.addHeader( new GridHeader( i18n.getString( "percent_incomplete" ), false, false ) ); - grid.addHeader( new GridHeader( i18n.getString( "Scheduled" ), false, false ) ); + grid.addHeader( new GridHeader( i18n.getString( "scheduled" ), false, false ) ); grid.addHeader( new GridHeader( i18n.getString( "percent_Scheduled" ), false, false ) ); grid.addHeader( new GridHeader( i18n.getString( "overdue" ), false, false ) ); grid.addHeader( new GridHeader( i18n.getString( "percent_overdue" ), false, false ) ); @@ -308,8 +309,9 @@ for ( ProgramStage programStage : program.getProgramStages() ) { grid.addRow(); + grid.addValue( programStage.getId() ); grid.addValue( programStage.getName() ); - + int completed = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds, startDate, endDate, ProgramStageInstance.COMPLETED_STATUS ); grid.addValue( completed ); @@ -335,4 +337,11 @@ return grid; } + public List getStatisticalProgramStageDetailsReport( ProgramStage programStage, + Collection orgunitIds, Date startDate, Date endDate, int status, Integer min, Integer max ) + { + return programStageInstanceStore.getStatisticalProgramStageDetailsReport( programStage, orgunitIds, startDate, + endDate, status, min, max ); + } + } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-12-14 07:29:29 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-12-17 02:42:30 +0000 @@ -347,42 +347,28 @@ public int getStatisticalProgramStageReport( ProgramStage programStage, Collection orgunitIds, Date startDate, Date endDate, int status ) { - Criteria criteria = getCriteria( Restrictions.eq( "programStage", programStage ), - Restrictions.isNull( "programInstance.endDate" ) ); - criteria.createAlias( "programInstance", "programInstance" ); - criteria.createAlias( "programInstance.patient", "patient" ); - criteria.createAlias( "patient.organisationUnit", "regOrgunit" ); - criteria.add( Restrictions.in( "regOrgunit.id", orgunitIds ) ); - - switch ( status ) - { - case ProgramStageInstance.COMPLETED_STATUS: - criteria.add( Restrictions.eq( "completed", true ) ); - criteria.add( Restrictions.between( "executionDate", startDate, endDate ) ); - break; - case ProgramStageInstance.VISITED_STATUS: - criteria.add( Restrictions.eq( "completed", false ) ); - criteria.add( Restrictions.between( "executionDate", startDate, endDate ) ); - break; - case ProgramStageInstance.FUTURE_VISIT_STATUS: - criteria.add( Restrictions.between( "programInstance.enrollmentDate", startDate, endDate ) ); - criteria.add( Restrictions.isNull( "executionDate" ) ); - criteria.add( Restrictions.ge( "dueDate", new Date() ) ); - break; - case ProgramStageInstance.LATE_VISIT_STATUS: - criteria.add( Restrictions.between( "programInstance.enrollmentDate", startDate, endDate ) ); - criteria.add( Restrictions.isNull( "executionDate" ) ); - criteria.add( Restrictions.lt( "dueDate", new Date() ) ); - break; - default: - break; - } + Criteria criteria = getStatisticalProgramStageCriteria( programStage, orgunitIds, startDate, endDate, status ); Number rs = (Number) criteria.setProjection( Projections.rowCount() ).uniqueResult(); return rs != null ? rs.intValue() : 0; } + @SuppressWarnings( "unchecked" ) + public List getStatisticalProgramStageDetailsReport( ProgramStage programStage, + Collection orgunitIds, Date startDate, Date endDate, int status, Integer min, Integer max ) + { + Criteria criteria = getStatisticalProgramStageCriteria( programStage, orgunitIds, startDate, endDate, status ); + + if ( min != null && max != null ) + { + criteria.setFirstResult( min ); + criteria.setMaxResults( max ); + } + + return criteria.list(); + } + // ------------------------------------------------------------------------- // Supportive methods // ------------------------------------------------------------------------- @@ -526,4 +512,41 @@ return sql; } + private Criteria getStatisticalProgramStageCriteria( ProgramStage programStage, Collection orgunitIds, + Date startDate, Date endDate, int status ) + { + Criteria criteria = getCriteria( Restrictions.eq( "programStage", programStage ), + Restrictions.isNull( "programInstance.endDate" ) ); + criteria.createAlias( "programInstance", "programInstance" ); + criteria.createAlias( "programInstance.patient", "patient" ); + criteria.createAlias( "patient.organisationUnit", "regOrgunit" ); + criteria.add( Restrictions.in( "regOrgunit.id", orgunitIds ) ); + + switch ( status ) + { + case ProgramStageInstance.COMPLETED_STATUS: + criteria.add( Restrictions.eq( "completed", true ) ); + criteria.add( Restrictions.between( "executionDate", startDate, endDate ) ); + break; + case ProgramStageInstance.VISITED_STATUS: + criteria.add( Restrictions.eq( "completed", false ) ); + criteria.add( Restrictions.between( "executionDate", startDate, endDate ) ); + break; + case ProgramStageInstance.FUTURE_VISIT_STATUS: + criteria.add( Restrictions.between( "programInstance.enrollmentDate", startDate, endDate ) ); + criteria.add( Restrictions.isNull( "executionDate" ) ); + criteria.add( Restrictions.ge( "dueDate", new Date() ) ); + break; + case ProgramStageInstance.LATE_VISIT_STATUS: + criteria.add( Restrictions.between( "programInstance.enrollmentDate", startDate, endDate ) ); + criteria.add( Restrictions.isNull( "executionDate" ) ); + criteria.add( Restrictions.lt( "dueDate", new Date() ) ); + break; + default: + break; + } + + return criteria; + } + } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateStatisticalProgramReportAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateStatisticalProgramReportAction.java 2012-12-14 07:29:29 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateStatisticalProgramReportAction.java 2012-12-17 02:42:30 +0000 @@ -30,9 +30,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import org.hisp.dhis.common.Grid; import org.hisp.dhis.i18n.I18n; @@ -42,9 +40,7 @@ import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; -import org.hisp.dhis.program.ProgramInstanceService; import org.hisp.dhis.program.ProgramService; -import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageInstanceService; import com.opensymphony.xwork2.Action; @@ -76,13 +72,6 @@ this.programService = programService; } - private ProgramInstanceService programInstanceService; - - public void setProgramInstanceService( ProgramInstanceService programInstanceService ) - { - this.programInstanceService = programInstanceService; - } - private ProgramStageInstanceService programStageInstanceService; public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) @@ -143,13 +132,6 @@ this.facilityLB = facilityLB; } - private OrganisationUnit organisationUnit; - - public OrganisationUnit getOrganisationUnit() - { - return organisationUnit; - } - private Collection programInstances = new ArrayList(); public Collection getProgramInstances() @@ -157,34 +139,13 @@ return programInstances; } - private Map statusMap = new HashMap(); - - public Map getStatusMap() - { - return statusMap; - } - - private Program program; - - public Program getProgram() - { - return program; - } - - private int total; - - public int getTotal() - { - return total; - } - private Grid grid; public Grid getGrid() { return grid; } - + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -192,9 +153,9 @@ public String execute() throws Exception { - organisationUnit = selectionManager.getSelectedOrganisationUnit(); + OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); - program = programService.getProgram( programId ); + Program program = programService.getProgram( programId ); Date sDate = format.parseDate( startDate ); @@ -205,7 +166,7 @@ // --------------------------------------------------------------------- Collection orgunitIds = new HashSet(); - + if ( facilityLB.equals( "selected" ) ) { orgunitIds.add( organisationUnit.getId() ); === 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 2012-12-14 13:46:47 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-12-17 02:42:30 +0000 @@ -261,10 +261,20 @@ - - - + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-12-14 07:29:29 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-12-17 02:42:30 +0000 @@ -484,4 +484,5 @@ percent_completed = Percent Completed percent_incomplete = Percent Incomplete percent_Scheduled = Percent scheduled -percent_overdue = Percent Overdue \ No newline at end of file +percent_overdue = Percent Overdue +scheduled = Scheduled \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-12-14 07:29:29 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-12-17 02:42:30 +0000 @@ -346,7 +346,14 @@ /content.vm - /dhis-web-commons/ajax/htmlGrid.vm + /dhis-web-caseentry/statisticalProgramReport.vm + F_GENERATE_STATISTICAL_PROGRAM_REPORT + + + + /content.vm + /dhis-web-caseentry/statisticalProgramDetailsReport.vm F_GENERATE_STATISTICAL_PROGRAM_REPORT === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/statisticalReport.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/statisticalReport.js 2012-12-14 05:49:05 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/statisticalReport.js 2012-12-17 02:42:30 +0000 @@ -1,3 +1,4 @@ +isAjax = true; function organisationUnitSelected( orgUnits, orgUnitNames ) { setFieldValue( 'orgunitname', orgUnitNames[0] ); @@ -7,18 +8,68 @@ function generatedStatisticalProgramReport() { - showLoader(); - - jQuery( "#contentDiv" ).load( "generateStatisticalProgramReport.action", - { - programId: getFieldValue( 'programId' ), + hideById('backBtn'); + hideById('statisticalReportDiv'); + hideById('detailsDiv'); + showLoader(); + jQuery( "#statisticalReportDiv" ).load( "generateStatisticalProgramReport.action", + { + programId: getFieldValue('programId'), + startDate: getFieldValue('startDate'), + endDate: getFieldValue( 'endDate' ), + facilityLB: $('input[name=facilityLB]:checked').val() + }, function() + { + setTableStyles(); + hideById('reportForm'); + showById('statisticalReportDiv'); + showById('reportTbl'); + hideLoader(); + }); +} + +function statisticalProgramDetailsReport( programStageId, status, total ) +{ + showLoader(); + hideById( 'reportTbl' ); + hideById( 'detailsDiv' ); + contentDiv = 'detailsDiv'; + jQuery( "#detailsDiv" ).load( "statisticalProgramDetailsReport.action", + { + programStageId: programStageId, startDate: getFieldValue( 'startDate' ), endDate: getFieldValue( 'endDate' ), + status:status, + total: total, facilityLB: $('input[name=facilityLB]:checked').val() }, function() { - setTableStyles(); + setFieldValue('status',status); + setFieldValue('total',total); + var subTitle = getFieldValue("programStageName") + + " - " + getStatusString( status ) + + " - " + i18n_total_result + ": " + total; + setInnerHTML('gridSubtitleDetails', subTitle ); + showById( 'detailsDiv'); + showById('backBtn'); hideLoader(); - showById( 'contentDiv' ); }); -} \ No newline at end of file +} + +function getStatusString( status ) +{ + switch(status){ + case 1: return i18n_completed; + case 2: return i18n_incomplete; + case 3: return i18n_scheduled; + case 4: return i18n_overdue; + default: return ""; + } +} + +function backOnClick() +{ + hideById('backBtn'); + showById('reportTbl'); + hideById('detailsDiv'); +} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm 2012-12-14 17:07:44 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm 2012-12-17 02:42:30 +0000 @@ -22,7 +22,7 @@
- +
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/statisticalProgramReportSelect.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/statisticalProgramReportSelect.vm 2012-12-14 05:49:05 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/statisticalProgramReportSelect.vm 2012-12-17 02:42:30 +0000 @@ -8,72 +8,70 @@

$i18n.getString( "statistical_program_report" )

+ +

+ + +

+ - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
$i18n.getString('use_data_from_level') - $i18n.getString('selected') - $i18n.getString('children_only') - $i18n.getString('all') -
- -
- - - + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
$i18n.getString('use_data_from_level') + $i18n.getString('selected') + $i18n.getString('children_only') + $i18n.getString('all') +
+ +
+
+
+ #parse( "dhis-web-commons/loader/loader.vm" ) -
- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css 2012-12-14 17:07:44 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css 2012-12-17 02:42:30 +0000 @@ -500,7 +500,6 @@ .gridTable th, .gridTable td { line-height: 170%; - text-align: center; width: 150px; }