=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsAction.java 2012-09-23 11:52:27 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsAction.java 2012-09-24 05:50:08 +0000 @@ -65,14 +65,14 @@ { this.programStageInstanceService = programStageInstanceService; } - + private CurrentUserService currentUserService; public void setCurrentUserService( CurrentUserService currentUserService ) { this.currentUserService = currentUserService; } - + private I18n i18n; public void setI18n( I18n i18n ) @@ -90,7 +90,7 @@ { this.programStageInstanceId = programStageInstanceId; } - + private String msg; public void setMsg( String msg ) @@ -125,28 +125,31 @@ OutboundSms outboundSms = new OutboundSms( msg, phoneNumber ); outboundSms.setSender( currentUserService.getCurrentUsername() ); outboundSmsService.sendMessage( outboundSms, null ); - + List outboundSmsList = programStageInstance.getOutboundSms(); - if( outboundSmsList == null) + if ( outboundSmsList == null ) { outboundSmsList = new ArrayList(); } outboundSmsList.add( outboundSms ); programStageInstance.setOutboundSms( outboundSmsList ); programStageInstanceService.updateProgramStageInstance( programStageInstance ); - + message = i18n.getString( "sent_message_to" ) + " " + phoneNumber; + + return SUCCESS; } catch ( SmsServiceException e ) { message = e.getMessage(); + + return ERROR; } } - else - { - message = i18n.getString( "patient_did_not_register_a_phone_number" ); - } - return SUCCESS; + + message = i18n.getString( "patient_did_not_register_a_phone_number" ); + + return INPUT; } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-09-24 05:02:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-09-24 05:50:08 +0000 @@ -416,7 +416,6 @@ ../dhis-web-commons/ouwt/ouwt.js ,javascript/commons.js ,javascript/patient.js - ,javascript/patientForm.js ,javascript/entry.js ,javascript/relationshipPatient.js @@ -887,8 +886,8 @@ ../dhis-web-commons/ouwt/ouwt.js, javascript/commons.js, - javascript/patient.js, javascript/relationshipPatient.js, + javascript/entry.js, javascript/smsReminder.js F_SMS_REMINDER @@ -916,10 +915,9 @@ - /dhis-web-commons/ajax/jsonResponseSuccess.vm - - /dhis-web-commons/ajax/jsonResponseError.vm - + /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseInput.vm + /dhis-web-commons/ajax/jsonResponseError.vm plainTextError === 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-24 05:02:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2012-09-24 05:50:08 +0000 @@ -56,35 +56,6 @@ } } -// ---------------------------------------------------------------------------- -// Search patients by name -// ---------------------------------------------------------------------------- - -function getPatientsByName( divname ) -{ - var fullName = jQuery('#' + divname + ' [id=fullName]').val().replace(/^\s+|\s+$/g,""); - if( fullName.length > 0) - { - contentDiv = 'resultSearchDiv'; - $('#resultSearchDiv' ).load("getPatientsByName.action", - { - fullName: fullName - }).dialog({ - title: i18n_search_result, - maximize: true, - closable: true, - modal:true, - overlay:{ background:'#000000', opacity: 0.8}, - width: 800, - height: 400 - }); - } - else - { - alert( i18n_no_patients_found ); - } -} - // ----------------------------------------------------------------------------- // Advanced search // ----------------------------------------------------------------------------- @@ -684,131 +655,6 @@ } } -// load program instance history -function programReports( programInstanceId ) -{ - $('#programReportDiv').load("getProgramReportHistory.action", {programInstanceId:programInstanceId}); -} - -// load SMS message and comments -function getEventMessages( programInstanceId ) -{ - $('#eventMessagesDiv').load("getEventMessages.action", {programInstanceId:programInstanceId}); -} - -// ---------------------------------------------------------------- -// Dash board -// ---------------------------------------------------------------- - -function showPatientDashboardForm( patientId ) -{ - hideById('selectDiv'); - hideById('searchDiv'); - hideById('listPatientDiv'); - hideById('editPatientDiv'); - hideById('listRelationshipDiv'); - hideById('addRelationshipDiv'); - hideById('migrationPatientDiv'); - hideById('patientProgramTrackingDiv'); - hideById('smsManagementDiv'); - setInnerHTML('listEventDiv',''); - - jQuery('#loaderDiv').show(); - jQuery('#patientDashboard').load('patientDashboard.action', - { - patientId:patientId - }, function() - { - setInnerHTML('mainFormLink', i18n_main_form_link); - showById('patientDashboard'); - jQuery('#loaderDiv').hide(); - }); -} - -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 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 ); - if( activeProgramStageInstanceId ) - { - 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 //----------------------------------------------------------------------------- @@ -904,6 +750,10 @@ } } +//----------------------------------------------------------------------------- +// Cosmetic UI +//----------------------------------------------------------------------------- + function resize(){ var width = 400; var w = $(window).width(); @@ -1059,3 +909,794 @@ ); } } + + +// ----------------------------------------------------------------------------- +// Show relationship with new patient +// ----------------------------------------------------------------------------- + +function showRelationshipList( patientId ) +{ + hideById('addRelationshipDiv'); + hideById('patientDashboard'); + hideById('selectDiv'); + hideById('searchDiv'); + hideById('listPatientDiv'); + + jQuery('#loaderDiv').show(); + jQuery('#listRelationshipDiv').load('showRelationshipList.action', + { + id:patientId + }, function() + { + showById('listRelationshipDiv'); + jQuery('#loaderDiv').hide(); + }); +} + +// ----------------------------------------------------------------------------- +// Update Patient +// ----------------------------------------------------------------------------- + +function showUpdatePatientForm( patientId ) +{ + hideById('listPatientDiv'); + setInnerHTML('editPatientDiv', ''); + hideById('selectDiv'); + hideById('searchDiv'); + hideById('migrationPatientDiv'); + hideById('patientDashboard'); + + jQuery('#loaderDiv').show(); + jQuery('#editPatientDiv').load('showUpdatePatientForm.action', + { + id:patientId + }, function() + { + jQuery('#searchPatientsDiv').dialog('close'); + jQuery('#loaderDiv').hide(); + showById('editPatientDiv'); + }); + + jQuery('#resultSearchDiv').dialog('close'); +} + +function validateUpdatePatient() +{ + $("#editPatientDiv :input").attr("disabled", true); + $.ajax({ + type: "POST", + url: 'validatePatient.action', + data: getParamsForDiv('editPatientDiv'), + success:updateValidationCompleted + }); +} + +function updateValidationCompleted( messageElement ) +{ + var type = jQuery(messageElement).find('message').attr('type'); + var message = jQuery(messageElement).find('message').text(); + + if ( type == 'success' ) + { + removeDisabledIdentifier(); + updatePatient(); + } + else + { + $("#editPatientDiv :input").attr("disabled", true); + if ( type == 'error' ) + { + showErrorMessage( i18n_saving_patient_failed + ':' + '\n' + message ); + } + else if ( type == 'input' ) + { + showWarningMessage( message ); + } + else if( type == 'duplicate' ) + { + showListPatientDuplicate(messageElement, true); + } + $("#editPatientDiv :input").attr("disabled", false); + } +} + +function updatePatient() +{ + $.ajax({ + type: "POST", + url: 'updatePatient.action', + data: getParamsForDiv('editPatientDiv'), + success: function( json ) { + showPatientDashboardForm( getFieldValue('id') ); + } + }); +} + +function addEventForPatientForm( divname ) +{ + jQuery("#" + divname + " [id=checkDuplicateBtn]").click(function() { + checkDuplicate( divname ); + }); + + jQuery("#" + divname + " [id=dobType]").change(function() { + dobTypeOnChange( divname ); + }); +} + +function showRepresentativeInfo( patientId) +{ + jQuery('#representativeInfo' ).dialog({ + title: i18n_representative_info, + maximize: true, + closable: true, + modal: false, + overlay: {background:'#000000', opacity:0.1}, + width: 400, + height: 300 + }); +} + +function removeDisabledIdentifier() +{ + jQuery("input.idfield").each(function(){ + if( jQuery(this).is(":disabled")) + jQuery(this).val(""); + }); +} + +/** + * Show list patient duplicate by jQuery thickbox plugin + * @param rootElement : root element of the response xml + * @param validate : is TRUE if this method is called from validation method + */ +function showListPatientDuplicate( rootElement, validate ) +{ + var message = jQuery(rootElement).find('message').text(); + var patients = jQuery(rootElement).find('patient'); + + var sPatient = ""; + jQuery( patients ).each( function( i, patient ) + { + sPatient += "
"; + sPatient += "" ; + sPatient += "" ; + sPatient += "" ; + sPatient += "" ; + sPatient += "" ; + sPatient += ""; + + var identifiers = jQuery(patient).find('identifier'); + if( identifiers.length > 0 ) + { + sPatient += ""; + + jQuery( identifiers ).each( function( i, identifier ) + { + sPatient +="" + +"" + +" " + +""; + }); + } + + var attributes = jQuery(patient).find('attribute'); + if( attributes.length > 0 ) + { + sPatient += ""; + + jQuery( attributes ).each( function( i, attribute ) + { + sPatient +="" + +"" + +" " + +""; + }); + } + sPatient += ""; + sPatient += "
" + i18n_patient_system_id + "" + jQuery(patient).find('systemIdentifier').text() + "
" + i18n_patient_full_name + "" + jQuery(patient).find('fullName').text() + "
" + i18n_patient_gender + "" + jQuery(patient).find('gender').text() + "
" + i18n_patient_date_of_birth + "" + jQuery(patient).find('dateOfBirth').text() + "
" + i18n_patient_age + "" + jQuery(patient).find('age').text() + "
" + i18n_patient_phone_number + "" + jQuery(patient).find('phoneNumber').text() + "
" + i18n_patient_identifiers + "
" + jQuery(identifier).find('name').text() + "" + jQuery(identifier).find('value').text() + "
" + i18n_patient_attributes + "
" + jQuery(attribute).find('name').text() + "" + jQuery(attribute).find('value').text() + "
"; + }); + + var result = i18n_duplicate_warning; + if( !validate ) + { + result += ""; + result += "

