dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18999
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8115: Improve Tracking program (WIP).
------------------------------------------------------------
revno: 8115
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-09-18 08:55:04 +0700
message:
Improve Tracking program (WIP).
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/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.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-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-09-13 07:24:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2012-09-18 01:55:04 +0000
@@ -341,6 +341,7 @@
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 ";
+ String orderBy = "";
boolean hasIdentifier = false;
boolean isSearchEvent = false;
@@ -403,46 +404,62 @@
}
else if ( keys[0].equals( Patient.PREFIX_PROGRAM_EVENT_BY_STATUS ) )
{
- sql += "pgi.programid as programid,";
patientGroupBy += ",pgi.programid ";
-
- sql += " MIN( psi.programstageinstanceid ) as programstageinstanceid,";
isSearchEvent = true;
patientWhere += patientOperator + "pgi.patientid=p.patientid and ";
patientWhere += "programid=" + id + " and ";
- patientWhere += "psi.duedate>='" + keys[3] + "' and psi.duedate<='" + keys[4] + "' and ";
+ patientWhere += "psi.duedate>='" + keys[2] + "' and psi.duedate<='" + keys[3] + "' and ";
patientWhere += "pgi.completed = false ";
- if ( keys.length == 6 )
- {
- patientWhere += " and psi.organisationunitid = " + keys[5];
- }
-
- int statusEvent = Integer.parseInt( keys[2] );
- switch ( statusEvent )
- {
- case ProgramStageInstance.COMPLETED_STATUS:
- patientWhere += " and psi.completed=true";
- break;
- case ProgramStageInstance.VISITED_STATUS:
- patientWhere += " and psi.executiondate is not null and psi.completed=false";
- break;
- case ProgramStageInstance.FUTURE_VISIT_STATUS:
- patientWhere += " and psi.executiondate is null and psi.duedate >= now()";
- break;
- case ProgramStageInstance.LATE_VISIT_STATUS:
- patientWhere += " and psi.executiondate is null and psi.duedate < now()";
- break;
- default:
- break;
- }
-
+
+ String operatorStatus = "";
+ String condition = " and ( ";
+
+ for ( int index = 5; index < keys.length; index++ )
+ {
+ int statusEvent = Integer.parseInt( keys[index] );
+ switch ( statusEvent )
+ {
+ case ProgramStageInstance.COMPLETED_STATUS:
+ patientWhere += condition + operatorStatus + "("
+ + " psi.completed=true and psi.organisationunitid=" + keys[4] + ")";
+ condition = "";
+ operatorStatus = " OR ";
+ continue;
+ case ProgramStageInstance.VISITED_STATUS:
+ patientWhere += condition + operatorStatus + "("
+ + " psi.executiondate is not null and psi.completed=false and psi.organisationunitid="
+ + keys[4] + ")";
+ operatorStatus = " OR ";
+ condition = "";
+ continue;
+ case ProgramStageInstance.FUTURE_VISIT_STATUS:
+ patientWhere += condition + operatorStatus + "("
+ + " psi.executiondate is null and psi.duedate >= now() and p.organisationunitid=" + keys[4]
+ + ")";
+ operatorStatus = " OR ";
+ condition = "";
+ continue;
+ case ProgramStageInstance.LATE_VISIT_STATUS:
+ patientWhere += condition + operatorStatus + "("
+ + " psi.executiondate is null and psi.duedate < now() and p.organisationunitid=" + keys[4]
+ + ")";
+ operatorStatus = " OR ";
+ condition = "";
+ continue;
+ default:
+ continue;
+ }
+ }
+ if ( condition.isEmpty() )
+ {
+ patientWhere += ")";
+ }
patientWhere += " and pgi.completed=false ";
patientOperator = " and ";
}
else if ( keys[0].equals( Patient.PREFIX_PROGRAM_STAGE ) )
{
- 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[4] + "' and ";
@@ -481,15 +498,18 @@
sql = sql.substring( 0, sql.length() - 1 ) + " "; // Removing last comma
- sql += " from patient p ";
+ String from = " from patient p ";
+ if ( isSearchEvent )
+ {
+ String subSQL = " ,MIN( psi.programstageinstanceid ) as programstageinstanceid,min(psi.duedate) as duedate ";
+ sql = sql + subSQL + from + " left join programinstance pgi on " + " (pgi.patientid=p.patientid) "
+ + " left join programstageinstance psi on " + " (psi.programinstanceid=pgi.programinstanceid) ";
+ orderBy = " ORDER BY duedate DESC ";
+ }
+
if ( hasIdentifier )
{
- 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 += from + " left join patientidentifier pi on p.patientid=pi.patientid ";
}
sql += patientWhere;
@@ -497,7 +517,7 @@
{
sql += patientGroupBy;
}
-
+ sql += orderBy;
sql += " ) as searchresult";
sql += otherWhere;
@@ -505,7 +525,7 @@
{
sql += statementBuilder.limitRecord( min, max );
}
-
+ System.out.println( "\n\n === \n " + sql );
return sql;
}
=== 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-09-15 04:18:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-09-18 01:55:04 +0000
@@ -450,4 +450,6 @@
three_days = 3 days
one_week = 1 week
one_month = 1 month
-remove_this_event = Remove this event
\ No newline at end of file
+remove_this_event = Remove this event
+overdue_scheduled = Overdue/Scheduled
+scheduled_overdue_incomplete = Scheduled/Overdue/Incomplete
\ No newline at end of file
=== 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-15 04:18:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2012-09-18 01:55:04 +0000
@@ -37,7 +37,9 @@
var endDate = jQuery.datepicker.formatDate( dateFormat, new Date(y2, m, d) );
var programId = getFieldValue('programIdAddPatient');
- var searchTexts = "stat_" + programId + "_4_" + startDate + "_" + endDate;
+ var searchTexts = "stat_" + programId + "_"
+ + startDate + "_" + endDate + "_"
+ + getFieldValue('orgunitId') + "_4";
showLoader();
jQuery('#listPatientDiv').load('getSMSPatientRecords.action',