← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4148: Improve patient report function.

 

------------------------------------------------------------
revno: 4148
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-07-15 15:07:54 +0700
message:
  Improve patient report function.
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/java/org/hisp/dhis/caseentry/action/report/ReportSelectAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateReportParametersAction.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/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js
  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/reportSelect.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-30 10:56:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2011-07-15 08:07:54 +0000
@@ -26,6 +26,7 @@
  */
 package org.hisp.dhis.program;
 
+import java.util.Date;
 import java.util.Collection;
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -71,5 +72,12 @@
     
     Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, int min, int max );
     
+    Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+
+    Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate,
+        int min, int max );
+
     int countProgramInstances( Program program, OrganisationUnit organisationUnit );
+    
+    int countProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
 }

=== 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-30 10:56:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java	2011-07-15 08:07:54 +0000
@@ -26,6 +26,7 @@
  */
 package org.hisp.dhis.program;
 
+import java.util.Date;
 import java.util.Collection;
 
 import org.hisp.dhis.common.GenericStore;
@@ -40,28 +41,35 @@
     extends GenericStore<ProgramInstance>
 {
     String ID = ProgramInstanceStore.class.getName();
-    
+
     Collection<ProgramInstance> get( boolean completed );
-    
+
     Collection<ProgramInstance> get( Program program );
-    
+
     Collection<ProgramInstance> get( Collection<Program> programs );
-    
+
     Collection<ProgramInstance> get( Program program, boolean completed );
-    
+
     Collection<ProgramInstance> get( Collection<Program> programs, boolean completed );
-    
+
     Collection<ProgramInstance> get( Patient patient );
-    
+
     Collection<ProgramInstance> get( Patient patient, boolean completed );
-    
+
     Collection<ProgramInstance> get( Patient patient, Program program );
-    
+
     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 );
+
+    Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+
+    Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate,
+        int min, int max );
+
+    int count( Program program, OrganisationUnit organisationUnit );
     
-    int count(Program program, OrganisationUnit organisationUnit );
+    int count( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
 }

=== 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	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2011-07-15 08:07:54 +0000
@@ -26,6 +26,7 @@
  */
 package org.hisp.dhis.program;
 
+import java.util.Date;
 import java.util.Collection;
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -136,8 +137,25 @@
         return programInstanceStore.get( program, organisationUnit, min, max );
     }
 
+    public Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit,
+        Date startDate, Date endDate )
+    {
+        return programInstanceStore.get( program, organisationUnit, startDate, endDate );
+    }
+
+    public Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit,
+        Date startDate, Date endDate, int min, int max )
+    {
+        return programInstanceStore.get( program, organisationUnit, startDate, endDate, min, max );
+    }
+
     public int countProgramInstances( Program program, OrganisationUnit organisationUnit )
     {
         return programInstanceStore.count( program, organisationUnit );
     }
+
+    public int countProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate )
+    {
+        return programInstanceStore.count( program, organisationUnit, startDate, endDate );
+    }
 }

=== 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	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2011-07-15 08:07:54 +0000
@@ -27,6 +27,7 @@
 
 package org.hisp.dhis.program.hibernate;
 
+import java.util.Date;
 import java.util.Collection;
 
 import org.hibernate.criterion.Order;
@@ -117,11 +118,49 @@
             .addOrder( Order.asc( "patient.id" ) ).setFirstResult( min ).setMaxResults( max ).list();
     }
 
+    @SuppressWarnings( "unchecked" )
+    public Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, Date startDate,
+        Date endDate )
+    {
+        return getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ), Restrictions.ge( "enrollmentDate", startDate ),
+            Restrictions.le( "enrollmentDate", endDate ) )
+            .createAlias( "patient", "patient" )
+            .add(Restrictions.eq( "patient.organisationUnit", organisationUnit ) ) 
+            .addOrder( Order.asc( "patient.id" ) ).list();
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, Date startDate,
+        Date endDate, int min, int max )
+    {
+        return getCriteria( Restrictions.eq( "program", program ), 
+            Restrictions.isNull( "endDate" ), 
+            Restrictions.ge( "enrollmentDate", startDate ),
+            Restrictions.le( "enrollmentDate", endDate ) )
+            .createAlias( "patient", "patient" )
+            .add(Restrictions.eq( "patient.organisationUnit", organisationUnit ) )
+            .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" ) )
+        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;
     }
