← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7298: Hide columns in Tabular report.

 

------------------------------------------------------------
revno: 7298
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-06-14 20:07:22 +0700
message:
  Hide columns in Tabular report.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  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/relationship/DefaultRelationshipService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java
  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/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.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/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-06-07 04:23:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-06-14 13:07:22 +0000
@@ -32,13 +32,10 @@
 import java.util.Map;
 
 import org.hisp.dhis.common.Grid;
-import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientIdentifierType;
 
 /**
  * @author Abyot Asalefew
@@ -67,7 +64,7 @@
     Collection<ProgramStageInstance> getProgramStageInstances( Date dueDate, Boolean completed );
 
     Collection<ProgramStageInstance> getProgramStageInstances( Date startDate, Date endDate );
-    
+
     Collection<ProgramStageInstance> getProgramStageInstances( Date startDate, Date endDate, Boolean completed );
 
     Collection<ProgramStageInstance> getAllProgramStageInstances();
@@ -88,18 +85,14 @@
     List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed );
 
     List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed );
-    
-    Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols, 
-        List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
-        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> organisationUnits,
-        int level, Date startDate, Date endDate, boolean descOrder, Integer min, Integer max );
-    
-    int getTabularReportCount( ProgramStage programStage, List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
-        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> organisationUnits,
-        int level, Date startDate, Date endDate );
-    
+
+    Grid getTabularReport( ProgramStage programStage, List<String> searchingKeys,
+        Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder, Integer min,
+        Integer max );
+
+    int getTabularReportCount( ProgramStage programStage, List<String> searchingKeys,
+        Collection<Integer> organisationUnits, int level, Date startDate, Date endDate );
+
     List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n );
-    
+
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-05-28 09:46:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-06-14 13:07:22 +0000
@@ -33,12 +33,9 @@
 
 import org.hisp.dhis.common.GenericStore;
 import org.hisp.dhis.common.Grid;
-import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientIdentifierType;
 
 /**
  * @author Abyot Asalefew
@@ -76,14 +73,10 @@
     
     List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
     
-    Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
-        List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
-        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> orgUnits,
-        int level, int maxLevel, Date startDate, Date endDate, boolean descOrder, Integer min, Integer max );
+    Grid getTabularReport( ProgramStage programStage, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
+        Collection<Integer> orgUnits, List<String> searchingKeys, int level, int maxLevel, Date startDate,
+        Date endDate, boolean descOrder, Integer min, Integer max );
     
-    int getTabularReportCount( ProgramStage programStage, List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
-        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> orgUnits,
-        int level, int maxLevel, Date startDate, Date endDate );
+    int getTabularReportCount( ProgramStage programStage, List<String> searchingKeys,
+        Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipService.java	2009-11-12 11:27:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipService.java	2012-06-14 13:07:22 +0000
@@ -47,6 +47,8 @@
     Relationship getRelationship( int id );
     
     Relationship getRelationship( Patient patientA, Patient patientB, RelationshipType relationshipType );
+    
+    Relationship getRelationship( Patient patientA, Patient patientB );
 
     Collection<Relationship> getAllRelationships();
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipStore.java	2009-11-20 07:45:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipStore.java	2012-06-14 13:07:22 +0000
@@ -38,10 +38,11 @@
 public interface RelationshipStore
     extends GenericStore<Relationship>
 {
-
     String ID = RelationshipStore.class.getName();
 
     Relationship get( Patient patientA, Patient patientB, RelationshipType relationshipType );
+    
+    Relationship get( Patient patientA, Patient patientB );
 
     Collection<Relationship> get( Patient patientA, RelationshipType relationshipType );
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-06-07 04:23:40 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-06-14 13:07:22 +0000
@@ -43,8 +43,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.system.grid.ListGrid;
@@ -197,31 +195,27 @@
         return programStageInstanceStore.get( patient, completed );
     }
 
-    public Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols, 
-        List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
-        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> organisationUnits,
-        int level, Date startDate, Date endDate, boolean descOrder, Integer min, Integer max )
+    public Grid getTabularReport( ProgramStage programStage, List<String> searchingKeys,
+        Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder, Integer min,
+        Integer max )
     {
         int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
-        
+
         Map<Integer, OrganisationUnitLevel> orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap();
-        
-        return programStageInstanceStore.getTabularReport( programStage, hiddenCols, orgUnitLevelMap, identifiers, fixedAttributes, attributes, 
-            dataElements, identifierKeys, attributeKeys, dataElementKeys, organisationUnits, level, maxLevel, startDate, endDate, descOrder, min, max );
+
+        return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits,
+            searchingKeys, level, maxLevel, startDate, endDate, descOrder, min, max );
     }
-    
-    public int getTabularReportCount( ProgramStage programStage, List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
-        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> organisationUnits,
-        int level, Date startDate, Date endDate )
+
+    public int getTabularReportCount( ProgramStage programStage, List<String> searchingKeys,
+        Collection<Integer> organisationUnits, int level, Date startDate, Date endDate )
     {
         int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
-        
-        return programStageInstanceStore.getTabularReportCount( programStage, identifiers, fixedAttributes, attributes, 
-            dataElements, identifierKeys, attributeKeys, dataElementKeys, organisationUnits, level, maxLevel, startDate, endDate );
+
+        return programStageInstanceStore.getTabularReportCount( programStage, searchingKeys, organisationUnits, level,
+            maxLevel, startDate, endDate );
     }
-    
+
     public List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n )
     {
         List<Grid> grids = new ArrayList<Grid>();

=== 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-07 13:09:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-06-14 13:07:22 +0000
@@ -26,6 +26,12 @@
  */
 package org.hisp.dhis.program.hibernate;
 
+import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_DATA_ELEMENT;
+import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_FIXED_ATTRIBUTE;
+import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_IDENTIFIER_TYPE;
+import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE;
+import static org.hisp.dhis.system.util.TextUtils.lower;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
@@ -39,14 +45,14 @@
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
-import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.hibernate.HibernateGenericStore;
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
@@ -58,8 +64,6 @@
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.support.rowset.SqlRowSet;
 
-import static org.hisp.dhis.system.util.TextUtils.*;
-
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -88,6 +92,27 @@
         this.statementBuilder = statementBuilder;
     }
 
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
     // -------------------------------------------------------------------------
     // Implemented methods
     // -------------------------------------------------------------------------
@@ -196,17 +221,13 @@
             .setFirstResult( min ).setMaxResults( max ).list();
     }
 
