← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9915: Re-put Identifiers and Attribute tab into Tabular report (WIP).

 

------------------------------------------------------------
revno: 9915
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-02-27 21:39:27 +0700
message:
   Re-put Identifiers and Attribute tab into Tabular report (WIP).
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAudit.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditStore.java
  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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAuditService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAuditStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.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/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAudit.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.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/javascript/activityPlan.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonPatientProperties.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.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/PatientAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java	2013-02-22 05:43:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java	2013-02-27 14:39:27 +0000
@@ -44,17 +44,17 @@
      */
     private static final long serialVersionUID = 3026922158464592390L;
 
-    public static final String TYPE_DATE = "DATE";
-
-    public static final String TYPE_STRING = "TEXT";
-
-    public static final String TYPE_INT = "NUMBER";
-
-    public static final String TYPE_BOOL = "YES/NO";
-
-    public static final String TYPE_COMBO = "COMBO";
-
-    public static final String TYPE_CALCULATED = "CALCULATED";
+    public static final String TYPE_DATE = "date";
+
+    public static final String TYPE_STRING = "string";
+
+    public static final String TYPE_INT = "number";
+
+    public static final String TYPE_BOOL = "bool";
+
+    public static final String TYPE_COMBO = "combo";
+
+    public static final String TYPE_CALCULATED = "calculated";
 
     private String description;
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAudit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAudit.java	2012-10-03 06:04:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAudit.java	2013-02-27 14:39:27 +0000
@@ -36,14 +36,20 @@
  */
 public class PatientAudit
 {
+    public static final String MODULE_PATIENT_DASHBOARD = "patient_dashboard";
+
+    public static final String MODULE_TABULAR_REPORT = "tabular_report";
+
     private int id;
 
     private Patient patient;
-    
+
     private String visitor;
 
     private Date date;
 
+    private String accessedModule;
+
     // -------------------------------------------------------------------------
     // Constructor
     // -------------------------------------------------------------------------
@@ -53,11 +59,12 @@
 
     }
 
-    public PatientAudit( Patient patient, Date date, String visitor )
+    public PatientAudit( Patient patient, String visitor, Date date, String accessedModule )
     {
         this.patient = patient;
+        this.visitor = visitor;
         this.date = date;
-        this.visitor = visitor;
+        this.accessedModule = accessedModule;
     }
 
     // -------------------------------------------------------------------------
@@ -104,4 +111,14 @@
         this.visitor = visitor;
     }
 
+    public String getAccessedModule()
+    {
+        return accessedModule;
+    }
+
+    public void setAccessedModule( String accessedModule )
+    {
+        this.accessedModule = accessedModule;
+    }
+
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditService.java	2012-10-18 07:29:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditService.java	2013-02-27 14:39:27 +0000
@@ -49,6 +49,6 @@
 
     Collection<PatientAudit> getPatientAudits( Patient patient );
 
-    PatientAudit getPatientAudit( Patient patient, String visitor, Date date );
+    PatientAudit getPatientAudit( Integer patientId, String visitor, Date date, String accessedModule );
 
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditStore.java	2012-10-18 07:29:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditStore.java	2013-02-27 14:39:27 +0000
@@ -40,6 +40,6 @@
 public interface PatientAuditStore extends GenericStore<PatientAudit>
 {
     Collection<PatientAudit> get( Patient patient );
-
-    PatientAudit get( Patient patient, String visitor, Date date );
+    
+    PatientAudit get( Integer patientId, String visitor, Date date, String accessedModule );
 }

=== 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	2013-02-18 13:12:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-02-27 14:39:27 +0000
@@ -91,7 +91,7 @@
 
     Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder,
-        Boolean completed, Integer min, Integer max, I18n i18n );
+        Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max, I18n i18n );
 
     int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, Boolean completed, Date startDate, Date endDate );

=== 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	2013-02-18 13:12:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-02-27 14:39:27 +0000
@@ -84,7 +84,7 @@
 
     Grid getTabularReport( ProgramStage programStage, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
         Collection<Integer> orgUnits, List<TabularReportColumn> columns, int level, int maxLevel, Date startDate,
-        Date endDate, boolean descOrder, Boolean completed, Integer min, Integer max, I18n i18n );
+        Date endDate, boolean descOrder, Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max, I18n i18n );
 
     int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate, Boolean completed );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAuditService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAuditService.java	2013-01-05 03:03:21 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAuditService.java	2013-02-27 14:39:27 +0000
@@ -79,9 +79,9 @@
     }
 
     @Override
-    public PatientAudit getPatientAudit( Patient patient, String visitor, Date date )
+    public PatientAudit getPatientAudit( Integer patientId, String visitor, Date date, String accessedModule )
     {
-        return patientAuditStore.get( patient, visitor, date );
+        return patientAuditStore.get( patientId, visitor, date, accessedModule );
     }
 
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAuditStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAuditStore.java	2012-11-01 08:48:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAuditStore.java	2013-02-27 14:39:27 +0000
@@ -54,9 +54,11 @@
     }
 
     @Override
-    public PatientAudit get( Patient patient, String visitor, Date date )
+    public PatientAudit get( Integer patientId, String visitor, Date date, String accessedModule )
     {
-        return (PatientAudit) getCriteria( Restrictions.eq( "patient", patient ),
-            Restrictions.eq( "visitor", visitor ), Restrictions.eq( "date", date ) ).uniqueResult();
+        return (PatientAudit) getCriteria( Restrictions.eq( "patient.id", patientId ),
+            Restrictions.eq( "visitor", visitor ), Restrictions.eq( "date", date ),
+            Restrictions.eq( "accessedModule", accessedModule ) ).uniqueResult();
     }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-02-20 08:38:11 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-02-27 14:39:27 +0000