+
+    public int count( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate )
+    {
+        Number rs = (Number) getCriteria( Restrictions.eq( "program", program ), 
+            Restrictions.isNull( "endDate" ),
+            Restrictions.ge( "enrollmentDate", startDate ), 
+            Restrictions.le( "enrollmentDate", 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	2011-05-06 11:10:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java	2011-07-15 08:07:54 +0000
@@ -29,12 +29,13 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
@@ -63,11 +64,11 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private SelectedStateManager selectedStateManager;
+    private OrganisationUnitSelectionManager selectionManager;
 
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
     {
-        this.selectedStateManager = selectedStateManager;
+        this.selectionManager = selectionManager;
     }
 
     private ProgramService programService;
@@ -102,32 +103,11 @@
     // Input/output
     // -------------------------------------------------------------------------
 
-    private OrganisationUnit organisationUnit;
-
-    public OrganisationUnit getOrganisationUnit()
-    {
-        return organisationUnit;
-    }
-
-    private Program program;
-
-    public Program getProgram()
-    {
-        return program;
-    }
-
-    private Collection<Program> programs = new ArrayList<Program>();
-
-    public Collection<Program> getPrograms()
-    {
-        return programs;
-    }
-
     private Integer programId;
 
-    public Integer getProgramId()
+    public void setProgramId( Integer programId )
     {
-        return programId;
+        this.programId = programId;
     }
 
     private String startDate;
@@ -137,11 +117,6 @@
         this.startDate = startDate;
     }
 
-    public String getStartDate()
-    {
-        return startDate;
-    }
-
     private String endDate;
 
     public void setEndDate( String endDate )
@@ -149,9 +124,11 @@
         this.endDate = endDate;
     }
 
-    public String getEndDate()
+    private OrganisationUnit organisationUnit;
+
+    public OrganisationUnit getOrganisationUnit()
     {
-        return endDate;
+        return organisationUnit;
     }
 
     Collection<ProgramInstance> programInstances = new ArrayList<ProgramInstance>();
@@ -168,6 +145,13 @@
         return colorMap;
     }
 