-    public Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols,
-        Map<Integer, OrganisationUnitLevel> orgUnitLevelMap, List<PatientIdentifierType> identifiers,
-        List<String> fixedAttributes, List<PatientAttribute> attributes, List<DataElement> dataElements,
-        Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys, Map<Integer, String> dataElementKeys,
-        Collection<Integer> orgUnits, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
-        Integer min, Integer max )
+    public Grid getTabularReport( ProgramStage programStage, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
+        Collection<Integer> orgUnits, List<String> searchingKeys, int level, int maxLevel, Date startDate,
+        Date endDate, boolean descOrder, Integer min, Integer max )
     {
         Grid grid = new ListGrid();
 
         grid.addHeader( new GridHeader( "id", true, true ) );
-
         grid.addHeader( new GridHeader( "Report date", false, true ) );
 
         // TODO hidden cols
@@ -215,32 +236,45 @@
         {
             int l = i + 1;
             String name = orgUnitLevelMap.containsKey( l ) ? orgUnitLevelMap.get( l ).getName() : "Level " + l;
+
             grid.addHeader( new GridHeader( name, false, true ) );
         }
 
-        for ( PatientIdentifierType type : identifiers )
-        {
-            grid.addHeader( new GridHeader( type.getName(), false, true ) );
-        }
-
-        for ( String attribute : fixedAttributes )
-        {
-            grid.addHeader( new GridHeader( attribute, false, true ) );
-        }
-
-        for ( PatientAttribute attribute : attributes )
-        {
-            grid.addHeader( new GridHeader( attribute.getName(), false, true ) );
-        }
-
-        for ( DataElement element : dataElements )
-        {
-            grid.addHeader( new GridHeader( element.getDisplayName(), false, true ) );
-        }
-
-        String sql = getTabularReportSql( false, programStage, identifiers, fixedAttributes, attributes, dataElements,
-            identifierKeys, attributeKeys, dataElementKeys, orgUnits, level, maxLevel, startDate, endDate, descOrder,
-            min, max );
+        for ( String searchingKey : searchingKeys )
+        {
+            String[] infor = searchingKey.split( "_" );
+            String objectType = infor[0];
+
+            boolean hidden = Boolean.parseBoolean( infor[2] );
+            String name = "";
+
+            if ( objectType.equals( PREFIX_FIXED_ATTRIBUTE ) )
+            {
+                name = infor[1];
+            }
+            else
+            {
+                int objectId = Integer.parseInt( infor[1] );
+
+                if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) )
+                {
+                    name = patientIdentifierTypeService.getPatientIdentifierType( objectId ).getName();
+                }
+                else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) )
+                {
+                    name = patientAttributeService.getPatientAttribute( objectId ).getName();
+                }
+                else if ( objectType.equals( PREFIX_DATA_ELEMENT ) )
+                {
+                    name = dataElementService.getDataElement( objectId ).getName();
+                }
+            }
+
+            grid.addHeader( new GridHeader( name, hidden, true ) );
+        }
+
+        String sql = getTabularReportSql( false, programStage, searchingKeys, orgUnits, level, maxLevel, startDate,
+            endDate, descOrder, min, max );
 
         SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
 
@@ -249,23 +283,18 @@
         return grid;
     }
 
-    public int getTabularReportCount( ProgramStage programStage, List<PatientIdentifierType> identifiers,
-        List<String> fixedAttributes, List<PatientAttribute> attributes, List<DataElement> dataElements,
-        Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys, Map<Integer, String> dataElementKeys,
-        Collection<Integer> orgUnits, int level, int maxLevel, Date startDate, Date endDate )
+    public int getTabularReportCount( ProgramStage programStage, List<String> searchingKeys,
+        Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate )
     {
-        String sql = getTabularReportSql( true, programStage, identifiers, fixedAttributes, attributes, dataElements,
-            identifierKeys, attributeKeys, dataElementKeys, orgUnits, level, maxLevel, startDate, endDate, false, null,
-            null );
+        String sql = getTabularReportSql( true, programStage, searchingKeys, organisationUnits, level, maxLevel,
+            startDate, endDate, false, null, null );
 
         return jdbcTemplate.queryForInt( sql );
     }
 
-    private String getTabularReportSql( boolean count, ProgramStage programStage,
-        List<PatientIdentifierType> identifiers, List<String> fixedAttributes, List<PatientAttribute> attributes,
-        List<DataElement> dataElements, Map<Integer, String> identifierKeys, Map<Integer, String> attributeKeys,
-        Map<Integer, String> dataElementKeys, Collection<Integer> orgUnits, int level, int maxLevel, Date startDate,
-        Date endDate, boolean descOrder, Integer min, Integer max )
+    private String getTabularReportSql( boolean count, ProgramStage programStage, List<String> searchingKeys,
+        Collection<Integer> 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 );
@@ -273,6 +302,8 @@
         String selector = count ? "count(*) " : "* ";
 
         String sql = "select " + selector + "from ( select psi.programstageinstanceid, psi.executiondate,";
+        String where = "";
+        String operator = "where ";
 
         for ( int i = 0; i < maxLevel; i++ )
         {
@@ -281,27 +312,57 @@
                 + ",";
         }
 
-        for ( PatientIdentifierType type : identifiers )
-        {
-            sql += "(select identifier from patientidentifier where patientid=p.patientid and patientidentifiertypeid="
-                + type.getId() + ") as identifier_" + type.getId() + ",";
-        }
-
-        for ( String attribute : fixedAttributes )
-        {
-            sql += "p." + attribute + ",";
-        }
-
-        for ( PatientAttribute attribute : attributes )
-        {
-            sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
-                + attribute.getId() + ") as attribute_" + attribute.getId() + ",";
-        }
-
-        for ( DataElement element : dataElements )
-        {
-            sql += "(select value from patientdatavalue where programstageinstanceid=psi.programstageinstanceid and dataelementid="
-                + element.getId() + ") as element_" + element.getId() + ",";
+        for ( String searchingKey : searchingKeys )
+        {
+            String[] infor = searchingKey.split( "_" );
+            String objectType = infor[0];
+
+            if ( objectType.equals( PREFIX_FIXED_ATTRIBUTE ) )
+            {
+                sql += "p." + infor[1] + ",";
+            }
+            else
+            {
+                int objectId = Integer.parseInt( infor[1] );
+                String value = "";
+
+                if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) )
+                {
+                    sql += "(select identifier from patientidentifier where patientid=p.patientid and patientidentifiertypeid="
+                        + objectId + ") as identifier_" + objectId + ",";
+
+                    if ( infor.length == 4 )
+                    {
+                        value = lower( infor[3] );
+                        where += operator + "lower(identifier_" + objectId + ") " + value + " ";
+
+                        operator = "and ";
+                    }
+                }
+                else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) )
+                {
+                    sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
+                        + objectId + ") as attribute_" + objectId + ",";
+                    if ( infor.length == 4 )
+                    {
+                        value = lower( infor[3] );
+                        where += operator + "lower(attribute_" + objectId + ") " + value + " ";
+                        operator = "and ";
+                    }
+                }
+                else if ( objectType.equals( PREFIX_DATA_ELEMENT ) )
+                {
+                    sql += "(select value from patientdatavalue where programstageinstanceid=psi.programstageinstanceid and dataelementid="
+                        + objectId + ") as element_" + objectId + ",";
+
+                    if ( infor.length == 4 )
+                    {
+                        value = lower( infor[3] );
+                        where += operator + "lower(element_" + objectId + ") " + value + " ";
+                        operator = "and ";
+                    }
+                }
+            }
         }
 
         sql = sql.substring( 0, sql.length() - 1 ) + " "; // Removing last comma
@@ -331,32 +392,15 @@
         sql += "psi.executiondate ";
         sql += descOrder ? "desc " : "";
         sql += (min != null && max != null) ? statementBuilder.limitRecord( min, max ) : ""; // TODO
