dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07189
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2032: Attribute wise sorting in patient module
------------------------------------------------------------
revno: 2032
committer: Namrata
branch nick: trunk
timestamp: Wed 2010-09-01 14:02:05 +0530
message:
Attribute wise sorting in patient module
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.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/patient/hibernate/HibernatePatientIdentifierStore.java
dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientStoreTest.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/paging.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm
--
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/patient/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2010-06-29 13:33:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2010-09-01 08:32:05 +0000
@@ -66,6 +66,8 @@
Collection<Patient> getPatientsByOrgUnit( OrganisationUnit organisationUnit, int min, int max );
+ Collection<Patient> getPatientsByOrgUnitAttr( OrganisationUnit organisationUnit, int min, int max , PatientAttribute patientAttribute);
+
int countGetPatientsByOrgUnit( OrganisationUnit organisationUnit );
Collection<Patient> getPatients( OrganisationUnit organisationUnit, String searchText, int min, int max );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java 2010-05-06 13:24:03 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientIdentifierService.java 2010-09-01 08:32:05 +0000
@@ -182,6 +182,7 @@
return patientIdentifierStore.listPatientByOrganisationUnit( organisationUnit, min, max );
}
+
public PatientIdentifier get( PatientIdentifierType type, String identifier )
{
return patientIdentifierStore.get( type, identifier );
=== 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 2010-06-29 13:33:33 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2010-09-01 08:32:05 +0000
@@ -187,9 +187,21 @@
public Collection<Patient> getPatientsByOrgUnit( OrganisationUnit organisationUnit, int min, int max )
{
+ //List<Patient> patientList = (ArrayList<Patient>) patientIdentifierService.listPatientByOrganisationUnit( organisationUnit );
return patientIdentifierService.listPatientByOrganisationUnit( organisationUnit , min, max );
}
+ public Collection<Patient> getPatientsByOrgUnitAttr( OrganisationUnit organisationUnit, int min, int max , PatientAttribute patientAttribute)
+ {
+ List<Patient> patientList = (ArrayList<Patient>) patientIdentifierService.listPatientByOrganisationUnit( organisationUnit );
+ if(patientAttribute != null)
+ {
+ List<Patient> sortedPatientList = (ArrayList<Patient>) sortPatientsByAttribute(patientList, patientAttribute);
+ return sortedPatientList.subList(min, max);
+ }
+ return patientList.subList(min, max);
+ }
+
public Collection<Patient> sortPatientsByAttribute( Collection<Patient> patients, PatientAttribute patientAttribute )
{
SortedMap<String, Patient> patientsSortedByAttribute = new TreeMap<String, Patient>();
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2010-06-23 19:59:35 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2010-09-01 08:32:05 +0000
@@ -28,6 +28,7 @@
package org.hisp.dhis.patient.hibernate;
import java.util.Collection;
+import java.util.List;
import org.hibernate.Query;
import org.hibernate.criterion.Projections;
@@ -35,6 +36,7 @@
import org.hisp.dhis.hibernate.HibernateGenericStore;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
import org.hisp.dhis.patient.PatientIdentifier;
import org.hisp.dhis.patient.PatientIdentifierStore;
import org.hisp.dhis.patient.PatientIdentifierType;
@@ -104,9 +106,15 @@
@SuppressWarnings( "unchecked" )
public Collection<Patient> listPatientByOrganisationUnit( OrganisationUnit organisationUnit, int min, int max )
{
+
+ String hql = "select distinct p from Patient p join p.identifiers i where i.organisationUnit = :organisationUnit order by p.id";
+ return getQuery( hql ).setEntity( "organisationUnit", organisationUnit ).setFirstResult( min ).setMaxResults( max ).list();
+
+ /*
return (Collection<Patient>) getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) )
- .setProjection( Projections.distinct( Projections.property( "patient" ) ) ).setFirstResult( min ).setMaxResults( max ).list();
+ .setProjection( Projections.distinct( Projections.property( "patient" ) ) ).setFirstResult( min ).setMaxResults( max ).list();*/
}
+
public Patient getPatient( PatientIdentifierType idenType, String value )
{
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientStoreTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientStoreTest.java 2010-02-22 13:47:05 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientStoreTest.java 2010-09-01 08:32:05 +0000
@@ -33,6 +33,9 @@
import static junit.framework.Assert.assertNull;
import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.organisationunit.OrganisationUnitStore;
import org.junit.Test;
/**
@@ -43,17 +46,28 @@
extends DhisSpringTest
{
private PatientStore patientStore;
+ private PatientIdentifierStore patientIdentifierStore;
+ private OrganisationUnitService organisationUnitService;
private Patient patientA;
private Patient patientB;
-
+ private OrganisationUnit organisationUnit;
+
@Override
public void setUpTest()
{
patientStore = (PatientStore) getBean( PatientStore.ID );
+ patientIdentifierStore = (PatientIdentifierStore) getBean ( PatientIdentifierStore.ID );
+ organisationUnitService = (OrganisationUnitService) getBean ( OrganisationUnitService.ID );
+
+ organisationUnit = createOrganisationUnit( 'A' );
+
+ organisationUnitService.addOrganisationUnit( organisationUnit );
patientA = createPatient( 'A' );
- patientB = createPatient( 'B' );
+ patientB = createPatient( 'B' );
+
+
}
@Test
@@ -61,10 +75,21 @@
{
int idA = patientStore.save( patientA );
int idB = patientStore.save( patientB );
+ patientIdentifierStore.listPatientByOrganisationUnit(organisationUnit, idB, idB);
assertEquals( patientA.getFirstName(), patientStore.get( idA ).getFirstName() );
assertEquals( patientB.getFirstName(), patientStore.get( idB ).getFirstName() );
}
+
+ @Test
+ public void addGetbyOu()
+ {
+ int idA = patientStore.save( patientA );
+ int idB = patientStore.save( patientB );
+
+ assertEquals( patientA.getFirstName(), patientStore.get( idA ).getFirstName() );
+ assertEquals( patientB.getFirstName(), patientStore.get( idB ).getFirstName() );
+ }
@Test
public void delete()
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java 2010-06-23 19:59:35 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java 2010-09-01 08:32:05 +0000
@@ -47,6 +47,7 @@
import org.hisp.dhis.relationship.RelationshipService;
import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
/**
* @author Abyot Asalefew Gizaw
@@ -171,7 +172,7 @@
this.pageSize = pageSize;
}
- private Integer defaultPageSize = 50;
+ private Integer defaultPageSize = 4;
public void setDefaultPageSize( Integer defaultPageSize )
{
@@ -199,17 +200,48 @@
return mapRelationShip;
}
+ public Integer sortPatientAttributeId;
+
+ public Integer getSortPatientAttributeId() {
+ return sortPatientAttributeId;
+ }
+
+ public void setSortPatientAttributeId(Integer sortPatientAttributeId) {
+ this.sortPatientAttributeId = sortPatientAttributeId;
+ }
+
+ private Map<Patient,String> mapPatientPatientAttr = new HashMap<Patient,String>();
+
+ public Map<Patient, String> getMapPatientPatientAttr() {
+ return mapPatientPatientAttr;
+ }
+
+ public void setMapPatientPatientAttr(Map<Patient, String> mapPatientPatientAttr) {
+ this.mapPatientPatientAttr = mapPatientPatientAttr;
+ }
+
+ PatientAttribute patientAttribute;
+
+ public PatientAttribute getPatientAttribute() {
+ return patientAttribute;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
public String execute()
- throws Exception
+ throws Exception
{
// ---------------------------------------------------------------------
// Validate selected OrganisationUnit
// ---------------------------------------------------------------------
-
+ if(sortPatientAttributeId!=null)
+ {
+
+ patientAttribute = patientAttributeService.getPatientAttribute(sortPatientAttributeId);
+
+ }
organisationUnit = selectionManager.getSelectedOrganisationUnit();
patientAttributes = patientAttributeService.getAllPatientAttributes();
@@ -220,23 +252,36 @@
selectedStateManager.clearSearchingAttributeId();
selectedStateManager.clearSearchTest();
-
-
+ //System.out.println(" listAll ");
pagingUtil = new PagingUtil( RequestUtil.getCurrentLink(ServletActionContext.getRequest()) + "?listAll=true", pageSize == null ? defaultPageSize : pageSize );
pagingUtil.setCurrentPage( currentPage == null ? 0 : currentPage );
total = patientService.countGetPatientsByOrgUnit( organisationUnit );
-
+ // System.out.println("total = "+total);
pagingUtil.setTotal( total );
-
- patients = patientService.getPatientsByOrgUnit( organisationUnit , pagingUtil.getStartPos(), pagingUtil.getPageSize() );
-
+
+ int numberOfPages = pagingUtil.getNumberOfPages();//2
+ int pageSize = pagingUtil.getPageSize();//4
+ int startPos = pagingUtil.getStartPos();//0,4
+ int endPos = ( startPos + pageSize > total ) ? total : ( startPos + pageSize );//4,7
+
+ //System.out.println("listAll startPos "+ startPos+" endPos "+ endPos );
+ patients = patientService.getPatientsByOrgUnitAttr( organisationUnit , startPos,endPos, patientAttribute );
if( patients != null && patients.size() > 0 )
{
+ //System.out.println("patients size = "+patients.size());
+ /*f(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ patients = patientService.sortPatientsByAttribute(patients, patientAttribute);
+ }*/
for( Patient patient : patients )
{
mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+ }
}
}
@@ -253,7 +298,7 @@
selectedStateManager.setSearchText( searchText );
PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( searchingAttributeId );
-
+ //System.out.println(" searchingAttributeId != null && searchText != null ");
pagingUtil = new PagingUtil( RequestUtil.getCurrentLink(ServletActionContext.getRequest())
+ "?searchingAttributeId=" + searchingAttributeId + "&searchText=" + searchText
, pageSize == null ? defaultPageSize : pageSize );
@@ -263,15 +308,23 @@
total = patientAttributeValueService.countSearchPatientAttributeValue( patientAttribute, searchText );
pagingUtil.setTotal( total );
-
+ //System.out.println(" searchingAttributeId != null && searchText != null ");
patients = patientAttributeValueService.searchPatientAttributeValue(
patientAttribute, searchText, pagingUtil.getStartPos(), pagingUtil.getPageSize() );
if( patients != null && patients.size() > 0 )
{
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ patients = patientService.sortPatientsByAttribute(patients, patientAttribute);
+ }
for( Patient patient : patients )
{
mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+ }
}
}
@@ -284,7 +337,7 @@
selectedStateManager.clearSearchingAttributeId();
selectedStateManager.setSearchText( searchText );
-
+ //System.out.println(" searchingAttributeId == null && searchText != null ");
pagingUtil = new PagingUtil( RequestUtil.getCurrentLink(ServletActionContext.getRequest()) + "?searchText=" + searchText, pageSize == null ? defaultPageSize : pageSize );
pagingUtil.setCurrentPage( currentPage == null ? 0 : currentPage );
@@ -297,9 +350,16 @@
if( patients != null && patients.size() > 0 )
{
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ patients = patientService.sortPatientsByAttribute(patients, patientAttribute);
+ }
for( Patient patient : patients )
{
- mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+ }
}
}
@@ -314,7 +374,7 @@
selectedStateManager.clearSearchingAttributeId();
selectedStateManager.clearSearchTest();
-
+ //System.out.println(" second listAll ");
pagingUtil = new PagingUtil( RequestUtil.getCurrentLink(ServletActionContext.getRequest()), pageSize == null ? defaultPageSize : pageSize );
pagingUtil.setCurrentPage( currentPage == null ? 0 : currentPage );
@@ -327,9 +387,17 @@
if( patients != null && patients.size() > 0 )
{
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ patients = patientService.sortPatientsByAttribute(patients, patientAttribute);
+ }
for( Patient patient : patients )
{
mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+ }
}
}
@@ -345,7 +413,7 @@
if ( searchingAttributeId != null && searchText != null )
{
PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( searchingAttributeId );
-
+ //System.out.println(" second searchingAttributeId != null && searchText != null ");
pagingUtil = new PagingUtil( RequestUtil.getCurrentLink(ServletActionContext.getRequest())
+ "?searchingAttributeId=" + searchingAttributeId + "&searchText=" + searchText
, pageSize == null ? defaultPageSize : pageSize );
@@ -355,20 +423,27 @@
total = patientAttributeValueService.countSearchPatientAttributeValue( patientAttribute, searchText );
pagingUtil.setTotal( total );
-
+ //System.out.println("pageSize = "+pageSize == null ? defaultPageSize : pageSize);
patients = patientAttributeValueService.searchPatientAttributeValue(
patientAttribute, searchText, pagingUtil.getStartPos(), pagingUtil.getPageSize() );
if( patients != null && patients.size() > 0 )
{
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ patients = patientService.sortPatientsByAttribute(patients, patientAttribute);
+ }
for( Patient patient : patients )
{
- mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+ }
}
}
}
-
+ //System.out.println(" inside class ");
pagingUtil = new PagingUtil( RequestUtil.getCurrentLink(ServletActionContext.getRequest()) + "?searchText=" + searchText, pageSize == null ? defaultPageSize : pageSize );
pagingUtil.setCurrentPage( currentPage == null ? 0 : currentPage );
@@ -376,14 +451,22 @@
total = patientService.countGetPatients( searchText );
pagingUtil.setTotal( total );
-
+
patients = patientService.getPatients( searchText, pagingUtil.getStartPos(), pagingUtil.getPageSize() );
if( patients != null && patients.size() > 0 )
{
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ patients = patientService.sortPatientsByAttribute(patients, patientAttribute);
+ }
for( Patient patient : patients )
{
mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
+ if(sortPatientAttributeId!=null && patientAttribute!=null)
+ {
+ mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+ }
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java 2009-10-27 17:39:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java 2010-09-01 08:32:05 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.patient.PatientAttributeService;
import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.patient.paging.PagingUtil;
/**
* @author Abyot Asalefew Gizaw
@@ -80,6 +81,35 @@
return patientAttributes;
}
+ private Integer currentPage;
+
+ public void setCurrentPage( Integer currentPage )
+ {
+ this.currentPage = currentPage;
+ }
+
+ private Integer pageSize;
+
+ public void setPageSize( Integer pageSize )
+ {
+ this.pageSize = pageSize;
+ }
+
+ private Integer defaultPageSize = 4;
+
+ public void setDefaultPageSize( Integer defaultPageSize )
+ {
+ this.defaultPageSize = defaultPageSize;
+ }
+
+ private PagingUtil pagingUtil;
+
+ public PagingUtil getPagingUtil()
+ {
+ return pagingUtil;
+ }
+
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2010-07-16 10:26:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2010-09-01 08:32:05 +0000
@@ -23,6 +23,7 @@
return true;
}
+
//------------------------------------------------------------------------------
// Validate EnrollmentDate
//------------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm 2010-07-13 16:35:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm 2010-09-01 08:32:05 +0000
@@ -6,7 +6,9 @@
#set ($sText = "" )
#end
-<style>
+
+
+<style>
tr.relationship-row{background-color: #BFFFC2; display : none}
</style>
@@ -38,6 +40,9 @@
<td style="vertical-align:top">
<table class="listTable">
<col>
+ #if($mapPatientPatientAttr.size()!=0)
+ <col>
+ #end
<col>
<col>
<col>
@@ -64,7 +69,10 @@
<input type="button" value="$i18n.getString( "cancel" )" onclick="window.location.href='patient.action'" style="width:10em">
</td>
<tr>
- <th>#</th>
+ <th>#</th>
+ #if($mapPatientPatientAttr.size()!=0)
+ <th>$patientAttribute.name</th>
+ #end
<th>$i18n.getString( "first_name" )</th>
<th>$i18n.getString( "middle_name" )</th>
<th>$i18n.getString( "last_name" )</th>
@@ -80,30 +88,36 @@
#foreach( $patient in $patients )
##set( $mark = !$mark)
<tr #alternate( $mark )>
- <td>
- #set( $nr = ( ( $pagingUtil.currentPage - 1 ) * $pagingUtil.pageSize ) + $velocityCount )
- $nr
- </td>
- <td>
- $encoder.htmlEncode( $patient.firstName )
- </td>
- <td>
- $encoder.htmlEncode( $patient.middleName )
- </td>
- <td>
- $encoder.htmlEncode( $patient.lastName )
- </td>
- <td>
- $encoder.htmlEncode( $patient.gender )
- </td>
- <td>
- $format.formatDate( $patient.birthDate )
- </td>
- <td>
+ <td>
+ #set( $nr = ( ( $pagingUtil.currentPage - 1 ) * $pagingUtil.pageSize ) + $velocityCount )
+ $nr
+ </td>
+ #if($mapPatientPatientAttr.size()!=0)
+ <td>
+ $mapPatientPatientAttr.get($patient)
+ </td>
+ #end
+
+ <td>
+ $encoder.htmlEncode( $patient.firstName )
+ </td>
+ <td>
+ $encoder.htmlEncode( $patient.middleName )
+ </td>
+ <td>
+ $encoder.htmlEncode( $patient.lastName )
+ </td>
+ <td>
+ $encoder.htmlEncode( $patient.gender )
+ </td>
+ <td>
+ $format.formatDate( $patient.birthDate )
+ </td>
+ <td>
$encoder.htmlEncode( $patient.getAge() )
</td>
- <td style="text-align:center"#alternate( $mark )>
+ <td style="text-align:center"#alternate( $mark )>
<a href="showProgramEnrollmentForm.action?id=$patient.id" title="$i18n.getString( "manage_program_enrollment" )"><img src="../images/enroll.png" alt="$i18n.getString( "manage_program_enrollment" )"></a>
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/paging.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/paging.vm 2010-03-09 12:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/paging.vm 2010-09-01 08:32:05 +0000
@@ -18,8 +18,14 @@
<div class="paging">
#if ($currentPage > 1)
#set ( $prev = $currentPage - 1 )
- <a href="${baseLink}currentPage=1&pageSize=${pageSize}" class="first" title="First">««</a>
- <a href="${baseLink}currentPage=${prev}&pageSize=${pageSize}" class="prev" title="Previous">«</a>
+ #if($mapPatientPatientAttr.size()!=0)
+ <a href="${baseLink}currentPage=1&pageSize=${pageSize}&sortPatientAttributeId=$patientAttribute.id" class="first" title="First">««</a>
+ <a href="${baseLink}currentPage=${prev}&pageSize=${pageSize}&sortPatientAttributeId=$patientAttribute.id" class="prev" title="Previous">«</a>
+ #else
+ <a href="${baseLink}currentPage=1&pageSize=${pageSize}" class="first" title="First">««</a>
+ <a href="${baseLink}currentPage=${prev}&pageSize=${pageSize}" class="prev" title="Previous">«</a>
+ #end
+
#else
<span class="first" title="First">««</span>
<span class="prev" title="Previous">«</span>
@@ -32,7 +38,11 @@
<span class="seperator">|</span>
#end
#if( $p != $currentPage )
+ #if($mapPatientPatientAttr.size()!=0)
+ <a href="${baseLink}currentPage=${p}&pageSize=${pageSize}&sortPatientAttributeId=$patientAttribute.id" class="page" title="Page $p">$p</a>
+ #else
<a href="${baseLink}currentPage=${p}&pageSize=${pageSize}" class="page" title="Page $p">$p</a>
+ #end
#else
<span class="page" title="Page $p">$p</span>
#end
@@ -41,8 +51,13 @@
#if ( $currentPage < $numberOfPages )
#set ( $next = $currentPage + 1 )
- <a href="${baseLink}currentPage=${next}&pageSize=${pageSize}" class="next" title="Next">»</a>
- <a href="${baseLink}currentPage=${numberOfPages}&pageSize=${pageSize}" class="last" title="Last">»»</a>
+ #if($mapPatientPatientAttr.size()!=0)
+ <a href="${baseLink}currentPage=${next}&pageSize=${pageSize}&sortPatientAttributeId=$patientAttribute.id" class="next" title="Next">»</a>
+ <a href="${baseLink}currentPage=${numberOfPages}&pageSize=${pageSize}&sortPatientAttributeId=$patientAttribute.id" class="last" title="Last">»»</a>
+ #else
+ <a href="${baseLink}currentPage=${next}&pageSize=${pageSize}" class="next" title="Next">»</a>
+ <a href="${baseLink}currentPage=${numberOfPages}&pageSize=${pageSize}" class="last" title="Last">»»</a>
+ #end
#else
<span class="next" title="Next">» </span>
<span class="last" title="Last">»»</span>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm 2009-11-14 14:29:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm 2010-09-01 08:32:05 +0000
@@ -6,8 +6,19 @@
<td><label>$i18n.getString( "registering_unit" )</label></td>
<td><input type="text" readonly="readonly" #if( $organisationUnit ) value="$encoder.htmlEncode( $organisationUnit.name )" #else value="[$i18n.getString( "please_select_village" )]" #end style="min-width:350px"></td>
<td> </td>
- <td><input type="button" value="$i18n.getString( "list_all_patients" )" onclick="window.location.href='listAllPatients.action'"></td>
- </tr>
+ <td><input type="button" value="$i18n.getString( "list_all_patients" )" onclick="window.location.href='listAllPatients.action'"></td>
+ </tr>
+ <tr>
+ <td align="right"><label>$i18n.getString( "sort_by" )</label></td>
+ <td>
+ <select id="patientAttributeId" name="patientAttributeId" style="min-width:350px" onchange="javascript:selectPatientAttribute()" #if( $programs.size() == 0 ) disabled="disabled" #end>
+ <option value="0">[$i18n.getString( "select" )]</option>
+ #foreach( $patientAttribute in $patientAttributes )
+ <option value="$patientAttribute.id" #if( $sortPatientAttributeId && $patientAttribute.id == $sortPatientAttributeId ) selected="selected" #end>$encoder.htmlEncode( $patientAttribute.name )</option>
+ #end
+ </select>
+ </td>
+ </tr>
</table>
<hr style="clear:both">
@@ -42,4 +53,13 @@
<script type="text/javascript">
var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ) , "'")';
+
+ function selectPatientAttribute()
+ {
+
+ var patientAttributeLB = document.getElementById('patientAttributeId');
+ var patientAttributeId = patientAttributeLB.options[patientAttributeLB.selectedIndex].value;
+
+ window.location.href='listAllPatients.action?sortPatientAttributeId='+patientAttributeId;
+ }
</script>
\ No newline at end of file