@@ -167,6 +167,17 @@
         executeSql( "ALTER TABLE dataset DROP CONSTRAINT program_name_key" );
         executeSql( "UPDATE userroleauthorities SET authority='F_PROGRAM_PUBLIC_ADD' WHERE authority='F_PROGRAM_ADD'" );
         
+        executeSql( "UPDATE patientaudit SET accessedModule='patient_dashboard' WHERE accessedModule is null" );
+        executeSql( "UPDATE patienttabularreport SET userOrganisationUnit=false WHERE userOrganisationUnit is null" );
+        executeSql( "UPDATE patienttabularreport SET userOrganisationUnitChildren=false WHERE userOrganisationUnitChildren is null" );
+        executeSql( "UPDATE patientattribute SET valueType='date' WHERE valueType='DATE'" );
+        executeSql( "UPDATE patientattribute SET valueType='string' WHERE valueType='TEXT'" );
+        executeSql( "UPDATE patientattribute SET valueType='number' WHERE valueType='NUMBER'" );
+        executeSql( "UPDATE patientattribute SET valueType='bool' WHERE valueType='YES/NO'" );
+        executeSql( "UPDATE patientattribute SET valueType='combo' WHERE valueType='COMBO'" );
+        executeSql( "UPDATE patientattribute SET valueType='calculated' WHERE valueType='CALCULATED'" );
+        executeSql( "UPDATE patientidentifiertype SET type='string' WHERE type='text'" );
+
         updateUid();
     }
 

=== 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	2013-02-18 13:12:14 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-02-27 14:39:27 +0000
@@ -178,14 +178,14 @@
 
     public Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder,
-        Boolean completed, Integer min, Integer max, I18n i18n )
+        Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max, I18n i18n )
     {
         int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
 
         Map<Integer, OrganisationUnitLevel> orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap();
 
         return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits, columns,
-            level, maxLevel, startDate, endDate, descOrder, completed, min, max, i18n );
+            level, maxLevel, startDate, endDate, descOrder, completed, accessPrivateInfo, min, max, i18n );
     }
 
     public int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,

=== 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	2013-02-18 13:12:14 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-02-27 14:39:27 +0000
@@ -55,6 +55,9 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAudit;
+import org.hisp.dhis.patient.PatientAuditService;
+import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.patientreport.PatientAggregateReport;
 import org.hisp.dhis.patientreport.TabularReportColumn;
 import org.hisp.dhis.period.Period;
@@ -68,6 +71,7 @@
 import org.hisp.dhis.system.grid.ListGrid;
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.TextUtils;
+import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.jdbc.support.rowset.SqlRowSet;
@@ -111,6 +115,27 @@
         this.organisationUnitService = organisationUnitService;
     }
 
+    private PatientAuditService patientAuditService;
+
+    public void setPatientAuditService( PatientAuditService patientAuditService )
+    {
+        this.patientAuditService = patientAuditService;
+    }
+
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
+    private PatientService patientService;
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
     // -------------------------------------------------------------------------
     // Implemented methods
     // -------------------------------------------------------------------------
@@ -221,7 +246,8 @@
 
     public Grid getTabularReport( ProgramStage programStage, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
         Collection<Integer> orgUnits, List<TabularReportColumn> columns, int level, int maxLevel, Date startDate,
-        Date endDate, boolean descOrder, Boolean completed, Integer min, Integer max, I18n i18n )
+        Date endDate, boolean descOrder, Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max,
+        I18n i18n )
     {
         // ---------------------------------------------------------------------
         // Headers cols
@@ -256,18 +282,49 @@
         }
 
         grid.addHeader( new GridHeader( "Complete", true, true ) );
+        grid.addHeader( new GridHeader( "PatientId", true, true ) );
 
         // ---------------------------------------------------------------------
         // Get SQL and build grid
         // ---------------------------------------------------------------------
 
         String sql = getTabularReportSql( false, programStage, columns, orgUnits, level, maxLevel, startDate, endDate,
-            descOrder, completed, min, max );
+            descOrder, completed, accessPrivateInfo, min, max );
 
         SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
 
         GridUtils.addRows( grid, rowSet );
 
+        // Save PatientAudit
+
+        if ( accessPrivateInfo != null && accessPrivateInfo )
+        {
+            long millisInDay = 60 * 60 * 24 * 1000;
+            long currentTime = new Date().getTime();
+            long dateOnly = (currentTime / millisInDay) * millisInDay;
+            Date date = new Date( dateOnly );
+            String visitor = currentUserService.getCurrentUsername();
+
+            List<Map<String, Object>> rows = jdbcTemplate.queryForList( sql );
+
+            if ( rows != null && !rows.isEmpty() )
+            {
+                for ( Map<String, Object> row : rows )
+                {
+                    Integer patientId = (Integer) row.get( "patientid" );
+
+                    PatientAudit patientAudit = patientAuditService.getPatientAudit( patientId, visitor, date,
+                        PatientAudit.MODULE_TABULAR_REPORT );
+                    if ( patientAudit == null )
+                    {
+                        Patient patient = patientService.getPatient( patientId );
+                        patientAudit = new PatientAudit( patient, visitor, date, PatientAudit.MODULE_TABULAR_REPORT );
+                        patientAuditService.savePatientAudit( patientAudit );
+                    }
+                }
+            }
+        }
+
         return grid;
     }
 
@@ -275,7 +332,7 @@
         Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate, Boolean completed )
     {
         String sql = getTabularReportSql( true, programStage, columns, organisationUnits, level, maxLevel, startDate,
-            endDate, false, completed, null, null );
+            endDate, false, completed, null, null, null );
 
         return jdbcTemplate.queryForInt( sql );
     }