-                                                                       // page
-                                                                       // size
+        // page
+        // size
         sql += ") as tabular ";
 
-        String operator = "where ";
-
-        for ( Integer key : identifierKeys.keySet() )
-        {
-            sql += operator + "lower(identifier_" + key + ") " + lower( identifierKeys.get( key ) ) + " ";
-            operator = "and ";
-        }
-
-        for ( Integer key : attributeKeys.keySet() )
-        {
-            sql += operator + "lower(attribute_" + key + ") " + lower( attributeKeys.get( key ) ) + " ";
-            operator = "and ";
-        }
-
-        for ( Integer key : dataElementKeys.keySet() )
-        {
-            sql += operator + "lower(element_" + key + ") " + lower( dataElementKeys.get( key ) ) + " ";
-            operator = "and ";
-        }
+        // filters
+        sql += where;
 
         sql = sql.substring( 0, sql.length() - 1 ) + " "; // Remove last comma
-                                                          // if exists
+        // if exists
 
         log.info( sql );
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipService.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/DefaultRelationshipService.java	2012-06-14 13:07:22 +0000
@@ -98,4 +98,9 @@
     {
         return relationshipStore.get( patientA, patientB, relationshipType );
     }
+    
+    public Relationship getRelationship( Patient patientA, Patient patientB )
+    {
+        return relationshipStore.get( patientA, patientB );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java	2011-03-31 01:55:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java	2012-06-14 13:07:22 +0000
@@ -70,4 +70,11 @@
             Restrictions.eq( "patientB", patientB ), Restrictions.eq( "relationshipType", relationshipType ) )
             .uniqueResult();
     }
