← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17879: Minor fix in Program reminder.

 

------------------------------------------------------------
revno: 17879
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-01-04 14:35:54 +0700
message:
  Minor fix in Program reminder.
modified:
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programReminder.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStageReminder.js


--
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-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2015-01-04 07:35:54 +0000
@@ -300,58 +300,55 @@
         SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
 
         Collection<SchedulingProgramObject> schedulingProgramObjects = new HashSet<>();
-
-        if ( rs.getRow() > 0 )
+        
+        while ( rs.next() )
         {
-            while ( rs.next() )
+            String message = rs.getString( "templatemessage" );
+
+            int programInstanceId = rs.getInt( "programinstanceid" );
+
+            List<String> attributeUids = reminderService.getAttributeUids( message );
+            SqlRowSet attributeValueRow = jdbcTemplate
+                .queryForRowSet( "select tea.uid ,teav.value from trackedentityattributevalue teav "
+                    + " INNER JOIN trackedentityattribute tea on tea.trackedentityattributeid=teav.trackedentityattributeid "
+                    + " INNER JOIN programinstance ps on teav.trackedentityinstanceid=ps.trackedentityinstanceid "
+                    + " INNER JOIN programstageinstance psi on ps.programinstanceid=psi.programinstanceid "
+                    + " where tea.uid in ( " + TextUtils.getQuotedCommaDelimitedString( attributeUids ) + ") "
+                    + " and ps.programinstanceid=" + programInstanceId );
+            while ( attributeValueRow.next() )
             {
-                String message = rs.getString( "templatemessage" );
-
-                int programInstanceId = rs.getInt( "programinstanceid" );
-
-                List<String> attributeUids = reminderService.getAttributeUids( message );
-                SqlRowSet attributeValueRow = jdbcTemplate
-                    .queryForRowSet( "select tea.uid ,teav.value from trackedentityattributevalue teav "
-                        + " INNER JOIN trackedentityattribute tea on tea.trackedentityattributeid=teav.trackedentityattributeid "
-                        + " INNER JOIN programinstance ps on teav.trackedentityinstanceid=ps.trackedentityinstanceid "
-                        + " INNER JOIN programstageinstance psi on ps.programinstanceid=psi.programinstanceid "
-                        + " where tea.uid in ( " + TextUtils.getQuotedCommaDelimitedString( attributeUids ) + ") "
-                        + " and ps.programinstanceid=" + programInstanceId );
-                while ( attributeValueRow.next() )
-                {
-                    String uid = attributeValueRow.getString( "uid" );
-                    String value = attributeValueRow.getString( "value" );
-                    String key = "\\{(" + TrackedEntityInstanceReminder.ATTRIBUTE + ")=(" + uid + ")\\}";
-                    message = message.replaceAll( key, value );
-                }
-
-                String organisationunitName = rs.getString( "orgunitName" );
-                String programName = rs.getString( "programName" );
-                String incidentDate = rs.getString( "dateofincident" ).split( " " )[0];
-                String daysSinceIncidentDate = rs.getString( "days_since_incident_date" );
-                String erollmentDate = rs.getString( "enrollmentdate" ).split( " " )[0];
-                String daysSinceEnrollementDate = rs.getString( "days_since_erollment_date" );
-
-                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_PROGRAM_NAME, programName );
-                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ORGUNIT_NAME,
-                    organisationunitName );
-                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_INCIDENT_DATE, incidentDate );
-                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ENROLLMENT_DATE,
-                    erollmentDate );
-                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_ENROLLMENT_DATE,
-                    daysSinceEnrollementDate );
-                message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE,
-                    daysSinceIncidentDate );
-
-                SchedulingProgramObject schedulingProgramObject = new SchedulingProgramObject();
-                schedulingProgramObject.setProgramInstanceId( programInstanceId );
-                schedulingProgramObject.setPhoneNumber( rs.getString( "phonenumber" ) );
-                schedulingProgramObject.setMessage( message );
-
-                schedulingProgramObjects.add( schedulingProgramObject );
+                String uid = attributeValueRow.getString( "uid" );
+                String value = attributeValueRow.getString( "value" );
+                String key = "\\{(" + TrackedEntityInstanceReminder.ATTRIBUTE + ")=(" + uid + ")\\}";
+                message = message.replaceAll( key, value );
             }
+
+            String organisationunitName = rs.getString( "orgunitName" );
+            String programName = rs.getString( "programName" );
+            String incidentDate = rs.getString( "dateofincident" ).split( " " )[0];
+            String daysSinceIncidentDate = rs.getString( "days_since_incident_date" );
+            String erollmentDate = rs.getString( "enrollmentdate" ).split( " " )[0];
+            String daysSinceEnrollementDate = rs.getString( "days_since_erollment_date" );
+
+            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_PROGRAM_NAME, programName );
+            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ORGUNIT_NAME,
+                organisationunitName );
+            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_INCIDENT_DATE, incidentDate );
+            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ENROLLMENT_DATE,
+                erollmentDate );
+            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_ENROLLMENT_DATE,
+                daysSinceEnrollementDate );
+            message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_INCIDENT_DATE,
+                daysSinceIncidentDate );
+
+            SchedulingProgramObject schedulingProgramObject = new SchedulingProgramObject();
+            schedulingProgramObject.setProgramInstanceId( programInstanceId );
+            schedulingProgramObject.setPhoneNumber( rs.getString( "phonenumber" ) );
+            schedulingProgramObject.setMessage( message );
+
+            schedulingProgramObjects.add( schedulingProgramObject );
         }
-
+        
         return schedulingProgramObjects;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programReminder.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programReminder.js	2014-08-06 15:20:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programReminder.js	2015-01-04 07:35:54 +0000
@@ -53,11 +53,11 @@
 	setInnerHTML('idField', json.reminder.uid);
 	
 	var days = json.reminder.daysAllowedSendMessage;
-	if( eval(days)>=0 ){
-		setInnerHTML('daysAllowedSendMessageField', days + " " + i18n_days_before);
+	if( eval(days)<=0 ){
+		setInnerHTML('daysAllowedSendMessageField', -1 * days + " " + i18n_days_before);
 	}
 	else{
-		setInnerHTML('daysAllowedSendMessageField', -1 * eval(days) + " " + i18n_days_after);
+		setInnerHTML('daysAllowedSendMessageField',eval(days) + " " + i18n_days_after);
 	}
 
     setInnerHTML('templateMessageField', json.reminder.templateMessage);

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStageReminder.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStageReminder.js	2014-08-06 15:20:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStageReminder.js	2015-01-04 07:35:54 +0000
@@ -53,11 +53,11 @@
     setInnerHTML('idField', json.reminder.uid);
 	
 	var days = json.reminder.daysAllowedSendMessage;
-	if( eval(days)>=0 ){
-		setInnerHTML('daysAllowedSendMessageField', days + " " + i18n_days_before);
+	if( eval(days)<=0 ){
+		setInnerHTML('daysAllowedSendMessageField', -1 * days + " " + i18n_days_before);
 	}
 	else{
-		setInnerHTML('daysAllowedSendMessageField', -1 * eval(days) + " " + i18n_days_after);
+		setInnerHTML('daysAllowedSendMessageField', eval(days) + " " + i18n_days_after);
 	}
     setInnerHTML('templateMessageField', json.reminder.templateMessage);
     setInnerHTML('dateToCompareField', json.reminder.dateToCompare);