@@ -632,7 +689,7 @@
 
     private String getTabularReportSql( boolean count, ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> orgUnits, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
-        Boolean completed, Integer min, Integer max )
+        Boolean completed, Boolean accessPrivateInfo, Integer min, Integer max )
     {
         Set<String> deKeys = new HashSet<String>();
         String selector = count ? "count(*) " : "* ";
@@ -726,6 +783,11 @@
         }
 
         sql += " psi.completed ";
+        if ( accessPrivateInfo != null && accessPrivateInfo )
+        {
+            sql += ", p.patientid ";
+        }
+
         sql += "from programstageinstance psi ";
         sql += "left join programinstance pi on (psi.programinstanceid=pi.programinstanceid) ";
         sql += "left join patient p on (pi.patientid=p.patientid) ";

=== 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	2013-02-21 03:39:25 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2013-02-27 14:39:27 +0000
@@ -34,6 +34,9 @@
 		<property name="statementBuilder" ref="statementBuilder" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="patientAuditService" ref="org.hisp.dhis.patient.PatientAuditService" />
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramInstanceStore"

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAudit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAudit.hbm.xml	2012-10-03 06:04:22 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAudit.hbm.xml	2013-02-27 14:39:27 +0000
@@ -16,5 +16,7 @@
 		<property name="date" />
 		
 		<property name="visitor" />
+		
+		<property name="accessedModule" />
 	</class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2013-02-26 06:26:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2013-02-27 14:39:27 +0000
@@ -263,10 +263,10 @@
         long dateOnly = (currentTime / millisInDay) * millisInDay;
         Date date = new Date( dateOnly );
         String visitor = currentUserService.getCurrentUsername();
-        PatientAudit patientAudit = patientAuditService.getPatientAudit( patient, visitor, date );
+        PatientAudit patientAudit = patientAuditService.getPatientAudit( patientId, visitor, date, PatientAudit.MODULE_PATIENT_DASHBOARD );
         if ( patientAudit == null )
         {
-            patientAudit = new PatientAudit( patient, date, visitor );
+            patientAudit = new PatientAudit( patient, visitor, date, PatientAudit.MODULE_PATIENT_DASHBOARD );
             patientAuditService.savePatientAudit( patientAudit );
         }
 

=== 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	2013-02-22 04:49:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2013-02-27 14:39:27 +0000
@@ -27,9 +27,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_NUMBER_DATA_ELEMENT;
-import static org.hisp.dhis.patientreport.PatientTabularReport.VALUE_TYPE_OPTION_SET;
+import static org.hisp.dhis.patientreport.PatientTabularReport.*;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -49,6 +47,11 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.patient.PatientAttribute;
+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.patientreport.TabularReportColumn;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
@@ -104,10 +107,38 @@
         this.currentUserService = currentUserService;
     }
 
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
+    private List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
+
+    public List<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
+    private List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
+
+    public List<PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
     private Collection<Integer> orgunitIds = new HashSet<Integer>();
 
     public void setOrgunitIds( Collection<Integer> orgunitIds )
@@ -267,6 +298,8 @@
         return message;
     }
 
+    private boolean accessPrivateInfo = false;
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -376,14 +409,14 @@
                 this.paging = createPaging( totalRecords );
 
                 grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
-                    startValue, endValue, !orderByOrgunitAsc, useCompletedEvents, getStartPos(), paging.getPageSize(),
-                    i18n );
+                    startValue, endValue, !orderByOrgunitAsc, useCompletedEvents, accessPrivateInfo, getStartPos(),
+                    paging.getPageSize(), i18n );
             }
+            // Download as Excel
             else
-            // Download as Excel
             {
                 grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
-                    startValue, endValue, !orderByOrgunitAsc, useCompletedEvents, null, null, i18n );
+                    startValue, endValue, !orderByOrgunitAsc, useCompletedEvents, accessPrivateInfo, null, null, i18n );
             }
         }
         catch ( SQLGrammarException ex )
@@ -435,7 +468,29 @@
                 column.setHidden( Boolean.parseBoolean( values[2] ) );
                 column.setQuery( values.length == 4 ? TextUtils.lower( values[3] ) : null );
 
-                if ( PREFIX_DATA_ELEMENT.equals( prefix ) )
+                if ( PREFIX_FIXED_ATTRIBUTE.equals( prefix ) )
+                {
+                    column.setName( values[1] );
+                    accessPrivateInfo = true;
+                }
+                else if ( PREFIX_IDENTIFIER_TYPE.equals( prefix ) )
+                {
+                    PatientIdentifierType identifierType = patientIdentifierTypeService
+                        .getPatientIdentifierType( column.getIdentifierAsInt() );
+
+                    column.setName( identifierType.getName() );
+                }
+                else if ( PREFIX_PATIENT_ATTRIBUTE.equals( prefix ) )
+                {
+                    PatientAttribute attribute = patientAttributeService.getPatientAttribute( column
+                        .getIdentifierAsInt() );
+                    patientAttributes.add( attribute );
+                    valueTypes.add( attribute.getValueType() );
+                    mapSuggestedValues.put( index, getSuggestedAttributeValues( attribute ) );
+
+                    column.setName( attribute.getName() );
+                }
+                else if ( PREFIX_DATA_ELEMENT.equals( prefix ) )
                 {
                     int objectId = Integer.parseInt( values[1] );
                     DataElement dataElement = dataElementService.getDataElement( objectId );
@@ -462,6 +517,27 @@
         return columns;
     }
 