+    
+    public Relationship get( Patient patientA, Patient patientB )
+    {
+        return (Relationship) getCriteria( Restrictions.eq( "patientA", patientA ),
+            Restrictions.eq( "patientB", patientB ) )
+            .uniqueResult();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-06-07 13:09:16 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-06-14 13:07:22 +0000
@@ -1,26 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans";
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-  xmlns:aop="http://www.springframework.org/schema/aop";
-  xsi:schemaLocation="
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:aop="http://www.springframework.org/schema/aop";
+	xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd";>
 
 	<!-- Store definitions -->
-	
+
 	<bean id="org.hisp.dhis.caseaggregation.CaseAggregationConditionStore"
-    class="org.hisp.dhis.caseaggregation.jdbc.JdbcCaseAggregationConditionStore">
-    	<property name="statementManager" ref="statementManager" />
-    	<property name="clazz" value="org.hisp.dhis.caseaggregation.CaseAggregationCondition" />
+		class="org.hisp.dhis.caseaggregation.jdbc.JdbcCaseAggregationConditionStore">
+		<property name="statementManager" ref="statementManager" />
+		<property name="clazz"
+			value="org.hisp.dhis.caseaggregation.CaseAggregationCondition" />
 		<property name="sessionFactory" ref="sessionFactory" />
-    </bean>
-	
+	</bean>
+
 	<bean id="org.hisp.dhis.activityplan.jdbc.JdbcActivityPlanStore"
-    class="org.hisp.dhis.activityplan.jdbc.JdbcActivityPlanStore">
-    	<property name="statementManager" ref="statementManager" />
-		<property name="statementBuilder" ref="statementBuilder"/>
-    </bean>
-    
+		class="org.hisp.dhis.activityplan.jdbc.JdbcActivityPlanStore">
+		<property name="statementManager" ref="statementManager" />
+		<property name="statementBuilder" ref="statementBuilder" />
+	</bean>
+
 	<bean id="org.hisp.dhis.relationship.RelationshipStore"
 		class="org.hisp.dhis.relationship.hibernate.HibernateRelationshipStore">
 		<property name="clazz" value="org.hisp.dhis.relationship.Relationship" />
@@ -38,7 +38,11 @@
 		<property name="clazz" value="org.hisp.dhis.program.ProgramStageInstance" />
 		<property name="sessionFactory" ref="sessionFactory" />
 		<property name="jdbcTemplate" ref="jdbcTemplate" />
-		<property name="statementBuilder" ref="statementBuilder"/>
+		<property name="statementBuilder" ref="statementBuilder" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramInstanceStore"
@@ -56,7 +60,7 @@
 		<property name="clazz" value="org.hisp.dhis.program.Program" />
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.program.ProgramValidationStore"
 		class="org.hisp.dhis.program.hibernate.HibernateProgramValidationStore">
 		<property name="clazz" value="org.hisp.dhis.program.ProgramValidation" />
@@ -66,9 +70,9 @@
 	<bean id="org.hisp.dhis.patient.PatientStore" class="org.hisp.dhis.patient.hibernate.HibernatePatientStore">
 		<property name="clazz" value="org.hisp.dhis.patient.Patient" />
 		<property name="sessionFactory" ref="sessionFactory" />
-		<property name="statementManager" ref="statementManager"/>
-		<property name="statementBuilder" ref="statementBuilder"/>
-		<property name="jdbcTemplate" ref="jdbcTemplate"/>
+		<property name="statementManager" ref="statementManager" />
+		<property name="statementBuilder" ref="statementBuilder" />
+		<property name="jdbcTemplate" ref="jdbcTemplate" />
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.PatientIdentifierStore"
@@ -77,7 +81,8 @@
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
 
-	<bean id="org.hisp.dhis.patient.PatientIdentifierTypeStore" class="org.hisp.dhis.patient.hibernate.HibernatePatientIdentifierTypeStore">
+	<bean id="org.hisp.dhis.patient.PatientIdentifierTypeStore"
+		class="org.hisp.dhis.patient.hibernate.HibernatePatientIdentifierTypeStore">
 		<property name="clazz" value="org.hisp.dhis.patient.PatientIdentifierType" />
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
@@ -90,20 +95,22 @@
 
 	<bean id="org.hisp.dhis.patientattributevalue.PatientAttributeValueStore"
 		class="org.hisp.dhis.patientattributevalue.hibernate.HibernatePatientAttributeValueStore">
-		<property name="clazz" value="org.hisp.dhis.patientattributevalue.PatientAttributeValue" />
-		<property name="sessionFactory" ref="sessionFactory" />
-		<property name="jdbcTemplate" ref="jdbcTemplate"/>
-	</bean>
-	
-    <bean id="org.hisp.dhis.patient.PatientAttributeOptionStore"
-   		class="org.hisp.dhis.patient.hibernate.HibernatePatientAttributeOptionStore">
-     	<property name="clazz" value="org.hisp.dhis.patient.PatientAttributeOption"/>
-     	<property name="sessionFactory" ref="sessionFactory"/>
-    </bean>
+		<property name="clazz"
+			value="org.hisp.dhis.patientattributevalue.PatientAttributeValue" />
+		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="jdbcTemplate" ref="jdbcTemplate" />
+	</bean>
+
+	<bean id="org.hisp.dhis.patient.PatientAttributeOptionStore"
+		class="org.hisp.dhis.patient.hibernate.HibernatePatientAttributeOptionStore">
+		<property name="clazz" value="org.hisp.dhis.patient.PatientAttributeOption" />
+		<property name="sessionFactory" ref="sessionFactory" />
+	</bean>
 
 	<bean id="org.hisp.dhis.patientdatavalue.PatientDataValueStore"
 		class="org.hisp.dhis.patientdatavalue.hibernate.HibernatePatientDataValueStore">
-		<property name="clazz" value="org.hisp.dhis.patientdatavalue.PatientDataValue" />
+		<property name="clazz"
+			value="org.hisp.dhis.patientdatavalue.PatientDataValue" />
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
 
@@ -112,23 +119,24 @@
 		<property name="clazz" value="org.hisp.dhis.patient.PatientAttributeGroup" />
 		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
-	
-   <bean id="org.hisp.dhis.program.ProgramStageDataElementStore"
-     class="org.hisp.dhis.program.hibernate.HibernateProgramStageDataElementStore">    
-     <property name="clazz" value="org.hisp.dhis.program.ProgramStageDataElement"/>
-     <property name="sessionFactory" ref="sessionFactory"/>
-   </bean>
-   
-   <bean id="org.hisp.dhis.patientreport.PatientTabularReportStore"
-    	class="org.hisp.dhis.patientreport.hibernate.HibernatePatientTabularReportStore">
-      	<property name="clazz" value="org.hisp.dhis.patientreport.PatientTabularReport" />
-    	<property name="sessionFactory" ref="sessionFactory" />
-   </bean>
-   
+
+	<bean id="org.hisp.dhis.program.ProgramStageDataElementStore"
+		class="org.hisp.dhis.program.hibernate.HibernateProgramStageDataElementStore">
+		<property name="clazz"
+			value="org.hisp.dhis.program.ProgramStageDataElement" />
+		<property name="sessionFactory" ref="sessionFactory" />
+	</bean>
+
+	<bean id="org.hisp.dhis.patientreport.PatientTabularReportStore"
+		class="org.hisp.dhis.patientreport.hibernate.HibernatePatientTabularReportStore">
+		<property name="clazz"
+			value="org.hisp.dhis.patientreport.PatientTabularReport" />
+		<property name="sessionFactory" ref="sessionFactory" />
+	</bean>
+
 	<!-- Service definitions -->
-	
-	<bean id="org.hisp.dhis.program.ProgramDataEntryService"
-		class="org.hisp.dhis.program.DefaultProgramDataEntryService">
+
+	<bean id="org.hisp.dhis.program.ProgramDataEntryService" class="org.hisp.dhis.program.DefaultProgramDataEntryService">
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="programStageInstanceService">
 			<ref bean="org.hisp.dhis.program.ProgramStageInstanceService" />
@@ -142,33 +150,34 @@
 		<property name="programStageDataElementService"
 			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.activityplan.ActivityPlanService"
-		class="org.hisp.dhis.activityplan.DefaultActivityPlanService">
+
+	<bean id="org.hisp.dhis.activityplan.ActivityPlanService" class="org.hisp.dhis.activityplan.DefaultActivityPlanService">
 		<property name="patientDataValueService"
 			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
-		<property name="programInstanceService"
-			ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="programService"
-			ref="org.hisp.dhis.program.ProgramService" />
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="activityPlanStore"
 			ref="org.hisp.dhis.activityplan.jdbc.JdbcActivityPlanStore" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.caseaggregation.CaseAggregationConditionService"
-    	class="org.hisp.dhis.caseaggregation.DefaultCaseAggregationConditionService">
-    	<property name="aggregationConditionStore" ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionStore" />
-    	<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />     	
-        <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />     	
-        <property name="dataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
-        <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />     	
-        <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-        <property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" /> 
-        <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />      	     	
-    </bean>
-    
+		class="org.hisp.dhis.caseaggregation.DefaultCaseAggregationConditionService">
+		<property name="aggregationConditionStore"
+			ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionStore" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<property name="dataValueService"
+			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+	</bean>
+
 	<bean id="org.hisp.dhis.program.nextvisit.NextVisitGenerator"
 		class="org.hisp.dhis.program.nextvisit.DefaultNextVisitGenerator">
 		<property name="patientDataValueService"
@@ -176,17 +185,17 @@
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.relationship.RelationshipService" class="org.hisp.dhis.relationship.DefaultRelationshipService">
 		<property name="relationshipStore" ref="org.hisp.dhis.relationship.RelationshipStore" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.relationship.RelationshipTypeService"
 		class="org.hisp.dhis.relationship.DefaultRelationshipTypeService">
 		<property name="relationshipTypeStore"
 			ref="org.hisp.dhis.relationship.RelationshipTypeStore" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.program.ProgramStageInstanceService"
 		class="org.hisp.dhis.program.DefaultProgramStageInstanceService">
 		<property name="programStageInstanceStore"
@@ -199,8 +208,10 @@
 
 	<bean id="org.hisp.dhis.program.ProgramInstanceService" class="org.hisp.dhis.program.DefaultProgramInstanceService">
 		<property name="programInstanceStore" ref="org.hisp.dhis.program.ProgramInstanceStore" />
-		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
-		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+		<property name="patientAttributeValueService"
+			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramStageService" class="org.hisp.dhis.program.DefaultProgramStageService">
@@ -210,15 +221,11 @@
 	<bean id="org.hisp.dhis.program.ProgramService" class="org.hisp.dhis.program.DefaultProgramService">
 		<property name="programStore" ref="org.hisp.dhis.program.ProgramStore" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.program.ProgramValidationService"
-		class="org.hisp.dhis.program.DefaultProgramValidationService">
-		<property name="validationStore"
-			ref="org.hisp.dhis.program.ProgramValidationStore" />
-		<property name="programStageService"
-			ref="org.hisp.dhis.program.ProgramStageService" />
-		<property name="dataElementService"
-			ref="org.hisp.dhis.dataelement.DataElementService" />
+
+	<bean id="org.hisp.dhis.program.ProgramValidationService" class="org.hisp.dhis.program.DefaultProgramValidationService">
+		<property name="validationStore" ref="org.hisp.dhis.program.ProgramValidationStore" />
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="valueService"
 			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
 	</bean>
@@ -229,8 +236,8 @@
 			ref="org.hisp.dhis.patient.PatientIdentifierService" />
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
-		<property name="patientIdentifierTypeService" 
-			ref="org.hisp.dhis.patient.PatientIdentifierTypeService"/>	
+		<property name="patientIdentifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 		<property name="relationshipTypeService"
@@ -260,11 +267,11 @@
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueStore" />
 	</bean>
 
-  <bean id="org.hisp.dhis.patient.PatientAttributeOptionService"
-    class="org.hisp.dhis.patient.DefaultPatientAttributeOptionService">
-    <property name="patientAttributeOptionStore"
-      ref="org.hisp.dhis.patient.PatientAttributeOptionStore"/>
-  </bean>
+	<bean id="org.hisp.dhis.patient.PatientAttributeOptionService"
+		class="org.hisp.dhis.patient.DefaultPatientAttributeOptionService">
+		<property name="patientAttributeOptionStore"
+			ref="org.hisp.dhis.patient.PatientAttributeOptionStore" />
+	</bean>
 
 	<bean id="org.hisp.dhis.patientdatavalue.PatientDataValueService"
 		class="org.hisp.dhis.patientdatavalue.DefaultPatientDataValueService">
@@ -277,99 +284,113 @@
 		<property name="patientAttributeGroupStore"
 			ref="org.hisp.dhis.patient.PatientAttributeGroupStore" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.program.ProgramStageDataElementService"
 		class="org.hisp.dhis.program.DefaultProgramStageDataElementService">
 		<property name="programStageDataElementStore"
-	  		ref="org.hisp.dhis.program.ProgramStageDataElementStore" />
-  	</bean>
-  
-   <bean id="org.hisp.dhis.patientreport.PatientTabularReportService"
-    	class="org.hisp.dhis.patientreport.DefaultPatientTabularReportService">
-    	<property name="tabularReportStore" ref="org.hisp.dhis.patientreport.PatientTabularReportStore" />
-    </bean>
-    
+			ref="org.hisp.dhis.program.ProgramStageDataElementStore" />
+	</bean>
+
+	<bean id="org.hisp.dhis.patientreport.PatientTabularReportService"
+		class="org.hisp.dhis.patientreport.DefaultPatientTabularReportService">
+		<property name="tabularReportStore"
+			ref="org.hisp.dhis.patientreport.PatientTabularReportStore" />
+	</bean>
+
 	<!-- Aggregation engine -->
 
 	<bean
 		id="org.hisp.dhis.patientdatavalue.aggregation.PatientDataValueAggregationEngine"
 		class="org.hisp.dhis.patientdatavalue.aggregation.DefaultPatientDataValueAggregationEngine">
-		<property name="statementManager" ref="statementManager"/>
+		<property name="statementManager" ref="statementManager" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 	</bean>
-	
+
 	<!-- DeletionHandlers -->
-	
-	<bean id="org.hisp.dhis.patient.PatientIdentifierDeletionHandler" 
+
+	<bean id="org.hisp.dhis.patient.PatientIdentifierDeletionHandler"
 		class="org.hisp.dhis.patient.PatientIdentifierDeletionHandler">
-		<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService"/>
+		<property name="patientIdentifierService"
+			ref="org.hisp.dhis.patient.PatientIdentifierService" />
 	</bean>
 
-	<bean id="org.hisp.dhis.program.ProgramInstanceDeletionHandler" 
+	<bean id="org.hisp.dhis.program.ProgramInstanceDeletionHandler"
 		class="org.hisp.dhis.program.ProgramInstanceDeletionHandler">
-		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService"/>
-		<property name="patientDataValueService" ref="org.hisp.dhis.patientdatavalue.PatientDataValueService"/>
-		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService"/>
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="patientDataValueService"
+			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.relationship.RelationshipDeletionHandler" 
+
+	<bean id="org.hisp.dhis.relationship.RelationshipDeletionHandler"
 		class="org.hisp.dhis.relationship.RelationshipDeletionHandler">
-		<property name="relationshipSevice" ref="org.hisp.dhis.relationship.RelationshipService"/>
+		<property name="relationshipSevice"
+			ref="org.hisp.dhis.relationship.RelationshipService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler" 
+
+	<bean
+		id="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler"
 		class="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler">
-		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService"/>
-		<property name="patientService" ref="org.hisp.dhis.patient.PatientService"/>
-	</bean>
-	
-	<bean id="org.hisp.dhis.program.ProgramDeletionHandler" 
-		class="org.hisp.dhis.program.ProgramDeletionHandler">
-		<property name="programService" ref="org.hisp.dhis.program.ProgramService"/>
-	</bean>
-	
-	<bean id="org.hisp.dhis.patient.PatientDeletionHandler" 
-		class="org.hisp.dhis.patient.PatientDeletionHandler">
-		<property name="patientService" ref="org.hisp.dhis.patient.PatientService"/>
-	</bean>
-	
-	<bean id="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler" 
+		<property name="patientAttributeValueService"
+			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.program.ProgramDeletionHandler" class="org.hisp.dhis.program.ProgramDeletionHandler">
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.patient.PatientDeletionHandler" class="org.hisp.dhis.patient.PatientDeletionHandler">
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler"
 		class="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler">
-		<property name="programStageDEService" ref="org.hisp.dhis.program.ProgramStageDataElementService"/>
-	</bean>
-	
-	<bean id="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler" class="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler">
-    	<property name="jdbcTemplate" ref="jdbcTemplate" />
-  	</bean>
-  	
-  	<bean id="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler" class="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler">
-    	<property name="aggregationConditionService" ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
-  	</bean>
-  	
-  	<bean id="org.hisp.dhis.program.ProgramValidationDeletionHandler" class="org.hisp.dhis.program.ProgramValidationDeletionHandler">
-    	<property name="programValidationService" ref="org.hisp.dhis.program.ProgramValidationService" />
-  	</bean>
-  	
-  	<bean id="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler" class="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler">
-    	<property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
-    	<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-  	</bean>
-  	
-  	<bean id="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler" 
+		<property name="programStageDEService"
+			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler"
+		class="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler">
+		<property name="jdbcTemplate" ref="jdbcTemplate" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler"
+		class="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler">
+		<property name="aggregationConditionService"
+			ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.program.ProgramValidationDeletionHandler"
+		class="org.hisp.dhis.program.ProgramValidationDeletionHandler">
+		<property name="programValidationService"
+			ref="org.hisp.dhis.program.ProgramValidationService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler"
+		class="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler">
+		<property name="dataEntryFormService"
+			ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler"
 		class="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler">
 		<property name="jdbcTemplate" ref="jdbcTemplate" />
 	</bean>
-  
+
 	<!-- Startup -->
-	
-	<bean id="org.hisp.dhis.patient.startup.TableAlteror" class="org.hisp.dhis.patient.startup.TableAlteror" >
+
+	<bean id="org.hisp.dhis.patient.startup.TableAlteror" class="org.hisp.dhis.patient.startup.TableAlteror">
 		<property name="statementManager" ref="statementManager" />
 		<property name="name" value="PatientTableAlteror" />
 		<property name="runlevel" value="4" />
 		<property name="skipInTests" value="true" />
 	</bean>
-	
+
 	<bean
 		class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
 		<property name="targetObject"
@@ -383,96 +404,100 @@
 			</list>
 		</property>
 	</bean>
-	
+
 	<!-- DeletionManager -->
-  
-  	<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-    	<property name="targetObject" ref="deletionManager"/>
-    	<property name="targetMethod" value="addDeletionHandlers"/>
-    	<property name="arguments">
-		  <list>
+
+	<bean
+		class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+		<property name="targetObject" ref="deletionManager" />
+		<property name="targetMethod" value="addDeletionHandlers" />
+		<property name="arguments">
 			<list>
-			  <ref local="org.hisp.dhis.patient.PatientDeletionHandler"/>
-			  <ref local="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler"/>
-			  <ref local="org.hisp.dhis.patient.PatientIdentifierDeletionHandler"/>
-			  <ref local="org.hisp.dhis.relationship.RelationshipDeletionHandler"/>
-			  <ref local="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler"/>
-			  
-			  <ref local="org.hisp.dhis.program.ProgramDeletionHandler"/>
-			  <ref local="org.hisp.dhis.program.ProgramInstanceDeletionHandler"/>
-			  <ref local="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler"/>
-			  <ref local="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler"/>
-			  <ref local="org.hisp.dhis.program.ProgramValidationDeletionHandler"/>
-			  <ref local="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler"/>
-			  
-			  <ref local="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler"/>
+				<list>
+					<ref local="org.hisp.dhis.patient.PatientDeletionHandler" />
+					<ref
+						local="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler" />
+					<ref local="org.hisp.dhis.patient.PatientIdentifierDeletionHandler" />
+					<ref local="org.hisp.dhis.relationship.RelationshipDeletionHandler" />
+					<ref
+						local="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler" />
+
+					<ref local="org.hisp.dhis.program.ProgramDeletionHandler" />
+					<ref local="org.hisp.dhis.program.ProgramInstanceDeletionHandler" />
+					<ref local="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler" />
+					<ref local="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler" />
+					<ref local="org.hisp.dhis.program.ProgramValidationDeletionHandler" />
+					<ref local="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler" />
+
+					<ref
+						local="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler" />
+				</list>
 			</list>
-		  </list>
 		</property>
 	</bean>
-	
+
 	<!-- AOP definitions -->
-  
-  	<aop:config>
-  	
-	    <aop:aspect ref="deletionInterceptor">
-	       
-	      <aop:before 
-		      pointcut="execution( * org.hisp.dhis.patient.PatientService.delete*(..) )" 
-		      method="intercept"/>
-		  <aop:before 
-	      	pointcut="execution( * org.hisp.dhis.patientattributevalue.PatientAttributeValueService.delete*(..) )" 
-	      	method="intercept"/>
-	      <aop:before
-		      pointcut="execution( * org.hisp.dhis.patient.PatientAttributeService.delete*(..) )" 
-		      method="intercept"/>
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.patient.PatientIdentifierService.delete*(..) )" 
-		      method="intercept"/>
-		   <aop:before 
-		      pointcut="execution( * org.hisp.dhis.patient.PatientIdentifierTypeService.delete*(..) )" 
-		      method="intercept"/>
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.relationship.RelationshipService.delete*(..) )" 
-		      method="intercept"/>
-		   <aop:before 
-		      pointcut="execution( * org.hisp.dhis.relationship.RelationshipTypeService.delete*(..) )" 
-		      method="intercept"/>
-		 
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.program.ProgramService.delete*(..) )" 
-		      method="intercept"/>
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.program.ProgramInstanceService.delete*(..) )" 
-		      method="intercept"/>
-		 <aop:before 
-		      pointcut="execution( * org.hisp.dhis.program.ProgramStageService.delete*(..) )" 
-		      method="intercept"/>
-	      <aop:before 
-		      pointcut="execution( * org.hisp.dhis.program.ProgramStageInstanceService.delete*(..) )" 
-		      method="intercept"/>
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.program.ProgramStageDataElementService.delete*(..) )" 
-		      method="intercept"/>
-		   <aop:before 
-		      pointcut="execution( * org.hisp.dhis.program.ProgramValidationService.delete*(..) )" 
-		      method="intercept"/>
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.program.ProgramStageInstanceService.delete*(..) )" 
-		      method="intercept"/>
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.patientdatavalue.PatientDataValueService.delete*(..) )" 
-		      method="intercept"/>
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.validation.ValidationCriteriaService.delete*(..) )" 
-		      method="intercept"/>
-		      
-		  <aop:before 
-		      pointcut="execution( * org.hisp.dhis.caseaggregation.CaseAggregationConditionService.delete*(..) )" 
-		      method="intercept"/>
-		      
-	    </aop:aspect>
-      
-  	</aop:config>
-  
+
+	<aop:config>
+
+		<aop:aspect ref="deletionInterceptor">
+
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.patient.PatientService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.patientattributevalue.PatientAttributeValueService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.patient.PatientAttributeService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.patient.PatientIdentifierService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.patient.PatientIdentifierTypeService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.relationship.RelationshipService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.relationship.RelationshipTypeService.delete*(..) )"
+				method="intercept" />
+
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.program.ProgramService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.program.ProgramInstanceService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.program.ProgramStageService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.program.ProgramStageInstanceService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.program.ProgramStageDataElementService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.program.ProgramValidationService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.program.ProgramStageInstanceService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.patientdatavalue.PatientDataValueService.delete*(..) )"
+				method="intercept" />
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.validation.ValidationCriteriaService.delete*(..) )"
+				method="intercept" />
+
+			<aop:before
+				pointcut="execution( * org.hisp.dhis.caseaggregation.CaseAggregationConditionService.delete*(..) )"
+				method="intercept" />
+
+		</aop:aspect>
+
+	</aop:config>
+
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java	2012-05-29 15:37:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java	2012-06-14 13:07:22 +0000
@@ -302,7 +302,7 @@
         Integer id = patientService.createPatient( patient, representativeId, relationshipTypeId,
             patientAttributeValues );
 
