=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2012-08-17 06:42:32 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2012-09-07 07:57:47 +0000 @@ -27,6 +27,7 @@ package org.hisp.dhis.program; import java.io.Serializable; +import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Set; @@ -48,10 +49,17 @@ private static final long serialVersionUID = 6239130884678145713L; public static final int COMPLETED_STATUS = 1; + public static final int VISITED_STATUS = 2; + public static final int FUTURE_VISIT_STATUS = 3; + public static final int LATE_VISIT_STATUS = 4; + public static final int UNKNOWN_STATUS = 5; + + public static final int SKIPPED_STATUS = 6; + private int id; private ProgramInstance programInstance; @@ -65,11 +73,13 @@ private OrganisationUnit organisationUnit; private boolean completed = false; - + private List outboundSms; - + private Set comments; + private Integer status; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -122,7 +132,7 @@ result = result * prime + programStage.hashCode(); result = result * prime + dueDate.hashCode(); result = result * prime + ((executionDate == null) ? 0 : executionDate.hashCode()); - + return result; } @@ -255,4 +265,47 @@ { this.comments = comments; } + + public Integer getStatus() + { + return status; + } + + public void setStatus( Integer status ) + { + this.status = status; + } + + public Integer getEventStatus() + { + if ( this.isCompleted() ) + { + return ProgramStageInstance.COMPLETED_STATUS; + } + else if ( this.getExecutionDate() != null ) + { + return ProgramStageInstance.VISITED_STATUS; + } + else + { + // ------------------------------------------------------------- + // If a program stage is not provided even a day after its due + // date, then that service is alerted red - because we are + // getting late + // ------------------------------------------------------------- + + Calendar dueDateCalendar = Calendar.getInstance(); + dueDateCalendar.setTime( this.getDueDate() ); + dueDateCalendar.add( Calendar.DATE, 1 ); + + if ( dueDateCalendar.getTime().before( new Date() ) ) + { + return ProgramStageInstance.LATE_VISIT_STATUS; + } + else + { + return ProgramStageInstance.FUTURE_VISIT_STATUS; + } + } + } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-08-16 13:46:23 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-09-07 07:57:47 +0000 @@ -128,35 +128,7 @@ for ( ProgramStageInstance programStageInstance : programStageInstances ) { - if ( programStageInstance.isCompleted() ) - { - colorMap.put( programStageInstance.getId(), ProgramStageInstance.COMPLETED_STATUS ); - } - else if ( programStageInstance.getExecutionDate() != null ) - { - colorMap.put( programStageInstance.getId(), ProgramStageInstance.VISITED_STATUS ); - } - else - { - // ------------------------------------------------------------- - // If a program stage is not provided even a day after its due - // date, then that service is alerted red - because we are - // getting late - // ------------------------------------------------------------- - - Calendar dueDateCalendar = Calendar.getInstance(); - dueDateCalendar.setTime( programStageInstance.getDueDate() ); - dueDateCalendar.add( Calendar.DATE, 1 ); - - if ( dueDateCalendar.getTime().before( new Date() ) ) - { - colorMap.put( programStageInstance.getId(), ProgramStageInstance.LATE_VISIT_STATUS ); - } - else - { - colorMap.put( programStageInstance.getId(), ProgramStageInstance.FUTURE_VISIT_STATUS ); - } - } + colorMap.put( programStageInstance.getId(), programStageInstance.getEventStatus() ); } return colorMap; @@ -205,8 +177,8 @@ Map orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap(); - return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits, - columns, level, maxLevel, startDate, endDate, descOrder, min, max ); + return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits, columns, + level, maxLevel, startDate, endDate, descOrder, min, max ); } public int getTabularReportCount( ProgramStage programStage, List columns, @@ -289,12 +261,11 @@ public void removeEmptyEvents( ProgramStage programStage ) { - programStageInstanceStore.removeEmptyEvents(programStage); + programStageInstanceStore.removeEmptyEvents( programStage ); } @Override - public void updateProgramStageInstances( Collection programStageInstanceIds, - OutboundSms outboundSms ) + public void updateProgramStageInstances( Collection programStageInstanceIds, OutboundSms outboundSms ) { programStageInstanceStore.update( programStageInstanceIds, outboundSms ); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml 2012-08-21 13:51:07 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml 2012-09-07 07:57:47 +0000 @@ -36,5 +36,7 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java 2012-09-05 14:30:23 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java 2012-09-07 07:57:47 +0000 @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -38,11 +37,9 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientAttributeGroup; -import org.hisp.dhis.patient.PatientAttributeGroupService; import org.hisp.dhis.patient.PatientIdentifier; import org.hisp.dhis.patient.PatientIdentifierService; import org.hisp.dhis.patient.PatientIdentifierType; -import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; import org.hisp.dhis.program.Program; @@ -70,8 +67,6 @@ private PatientIdentifierService patientIdentifierService; - private PatientAttributeGroupService patientAttributeGroupService; - private PatientAttributeValueService patientAttributeValueService; private SelectedStateManager selectedStateManager; @@ -125,12 +120,7 @@ { return patientAttributeValueMap; } - - public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService ) - { - this.patientAttributeGroupService = patientAttributeGroupService; - } - + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) { this.patientAttributeValueService = patientAttributeValueService; === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SetEventStatusAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SetEventStatusAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SetEventStatusAction.java 2012-09-07 07:57:47 +0000 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2004-2009, 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.reminder; + +import java.util.Date; + +import org.hisp.dhis.program.ProgramStageInstance; +import org.hisp.dhis.program.ProgramStageInstanceService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version SetEventStatusAction.java 1:13:45 PM Sep 7, 2012 $ + */ +public class SetEventStatusAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + private ProgramStageInstanceService programStageInstanceService; + + public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) + { + this.programStageInstanceService = programStageInstanceService; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer programStageInstanceId; + + public void setProgramStageInstanceId( Integer programStageInstanceId ) + { + this.programStageInstanceId = programStageInstanceId; + } + + private Integer status; + + public void setStatus( Integer status ) + { + this.status = status; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + ProgramStageInstance programStageInstance = programStageInstanceService + .getProgramStageInstance( programStageInstanceId ); + + if ( ProgramStageInstance.COMPLETED_STATUS == status.intValue() ) + { + programStageInstance.setExecutionDate( new Date() ); + programStageInstance.setCompleted( true ); + programStageInstance.setStatus( null ); + } + else if ( ProgramStageInstance.VISITED_STATUS == status.intValue() ) + { + programStageInstance.setCompleted( false ); + programStageInstance.setStatus( null ); + } + else if ( ProgramStageInstance.UNKNOWN_STATUS == status.intValue() ) + { + programStageInstance.setStatus( null ); + } + else if ( ProgramStageInstance.SKIPPED_STATUS == status.intValue() ) + { + programStageInstance.setExecutionDate( new Date() ); + programStageInstance.setCompleted( true ); + programStageInstance.setStatus( status ); + } + + programStageInstanceService.updateProgramStageInstance( programStageInstance ); + + return SUCCESS; + } + +} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-09-06 09:44:43 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-09-07 07:57:47 +0000 @@ -627,8 +627,6 @@ - + + + + + plainTextError - + + + /content.vm + /dhis-web-caseentry/patientProgramTracking.vm + F_PATIENT_UPDATE + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseError.vm + F_PATIENT_UPDATE + + /dhis-web-caseentry/patientDashboard.vm style/style.css - + +#set($programStageInstances = $programInstance.programStageInstances) + + + - - - + + + - #set( $mark = false ) - #foreach( $programStageInstance in $programInstance.programStageInstances ) - #if( $programStageInstance.outboundSms.size() > 0 || - $programStageInstance.outboundSms.size() > 0 ) - - #foreach( $comment in $programStageInstance.comments ) - - - - - - #set( $mark = !$mark ) - #end + + + #set($index = 0) + #set( $mark = false ) + #foreach($programStageInstance in $programStageInstances) + #foreach( $comment in $programStageInstance.comments ) + #if( $index < 5 ) + + + + + #set($index = $index + 1) + #set( $mark = !$mark) + + #end + #end + #end + + + + #foreach($programStageInstance in $programStageInstances) + #foreach( $sms in $programStageInstance.outboundSms ) + #if( $index < 5 ) + + + + + #set( $mark = !$mark) + + #end + #end + #end + + + + #foreach($programStageInstance in $programStageInstances) + #foreach( $comment in $programStageInstance.comments ) + #if( $index >= 5 ) + + + + + #set( $mark = !$mark) + + #end + #end + #end + #foreach($programStageInstance in $programStageInstances) #foreach( $sms in $programStageInstance.outboundSms ) - - - - - - #set( $mark = !$mark ) + #if( $index >= 5 ) + + + + + #set( $mark = !$mark) + + #end #end #end - #end -
$i18n.getString('date')$i18n.getString('program_stage')$i18n.getString('message')$i18n.getString( "date" )$i18n.getString( "program_stage" )$i18n.getString( "message" )
$!format.formatDate( $comment.createdDate )$programStageInstance.programStage.name($comment.creator) $comment.commentText
$format.formatDate($comment.createdDate)$programStageInstance.programStage.name$comment.creator - $comment.commentText
$format.formatDate($!sms.date) $programStageInstance.programStage.name$sms.message
+ + \ 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-09-06 09:44:43 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-09-07 07:57:47 +0000 @@ -1,3 +1,17 @@ +var prefixId = 'ps_'; +var COLOR_RED = "#fb4754"; +var COLOR_GREEN = "#8ffe8f"; +var COLOR_YELLOW = "#f9f95a"; +var COLOR_LIGHTRED = "#fb6bfb"; +var COLOR_LIGHT_RED = "#ff7676"; +var COLOR_LIGHT_YELLOW = "#ffff99"; +var COLOR_LIGHT_GREEN = "#ccffcc"; +var COLOR_LIGHT_LIGHTRED = "#ff99ff"; +var SUCCESS_COLOR = '#ccffcc'; +var ERROR_COLOR = '#ccccff'; +var SAVING_COLOR = '#ffffcc'; +var SUCCESS = 'success'; +var ERROR = 'error'; // Disable caching for ajax requests in general @@ -379,16 +393,6 @@ window.location.href = url; } -var prefixId = 'ps_'; -var COLOR_RED = "#fb4754"; -var COLOR_GREEN = "#8ffe8f"; -var COLOR_YELLOW = "#f9f95a"; -var COLOR_LIGHTRED = "#fb6bfb"; -var COLOR_LIGHT_RED = "#ff7676"; -var COLOR_LIGHT_YELLOW = "#ffff99"; -var COLOR_LIGHT_GREEN = "#ccffcc"; -var COLOR_LIGHT_LIGHTRED = "#ff99ff"; - function setEventColorStatus( elementId, status ) { status = eval(status); @@ -658,3 +662,185 @@ $('#eventMessagesDiv').load("getEventMessages.action", {programInstanceId:programInstanceId}); } +// ---------------------------------------------------------------- +// Dash board +// ---------------------------------------------------------------- + +function activeProgramInstanceDiv( programInstanceId ) +{ + jQuery(".selected").each(function(){ + jQuery(this).removeClass(); + }); + + jQuery("#infor_" + programInstanceId).each(function(){ + jQuery(this).addClass('selected bold'); + }); + + showById('pi_' + programInstanceId); +} + +function hideProgramInstanceDiv( programInstanceId ) +{ + hideById('pi_' + programInstanceId); + jQuery('#pi_' + programInstanceId).removeClass("link-area-active"); + jQuery("#img_" + programInstanceId).attr('src',''); +} + +function showPatientDashboardForm( patientId ) +{ + hideById('listPatientDiv'); + hideById('editPatientDiv'); + hideById('selectDiv'); + hideById('searchDiv'); + hideById('migrationPatientDiv'); + + jQuery('#loaderDiv').show(); + jQuery('#patientDashboard').load('patientDashboard.action', + { + patientId:patientId + }, function() + { + showById('patientDashboard'); + hideById('enrollProgramBtn'); + jQuery('#loaderDiv').hide(); + }); +} + +function loadActiveProgramStageRecords(programInstanceId, activeProgramStageInstanceId) +{ + jQuery('#loaderDiv').show(); + jQuery('#programEnrollmentDiv').load('enrollmentform.action', + { + programInstanceId:programInstanceId + }, function() + { + showById('programEnrollmentDiv'); + var type = jQuery('#tr_'+programInstanceId).attr('programType'); + if(type=='2'){ + hideById('programInstanceDiv'); + var programStageInstanceId = jQuery('#tr_'+programInstanceId).attr('programStageInstanceId'); + loadDataEntry( programStageInstanceId ); + } + else{ + showById('programInstanceDiv'); + } + activeProgramInstanceDiv( programInstanceId ); + loadDataEntry( activeProgramStageInstanceId ); + jQuery('#loaderDiv').hide(); + }); +} + +function loadProgramStageRecords( programStageInstanceId, completed ) +{ + showLoader(); + jQuery('#dataEntryFormDiv').load( "viewProgramStageRecords.action", + { + programStageInstanceId: programStageInstanceId + }, function() { + if(completed){ + jQuery( "#dataEntryFormDiv :input").each(function(){ + disable(this.id); + }); + } + showById('dataEntryFormDiv'); + hideLoader(); + }); +} + +function updateEnrollment( patientId, programId, programInstanceId, programName ) +{ + var dateOfIncident = jQuery('#tab-3 [id=dateOfIncident]').val(); + var enrollmentDate = jQuery('#tab-3 [id=enrollmentDate]').val(); + + jQuery.postJSON( "saveProgramEnrollment.action", + { + patientId: getFieldValue('patientId'), + programId: programId, + dateOfIncident: dateOfIncident, + enrollmentDate: enrollmentDate + }, + function( json ) + { + var infor = programName + " (" + enrollmentDate + ")"; + setInnerHTML("infor_" + programInstanceId, infor ); + showSuccessMessage(i18n_enrol_success); + }); +} + +//----------------------------------------------------------------------------- +// Save due-date +//----------------------------------------------------------------------------- + +function saveDueDate( programStageInstanceId, programStageInstanceName ) +{ + var field = document.getElementById( 'value_' + programStageInstanceId + '_date' ); + + var dateOfIncident = new Date( byId('dateOfIncident').value ); + var dueDate = new Date(field.value); + + if( dueDate < dateOfIncident ) + { + field.style.backgroundColor = '#FFCC00'; + alert( i18n_date_less_incident ); + return; + } + + field.style.backgroundColor = '#ffffcc'; + + var dateDueSaver = new DateDueSaver( programStageInstanceId, field.value, '#ccffcc' ); + dateDueSaver.save(); +} + +function DateDueSaver( programStageInstanceId_, dueDate_, resultColor_ ) +{ + var programStageInstanceId = programStageInstanceId_; + var dueDate = dueDate_; + var resultColor = resultColor_; + + this.save = function() + { + var params = 'programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate; + $.ajax({ + type: "POST", + url: "saveDueDate.action", + data: params, + dataType: "xml", + success: function(result){ + handleResponse (result); + }, + error: function(request,status,errorThrown) { + handleHttpError (request); + } + }); + }; + + function handleResponse( rootElement ) + { + var codeElement = rootElement.getElementsByTagName( 'code' )[0]; + var code = parseInt( codeElement.firstChild.nodeValue ); + + if ( code == 0 ) + { + markValue( resultColor ); + } + else + { + markValue( COLOR_GREY ); + window.alert( i18n_saving_value_failed_status_code + '\n\n' + code ); + } + } + + function handleHttpError( errorCode ) + { + markValue( COLOR_GREY ); + window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode ); + } + + function markValue( color ) + { + + var element = document.getElementById( 'value_' + programStageInstanceId + '_date' ); + + element.style.backgroundColor = color; + } +} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-08-28 09:11:19 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-09-07 07:57:47 +0000 @@ -1,9 +1,3 @@ -var SUCCESS_COLOR = '#ccffcc'; -var ERROR_COLOR = '#ccccff'; -var SAVING_COLOR = '#ffffcc'; -var SUCCESS = 'success'; -var ERROR = 'error'; - //-------------------------------------------------------------------------------------------- // Load program-stages by the selected program //-------------------------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-09-06 09:44:43 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-09-07 07:57:47 +0000 @@ -571,30 +571,6 @@ } -//----------------------------------------------------------------------------- -//Save -//----------------------------------------------------------------------------- - -function saveDueDate( programStageInstanceId, programStageInstanceName ) -{ - var field = document.getElementById( 'value_' + programStageInstanceId + '_date' ); - - var dateOfIncident = new Date( byId('dateOfIncident').value ); - var dueDate = new Date(field.value); - - if( dueDate < dateOfIncident ) - { - field.style.backgroundColor = '#FFCC00'; - alert( i18n_date_less_incident ); - return; - } - - field.style.backgroundColor = '#ffffcc'; - - var dateDueSaver = new DateDueSaver( programStageInstanceId, field.value, '#ccffcc' ); - dateDueSaver.save(); -} - //---------------------------------------------------- // Show relationship with new patient //---------------------------------------------------- @@ -691,65 +667,6 @@ hideLoader(); } -//----------------------------------------------------------------------------- -// Saver objects -//----------------------------------------------------------------------------- - -function DateDueSaver( programStageInstanceId_, dueDate_, resultColor_ ) -{ - var programStageInstanceId = programStageInstanceId_; - var dueDate = dueDate_; - var resultColor = resultColor_; - - this.save = function() - { - var params = 'programStageInstanceId=' + programStageInstanceId + '&dueDate=' + dueDate; - $.ajax({ - type: "POST", - url: "saveDueDate.action", - data: params, - dataType: "xml", - success: function(result){ - handleResponse (result); - }, - error: function(request,status,errorThrown) { - handleHttpError (request); - } - }); - }; - - function handleResponse( rootElement ) - { - var codeElement = rootElement.getElementsByTagName( 'code' )[0]; - var code = parseInt( codeElement.firstChild.nodeValue ); - - if ( code == 0 ) - { - markValue( resultColor ); - } - else - { - markValue( COLOR_GREY ); - window.alert( i18n_saving_value_failed_status_code + '\n\n' + code ); - } - } - - function handleHttpError( errorCode ) - { - markValue( COLOR_GREY ); - window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode ); - } - - function markValue( color ) - { - - var element = document.getElementById( 'value_' + programStageInstanceId + '_date' ); - - element.style.backgroundColor = color; - } -} - - // ----------------------------------------------------------------------------- // remove value of all the disabled identifier fields // an identifier field is disabled when its value is inherited from another person ( underAge is true ) @@ -908,107 +825,3 @@ showSuccessMessage( i18n_save_success ); } ); } - -// ---------------------------------------------------------------- -// Dash board -// ---------------------------------------------------------------- - -function activeProgramInstanceDiv( programInstanceId ) -{ - jQuery(".selected").each(function(){ - jQuery(this).removeClass(); - }); - - jQuery("#infor_" + programInstanceId).each(function(){ - jQuery(this).addClass('selected bold'); - }); - - showById('pi_' + programInstanceId); -} - -function hideProgramInstanceDiv( programInstanceId ) -{ - hideById('pi_' + programInstanceId); - jQuery('#pi_' + programInstanceId).removeClass("link-area-active"); - jQuery("#img_" + programInstanceId ).attr('src',''); -} - -function showPatientDashboardForm( patientId ) -{ - hideById('listPatientDiv'); - hideById('editPatientDiv'); - hideById('selectDiv'); - hideById('searchDiv'); - hideById('migrationPatientDiv'); - - jQuery('#loaderDiv').show(); - jQuery('#patientDashboard').load('patientDashboard.action', - { - patientId:patientId - }, function() - { - showById('patientDashboard'); - jQuery('#loaderDiv').hide(); - }); -} - -function loadActiveProgramStageRecords(programInstanceId, activeProgramStageInstanceId) -{ - jQuery('#loaderDiv').show(); - jQuery('#programEnrollmentDiv').load('enrollmentform.action', - { - programInstanceId:programInstanceId - }, function() - { - showById('programEnrollmentDiv'); - var type = jQuery('#tr_'+programInstanceId).attr('programType'); - if(type=='2'){ - hideById('programInstanceDiv'); - var programStageInstanceId = jQuery('#tr_'+programInstanceId).attr('programStageInstanceId'); - loadDataEntry( programStageInstanceId ); - } - else{ - showById('programInstanceDiv'); - } - activeProgramInstanceDiv( programInstanceId ); - loadDataEntry( activeProgramStageInstanceId ); - jQuery('#loaderDiv').hide(); - }); -} - -function loadProgramStageRecords( programStageInstanceId, completed ) -{ - showLoader(); - jQuery('#dataEntryFormDiv').load( "viewProgramStageRecords.action", - { - programStageInstanceId: programStageInstanceId - }, function() { - if(completed){ - jQuery( "#dataEntryFormDiv :input").each(function(){ - disable(this.id); - }); - } - showById('dataEntryFormDiv'); - hideLoader(); - }); -} - -function updateEnrollment( patientId, programId, programInstanceId, programName ) -{ - var dateOfIncident = jQuery('#tab-3 [id=dateOfIncident]').val(); - var enrollmentDate = jQuery('#tab-3 [id=enrollmentDate]').val(); - - jQuery.postJSON( "saveProgramEnrollment.action", - { - patientId: getFieldValue('patientId'), - programId: programId, - dateOfIncident: dateOfIncident, - enrollmentDate: enrollmentDate - }, - function( json ) - { - var infor = programName + " (" + enrollmentDate + ")"; - setInnerHTML("infor_" + programInstanceId, infor ); - showSuccessMessage(i18n_enrol_success); - }); -} \ 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-06 09:44:43 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2012-09-07 07:57:47 +0000 @@ -71,6 +71,7 @@ function getOutboundSmsList( programStageInstanceId, isSendSMS ) { setFieldValue('sendToList', "false"); + setInnerHTML('patientProgramTrackingDiv', ''); $('#smsManagementDiv' ).load("getOutboundSmsList.action", { programStageInstanceId: programStageInstanceId @@ -82,9 +83,10 @@ }); } -function showSendSmsForm() +function showSendSmsForm(programStageName, programStageInstanceId) { - setFieldValue('sendToList', "true"); + setFieldValue( 'programStageInstanceId', programStageInstanceId ); + setFieldValue( 'programStageName', programStageName ); $('#sendSmsFormDiv' ).load("getGateway.action").dialog( { title:i18n_send_sms, @@ -121,7 +123,6 @@ function sendSMS() { var sendToList = getFieldValue('sendToList'); - if( sendToList == 'false'){ sendSmsOnePatient() } @@ -143,9 +144,10 @@ { if ( json.response == "success" ) { showSuccessMessage( json.message ); - jQuery('#smsManagementList').prepend("" + getFieldValue('currentDate') + "" + getFieldValue('smsMessage') + ""); + jQuery('#commentTB').prepend("" + getFieldValue('currentDate') + "" + + "" + getFieldValue('programStageName') + "" + + "" + getFieldValue('smsMessage') + ""); var noMessage = eval( getInnerHTML('noMessageDiv_' + programStageInstanceId)) + 1; - jQuery('#noMessageDiv_' + programStageInstanceId).html(noMessage); } else { showErrorMessage( json.message, 7000 ); @@ -158,18 +160,18 @@ params = getSearchParams(); params += "&gatewayId=" + getFieldValue( 'gatewayId' ); params += "&msg=" + getFieldValue( 'smsMessage' ); + params += "&programStageInstanceId=" + getFieldValue('programStageInstanceId'); $.ajax({ url: 'sendSMSTotList.action', type:"POST", data: params, success: function( json ){ if ( json.response == "success" ) { + var programStageName = getFieldValue('programStageName'); + jQuery('#commentTB').prepend("" + getFieldValue("currentDate") + "" + + "" + programStageName + "" + + "" + getFieldValue( 'smsMessage' ) + ""); showSuccessMessage( json.message ); - jQuery("#patientList [programStageId=" + programStageId + "][status=" + status + "]" ).each( function(){ - var programStageInstanceId = jQuery(this).attr('programStageInstanceId'); - var noMessage = eval( getInnerHTML('noMessageDiv_' + programStageInstanceId)) + 1; - jQuery('#noMessageDiv_' + programStageInstanceId).html(noMessage); - }); } else { showErrorMessage( json.message ); @@ -190,16 +192,17 @@ }); } -function keypress(event, programStageInstanceId ) +function keypress(event, field, programStageInstanceId ) { var key = getKeyCode( event ); if ( key==13 ){ // Enter - addComment( programStageInstanceId ); + addComment( field, programStageInstanceId ); } } -function addComment( programStageInstanceId ) +function addComment( field, programStageInstanceId ) { + field.style.backgroundColor = SAVING_COLOR; var commentText = getFieldValue( 'commentText' ); if( commentText != '') { @@ -209,12 +212,13 @@ commentText: commentText }, function ( json ) { - var programStageName = jQuery("#ps_" + programStageInstanceId).attr('programStageName'); + var programStageName = jQuery("#box_" + programStageInstanceId).attr('programStageName'); jQuery('#commentTB').prepend("" + getFieldValue("currentDate") + "" + "" + programStageName + "" + "" + getFieldValue('currentUsername') + " - " + commentText + ""); - setFieldValue( 'commentText','' ); - showSuccessMessage( i18n_comment_added ); + field.value=""; + jQuery(field).attr('placeholder', i18n_comment_added ); + field.style.backgroundColor = SUCCESS_COLOR; } ); } } @@ -243,7 +247,7 @@ jQuery("#tb_" + programInstanceId + " .arrow-left").toggle(); jQuery("#tb_" + programInstanceId + " .arrow-right").toggle(); - if( jQuery("#tb_" + programInstanceId + " .searched").length==0) + if( jQuery("#tb_" + programInstanceId + " .searched").length>0) { var id = jQuery("#tb_" + programInstanceId + " .searched").attr('id').split('_')[1]; showById("arrow_" + id); @@ -251,9 +255,79 @@ } } -function backToSelect() +// -------------------------------------------------------------------- +// Patient program tracking +// -------------------------------------------------------------------- + +function showPatientProgramTracking(programInstanceId) +{ + hideById("listPatientDiv"); + hideById("searchDiv"); + setInnerHTML("smsManagementDiv", ""); + showLoader(); + $( '#patientProgramTrackingDiv' ).load( "patientProgramTracking.action", + { + programInstanceId:programInstanceId + },function( ) + { + showById('patientProgramTrackingDiv'); + hideLoader(); + }); +} + +function setEventStatus( field, programStageInstanceId ) +{ + field.style.backgroundColor = SAVING_COLOR; + jQuery.postUTF8( 'setEventStatus.action', + { + programStageInstanceId:programStageInstanceId, + status:field.value + }, function ( json ) + { + field.style.backgroundColor = SUCCESS_COLOR; + } ); +} + +function removeEvent( programStageId ) +{ + var result = window.confirm( i18n_comfirm_delete_event ); + + if ( result ) + { + $.postJSON( + "removeCurrentEncounter.action", + { + "id": programStageId + }, + function( json ) + { + if ( json.response == "success" ) + { + jQuery( "tr#tr" + programStageId ).remove(); + + jQuery( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" ); + jQuery( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" ); + jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" ); + jQuery( "table.listTable tbody" ).trigger("update"); + + hideById('smsManagementDiv'); + + showSuccessMessage( i18n_delete_success ); + } + else if ( json.response == "error" ) + { + showWarningMessage( json.message ); + } + } + ); + } +} + + +function onClickBackBtn() { showById('searchDiv'); showById('listPatientDiv'); hideById('smsManagementDiv'); -} \ No newline at end of file + hideById('patientProgramTrackingDiv'); +} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm 2012-09-04 10:10:05 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm 2012-09-07 07:57:47 +0000 @@ -74,8 +74,8 @@ - - -
+