dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20399
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9291: Add statistical reports on program summary report
------------------------------------------------------------
revno: 9291
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-12-13 15:48:54 +0700
message:
Add statistical reports on program summary report
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
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/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java
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/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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-11-14 05:52:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-12-13 08:48:54 +0000
@@ -86,19 +86,23 @@
*/
List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed );
+ int getProgramInstancesCount( ProgramStage programStage, Collection<Integer> orgunitIds,
+ Date startDate, Date endDate );
+
List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed );
- Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns, Collection<Integer> organisationUnits,
- int level, Date startDate, Date endDate, boolean descOrder, Boolean completed, Integer min, Integer max );
+ Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns,
+ Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder,
+ Boolean completed, Integer min, Integer max );
int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
Collection<Integer> organisationUnits, int level, Boolean completed, Date startDate, Date endDate );
List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n );
-
+
void removeEmptyEvents( ProgramStage programStage, OrganisationUnit organisationUnit );
void updateProgramStageInstances( Collection<Integer> programStageInstances, OutboundSms outboundSms );
-
+
Collection<SchedulingProgramObject> getSendMesssageEvents();
}
=== 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-11-14 05:52:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-12-13 08:48:54 +0000
@@ -53,38 +53,44 @@
Collection<ProgramStageInstance> get( ProgramStage programStage );
Collection<ProgramStageInstance> get( Date dueDate );
-
+
Collection<ProgramStageInstance> get( Date dueDate, Boolean completed );
Collection<ProgramStageInstance> get( Date startDate, Date endDate );
-
+
Collection<ProgramStageInstance> get( Date startDate, Date endDate, Boolean completed );
Collection<ProgramStageInstance> get( Collection<ProgramInstance> programInstances );
- /** Get all {@link ProgramStageInstance program stage instances} for unit.
+ /**
+ * Get all {@link ProgramStageInstance program stage instances} for unit.
+ *
* @param unit - the unit to get instances for.
* @param after - optional date the instance should be on or after.
* @param before - optional date the instance should be on or before.
- * @param completed - optional flag to only get completed (<code>true</code>) or uncompleted (<code>false</code>) instances.
+ * @param completed - optional flag to only get completed (<code>true</code>
+ * ) or uncompleted (<code>false</code>) instances.
* @return
*/
public List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed );
- List<ProgramStageInstance> get( Patient patient, Boolean completed);
-
- List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
-
+ List<ProgramStageInstance> get( Patient patient, Boolean completed );
+
+ List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate,
+ int min, int max );
+
Grid getTabularReport( ProgramStage programStage, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
Collection<Integer> orgUnits, List<TabularReportColumn> columns, int level, int maxLevel, Date startDate,
Date endDate, boolean descOrder, Boolean completed, Integer min, Integer max );
-
+
int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
- Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate, Boolean completed );
-
+ Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate, Boolean completed );
+
void removeEmptyEvents( ProgramStage programStage, OrganisationUnit organisationUnit );
void update( Collection<Integer> programStageInstanceIds, OutboundSms outboundSms );
-
+
Collection<SchedulingProgramObject> getSendMesssageEvents();
+
+ int getCount( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate);
}
=== 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-11-14 05:52:34 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-12-13 08:48:54 +0000
@@ -169,8 +169,8 @@
}
public Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns,
- Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder, Boolean completed, Integer min,
- Integer max )
+ Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder,
+ Boolean completed, Integer min, Integer max )
{
int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
@@ -273,4 +273,12 @@
{
return programStageInstanceStore.getSendMesssageEvents();
}
+
+ @Override
+ public int getProgramInstancesCount( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate,
+ Date endDate )
+ {
+ return programStageInstanceStore.getCount( programStage, orgunitIds, startDate, endDate );
+ }
+
}
=== 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-11-26 03:11:12 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-12-13 08:48:54 +0000
@@ -34,8 +34,10 @@
import java.util.Map;
import java.util.Set;
+import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.GridHeader;
@@ -222,8 +224,8 @@
deKeys.add( deKey );
}
}
- }
-
+ }
+
grid.addHeader( new GridHeader( "Complete", true, true ) );
// ---------------------------------------------------------------------
@@ -342,6 +344,21 @@
return schedulingProgramObjects;
}
+ public int getCount( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate )
+ {
+ Criteria criteria = getCriteria( Restrictions.eq( "programStage", programStage ),
+ Restrictions.isNull( "programInstance.endDate" ),
+ Restrictions.between( "programInstance.enrollmentDate", startDate, endDate ) );
+ criteria.createAlias( "programInstance", "programInstance" );
+ criteria.createAlias( "programInstance.patient", "patient" );
+ criteria.createAlias( "patient.organisationUnit", "regOrgunit" );
+ criteria.add( Restrictions.in( "regOrgunit.id", orgunitIds ) );
+
+ Number rs = (Number) criteria.setProjection( Projections.rowCount() ).uniqueResult();
+
+ return rs != null ? rs.intValue() : 0;
+ }
+
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
@@ -441,7 +458,7 @@
}
}
- sql += " psi.completed ";
+ sql += " psi.completed ";
sql += "from programstageinstance psi ";
sql += "left join programinstance pi on (psi.programinstanceid=pi.programinstanceid) ";
sql += "left join patient p on (pi.patientid=p.patientid) ";
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java 2012-10-09 03:53:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java 2012-12-13 08:48:54 +0000
@@ -43,6 +43,8 @@
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;
/**
* @author Abyot Asalefew Gizaw
@@ -75,7 +77,14 @@
{
this.programInstanceService = programInstanceService;
}
-
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
private OrganisationUnitService organisationUnitService;
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
@@ -157,6 +166,13 @@
return total;
}
+ private Map<Integer, Integer> completedMap = new HashMap<Integer, Integer>();
+
+ public Map<Integer, Integer> getCompletedMap()
+ {
+ return completedMap;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -206,8 +222,15 @@
programInstances = programInstanceService.getProgramInstances( program, orgunitIds, sDate, eDate,
paging.getStartPos(), paging.getPageSize() );
+
+ for ( ProgramStage programStage : program.getProgramStages() )
+ {
+ int completedNo = programStageInstanceService.getProgramInstancesCount( programStage, orgunitIds,
+ sDate, eDate );
+ completedMap.put( programStage.getId(), completedNo );
+ }
}
-
+
return SUCCESS;
}
}
=== 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-11-23 03:02:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-12-13 08:48:54 +0000
@@ -246,6 +246,7 @@
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
<property name="organisationUnitService"
ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.report.ViewRecordsAction"
=== 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-11-23 04:16:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-12-13 08:48:54 +0000
@@ -476,4 +476,5 @@
show_all = Show all
you_have_active_filters = You have active filters
back_to_event_list = Back to event list
-add_patient_and_add_new = Add person and Add new
\ No newline at end of file
+add_patient_and_add_new = Add person and Add new
+number_of_completed_events = Completed Events No.
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm 2012-12-07 13:55:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm 2012-12-13 08:48:54 +0000
@@ -1,15 +1,17 @@
-<table>
- <tr>
- <td class='text-column' >$i18n.getString( "search_result_matching_the_search_criteria" ):</td>
- <td> </td>
- <td> </td>
- <td>$i18n.getString( "list_all_patients" )</td>
- </tr>
- <tr>
- <td class='text-column' >$i18n.getString( "total_result" )</td>
- <td> </td>
- <td> </td>
- <td>
+<table class='contentProviderTable' style="width:600px;" >
+ <tr class="bold">
+ <td>$i18n.getString( "program_stage")</td>
+ <td align="center">$i18n.getString("number_of_completed_events")</td>
+ </tr>
+ #foreach($programStage in $program.programStages)
+ <tr>
+ <td class='text-column'>$encoder.htmlEncode($programStage.name)</td>
+ <td align="center">$completedMap.get($programStage.id)</td>
+ </tr>
+ #end
+ <tr class="bold">
+ <td class='text-column'>$i18n.getString( "total_result" )</td>
+ <td align="center">
#if($!total)
$total
#else
@@ -19,6 +21,7 @@
</tr>
</table>
+
#if( $programInstances && $programInstances.size() > 0 )
<p>#parse( "/dhis-web-caseentry/colorHelp.vm" )</p>