-        message = id + "";
+        message = id + "_" + systemGenerateIdentifier.getIdentifier();
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2012-06-14 13:07:22 +0000
@@ -48,6 +48,8 @@
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.relationship.Relationship;
+import org.hisp.dhis.relationship.RelationshipService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -75,7 +77,9 @@
     private PatientAttributeGroupService patientAttributeGroupService;
 
     private PatientIdentifierTypeService patientIdentifierTypeService;
-
+    
+    private RelationshipService relationshipService;
+    
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -104,7 +108,7 @@
 
     private String systemIdentifier;
 
-    private Patient representative;
+    private Relationship relationship;
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -128,8 +132,9 @@
         identiferMap = new HashMap<Integer, String>();
 
         PatientIdentifierType idType = null;
-        representative = patient.getRepresentative();
-
+        Patient representative = patient.getRepresentative();
+        relationship = relationshipService.getRelationship( representative, patient );
+        
         if ( patient.isUnderAge() && representative != null )
         {
             for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() )
@@ -198,6 +203,11 @@
         this.patientService = patientService;
     }
 
+    public Relationship getRelationship()
+    {
+        return relationship;
+    }
+
     public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
     {
         this.patientIdentifierService = patientIdentifierService;
@@ -228,9 +238,9 @@
         this.patientIdentifierTypeService = patientIdentifierTypeService;
     }
 
