dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13293
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4212: Improve Search patient function ( Patient module ).
------------------------------------------------------------
revno: 4212
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-07-27 10:07:45 +0700
message:
Improve Search patient function ( Patient module ).
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java
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/patientattributevalue/DefaultPatientAttributeValueService.java
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/resources/org/hisp/dhis/caseentry/i18n_module.properties
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/javascript/dataEntry.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-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<PatientAttributeValue> getAllPatientAttributeValues();
Map<Integer, Collection<PatientAttributeValue>> getPatientAttributeValueMapForPatients( Collection<Patient> patients );
+
+ Map<Integer, PatientAttributeValue> getPatientAttributeValueMapForPatients( Collection<Patient> patients, PatientAttribute patientAttribute );
Collection<PatientAttributeValue> 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<Patient> sortPatientsByAttribute( Collection<Patient> patients, PatientAttribute patientAttribute )
{
- SortedMap<String, Patient> patientsSortedByAttribute = new TreeMap<String, Patient>();
+ List<PatientAttributeValue> patientsSortedByAttribute = new ArrayList<PatientAttributeValue>();
- Set<Patient> sortedPatients = new HashSet<Patient>();
+ Collection<Patient> sortedPatients = new ArrayList<Patient>();
// ---------------------------------------------------------------------
// 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<Patient> 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<Integer, PatientAttributeValue> getPatientAttributeValueMapForPatients( Collection<Patient> patients,
+ PatientAttribute patientAttribute )
+ {
+ Map<Integer, PatientAttributeValue> attributeValueMap = new HashMap<Integer, PatientAttributeValue>();
+
+ Collection<PatientAttributeValue> patientAttributeValues = getPatientAttributeValues( patients );
+
+ if ( patientAttributeValues != null )
+ {
+ for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
+ {
+ if ( patientAttributeValue.getPatientAttribute() == patientAttribute )
+ {
+ attributeValueMap.put( patientAttributeValue.getPatient().getId(), patientAttributeValue );
+ }
+ }
+ }
+
+ return attributeValueMap;
+ }
+
public Collection<PatientAttributeValue> 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<Patient, PatientAttributeValue> patinetAttributeValueMap = new HashMap<Patient, PatientAttributeValue>();
+ private Map<Integer, PatientAttributeValue> patientAttributeValueMap = new HashMap<Integer, PatientAttributeValue>();
- public Map<Patient, PatientAttributeValue> getPatinetAttributeValueMap()
+ public Map<Integer, PatientAttributeValue> getPatientAttributeValueMap()
{
- return patinetAttributeValueMap;
+ return patientAttributeValueMap;
}
Collection<Patient> patientListByOrgUnit;
@@ -220,8 +220,6 @@
// Program instances for the selected program
// ---------------------------------------------------------------------
- Collection<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
-
total = patientService.countGetPatientsByOrgUnitProgram( organisationUnit, program );
this.paging = createPaging( total );
@@ -229,6 +227,14 @@
patientListByOrgUnit = new ArrayList<Patient>( patientService.getPatients( organisationUnit, program, paging
.getStartPos(), paging.getPageSize() ) );
+ if ( sortPatientAttribute != null )
+ {
+ patientAttributeValueMap = patientAttributeValueService.getPatientAttributeValueMapForPatients(
+ patientListByOrgUnit, sortPatientAttribute );
+ }
+
+ Collection<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
+
for ( Patient patient : patientListByOrgUnit )
{
Collection<ProgramInstance> _programInstances = programInstanceService.getProgramInstances( patient,
@@ -246,11 +252,6 @@
programInstances.add( programInstance );
- PatientAttributeValue patientAttributeValue = patientAttributeValueService
- .getPatientAttributeValue( patient, sortPatientAttribute );
-
- patinetAttributeValueMap.put( patient, patientAttributeValue );
-
List<ProgramStageInstance> programStageInstanceList = new ArrayList<ProgramStageInstance>(
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 @@
<table class="mainPageTable">
<tr>
<td style="vertical-align:top">
- <table class="listTable">
+ <table class="listTable" id="patientList">
+ <col>
#if( $sortPatientAttribute )
<col>
#end
#foreach( $programStage in $program.programStages )
<col>
- #end
- <tr>
- #if( $sortPatientAttribute )
- <th style="text-align:center">$encoder.htmlEncode( $sortPatientAttribute.name )</th>
- #end
- <th style="text-align:center">$i18n.getString( "full_name" )</th>
- #foreach( $programStage in $program.programStages )
- <th style="text-align:center">$encoder.htmlEncode( $programStage.name )</th>
- #end
- </tr>
-
+ #end
+ <thead>
+ <tr>
+ <th>#</th>
+ #if( $sortPatientAttribute )
+ <th style="text-align:center">$encoder.htmlEncode( $sortPatientAttribute.name )</th>
+ #end
+ <th style="text-align:center">$i18n.getString( "full_name" )</th>
+ #foreach( $programStage in $program.programStages )
+ <th style="text-align:center" class="{sorter: false}">$encoder.htmlEncode( $programStage.name )</th>
+ #end
+ </tr>
+ </thead>
<tbody id="list">
#set( $mark = false )
#foreach( $patient in $patientListByOrgUnit )
#set( $programInstance = $programInstanceMap.get( $patient ) )
- <tr #alternate( $mark )>
+ <tr #alternate( $mark )>
+ <td>
+ #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount )
+ $nr
+ </td>
#if( $sortPatientAttribute )
- #set( $patientAttributeValue = $patinetAttributeValueMap.get( $patient ) )
- <td>$!patientAttributeValue.value</td>
+ <td>$!patientAttributeValueMap.get( $patient.id ).value</td>
#end
- <td><a href="javascript:showPatientDetails( $programInstance.patient.id )" title="$i18n.getString( "show_details" )">$patient.getFullName()</a></td>
+ <td><a href="javascript:showPatientDetails( $programInstance.patient.id )" title="$i18n.getString( 'show_details' )">$patient.getFullName()</a></td>
#foreach( $programStageInstance in $programStageInstanceMap.get( $programInstance ) )
#if( $programStageInstance.executionDate )
<td style="text-align:center" bgcolor="$colorMap.get( $programStageInstance.id )">
@@ -65,3 +71,9 @@
<p><label>$i18n.getString( "attributes" ):</label><br><span id="attributeField"></span></p>
<p><label>$i18n.getString( "enrolled_in_program" ):</label><br><span id="programField"></span></p>
</div>
+
+<script>
+ jQuery(document).ready(function(){
+ tableSorter( 'patientList' );
+ });
+</script>
=== 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();
});
}