+    private List<String> getSuggestedAttributeValues( PatientAttribute patientAttribute )
+    {
+        List<String> values = new ArrayList<String>();
+        String valueType = patientAttribute.getValueType();
+
+        if ( valueType.equals( PatientAttribute.TYPE_BOOL ) )
+        {
+            values.add( i18n.getString( "yes" ) );
+            values.add( i18n.getString( "no" ) );
+        }
+        else if ( valueType.equals( PatientAttribute.TYPE_COMBO ) )
+        {
+            for ( PatientAttributeOption attributeOption : patientAttribute.getAttributeOptions() )
+            {
+                values.add( attributeOption.getName() );
+            }
+        }
+
+        return values;
+    }
+
     private List<String> getSuggestedDataElementValues( DataElement dataElement )
     {
         List<String> values = new ArrayList<String>();

=== 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	2013-02-26 03:21:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-02-27 14:39:27 +0000
@@ -880,6 +880,10 @@
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientIdentifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 	</bean>
 
 	<bean

=== 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	2013-02-26 02:41:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-02-27 14:39:27 +0000
@@ -554,4 +554,5 @@
 sum_avg_of = Sum/Avg of
 filter = Filter
 multiple_periods_selected_as_filter = Multiple periods selected as filter. The first one is being used.
-multiple_orgunits_selected_as_filter = Multiple organisation units selected as filter. The first one is being used.
\ No newline at end of file
+multiple_orgunits_selected_as_filter = Multiple organisation units selected as filter. The first one is being used.
+accessed_module = Accessed module
\ No newline at end of file

=== 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	2013-02-25 03:34:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-02-27 14:39:27 +0000
@@ -40,6 +40,7 @@
             path_api: '../../api/',
             path_images: 'images/',
 			initialize: 'tabularInitialize.action',
+			patientproperties_get: 'loadPatientProperties.action',
 			programstages_get: 'loadReportProgramStages.action',
 			dataelements_get: 'loadDataElements.action',
 			organisationunitchildren_get: 'getOrganisationUnitChildren.action',
@@ -170,7 +171,17 @@
         window_favorite_ypos: 100,
         window_confirm_width: 250,
 		window_record_width: 450,
-		window_record_height: 300
+		window_record_height: 300,
+		west_dataelements_multiselect: 120,
+		west_dataelements_filter_panel: 135,
+		west_dataelements_expand_filter_panel: 280,
+		west_dataelements_collapse_filter_panel: 130,
+		west_dataelements_expand_aggregate_filter_panel: 230,
+		west_dataelements_collapse_aggregate_filter_panel: 80,
+		west_properties_multiselect: 150,
+		west_properties_filter_panel: 130,
+		west_properties_expand_filter_panel: 280,
+		west_properties_collapse_filter_panel: 135
     },
 	util: {
 		jsonEncodeString: function(str) {
@@ -213,6 +224,7 @@
         params: {
             program:{},
 			programStage: {},
+			patientProperty: {},
 			dataelement: {},
 			organisationunit: {},
 			relativeperiod: {
@@ -282,7 +294,8 @@
                 return ((screen.height/2)-((cmp.height/2)-100));
             },
             resizeParams: function() {
-				var a = [TR.cmp.params.dataelement.panel, 
+				var a = [TR.cmp.params.patientProperty.panel,
+						 TR.cmp.params.dataelement.panel, 
 						 TR.cmp.params.organisationunit.treepanel];
 				for (var i = 0; i < a.length; i++) {
 					if (!a[i].collapsed) {
@@ -308,9 +321,9 @@
                 }
                 this.filterAvailable(a, s);
 				
-				if(f)
+				if(f!=undefined)
 				{
-					this.addFilterField( 'filterPanel', selected[0], name, valueType );
+					this.addFilterField( f, selected[0], name, valueType );
 				}
             },
             selectAll: function(a, s, f) {
@@ -325,7 +338,10 @@
 						var valueType = a.store.getAt(i).data.valueType;
 						
 						array.push({id: id, name: name, compulsory: a.store.getAt(i).data.compulsory, valueType: valueType});
-						this.addFilterField( 'filterPanel', id, name, valueType );
+						if(f!=undefined)
+						{
+							this.addFilterField( f, id, name, valueType );
+						}
 					}
 				}
 				s.store.add(array);
@@ -339,9 +355,9 @@
                     });                    
                     this.filterAvailable(a, s);
                 }
-				if(f)
+				if(f!=undefined)
 				{
-					this.removeFilterField( 'filterPanel', selected[0], a.store.getAt(a.store.findExact('id', selected)).data.valueType );
+					this.removeFilterField( f, selected[0], a.store.getAt(a.store.findExact('id', selected)).data.valueType );
 				}
             },
             unselectAll: function(a, s, f) {
@@ -352,7 +368,10 @@
 					if( elements[index].style.display != 'none' )
 					{
 					  arr.push(item.data.id);
-					  TR.util.multiselect.removeFilterField( 'filterPanel', item.data.id, item.data.valueType );
+					  if(f!=undefined)
+					  {
+						TR.util.multiselect.removeFilterField( f, item.data.id, item.data.valueType );
+					  }
 					}
 					index++;
 				}); 
@@ -1016,6 +1035,28 @@
 									TR.state.orgunitIds.push( f.orgunitIds[i].localid );
 								}
 								
