← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10656: Fix resource table bug for anonymous entry form.

 

------------------------------------------------------------
revno: 10656
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-22 13:06:16 +0700
message:
  Fix resource table bug for anonymous entry form.
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/GenerateTabularReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageDataElements.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.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	2013-04-16 05:41:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-04-22 06:06:16 +0000
@@ -89,12 +89,13 @@
 
     List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed );
 
-    Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns,
+    Grid getTabularReport( Boolean anonynousEntryForm, ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder,
         Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max, I18n i18n );
 
-    int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
-        Collection<Integer> organisationUnits, int level, Boolean completed, Date startDate, Date endDate );
+    int getTabularReportCount( Boolean anonynousEntryForm, 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 );
 
@@ -129,6 +130,7 @@
 
     Collection<Integer> getOrganisationUnitIds( Date startDate, Date endDate );
 
-    Grid getCompletenessProgramStageInstance( OrganisationUnit orgunit, Program program, String startDate, String endDate, I18n i18n );
+    Grid getCompletenessProgramStageInstance( OrganisationUnit orgunit, Program program, String startDate,
+        String endDate, I18n i18n );
 
 }

=== 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	2013-04-16 05:41:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-04-22 06:06:16 +0000
@@ -82,13 +82,14 @@
     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, Boolean accessPrivateInfo, Integer min, Integer max,
-        I18n i18n );
+    Grid getTabularReport( Boolean anonynousEntryForm, ProgramStage programStage,
+        Map<Integer, OrganisationUnitLevel> orgUnitLevelMap, Collection<Integer> orgUnits,
+        List<TabularReportColumn> columns, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
+        Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max, I18n i18n );
 
-    int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
-        Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate, Boolean completed );
+    int getTabularReportCount( Boolean anonynousEntryForm, ProgramStage programStage,
+        List<TabularReportColumn> columns, Collection<Integer> organisationUnits, int level, int maxLevel,
+        Date startDate, Date endDate, Boolean completed );
 
     void removeEmptyEvents( ProgramStage programStage, OrganisationUnit organisationUnit );
 

=== 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	2013-04-16 05:41:25 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-04-22 06:06:16 +0000
@@ -176,7 +176,7 @@
         return programStageInstanceStore.get( patient, completed );
     }
 
-    public Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns,
+    public Grid getTabularReport( Boolean anonynousEntryForm, ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder,
         Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max, I18n i18n )
     {
@@ -184,16 +184,16 @@
 
         Map<Integer, OrganisationUnitLevel> orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap();
 
-        return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits, columns,
+        return programStageInstanceStore.getTabularReport( anonynousEntryForm, programStage, orgUnitLevelMap, organisationUnits, columns,
             level, maxLevel, startDate, endDate, descOrder, completed, accessPrivateInfo, min, max, i18n );
     }
 
-    public int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
+    public int getTabularReportCount( Boolean anonynousEntryForm, ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, Boolean completed, Date startDate, Date endDate )
     {
         int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
 
-        return programStageInstanceStore.getTabularReportCount( programStage, columns, organisationUnits, level,
+        return programStageInstanceStore.getTabularReportCount( anonynousEntryForm, programStage, columns, organisationUnits, level,
             maxLevel, startDate, endDate, completed );
     }
 

=== 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	2013-04-16 05:41:25 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-04-22 06:06:16 +0000
@@ -257,10 +257,10 @@
             .setFirstResult( min ).setMaxResults( max ).list();
     }
 
-    public 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, Boolean accessPrivateInfo, Integer min, Integer max,
-        I18n i18n )
+    public Grid getTabularReport( Boolean anonynousEntryForm, ProgramStage programStage,
+        Map<Integer, OrganisationUnitLevel> orgUnitLevelMap, Collection<Integer> orgUnits,
+        List<TabularReportColumn> columns, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
+        Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max, I18n i18n )
     {
         // ---------------------------------------------------------------------
         // Headers cols
@@ -274,10 +274,13 @@
         grid.addHeader( new GridHeader( "id", true, true ) );
         grid.addHeader( new GridHeader( programStage.getReportDateDescription(), false, true ) );
 
-        for ( int i = level; i <= maxLevel; i++ )
+        if ( anonynousEntryForm == null || !anonynousEntryForm )
         {
-            String name = orgUnitLevelMap.containsKey( i ) ? orgUnitLevelMap.get( i ).getName() : "Level " + i;
-            grid.addHeader( new GridHeader( name, false, true ) );
+            for ( int i = level; i <= maxLevel; i++ )
+            {
+                String name = orgUnitLevelMap.containsKey( i ) ? orgUnitLevelMap.get( i ).getName() : "Level " + i;
+                grid.addHeader( new GridHeader( name, false, true ) );
+            }
         }
 
         Collection<String> deKeys = new HashSet<String>();
@@ -301,8 +304,8 @@
         // Get SQL and build grid
         // ---------------------------------------------------------------------
 
-        String sql = getTabularReportSql( false, programStage, columns, orgUnits, level, maxLevel, startDate, endDate,
-            descOrder, completed, accessPrivateInfo, min, max );
+        String sql = getTabularReportSql( anonynousEntryForm, false, programStage, columns, orgUnits, level, maxLevel,
+            startDate, endDate, descOrder, completed, accessPrivateInfo, min, max );
 
         SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
 
@@ -341,11 +344,12 @@
         return grid;
     }
 