-    public Patient getRepresentative()
+    public void setRelationshipService( RelationshipService relationshipService )
     {
-        return representative;
+        this.relationshipService = relationshipService;
     }
 
     public void setId( int id )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-06-11 08:24:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-06-14 13:07:22 +0000
@@ -28,10 +28,7 @@
 package org.hisp.dhis.caseentry.action.report;
 
 import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_DATA_ELEMENT;
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_IDENTIFIER_TYPE;
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_META_DATA;
 import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE;
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_FIXED_ATTRIBUTE;
 import static org.hisp.dhis.patientreport.PatientTabularReport.VALUE_TYPE_OPTION_SET;
 
 import java.util.ArrayList;
@@ -55,7 +52,6 @@
 import org.hisp.dhis.patient.PatientAttributeOption;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
@@ -102,13 +98,6 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
-    private PatientIdentifierTypeService identifierTypeService;
-
-    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
-    {
-        this.identifierTypeService = identifierTypeService;
-    }
-
     private PatientAttributeService patientAttributeService;
 
     public void setPatientAttributeService( PatientAttributeService patientAttributeService )
@@ -246,13 +235,6 @@
         return valueTypes;
     }
 
-    private List<String> fixedAttributes = new ArrayList<String>();
-
-    public void setFixedAttributes( List<String> fixedAttributes )
-    {
-        this.fixedAttributes = fixedAttributes;
-    }
-
     private Map<Integer, List<String>> mapSuggestedValues = new HashMap<Integer, List<String>>();
 
     public Map<Integer, List<String>> getMapSuggestedValues()
