← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7934: Error when to search patients with due-date params in SMS Reminder.

 

------------------------------------------------------------
revno: 7934
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-08-20 10:18:20 +0700
message:
  Error when to search patients with due-date params in SMS Reminder.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java
  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/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.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-08-18 13:17:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2012-08-20 03:18:20 +0000
@@ -405,7 +405,7 @@
                 sql += " MIN( psi.programstageinstanceid ) as programstageinstanceid,";
                 isSearchEvent = true;
                 patientWhere += patientOperator + "pgi.patientid=p.patientid and psi.programstageid=" + id + " and ";
-                patientWhere += "psi.duedate>='" + keys[3] + "' and psi.duedate<='" + keys[3] + "' and ";
+                patientWhere += "psi.duedate>='" + keys[3] + "' and psi.duedate<='" + keys[4] + "' and ";
                     
                 int statusEvent = Integer.parseInt( keys[2] );
                 switch ( statusEvent )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java	2012-08-16 15:47:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java	2012-08-20 03:18:20 +0000
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.caseentry.action.caseentry;
-
-import java.util.Date;
-
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramInstanceService;
-import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- * 
- * @version $Id: CreateAnonymousEncounterAction.java Dec 16, 2011 9:08:12 AM $
- */
-public class CreateAnonymousEncounterAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    private ProgramService programService;
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    private ProgramInstanceService programInstanceService;
-
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
-    private ProgramStageInstanceService programStageInstanceService;
-
-    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
-    {
-        this.programStageInstanceService = programStageInstanceService;
-    }
-
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    private I18n i18n;
-
-    public void setI18n( I18n i18n )
-    {
-        this.i18n = i18n;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input/Output
-    // -------------------------------------------------------------------------
-
-    private Integer programId;
-
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    public String executionDate;
-
-    public void setExecutionDate( String executionDate )
-    {
-        this.executionDate = executionDate;
-    }
-
-    private String message;
-
-    public String getMessage()
-    {
-        return message;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-        throws Exception
-    {
-        Date date = format.parseDate( executionDate );
-
-        if ( date == null )
-        {
-            message = i18n.getString( "please_enter_report_date" );
-        }
-        else
-        {
-            Program program = programService.getProgram( programId );
-            ProgramStage programStage = program.getProgramStages().iterator().next();
-            
-            ProgramInstance programInstance = programInstanceService.getProgramInstances( program ).iterator().next();
-
-            ProgramStageInstance programStageInstance = new ProgramStageInstance();
-            programStageInstance.setProgramInstance( programInstance );
-            programStageInstance.setProgramStage( programStage );
-            programStageInstance.setDueDate( date );
-            programStageInstance.setExecutionDate( date );
-            programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
-
-            int id = programStageInstanceService.addProgramStageInstance( programStageInstance );
-
-            message = id + "";
-        }
-
-        return (date != null) ? SUCCESS : INPUT;
-    }
-}

=== 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	2012-08-17 12:39:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-08-20 03:18:20 +0000
@@ -416,5 +416,4 @@
 post_comment = Post comment
 comments = Comments
 no_sms_service_available = No Sms service available
-due_date_from_to = Due date (from-to)
-please_select_status = Please select status
\ No newline at end of file
+due_date_from_to = Due date (from-to)
\ No newline at end of file

=== 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-08-18 13:17:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-08-20 03:18:20 +0000
@@ -80,7 +80,7 @@
 		contend += '&nbsp;<input type="button" class="small-button" value="-" onclick="removeAttributeOption(' + "'" + rowId + "'" + ');"></td>';
 		contend = '<tr id="' + rowId + '">' + contend + '</tr>';
 
-	jQuery('#advancedSearchTB > tbody:last').append( contend );
+	jQuery('#advancedSearchTB').append( contend );
 }	
 
 function removeAttributeOption( rowId )
@@ -189,17 +189,23 @@
 	hideById( 'listPatientDiv' );
 	var flag = true;
 	var dateOperator = '';
-	if (getFieldValue('searchByProgramStage') == "false"){
-		jQuery("#searchDiv :input").each( function( i, item )
+	
+	if (getFieldValue('searchByProgramStage') == "true" 
+		&& getFieldValue('programStageAddPatient') == '' 
+		&& jQuery("#searchDiv :input[name=searchText]").val() == ''){
+		flag = false;
+	}
+	
+	jQuery("#searchDiv :input").each( function( i, item )
+	{
+		var elementName = $(this).attr('name');
+		if( elementName=='searchText' && jQuery( item ).val() == '' && !flag)
 		{
-			var elementName = $(this).attr('name');
-			if( elementName=='searchText' && jQuery( item ).val() == '' )
-			{
-				showWarningMessage( i18n_specify_search_criteria );
-				flag = false;
-			}
-		});
-	}
+			showWarningMessage( i18n_specify_search_criteria );
+			flag = false;
+		}
+	});
+	
 	if(flag){
 		contentDiv = 'listPatientDiv';
 		jQuery( "#loaderDiv" ).show();
@@ -218,7 +224,7 @@
 		params += '&searchTexts=prgst_' + programStageId + '_' + statusEvent + '_' + startDueDate + '_' + endDueDate;
 	}
 	
