dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18744
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7933: Add function to search events by due-date in SMS Reminder.
------------------------------------------------------------
revno: 7933
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-08-18 20:17:10 +0700
message:
Add function to search events by due-date 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/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
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.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-16 13:46:23 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2012-08-18 13:17:10 +0000
@@ -268,7 +268,6 @@
public Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max )
{
String sql = searchPatientSql( false, searchKeys, orgunit, min, max );
-
Collection<String> phoneNumbers = new HashSet<String>();
try
@@ -338,9 +337,11 @@
+ " from ( select distinct p.patientid, p.firstname, p.middlename, p.lastname, p.gender, p.phonenumber, p.birthdate, p.deathdate,";
String patientWhere = "";
String patientOperator = " where ";
+ String patientGroupBy = " GROUP BY p.patientid, p.firstname, p.middlename, p.lastname, p.gender, p.phonenumber, p.birthdate, p.deathdate ";
String otherWhere = "";
String operator = " where ";
boolean hasIdentifier = false;
+ boolean isSearchEvent = false;
for ( String searchKey : searchKeys )
{
@@ -401,32 +402,30 @@
}
else if ( keys[0].equals( Patient.PREFIX_PROGRAM_STAGE ) )
{
- sql += "(select psi.programstageinstanceid from programstageinstance psi ";
- sql += "left join programinstance pgi on (psi.programinstanceid=pgi.programinstanceid) ";
- sql += "where pgi.patientid=p.patientid and psi.programstageid=" + id + " and ";
-
+ 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 ";
+
int statusEvent = Integer.parseInt( keys[2] );
switch ( statusEvent )
{
case ProgramStageInstance.COMPLETED_STATUS:
- sql += "psi.completed=true";
+ patientWhere += "psi.completed=true";
break;
case ProgramStageInstance.VISITED_STATUS:
- sql += "psi.executiondate is not null";
+ patientWhere += "psi.executiondate is not null";
break;
case ProgramStageInstance.FUTURE_VISIT_STATUS:
- sql += "psi.executiondate is null and psi.duedate >= now()";
+ patientWhere += "psi.executiondate is null and psi.duedate >= now()";
break;
case ProgramStageInstance.LATE_VISIT_STATUS:
- sql += "psi.executiondate is null and psi.duedate < now()";
+ patientWhere += "psi.executiondate is null and psi.duedate < now()";
break;
default:
break;
}
-
- sql += " limit 1 ) as programstageinstanceid,";
- otherWhere += operator + " programstageinstanceid is not null";
- operator = " and ";
+ patientOperator = " and ";
}
}
@@ -444,8 +443,20 @@
{
sql += " left join patientidentifier pi on p.patientid=pi.patientid ";
}
+ if(isSearchEvent)
+ {
+ sql += " left join programinstance pgi on " +
+ " (pgi.patientid=p.patientid) " +
+ " left join programstageinstance psi on " +
+ " (psi.programinstanceid=pgi.programinstanceid) ";
+ }
sql += patientWhere;
+ if( isSearchEvent )
+ {
+ sql += patientGroupBy;
+ }
+
sql += " ) as searchresult";
sql += otherWhere;
@@ -453,7 +464,6 @@
{
sql += statementBuilder.limitRecord( min, max );
}
-
return sql;
}
=== 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-17 13:51:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-08-18 13:17:10 +0000
@@ -213,7 +213,9 @@
var programStageId = jQuery('#programStageAddPatient').val();
if( getFieldValue('searchByProgramStage') == "true" && programStageId!=''){
var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]').val();
- params += '&searchTexts=prgst_' + programStageId + '_' + statusEvent;
+ var startDueDate = getFieldValue('startDueDate');
+ var endDueDate = getFieldValue('endDueDate');
+ params += '&searchTexts=prgst_' + programStageId + '_' + statusEvent + '_' + startDueDate + '_' + endDueDate;
}
jQuery( '#advancedSearchTB tbody tr' ).each( function( i, row ){
=== 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-17 13:51:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2012-08-18 13:17:10 +0000
@@ -48,6 +48,10 @@
</select>
</td>
</tr>
+ <tr>
+ <td><input type='textbox' id='startDueDate' name='startDueDate'></td>
+ <td><input type='textbox' id='endDueDate' name='endDueDate'></td>
+ </tr>
</thead>
<tbody>
<tr id='advSearchBox0'>
@@ -80,7 +84,7 @@
<input type="button" class='large-button' value='$i18n.getString( "search" )' onclick='validateAdvancedSearch();' id='searchPatientBtn'>
</td>
<td>
- <input type="button" id='programStageActionBtn' value="$i18n.getString('send_sms_to_list')" onclick="showSendSmsForm();" class='hidden'>
+ <input type="button" id='sendSmsToListBtn' value="$i18n.getString('send_sms_to_list')" onclick="showSendSmsForm();" class='hidden'>
</td>
</tr>
</tbody>
@@ -94,4 +98,6 @@
var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
var searchTextBox = '<input type="text" id="searchText" name="searchText" onkeyup="searchPatientsOnKeyUp( event );">';
+ datePickerValid( 'startDueDate', true );
+ datePickerValid( 'endDueDate', true );
</script>
\ No newline at end of file
=== 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-17 09:17:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsPatientRecords.vm 2012-08-18 13:17:10 +0000
@@ -97,7 +97,7 @@
#else
var programId = jQuery("#programIdAddPatient").val();
var programStageId = jQuery("#programStageAddPatient").val();
- var status = jQuery('#programStageAddPatientTR [id=statusEvent]:checked').val();
+ var status = jQuery('#programStageAddPatientTR [id=statusEvent]').val();
jQuery("#patientList [programStageId=" + programStageId + "][status=" + status + "]" ).addClass("stage-object-selected");
#end
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm 2012-08-17 13:51:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm 2012-08-18 13:17:10 +0000
@@ -2,13 +2,14 @@
jQuery(document).ready( function(){
showById('programAddPatientTR');
showById('programStageAddPatientTR');
+ showById('sendSmsToListBtn');
jQuery("#programIdAddPatient option").each(function(){
var item = jQuery(this);
if( item.attr('type')!=1 && item.val()!='' ){
item.remove();
}
});
-
+
jQuery("#searchObjectId [value=prg]").remove();
hideById('addPatientBtn');
disable('advancedSearchBtn');