dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29484
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14905: Apply web-api for Lost to follow up function, displayed the attribute-values of TEIs in the resul...
------------------------------------------------------------
revno: 14905
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-04-19 02:17:51 +0800
message:
Apply web-api for Lost to follow up function, displayed the attribute-values of TEIs in the result list.
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.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/javascript/smsReminder.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/trackedEntityInstance.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTrackedEntityInstanceCriteria.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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2014-04-18 10:14:28 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2014-04-18 18:17:51 +0000
@@ -62,7 +62,7 @@
implements EventStore
{
private static final Log log = LogFactory.getLog( JdbcEventStore.class );
-
+
@Autowired
private JdbcTemplate jdbcTemplate;
@@ -72,8 +72,9 @@
private static final ObjectMapper objectMapper = new ObjectMapper();
@Override
- public List<Event> getAll( Program program, ProgramStage programStage, ProgramStatus programStatus, Boolean followUp,
- List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance, Date startDate, Date endDate, EventStatus status )
+ public List<Event> getAll( Program program, ProgramStage programStage, ProgramStatus programStatus,
+ Boolean followUp, List<OrganisationUnit> organisationUnits, TrackedEntityInstance trackedEntityInstance,
+ Date startDate, Date endDate, EventStatus status )
{
List<Event> events = new ArrayList<Event>();
@@ -81,7 +82,8 @@
if ( trackedEntityInstance != null )
{
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( trackedEntityInstance.getTrackedEntityInstance() );
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = entityInstanceService
+ .getTrackedEntityInstance( trackedEntityInstance.getTrackedEntityInstance() );
if ( entityInstance != null )
{
@@ -93,7 +95,7 @@
trackedEntityInstanceId, startDate, endDate, status );
SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
-
+
log.info( "Event query SQL: " + sql );
Event event = new Event();
@@ -117,7 +119,14 @@
event.setProgramStage( rowSet.getString( "ps_uid" ) );
event.setStoredBy( rowSet.getString( "psi_completeduser" ) );
event.setOrgUnit( rowSet.getString( "ou_uid" ) );
- event.setEventDate( rowSet.getString( "psi_executiondate" ) );
+ if ( rowSet.getString( "psi_executiondate" ) != null )
+ {
+ event.setEventDate( rowSet.getString( "psi_executiondate" ) );
+ }
+ else
+ {
+ event.setEventDate( rowSet.getString( "psi_duedate" ) );
+ }
if ( rowSet.getBoolean( "ps_capturecoordinates" ) )
{
@@ -127,7 +136,7 @@
if ( !StringUtils.isEmpty( psi_longitude ) && !StringUtils.isEmpty( psi_latitude ) )
{
Coordinate coordinate = new Coordinate( psi_longitude, psi_latitude );
-
+
try
{
List<Double> list = objectMapper.readValue( coordinate.getCoordinateString(),
@@ -169,20 +178,30 @@
return events;
}
- private String buildSql( Program program, ProgramStage programStage, ProgramStatus programStatus, Boolean followUp, List<Integer> orgUnitIds,
- Integer trackedEntityInstanceId, Date startDate, Date endDate, EventStatus status )
+ private String buildSql( Program program, ProgramStage programStage, ProgramStatus programStatus, Boolean followUp,
+ List<Integer> orgUnitIds, Integer trackedEntityInstanceId, Date startDate, Date endDate, EventStatus status )
{
SqlHelper hlp = new SqlHelper();
-
+
String sql = "select p.uid as p_uid, ps.uid as ps_uid, ps.capturecoordinates as ps_capturecoordinates, pa.uid as pa_uid, psi.uid as psi_uid, psi.status as psi_status, ou.uid as ou_uid, "
- + "psi.executiondate as psi_executiondate, psi.completeduser as psi_completeduser, psi.longitude as psi_longitude, psi.latitude as psi_latitude,"
+ + "psi.executiondate as psi_executiondate, psi.duedate as psi_duedate, psi.completeduser as psi_completeduser, psi.longitude as psi_longitude, psi.latitude as psi_latitude,"
+ " pdv.value as pdv_value, pdv.storedby as pdv_storedby, pdv.providedelsewhere as pdv_providedelsewhere, de.uid as de_uid"
+ " from program p"
+ " left join programstage ps on ps.programid=p.programid"
+ " left join programstageinstance psi on ps.programstageid=psi.programstageid"
- + " left join programinstance pi on pi.programinstanceid=psi.programinstanceid"
- + " left join organisationunit ou on (psi.organisationunitid=ou.organisationunitid)"
- + " left join trackedentitydatavalue pdv on psi.programstageinstanceid=pdv.programstageinstanceid"
+ + " left join programinstance pi on pi.programinstanceid=psi.programinstanceid";
+
+ if ( status == EventStatus.VISITED || status == EventStatus.COMPLETED )
+ {
+ sql += " left join organisationunit ou on (psi.organisationunitid=ou.organisationunitid) ";
+ }
+ else
+ {
+ sql += " left join trackedentityinstance tei on tei.trackedentityinstanceid=pi.trackedentityinstanceid "
+ + " left join organisationunit ou on (tei.organisationunitid=ou.organisationunitid) ";
+ }
+
+ sql += " left join trackedentitydatavalue pdv on psi.programstageinstanceid=pdv.programstageinstanceid"
+ " left join dataelement de on pdv.dataelementid=de.dataelementid "
+ " left join trackedentityinstance pa on pa.trackedentityinstanceid=pi.trackedentityinstanceid ";
@@ -200,15 +219,15 @@
{
sql += hlp.whereAnd() + " ps.programstageid = " + programStage.getId() + " ";
}
-
+
if ( programStatus != null )
{
sql += hlp.whereAnd() + " pi.status = " + programStatus.getValue() + " ";
}
-
+
if ( followUp != null )
{
- sql += hlp.whereAnd() + " pi.followup is " + ( followUp ? "true" : "false" ) + " ";
+ sql += hlp.whereAnd() + " pi.followup is " + (followUp ? "true" : "false") + " ";
}
if ( orgUnitIds != null && !orgUnitIds.isEmpty() )
@@ -225,7 +244,7 @@
{
sql += hlp.whereAnd() + " psi.executiondate <= '" + getMediumDateString( endDate ) + "' ";
}
-
+
if ( status != null )
{
sql += hlp.whereAnd() + " psi.status = " + status.getValue() + " ";
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-04-18 14:01:25 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-04-18 18:17:51 +0000
@@ -318,7 +318,7 @@
if ( params.hasProgramStatus() )
{
- sql += "and pi.status = " + PROGRAM_STATUS_MAP.get( params.getProgramStatus() + " " );
+ sql += "and pi.status = " + PROGRAM_STATUS_MAP.get( params.getProgramStatus() ) + " ";
}
if ( params.hasFollowUp() )
=== 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 2014-04-17 16:00:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2014-04-18 18:17:51 +0000
@@ -141,14 +141,18 @@
}
if( getFieldValue('startDate') != ''){
- params += "&startDate=" + getFieldValue('startDate');
- params += "&endDate=" + getFieldValue('endDate');
+ params += "&eventStartDate=" + getFieldValue('startDate');
+ params += "&eventEndDate=" + getFieldValue('endDate');
}
if( getFieldValue('status')!= '' ){
params += "&status=" + getFieldValue('status');
}
+ if( $('#followup').attr('checked')=='checked'){
+ params += "followUp=true";
+ }
+
var flag = false;
$('#advancedSearchTB tr').each(
function(i, row) {
@@ -372,12 +376,17 @@
});
clearListById('searchObjectId');
-
+ clearListById('attributeIds');
for ( var i in json.attributes) {
jQuery('#searchObjectId').append(
'<option value="' + json.attributes[i].id
+ '" displayed="' + json.attributes[i].displayed + '">'
+ json.attributes[i].name + '</option>');
+
+ if(json.attributes[i].displayed=='true'){
+ jQuery('#attributeIds').append(
+ '<option value="' + json.attributes[i].id + '"></option>');
+ }
}
if (getFieldValue('program') != '') {
=== 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 2014-04-16 13:07:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2014-04-18 18:17:51 +0000
@@ -65,15 +65,27 @@
$('#contentDataRecord').html('');
hideById('advanced-search');
- var params = "orgUnit=" + getFieldValue("orgunitId");
+ var params = "ou=" + getFieldValue("orgunitId");
params += "&ouMode=SELECTED";
params += "&program=" + getFieldValue('program');
+ params += "&programStatus=ACTIVE";
+ params += "&page=" + page;
+
if( $('#followup').attr('checked')=='checked'){
params += "followUp=true";
}
+
+ params += '&eventStatus=' + getFieldValue('status');
+ params += "&eventStartDate=1900-01-01";
+ params += "&eventEndDate=3000-01-01";
+
+ $('#attributeIds option').each(function(i, item){
+ params += "&attribute=" + item.value;
+ });
+
$.ajax({
type : "GET",
- url : "../api/events.json",
+ url : "../api/trackedEntityInstances.json",
data : params,
dataType : "json",
success : function(json) {
@@ -90,14 +102,86 @@
var table = "";
// Header
- if (json.pager.total > 0) {
- table += "<p>" + i18n_total_result + " : " + json.pager.total
+ if (json.metaData.pager.total > 0) {
+ table += "<p>" + i18n_total_result + " : " + json.metaData.pager.total
+ "</p>";
} else {
table += "<p>" + i18n_no_result_found + "</p>";
}
- if( json.pager.total > 0 ){
+ // TEI list
+ table += "<table class='listTable' width='100%'>";
+
+ var idx = 4;
+ if(getFieldValue('ouMode') != 'SELECTED'){
+ var idx = 3;
+ }
+ else if(getFieldValue('program') != '') {
+ idx = 5;
+ }
+ table += "<col width='30' />";
+ for (var i = idx; i < json.width; i++) {
+ table += "<col />";
+ }
+ table += "<col width='200' />";
+ table += "<thead><tr><th>#</th>";
+ for (var i = idx; i < json.width; i++) {
+ table += "<th>" + json.headers[i].column + "</th>";
+ }
+ table += "<th>" + i18n_operations + "</th>";
+ table += "</tr></thead>";
+
+ table += "<tbody id='list'>";
+ for ( var i in json.rows) {
+ var cols = json.rows[i];
+ var uid = cols[0];
+ var no = eval(json.metaData.pager.page);
+ no = (no - 1) * 50 + eval(i) + 1;
+ table += "<tr id='tr" + uid + "'>";
+ table += "<td>" + no + "</td>";
+ for (var j = idx; j < json.width; j++) {
+ var colVal = cols[j];
+ if (j == 4) {
+ colVal = json.metaData.names[colVal];
+ }
+ table += "<td onclick=\"javascript:isDashboard=true;showTrackedEntityInstanceDashboardForm( '"
+ + uid
+ + "' )\" title='"
+ + i18n_dashboard
+ + "'>" + colVal + "</td>";
+ }
+
+ // Operations column
+ table += "<td>";
+ table += "<a href=\"javascript:isDashboard=false;showEvents(" + isAdvancedSearch + ", '"
+ + uid
+ + "' )\" title='"
+ + i18n_events
+ + "'><img src='../images/edit_sections.png' alt='"
+ + i18n_events
+ + "'></a>";
+ table += "<a href=\"javascript:isDashboard=false;showTrackedEntityInstanceDashboardForm( '"
+ + uid
+ + "' )\" title='"
+ + i18n_dashboard
+ + "'><img src='../images/enroll.png' alt='"
+ + i18n_dashboard
+ + "'></a>";
+ table += "<a href=\"javascript:programTrackingList( '" + uid + "', false ) \" "
+ + " title='"
+ + i18n_edit
+ + "'><img src= '../images/edit.png' alt='"
+ + i18n_edit
+ + "'></a>";
+ table += "</td>";
+ table += "</tr>";
+ }
+ table += "</tbody>";
+ table += "</table>";
+
+ return table + paging(json, page);
+
+ if( json.metaData.pager.total > 0 ){
// Event list
table += "<table class='listTable' width='100%'>";
@@ -117,8 +201,8 @@
var row = json.events[i];
var uid = row.event;
var teiUid = row.trackedEntityInstance;
- var no = eval(json.pager.page);
- no = (no - 1) * json.pager.pageSize + eval(i) + 1;
+ var no = eval(json.metaData.pager.page);
+ no = (no - 1) * json.metaData.pager.pageSize + eval(i) + 1;
table += "<tr id='tr" + uid + "'>";
table += "<td>" + no + "</td>";// No.
table += "<td>" + row.eventDate + "</td>";// Event-date
@@ -138,23 +222,7 @@
table += "</td>";
}
- // Operations column
- table += "<td>";
- table += "<a href=\"javascript:isDashboard=false;showTrackedEntityInstanceDashboardForm( '"
- + teiUid
- + "' )\" title='"
- + i18n_dashboard
- + "'><img src='../images/enroll.png' alt='"
- + i18n_dashboard
- + "'></a>";
- table += "<a href=\"javascript:programTrackingList( '" + uid + "', false ) \" "
- + " title='"
- + i18n_edit
- + "'><img src= '../images/edit.png' alt='"
- + i18n_edit
- + "'></a>";
- table += "</td>";
- table += "</tr>";
+
}
table += "</tbody>";
table += "</table>";
@@ -172,12 +240,12 @@
searchMethod = "validateAdvancedSearch";
}
- var table = "<table width='100%' style='background-color: #ebf0f6;'><tr><td rowpan='"
+ var table = "<table width='100%' style='background-color: #ebf0f6;'><tr><td colspan='"
+ json.width + "'>";
table += "<div class='paging'>";
table += "<span class='first' title='" + i18n_first + "'>««</span>";
table += "<span class='prev' title='" + i18n_prev + "'>«</span>";
- for (var i = 1; i <= json.pager.pageCount; i++) {
+ for (var i = 1; i <= json.metaData.pager.pageCount; i++) {
if (i == page) {
table += "<span class='page' title='" + i18n_page + " " + i + "'>"
+ i + "</span>";
@@ -195,6 +263,48 @@
return table;
}
+function showEvents( isAdvancedSearch, teiUid){
+ var params = "orgUnit=" + getFieldValue("orgunitId");
+ params += "&program=" + getFieldValue('program');
+ params += "&trackedEntityInstance=" + teiUid;
+ params += '&eventStatus=' + getFieldValue('status');
+ if( isAdvancedSearch ){ // advanced-search
+ params += "&eventStartDate=" + getFieldValue('startDate');
+ params += "&eventEndDate=" + getFieldValue('endDate');
+ }
+ else // list
+ {
+ params += "&eventStartDate=1900-01-01";
+ params += "&eventEndDate=3000-01-01";
+ }
+
+ $.ajax({
+ type : "GET",
+ url : "../api/events.json",
+ data : params,
+ dataType : "json",
+ success : function(json) {
+ var table = "<table>"
+ for ( var i in json.events) {
+ var row = json.events[i];
+ var uid = row.event;
+ var eventDate = row.eventDate;
+ table += "<tr><td><a href='javascript:programTrackingList( \"" + uid + "\") ' >" + eventDate + "</a></td></tr>";
+ }
+ table += "</table>";
+ $('#eventList').html(table);
+ $('#eventList').dialog({
+ title : i18n_events,
+ maximize : true,
+ closable : true,
+ modal : false,
+ width : 380,
+ height : 290
+ }).show('fast');
+ }
+ });
+}
+
// --------------------------------------------------------------------
// Search events
// --------------------------------------------------------------------
@@ -208,7 +318,6 @@
$('#listEventDiv').html('');
hideById('listEventDiv');
showLoader();
- params += "&orgUnit=" + getFieldValue("orgunitId");
$.ajax({
url : '../api/events.json',
type : "GET",
@@ -235,6 +344,7 @@
function programTrackingList( programStageInstanceId, isSendSMS )
{
+ $('#eventList').dialog('close');
hideById('listEventDiv');
hideById('searchDiv');
showLoader();
@@ -381,12 +491,13 @@
hideById('smsManagementDiv');
hideById('entityInstanceDashboard');
- if( events == 1){
- listAllTrackedEntityInstance();
- }
- else if( events == 2){
- validateAdvancedSearch();
- }
+ if( isAdvancedSearch ){
+ validateAdvancedSearch(1);
+ }
+ else{
+ listAllTrackedEntityInstance(1);
+ }
+
}
// load program instance history
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/trackedEntityInstance.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/trackedEntityInstance.js 2014-04-13 14:11:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/trackedEntityInstance.js 2014-04-18 18:17:51 +0000
@@ -220,10 +220,13 @@
contentDiv = 'listEntityInstanceDiv';
var params = "page=" + page;
if (getFieldValue('program') != '') {
- params += "&program="
- + getFieldValue('program');
+ params += "&program=" + getFieldValue('program');
}
-
+
+ $('#attributeIds option').each(function(i, item){
+ params += "&attribute=" + item.value;
+ });
+
$.ajax({
type : "GET",
url : "../api/trackedEntityInstances.json?ou="
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm 2014-04-17 16:00:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm 2014-04-18 18:17:51 +0000
@@ -48,6 +48,7 @@
<div id='listEventDiv'></div>
<div id='entityInstanceDashboard'></div> <!-- TrackedEntityInstance dashboard -->
+<div id='eventList'></div>
<div id='smsManagementDiv'></div>
<div id='sendSmsFormDiv'></div>
<div id='editEntityInstanceDiv'></div> <!-- Add TrackedEntityInstance Form -->
@@ -177,6 +178,7 @@
var i18n_no_result_found = '$encoder.jsEscape( $i18n.getString( "no_result_found" ) , "'")';
var i18n_data_values = '$encoder.jsEscape( $i18n.getString( "data_values" ) , "'")';
var i18n_complete_program_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_program_confirm_message" ) , "'")';
+ var i18n_events = '$encoder.jsEscape( $i18n.getString( "events" ) , "'")';
var checkedDuplicate = false;
var registration = false;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTrackedEntityInstanceCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTrackedEntityInstanceCriteria.vm 2014-04-13 14:11:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTrackedEntityInstanceCriteria.vm 2014-04-18 18:17:51 +0000
@@ -2,6 +2,7 @@
<input type='hidden' id='orgunitId' name='orgunitId' value='$organisationUnit.uid' >
<input type="hidden" id='hideLink' name='hideLink' value='false'>
<input type='hidden' id='isSearchByProgram' name='isSearchByProgram' value='false' >
+ <select id='attributeIds' name='attributeIds' class='hidden'></select>
<table style="margin-bottom:8px" id="commonSearchDiv" name="commonSearchDiv">
<tr>
@@ -47,9 +48,8 @@
<td>$i18n.getString('status')</td>
<td>
<select id="status" name="status">
- <option value=''>$i18n.getString("all")</option>
+ <option value='ACTIVE'>$i18n.getString("all")</option>
<option value='LATE_VISIT'>$i18n.getString("overdue")</option>
- <option value='ACTIVE'>$i18n.getString("active")</option>
<option value='VISITED'>$i18n.getString("incomplete")</option>
<option value='COMPLETED'>$i18n.getString("completed")</option>
<option value='FUTURE_VISIT'>$i18n.getString("scheduled_in_future")</option>