+								 // Patient properties
+								 TR.store.patientProperty.selected.removeAll();
+								 
+								 // programs with registration
+								 if (f.patientProperties && f.type != "3" ) {
+										 for (var i = 0; i < f.patientProperties.length; i++) {
+												 TR.cmp.params.patientProperty.objects.push({id: f.patientProperties[i].id, name: TR.util.string.getEncodedString(f.patientProperties[i].name)});
+										 }
+										 TR.store.patientProperty.selected.add(TR.cmp.params.patientProperty.objects);
+								 
+										 var storePatientProperty = TR.store.patientProperty.available;
+										 storePatientProperty.parent = f.programId;
+										 if (TR.util.store.containsParent(storePatientProperty)) {
+												 TR.util.store.loadFromStorage(storePatientProperty);
+												 TR.util.multiselect.filterAvailable(TR.cmp.params.patientProperty.available, TR.cmp.params.patientProperty.selected);
+										 }
+										 else {
+												 storePatientProperty.load({params: {programId: f.programId}});
+										 }
+								 
+								 }
+                                                         
 								// Data element
 								
 								Ext.getCmp('filterPanel').removeAll();
@@ -1275,6 +1316,32 @@
 				}
 			}
 		}),
+		patientProperty: {
+			available: Ext.create('Ext.data.Store', {
+				 fields: ['id', 'name', 'valueType'],
+				 proxy: {
+					 type: 'ajax',
+					 url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.patientproperties_get,
+					 reader: {
+						 type: 'json',
+						 root: 'patientProperties'
+					 }
+				 },
+				 isloaded: false,
+				 storage: {},
+				 listeners: {
+					 load: function(s) {
+						 this.isloaded = true;
+						 TR.util.store.addToStorage(s);
+						 TR.util.multiselect.filterAvailable(TR.cmp.params.patientProperty.available, TR.cmp.params.patientProperty.selected);
+					 }
+				 }
+			 }),
+			 selected: Ext.create('Ext.data.Store', {
+				 fields: ['id', 'name'],
+				 data: []
+			 })
+		},
 		programStage: Ext.create('Ext.data.Store', {
 			fields: ['id', 'name'],
 			proxy: {
@@ -1586,6 +1653,42 @@
 				// Get searching values
 				p.searchingValues = [];
 				
+				// Patient properties
+				TR.cmp.params.patientProperty.selected.store.each( function(r) {
+					//p.searchingValues.push( r.data.id + '_false_' );
+					
+					var propId = r.data.id;
+					var valueType = r.data.valueType;
+					var length = Ext.getCmp('p_' + propId).items.length/4;
+					var hidden = TR.state.caseBasedReport.isColHidden(propId);
+					
+					for(var idx=0;idx<length;idx++)
+					{
+						var id = propId + '_' + idx;
+						var filterValue = Ext.getCmp('filter_' + id).rawValue;
+						var filter = propId + '_' + hidden 
+						if( filterValue!=''){
+							var filterOpt = Ext.getCmp('filter_opt_' + id).rawValue;
+							filter += '_' + filterOpt + ' ';
+							if( filterOpt == 'IN' )
+							{
+								var filterValues = filterValue.split(";");
+								filter +="(";
+								for(var i=0;i<filterValues.length;i++)
+								{
+									filter += "'"+ filterValues[i] +"',";
+								}
+								filter = filter.substr(0,filter.length - 1) + ")";
+							}
+							else
+							{
+								filter += "'" + filterValue + "'";
+							}
+						}
+						p.searchingValues.push( filter );
+					}
+				});
+				
 				TR.cmp.params.dataelement.selected.store.each( function(r) {
 					var valueType = r.data.valueType;
 					var deId = r.data.id;
@@ -1600,7 +1703,6 @@
 						if( filterValue!=''){
 							var filterOpt = Ext.getCmp('filter_opt_' + id).rawValue;
 							filter += '_' + filterOpt + ' ';
-						
 							if( filterOpt == 'IN' )
 							{
 								var filterValues = filterValue.split(";");
@@ -1897,7 +1999,12 @@
 					p.deGroupBy = Ext.getCmp('dataElementGroupByCbx').getValue().split('_')[1];
 				}
 				
-				// Filter values
+				// Filter values for patient-properties
+				TR.cmp.params.patientProperty.selected.store.each( function(r) {
+					p.searchingValues.push( r.data.id + '_false_' );
+				});
+				
+				// Filter values for data-elements
 				
 				p.deFilters = [];
 				TR.cmp.params.dataelement.selected.store.each( function(r) {
@@ -2445,6 +2552,19 @@
 					}
 				}
 				
+				// Patient properties columns
+			
+				TR.cmp.params.patientProperty.selected.store.each( function(r) {
+					cols[++index] = {
+						header: r.data.name, 
+						dataIndex: 'col' + index,
+						height: TR.conf.layout.east_gridcolumn_height,
+						name: r.data.id,
+						sortable: false,
+						draggable: false
+					}
+				});
+				
 				// Data element columns
 				
 				TR.cmp.params.dataelement.selected.store.each( function(r) {
@@ -2753,6 +2873,28 @@
 											TR.state.isFilter = false;
 											var pId = cb.getValue();
 											
+											// Registration programs
+											if( cb.displayTplData[0].type !='3' )
+											{
+												// IDENTIFIER TYPE && PATIENT ATTRIBUTES
+												var storePatientProperty = TR.store.patientProperty.available;
+												TR.store.patientProperty.selected.removeAll();
+												storePatientProperty.parent = pId;
+												
+												if (TR.util.store.containsParent(storePatientProperty)) {
+													TR.util.store.loadFromStorage(storePatientProperty);
+													TR.util.multiselect.filterAvailable(TR.cmp.params.patientProperty.available, TR.cmp.params.patientProperty.selected);
+												}
+												else {
+													storePatientProperty.load({params: {programId: pId}});
+												}
+											}
+											else
+											{
+												TR.store.patientProperty.available.removeAll();
+												TR.store.patientProperty.selected.removeAll();
+											}
+										
 											// PROGRAM-STAGE										
 											var storeProgramStage = TR.store.programStage;
 											TR.store.dataelement.available.removeAll();
@@ -3273,7 +3415,7 @@
 																icon: 'images/arrowright.png',
 																width: 22,
 																handler: function() {
-																	TR.util.multiselect.select(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected);
+																	TR.util.multiselect.select(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected,'filterPropPanel');
 																}
 															},
 															{
@@ -3281,7 +3423,7 @@
 																icon: 'images/arrowrightdouble.png',
 																width: 22,
 																handler: function() {
-																	TR.util.multiselect.selectAll(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected);
+																	TR.util.multiselect.selectAll(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected,'filterPropPanel');
 																}
 															},
 															' '
@@ -3696,6 +3838,192 @@
 										}
 									},
 									
+									// IDENTIFIER TYPE AND PATIENT-ATTRIBUTE
+									
+									{
+										title: '<div style="height:17px;background-image:url(images/data.png); background-repeat:no-repeat; padding-left:20px">' + TR.i18n.identifiers_and_attributes + '</div>',
+										hideCollapseTool: true,
+										items: [
+											{
+												xtype: 'panel',
+												layout: 'column',
+												bodyStyle: 'border-style:none',
+												items: [
+													{
+														xtype: 'multiselect',
+														id: 'availablePatientProperties',
+														name: 'availablePatientProperties',
+														cls: 'tr-toolbar-multiselect-left',
+														width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor) / 2,
+														height: TR.conf.layout.west_properties_multiselect,
+														displayField: 'name',
+														valueField: 'id',
+														queryMode: 'local',
+														store: TR.store.patientProperty.available,
+														tbar: [
+															{
+																xtype: 'label',
+																text: TR.i18n.available,
+																cls: 'tr-toolbar-multiselect-left-label'
+															},
+															'->',
+															{
+																xtype: 'button',
+																icon: 'images/arrowright.png',
+																width: 22,
+																handler: function() {
+																	TR.util.multiselect.select(TR.cmp.params.patientProperty.available, TR.cmp.params.patientProperty.selected,'filterPropPanel');
+																}
+															},
+															{
+																xtype: 'button',
+																icon: 'images/arrowrightdouble.png',
+																width: 22,
+																handler: function() {
+																	TR.util.multiselect.selectAll(TR.cmp.params.patientProperty.available, TR.cmp.params.patientProperty.selected,'filterPropPanel');
+																}
+															},
+															' '
+														],
+														listeners: {
+															added: function() {
+																TR.cmp.params.patientProperty.available = this;
+															},                                                                
+															afterrender: function() {
+																this.boundList.on('itemdblclick', function() {
+																	TR.util.multiselect.select(this, TR.cmp.params.patientProperty.selected,'filterPropPanel');
+																}, this);
+															}
+														}
+													},                                            
+													{
+														xtype: 'multiselect',
+														id: 'selectedPatientProperties',
+														name: 'selectedPatientProperties',
+														cls: 'tr-toolbar-multiselect-right',
+														width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor) / 2,
+														height: TR.conf.layout.west_properties_multiselect,
+														displayField: 'name',
+														valueField: 'id',
+														ddReorder: true,
+														queryMode: 'local',
+														store: TR.store.patientProperty.selected,
+														tbar: [
+															' ',
+															{
+																xtype: 'button',
+																icon: 'images/arrowleftdouble.png',
+																width: 22,
+																handler: function() {
+																	TR.util.multiselect.unselectAll(TR.cmp.params.patientProperty.available, TR.cmp.params.patientProperty.selected,'filterPropPanel');
+																}
+															},
+															{
+																xtype: 'button',
+																icon: 'images/arrowleft.png',
+																width: 22,
+																handler: function() {
+																	TR.util.multiselect.unselect(TR.cmp.params.patientProperty.available, TR.cmp.params.patientProperty.selected,'filterPropPanel');
+																}
+															},
+															'->',
+															{
+																xtype: 'label',
+																text: TR.i18n.selected,
+																cls: 'tr-toolbar-multiselect-right-label'
+															}
+														],
+														listeners: {
+															added: function() {
+																TR.cmp.params.patientProperty.selected = this;
+															},          
+															afterrender: function() {
+																this.boundList.on('itemdblclick', function() {
+																	TR.util.multiselect.unselect(TR.cmp.params.patientProperty.available, this,'filterPropPanel');
+																}, this);
+															}
+														}
+													},
+													{
+														xtype: 'toolbar',
+														width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor),
+														cls: 'tr-toolbar-multiselect-left',
+														style: 'margin-top:10px;',
+														items: [
+															{
+																xtype: 'label',	
+																text: TR.i18n.filter_values,
+																cls: 'tr-toolbar-multiselect-left-label'
+															},
+															'->',
+															{
+																xtype: 'button',
+																icon: 'images/arrowup.png',
+																tooltip: TR.i18n.show_hide_filter_values,
+																up: true,
+																width: 22,
+																handler: function() {
+																	if(this.up==true){
+																		Ext.getCmp('availablePatientProperties').setVisible(false);
+																		Ext.getCmp('selectedPatientProperties').setVisible(false);
+																		if(Ext.getCmp('reportTypeGroup').getValue().reportType=='true'){
+																			Ext.getCmp('filterPropPanel').setHeight(TR.conf.layout.west_properties_expand_filter_panel);
+																		}
+																		else{
+																			Ext.getCmp('filterPropPanel').setHeight(TR.conf.layout.west_properties_collapse_filter_panel);
+																		}
+																		this.setIcon('images/arrowdown.png');
+																		this.up = false;
+																	}
+																	else{
+																		Ext.getCmp('availablePatientProperties').setVisible(true);
+																		Ext.getCmp('selectedPatientProperties').setVisible(true);
+																		if(Ext.getCmp('reportTypeGroup').getValue().reportType=='true'){
+																			Ext.getCmp('filterPropPanel').setHeight(TR.conf.layout.west_properties_collapse_filter_panel);
+																		}
+																		else{
+																			Ext.getCmp('filterPropPanel').setHeight(TR.conf.layout.west_properties_expand_filter_panel);
+																		}
+																		this.setIcon('images/arrowup.png');
+																		this.up = true;
+																	}
+																}
+															}
+														]
+													},
+													{
+														xtype: 'panel',
+														layout: 'column',
+														id: 'filterPropPanel',
+														height: TR.conf.layout.west_properties_filter_panel,
+														bodyStyle: 'background-color:transparent; padding:10px 10px 0px 3px',
+														autoScroll: true,
+														overflowX: 'hidden',
+														overflowY: 'auto',
+														width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor) ,
+														items: []
+													}
+												]
+											}
+											
+										],
+										listeners: {
+											added: function() {
+												TR.cmp.params.patientProperty.panel = this;
+											},
+											expand: function() {
+												var programId = TR.cmp.settings.program.getValue();	
+												if( programId != null )
+												{
+													var programType = TR.cmp.settings.program.displayTplData[0].type;											
+													if (programId != null && !TR.store.patientProperty.available.isloaded && programType !='3') {
+														TR.store.patientProperty.available.load({params: {programId: programId}});
+													}
+												}
+											}
+										}
+									},
+									
 									// DATA ELEMENTS
 									{
 										title: '<div id="dataElementTabTitle" style="height:17px;background-image:url(images/data.png); background-repeat:no-repeat; padding-left:20px;">' + TR.i18n.data_filter + '</div>',
@@ -3723,7 +4051,7 @@
 																icon: 'images/arrowright.png',
 																width: 22,
 																handler: function() {
-																	TR.util.multiselect.select(TR.cmp.params.dataelement.available, TR.cmp.params.dataelement.selected, true);
+																	TR.util.multiselect.select(TR.cmp.params.dataelement.available, TR.cmp.params.dataelement.selected, 'filterPanel');
 																	TR.util.multiselect.filterSelector( TR.cmp.params.dataelement.available, Ext.getCmp('deFilterAvailable').getValue());
 																}
 															},
@@ -3732,7 +4060,7 @@
 																icon: 'images/arrowrightdouble.png',
 																width: 22,
 																handler: function() {
-																	TR.util.multiselect.selectAll(TR.cmp.params.dataelement.available, TR.cmp.params.dataelement.selected, true);
+																	TR.util.multiselect.selectAll(TR.cmp.params.dataelement.available, TR.cmp.params.dataelement.selected, 'filterPanel');
 																	TR.util.multiselect.filterSelector( TR.cmp.params.dataelement.available, Ext.getCmp('deFilterAvailable').getValue());
 																}
 															},