+    private Program program;
+
+    public Program getProgram()
+    {
+        return program;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -175,42 +159,29 @@
     public String execute()
         throws Exception
     {
-        organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
-        program = selectedStateManager.getSelectedProgram();
-
-        programId = program.getId();
-
-        programs = programService.getPrograms( organisationUnit );
+        organisationUnit = selectionManager.getSelectedOrganisationUnit();
+
+        program = programService.getProgram( programId );
+
+        Date sDate = format.parseDate( startDate );
+
+        Date eDate = format.parseDate( endDate );
 
         // ---------------------------------------------------------------------
         // Program instances for the selected program
         // ---------------------------------------------------------------------
 
-        int total = programInstanceService.countProgramInstances( program, organisationUnit );
+        int total = programInstanceService.countProgramInstances( program, organisationUnit, sDate, eDate );
 
         this.paging = createPaging( total );
 
-        Collection<ProgramInstance> selectedProgramInstances = programInstanceService.getProgramInstances( program,
-            organisationUnit, paging.getStartPos(), paging.getPageSize() );
+        programInstances = programInstanceService.getProgramInstances( program, organisationUnit, sDate, eDate, paging
+            .getStartPos(), paging.getPageSize() );
 
         Collection<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
 
-        for ( ProgramInstance programInstance : selectedProgramInstances )
+        for ( ProgramInstance programInstance : programInstances )
         {
-            if ( !programInstance.isCompleted() )
-            {
-                programInstances.add( programInstance );
-            }
-            else
-            {
-                if ( programInstance.getEnrollmentDate().before( format.parseDate( endDate ) )
-                    && programInstance.getEnrollmentDate().after( format.parseDate( startDate ) ) )
-                {
-                    programInstances.add( programInstance );
-                }
-            }
-
             programStageInstances.addAll( programInstance.getProgramStageInstances() );
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ReportSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ReportSelectAction.java	2011-05-12 09:40:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ReportSelectAction.java	2011-07-15 08:07:54 +0000
@@ -27,13 +27,7 @@
 
 package org.hisp.dhis.caseentry.action.report;
 
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 
 import com.opensymphony.xwork2.Action;
 
@@ -47,49 +41,12 @@
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    private ProgramService programService;
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input/output
-    // -------------------------------------------------------------------------
-
-    private OrganisationUnit organisationUnit;
-
-    public OrganisationUnit getOrganisationUnit()
-    {
-        return organisationUnit;
-    }
-
-    private Integer programId;
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    public Integer getProgramId()
-    {
-        return programId;
-    }
-
-    private Collection<Program> programs = new ArrayList<Program>();
-
-    public Collection<Program> getPrograms()
-    {
-        return programs;
+   
+    private OrganisationUnitSelectionManager selectionManager;
+
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
     }
 
     // -------------------------------------------------------------------------
@@ -97,58 +54,9 @@
     // -------------------------------------------------------------------------
 
     public String execute()
-        throws Exception
     {
-        // ---------------------------------------------------------------------
-        // Validate selected OrganisationUnit
-        // ---------------------------------------------------------------------
-
-        organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
-        if ( organisationUnit == null )
-        {
-            programId = null;
-
-            selectedStateManager.clearSelectedProgram();
-
-            return SUCCESS;
-        }
-
-        // ---------------------------------------------------------------------
-        // Load assigned Programs
-        // ---------------------------------------------------------------------
-
-        programs = programService.getPrograms( organisationUnit );
-
-        // ---------------------------------------------------------------------
-        // Validate selected Program
-        // ---------------------------------------------------------------------
-
-        Program selectedProgram;
-
-        if ( programId != null )
-        {
-            selectedProgram = programService.getProgram( programId );
-        }
-        else
-        {
-            selectedProgram = selectedStateManager.getSelectedProgram();
-        }
-
-        if ( selectedProgram != null && programs.contains( selectedProgram ) )
-        {
-            programId = selectedProgram.getId();
-            selectedStateManager.setSelectedProgram( selectedProgram );
-        }
-        else
-        {
-            programId = null;
-
-            selectedStateManager.clearSelectedProgram();
-
-            return SUCCESS;
-        }
-
+        selectionManager.clearSelectedOrganisationUnits();
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateReportParametersAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateReportParametersAction.java	2011-03-31 01:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/ValidateReportParametersAction.java	2011-07-15 08:07:54 +0000
@@ -29,7 +29,6 @@
 
 import java.util.Date;
 
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 
@@ -45,14 +44,7 @@
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
+    
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -103,20 +95,6 @@
     public String execute()
         throws Exception
     {
-        if ( selectedStateManager.getSelectedOrganisationUnit() == null )
-        {
-            message = i18n.getString( "please_select_a_reporting_unit" );
-
-            return INPUT;
-        }
-
-        if ( selectedStateManager.getSelectedProgram() == null )
-        {
-            message = i18n.getString( "please_select_a_program" );
-
-            return INPUT;
-        }
-
         if ( startDate == null )
         {
             message = i18n.getString( "please_choose_a_valid_start_date" );

=== 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	2011-07-14 09:31:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-07-15 08:07:54 +0000
@@ -175,22 +175,20 @@
     <property name="activityPlanService" ref="org.hisp.dhis.activityplan.ActivityPlanService" />
   </bean>
 
-	<!-- Report -->
+  <!-- Report -->
 
   <bean id="org.hisp.dhis.caseentry.action.report.ReportSelectAction" class="org.hisp.dhis.caseentry.action.report.ReportSelectAction"
     scope="prototype">
-    <property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-    <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+    <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
   </bean>
 
   <bean id="org.hisp.dhis.caseentry.action.report.ValidateReportParametersAction" class="org.hisp.dhis.caseentry.action.report.ValidateReportParametersAction"
     scope="prototype">
-    <property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
   </bean>
 
   <bean id="org.hisp.dhis.caseentry.action.report.GenerateReportAction" class="org.hisp.dhis.caseentry.action.report.GenerateReportAction"
     scope="prototype">
-    <property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+    <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
     <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
     <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
     <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />

=== 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	2011-06-14 16:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-07-15 08:07:54 +0000
@@ -308,4 +308,5 @@
 validation														= Validation
 program_validation_description									= Program Validation Description
 please_select_village											= Please select village
-select_sorting_attribute										= Select a specfied attribute / ALL
\ No newline at end of file
+select_sorting_attribute										= Select a specfied attribute / ALL
+no_result														= No result
\ 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	2011-07-15 03:35:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-07-15 08:07:54 +0000
@@ -153,6 +153,14 @@
     
     <!-- Report -->
 
+ 	<action name="reportSelect" class="org.hisp.dhis.caseentry.action.report.ReportSelectAction">
+      <interceptor-ref name="organisationUnitTreeStack" />
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-caseentry/reportSelect.vm</param>
+      <param name="menu">/dhis-web-caseentry/reportsMenu.vm</param>
+      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/report.js</param>
+    </action>
+    
     <action name="reportSelect" class="org.hisp.dhis.caseentry.action.report.ReportSelectAction">
       <interceptor-ref name="organisationUnitTreeStack" />
       <result name="success" type="velocity">/main.vm</result>
@@ -169,10 +177,9 @@
     </action>
 
     <action name="generateReport" class="org.hisp.dhis.caseentry.action.report.GenerateReportAction">
-      <interceptor-ref name="organisationUnitTreeStack" />
       <result name="success" type="velocity">/content.vm</result>
       <param name="page">/dhis-web-caseentry/report.vm</param>
-      <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/report.js</param>
+      <param name="javascripts">javascript/report.js</param>
       <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js	2011-05-23 06:10:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/report.js	2011-07-15 08:07:54 +0000
@@ -2,7 +2,40 @@
 
 function organisationUnitSelected( orgUnits )
 {
-    window.location.href = 'reportSelect.action';
+    showLoader();
+	jQuery.postJSON( "getPrograms.action",
+	{
+	}, 
+	function( json ) 
+	{    
+		setFieldValue( 'orgunitname', json.organisationUnit );
+		
+		clearListById('programId');
+		if( json.programs.length == 0)
+		{
+			disable('programId');
+			disable('startDate');
+			disable('endDate');
+			disable('endDate');
+			disable('generateBtn');
+		}
+		else
+		{
+			addOptionById( 'programId', "0", i18n_select );
+			
+			for ( var i in json.programs ) 
+			{
+				addOptionById( 'programId', json.programs[i].id, json.programs[i].name );
+			} 
+			enable('programId');
+			enable('startDate');
+			enable('endDate');
+			enable('endDate');
+			enable('generateBtn');
+		}
+		
+		hideLoader();
+	});
 }
 
 selection.setListenerFunction( organisationUnitSelected );
@@ -47,8 +80,9 @@
 
 	jQuery( "#contentDiv" ).load( "generateReport.action",
 	{
-		'startDate': getFieldValue( 'startDate' ),
-		'&endDate': getFieldValue( 'endDate' )
+		programId: getFieldValue( 'programId' ),
+		startDate: getFieldValue( 'startDate' ),
+		endDate: getFieldValue( 'endDate' )
 	}, function() { unLockScreen();hideById( 'message' );showById( 'contentDiv' );});
 }
 

=== 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	2011-05-12 09:40:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm	2011-07-15 08:07:54 +0000
@@ -1,3 +1,6 @@
+#if( $programInstance.size() == 0 )
+	<i>$i18n.getString('no_result')</i>
+#else
 <table class="mainPageTable">
 <tr>
     <td style="vertical-align:top">    
@@ -41,7 +44,7 @@
     </td>
 </tr>
 </table>
-
+#end
 <p></p>
 
 <div class="paging-container">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm	2011-05-12 09:40:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportSelect.vm	2011-07-15 08:07:54 +0000
@@ -1,56 +1,55 @@
-<script type="text/javascript">   
-    var i18n_report_generation_failed = '$encoder.jsEscape( $i18n.getString( "report_generation_failed" ), "'")';    
-</script>   
-
 <h3>$i18n.getString( "report_management" )</h3>
 
 <form id="reportForm" name="reportForm" method="post" action="reportSelect.action">
 <table>	
     <tr>
 	  <td><label>$i18n.getString( "reporting_unit" )</label></td>
-	  <td><input type="text" readonly="readonly" #if( $organisationUnit ) value="$encoder.htmlEncode( $organisationUnit.name )" #else value="[$i18n.getString( "select" )]" #end style="min-width:350px"></td>
+	  <td><input type="text" readonly="readonly" id='orgunitname' name='orgunitname' #if( $organisationUnit ) value="$encoder.htmlEncode( $organisationUnit.name )" #else value="[$i18n.getString( "select" )]" #end style="min-width:350px"></td>
     </tr>
     
     <tr>
-        <td><label for="programId">$i18n.getString( "program" )</label></td>
+        <td><label for="programId">$i18n.getString( "program" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
         <td>
-            <select id="programId" name="programId" style="min-width:350px" onchange="document.forms[0].submit();" #if( $!programs && $programs.size() == 0 ) disabled="disabled" #end>
-                <option value="0">[$i18n.getString( "select" )]</option>
-                #foreach( $program in $programs )
-                    <option value="$program.id" #if( $programId && $program.id == $programId ) selected="selected" #end>$encoder.htmlEncode( $program.name )</option>
-                #end
+            <select id="programId" name="programId" disabled style="min-width:350px" class="{validate:{required:true}}">
             </select>
         </td>
     </tr>
         
     <tr>
-        <td><label>$i18n.getString( "start_date" )</label></td>
+        <td><label>$i18n.getString( "start_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
         <td>
-            <input type="text" id="startDate" name="startDate" #if( $startDate ) value="$encoder.htmlEncode( $startDate )" #end />
+            <input type="text" id="startDate" name="startDate" disabled class="{validate:{required:true}}" />
 			<script type="text/javascript">
-				datePicker('startDate');
+				datePickerValid('startDate');
             </script>  	
         </td>
     </tr>
     
     <tr>
-        <td><label>$i18n.getString( "end_date" )</label></td>
+        <td><label>$i18n.getString( "end_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
         <td>
-            <input type="text" id="endDate" name="endDate" #if( $endDate ) value="$encoder.htmlEncode( $endDate )" #end />
+            <input type="text" id="endDate" name="endDate" disabled class="{validate:{required:true}}" />
             <script type="text/javascript">
-				datePicker('endDate');
+				datePickerValid('endDate');
             </script> 				
         </td>      
     </tr>    	                		
 </table>
 <p>
-    <input type="button" value="$i18n.getString( 'generate' )" style="width:10em" onclick="validateAndGenerateReport()"/>
+    <input type="button" id='generateBtn' name='generateBtn' disabled value="$i18n.getString( 'generate' )" style="width:10em" onclick="validateAndGenerateReport()"/>
     <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='index.action'" style="width:10em"/>
 </p>  
 </form>
 
+#parse( "dhis-web-commons/loader/loader.vm" )
+
 <hr style="clear:both">
 
 <div id="contentDiv"></div>
 
-<span id="message"></span>
\ No newline at end of file
+<span id="message"></span>
+
+<script type="text/javascript">   
+    var i18n_report_generation_failed = '$encoder.jsEscape( $i18n.getString( "report_generation_failed" ), "'")';    
+	var i18n_select = '$encoder.jsEscape( $i18n.getString( "select" ), "'")';    
+</script>