@@ -260,14 +242,6 @@
         return mapSuggestedValues;
     }
 
-    private Map<Integer, String> searchingIdenKeys = new HashMap<Integer, String>();
-
-    private Map<Integer, String> searchingAttrKeys = new HashMap<Integer, String>();
-
-    private Map<Integer, String> searchingDEKeys = new HashMap<Integer, String>();
-
-    private List<Boolean> hiddenCols = new ArrayList<Boolean>();
-
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -303,7 +277,7 @@
                 if ( selectedOrgunit.getParent() == null )
                 {
                     organisationUnits = null; // Ignore org unit criteria when
-                                              // root
+                    // root
                 }
                 else
                 {
@@ -321,41 +295,31 @@
         // TODO check sql traffic
 
         Date startValue = format.parseDate( startDate );
-
         Date endValue = format.parseDate( endDate );
-
-        // ---------------------------------------------------------------------
-        // Get DE searching-keys
-        // ---------------------------------------------------------------------
-
         getParams();
-
+        
         // ---------------------------------------------------------------------
         // Generate tabular report
         // ---------------------------------------------------------------------
 
         if ( type == null ) // Tabular report
         {
-            int totalRecords = programStageInstanceService.getTabularReportCount( programStage, identifierTypes,
-                fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys,
-                searchingDEKeys, organisationUnits, level, startValue, endValue );
+            int totalRecords = programStageInstanceService.getTabularReportCount( programStage, searchingValues,
+                organisationUnits, level, startValue, endValue );
 
             total = getNumberOfPages( totalRecords );
 
             this.paging = createPaging( totalRecords );
             // total = paging.getTotal(); //TODO
 
-            grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes,
-                fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys,
-                searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc, paging
-                    .getStartPos(), paging.getPageSize() );
+            grid = programStageInstanceService.getTabularReport( programStage, searchingValues, organisationUnits,
+                level, startValue, endValue, !orderByOrgunitAsc, paging.getStartPos(), paging.getPageSize() );
         }
         else
         // Download as Excel
         {
-            grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes,
-                fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys,
-                searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc, null, null );
+            grid = programStageInstanceService.getTabularReport( programStage, searchingValues, organisationUnits,
+                level, startValue, endValue, !orderByOrgunitAsc, null, null );
         }
         System.out.println();
         System.out.println( grid );
@@ -375,76 +339,20 @@
 
     private void getParams()
     {
-        // ---------------------------------------------------------------------
-        // Get Patient-Identifier searching-keys
-        // ---------------------------------------------------------------------
-
         int index = 0;
         for ( String searchingValue : searchingValues )
         {
             String[] infor = searchingValue.split( "_" );
             String objectType = infor[0];
 
-            if ( objectType.equals( PREFIX_META_DATA ) )
-            {
-                hiddenCols.add( Boolean.parseBoolean( infor[2] ) );
-            }
-            else if ( objectType.equals( PREFIX_FIXED_ATTRIBUTE ) )
-            {
-                fixedAttributes.add( infor[1] );
-                hiddenCols.add( Boolean.parseBoolean( infor[2] ) );
-            }
-            else if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) )
-            {
-                int objectId = Integer.parseInt( infor[1] );
-                PatientIdentifierType identifierType = identifierTypeService.getPatientIdentifierType( objectId );
-                identifierTypes.add( identifierType );
-
-                // Get value-type && suggested-values
-                valueTypes.add( identifierType.getType() );
-                hiddenCols.add( Boolean.parseBoolean( infor[2] ) );
-
-                // Get searching-value
-                if ( infor.length == 4 )
-                {
-                    searchingIdenKeys.put( objectId, infor[3].trim() );
-                    values.add( infor[3].trim() );
-                }
-                else
-                {
-                    values.add( "" );
-                }
-                index++;
-            }
-            else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) )
+            if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) )
             {
                 int objectId = Integer.parseInt( infor[1] );
                 PatientAttribute attribute = patientAttributeService.getPatientAttribute( objectId );
                 patientAttributes.add( attribute );
-
-                // Get value-type && suggested-values
+                
                 valueTypes.add( attribute.getValueType() );
                 mapSuggestedValues.put( index, getSuggestedAttributeValues( attribute ) );
-                hiddenCols.add( Boolean.parseBoolean( infor[2] ) );
-
-                // Get searching-value
-                if ( infor.length == 4 )
-                {
-                    searchingAttrKeys.put( objectId, infor[3].trim() );
-                    String value = infor[3].trim();
-                    // if ( attribute.getValueType().equals(
-                    // PatientAttribute.TYPE_BOOL ) )
-                    // {
-                    // value = (value.indexOf( i18n.getString( "yes" ) ) != -1)
-                    // ? "true" : "false";
-                    // }
-                    values.add( value );
-                }
-                else
-                {
-                    values.add( "" );
-                }
-                index++;
             }
             else if ( objectType.equals( PREFIX_DATA_ELEMENT ) )
             {
@@ -456,31 +364,8 @@
                 String valueType = (dataElement.getOptionSet() != null) ? VALUE_TYPE_OPTION_SET : dataElement.getType();
                 valueTypes.add( valueType );
                 mapSuggestedValues.put( index, getSuggestedDataElementValues( dataElement ) );
-                hiddenCols.add( Boolean.parseBoolean( infor[2] ) );
-
-                if ( infor.length == 4 )
-                {
-                    String value = infor[3].trim();
-                    // if ( dataElement.getType().equals(
-                    // DataElement.VALUE_TYPE_BOOL ) )
-                    // {
-                    // int startIndx = value.indexOf( '\'' ) + 1;
-                    // int endIndx = value.lastIndexOf( '\'' );
-                    // String key = value.substring( startIndx, endIndx );
-                    //                           
-                    // value = (key.equals(i18n.getString( "yes" ))) ?
-                    // value.replace( key, "true" ) : value.replace( key,
-                    // "false" );
-                    // }
-                    searchingDEKeys.put( objectId, value );
-                    values.add( value );
-                }
-                else
-                {
-                    values.add( "" );
-                }
-                index++;
             }
+            index++;
         }
     }
 

