=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java 2010-10-29 05:24:41 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java 2011-07-27 03:07:45 +0000 @@ -62,6 +62,8 @@ Collection getAllPatientAttributeValues(); Map> getPatientAttributeValueMapForPatients( Collection patients ); + + Map getPatientAttributeValueMapForPatients( Collection patients, PatientAttribute patientAttribute ); Collection searchPatientAttributeValue( PatientAttribute patientAttribute, String searchText ); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2011-05-26 03:43:41 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2011-07-27 03:07:45 +0000 @@ -30,12 +30,11 @@ import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; import org.apache.commons.lang.StringUtils; import org.hisp.dhis.i18n.I18nFormat; @@ -332,9 +331,9 @@ @Override public Collection sortPatientsByAttribute( Collection patients, PatientAttribute patientAttribute ) { - SortedMap patientsSortedByAttribute = new TreeMap(); + List patientsSortedByAttribute = new ArrayList(); - Set sortedPatients = new HashSet(); + Collection sortedPatients = new ArrayList(); // --------------------------------------------------------------------- // Better to fetch all attribute values at once than fetching the @@ -345,14 +344,12 @@ .getPatientAttributeValues( patients ); if ( patientAttributeValues != null ) - { + { for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) { if ( patientAttribute == patientAttributeValue.getPatientAttribute() ) { - patientsSortedByAttribute.put( patientAttributeValue.getValue() + "-" - + patientAttributeValue.getPatient().getFullName() + "-" - + patientAttributeValue.getPatient().getId(), patientAttributeValue.getPatient() ); + patientsSortedByAttribute.add( patientAttributeValue ); } } } @@ -361,19 +358,15 @@ // Make sure all patients are in the sorted list - because all // patients might not have the sorting attribute/value // --------------------------------------------------------------------- - - for ( Patient patient : patientsSortedByAttribute.values() ) - { - sortedPatients.add( patient ); - } - - for ( Patient patient : patients ) - { - if ( !sortedPatients.contains( patient ) ) - { - sortedPatients.add( patient ); - } - } + + for( PatientAttributeValue patientAttributeValue : patientsSortedByAttribute ) + { + sortedPatients.add( patientAttributeValue.getPatient() ); + } + + patients.removeAll( patientsSortedByAttribute ); + + sortedPatients.addAll( patients ); return sortedPatients; } @@ -383,7 +376,7 @@ { return patientStore.getByNames( name.toLowerCase() ); } - + @Override public Collection getPatientsByNames( String name, int min, int max ) { @@ -477,7 +470,7 @@ { return patientStore.countGetPatientsByOrgUnitProgram( organisationUnit, program ); } - + @Override public Object getObjectValue( String property, String value, I18nFormat format ) { === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java 2011-03-31 01:55:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java 2011-07-27 03:07:45 +0000 @@ -164,6 +164,27 @@ return patentAttributeValueMap; } + public Map getPatientAttributeValueMapForPatients( Collection patients, + PatientAttribute patientAttribute ) + { + Map attributeValueMap = new HashMap(); + + Collection patientAttributeValues = getPatientAttributeValues( patients ); + + if ( patientAttributeValues != null ) + { + for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) + { + if ( patientAttributeValue.getPatientAttribute() == patientAttribute ) + { + attributeValueMap.put( patientAttributeValue.getPatient().getId(), patientAttributeValue ); + } + } + } + + return attributeValueMap; + } + public Collection searchPatientAttributeValue( PatientAttribute patientAttribute, String searchText ) { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java 2011-05-20 09:23:01 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java 2011-07-27 03:07:45 +0000 @@ -175,11 +175,11 @@ return programInstanceMap; } - private Map patinetAttributeValueMap = new HashMap(); + private Map patientAttributeValueMap = new HashMap(); - public Map getPatinetAttributeValueMap() + public Map getPatientAttributeValueMap() { - return patinetAttributeValueMap; + return patientAttributeValueMap; } Collection patientListByOrgUnit; @@ -220,8 +220,6 @@ // Program instances for the selected program // --------------------------------------------------------------------- - Collection programStageInstances = new ArrayList(); - total = patientService.countGetPatientsByOrgUnitProgram( organisationUnit, program ); this.paging = createPaging( total ); @@ -229,6 +227,14 @@ patientListByOrgUnit = new ArrayList( patientService.getPatients( organisationUnit, program, paging .getStartPos(), paging.getPageSize() ) ); + if ( sortPatientAttribute != null ) + { + patientAttributeValueMap = patientAttributeValueService.getPatientAttributeValueMapForPatients( + patientListByOrgUnit, sortPatientAttribute ); + } + + Collection programStageInstances = new ArrayList(); + for ( Patient patient : patientListByOrgUnit ) { Collection _programInstances = programInstanceService.getProgramInstances( patient, @@ -246,11 +252,6 @@ programInstances.add( programInstance ); - PatientAttributeValue patientAttributeValue = patientAttributeValueService - .getPatientAttributeValue( patient, sortPatientAttribute ); - - patinetAttributeValueMap.put( patient, patientAttributeValue ); - List programStageInstanceList = new ArrayList( programInstance.getProgramStageInstances() ); Collections.sort( programStageInstanceList, new ProgramStageInstanceComparator() ); @@ -261,15 +262,6 @@ } } - // --------------------------------------------------------------------- - // Sorting PatientList by selected Patient Attribute - // --------------------------------------------------------------------- - - if ( sortPatientAttributeId != null ) - { - patientListByOrgUnit = patientService.sortPatientsByAttribute( patientListByOrgUnit, sortPatientAttribute ); - } - colorMap = programStageInstanceService.colorProgramStageInstances( programStageInstances ); return SUCCESS; === 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 2011-07-15 08:07:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-07-27 03:07:45 +0000 @@ -309,4 +309,5 @@ program_validation_description = Program Validation Description please_select_village = Please select village select_sorting_attribute = Select a specfied attribute / ALL -no_result = No result \ No newline at end of file +no_result = No result +filter_by = Filter by === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm 2011-05-20 09:23:01 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataentryRecords.vm 2011-07-27 03:07:45 +0000 @@ -1,33 +1,39 @@
- +
+ #if( $sortPatientAttribute ) #end #foreach( $programStage in $program.programStages ) - #end - - #if( $sortPatientAttribute ) - - #end - - #foreach( $programStage in $program.programStages ) - - #end - - + #end + + + + #if( $sortPatientAttribute ) + + #end + + #foreach( $programStage in $program.programStages ) + + #end + + #set( $mark = false ) #foreach( $patient in $patientListByOrgUnit ) #set( $programInstance = $programInstanceMap.get( $patient ) ) - + + #if( $sortPatientAttribute ) - #set( $patientAttributeValue = $patinetAttributeValueMap.get( $patient ) ) - + #end - + #foreach( $programStageInstance in $programStageInstanceMap.get( $programInstance ) ) #if( $programStageInstance.executionDate )
$encoder.htmlEncode( $sortPatientAttribute.name )$i18n.getString( "full_name" )$encoder.htmlEncode( $programStage.name )
#$encoder.htmlEncode( $sortPatientAttribute.name )$i18n.getString( "full_name" )$encoder.htmlEncode( $programStage.name )
+ #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount ) + $nr + $!patientAttributeValue.value$!patientAttributeValueMap.get( $patient.id ).value$patient.getFullName()$patient.getFullName() @@ -65,3 +71,9 @@



+ + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js 2011-07-25 06:49:16 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js 2011-07-27 03:07:45 +0000 @@ -1031,6 +1031,7 @@ function selectProgram() { + setInnerHTML('listPatient', ''); if( getFieldValue('programId') == 0 ) { hideById('listPatient'); @@ -1038,14 +1039,16 @@ } contentDiv = 'listPatient'; + showLoader(); jQuery('#listPatient').load("getDataRecords.action", { programId:getFieldValue('programId'), sortPatientAttributeId: getFieldValue('patientAttributeId') }, - function( ) + function() { showById("listPatient"); + hideLoader(); }); }