← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8374: Error when searching events in program tracking.

 

------------------------------------------------------------
revno: 8374
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-04 22:05:38 +0700
message:
  Error when searching events in program tracking.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-10-02 06:59:33 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-10-04 15:05:38 +0000
@@ -246,9 +246,7 @@
     public Collection<Patient> search( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max )
     {
         String sql = searchPatientSql( false, searchKeys, orgunit, min, max );
-
         Collection<Patient> patients = new HashSet<Patient>();
-
         try
         {
             patients = jdbcTemplate.query( sql, new RowMapper<Patient>()
@@ -258,7 +256,7 @@
                 {
                     return get( rs.getInt( 1 ) );
                 }
-            } );
+            });
         }
         catch ( Exception ex )
         {
@@ -273,7 +271,6 @@
     {
         String sql = searchPatientSql( false, searchKeys, orgunit, min, max );
         Collection<String> phoneNumbers = new HashSet<String>();
-
         try
         {
             phoneNumbers = jdbcTemplate.query( sql, new RowMapper<String>()
@@ -284,7 +281,7 @@
                     String phoneNumber = rs.getString( "phonenumber" );
                     return (phoneNumber == null || phoneNumber.isEmpty()) ? "0" : phoneNumber;
                 }
-            } );
+            });
         }
         catch ( Exception ex )
         {
@@ -298,9 +295,7 @@
         Integer min, Integer max )
     {
         String sql = searchPatientSql( false, searchKeys, orgunit, min, max );
-
         Collection<Integer> programStageInstanceIds = new HashSet<Integer>();
-
         try
         {
             programStageInstanceIds = jdbcTemplate.query( sql, new RowMapper<Integer>()
@@ -310,7 +305,7 @@
                 {
                     return rs.getInt( "programstageinstanceid" );
                 }
-            } );
+            });
         }
         catch ( Exception ex )
         {
@@ -323,7 +318,6 @@
     public int countSearch( List<String> searchKeys, OrganisationUnit orgunit )
     {
         String sql = searchPatientSql( true, searchKeys, orgunit, null, null );
-
         return jdbcTemplate.queryForInt( sql );
     }
 
@@ -455,7 +449,7 @@
                         patientWhere += condition
                             + operatorStatus
                             + "("
-                            + " psi.status is null and psi.executiondate is null and psi.duedate >= now() and p.organisationunitid="
+                            + " psi.status is null and psi.executiondate is null and (DATE(now()) - DATE(psi.duedate) <= 0) and p.organisationunitid="
                             + keys[4] + ")";
                         operatorStatus = " OR ";
                         condition = "";
@@ -464,7 +458,7 @@
                         patientWhere += condition
                             + operatorStatus
                             + "("
-                            + " psi.status is null and psi.executiondate is null and psi.duedate < now() and p.organisationunitid="
+                            + " psi.status is null and psi.executiondate is null and (DATE(now()) - DATE(psi.duedate) > 0) and p.organisationunitid="
                             + keys[4] + ")";
                         operatorStatus = " OR ";
                         condition = "";

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-10-03 03:46:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-10-04 15:05:38 +0000
@@ -181,8 +181,8 @@
 
     private void updateCaseAggregationCondition()
     {
-        String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "[0-9]+" + SEPARATOR_ID
-            + "[0-9]+" + "\\]";
+        String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+" + SEPARATOR_ID
+            + "[0-9]+" + "\\])";
 
         try
         {
@@ -202,8 +202,8 @@
                 // ---------------------------------------------------------------------
 
                 Pattern pattern = Pattern.compile( regExp );
-
-                Matcher matcher = pattern.matcher( resultSet.getString( 2 ) );
+                String expression = resultSet.getString( 2 ).replaceAll( "'", "''" );
+                Matcher matcher = pattern.matcher( expression );
 
                 while ( matcher.find() )
                 {
@@ -222,19 +222,15 @@
                     if ( rsProgramId.next() )
                     {
                         int programId = rsProgramId.getInt( 1 );
-
                         String aggregationExpression = "[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT
-                            + programId + "." + programStageId + "." + ids[1] + "]";
-
+                            + programId + SEPARATOR_ID + programStageId + SEPARATOR_ID + ids[1] + "]";
                         matcher.appendReplacement( formular, aggregationExpression );
                     }
                 }
 
                 matcher.appendTail( formular );
-
                 executeSql( "UPDATE caseaggregationcondition SET aggregationExpression='" + formular.toString()
                     + "'  WHERE caseaggregationconditionid=" + resultSet.getInt( 1 ) );
-
             }
         }
         catch ( Exception e )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm	2012-09-15 04:18:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/eventMessage.vm	2012-10-04 15:05:38 +0000
@@ -31,7 +31,7 @@
 				#if( $index < 5 )
 					<tr id="tr${sms.id}">
 						<td>$format.formatDateTime($!sms.date)</td>
-						<td> $programStageInstance.programStage.name</td>
+						<td>$programStageInstance.programStage.name</td>
 						<td>$sms.sender</td>
 						<td>$sms.message</td>
 					</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2012-09-27 09:35:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2012-10-04 15:05:38 +0000
@@ -261,7 +261,6 @@
 
 function reloadRecordList()
 {
-	var listAll = getFieldValue('listAll');
 	var startDate = getFieldValue('startDueDate');
 	var endDate = getFieldValue('endDueDate');
 	var arrStatus = getFieldValue('statusEvent').split('_');

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-04 04:31:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-04 15:05:38 +0000
@@ -204,16 +204,14 @@
 	var params = "";
 	var programIds = "";
 	var programStageId = jQuery('#programStageAddPatient').val();
-	if( getFieldValue('searchByProgramStage') == "true" && programStageId!=''){
+	if( getFieldValue('searchByProgramStage') == "true" ){
 		var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]').val();
 		var startDueDate = getFieldValue('startDueDate');
 		var endDueDate = getFieldValue('endDueDate');
 		params += '&searchTexts=stat_' + getFieldValue('programIdAddPatient') 
-			   + '_' + startDueDate + '_' + endDueDate + '_false_' + statusEvent;
-		if( statusEvent != '3' && statusEvent != '4' && statusEvent != '0' )
-		{
-			params += "_" + getFieldValue('orgunitId');
-		}
+			   + '_' + startDueDate + '_' + endDueDate
+			   + "_" + getFieldValue('orgunitId')
+			   + '_false_' + statusEvent;
 	}
 	
 	var flag = false;
@@ -251,11 +249,10 @@
 					p = "";
 				}
 			}