"; + } + + result += "
" + sPatient; + jQuery('#resultSearchDiv' ).html( result ); + jQuery('#resultSearchDiv' ).dialog({ + title: i18n_duplicated_patient_list, + maximize: true, + closable: true, + modal:true, + overlay:{background:'#000000', opacity:0.1}, + width: 800, + height: 400 + }); +} + +// ----------------------------------------------------------------------------- +// Show representative form +// ----------------------------------------------------------------------------- + +function toggleUnderAge(this_) +{ + if( jQuery(this_).is(":checked")) + { + jQuery('#representativeDiv').dialog('destroy').remove(); + jQuery('
' ).load( 'showAddRepresentative.action',{}, + function(){ + $('#patientForm [id=birthDate]').attr('id','birthDate_id'); + $('#patientForm [id=birthDate_id]').attr('name','birthDate_id'); + }).dialog({ + title: i18n_child_representative, + maximize: true, + closable: true, + modal:true, + overlay:{background:'#000000', opacity:0.1}, + width: 800, + height: 450, + close:function() + { + $('#patientForm [id=birthDate_id]').attr('id','birthDate'); + $('#patientForm [id=birthDate]').attr('name','birthDate'); + } + }); + }else + { + jQuery("#representativeDiv :input.idfield").each(function(){ + if( jQuery(this).is(":disabled")) + { + jQuery(this).removeAttr("disabled").val(""); + } + }); + jQuery("#representativeId").val(""); + jQuery("#relationshipTypeId").val(""); + } +} + +// ---------------------------------------------------------------- +// Enrollment program +// ---------------------------------------------------------------- + +function showProgramEnrollmentForm( patientId ) +{ + jQuery('#enrollmentDiv').load('showProgramEnrollmentForm.action', + { + id:patientId + }).dialog({ + title: i18n_enroll_program, + maximize: true, + closable: true, + modal:true, + overlay:{background:'#000000', opacity:0.1}, + width: 550, + height: 450 + }); +} + +function programOnchange( programId ) +{ + if( programId==0){ + hideById('enrollmentDateTR'); + hideById('dateOfIncidentTR'); + } + else{ + var type = jQuery('#enrollmentDiv [name=programId] option:selected').attr('programType') + if(type=='2'){ + hideById('enrollmentDateTR'); + hideById('dateOfIncidentTR'); + disable('enrollmentDate'); + disable('dateOfIncident'); + } + else{ + showById( 'enrollmentDateTR'); + enable('enrollmentDate'); + + var dateOfEnrollmentDescription = jQuery('#enrollmentDiv [name=programId] option:selected').attr('dateOfEnrollmentDescription'); + var dateOfIncidentDescription = jQuery('#enrollmentDiv [name=programId] option:selected').attr('dateOfIncidentDescription'); + setInnerHTML('enrollmentDateDescription', dateOfEnrollmentDescription); + setInnerHTML('dateOfIncidentDescription', dateOfIncidentDescription); + + var displayIncidentDate = jQuery('#enrollmentDiv [name=programId] option:selected').attr('displayIncidentDate'); + if( displayIncidentDate=='true'){ + showById('dateOfIncidentTR'); + enable('dateOfIncident'); + } + else{ + hideById('dateOfIncidentTR'); + disable('dateOfIncident'); + } + } + var programId = jQuery('#programEnrollmentSelectDiv [id=programId] option:selected').val(); + jQuery('#identifierAndAttributeDiv').load("getPatientIdentifierAndAttribute.action", + { + id:programId + }, function(){ + showById('identifierAndAttributeDiv'); + }); + } +} + +function saveEnrollment( patientId, programId ) +{ + var patientId = jQuery('#enrollmentDiv [id=patientId]').val(); + var programId = jQuery('#enrollmentDiv [id=programId] option:selected').val(); + var programName = jQuery('#enrollmentDiv [id=programId] option:selected').text(); + var dateOfIncident = jQuery('#enrollmentDiv [id=dateOfIncidentField]').val(); + var enrollmentDate = jQuery('#enrollmentDiv [id=enrollmentDateField]').val(); + + jQuery.postJSON( "saveProgramEnrollment.action", + { + patientId: patientId, + programId: programId, + dateOfIncident: dateOfIncident, + enrollmentDate: enrollmentDate + }, + function( json ) + { + var programInstanceId = json.programInstanceId; + var programStageInstanceId = json.activeProgramStageInstanceId; + var programStageName = json.activeProgramStageName; + var dueDate = json.dueDate; + var type = jQuery('#enrollmentDiv [id=programId] option:selected').attr('programType'); + + var activedRow = "" + + " " + + " " + + "" + + programName + "(" + enrollmentDate + ")" + + ""; + + activedRow += "" + + "• " + programStageName + "(" + dueDate + ")"; + + jQuery('#activeTB' ).prepend(activedRow); + jQuery('#enrollmentDiv').dialog("close"); + saveIdentifierAndAttribute( patientId, programId,'identifierAndAttributeDiv' ); + loadProgramInstance( programInstanceId, false ); + showSuccessMessage(i18n_enrol_success); + }); +} + +// ---------------------------------------------------------------- +// Load program instance +// ---------------------------------------------------------------- + +function loadProgramInstance( programInstanceId, completed ) +{ + if( programInstanceId=='') { + hideById('programEnrollmentDiv'); + return; + } + 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 ); + if( completed ){ + hideById('newEncounterBtn_' + programInstanceId); + } + jQuery('#loaderDiv').hide(); + resize(); + }); +} + +// ---------------------------------------------------------------- +// Program enrollmment && unenrollment +// ---------------------------------------------------------------- + +function validateProgramEnrollment() +{ + jQuery('#loaderDiv').show(); + $.ajax({ + type: "GET", + url: 'validatePatientProgramEnrollment.action', + data: getParamsForDiv('programEnrollmentSelectDiv'), + success: function(json) { + hideById('message'); + var type = json.response; + if ( type == 'success' ){ + saveProgramEnrollment(); + } + else if ( type == 'error' ){ + setMessage( i18n_program_enrollment_failed + ':' + '\n' + message ); + } + else if ( type == 'input' ){ + setMessage( json.message ); + } + jQuery('#loaderDiv').hide(); + } + }); +} + +function saveProgramEnrollment() +{ + $.ajax({ + type: "POST", + url: 'saveProgramEnrollment.action', + data: getParamsForDiv('programEnrollmentSelectDiv'), + success: function( html ) { + setInnerHTML('programEnrollmentDiv', html ); + jQuery('#enrollBtn').attr('value',i18n_update); + showSuccessMessage( i18n_enrol_success ); + } + }); + return false; +} + +function unenrollmentForm( programInstanceId ) +{ + $.ajax({ + type: "POST", + url: 'removeEnrollment.action', + data: "programInstanceId=" + programInstanceId, + success: function( json ) + { + jQuery('#completedList' ).append(''); + hideById('tr1_' + programInstanceId ); + hideById('tr2_' + programInstanceId ); + setInnerHTML('programEnrollmentDiv',''); + showSuccessMessage( i18n_unenrol_success ); + } + }); + + +} + +// ---------------------------------------------------------------- +// Identifiers && Attributes for selected program +// ---------------------------------------------------------------- + +function saveIdentifierAndAttribute( patientId, programId, paramsDiv) +{ + var params = getParamsForDiv(paramsDiv); + params += "&patientId=" + patientId; + params +="&programId=" + programId; + $.ajax({ + type: "POST", + url: 'savePatientIdentifierAndAttribute.action', + data: params, + success: function(json) + { + showSuccessMessage( i18n_save_success ); + } + }); +} + +// ---------------------------------------------------------------- +// Show selected data-recording +// ---------------------------------------------------------------- + +function showSelectedDataRecoding( patientId ) +{ + showLoader(); + hideById('searchDiv'); + hideById('dataEntryFormDiv'); + hideById('migrationPatientDiv'); + hideById('dataRecordingSelectDiv'); + + jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', + { + patientId: patientId + }, + function() + { + jQuery('#dataRecordingSelectDiv [id=backBtnFromEntry]').hide(); + showById('dataRecordingSelectDiv'); + + var programId = jQuery('#programEnrollmentSelectDiv [id=programId] option:selected').val(); + $('#dataRecordingSelectDiv [id=programId]').val( programId ); + $('#dataRecordingSelectDiv [id=inputCriteria]').hide(); + showById('dataRecordingSelectDiv'); + hideLoader(); + hideById('contentDiv'); + }); +} + +// ---------------------------------------------------------------- +// Patient Location +// ---------------------------------------------------------------- + +function getPatientLocation( patientId ) +{ + hideById('listPatientDiv'); + hideById('selectDiv'); + hideById('searchDiv'); + setInnerHTML('patientDashboard',''); + + jQuery('#loaderDiv').show(); + + jQuery('#migrationPatientDiv').load("getPatientLocation.action", + { + patientId: patientId + } + , function(){ + showById( 'migrationPatientDiv' ); + jQuery( "#loaderDiv" ).hide(); + }); +} + +function registerPatientLocation( patientId ) +{ + $.getJSON( 'registerPatientLocation.action',{ patientId:patientId } + , function( json ) + { + showPatientDashboardForm(patientId); + showSuccessMessage( i18n_save_success ); + } ); +} + +// ---------------------------------------------------------------- +// List program-stage-instance of selected program +// ---------------------------------------------------------------- + +function getVisitSchedule( programInstanceId ) +{ + $('#tab-3').load("getVisitSchedule.action", {programInstanceId:programInstanceId}); +} + + +// ---------------------------------------------------------------- +// Dash board +// ---------------------------------------------------------------- + +function showPatientDashboardForm( patientId ) +{ + hideById('selectDiv'); + hideById('searchDiv'); + hideById('listPatientDiv'); + hideById('editPatientDiv'); + hideById('listRelationshipDiv'); + hideById('addRelationshipDiv'); + hideById('migrationPatientDiv'); + hideById('smsManagementDiv'); + setInnerHTML('listEventDiv',''); + + jQuery('#loaderDiv').show(); + jQuery('#patientDashboard').load('patientDashboard.action', + { + patientId:patientId + }, function() + { + setInnerHTML('mainFormLink', i18n_main_form_link); + showById('patientDashboard'); + jQuery('#loaderDiv').hide(); + }); +} + +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 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'); + loadDataEntryloadDataEntry( programStageInstanceId ); + } + else{ + showById('programInstanceDiv'); + } + activeProgramInstanceDiv( programInstanceId ); + if( activeProgramStageInstanceId ) + { + 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); + }); +} + +// load program instance history +function programReports( programInstanceId ) +{ + $('#programReportDiv').load("getProgramReportHistory.action", {programInstanceId:programInstanceId}); +} + +// load SMS message and comments +function getEventMessages( programInstanceId ) +{ + $('#eventMessagesDiv').load("getEventMessages.action", {programInstanceId:programInstanceId}); +} + +// -------------------------------------------------------------------- +// Comment && Message +// -------------------------------------------------------------------- + +function sendSmsOnePatient( field, programStageInstanceId ) +{ + setInnerHTML('smsError', ''); + if(field.value==""){ + field.style.backgroundColor = ERROR_COLOR; + jQuery('#smsError').css("color", "red"); + setInnerHTML('smsError', i18n_this_field_is_required); + return; + } + + field.style.backgroundColor = SAVING_COLOR; + programStageInstanceId = getFieldValue( 'programStageInstanceId' ); + jQuery.postUTF8( 'sendSMS.action', + { + programStageInstanceId: programStageInstanceId, + msg: field.value + }, function ( json ) + { + if ( json.response == "success" ) { + field.value=""; + jQuery('#smsError').css("color", "green"); + setInnerHTML('smsError', json.message); + var date = new Date(); + var currentTime = date.getHours() + ":" + date.getMinutes(); + jQuery('#commentTB').prepend("" + getFieldValue('currentDate') + " " + currentTime + "" + + "" + getFieldValue('programStageName') + "" + + "" + getFieldValue('currentUsername') + "" + + "" + field.value + ""); + field.style.backgroundColor = SUCCESS_COLOR; + } + else { + showSuccessMessage( json.message ); + jQuery('#smsError').css("color", "red"); + setInnerHTML('smsError', json.message); + field.style.backgroundColor = ERROR_COLOR; + } + + if( jQuery("#commentTB tr.hidden").length > 0 ){ + commentDivToggle(true); + } + else{ + commentDivToggle(false); + } + }); +} + +function addComment( field, programStageInstanceId ) +{ + field.style.backgroundColor = SAVING_COLOR; + var commentText = field.value; + if( commentText == ''){ + field.style.backgroundColor = ERROR_COLOR; + return; + } + + jQuery.postUTF8( 'addPatientComment.action', + { + programStageInstanceId: programStageInstanceId, + commentText: commentText + }, function ( json ) + { + var programStageName = jQuery("#ps_" + programStageInstanceId).attr('programStageName'); + var date = new Date(); + var currentTime = date.getHours() + ":" + date.getMinutes(); + jQuery('#commentTB').prepend("" + getFieldValue("currentDate") + " " + currentTime + "" + + "" + programStageName + "" + + "" + getFieldValue('currentUsername') + "" + + "" + commentText + ""); + field.value=""; + showSuccessMessage( i18n_comment_added ); + field.style.backgroundColor = SUCCESS_COLOR; + + if( jQuery("#commentTB tr.hidden").length > 0 ){ + commentDivToggle(true); + } + else{ + commentDivToggle(false); + } + }); +} + +function removeComment( programStageInstanceId, commentId ) +{ + jQuery.postUTF8( 'removePatientComment.action', + { + programStageInstanceId:programStageInstanceId, + id: commentId + }, function ( json ) + { + showSuccessMessage( json.message ); + hideById( 'comment_' + commentId ); + } ); +} + +function commentDivToggle(isHide) +{ + var index = 1; + jQuery("#commentTB tr").removeClass("hidden"); + jQuery("#commentTB tr").each( function(){ + if(isHide && index > 5){ + jQuery(this).addClass("hidden"); + } + else if(!isHide){ + jQuery(this).removeClass("hidden"); + } + index++; + }); + + if( isHide ){ + showById('showCommentBtn'); + hideById('hideCommentBtn'); + } + else + { + hideById('showCommentBtn'); + showById('hideCommentBtn'); + } +} === 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-24 05:02:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-09-24 05:50:08 +0000 @@ -1,92 +1,118 @@ -function addEventForPatientForm( divname ) -{ - jQuery("#" + divname + " [id=checkDuplicateBtn]").click(function() { - checkDuplicate( divname ); - }); - - jQuery("#" + divname + " [id=dobType]").change(function() { - dobTypeOnChange( divname ); - }); -} - -// ----------------------------------------------------------------------------- -// Show relationship with new patient -// ----------------------------------------------------------------------------- - -function showRelationshipList( patientId ) -{ +function organisationUnitSelected( orgUnits, orgUnitNames ) +{ + showById('selectDiv'); + showById('searchDiv'); + hideById('listPatientDiv'); + hideById('editPatientDiv'); + hideById('enrollmentDiv'); + hideById('listRelationshipDiv'); hideById('addRelationshipDiv'); - hideById('patientDashboard'); - hideById('selectDiv'); - hideById('searchDiv'); - hideById('listPatientDiv'); - - jQuery('#loaderDiv').show(); - jQuery('#listRelationshipDiv').load('showRelationshipList.action', - { - id:patientId - }, function() - { - showById('listRelationshipDiv'); - jQuery('#loaderDiv').hide(); - }); -} - -// ----------------------------------------------------------------------------- -// Update Patient -// ----------------------------------------------------------------------------- - -function showUpdatePatientForm( patientId ) -{ - hideById('listPatientDiv'); - setInnerHTML('editPatientDiv', ''); - hideById('selectDiv'); - hideById('searchDiv'); - hideById('migrationPatientDiv'); - hideById('patientDashboard'); - - jQuery('#loaderDiv').show(); - jQuery('#editPatientDiv').load('showUpdatePatientForm.action', - { - id:patientId - }, function() - { - jQuery('#searchPatientsDiv').dialog('close'); - jQuery('#loaderDiv').hide(); + hideById('migrationPatientDiv'); + hideById('patientDashboard'); + enable('listPatientBtn'); + enable('addPatientBtn'); + enable('advancedSearchBtn'); + setFieldValue("orgunitName", orgUnitNames[0]); +} + +selection.setListenerFunction( organisationUnitSelected ); + +// ----------------------------------------------------------------------------- +// List && Search patients +// ----------------------------------------------------------------------------- + +function listAllPatient() +{ + hideById('listPatientDiv'); + hideById('editPatientDiv'); + hideById('migrationPatientDiv'); + + jQuery('#loaderDiv').show(); + contentDiv = 'listPatientDiv'; + jQuery('#listPatientDiv').load('searchRegistrationPatient.action',{ + listAll:true + }, + function(){ + statusSearching = 0; + showById('listPatientDiv'); + jQuery('#loaderDiv').hide(); + }); + hideLoader(); +} + +function advancedSearch( params ) +{ + $.ajax({ + url: 'searchRegistrationPatient.action', + type:"POST", + data: params, + success: function( html ){ + statusSearching = 1; + setInnerHTML( 'listPatientDiv', html ); + showById('listPatientDiv'); + setFieldValue('listAll',false); + jQuery( "#loaderDiv" ).hide(); + } + }); +} + +// ----------------------------------------------------------------------------- +// Remove patient +// ----------------------------------------------------------------------------- + +function removePatient( patientId, fullName ) +{ + removeItem( patientId, fullName, i18n_confirm_delete, 'removePatient.action' ); +} + +// ----------------------------------------------------------------------------- +// Add Patient +// ----------------------------------------------------------------------------- + +function showAddPatientForm() +{ + hideById('listPatientDiv'); + hideById('selectDiv'); + hideById('searchDiv'); + hideById('migrationPatientDiv'); + + jQuery('#loaderDiv').show(); + jQuery('#editPatientDiv').load('showAddPatientForm.action' + , function() + { showById('editPatientDiv'); + jQuery('#loaderDiv').hide(); }); - - jQuery('#resultSearchDiv').dialog('close'); + } -function validateUpdatePatient() -{ - $("#editPatientDiv :input").attr("disabled", true); +function validateAddPatient() +{ + $("#patientForm :input").attr("disabled", true); $.ajax({ type: "POST", url: 'validatePatient.action', - data: getParamsForDiv('editPatientDiv'), - success:updateValidationCompleted - }); + data: getParamsForDiv('patientForm'), + success:addValidationCompleted + }); } -function updateValidationCompleted( messageElement ) +function addValidationCompleted( data ) { - var type = jQuery(messageElement).find('message').attr('type'); - var message = jQuery(messageElement).find('message').text(); - - if ( type == 'success' ) - { - removeDisabledIdentifier(); - updatePatient(); - } + var type = jQuery(data).find('message').attr('type'); + var message = jQuery(data).find('message').text(); + + if ( type == 'success' ) + { + removeDisabledIdentifier( ); + addPatient(); + } else { - $("#editPatientDiv :input").attr("disabled", true); if ( type == 'error' ) { - showErrorMessage( i18n_saving_patient_failed + ':' + '\n' + message ); + showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + message ); } else if ( type == 'input' ) { @@ -94,449 +120,125 @@ } else if( type == 'duplicate' ) { - showListPatientDuplicate(messageElement, true); + showListPatientDuplicate(data, false); } - $("#editPatientDiv :input").attr("disabled", false); + + $("#patientForm :input").attr("disabled", false); } } -function updatePatient() +function addPatient() { $.ajax({ type: "POST", - url: 'updatePatient.action', - data: getParamsForDiv('editPatientDiv'), - success: function( json ) { - showPatientDashboardForm( getFieldValue('id') ); + url: 'addPatient.action', + data: getParamsForDiv('patientForm'), + success: function(json) { + var patientId = json.message.split('_')[0]; + jQuery('#resultSearchDiv').dialog('close'); + showPatientDashboardForm( patientId ); } }); -} - -function showRepresentativeInfo( patientId) -{ - jQuery('#representativeInfo' ).dialog({ - title: i18n_representative_info, - maximize: true, - closable: true, - modal: false, - overlay: {background:'#000000', opacity:0.1}, - width: 400, - height: 300 - }); -} - -function removeDisabledIdentifier() -{ - jQuery("input.idfield").each(function(){ - if( jQuery(this).is(":disabled")) - jQuery(this).val(""); - }); -} - -/** - * Show list patient duplicate by jQuery thickbox plugin - * @param rootElement : root element of the response xml - * @param validate : is TRUE if this method is called from validation method - */ -function showListPatientDuplicate( rootElement, validate ) -{ - var message = jQuery(rootElement).find('message').text(); - var patients = jQuery(rootElement).find('patient'); - - var sPatient = ""; - jQuery( patients ).each( function( i, patient ) - { - sPatient += "
"; - sPatient += "" ; - sPatient += "" ; - sPatient += "" ; - sPatient += "" ; - sPatient += "" ; - sPatient += ""; - - var identifiers = jQuery(patient).find('identifier'); - if( identifiers.length > 0 ) - { - sPatient += ""; - - jQuery( identifiers ).each( function( i, identifier ) - { - sPatient +="" - +"" - +" " - +""; - }); - } - - var attributes = jQuery(patient).find('attribute'); - if( attributes.length > 0 ) - { - sPatient += ""; - - jQuery( attributes ).each( function( i, attribute ) - { - sPatient +="" - +"" - +" " - +""; - }); - } - sPatient += ""; - sPatient += "
" + i18n_patient_system_id + "" + jQuery(patient).find('systemIdentifier').text() + "
" + i18n_patient_full_name + "" + jQuery(patient).find('fullName').text() + "
" + i18n_patient_gender + "" + jQuery(patient).find('gender').text() + "
" + i18n_patient_date_of_birth + "" + jQuery(patient).find('dateOfBirth').text() + "
" + i18n_patient_age + "" + jQuery(patient).find('age').text() + "
" + i18n_patient_phone_number + "" + jQuery(patient).find('phoneNumber').text() + "
" + i18n_patient_identifiers + "
" + jQuery(identifier).find('name').text() + "" + jQuery(identifier).find('value').text() + "
" + i18n_patient_attributes + "
" + jQuery(attribute).find('name').text() + "" + jQuery(attribute).find('value').text() + "
"; - }); - - var result = i18n_duplicate_warning; - if( !validate ) - { - result += ""; - result += "

