=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-06-14 13:07:22 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-06-23 11:05:13 +0000 @@ -94,5 +94,4 @@ Collection organisationUnits, int level, Date startDate, Date endDate ); List getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n ); - } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-06-20 08:18:00 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-06-23 11:05:13 +0000 @@ -292,13 +292,14 @@ return jdbcTemplate.queryForInt( sql ); } + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + private String getTabularReportSql( boolean count, ProgramStage programStage, List searchingKeys, Collection orgUnits, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder, Integer min, Integer max ) { - String sDate = DateUtils.getMediumDateString( startDate ); - String eDate = DateUtils.getMediumDateString( endDate ); - String selector = count ? "count(*) " : "* "; String sql = "select " + selector + "from ( select psi.programstageinstanceid, psi.executiondate,"; @@ -382,9 +383,16 @@ sql += "join _orgunitstructure ous on (psi.organisationunitid=ous.organisationunitid) "; sql += "where psi.programstageid=" + programStage.getId() + " "; - sql += "and psi.executiondate >= '" + sDate + "' "; - sql += "and psi.executiondate < '" + eDate + "' "; - + + if ( startDate != null && endDate != null ) + { + String sDate = DateUtils.getMediumDateString( startDate ); + String eDate = DateUtils.getMediumDateString( endDate ); + + sql += "and psi.executiondate >= '" + sDate + "' "; + sql += "and psi.executiondate < '" + eDate + "' "; + } + if ( orgUnits != null ) { sql += "and ou.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgUnits ) + ") "; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java 2012-06-07 04:23:40 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java 2012-06-23 11:05:13 +0000 @@ -32,8 +32,10 @@ import org.hisp.dhis.caseentry.state.SelectedStateManager; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageInstance; import org.hisp.dhis.program.ProgramStageInstanceService; @@ -51,14 +53,21 @@ // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- - + private SelectedStateManager selectedStateManager; public void setSelectedStateManager( SelectedStateManager selectedStateManager ) { this.selectedStateManager = selectedStateManager; } - + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + private ProgramInstanceService programInstanceService; public void setProgramInstanceService( ProgramInstanceService programInstanceService ) @@ -86,17 +95,16 @@ { this.i18n = i18n; } - + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- - - private Integer programInstanceId; - - public void setProgramInstanceId( Integer programInstanceId ) + private Integer programId; + + public void setProgramId( Integer programId ) { - this.programInstanceId = programInstanceId; + this.programId = programId; } public String executionDate; @@ -123,9 +131,15 @@ { Date date = format.parseDate( executionDate ); - if ( date != null ) - { - ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId ); + if ( date == null ) + { + message = i18n.getString( "please_enter_report_date" ); + } + else + { + Program program = programService.getProgram( programId ); + + ProgramInstance programInstance = programInstanceService.getProgramInstances( program ).iterator().next(); ProgramStageInstance programStageInstance = new ProgramStageInstance(); programStageInstance.setProgramInstance( programInstance ); @@ -139,14 +153,10 @@ programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() ); int id = programStageInstanceService.addProgramStageInstance( programStageInstance ); - + message = id + ""; - - return SUCCESS; } - message = i18n.getString("please_enter_report_date"); - - return INPUT; + return (date != null) ? SUCCESS : INPUT; } } === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramStageDataElementsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramStageDataElementsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramStageDataElementsAction.java 2012-06-23 11:05:13 +0000 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2004-2012, 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.caseentry; + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramStageService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $GetProgramStageDataElementsAction.java Jun 21, 2012 9:43:56 PM$ + */ +public class GetProgramStageDataElementsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramStageService programStageService; + + public void setProgramStageService( ProgramStageService programStageService ) + { + this.programStageService = programStageService; + } + + // ------------------------------------------------------------------------- + // Input/Output + // ------------------------------------------------------------------------- + + private Integer programStageId; + + public void setProgramStageId( Integer programStageId ) + { + this.programStageId = programStageId; + } + + private List programStageDataElements; + + public List getProgramStageDataElements() + { + return programStageDataElements; + } + + // ------------------------------------------------------------------------- + // Implementation Action + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + programStageDataElements = new ArrayList( programStageService.getProgramStage( + programStageId ).getProgramStageDataElements() ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadAnonymousProgramsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadAnonymousProgramsAction.java 2012-05-23 15:02:50 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadAnonymousProgramsAction.java 2012-06-23 11:05:13 +0000 @@ -27,14 +27,14 @@ package org.hisp.dhis.caseentry.action.caseentry; -import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitLevel; +import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramInstance; -import org.hisp.dhis.program.ProgramInstanceService; import org.hisp.dhis.program.ProgramService; import com.opensymphony.xwork2.Action; @@ -58,6 +58,13 @@ this.selectionManager = selectionManager; } + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + private ProgramService programService; public void setProgramService( ProgramService programService ) @@ -65,22 +72,29 @@ this.programService = programService; } - private ProgramInstanceService programInstanceService; - - public void setProgramInstanceService( ProgramInstanceService programInstanceService ) - { - this.programInstanceService = programInstanceService; - } - // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- - private Collection programInstances = new ArrayList(); - - public Collection getProgramInstances() - { - return programInstances; + private OrganisationUnit orgunit; + + public OrganisationUnit getOrgunit() + { + return orgunit; + } + + private Collection programs; + + public Collection getPrograms() + { + return programs; + } + + private List levels; + + public List getLevels() + { + return levels; } // ------------------------------------------------------------------------- @@ -90,17 +104,11 @@ public String execute() throws Exception { - OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit(); - - if ( orgunit != null ) - { - Collection programs = programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION, orgunit ); - - if ( programs != null && programs.size() > 0 ) - { - programInstances = programInstanceService.getProgramInstances( programs ); - } - } + orgunit = selectionManager.getSelectedOrganisationUnit(); + + programs = programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION, orgunit ); + + levels = organisationUnitService.getFilledOrganisationUnitLevels(); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2012-06-14 04:41:08 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2012-06-23 11:05:13 +0000 @@ -170,12 +170,7 @@ programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId ); program = programStageInstance.getProgramStage().getProgram(); - - if ( !program.isRegistration() && programStageInstance.isCompleted() ) - { - return SUCCESS; - } - + selectedStateManager.setSelectedProgramStageInstance( programStageInstance ); // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveCurrentEncounterAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveCurrentEncounterAction.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/RemoveCurrentEncounterAction.java 2012-06-23 11:05:13 +0000 @@ -57,11 +57,11 @@ // Input // ------------------------------------------------------------------------- - private int programStageInstanceId; + private int id; - public void setProgramStageInstanceId( int programStageInstanceId ) + public void setId( int id ) { - this.programStageInstanceId = programStageInstanceId; + this.id = id; } private I18n i18n; @@ -91,7 +91,7 @@ { try { - ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId ); + ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( id ); programStageInstanceService.deleteProgramStageInstance( programStageInstance ); } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RegisterPatientLocationAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RegisterPatientLocationAction.java 2012-03-27 14:19:09 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RegisterPatientLocationAction.java 2012-06-23 11:05:13 +0000 @@ -61,7 +61,7 @@ } // ------------------------------------------------------------------------- - // Action implementation + // Setter // ------------------------------------------------------------------------- private Integer patientId; === 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-06-15 04:41:31 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-06-23 11:05:13 +0000 @@ -367,8 +367,8 @@ scope="prototype"> + - + + + + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-06-18 07:02:55 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-06-23 11:05:13 +0000 @@ -65,7 +65,7 @@ intro_visit_plan=View the visit plan to get an overview of outstanding, pending and completed visits. other_facility=Private facility error_required_field=Please enter value for all data element in red color. -complete_confirm_message=Are you sure this Program stage is completed ? You can not change its data after it is completed. +complete_confirm_message=Are you sure this event is completed ? complete=Complete data entry case_aggregation_form=Person aggregation form dataset_list=Dataset List @@ -218,13 +218,13 @@ representative_info=Representative's information relationship_for=Relationship for date_of_edit=Date of edit -anonymous_events=Anonymous events -intro_anonymous_events=Register anonymous events. The data to register is defined by a single event anonymous program. +anonymous_events=Single events without registration +intro_anonymous_events=Register Single events without registration. The data to register is defined by a single event without registration program. create_new_event=Create new event delete_current_event=Delete current event -delete_current_event_success=Delete current event successfully +delete_event_success=Delete event successfully please_enter_report_date=Please enter report date -comfirm_delete_current_event=Are you sure you want to delete the current event? +comfirm_delete_event=Are you sure you want to delete the event? registered_by_orgunit=Registered by facility event_information=Event information history_events=History events @@ -361,3 +361,7 @@ set_as_representative_and_copy_attributes_for_the_person = Set as representative and copy attributes for the person is_not_representative = Is not representative ? save_all = Save all +list_all_events = List All Events +search_events_by_dataelements = Search events by data elements +list_all_events = List all events +specify_data_element = Please specify a data element \ No newline at end of file === 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-06-18 08:38:51 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-06-23 11:05:13 +0000 @@ -151,6 +151,18 @@ /dhis-web-caseentry/jsonOptions.vm + + /dhis-web-caseentry/jsonProgramStageDataElements.vm + + + + /content.vm + /dhis-web-caseentry/programStageInstancesList.vm + F_NAME_BASED_DATA_ENTRY + + $i18n.getString( "anonymous_events" ) + + +

$i18n.getString( "anonymous_events" ) #openHelp( "patient" )

+ + + + -
- - - -
- -
- - - - - - - - - - - - -
$i18n.getString('program') - -
- -
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ $i18n.getString("program") * + + + + +
 
$i18n.getString('use_data_from_level') + $i18n.getString('selected') + $i18n.getString('children_only') + $i18n.getString('all') +
$i18n.getString('show_hierachy_from_level') + #foreach( $level in $levels ) + $level.name + #end + +
$i18n.getString('report_date') + $i18n.getString('to')   + +
$i18n.getString('data_elements') + + + + + + + + +
+ + + +
+
+
#parse( "dhis-web-commons/loader/loader.vm" ) -
+
+ + + + \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-06-18 09:40:23 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2012-06-23 11:05:13 +0000 @@ -82,7 +82,7 @@ - #elseif($hasOptionSet) + #elseif($hasOptionSet=='true') #else === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2012-06-15 04:55:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2012-06-23 11:05:13 +0000 @@ -1,87 +1,265 @@ -function organisationUnitSelected( orgUnits ) +function organisationUnitSelected( orgUnits, orgUnitNames ) { - hideById('dataEntryFormDiv'); - disable( 'executionDate' ); - setFieldValue('executionDate', ''); - $('#executionDate').unbind('change'); - - disable('createEventBtn'); - disable('deleteCurrentEventBtn'); - - $.getJSON( 'loadAnonymousPrograms.action',{} - , function( json ) - { - clearListById( 'programId' ); - addOptionById( 'programId', '', i18n_please_select ); - - var preSelectedProgramId = getFieldValue('selectedProgramId'); - for ( i in json.programInstances ) - { - if( preSelectedProgramId == json.programInstances[i].id ) - { - $('#programId').append(''); - } - else - { - $('#programId').append(''); - } - } - - if( byId('programId').selectedIndex > 0 ) - { - loadEventForm(); - } - } ); + setFieldValue( 'orgunitId', orgUnits[0] ); + setFieldValue( 'orgunitName', orgUnitNames[0] ); + hideById('listDiv'); + hideById('dataEntryInfor'); } selection.setListenerFunction( organisationUnitSelected ); - -function loadEventForm() +function getDataElements() +{ + hideById('dataEntryInfor'); + hideById('listDiv'); + clearListById('dataElementId'); + programStageId = jQuery('#programId option:selected').attr('programStageId'); + setFieldValue('programStageId', programStageId ); + + if( programStageId == '') + { + removeAllAttributeOption(); + jQuery('#criteriaDiv :input').each( function( idx, item ){ + disable(this.id); + }); + enable('orgunitName'); + enable('programId'); + hideById('listDiv'); + setFieldValue('searchText'); + return; + } + + jQuery.getJSON( "getProgramStageDataElementList.action", + { + programStageId: getFieldValue('programStageId') + }, + function( json ) + { + jQuery( '#dataElementId').append( '' ); + for ( i in json.programStageDataElements ) { + jQuery( '#dataElementId').append( '' ); + + if( json.programStageDataElements[i].compulsory=='true' ){ + jQuery( '#compulsoryDE').append( ''); + } + } + + jQuery('#criteriaDiv :input').each( function( idx, item ){ + enable(this.id); + }); + }); +} + +function removeAllAttributeOption() +{ + jQuery( '#advancedSearchTB tbody tr' ).each( function( i, item ) + { + if(i>0){ + jQuery( item ).remove(); + } + }) +} + +function validateSearchEvents( listAll ) { - hideById('dataEntryFormDiv'); - setFieldValue('executionDate', ''); - disable( 'executionDate' ); - disable('createEventBtn'); - disable('deleteCurrentEventBtn'); + var flag = true; + if( listAll && jQuery( '#compulsoryDE option' ).length == 0 ){ + flag = false; + } + else if( !listAll ) + { + jQuery( '#advancedSearchTB tbody tr' ).each( function( i, row ){ + jQuery( this ).find(':input').each( function( idx, item ){ + var input = jQuery( item ); + if( input.attr('type') != 'button' && idx==0 && input.val()=='' ){ + showWarningMessage( i18n_specify_data_element ); + flag = false; + } + }) + }); + } + + if(flag){ + searchEvents( listAll ); + } +} + +function searchEvents( listAll ) +{ + hideById('dataEntryInfor'); + hideById('listDiv'); - var programId = getFieldValue('programId'); - if( programId == '' ) - { - $('#executionDate').unbind('change'); - return; - } - - showLoader(); - - jQuery.getJSON( "loadProgramStageInstances.action", - { - programId: programId + var params = ''; + if(listAll){ + params += '&startDate='; + params += '&endDate='; + jQuery( '#compulsoryDE option' ).each( function( i, item ){ + var input = jQuery( item ); + params += '&searchingValues=de_' + input.val() + '_false_'; + }); + } + else{ + params += '&startDate=' + getFieldValue('startDate'); + params += '&endDate=' + getFieldValue('endDate'); + jQuery( '#advancedSearchTB tbody tr' ).each( function(){ + var searchingValue = ''; + jQuery( this ).find(':input').each( function( idx, item ){ + var input = jQuery( item ); + if( input.attr('type') != 'button' ){ + if( idx==0 && input.val()!=''){ + searchingValue = 'de_' + input.val() + '_false_'; + } + else if( input.val()!='' ){ + searchingValue += getValueFormula(input.val().toLowerCase()); + } + } + }); + params += '&searchingValues=' + searchingValue; + }) + } + + + + params += '&facilityLB=' + $('input[name=facilityLB]:checked').val(); + params += '&level=' + $('input[name=level]:checked').val(); + params += '&orgunitIds=' + getFieldValue('orgunitId'); + params += '&programStageId=' + getFieldValue('programStageId'); + params += '&orderByOrgunitAsc=' + true; + + contentDiv = 'listDiv'; + showLoader(); + + $.ajax({ + type: "POST", + url: 'searchProgramStageInstances.action', + data: params, + success: function( html ){ + hideById('loaderDiv'); + hideById('dataEntryInfor'); + setInnerHTML( 'listDiv', html ); + showById('listDiv'); + } + }); +} + +function getValueFormula( value ) +{ + if( value.indexOf('"') != value.lastIndexOf('"') ) + { + value = value.replace(/"/g,"'"); + } + // if key is [xyz] && [=xyz] + if( value.indexOf("'")==-1 ){ + var flag = value.match(/[>|>=|<|<=|=|!=]+[ ]*/); + + if( flag == null ) + { + value = "='"+ value + "'"; + } + else + { + value = value.replace( flag, flag + "'"); + value += "'"; + } + } + // if key is ['xyz'] && [='xyz'] + // if( value.indexOf("'") != value.lastIndexOf("'") ) + else + { + var flag = value.match(/[>|>=|<|<=|=|!=]+[ ]*/); + + if( flag == null ) + { + value = "="+ value; + } + } + + return value; +} + +function removeEvent( psId ) +{ + removeItem( psId, '', i18n_comfirm_delete_event, 'removeCurrentEncounter.action' ); +} + +function showUpdateEvent( psId ) +{ + hideById('selectDiv'); + hideById('searchDiv'); + hideById('listDiv'); + setFieldValue('programStageInstanceId', psId); + showLoader(); + + $( '#dataEntryFormDiv' ).load( "dataentryform.action", + { + programStageInstanceId: psId + },function( ) + { + var programName = jQuery('#programId option:selected').text(); + programName += ' - ' + i18n_report_date + ' : ' + jQuery('#incidentDate').val(); + + setInnerHTML('programName', programName ); + + if( getFieldValue('completed')=='true' ){ + disable('completeBtn'); + } + else{ + enable('completeBtn'); + } + + hideById('loaderDiv'); + showById('dataEntryInfor'); + showById('entryFormContainer'); + } ); +} + +function backEventList() +{ + hideById('dataEntryInfor'); + showById('selectDiv'); + showById('searchDiv'); + showById('listDiv'); +} + +function showAddEventForm() +{ + jQuery.postJSON( "createAnonymousEncounter.action", + { + programId: jQuery('#programId option:selected').val(), + executionDate: getFieldValue('executionDateNewEvent') }, function( json ) { - if( json.programStageInstances.length > 0 ) + if(json.response=='success') { - setFieldValue( 'programStageInstanceId', json.programStageInstances[0].id ); - setFieldValue( 'selectedProgramId', programId ); - $('#executionDate').bind('change'); - loadEventRegistrationForm(); + setFieldValue('programStageInstanceId', json.message ); + showUpdateEvent( json.message ) } else { - enable( 'executionDate' ); - enable('createEventBtn'); - disable('deleteCurrentEventBtn'); - disable('completeBtn'); - hideById('loaderDiv'); + showWarningMessage( json.message ); } - - }); + }); } + + + + + + + + + + + function loadEventRegistrationForm() { + hideById('selectDiv'); + hideById('searchDiv'); + hideById('listDiv'); + showLoader(); $( '#dataEntryFormDiv' ).load( "dataentryform.action", { programStageInstanceId:getFieldValue('programStageInstanceId') @@ -121,6 +299,55 @@ } ); } + + + + + + + +function loadEventForm() +{ + hideById('dataEntryFormDiv'); + setFieldValue('executionDate', ''); + disable( 'executionDate' ); + disable('createEventBtn'); + disable('deleteCurrentEventBtn'); + + var programId = getFieldValue('programId'); + if( programId == '' ) + { + $('#executionDate').unbind('change'); + return; + } + + showLoader(); + + jQuery.getJSON( "loadProgramStageInstances.action", + { + programId: programId + }, + function( json ) + { + if( json.programStageInstances.length > 0 ) + { + setFieldValue( 'programStageInstanceId', json.programStageInstances[0].id ); + setFieldValue( 'selectedProgramId', programId ); + $('#executionDate').bind('change'); + loadEventRegistrationForm(); + } + else + { + enable( 'executionDate' ); + enable('createEventBtn'); + disable('deleteCurrentEventBtn'); + disable('completeBtn'); + hideById('loaderDiv'); + } + + }); +} + function createNewEvent() { jQuery.postJSON( "createAnonymousEncounter.action", @@ -150,40 +377,3 @@ }); } -function deleteCurrentEvent() -{ - var result = window.confirm( i18n_comfirm_delete_current_event ); - - if ( result ) - { - jQuery.postJSON( "removeCurrentEncounter.action", - { - programStageInstanceId: getFieldValue('programStageInstanceId') - }, - function( json ) - { - var type = json.response; - - if( type == 'success' ) - { - hideById('dataEntryFormDiv'); - byId('programId').selectedIndex = 0; - - disable('deleteCurrentEventBtn'); - enable('createEventBtn'); - - setFieldValue('executionDate',''); - enable( 'executionDate' ); - $('#executionDate').unbind('change'); - - selection.enable(); - - showSuccessMessage( i18n_delete_current_event_success ); - } - else if( type == 'input' ) - { - showWarningMessage( json.message ); - } - }); - } -} === 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-06-20 06:32:51 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-06-23 11:05:13 +0000 @@ -619,16 +619,24 @@ var flag = false; jQuery("#dataEntryFormDiv input[name='entryfield'],select[name='entryselect']").each(function(){ jQuery(this).parent().removeClass("errorCell"); - if( jQuery(this).metadata({ - "type":"attr", - "name":"data" - }).compulsory ){ - if( !jQuery(this).val() || jQuery(this).val() == "undifined" ){ + + var arrData = jQuery( this ).attr('data').replace('{','').replace('}','').replace(/'/g,"").split(','); + var data = new Array(); + for( var i in arrData ) + { + var values = arrData[i].split(':'); + var key = jQuery.trim( values[0] ); + var value = jQuery.trim( values[1] ) + data[key] = value; + } + var compulsory = data['compulsory']; + if( compulsory == 'true' && + ( !jQuery(this).val() || jQuery(this).val() == "undifined" ) ){ flag = true; jQuery(this).parent().addClass("errorCell"); } - } }); + if( flag ){ alert(i18n_error_required_field); return; === 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-06-20 09:46:37 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-06-23 11:05:13 +0000 @@ -38,8 +38,7 @@ jQuery('#listPatientDiv').load("searchRegistrationPatient.action", { sortPatientAttributeId: getFieldValue('sortPatientAttributeId') - } - , function(){ + }, function(){ showById('listPatientDiv'); jQuery( "#loaderDiv" ).hide(); }); @@ -57,7 +56,7 @@ url: 'validatePatient.action', data: getParamsForDiv('editPatientDiv'), success:addValidationCompleted - }); + }); } function addValidationCompleted( data ) @@ -632,7 +631,7 @@ } else if( statusSearching == 1 ) { - searchAdvancedPatients(); + searchAdvancedPatient(); } } === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageDataElements.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageDataElements.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageDataElements.vm 2012-06-23 11:05:13 +0000 @@ -0,0 +1,11 @@ +#set( $size = ${programStageDataElements.size()} ) +{ "programStageDataElements": [ + #foreach( ${programStageDataElement} in $!{programStageDataElements} ) + { + "id": "${programStageDataElement.dataElement.id}", + "name": "$!encoder.jsonEncode( ${programStageDataElement.dataElement.name} )", + "compulsory": "${programStageDataElement.compulsory}" + }#if( $velocityCount < $size ),#end + #end + ] +} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2012-06-14 03:58:46 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2012-06-23 11:05:13 +0000 @@ -48,8 +48,8 @@ - - + + === added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm 2012-06-23 11:05:13 +0000 @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + +
$i18n.getString( "search_result_matching_the_search_criteria" ):   + #if($!listAll) + $i18n.getString( "list_all_events" ) + #else + $i18n.getString( "search_events_by_dataelements" ) + #end +
$i18n.getString( "total_result" )  $!total
+ + + + + + + #set( $noCol = $grid.getHeaders().size() + 3 ) + + + +
+ + + + + #set($index = 0) + #foreach( $col in $grid.getHeaders() ) + #if( $index > 0 ) + + #end + #set($index = $index + 1) + #end + + + + + + #set($noCols = $grid.getHeaders().size()) + #foreach( $row in $grid.getRows() ) + #set($index = 0) + + + + #foreach( $col in $row ) + #if( $index == 0 ) + #set($psid = $col) + #elseif( $index < $noCols ) + + #end + #set($index = $index + 1) + #end + + + #set( $mark = !$mark) + + + #end + +
#$col.name$i18n.getString( "operations" )
+ #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount ) + $nr + $!col + $i18n.getString( "edit_profile" ) + $i18n.getString( "remove" ) +
+
+

+
+ #parse( "/dhis-web-commons/paging/paging.vm" ) +
+
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css 2012-06-20 06:32:51 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css 2012-06-23 11:05:13 +0000 @@ -15,14 +15,13 @@ } input[type="text"] { - width: 250px; + width: 255px; } select { - width: 253px; + width: 265px; } - .button-list { text-align:right; @@ -67,6 +66,8 @@ text-align: left; } +.errorCell{background-color: #FFCFCF} + /*----------------------------------------------------------------------------*/ /* button list /*----------------------------------------------------------------------------*/ @@ -78,7 +79,6 @@ width:100%; } - div.actions { float: right; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm 2012-06-14 13:19:46 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm 2012-06-23 11:05:13 +0000 @@ -99,8 +99,8 @@ - - + +