-    public int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
-        Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate, Boolean completed )
+    public int getTabularReportCount( Boolean anonynousEntryForm, ProgramStage programStage,
+        List<TabularReportColumn> columns, Collection<Integer> organisationUnits, int level, int maxLevel,
+        Date startDate, Date endDate, Boolean completed )
     {
-        String sql = getTabularReportSql( true, programStage, columns, organisationUnits, level, maxLevel, startDate,
-            endDate, false, completed, null, null, null );
+        String sql = getTabularReportSql( anonynousEntryForm, true, programStage, columns, organisationUnits, level,
+            maxLevel, startDate, endDate, false, completed, null, null, null );
 
         return jdbcTemplate.queryForObject( sql, Integer.class );
     }
@@ -877,9 +881,9 @@
         return criteria;
     }
 
-    private String getTabularReportSql( boolean count, ProgramStage programStage, List<TabularReportColumn> columns,
-        Collection<Integer> orgUnits, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
-        Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max )
+    private String getTabularReportSql( Boolean anonynousEntryForm, boolean count, ProgramStage programStage,
+        List<TabularReportColumn> columns, Collection<Integer> orgUnits, int level, int maxLevel, Date startDate,
+        Date endDate, boolean descOrder, Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max )
     {
         Set<String> deKeys = new HashSet<String>();
         String selector = count ? "count(*) " : "* ";
@@ -888,10 +892,13 @@
         String where = "";
         String operator = "where ";
 
-        for ( int i = level; i <= maxLevel; i++ )
+        if ( anonynousEntryForm == null || !anonynousEntryForm )
         {
-            sql += "(select name from organisationunit where organisationunitid=ous.idlevel" + i + ") as level_" + i
-                + ",";
+            for ( int i = level; i <= maxLevel; i++ )
+            {
+                sql += "(select name from organisationunit where organisationunitid=ous.idlevel" + i + ") as level_"
+                    + i + ",";
+            }
         }
 
         for ( TabularReportColumn column : columns )
@@ -1012,7 +1019,11 @@
         sql += "left join programinstance pi on (psi.programinstanceid=pi.programinstanceid) ";
         sql += "left join patient p on (pi.patientid=p.patientid) ";
         sql += "join organisationunit ou on (ou.organisationunitid=psi.organisationunitid) ";
-        sql += "join _orgunitstructure ous on (psi.organisationunitid=ous.organisationunitid) ";
+
+        if ( anonynousEntryForm == null || !anonynousEntryForm )
+        {
+            sql += "join _orgunitstructure ous on (psi.organisationunitid=ous.organisationunitid) ";
+        }
 
         sql += "where psi.programstageid=" + programStage.getId() + " ";
 
@@ -1036,9 +1047,12 @@
 
         sql += "order by ";
 
-        for ( int i = level; i <= maxLevel; i++ )
+        if ( anonynousEntryForm == null || !anonynousEntryForm )
         {
-            sql += "level_" + i + ",";
+            for ( int i = level; i <= maxLevel; i++ )
+            {
+                sql += "level_" + i + ",";
+            }
         }
 
         sql += "psi.executiondate ";

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2013-04-15 04:08:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2013-04-22 06:06:16 +0000
@@ -131,6 +131,13 @@
         return identifierTypes;
     }
 
+    private Boolean anonynousEntryForm;
+
+    public void setAnonynousEntryForm( Boolean anonynousEntryForm )
+    {
+        this.anonynousEntryForm = anonynousEntryForm;
+    }
+
     private List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
 
     public List<PatientAttribute> getPatientAttributes()