"; - } - - result += "
" + sPatient; - jQuery('#resultSearchDiv' ).html( result ); - jQuery('#resultSearchDiv' ).dialog({ - title: i18n_duplicated_patient_list, - maximize: true, - closable: true, - modal:true, - overlay:{background:'#000000', opacity:0.1}, - width: 800, - height: 400 - }); -} - -// ----------------------------------------------------------------------------- -// Show representative form -// ----------------------------------------------------------------------------- - -function toggleUnderAge(this_) -{ - if( jQuery(this_).is(":checked")) - { - jQuery('#representativeDiv').dialog('destroy').remove(); - jQuery('
' ).load( 'showAddRepresentative.action',{}, - function(){ - $('#patientForm [id=birthDate]').attr('id','birthDate_id'); - $('#patientForm [id=birthDate_id]').attr('name','birthDate_id'); - }).dialog({ - title: i18n_child_representative, - maximize: true, - closable: true, - modal:true, - overlay:{background:'#000000', opacity:0.1}, - width: 800, - height: 450, - close:function() - { - $('#patientForm [id=birthDate_id]').attr('id','birthDate'); - $('#patientForm [id=birthDate]').attr('name','birthDate'); - } - }); - }else - { - jQuery("#representativeDiv :input.idfield").each(function(){ - if( jQuery(this).is(":disabled")) - { - jQuery(this).removeAttr("disabled").val(""); - } - }); - jQuery("#representativeId").val(""); - jQuery("#relationshipTypeId").val(""); - } -} - -// ---------------------------------------------------------------- -// Enrollment program -// ---------------------------------------------------------------- - -function showProgramEnrollmentForm( patientId ) -{ - jQuery('#enrollmentDiv').load('showProgramEnrollmentForm.action', - { - id:patientId - }).dialog({ - title: i18n_enroll_program, - maximize: true, - closable: true, - modal:true, - overlay:{background:'#000000', opacity:0.1}, - width: 550, - height: 450 - }); -} - -function programOnchange( programId ) -{ - if( programId==0){ - hideById('enrollmentDateTR'); - hideById('dateOfIncidentTR'); - } - else{ - var type = jQuery('#enrollmentDiv [name=programId] option:selected').attr('programType') - if(type=='2'){ - hideById('enrollmentDateTR'); - hideById('dateOfIncidentTR'); - disable('enrollmentDate'); - disable('dateOfIncident'); - } - else{ - showById( 'enrollmentDateTR'); - enable('enrollmentDate'); - - var dateOfEnrollmentDescription = jQuery('#enrollmentDiv [name=programId] option:selected').attr('dateOfEnrollmentDescription'); - var dateOfIncidentDescription = jQuery('#enrollmentDiv [name=programId] option:selected').attr('dateOfIncidentDescription'); - setInnerHTML('enrollmentDateDescription', dateOfEnrollmentDescription); - setInnerHTML('dateOfIncidentDescription', dateOfIncidentDescription); - - var displayIncidentDate = jQuery('#enrollmentDiv [name=programId] option:selected').attr('displayIncidentDate'); - if( displayIncidentDate=='true'){ - showById('dateOfIncidentTR'); - enable('dateOfIncident'); - } - else{ - hideById('dateOfIncidentTR'); - disable('dateOfIncident'); - } - } - var programId = jQuery('#programEnrollmentSelectDiv [id=programId] option:selected').val(); - jQuery('#identifierAndAttributeDiv').load("getPatientIdentifierAndAttribute.action", - { - id:programId - }, function(){ - showById('identifierAndAttributeDiv'); - }); - } -} - -function saveEnrollment( patientId, programId ) -{ - var patientId = jQuery('#enrollmentDiv [id=patientId]').val(); - var programId = jQuery('#enrollmentDiv [id=programId] option:selected').val(); - var programName = jQuery('#enrollmentDiv [id=programId] option:selected').text(); - var dateOfIncident = jQuery('#enrollmentDiv [id=dateOfIncidentField]').val(); - var enrollmentDate = jQuery('#enrollmentDiv [id=enrollmentDateField]').val(); - - jQuery.postJSON( "saveProgramEnrollment.action", - { - patientId: patientId, - programId: programId, - dateOfIncident: dateOfIncident, - enrollmentDate: enrollmentDate - }, - function( json ) - { - var programInstanceId = json.programInstanceId; - var programStageInstanceId = json.activeProgramStageInstanceId; - var programStageName = json.activeProgramStageName; - var dueDate = json.dueDate; - var type = jQuery('#enrollmentDiv [id=programId] option:selected').attr('programType'); - - var activedRow = "" - + " " - + " " - + "" - + programName + "(" + enrollmentDate + ")" - + ""; - - activedRow += "" - + "• " + programStageName + "(" + dueDate + ")"; - - jQuery('#activeTB' ).prepend(activedRow); - jQuery('#enrollmentDiv').dialog("close"); - saveIdentifierAndAttribute( patientId, programId,'identifierAndAttributeDiv' ); - loadProgramInstance( programInstanceId, false ); - showSuccessMessage(i18n_enrol_success); - }); -} - -// ---------------------------------------------------------------- -// Load program instance -// ---------------------------------------------------------------- - -function loadProgramInstance( programInstanceId, completed ) -{ - if( programInstanceId=='') { - hideById('programEnrollmentDiv'); - return; - } - 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 ); - if( completed ){ - hideById('newEncounterBtn_' + programInstanceId); - } - jQuery('#loaderDiv').hide(); - resize(); - }); -} - -// ---------------------------------------------------------------- -// Program enrollmment && unenrollment -// ---------------------------------------------------------------- - -function validateProgramEnrollment() -{ - jQuery('#loaderDiv').show(); - $.ajax({ - type: "GET", - url: 'validatePatientProgramEnrollment.action', - data: getParamsForDiv('programEnrollmentSelectDiv'), - success: function(json) { - hideById('message'); - var type = json.response; - if ( type == 'success' ){ - saveProgramEnrollment(); - } - else if ( type == 'error' ){ - setMessage( i18n_program_enrollment_failed + ':' + '\n' + message ); - } - else if ( type == 'input' ){ - setMessage( json.message ); - } - jQuery('#loaderDiv').hide(); - } - }); -} - -function saveProgramEnrollment() -{ - $.ajax({ - type: "POST", - url: 'saveProgramEnrollment.action', - data: getParamsForDiv('programEnrollmentSelectDiv'), - success: function( html ) { - setInnerHTML('programEnrollmentDiv', html ); - jQuery('#enrollBtn').attr('value',i18n_update); - showSuccessMessage( i18n_enrol_success ); - } - }); return false; } -function unenrollmentForm( programInstanceId ) -{ - $.ajax({ - type: "POST", - url: 'removeEnrollment.action', - data: "programInstanceId=" + programInstanceId, - success: function( json ) - { - jQuery('#completedList' ).append(''); - hideById('tr1_' + programInstanceId ); - hideById('tr2_' + programInstanceId ); - setInnerHTML('programEnrollmentDiv',''); - showSuccessMessage( i18n_unenrol_success ); - } - }); - - -} - -// ---------------------------------------------------------------- -// Identifiers && Attributes for selected program -// ---------------------------------------------------------------- - -function saveIdentifierAndAttribute( patientId, programId, paramsDiv) -{ - var params = getParamsForDiv(paramsDiv); - params += "&patientId=" + patientId; - params +="&programId=" + programId; - $.ajax({ - type: "POST", - url: 'savePatientIdentifierAndAttribute.action', - data: params, - success: function(json) - { - showSuccessMessage( i18n_save_success ); - } - }); -} - -// ---------------------------------------------------------------- -// Show selected data-recording -// ---------------------------------------------------------------- - -function showSelectedDataRecoding( patientId ) -{ - showLoader(); - hideById('searchDiv'); +// ---------------------------------------------------------------- +// Click Back to main form +// ---------------------------------------------------------------- + +function onClickBackBtn() +{ + showById('mainLinkLbl'); + showById('selectDiv'); + showById('searchDiv'); + showById('listPatientDiv'); + + hideById('editPatientDiv'); + hideById('enrollmentDiv'); + hideById('listRelationshipDiv'); + hideById('addRelationshipDiv'); + hideById('migrationPatientDiv'); + setInnerHTML('patientDashboard',''); +} + +function loadPatientList() +{ + hideById('editPatientDiv'); + hideById('enrollmentDiv'); + hideById('listRelationshipDiv'); + hideById('addRelationshipDiv'); + hideById('dataRecordingSelectDiv'); hideById('dataEntryFormDiv'); hideById('migrationPatientDiv'); - hideById('dataRecordingSelectDiv'); - - jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', - { - patientId: patientId - }, - function() - { - jQuery('#dataRecordingSelectDiv [id=backBtnFromEntry]').hide(); - showById('dataRecordingSelectDiv'); - - var programId = jQuery('#programEnrollmentSelectDiv [id=programId] option:selected').val(); - $('#dataRecordingSelectDiv [id=programId]').val( programId ); - $('#dataRecordingSelectDiv [id=inputCriteria]').hide(); - showById('dataRecordingSelectDiv'); + + showById('mainLinkLbl'); + showById('selectDiv'); + showById('searchDiv'); + + if( statusSearching == 0) + { + listAllPatient(); + } + else if( statusSearching == 1 ) + { + validateAdvancedSearch(); + } +} + +//------------------------------------------------------------------------------ +// Load data entry form +//------------------------------------------------------------------------------ + +function loadDataEntry( programStageInstanceId ) +{ + setInnerHTML('dataEntryFormDiv', ''); + showById('dataEntryFormDiv'); + showById('executionDateTB'); + showById('inputCriteriaDiv'); + setFieldValue( 'dueDate', '' ); + setFieldValue( 'executionDate', '' ); + disable('validationBtn'); + disableCompletedButton(true); + disable('uncompleteBtn'); + + jQuery(".stage-object-selected").removeClass('stage-object-selected'); + var selectedProgramStageInstance = jQuery( '#' + prefixId + programStageInstanceId ); + selectedProgramStageInstance.addClass('stage-object-selected'); + setFieldValue( 'programStageId', selectedProgramStageInstance.attr('psid') ); + + showLoader(); + $( '#dataEntryFormDiv' ).load( "dataentryform.action", + { + programStageInstanceId: programStageInstanceId + },function( ) + { + var executionDate = jQuery('#executionDate').val(); + var completed = jQuery('#entryFormContainer input[id=completed]').val(); + var irregular = jQuery('#entryFormContainer input[id=irregular]').val(); + var reportDateDes = jQuery("#ps_" + programStageInstanceId).attr("reportDateDes"); + setInnerHTML('reportDateDescriptionField',reportDateDes); + enable('validationBtn'); + if( executionDate == '' ) + { + disable('validationBtn'); + } + else if( executionDate != '' && completed == 'false' ) + { + disableCompletedButton(false); + } + else if( completed == 'true' ) + { + disableCompletedButton(true); + } + resize(); hideLoader(); - hideById('contentDiv'); - }); -} - -// ---------------------------------------------------------------- -// Patient Location -// ---------------------------------------------------------------- - -function getPatientLocation( patientId ) -{ - hideById('listPatientDiv'); - hideById('selectDiv'); - hideById('searchDiv'); - setInnerHTML('patientDashboard',''); - - jQuery('#loaderDiv').show(); - - jQuery('#migrationPatientDiv').load("getPatientLocation.action", - { - patientId: patientId - } - , function(){ - showById( 'migrationPatientDiv' ); - jQuery( "#loaderDiv" ).hide(); - }); -} - -function registerPatientLocation( patientId ) -{ - $.getJSON( 'registerPatientLocation.action',{ patientId:patientId } - , function( json ) - { - showPatientDashboardForm(patientId); - showSuccessMessage( i18n_save_success ); + hideById('contentDiv'); + jQuery('#dueDate').focus(); } ); } // ---------------------------------------------------------------- -// List program-stage-instance of selected program +// Cosmetic UI // ---------------------------------------------------------------- -function getVisitSchedule( programInstanceId ) -{ - $('#tab-3').load("getVisitSchedule.action", {programInstanceId:programInstanceId}); -} +function reloadOneRecord(){} === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patientForm.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patientForm.js 2012-09-24 05:02:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patientForm.js 1970-01-01 00:00:00 +0000 @@ -1,244 +0,0 @@ - -function organisationUnitSelected( orgUnits, orgUnitNames ) -{ - showById('selectDiv'); - showById('searchDiv'); - hideById('listPatientDiv'); - hideById('editPatientDiv'); - hideById('enrollmentDiv'); - hideById('listRelationshipDiv'); - hideById('addRelationshipDiv'); - hideById('migrationPatientDiv'); - hideById('patientDashboard'); - enable('listPatientBtn'); - enable('addPatientBtn'); - enable('advancedSearchBtn'); - setFieldValue("orgunitName", orgUnitNames[0]); -} - -selection.setListenerFunction( organisationUnitSelected ); - -// ----------------------------------------------------------------------------- -// List && Search patients -// ----------------------------------------------------------------------------- - -function listAllPatient() -{ - hideById('listPatientDiv'); - hideById('editPatientDiv'); - hideById('migrationPatientDiv'); - - jQuery('#loaderDiv').show(); - contentDiv = 'listPatientDiv'; - jQuery('#listPatientDiv').load('searchRegistrationPatient.action',{ - listAll:true - }, - function(){ - statusSearching = 0; - showById('listPatientDiv'); - jQuery('#loaderDiv').hide(); - }); - hideLoader(); -} - -function advancedSearch( params ) -{ - $.ajax({ - url: 'searchRegistrationPatient.action', - type:"POST", - data: params, - success: function( html ){ - statusSearching = 1; - setInnerHTML( 'listPatientDiv', html ); - showById('listPatientDiv'); - setFieldValue('listAll',false); - jQuery( "#loaderDiv" ).hide(); - } - }); -} - -// ----------------------------------------------------------------------------- -// Remove patient -// ----------------------------------------------------------------------------- - -function removePatient( patientId, fullName ) -{ - removeItem( patientId, fullName, i18n_confirm_delete, 'removePatient.action' ); -} - -// ----------------------------------------------------------------------------- -// Add Patient -// ----------------------------------------------------------------------------- - -function showAddPatientForm() -{ - hideById('listPatientDiv'); - hideById('selectDiv'); - hideById('searchDiv'); - hideById('migrationPatientDiv'); - - jQuery('#loaderDiv').show(); - jQuery('#editPatientDiv').load('showAddPatientForm.action' - , function() - { - showById('editPatientDiv'); - jQuery('#loaderDiv').hide(); - }); - -} - -function validateAddPatient() -{ - $("#patientForm :input").attr("disabled", true); - $.ajax({ - type: "POST", - url: 'validatePatient.action', - data: getParamsForDiv('patientForm'), - success:addValidationCompleted - }); -} - -function addValidationCompleted( data ) -{ - var type = jQuery(data).find('message').attr('type'); - var message = jQuery(data).find('message').text(); - - if ( type == 'success' ) - { - removeDisabledIdentifier( ); - addPatient(); - } - else - { - if ( type == 'error' ) - { - showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + message ); - } - else if ( type == 'input' ) - { - showWarningMessage( message ); - } - else if( type == 'duplicate' ) - { - showListPatientDuplicate(data, false); - } - - $("#patientForm :input").attr("disabled", false); - } -} - -function addPatient() -{ - $.ajax({ - type: "POST", - url: 'addPatient.action', - data: getParamsForDiv('patientForm'), - success: function(json) { - var patientId = json.message.split('_')[0]; - jQuery('#resultSearchDiv').dialog('close'); - showPatientDashboardForm( patientId ); - } - }); - return false; -} - -// ---------------------------------------------------------------- -// Click Back to main form -// ---------------------------------------------------------------- - -function onClickBackBtn() -{ - showById('mainLinkLbl'); - showById('selectDiv'); - showById('searchDiv'); - showById('listPatientDiv'); - - hideById('editPatientDiv'); - hideById('enrollmentDiv'); - hideById('listRelationshipDiv'); - hideById('addRelationshipDiv'); - hideById('migrationPatientDiv'); - setInnerHTML('patientDashboard',''); -} - -function loadPatientList() -{ - hideById('editPatientDiv'); - hideById('enrollmentDiv'); - hideById('listRelationshipDiv'); - hideById('addRelationshipDiv'); - hideById('dataRecordingSelectDiv'); - hideById('dataEntryFormDiv'); - hideById('migrationPatientDiv'); - - showById('mainLinkLbl'); - showById('selectDiv'); - showById('searchDiv'); - - if( statusSearching == 0) - { - listAllPatient(); - } - else if( statusSearching == 1 ) - { - validateAdvancedSearch(); - } -} - -//------------------------------------------------------------------------------ -// Load data entry form -//------------------------------------------------------------------------------ - -function loadDataEntry( programStageInstanceId ) -{ - setInnerHTML('dataEntryFormDiv', ''); - showById('dataEntryFormDiv'); - showById('executionDateTB'); - showById('inputCriteriaDiv'); - setFieldValue( 'dueDate', '' ); - setFieldValue( 'executionDate', '' ); - disable('validationBtn'); - disableCompletedButton(true); - disable('uncompleteBtn'); - - jQuery(".stage-object-selected").removeClass('stage-object-selected'); - var selectedProgramStageInstance = jQuery( '#' + prefixId + programStageInstanceId ); - selectedProgramStageInstance.addClass('stage-object-selected'); - setFieldValue( 'programStageId', selectedProgramStageInstance.attr('psid') ); - - showLoader(); - $( '#dataEntryFormDiv' ).load( "dataentryform.action", - { - programStageInstanceId: programStageInstanceId - },function( ) - { - var executionDate = jQuery('#executionDate').val(); - var completed = jQuery('#entryFormContainer input[id=completed]').val(); - var irregular = jQuery('#entryFormContainer input[id=irregular]').val(); - var reportDateDes = jQuery("#ps_" + programStageInstanceId).attr("reportDateDes"); - setInnerHTML('reportDateDescriptionField',reportDateDes); - enable('validationBtn'); - if( executionDate == '' ) - { - disable('validationBtn'); - } - else if( executionDate != '' && completed == 'false' ) - { - disableCompletedButton(false); - } - else if( completed == 'true' ) - { - disableCompletedButton(true); - } - resize(); - hideLoader(); - hideById('contentDiv'); - jQuery('#dueDate').focus(); - } ); -} - -// ---------------------------------------------------------------- -// Cosmetic UI -// ---------------------------------------------------------------- - -function reloadOneRecord(){} === 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-24 05:02:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js 2012-09-24 05:50:08 +0000 @@ -6,7 +6,6 @@ hideById('listEventDiv'); hideById('listEventDiv'); hideById('patientDashboard'); - hideById('patientProgramTrackingDiv'); hideById('smsManagementDiv'); hideById('sendSmsFormDiv'); hideById('editPatientDiv'); @@ -104,30 +103,12 @@ } // -------------------------------------------------------------------- -// Patient program tracking +// program tracking form // -------------------------------------------------------------------- -function showPatientProgramTracking(programInstanceId) -{ - hideById("listEventDiv"); - hideById("searchDiv"); - setInnerHTML("smsManagementDiv", ""); - showLoader(); - $( '#patientProgramTrackingDiv' ).load( "patientProgramTracking.action", - { - programInstanceId:programInstanceId - },function( ) - { - hideById('mainLinkLbl'); - showById('patientProgramTrackingDiv'); - hideLoader(); - }); -} - function getOutboundSmsList( programStageInstanceId, isSendSMS ) { setFieldValue('sendToList', "false"); - setInnerHTML('patientProgramTrackingDiv', ''); $('#smsManagementDiv' ).load("getOutboundSmsList.action", { programStageInstanceId: programStageInstanceId @@ -190,48 +171,6 @@ } } -function sendSmsOnePatient( field, programStageInstanceId ) -{ - setInnerHTML('smsError', ''); - if(field.value==""){ - field.style.backgroundColor = ERROR_COLOR; - jQuery('#smsError').css("color", "red"); - setInnerHTML('smsError', i18n_this_field_is_required); - return; - } - - field.style.backgroundColor = SAVING_COLOR; - programStageInstanceId = getFieldValue( 'programStageInstanceId' ); - jQuery.postUTF8( 'sendSMS.action', - { - programStageInstanceId: programStageInstanceId, - msg: field.value - }, function ( json ) - { - if ( json.response == "success" ) { - jQuery('#smsError').css("color", "green"); - setInnerHTML('smsError', json.message); - var currentTime = date.getHours() + ":" + date.getMinutes(); - jQuery('#commentTB').prepend("" + getFieldValue('currentDate') + " " + currentTime + "" - + "" + getFieldValue('programStageName') + "" - + "" + getFieldValue('currentUsername') + "" - + "" + field.value + ""); - var noMessage = eval( getInnerHTML('noMessageDiv_' + programStageInstanceId)) + 1; - } - else { - showErrorMessage( json.message, 7000 ); - } - - if( jQuery("#commentTB tr.hidden").length > 0 ){ - commentDivToggle(true); - } - else{ - commentDivToggle(false); - } - field.style.backgroundColor = SUCCESS_COLOR; - }); -} - function sendSmsToList() { params = getSearchParams(); @@ -258,31 +197,6 @@ }); } -function commentDivToggle(isHide) -{ - var index = 1; - jQuery("#commentTB tr").removeClass("hidden"); - jQuery("#commentTB tr").each( function(){ - if(isHide && index > 5){ - jQuery(this).addClass("hidden"); - } - else if(!isHide){ - jQuery(this).removeClass("hidden"); - } - index++; - }); - - if( isHide ){ - showById('showCommentBtn'); - hideById('hideCommentBtn'); - } - else - { - hideById('showCommentBtn'); - showById('hideCommentBtn'); - } -} - // -------------------------------------------------------------------- // Post Comments // -------------------------------------------------------------------- @@ -316,53 +230,6 @@ } } -function addComment( field, programStageInstanceId ) -{ - field.style.backgroundColor = SAVING_COLOR; - var commentText = field.value; - if( commentText == ''){ - field.style.backgroundColor = ERROR_COLOR; - return; - } - - jQuery.postUTF8( 'addPatientComment.action', - { - programStageInstanceId: programStageInstanceId, - commentText: commentText - }, function ( json ) - { - var programStageName = jQuery("#ps_" + programStageInstanceId).attr('programStageName'); - var date = new Date(); - var currentTime = date.getHours() + ":" + date.getMinutes(); - jQuery('#commentTB').prepend("" + getFieldValue("currentDate") + " " + currentTime + "" - + "" + programStageName + "" - + "" + getFieldValue('currentUsername') + "" - + "" + commentText + ""); - field.value=""; - showSuccessMessage( i18n_comment_added ); - field.style.backgroundColor = SUCCESS_COLOR; - - if( jQuery("#commentTB tr.hidden").length > 0 ){ - commentDivToggle(true); - } - else{ - commentDivToggle(false); - } - }); -} - -function removeComment( programStageInstanceId, commentId ) -{ - jQuery.postUTF8( 'removePatientComment.action', - { - programStageInstanceId:programStageInstanceId, - id: commentId - }, function ( json ) - { - showSuccessMessage( json.message ); - hideById( 'comment_' + commentId ); - } ); -} // -------------------------------------------------------------------- // Dashboard @@ -489,7 +356,6 @@ showById('migrationPatientDiv'); hideById('smsManagementDiv'); hideById('patientDashboard'); - hideById('patientProgramTrackingDiv'); if( eventList == 1){ listAllPatient(); === removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientProgramTracking.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientProgramTracking.vm 2012-09-24 05:02:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientProgramTracking.vm 1970-01-01 00:00:00 +0000 @@ -1,217 +0,0 @@ -