@@ -3778,7 +4106,7 @@
 														name: 'availableDataelements',
 														cls: 'tr-toolbar-multiselect-left',
 														width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor) / 2,
-														height: 120,
+														height: TR.conf.layout.west_dataelements_multiselect,
 														displayField: 'name',
 														valueField: 'id',
 														queryMode: 'remote',
@@ -3830,7 +4158,7 @@
 															},                                                                
 															afterrender: function() {
 																this.boundList.on('itemdblclick', function() {
-																	TR.util.multiselect.select(this, TR.cmp.params.dataelement.selected, true);
+																	TR.util.multiselect.select(this, TR.cmp.params.dataelement.selected, 'filterPanel');
 																	TR.util.multiselect.filterSelector( TR.cmp.params.dataelement.available, Ext.getCmp('deFilterAvailable').getValue());
 																}, this);																
 															}
@@ -3842,7 +4170,7 @@
 														name: 'selectedDataelements',
 														cls: 'tr-toolbar-multiselect-right',
 														width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor) / 2,
-														height: 120,
+														height: TR.conf.layout.west_dataelements_multiselect,
 														displayField: 'name',
 														valueField: 'id',
 														ddReorder: true,
@@ -3926,10 +4254,10 @@
 																		Ext.getCmp('availableDataelements').setVisible(false);
 																		Ext.getCmp('selectedDataelements').setVisible(false);
 																		if(Ext.getCmp('reportTypeGroup').getValue().reportType=='true'){
-																			Ext.getCmp('filterPanel').setHeight(300);
+																			Ext.getCmp('filterPanel').setHeight(TR.conf.layout.west_dataelements_expand_filter_panel);
 																		}
 																		else{
-																			Ext.getCmp('filterPanel').setHeight(255);
+																			Ext.getCmp('filterPanel').setHeight(TR.conf.layout.west_dataelements_expand_aggregate_filter_panel);
 																		}
 																		this.setIcon('images/arrowdown.png');
 																		this.up = false;