-	jQuery( '#advancedSearchTB tbody tr' ).each( function( i, row ){
+	jQuery( '#advancedSearchTB tr' ).each( function( i, row ){
 		var dateOperator = "";
 		var p = "";
 		jQuery( this ).find(':input').each( function( idx, item ){

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-08-18 13:17:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2012-08-20 03:18:20 +0000
@@ -27,8 +27,7 @@
 </table>
 
 <div id='advanced-search' class='hidden'>
-	<table id='advancedSearchTB'>	
-		<thead>
+	<table>	
 		<tr id='programStageAddPatientTR' class='hidden'>
 			<td>
 				<select id='programStageAddPatient' name='programStageAddPatient' onchange='enableRadioButton();'>
@@ -40,7 +39,6 @@
 			</td>
 			<td>
 				<select id="statusEvent" name="statusEvent">
-					<option value=''>[$i18n.getString("please_select_status")]</option>
 					<option value='1'>$i18n.getString("completed")</option>
 					<option value='2'>$i18n.getString("incomplete")</option>
 					<option value='3'>$i18n.getString("scheduled_in_future")</option> 
@@ -49,11 +47,13 @@
 			</td>
 		</tr>
 		<tr>
-			<td><input type='textbox' id='startDueDate' name='startDueDate'></td>
-			<td><input type='textbox' id='endDueDate' name='endDueDate'></td>
+			<td>$i18n.getString('due_date_from_to')</td>
+			<td>
+				<input type='textbox' id='startDueDate' name='startDueDate' style='width:105px;'>
+				<input type='textbox' id='endDueDate' name='endDueDate' style='width:105px;'>
+			</td>
 		</tr>
-		</thead>
-		<tbody>
+		<tbody id='advancedSearchTB'>
 			<tr id='advSearchBox0'>	       
 				<td id='searchingAttributeIdTD'>
 				  <select id="searchObjectId" name="searchObjectId" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end onchange="searchObjectOnChange(this)">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.vm	2012-08-18 13:17:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.vm	2012-08-20 03:18:20 +0000
@@ -43,6 +43,7 @@
 								<td class='stage-flow'>
 									<div id='flow_$programInstance.id' class='stage-flow'><table class="stage-flow">
 										<tr>
+										#set( $flag = "false" )
 										#foreach( $programStageInstance in $programStageInstances )
 											<td>
 												<img src='images/rightarrow.png'>
@@ -51,9 +52,21 @@
 												<table class='stage-object'>
 													<tr>
 														<td><input type='button' id='ps_$programStageInstance.id' name='programStageBtn' programStageInstanceId='$programStageInstance.id' programStageId='$programStageInstance.programStage.id' status="$statusMap.get( $programStageInstance.id )" class='stage-object' value='$programStageInstance.programStage.name $format.formatDate( $programStageInstance.dueDate )' onclick='javascript:getOutboundSmsList( $programStageInstance.id, false );'></td>
-														<script>	
+														<script>
 															var status = $statusMap.get( $programStageInstance.id ); 
+															var programStageId = '$programStageInstance.programStage.id';
+															var dueDate = '$programStageInstance.dueDate';
+															var flag = "$flag"
 															setEventColorStatus( 'ps_' + $programStageInstance.id ,status);
+														
+															if( status == getFieldValue('statusEvent') 
+																&& programStageId == getFieldValue('programStageAddPatient')
+																&& dueDate >= getFieldValue('startDueDate') && dueDate <= getFieldValue('endDueDate') 
+																&& flag == "false")
+															{
+																jQuery("#ps_$programStageInstance.id").addClass("stage-object-selected");
+																#set( $flag = "true" )
+															}
 														</script>
 													</tr>
 													<tr>
@@ -93,11 +106,11 @@
 #end
 
 <script>
-	#if($!listAll)
+	/* #if($!listAll)
 	#else
 		var programId = jQuery("#programIdAddPatient").val();
 		var programStageId = jQuery("#programStageAddPatient").val();
 		var status = jQuery('#programStageAddPatientTR [id=statusEvent]').val();
 		jQuery("#patientList [programStageId=" + programStageId + "][status=" + status + "]" ).addClass("stage-object-selected");
-	#end
+	#end */
 </script>