=== 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-13 08:22:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-06-14 13:07:22 +0000
@@ -88,8 +88,7 @@
 		scope="prototype">
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-		<property name="dataElementService"
-			ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="patientDataValueService"
 			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
 	</bean>
@@ -424,9 +423,10 @@
 		</property>
 		<property name="patientAttributeGroupService"
 			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
-		<property name="patientIdentifierTypeService">
-			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		</property>
+		<property name="patientIdentifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="relationshipService"
+			ref="org.hisp.dhis.relationship.RelationshipService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.AddPatientAction"
@@ -792,9 +792,9 @@
 		class="org.hisp.dhis.caseentry.action.patient.ValidateSearchRelationshipAction"
 		scope="prototype">
 	</bean>
-	
+
 	<!-- Tabular report -->
-	
+
 	<bean id="org.hisp.dhis.caseentry.action.report.TabularReportSelectAction"
 		class="org.hisp.dhis.caseentry.action.report.TabularReportSelectAction"
 		scope="prototype">
@@ -808,19 +808,23 @@
 	<bean id="org.hisp.dhis.caseentry.action.report.TabularInitializeAction"
 		class="org.hisp.dhis.caseentry.action.report.TabularInitializeAction"
 		scope="prototype">
-		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="organisationUnitService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+		<property name="organisationUnitGroupService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitChildrenAction"
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitChildrenAction"
 		class="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitChildrenAction"
 		scope="prototype">
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.report.LoadPatientPropertiesAction"
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.report.LoadPatientPropertiesAction"
 		class="org.hisp.dhis.caseentry.action.report.LoadPatientPropertiesAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
@@ -829,13 +833,13 @@
 		<property name="attributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.caseentry.action.report.LoadProgramStagesAction"
 		class="org.hisp.dhis.caseentry.action.report.LoadProgramStagesAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction"
 		class="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction"
 		scope="prototype">
@@ -847,17 +851,15 @@
 		class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction"
 		scope="prototype">
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-		<property name="identifierTypeService"
-			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction"
 		class="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction"
@@ -865,25 +867,21 @@
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 	</bean>
-	
-	<bean
-		id="org.hisp.dhis.caseentry.action.report.GetTabularReportsAction"
+
+	<bean id="org.hisp.dhis.caseentry.action.report.GetTabularReportsAction"
 		class="org.hisp.dhis.caseentry.action.report.GetTabularReportsAction"
 		scope="prototype">
 		<property name="tabularReportService"
 			ref="org.hisp.dhis.patientreport.PatientTabularReportService" />
-		<property name="currentUserService"
-			ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 	</bean>
-	
-	<bean
-		id="org.hisp.dhis.caseentry.action.report.SaveTabularReportAction"
+
+	<bean id="org.hisp.dhis.caseentry.action.report.SaveTabularReportAction"
 		class="org.hisp.dhis.caseentry.action.report.SaveTabularReportAction"
 		scope="prototype">
 		<property name="tabularReportService"
 			ref="org.hisp.dhis.patientreport.PatientTabularReportService" />
-		<property name="currentUserService"
-			ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="organisationUnitService"
@@ -895,15 +893,14 @@
 		<property name="programStageDataElementService"
 			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>
-	
-	<bean
-		id="org.hisp.dhis.caseentry.action.report.GetTabularReportAction"
+
+	<bean id="org.hisp.dhis.caseentry.action.report.GetTabularReportAction"
 		class="org.hisp.dhis.caseentry.action.report.GetTabularReportAction"
 		scope="prototype">
 		<property name="tabularReportService"
 			ref="org.hisp.dhis.patientreport.PatientTabularReportService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.report.UpdateTabularReportNameAction"
 		class="org.hisp.dhis.caseentry.action.report.UpdateTabularReportNameAction"
@@ -911,9 +908,8 @@
 		<property name="tabularReportService"
 			ref="org.hisp.dhis.patientreport.PatientTabularReportService" />
 	</bean>
-	
-	<bean
-		id="org.hisp.dhis.caseentry.action.report.DeleteTabularReportAction"
+
+	<bean id="org.hisp.dhis.caseentry.action.report.DeleteTabularReportAction"
 		class="org.hisp.dhis.caseentry.action.report.DeleteTabularReportAction"
 		scope="prototype">
 		<property name="tabularReportService"

=== 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-14 03:58:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-06-14 13:07:22 +0000
@@ -162,7 +162,7 @@
 search_value=Search value
 add_person_successfully=Add person successfully
 please_select_relationshipType=Please select relationship type
-please_choose_representative_for_this_under_age_patient=Please chose representative for this under age person
+please_choose_representative_for_this_under_age_patient=Please choose representative for this under age person
 please_choose_relationshipType_for_this_under_age_patient=Please choose relationship type for this under age person
 dateOfEnrollmentDescription=Date of enrollment description
 dateOfIncidentDescription=Date of incident description

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-06-13 03:59:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-06-14 13:07:22 +0000
@@ -93,8 +93,7 @@
 			domain: 'domain_',
 		},
 		image: {
-            xls: 'xls',
-            pdf: 'pdf'
+            xls: 'xls'
         },
         cmd: {
             init: 'init_',
@@ -900,12 +899,16 @@
             p += "&endDate=" + TR.cmp.settings.endDate.rawValue;
 			p += "&facilityLB=" + TR.cmp.settings.facilityLB.getValue();
 			p += "&level=" + TR.cmp.settings.level.getValue();
-			p += "&orgunitId=" + TR.state.orgunitId;
 			p += "&orderByOrgunitAsc=" + 'true';
 			p += "&orderByExecutionDateByAsc=" +'true';
 			p += "&programStageId=" + TR.cmp.params.programStage.getValue();
 			p += "&type=" + type;
 			
+			// organisation units
+			for( var i=0; i<TR.state.orgunitIds.length; i++ ){
+				p += '&orgunitIds=' + TR.state.orgunitIds[i];
+			}
+			
 			if( !TR.state.paramChanged() )
 			{
 				var colNames = new Array();
@@ -1211,7 +1214,8 @@
 					name: 'meta_' + index,
 					sortable: false,
 					draggable: false,
-					hidden: eval(TR.value.columns[index].hidden)
+					hideable: false,
+					menuDisabled: true
 				}
 			}
 			
@@ -2878,14 +2882,6 @@
 											handler: function() {
 												b.execute(TR.conf.finals.image.xls);
 											}
-										},
-										{
-											text: TR.i18n.pdf,
-											iconCls: 'tr-menu-item-pdf',
-											minWidth: 105,
-											handler: function() {
-												b.execute(TR.conf.finals.image.pdf);
-											}
 										}
 									]                                            
 								});

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm	2012-06-12 05:26:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm	2012-06-14 13:07:22 +0000
@@ -9,7 +9,7 @@
 	#foreach( $col in $grid.getHeaders() )
 	{
 	  #set( $mapIndx = $index - $metaData  )
-	  "xtype": 	#if( $index > $metaData && $mapSuggestedValues.get($mapIndx).size() > 0 )
+	  "xtype": 	#if( $mapSuggestedValues.get($mapIndx) && $index > $metaData && $mapSuggestedValues.get($mapIndx).size() > 0 )
 						"combobox"
 					#else
 						"textfield"