@@ -3940,10 +4268,10 @@
 																		Ext.getCmp('availableDataelements').setVisible(true);
 																		Ext.getCmp('selectedDataelements').setVisible(true);
 																		if(Ext.getCmp('reportTypeGroup').getValue().reportType=='true'){
-																			Ext.getCmp('filterPanel').setHeight(155);
+																			Ext.getCmp('filterPanel').setHeight(TR.conf.layout.west_dataelements_collapse_filter_panel);
 																		}
 																		else{
-																			Ext.getCmp('filterPanel').setHeight(105);
+																			Ext.getCmp('filterPanel').setHeight(TR.conf.layout.west_dataelements_collapse_aggregate_filter_panel);
 																		}
 																		this.setIcon('images/arrowup.png');
 																		this.up = true;
@@ -3960,7 +4288,7 @@
 														autoScroll: true,
 														overflowX: 'hidden',
 														overflowY: 'auto',
-														height: 160,
+														height: TR.conf.layout.west_dataelements_filter_panel,
 														width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor) ,
 														items: []
 													}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2012-12-18 06:17:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2013-02-27 14:39:27 +0000
@@ -6,10 +6,10 @@
 	$('#contentDataRecord').html('');
 	setFieldValue('orgunitName', orgUnitNames[0]);
 	setFieldValue('orgunitId', orgUnits[0]);
