dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18727
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7919: Add function to search patients with completed/incompleted/scheduled/overdue events for SMS reminder
------------------------------------------------------------
revno: 7919
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-08-16 13:20:33 +0700
message:
Add function to search patients with completed/incompleted/scheduled/overdue events for SMS reminder
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java
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/patient/SearchPatientAction.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/javascript/smsReminder.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/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-api/src/main/java/org/hisp/dhis/patient/Patient.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2012-07-13 02:46:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2012-08-16 06:20:33 +0000
@@ -63,6 +63,7 @@
public static String PREFIX_FIXED_ATTRIBUTE = "fixedAttr";
public static String PREFIX_PATIENT_ATTRIBUTE = "attr";
public static String PREFIX_PROGRAM = "prg";
+ public static String PREFIX_PROGRAM_STAGE = "prgst";
public static String FIXED_ATTR_BIRTH_DATE = "birthDate";
public static String FIXED_ATTR_AGE = "age";
=== 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-02 10:32:32 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2012-08-16 06:20:33 +0000
@@ -48,6 +48,7 @@
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientStore;
import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramStageInstance;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.transaction.annotation.Transactional;
@@ -317,17 +318,17 @@
}
else if ( keys[0].equals( Patient.PREFIX_IDENTIFIER_TYPE ) )
{
- patientWhere = patientOperator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%" + id
- + "%' ) or lower(pi.identifier)='" + id + "' ";
-
+ patientWhere += patientOperator + "( ( lower( " + statementBuilder.getPatientFullName() + " ) like '%"
+ + id + "%' ) or lower(pi.identifier)='" + id + "' ";
+
String[] keyValues = id.split( " " );
- if( keyValues.length==2)
+ if ( keyValues.length == 2 )
{
- String otherId = keyValues[0] + " " + keyValues[1];
+ String otherId = keyValues[0] + " " + keyValues[1];
patientWhere += " or lower( " + statementBuilder.getPatientFullName() + " ) like '%" + otherId
+ "%' ";
}
- patientWhere += ")";
+ patientWhere += ")";
patientOperator = " and ";
hasIdentifier = true;
}
@@ -335,33 +336,64 @@
{
sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
+ id + " ) as " + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ",";
- otherWhere = operator + "lower(" + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ")='" + value + "'";
+ otherWhere += operator + "lower(" + Patient.PREFIX_PATIENT_ATTRIBUTE + "_" + id + ")='" + value + "'";
operator = " and ";
}
else if ( keys[0].equals( Patient.PREFIX_PROGRAM ) )
{
sql += "(select programid from patient_programs where patientid=p.patientid and programid=" + keys[1]
+ " ) as " + Patient.PREFIX_PROGRAM + "_" + id + ",";
- otherWhere = operator + Patient.PREFIX_PROGRAM + "_" + id + "=" + id;
+ otherWhere += operator + Patient.PREFIX_PROGRAM + "_" + id + "=" + id;
+ operator = " and ";
+ }
+ else if ( keys[0].equals( Patient.PREFIX_PROGRAM_STAGE ) )
+ {
+ sql += "(select COUNT(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 ";
+
+ int statusEvent = Integer.parseInt( keys[2] );
+ switch ( statusEvent )
+ {
+ case ProgramStageInstance.COMPLETED_STATUS:
+ sql += "psi.completed=true";
+ break;
+ case ProgramStageInstance.VISITED_STATUS:
+ sql += "psi.executiondate is not null";
+ break;
+ case ProgramStageInstance.FUTURE_VISIT_STATUS:
+ sql += "psi.executiondate is null and psi.duedate >= now()";
+ break;
+ case ProgramStageInstance.LATE_VISIT_STATUS:
+ sql += "psi.executiondate is null and psi.duedate < now()";
+ break;
+ default:
+ break;
+ }
+
+ sql += " ) as " + Patient.PREFIX_PROGRAM_STAGE + "_" + id + ",";
+
+ otherWhere += operator + Patient.PREFIX_PROGRAM_STAGE + "_" + id + ">0";
operator = " and ";
}
}
if ( orgunit != null )
{
- sql += "(select organisationunitid from patient where patientid=p.patientid and organisationunitid = " + orgunit.getId() + " ) as orgunitid,";
+ sql += "(select organisationunitid from patient where patientid=p.patientid and organisationunitid = "
+ + orgunit.getId() + " ) as orgunitid,";
otherWhere += operator + "orgunitid=" + orgunit.getId();
}
-
+
sql = sql.substring( 0, sql.length() - 1 ) + " "; // Removing last comma
-
+
sql += " from patient p ";
if ( hasIdentifier )
{
sql += " left join patientidentifier pi on p.patientid=pi.patientid ";
}
- sql += patientWhere ;
+ sql += patientWhere;
sql += " ) as searchresult";
sql += otherWhere;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java 2012-07-26 08:53:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchPatientAction.java 2012-08-16 06:20:33 +0000
@@ -63,7 +63,7 @@
private Boolean searchBySelectedOrgunit;
private boolean listAll;
-
+
private Collection<Patient> patients = new ArrayList<Patient>();
// -------------------------------------------------------------------------
=== 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-15 02:57:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-08-16 06:20:33 +0000
@@ -408,4 +408,6 @@
completed_programs = Completed programs
active_programs = Active programs
completed = Completed
-create_event_success = Create event successfully.
\ No newline at end of file
+create_event_success = Create event successfully.
+overdue = Overdue
+scheduled_in_future = Scheduled in future
\ 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-16 02:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-08-16 06:20:33 +0000
@@ -221,6 +221,13 @@
}
})
});
+
+ if( getFieldValue('searchByProgramStage') == "true"){
+ var programStageId = jQuery('#programStageAddPatientTR [id=programStageAddPatient_' + getFieldValue('programIdAddPatient') + ']').val();
+ var statusEvent = jQuery('#programStageAddPatientTR [id=statusEvent]:checked').val();
+ params += '&searchTexts=prgst_' + programStageId + '_' + statusEvent;
+ }
+
params += '&listAll=false';
params += '&searchBySelectedOrgunit=' + byId('searchBySelectedOrgunit').checked;
@@ -412,6 +419,9 @@
function enableBtn(){
var programIdAddPatient = getFieldValue('programIdAddPatient');
+ jQuery('#programStageAddPatientTR [name=programStageAddPatient]').addClass("hidden");
+ jQuery('#programStageAddPatientTR [id=programStageAddPatient_' + programIdAddPatient + ']').removeClass("hidden");
+
if( programIdAddPatient!='' ){
enable('listPatientBtn');
enable('addPatientBtn');
@@ -419,6 +429,7 @@
jQuery('#advanced-search :input').each( function( idx, item ){
enable(this.id);
});
+ jQuery('#programStageAddPatientTR [name=statusEvent]').attr("disabled", true);
}
else
{
@@ -431,6 +442,17 @@
}
}
+function enableRadioButton( programId )
+{
+ var prorgamStageId = jQuery('#programStageAddPatientTR [id=programStageAddPatient_' + programId + ']').val();
+ if( prorgamStageId== ''){
+ jQuery('#programStageAddPatientTR [name=statusEvent]').attr("disabled", true);
+ }
+ else{
+ jQuery('#programStageAddPatientTR [name=statusEvent]').removeAttr("disabled");
+ }
+}
+
function showColorHelp()
{
jQuery('#colorHelpDiv').dialog({
=== 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-08-09 14:21:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2012-08-16 06:20:33 +0000
@@ -103,8 +103,6 @@
} );
}
-
-
function loadProgramStageRecords( programStageInstanceId )
{
setInnerHTML('dataEntryFormDiv', '');
=== 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-07 05:43:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2012-08-16 06:20:33 +0000
@@ -1,3 +1,4 @@
+<input type='hidden' id='searchByProgramStage' name='searchByProgramStage' value="false">
<table style="margin-bottom:8px">
<tr>
<td>
@@ -12,7 +13,7 @@
<input type="button" id='advancedSearchBtn' value='$i18n.getString( "advanced_search" )' onclick="jQuery('#advanced-search').toggle();" #if( $organisationUnit ) #else disabled #end>
</td>
</tr>
- <tr id='programAddPatientTR'class='hidden'>
+ <tr id='programAddPatientTR' class='hidden'>
<td>$i18n.getString('program')</td>
<td>
<select id='programIdAddPatient' name='programIdAddPatient' onchange='enableBtn();'>
@@ -27,6 +28,29 @@
<div id='advanced-search' class='hidden'>
<table id='advancedSearchTB'>
+ <thead>
+ <tr id='programStageAddPatientTR' class='hidden'>
+ <td>
+ <select id='programStageAddPatient_' name='programStageAddPatient' disabled>
+ <option value=''>[$i18n.getString("please_select_program_stage")]</option>
+ </select>
+ #foreach($program in $programs)
+ <select id='programStageAddPatient_$program.id' name='programStageAddPatient' onchange='enableRadioButton($program.id);' class='hidden'>
+ <option value=''>[$i18n.getString("please_select_program_stage")]</option>
+ #foreach($programStage in $program.programStages)
+ <option value="$programStage.id">$programStage.name</option>
+ #end
+ </select>
+ #end
+ </td>
+ <td>
+ <input type="radio" disabled id="statusEvent" name="statusEvent" value='1'> $i18n.getString("completed")
+ <input type="radio" disabled id="statusEvent" name="statusEvent" value='2'> $i18n.getString("incomplete")
+ <input type="radio" disabled id="statusEvent" name="statusEvent" value='3'> $i18n.getString("scheduled_in_future")
+ <input type="radio" disabled id="statusEvent" name="statusEvent" value='4'> $i18n.getString("overdue")
+ </td>
+ </tr>
+ </thead>
<tbody>
<tr id='advSearchBox0'>
<td id='searchingAttributeIdTD'>
=== 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-16 03:02:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/smsReminderSelect.vm 2012-08-16 06:20:33 +0000
@@ -1,6 +1,7 @@
<script>
jQuery(document).ready( function(){
showById('programAddPatientTR');
+ showById('programStageAddPatientTR');
jQuery("#programIdAddPatient option").each(function(){
var item = jQuery(this);
if( item.attr('type')!=1 && item.val()!='' ){
@@ -12,6 +13,7 @@
hideById('addPatientBtn');
disable('advancedSearchBtn');
hideById('searchBySelectedUnitTD');
+ setFieldValue('searchByProgramStage', 'true');
});
</script>
@@ -35,4 +37,7 @@
var i18n_sms_message_management = '$encoder.jsEscape( $i18n.getString( "sms_message_management" ) , "'")';
var i18n_send_sms = '$encoder.jsEscape( $i18n.getString( "send_sms" ) , "'")';
var i18n_please_select = '[' + '$encoder.jsEscape( $i18n.getString( "please_select" ) , "'")' + ']';
+ var i18n_specify_search_criteria = '$encoder.jsEscape( $i18n.getString( "specify_search_criteria" ) , "'")';
+ var i18n_color_quick_help = '$encoder.jsEscape( $i18n.getString( "color_quick_help" ) , "'")';
+ var searchTextBox = '<input type="text" id="searchText" name="searchText">';
</script>