dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08292
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1978: Add paging function for summary report function into Patient module.
------------------------------------------------------------
revno: 1978
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2010-10-30 17:56:31 +0700
message:
Add paging function for summary report function into Patient module.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.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/struts.xml
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/ProgramInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2010-10-30 10:56:31 +0000
@@ -68,4 +68,8 @@
Collection<ProgramInstance> getProgramInstances( Patient patient, Program program, boolean completed );
Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit );
+
+ Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, int min, int max );
+
+ int countProgramInstances( Program program, OrganisationUnit organisationUnit );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java 2010-10-30 10:56:31 +0000
@@ -60,4 +60,8 @@
Collection<ProgramInstance> get( Patient patient, Program program, boolean completed );
Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit );
+
+ Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, int min, int max );
+
+ int count(Program program, OrganisationUnit organisationUnit );
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2010-10-30 10:56:31 +0000
@@ -129,5 +129,14 @@
{
return programInstanceStore.get( program, organisationUnit );
}
-
+
+ public Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, int min, int max )
+ {
+ return programInstanceStore.get( program, organisationUnit, min, max );
+ }
+
+ public int countProgramInstances(Program program, OrganisationUnit organisationUnit )
+ {
+ return programInstanceStore.count( program, organisationUnit );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2010-10-30 10:56:31 +0000
@@ -29,6 +29,8 @@
import java.util.Collection;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.hibernate.HibernateGenericStore;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -104,7 +106,23 @@
public Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit )
{
return getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) ).createAlias( "patient", "patient" )
- .add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) ).list();
+ .add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) ).list();
}
+ @SuppressWarnings( "unchecked" )
+ public Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, int min, int max )
+ {
+ return getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) )
+ .add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) )
+ .createAlias( "patient", "patient" ).addOrder( Order.asc( "patient.id" ) )
+ .setFirstResult( min ).setMaxResults( max ).list();
+ }
+
+ public int count(Program program, OrganisationUnit organisationUnit )
+ {
+ Number rs = (Number) getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) ).createAlias( "patient", "patient" )
+ .add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) )
+ .setProjection( Projections.rowCount() ).uniqueResult();
+ return rs != null ? rs.intValue() : 0;
+ }
}
=== 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 2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java 2010-10-30 10:56:31 +0000
@@ -35,6 +35,8 @@
import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
@@ -42,14 +44,12 @@
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Abyot Asalefew Gizaw
* @version $Id$
*/
public class GenerateReportAction
- implements Action
+ extends ActionPagingSupport<ProgramInstance>
{
public static final String RED = "#ff0000";
@@ -182,9 +182,14 @@
// ---------------------------------------------------------------------
// Program instances for the selected program
// ---------------------------------------------------------------------
-
- Collection<ProgramInstance> selectedProgramInstances = programInstanceService.getProgramInstances( program, organisationUnit );
-
+ System.out.println("\n\n =============== \n 1.. ");
+ int total = programInstanceService.countProgramInstances( program, organisationUnit );
+System.out.println("\n total 2 : " + total);
+ this.paging = createPaging( total );
+System.out.println("\n 3.. ");
+ Collection<ProgramInstance> selectedProgramInstances = programInstanceService.getProgramInstances( program,
+ organisationUnit, paging.getStartPos(), paging.getPageSize());
+System.out.println("\n 4 selectedProgramInstances : " + selectedProgramInstances );
Collection<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
for ( ProgramInstance programInstance : selectedProgramInstances )
=== 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 2010-10-30 05:54:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2010-10-30 10:56:31 +0000
@@ -216,7 +216,8 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-caseentry/report.vm</param>
<param name="menu">/dhis-web-caseentry/reportsMenu.vm</param>
- <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/calendar/calendar.js,../dhis-web-commons/calendar/calendar-lang.js,../dhis-web-commons/calendar/calendar-setup.js,javascript/report.js</param>
+ <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/calendar/calendar.js,../dhis-web-commons/calendar/calendar-lang.js,../dhis-web-commons/calendar/calendar-setup.js,javascript/report.js</param>
+ <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
</action>
<action name="viewRecords" class="org.hisp.dhis.caseentry.action.report.ViewRecordsAction">
=== 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 2010-07-06 09:34:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm 2010-10-30 10:56:31 +0000
@@ -20,7 +20,7 @@
#set( $mark = false )
#foreach( $programInstance in $programInstances )
<tr #alternate( $mark )>
- <td><a href="javascript:showPatientDetails( $programInstance.patient.id )" title="$i18n.getString( "show_details" )">$encoder.htmlEncode( $programInstance.patient.getFullName() )</a></td>
+ <td><a href="javascript:showPatientDetails( $programInstance.patient.id )" title='$i18n.getString( "show_details" )'>$programInstance.patient.getFullName()</a></td>
#foreach( $programStageInstance in $programInstance.programStageInstances )
#if( $programStageInstance.executionDate )
<td style="text-align:center" bgcolor="$colorMap.get( $programStageInstance.id )">
@@ -44,6 +44,10 @@
</td>
</tr>
</table>
+<p></p>
+<div class="paging-container">
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+</div>
<div id="detailsArea" style="display:none;overflow:auto;height:250px;width:250px" ondblclick="javascript:hideDetails()">
<div style="float:right;" onclick="javascript:hideDetails()">