-		})
+		});
 		
 		var searchInAllFacility = byId('searchInAllFacility').checked;
-		if( getFieldValue('searchByProgramStage') == "true" 
-			&& !searchInAllFacility){
+		if( getFieldValue('searchByProgramStage') == "false" && !searchInAllFacility ){
 			p += "_" + getFieldValue('orgunitId');
 		}
 		params += p;
@@ -1603,7 +1600,6 @@
 		}, function ( json )
 		{
 			if ( json.response == "success" ) {
-				field.value="";
 				jQuery('#smsError').css("color", "green");
 				setInnerHTML('smsError', json.message);
 				var date = new Date();
@@ -1612,6 +1608,7 @@
 					+ "<td>" + getFieldValue('programStageName') + "</td>"
 					+ "<td>" + getFieldValue('currentUsername') + "</td>"
 					+ "<td>" + field.value + "</td></tr>");
+				field.value="";
 				field.style.backgroundColor = SUCCESS_COLOR;
 			}
 			else {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-09-27 09:35:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2012-10-04 15:05:38 +0000
@@ -86,6 +86,9 @@
 {
 	setFieldValue('listAll', "false");
 	$('#contentDataRecord').html('');
+	$('#listEventDiv').html('');
+	hideById('listEventDiv');
+	showLoader();
 	params += "&programId=" + getFieldValue('programIdAddPatient');
 	$.ajax({
 		url: 'getSMSPatientRecords.action',
@@ -277,8 +280,8 @@
 	var listAll = getFieldValue('listAll');
 	var startDate = getFieldValue('startDueDate');
 	var endDate = getFieldValue('endDueDate');
-	var status = getFieldValue('statusEvent');
-	if( listAll )
+	var statusEvent = getFieldValue('statusEvent');
+	if( listAll == 'true' )
 	{
 		var date = new Date();
 		var d = date.getDate() - 1;
@@ -293,7 +296,7 @@
 	jQuery("#patientList .stage-object").each( function(){
 		var id = this.id.split('_')[1];
 		var dueDate = jQuery(this).attr('dueDate');
-		var statusEvent = jQuery(this).attr('status');
+		var status = jQuery(this).attr('status');
 		var programInstanceId = jQuery(this).attr('programInstanceId');
 		if( dueDate >= startDate && dueDate <= endDate && statusEvent == status )
 		{

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2012-09-24 05:02:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2012-10-04 15:05:38 +0000
@@ -123,7 +123,7 @@
 				<td>$i18n.getString( "message" )</td>
 				<td>
 					<textarea id="smsMessage" name="smsMessage" style="width:260px;height:100px;" class="{validate:{required:true,maxlength:160}}"></textarea>
-					<input type="button" value="$i18n.getString( 'send_sms' )" onclick="sendSmsOnePatient( byId('smsMessage'),'$programStageInstance.id' );"/>
+					<input type="button" value="&raquo;" class='tiny-button' onclick="sendSmsOnePatient( byId('smsMessage'),'$programStageInstance.id' );"/>
 				</td>
 			</tr>
 			<tr>
@@ -184,7 +184,7 @@
 				#foreach( $sms in $outboundSms )
 					#if( $index >= 5 )
 						<tr id="tr${sms.id}" class='hidden' >
-							<td>$format.formatDateTime($!sms.date)</td>
+							<td>$format.formatDateTime($sms.date)</td>
 							<td>$programStageInstance.programStage.name</td>
 							<td>$sms.sender</td>
 							<td>$sms.message</td>