@@ -397,21 +404,21 @@
         {
             if ( type == null ) // Tabular report
             {
-                totalRecords = programStageInstanceService.getTabularReportCount( programStage, columns,
+                totalRecords = programStageInstanceService.getTabularReportCount( anonynousEntryForm, programStage, columns,
                     organisationUnits, level, useCompletedEvents, startValue, endValue );
 
                 total = getNumberOfPages( totalRecords );
 
                 this.paging = createPaging( totalRecords );
 
-                grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
+                grid = programStageInstanceService.getTabularReport( anonynousEntryForm, programStage, columns, organisationUnits, level,
                     startValue, endValue, !orderByOrgunitAsc, useCompletedEvents, accessPrivateInfo, getStartPos(),
                     paging.getPageSize(), i18n );
             }
             // Download as Excel
             else
             {
-                grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
+                grid = programStageInstanceService.getTabularReport( anonynousEntryForm, programStage, columns, organisationUnits, level,
                     startValue, endValue, !orderByOrgunitAsc, useCompletedEvents, accessPrivateInfo, null, null, i18n );
             }
         }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-04-22 05:42:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-04-22 06:06:16 +0000
@@ -351,9 +351,9 @@
 
             jQuery( '[name=searchObjectId]' ).append( '<option value="" >[' + i18n_please_select + ']</option>' );
             for ( i in json.programStageDataElements ) {
-                jQuery( '[name=searchObjectId]' ).append( '<option value="' + json.programStageDataElements[i].id + '" type="' + json.programStageDataElements[i].type + '">' + json.programStageDataElements[i].name + '</option>' );
+                jQuery( '[name=searchObjectId]' ).append( '<option value="' + json.programStageDataElements[i].id + '" uid="' + json.programStageDataElements[i].uid + '" type="' + json.programStageDataElements[i].type + '">' + json.programStageDataElements[i].name + '</option>' );
                 if ( json.programStageDataElements[i].displayInReports == 'true' ) {
-                    jQuery( '#displayInReports' ).append( '<option value="' + json.programStageDataElements[i].id + '"></option>' );
+                    jQuery( '#displayInReports' ).append( '<option value="' + json.programStageDataElements[i].id + '" uid="' + json.programStageDataElements[i].uid + '" ></option>' );
                 }
             }
 
@@ -383,10 +383,10 @@
         }
         else if ( valueType == 'optionset' ) {
             element.replaceWith( searchTextBox );
-            autocompletedFilterField( container + " [id=searchText]", jQuery( this_ ).val() );
+            autocompletedFilterField( container + " [id=searchText]", jQuery(this_).find("option:selected").attr('uid') );
         }
         else if ( valueType == 'username' ) {
-            autocompletedUsernameField( jQuery( this ).attr( 'id' ) );
+            autocompletedUsernameField( jQuery( this_ ).attr( 'id' ) );
         }
         else {
             element.replaceWith( searchTextBox );
@@ -590,7 +590,7 @@
     hideById( 'dataEntryInfor' );
     hideById( 'listDiv' );
 
-    var params = '';
+    var params = 'anonynousEntryForm=true';
     jQuery( '#displayInReports option' ).each( function ( i, item ) {
         var input = jQuery( item );
         params += '&searchingValues=de_' + input.val() + '_false_';

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageDataElements.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageDataElements.vm	2012-12-10 12:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageDataElements.vm	2013-04-22 06:06:16 +0000
@@ -3,6 +3,7 @@
   #foreach( ${programStageDataElement} in $!{programStageDataElements} )
   {
 	"id": "${programStageDataElement.dataElement.id}",
+	"uid": "${programStageDataElement.dataElement.uid}",
 	"name": "$!encoder.jsonEncode( ${programStageDataElement.dataElement.getFormNameFallback()} )",
 	"type": 
 		#if( $!programStageDataElement.dataElement.optionSet )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm	2013-03-15 07:39:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm	2013-04-22 06:06:16 +0000
@@ -28,7 +28,7 @@
 						#set($index = 0)
 						#set( $noHeader = $grid.getHeaders().size() )
 						#foreach( $col in $grid.getHeaders() )
-							#if( $index == 1 || ( $index > 2 && $index < $noHeader - 2 ))
+							#if( $index > 0 && $index < $noHeader - 2 )
 								<th>$col.name</th>
 							#end
 							#set($index = $index + 1)
@@ -51,8 +51,7 @@
 									#set($psid = $col)
 								#elseif($velocityCount == $noHeader - 1 )
 									#set($completed = $col)
-								#elseif( $index == 1 
-									|| ( $index > 2 && $index < $noHeader - 2 ))
+								#else
 									<td>$!col</td>
 								#end
 								#set($index = $index + 1)