- $i18n.getString( 'program_tracking' ) - • $i18n.getString( 'patient_dashboard' ) - » $!programInstance.program.name -

- - - - - - - - - - - - - - - - - - - - - - - - - -
$i18n.getString("full_name")$!programInstance.patient.getFullName()
$i18n.getString("gender")$programInstance.patient.gender
$i18n.getString("date_of_birth")$format.formatDate( $!programInstance.patient.birthDate) $!programInstance.patient.getAge()
$i18n.getString("phone_number") - #if($!programInstance.patient.phoneNumber && $!programInstance.patient.phoneNumber!='') - $!programInstance.patient.phoneNumber - #else - [$i18n.getString('none')] - #end -
- -
- - - -
- - - - - - #set( $mark = true ) - #foreach ($identifierType in $identifierTypes) - #set( $identifier = '') - #set( $identifier = $identiferMap.get( $identifierType.id ) ) - #if($identifier) - - - - - #set( $mark = !$mark ) - #end - #end - - - #foreach ($attributeGroup in $attributeGroupsMap.keySet() ) - #set($attributes = $attributeGroupsMap.get($attributeGroup)) - #foreach($attribute in $attributes ) - #set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) ) - #if($attributeValue) - - - - - #set( $mark = !$mark ) - #end - #end - #end -
$i18n.getString("health_worker") - #if($!programInstance.patient.healthWorker ) - $!programInstance.patient.healthWorker.name - #else - [$i18n.getString('none')] - #end -
$identifierType.name$identifier
$attribute.name$attributeValue
-
- - -
-
- $i18n.getString("program") - - - - - - - - - -
$programInstance.program.dateOfEnrollmentDescription:
$programInstance.program.dateOfIncidentDescription:
-
-
- #if( $programStageInstances.size() > 0 ) - - - - - - - - - - - - - - - - - #set( $rowCount = 0 ) - #set( $mark = false ) - #foreach( $programStageInstance in $programStageInstances ) - #set( $rowCount = $rowCount + 1 ) - - ##rowCount - - ##stage name - - #set( $duedateId = "value_" + $programStageInstance.id + "_date" ) - #set($status = $statusMap.get( $programStageInstance.id )) - - - - - - #set( $mark = !$mark ) - #end -
$i18n.getString( "nr" )$i18n.getString( "program_stage" )$i18n.getString( "reschedule_due_date" )$i18n.getString( "status" )$i18n.getString( "message" )$i18n.getString( "remove" )
$rowCount - $encoder.htmlEncode( $programStageInstance.programStage.name ) - - - - - - - - - - - - #if($programStageInstance.programStage.irregular=='true' && ($status==3 || $status==4 || $status==5 )) - $i18n.getString( "remove" ) - #end -
- #end -
- - -
- #parse( "/dhis-web-caseentry/eventMessage.vm" ) -
- -
- -
- - === 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 2012-09-24 05:02:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm 2012-09-24 05:50:08 +0000 @@ -1,6 +1,3 @@ - - -