+	jQuery( '#programIdAddPatient').append( '<option value="">' + i18n_please_select + '</option>' );
 	jQuery.get("getPrograms.action",{}, 
 		function(json)
 		{
-			jQuery( '#programIdAddPatient').append( '<option value="">' + i18n_please_select + '</option>' );
 			for ( i in json.programs ) {
 				if(json.programs[i].type==1){
 					jQuery( '#programIdAddPatient').append( '<option value="' + json.programs[i].id +'" type="' + json.programs[i].type + '">' + json.programs[i].name + '</option>' );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonPatientProperties.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonPatientProperties.vm	2013-02-13 15:58:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonPatientProperties.vm	2013-02-27 14:39:27 +0000
@@ -1,47 +1,61 @@
 { "patientProperties": [
   {
 	"id": "fixedAttr_firstName",
-	"name": "$i18n.getString('first_name')"
+	"name": "$i18n.getString('first_name')",
+	"valueType": "string"
   },
   {
 	"id": "fixedAttr_middleName",
-	"name": "$i18n.getString('middle_name')"
+	"name": "$i18n.getString('middle_name')",
+	"valueType": "string"
   },
   {
 	"id": "fixedAttr_lastName",
-	"name": "$i18n.getString('last_name')"
+	"name": "$i18n.getString('last_name')",
+	"valueType": "string"
   },
   {
 	"id": "fixedAttr_gender",
-	"name": "$i18n.getString('gender')"
+	"name": "$i18n.getString('gender')",
+	"valueType": "string"
   },
   {
 	"id": "fixedAttr_birthDate",
-	"name": "$i18n.getString('date_of_birth')"
+	"name": "$i18n.getString('date_of_birth')",
+	"valueType": "date"
   },
   {
 	"id": "fixedAttr_dobType",
-	"name": "$i18n.getString('dob_type')"
+	"name": "$i18n.getString('dob_type')",
+	"valueType": "list"
   },
   {
 	"id": "fixedAttr_phoneNumber",
-	"name": "$i18n.getString('phone_number')"
+	"name": "$i18n.getString('phone_number')",
+	"valueType": "string"
   },
   {
 	"id": "fixedAttr_deathdate",
-	"name": "$i18n.getString('death_date')"
+	"name": "$i18n.getString('death_date')",
+	"valueType": "date"
   },
   #foreach( ${identifierType} in $!{identifierTypes} )
   {
 	"id": "iden_${identifierType.id}",
-	"name": "$!encoder.jsonEncode( ${identifierType.displayName} )"
+	"name": "$!encoder.jsonEncode( ${identifierType.displayName} )",
+	"valueType": "$identifierType.type"
   },
   #end
   #set( $size = $!{patientAttributes.size()} )
   #foreach( $patientAttribute in $!{patientAttributes} )
   {
     "id": "attr_${patientAttribute.id}",
-	"name": "$!encoder.jsonEncode( ${patientAttribute.displayName} )"
+	"name": "$!encoder.jsonEncode( ${patientAttribute.displayName} )",
+	"valueType": #if( $patientAttribute.valueType == 'combo')
+					"list"
+				 #else
+					"${patientAttribute.valueType}"
+				 #end
   }#if( $velocityCount < $size ),#end
   #end
   ]

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2013-02-26 03:21:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2013-02-27 14:39:27 +0000
@@ -197,21 +197,24 @@
 <br>
 <div id='programEnrollmentDiv' class='hidden'></div>
 <div id='dataEntryFormDiv'></div>
-<div id='dashboardHistoryDiv' class="dashboard-history" style="display:none;height:250px;width:300px;">
-	<table width="300px;">
+<div id='dashboardHistoryDiv' class="dashboard-history" style="display:none;height:250px;width:400px;">
+	<table width="400px;">
 		<colgroup>
-			<col width="150px">
+			<col width="100px">
+			<col width="100px">
 			<col>
 		</colgroup>
 		<tr>
 			<th>$i18n.getString("date")</th>
 			<th>$i18n.getString("visitor")</th>
+			<th>$i18n.getString("accessed_module")</th>
 		</tr>
 	</table>
-	<div style="height:200px;width:300px;overflow:auto">
-		<table width='280px'>
+	<div style="height:200px;width:450px;overflow:auto">
+		<table width='400px'>
 			<colgroup>
-				<col width="150px">
+				<col width="100px">
+				<col width="100px">
 				<col>
 			</colgroup>
 			#set( $mark = false )
@@ -219,6 +222,7 @@
 			<tr #alternate( $mark )>
 				<td>$format.formatDate($patientAudit.date)</td>
 				<td>$encoder.htmlEncode($patientAudit.visitor)</td>
+				<td>$i18n.getString($patientAudit.accessedModule)</td>
 			</tr>
 			#set( $mark = !$mark )
 			#end