← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7162: (patient) Improve Person Query Builder.

 

------------------------------------------------------------
revno: 7162
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-06-04 11:06:04 +0700
message:
  (patient) Improve Person Query Builder.
removed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetProgramStagesAction.java
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonParamsByProgram.vm
renamed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPSDataElementsAction.java => dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPatientDataElementsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responsePSDataElement.vm => dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonPatientDataElements.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionDeletionHandler.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.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/resources/org/hisp/dhis/caseaggregation/hibernate/CaseAggregationCondition.hbm.xml
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/AddCaseAggregationConditionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/UpdateCaseAggregationConditionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addCaseAggregationForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateCaseAggregationForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPatientDataElementsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonPatientDataElements.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/caseaggregation/CaseAggregationCondition.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java	2012-02-08 12:43:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java	2012-06-04 04:06:04 +0000
@@ -27,6 +27,7 @@
 
 package org.hisp.dhis.caseaggregation;
 
+import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 
@@ -36,48 +37,46 @@
  * @version CaseAggregationCondition.java Nov 17, 2010 10:47:12 AM
  */
 public class CaseAggregationCondition
+    extends BaseIdentifiableObject
 {
+    private static final long serialVersionUID = -5746649805915250424L;
+
     public static final String SEPARATOR_ID = "\\.";
 
     public static final String SEPARATOR_OBJECT = ":";
-    
 
     public static final String AGGRERATION_COUNT = "COUNT";
 
     public static final String AGGRERATION_SUM = "SUM";
-    
-    
+
     public static final String OPERATOR_AND = "AND";
 
     public static final String OPERATOR_OR = "OR";
-    
 
     public static String OBJECT_PROGRAM_STAGE_DATAELEMENT = "DE";
 
     public static String OBJECT_PATIENT_ATTRIBUTE = "CA";
 
     public static String OBJECT_PATIENT_PROPERTY = "CP";
-    
+
     public static String OBJECT_PROGRAM_PROPERTY = "PP";
-    
+
     public static String OBJECT_PROGRAM = "PG";
-    
+
     public static String OBJECT_PATIENT = "PT";
-    
+
     public static String OBJECT_PROGRAM_STAGE = "PS";
+    
+    public static String OBJECT_PROGRAM_STAGE_PROPERTY = "PSP";
 
     // -------------------------------------------------------------------------
     // Fields
     // -------------------------------------------------------------------------
 
-    private Integer id;
-
     private String operator;
 
     private String aggregationExpression;
 
-    private String description;
-
     private DataElement aggregationDataElement;
 
     private DataElementCategoryOptionCombo optionCombo;
@@ -91,10 +90,10 @@
 
     }
 
-    public CaseAggregationCondition( String description, String operator, String aggregationExpression, 
+    public CaseAggregationCondition( String name, String operator, String aggregationExpression,
         DataElement aggregationDataElement, DataElementCategoryOptionCombo optionCombo )
     {
-        this.description = description;
+        this.name = name;
         this.operator = operator;
         this.aggregationExpression = aggregationExpression;
         this.aggregationDataElement = aggregationDataElement;
@@ -146,11 +145,6 @@
     // Getters && Setters
     // -------------------------------------------------------------------------
 
-    public Integer getId()
-    {
-        return id;
-    }
-
     public DataElement getAggregationDataElement()
     {
         return aggregationDataElement;
@@ -195,15 +189,4 @@
     {
         this.aggregationExpression = aggregationExpression;
     }
-
-    public String getDescription()
-    {
-        return description;
-    }
-
-    public void setDescription( String description )
-    {
-        this.description = description;
-    }
-
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionDeletionHandler.java	2012-02-11 13:58:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionDeletionHandler.java	2012-06-04 04:06:04 +0000
@@ -121,7 +121,7 @@
 
             if ( programs != null && programs.contains( program ) )
             {
-                return condition.getDescription();
+                return condition.getName();
             }
         }
 
@@ -142,7 +142,7 @@
 
             if ( patientAttributes != null && patientAttributes.contains( patientAttribute ) )
             {
-                return condition.getDescription();
+                return condition.getName();
             }
         }
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2012-03-21 09:19:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2012-06-04 04:06:04 +0000
@@ -35,6 +35,7 @@
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT;
+import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_PROPERTY;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OPERATOR_AND;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID;
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT;
@@ -78,8 +79,9 @@
     implements CaseAggregationConditionService
 {
     private final String regExp = "\\[(" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE + "|"
-        + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|"
-        + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+[" + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
+        + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|"
+        + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+["
+        + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
 
     private final String IS_NULL = "is null";
 
@@ -87,7 +89,9 @@
 
     private final String INVALID_CONDITION = "Invalid condition";
 
-    private final String NUMBER_PATIENTS_REGISTERED = "Registered Beneficiaries No";
+    private final String TOTAL_OF_PATIENTS_REGISTERED = "Total of patient registration";
+
+    private final String IN_CONDITION_GET_ALL = "*";
 
     private final String IN_CONDITION_START_SIGN = "@";
 
@@ -210,7 +214,7 @@
         Period period )
     {
         String sql = convertCondition( aggregationCondition, orgunit, period );
-        
+        System.out.println( "\n === \n sql : " + sql );
         Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sql );
 
         if ( patientIds == null )
@@ -261,19 +265,16 @@
     {
         Collection<Patient> result = new HashSet<Patient>();
 
-        // get params
-        int orgunitId = orgunit.getId();
-        String startDate = DateUtils.getMediumDateString( period.getStartDate() );
-        String endDate = DateUtils.getMediumDateString( period.getEndDate() );
-
-        String sql = createSQL( aggregationCondition.getAggregationExpression(), aggregationCondition.getOperator(),
-            orgunitId, startDate, endDate );
+        String sql = convertCondition( aggregationCondition, orgunit, period );
 
         Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sql );
 
-        for ( Integer patientId : patientIds )
+        if ( patientIds != null )
         {
-            result.add( patientService.getPatient( patientId ) );
+            for ( Integer patientId : patientIds )
+            {
+                result.add( patientService.getPatient( patientId ) );
+            }
         }
 
         return result;
@@ -322,19 +323,24 @@
             {
                 String[] ids = info[1].split( SEPARATOR_ID );
 
-                int programStageId = Integer.parseInt( ids[0] );
-                ProgramStage programStage = programStageService.getProgramStage( programStageId );
+                int programId = Integer.parseInt( ids[0] );
+                Program program = programService.getProgram( programId );
 
-                int dataElementId = Integer.parseInt( ids[1] );
+                String programStage = ids[1];
+                if ( !programStage.equals( IN_CONDITION_GET_ALL ) )
+                {
+                    programStage = programStageService.getProgramStage( Integer.parseInt( programStage ) ).getName();
+                }
+                int dataElementId = Integer.parseInt( ids[2] );
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
-                if ( programStage == null || dataElement == null )
+                if ( program == null || dataElement == null )
                 {
                     return INVALID_CONDITION;
                 }
 
-                matcher.appendReplacement( description, "[" + programStage.getName() + SEPARATOR_ID
-                    + dataElement.getName() + "]" );
+                matcher.appendReplacement( description, "[" + program.getName() + SEPARATOR_ID + programStage
+                    + SEPARATOR_ID + dataElement.getName() + "]" );
             }
             else
             {
@@ -343,7 +349,7 @@
                 if ( info[0].equalsIgnoreCase( OBJECT_PATIENT ) )
                 {
                     matcher.appendReplacement( description, "[" + OBJECT_PATIENT + SEPARATOR_OBJECT
-                        + NUMBER_PATIENTS_REGISTERED + "]" );
+                        + TOTAL_OF_PATIENTS_REGISTERED + "]" );
                 }
                 else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) )
                 {
@@ -399,7 +405,7 @@
     public Collection<DataElement> getDataElementsInCondition( String aggregationExpression )
     {
         String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "[0-9]+" + SEPARATOR_ID
-            + "[0-9]+" + "\\]";
+            + "[0-9]+" + SEPARATOR_ID + "[0-9]+" + "\\]";
 
         Collection<DataElement> dataElements = new HashSet<DataElement>();
 
@@ -419,7 +425,7 @@
             String[] info = match.split( SEPARATOR_OBJECT );
             String[] ids = info[1].split( SEPARATOR_ID );
 
-            int dataElementId = Integer.parseInt( ids[1] );
+            int dataElementId = Integer.parseInt( ids[2] );
             DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
             dataElements.add( dataElement );
@@ -430,7 +436,8 @@
 
     public Collection<Program> getProgramsInCondition( String aggregationExpression )
     {
-        String regExp = "\\[" + OBJECT_PROGRAM + SEPARATOR_OBJECT + "[0-9]+\\]";
+        String regExp = "\\[(" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + ")" + SEPARATOR_OBJECT
+            + "[a-zA-Z0-9\\- ]+";
 
         Collection<Program> programs = new HashSet<Program>();
 
@@ -448,9 +455,9 @@
             match = match.replaceAll( "[\\[\\]]", "" );
 
             String[] info = match.split( SEPARATOR_OBJECT );
-
-            int programId = Integer.parseInt( info[1] );
-
+            String[] ids = info[1].split( SEPARATOR_ID );
+
+            int programId = Integer.parseInt( ids[0] );
             Program program = programService.getProgram( programId );
 
             programs.add( program );
@@ -609,22 +616,23 @@
                 {
                     String[] ids = info[1].split( SEPARATOR_ID );
 
-                    int programStageId = Integer.parseInt( ids[0] );
-                    int dataElementId = Integer.parseInt( ids[1] );
+                    int programId = Integer.parseInt( ids[0] );
+                    String programStageId = ids[1];
+                    int dataElementId = Integer.parseInt( ids[2] );
 
                     String valueToCompare = expression[i].replace( "[" + match + "]", "" ).trim();
 
                     if ( valueToCompare.equalsIgnoreCase( IS_NULL ) )
                     {
-                        condition = getConditionForNotDataElement( programStageId, operator, dataElementId, orgunitId,
-                            startDate, endDate );
+                        condition = getConditionForNotDataElement( programId, programStageId, operator, dataElementId,
+                            orgunitId, startDate, endDate );
 
                         expression[i] = expression[i].replace( valueToCompare, "" );
                     }
                     else
                     {
-                        condition = getConditionForDataElement( programStageId, operator, dataElementId, orgunitId,
-                            startDate, endDate );
+                        condition = getConditionForDataElement( programId, programStageId, operator, dataElementId,
+                            orgunitId, startDate, endDate );
                         if ( !expression[i].contains( "+" ) )
                         {
                             condition += " AND pd.value ";
@@ -638,16 +646,25 @@
 
                 else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_PROPERTY ) )
                 {
-                    condition = getConditionForProgramProperty( operator, startDate, endDate ) + info[1];
+                    condition = getConditionForProgramProperty( operator, startDate, endDate, info[1] );
                 }
                 else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM ) )
                 {
-                    condition = getConditionForProgram( info[1], operator, orgunitId, startDate, endDate );
+                    String[] ids = info[1].split( SEPARATOR_ID );
+                    condition = getConditionForProgram( ids[0], operator, orgunitId, startDate, endDate );
+                    if ( ids.length > 1 )
+                    {
+                        condition += ids[1];
+                    }
                 }
                 else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_STAGE ) )
                 {
                     condition = getConditionForProgramStage( info[1], operator, orgunitId, startDate, endDate );
                 }
+                else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_STAGE_PROPERTY ) )
+                {
+                    condition = getConditionForProgramStageProperty( info[1], operator, orgunitId, startDate, endDate );
+                }
 
                 // -------------------------------------------------------------
                 // Replacing the operand with 1 in order to later be able to
@@ -690,8 +707,8 @@
         return getSQL( operator, conditions, operators );
     }
 
-    private String getConditionForNotDataElement( int programStageId, String operator, int dataElementId,
-        int orgunitId, String startDate, String endDate )
+    private String getConditionForNotDataElement( int programId, String programStageId, String operator,
+        int dataElementId, int orgunitId, String startDate, String endDate )
     {
         String sql = "SELECT distinct(pi.patientid) ";
         String condition = "pi.patientid";
@@ -722,21 +739,25 @@
             + "INNER JOIN patientdatavalue as pd ON psi.programstageinstanceid = pd.programstageinstanceid "
             + "WHERE psi.organisationunitid = "
             + orgunitId
-            + " AND ps.programstageid = "
-            + programStageId
-            + " "
+            + " AND pgi.programid = "
+            + programId
             + "AND psi.executionDate >= '"
             + startDate
             + "' AND psi.executionDate <= '"
             + endDate
             + "' "
-            + "AND pd.dataelementid = " + dataElementId + " " + "  ) ";
-
-        return sql;
+            + "AND pd.dataelementid = " + dataElementId + " ";
+
+        if ( !programStageId.equals( IN_CONDITION_GET_ALL ) )
+        {
+            sql += " AND ps.programstageid = " + programStageId;
+        }
+
+        return sql + "  ) ";
     }
 
-    private String getConditionForDataElement( int programStageId, String operator, int dataElementId, int orgunitId,
-        String startDate, String endDate )
+    private String getConditionForDataElement( int programId, String programStageId, String operator,
+        int dataElementId, int orgunitId, String startDate, String endDate )
     {
         String sql = "SELECT distinct(pi.patientid) ";
 
@@ -745,14 +766,20 @@
             sql = "SELECT psi.programstageinstanceid ";
         }
 
-        return sql + "FROM programstageinstance as psi "
+        sql += "FROM programstageinstance as psi "
             + "INNER JOIN programstage as ps ON psi.programstageid = ps.programstageid "
             + "INNER JOIN patientdatavalue as pd ON psi.programstageinstanceid = pd.programstageinstanceid "
             + "INNER JOIN programstage_dataelements as psd ON ps.programstageid = psd.programstageid "
             + "INNER JOIN programinstance as pi ON pi.programinstanceid = psi.programinstanceid "
-            + "WHERE psd.dataelementid = " + dataElementId + " " + "AND psi.organisationunitid = " + orgunitId
-            + " AND ps.programstageid = " + programStageId + " " + "AND psi.executionDate >= '" + startDate
-            + "' AND psi.executionDate <= '" + endDate + "' ";
+            + "WHERE psd.dataelementid = " + dataElementId + " " + "AND psi.organisationunitid = " + orgunitId + " "
+            + "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' ";
+
+        if ( !programStageId.equals( IN_CONDITION_GET_ALL ) )
+        {
+            sql += " AND ps.programstageid = " + programStageId;
+        }
+
+        return sql;
     }
 
     private String getConditionForPatientAttribute( int attributeId, String operator )
@@ -764,7 +791,7 @@
             sql = "SELECT pi.patientid ";
         }
 
-        return sql + "FROM patient as pi " + "INNER JOIN patientattributevalue as pav ON pav.patientid = pi.patientid "
+        return sql + "FROM patient as pi INNER JOIN patientattributevalue as pav ON pav.patientid = pi.patientid "
             + "WHERE pav.patientattributeid = " + attributeId + " " + "AND pav.value ";
     }
 
@@ -801,8 +828,7 @@
 
         if ( propertyName.equals( PROPERTY_AGE ) )
         {
-            sql += "((  12 * ( EXTRACT(YEAR FROM DATE '" + startDate + "' ) - EXTRACT(YEAR FROM birthdate ) ) ) + "
-                + "EXTRACT( MONTH FROM DATE '" + startDate + "' ) - EXTRACT( MONTH FROM birthdate ) )" + " ";
+            sql += "DATE('" + startDate + "') - DATE(birthdate) ";
         }
         else
         {
@@ -812,7 +838,7 @@
         return sql;
     }
 
-    private String getConditionForProgramProperty( String operator, String startDate, String endDate )
+    private String getConditionForProgramProperty( String operator, String startDate, String endDate, String property )
     {
         String sql = "SELECT distinct(pi.patientid) ";
 
@@ -823,7 +849,8 @@
 
         return sql + "FROM programstageinstance as psi "
             + "INNER JOIN programinstance as pi ON psi.programinstanceid = pi.programinstanceid "
-            + "WHERE psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' AND ";
+            + "WHERE psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' AND "
+            + property;
     }
 
     private String getConditionForProgram( String programId, String operator, int orgunitId, String startDate,
@@ -858,6 +885,21 @@
             + "' AND psi.organisationunitid = " + orgunitId + " ";
     }
 
+    private String getConditionForProgramStageProperty( String property, String operator, int orgunitId,
+        String startDate, String endDate )
+    {
+        String select = "SELECT distinct(pi.patientid) ";
+
+        if ( operator.equals( AGGRERATION_SUM ) )
+        {
+            select = "SELECT psi.programstageinstanceid ";
+        }
+
+        return select + "FROM programinstance as pi INNER JOIN programstageinstance psi "
+            + "ON pi.programinstanceid = psi.programinstanceid WHERE " + " psi.executiondate >= '" + startDate
+            + "' AND psi.executiondate <= '" + endDate + "' AND psi.organisationunitid = " + orgunitId + " AND " + property;
+    }
+
     private String getSQL( String aggregateOperator, List<String> conditions, List<String> operators )
     {
         String sql = conditions.get( 0 );

=== 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	2012-05-30 03:30:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-06-04 04:06:04 +0000
@@ -27,8 +27,13 @@
 
 package org.hisp.dhis.patient.startup;
 
+import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT;
+import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID;
+import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT;
+
 import java.sql.ResultSet;
 import java.sql.Statement;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.amplecode.quick.StatementHolder;
@@ -88,7 +93,7 @@
         executeSql( "ALTER TABLE program DROP COLUMN singleevent" );
         executeSql( "ALTER TABLE program DROP COLUMN anonymous" );
         executeSql( "UPDATE program SET type=1 where type is null" );
-        
+
         executeSql( "UPDATE programstage set irregular=false where irregular is null" );
 
         executeSql( "DROP TABLE programattributevalue" );
@@ -98,9 +103,13 @@
 
         executeSql( "ALTER TABLE patientattribute DROP COLUMN noChars" );
         executeSql( "ALTER TABLE programstageinstance ALTER executiondate TYPE date" );
-        
+
         executeSql( "ALTER TABLE patientidentifier ALTER COLUMN patientid DROP NOT NULL" );
         executeSql( "ALTER TABLE patient DROP COLUMN bloodgroup" );
+        executeSql( "ALTER TABLE patientmobilesetting DROP COLUMN bloodGroup" );
+
+        executeSql( "ALTER TABLE caseaggregationcondition RENAME description TO name" );
+        updateCaseAggregationCondition();
     }
 
     // -------------------------------------------------------------------------
@@ -139,6 +148,70 @@
         }
     }
 
+    private void updateCaseAggregationCondition()
+    {
+        String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "[0-9]+" + SEPARATOR_ID
+            + "[0-9]+" + "\\]";
+
+        try
+        {
+            StatementHolder holder = statementManager.getHolder();
+
+            Statement statement = holder.getStatement();
+
+            ResultSet resultSet = statement
+                .executeQuery( "SELECT caseaggregationconditionid, aggregationExpression FROM caseaggregationcondition" );
+
+            while ( resultSet.next() )
+            {
+                StringBuffer formular = new StringBuffer();
+
+                // ---------------------------------------------------------------------
+                // parse expressions
+                // ---------------------------------------------------------------------
+
+                Pattern pattern = Pattern.compile( regExp );
+
+                Matcher matcher = pattern.matcher( resultSet.getString( 2 ) );
+
+                while ( matcher.find() )
+                {
+                    String match = matcher.group();
+                    match = match.replaceAll( "[\\[\\]]", "" );
+
+                    String[] info = match.split( SEPARATOR_OBJECT );
+                    String[] ids = info[1].split( SEPARATOR_ID );
+                    int programStageId = Integer.parseInt( ids[0] );
+
+                    StatementHolder _holder = statementManager.getHolder();
+                    Statement _statement = _holder.getStatement();
+                    ResultSet rsProgramId = _statement
+                        .executeQuery( "SELECT programid FROM programstage where programstageid=" + programStageId );
+
+                    if ( rsProgramId.next() )
+                    {
+                        int programId = rsProgramId.getInt( 1 );
+
+                        String aggregationExpression = "[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT
+                            + programId + "." + programStageId + "." + ids[1] + "]";
+
+                        matcher.appendReplacement( formular, aggregationExpression );
+                    }
+                }
+
+                matcher.appendTail( formular );
+
+                executeSql( "UPDATE caseaggregationcondition SET aggregationExpression='" + formular.toString()
+                    + "'  WHERE caseaggregationconditionid=" + resultSet.getInt( 1 ) );
+
+            }
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
     private int executeSql( String sql )
     {
         try

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/caseaggregation/hibernate/CaseAggregationCondition.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/caseaggregation/hibernate/CaseAggregationCondition.hbm.xml	2011-05-28 21:25:46 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/caseaggregation/hibernate/CaseAggregationCondition.hbm.xml	2012-06-04 04:06:04 +0000
@@ -1,7 +1,9 @@
 <?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";>
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";
+  [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+>
 
 <hibernate-mapping>
   <class name="org.hisp.dhis.caseaggregation.CaseAggregationCondition" table="caseaggregationcondition">
@@ -9,13 +11,13 @@
     <id name="id" column="caseaggregationconditionid">
       <generator class="native" />
     </id>
+    
+	&identifiableProperties;
 
     <property name="operator" not-null="true" />
 
     <property name="aggregationExpression" not-null="true" />
 
-    <property name="description" />
-
     <many-to-one name="aggregationDataElement" class="org.hisp.dhis.dataelement.DataElement" column="aggregationDataElementid"
       foreign-key="fk_caseaggregationcondition_dataelement" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm	2011-09-28 07:11:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm	2012-06-04 04:06:04 +0000
@@ -1,7 +1,7 @@
 { "caseAggregation":
   {
     "id": "${caseAggregation.id}",
-	"description": "$!encoder.jsonEncode( ${caseAggregation.description} )",
+	"name": "$!encoder.jsonEncode( ${caseAggregation.name} )",
 	"operator": "${caseAggregation.operator}",
 	"aggregationDataElement": "$!encoder.jsonEncode( ${caseAggregation.aggregationDataElement.name} )",
 	"optionCombo": "$!encoder.jsonEncode( ${caseAggregation.optionCombo.name} )",

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/AddCaseAggregationConditionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/AddCaseAggregationConditionAction.java	2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/AddCaseAggregationConditionAction.java	2012-06-04 04:06:04 +0000
@@ -62,7 +62,7 @@
 
     private String aggregationCondition;
 
-    private String description;
+    private String name;
 
     private String aggregationDataElementId;
 
@@ -100,9 +100,9 @@
         this.aggregationCondition = aggregationCondition;
     }
 
-    public void setDescription( String description )
+    public void setName( String name )
     {
-        this.description = description;
+        this.name = name;
     }
 
     // -------------------------------------------------------------------------
@@ -120,7 +120,7 @@
         DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
             .getDataElementCategoryOptionCombo( Integer.parseInt( ids[1] ) );
 
-        CaseAggregationCondition condition = new CaseAggregationCondition( description, operator, aggregationCondition,
+        CaseAggregationCondition condition = new CaseAggregationCondition( name, operator, aggregationCondition,
             aggregationDataElement, optionCombo );
 
         aggregationConditionService.addCaseAggregationCondition( condition );

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java	2012-06-04 04:06:04 +0000
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.caseaggregation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $Id: GetParamsByProgramAction.java Jun 02, 2012 02:24:49 PM $
+ */
+public class GetParamsByProgramAction
+    implements Action
+{
+
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    private PatientAttributeService attributeService;
+
+    public void setAttributeService( PatientAttributeService attributeService )
+    {
+        this.attributeService = attributeService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private List<ProgramStage> programStages;
+
+    public List<ProgramStage> getProgramStages()
+    {
+        return programStages;
+    }
+
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    private Collection<PatientAttribute> patientAttributes = new HashSet<PatientAttribute>();
+
+    public Collection<PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+    public String execute()
+    {
+        Program program = programService.getProgram( programId );
+        programStages = new ArrayList<ProgramStage>( program.getProgramStages() );
+
+        if ( program.isRegistration() )
+        {
+            patientAttributes.addAll( attributeService.getPatientAttributes( null, null ) );
+            patientAttributes.addAll( attributeService.getPatientAttributes( program ) );
+        }
+        
+        return SUCCESS;
+    }
+}

=== renamed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPSDataElementsAction.java' => 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPatientDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPSDataElementsAction.java	2012-02-11 13:58:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPatientDataElementsAction.java	2012-06-04 04:06:04 +0000
@@ -28,15 +28,25 @@
 package org.hisp.dhis.patient.action.caseaggregation;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElementService;
 import org.hisp.dhis.program.ProgramStageService;
 
 import com.opensymphony.xwork2.Action;
 
-public class GetPSDataElementsAction
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $Id: GetPatientDataElementsAction.java Mar 09, 2011 01:24:49 PM $
+ */
+public class GetPatientDataElementsAction
     implements Action
 {
 
@@ -44,6 +54,13 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
     private ProgramStageService programStageService;
 
     public void setProgramStageService( ProgramStageService programStageService )
@@ -62,60 +79,51 @@
     // Input & Output
     // -------------------------------------------------------------------------
 
-    private List<String> optionComboNames;
-
-    public List<String> getOptionComboNames()
-    {
-        return optionComboNames;
-    }
-
-    private List<String> optionComboIds;
-
-    public List<String> getOptionComboIds()
-    {
-        return optionComboIds;
-    }
-
-    private List<String> optionComboType;
-
-    public List<String> getOptionComboType()
-    {
-        return optionComboType;
-    }
-
-    private Integer psId;
-
-    public void setPsId( Integer psId )
-    {
-        this.psId = psId;
-    }
-    
-    public Integer getPsId()
-    {
-        return psId;
-    }
-
-    private List<DataElement> dataElementList;
-
-    public List<DataElement> getDataElementList()
-    {
-        return dataElementList;
+    private Integer programId;
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    private Integer programStageId;
+
+    public void setProgramStageId( Integer programStageId )
+    {
+        this.programStageId = programStageId;
+    }
+
+    private List<DataElement> dataElements;
+
+    public List<DataElement> getDataElements()
+    {
+        return dataElements;
     }
 
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
-   
+
     public String execute()
     {
-        optionComboNames = new ArrayList<String>();
-
-        optionComboIds = new ArrayList<String>();
-
-        optionComboType = new ArrayList<String>();
-
-        dataElementList = new ArrayList<DataElement>( programStageDataElementService
-            .getListDataElement( programStageService.getProgramStage( psId ) ) );
+        if ( programStageId == null )
+        {
+            Program program = programService.getProgram( programId );
+
+            Set<DataElement> dataElementsInProgram = new HashSet<DataElement>();
+
+            for ( ProgramStage programStage : program.getProgramStages() )
+            {
+                dataElementsInProgram.addAll( programStageDataElementService.getListDataElement( programStage ) );
+            }
+            
+            dataElements = new ArrayList<DataElement>( dataElementsInProgram );
+        }
+        else
+        {
+            dataElements = new ArrayList<DataElement>( programStageDataElementService
+                .getListDataElement( programStageService.getProgramStage( programStageId ) ) );
+        }
 
         return SUCCESS;
     }

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetProgramStagesAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetProgramStagesAction.java	2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetProgramStagesAction.java	1970-01-01 00:00:00 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.patient.action.caseaggregation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.program.ProgramService;
-import org.hisp.dhis.program.ProgramStage;
-
-import com.opensymphony.xwork2.Action;
-
-public class GetProgramStagesAction implements Action
-{
-
-    // -------------------------------------------------------------------------
-    // Dependency
-    // -------------------------------------------------------------------------
-
-    private ProgramService programService;
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-    
-    // -------------------------------------------------------------------------
-    // Input & Output
-    // -------------------------------------------------------------------------
-
-    private List<ProgramStage> programStages;
-    
-    public List<ProgramStage> getProgramStages()
-    {
-        return programStages;
-    }
-    
-    private Integer programId;
-    
-    public void setProgramId( Integer programId )
-    {
-        this.programId = programId;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-    public String execute()
-    {
-        programStages = new ArrayList<ProgramStage>( programService.getProgram( programId ).getProgramStages() );
-        
-        return SUCCESS;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/UpdateCaseAggregationConditionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/UpdateCaseAggregationConditionAction.java	2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/UpdateCaseAggregationConditionAction.java	2012-06-04 04:06:04 +0000
@@ -64,7 +64,7 @@
 
     private String aggregationCondition;
 
-    private String description;
+    private String name;
 
     private String aggregationDataElementId;
 
@@ -96,7 +96,7 @@
     {
         this.aggregationDataElementId = aggregationDataElementId;
     }
-    
+
     public void setOperator( String operator )
     {
         this.operator = operator;
@@ -107,9 +107,9 @@
         this.aggregationCondition = aggregationCondition;
     }
 
-    public void setDescription( String description )
+    public void setName( String name )
     {
-        this.description = description;
+        this.name = name;
     }
 
     // -------------------------------------------------------------------------
@@ -127,15 +127,15 @@
             .getDataElementCategoryOptionCombo( Integer.parseInt( ids[1] ) );
 
         CaseAggregationCondition expression = aggregationConditionService.getCaseAggregationCondition( id );
-        
+
         expression.setOperator( operator );
         expression.setAggregationExpression( aggregationCondition );
-        expression.setDescription( description );
+        expression.setName( name );
         expression.setAggregationDataElement( aggregationDataElement );
         expression.setOptionCombo( optionCombo );
-        
+
         aggregationConditionService.updateCaseAggregationCondition( expression );
-        
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-05-24 05:13:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-06-04 04:06:04 +0000
@@ -553,23 +553,21 @@
 			<ref bean="org.hisp.dhis.dataset.DataSetService" />
 		</property>
 	</bean>
-
+	
 	<bean
-		id="org.hisp.dhis.patient.action.caseaggregation.GetProgramStagesAction"
-		class="org.hisp.dhis.patient.action.caseaggregation.GetProgramStagesAction"
+		id="org.hisp.dhis.patient.action.caseaggregation.GetParamsByProgramAction"
+		class="org.hisp.dhis.patient.action.caseaggregation.GetParamsByProgramAction"
 		scope="prototype">
-		<property name="programService">
-			<ref bean="org.hisp.dhis.program.ProgramService" />
-		</property>
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="attributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 
 	<bean
-		id="org.hisp.dhis.patient.action.caseaggregation.GetPSDataElementsAction"
-		class="org.hisp.dhis.patient.action.caseaggregation.GetPSDataElementsAction"
+		id="org.hisp.dhis.patient.action.caseaggregation.GetPatientDataElementsAction"
+		class="org.hisp.dhis.patient.action.caseaggregation.GetPatientDataElementsAction"
 		scope="prototype">
-		<property name="programStageService">
-			<ref bean="org.hisp.dhis.program.ProgramStageService" />
-		</property>
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 		<property name="programStageDataElementService"
 			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-05-30 07:22:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-06-04 04:06:04 +0000
@@ -20,7 +20,7 @@
 create_new_relationship_type=Create new relationship type
 relationship_type_management=Relationship type management
 or=or
-age_month=Age(months)
+age_days=Age(days)
 value_must_integer=Value must be an integer
 program_stage=Program Stage
 close=Close
@@ -70,8 +70,8 @@
 beneficiary_aggregation_query_builder=Person Aggregation Query Builder
 beneficiary_aggregation_query_builder_management=Person aggregation query builder management
 dataelement_group=Data Element Group
-dataelement=Data Element
-case_attributes=Person Attributes
+dataelements=Data elements
+patient_attributes=Person attributes
 operator=Operator
 dataentryform_management_for_program_stage=Data entry form management for Program stage
 choose_existing_dataentry=Choose existing data entry form
@@ -162,7 +162,6 @@
 condition=Condition
 condition_detail=Condition details
 edit_case_aggregation_condition=Edit person aggregation query builder
-enrolldate_minus_incidentdate=Date of Enrollment - Date of Incident
 program_properties=Program properties
 orgunit=Organisation unit
 validation_criteria_details=Validation criteria details
@@ -203,7 +202,7 @@
 test_condition=Test condition
 run_success=Run successful
 run_fail=Run failed
-patients_registered=Registered Persons No
+total_of_patient_registration=Total of patient registration
 repeatable=Repeatable
 date_of_birth=Date of Birth
 anonymous=Anonymous
@@ -226,16 +225,22 @@
 no_date_data_element_in_selected_program_stage=No data elements with date-type in the selected program stage
 shown_on_reports=Shown on reports 
 show_provided_provided_elsewhere=Show provided elsewhere
-suggested_values=Suggested values
-add_all_values=Add all values
+available_values=Available values
+insert_selected_values=Insert selected values
 display_provided_other_facility_column=Display provided other facility column
 aggregation_query_builder=Aggregation Query Builder
 patient_org_unit_registration=Person Org Unit Registration
-dataset= Dataset
-filter_by_data_set = Filter by dataset
-show_all_item = Show All Items
-multiple_events_with_registration = Multiple events with registration
-single_event_with_registration = Single event with registration
-single_event_without_registration = Single event without registration
-for = for
-standard_interval_days = Standard interval days
\ No newline at end of file
+dataset=Dataset
+filter_by_data_set=Filter by dataset
+show_all_item=Show All Items
+multiple_events_with_registration=Multiple events with registration
+single_event_with_registration=Single event with registration
+single_event_without_registration=Single event without registration
+for=for
+standard_interval_days=Standard interval days
+times=Times
+program_enrollment=Program enrollment
+due_date=Due date
+stage_visited = Stage visited
+report_date = Report date
+program_stage_properties = Program stage properties
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-05-24 05:13:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-06-04 04:06:04 +0000
@@ -598,18 +598,18 @@
 				/dhis-web-maintenance-patient/responseAggerateDataElement.vm
 			</result>
 		</action>
-
-		<action name="getProgramStages"
-			class="org.hisp.dhis.patient.action.caseaggregation.GetProgramStagesAction">
-			<result name="success" type="velocity-xml">
-				/dhis-web-maintenance-patient/responseProgramStages.vm
+		
+		<action name="getParamsByProgram"
+			class="org.hisp.dhis.patient.action.caseaggregation.GetParamsByProgramAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-maintenance-patient/jsonParamsByProgram.vm
 			</result>
 		</action>
-
-		<action name="getPSDataElements"
-			class="org.hisp.dhis.patient.action.caseaggregation.GetPSDataElementsAction">
-			<result name="success" type="velocity-xml">
-				/dhis-web-maintenance-patient/responsePSDataElement.vm
+		
+		<action name="getPatientDataElements"
+			class="org.hisp.dhis.patient.action.caseaggregation.GetPatientDataElementsAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-maintenance-patient/jsonPatientDataElements.vm
 			</result>
 		</action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2012-03-21 09:19:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2012-06-04 04:06:04 +0000
@@ -14,14 +14,16 @@
     <tbody>
 	
     <tr>
-        <td><label>$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td><input type="text" id="description" name="description" class="{validate:{required:true,minlength:2}}"></td>
+        <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+        <td>
+			<input type="text" id="name" name="name" class="{validate:{required:true,minlength:2}}">
+		</td>
     </tr>
     
     <tr>
 		<td><label for="dataSets">$i18n.getString( "dataset" )</label></td>
 		<td>
-			<select id="dataSets" name="dataSets" onchange="getDataElementsByDataset();">
+			<select id="dataSets" name="dataSets" onChange="getDataElementsByDataset();">
 				<option value="">[$i18n.getString('please_select')]</option>
 				#foreach( $dataSet in $dataSets)
 					<option value="$dataSet.id" #if( $dataSetId=="$dataSet.id") selected #end>$dataSet.name</option>
@@ -32,21 +34,44 @@
     
     <tr>
 		<td><label for="dataElement">$i18n.getString( "dataelement" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-		<td>
-			<select id="aggregationDataElementId" name="aggregationDataElementId" class="{validate:{required:true}} hidden" >
-			</select>
-			<input type="text" id="aggregationDataElementInput" name="aggregationDataElementInput" class='autocompleted-field' >
-			<button type='button' id='dataElementsButton' class='small-button' disabled >&nbsp;</button>
-		</td>				
+		<td>			
+			<select id="aggregationDataElementId" name="aggregationDataElementId" class="{validate:{required:true}} hidden" ></select>
+			<input id="aggregationDataElementInput" name="aggregationDataElementInput" style='width:303px'>
+			<button type='button' id='dataElementsButton' class='arrow-down' disabled>&nbsp;</button>
+		</td>
 	</tr>
 	
 	<tr>
 		<td><label for="operator">$i18n.getString( "operator" )</label></td>
 		<td>
 			<input type="radio" id="operator" name="operator" value="COUNT" checked >$i18n.getString('count')
-			<input type="radio" id="operator" name="operator" value="SUM"> $i18n.getString('sum')
-		</td>
-	</tr>
+			<input type="radio" id="operator" name="operator" value="SUM"> $i18n.getString('times')
+		</td>
+	</tr>
+	
+	<tr>
+		<td>
+			<label for="programId">$i18n.getString( "program" )</label>
+		</td>
+		<td>
+			<select id="programId" name="programId" onChange="getParams();">
+				<option value="0">[$i18n.getString('please_select')]</option>
+				#foreach( $program in $programs )
+					<option value="$program.id" title='$program.name' type='$program.type'>$encoder.htmlEncode( $program.name )</option>
+				#end
+			</select>
+		</td>
+	</tr>
+	
+	<tr>
+		<td>
+			<label for="programStage">$i18n.getString( "program_stage" )</label>
+		</td>
+		<td>
+			<select id="programStageId" name="programStageId" onChange="getPatientDataElements();" ondblclick="insertProgramStage(this);"></select>
+		</td>
+	</tr>
+	
 	<tr>
         <td colspan="2"><p></p></td>
     </tr>
@@ -56,112 +81,50 @@
 
 <div id="tabs">
 	<ul>
-		<li><a href="#tab-1">$i18n.getString("dataelement")</a></li>
-		<li><a href="#tab-2">$i18n.getString("case_attributes")</a></li>
+		<li><a href="#tab-1">$i18n.getString("dataelements")</a></li>
+		<li><a href="#tab-2">$i18n.getString("patient_attributes")</a></li>
 		<li><a href="#tab-3">$i18n.getString("program")</a></li>
 	</ul>	
 	
 	<div id="tab-1">
-		<table>
-			<tr>
-				<td>
-				<fieldset style="border: 1px solid #3f5d8e; ">
-				<legend>$i18n.getString( "data_element" )</legend>
-				<table>
-					<tr>
-						<td>
-							<label for="program">$i18n.getString( "program" )</label>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<select id="program" name="program" onChange="getProgramStages();">
-								<option value="0">[$i18n.getString('please_select')]</option>
-								#foreach( $program in $programs )
-									<option value="$program.id" title='$program.name'>$encoder.htmlEncode( $program.name )</option>
-								#end
-							</select>
-						</td>
-					</tr>
-					
-					<tr>
-						<td>
-							<label for="programStage">$i18n.getString( "program_stage" )</label>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<select id="programStage" name="programStage" onchange="getPrgramStageDataElements();" ondblclick="insertProgramStage(this);">
-							</select>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<label for="dataelement">$i18n.getString( "dataelement" )</label>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<input type='text' onkeyup="filterDE(event, this.value, 'programstageDE');"/>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<select id="programstageDE" name="programstageDE" size="5" style="width:20em; height: 6em" ondblclick="insertInfo(this);" onclick="getSuggestedValues(this.id, 'suggestedDEValues' )">
-							</select>
-						</td>
-					</tr>
-				</table>
-				</fieldset>
-			</td>
-			<td>
-				<fieldset style="border: 1px solid #3f5d8e; ">
-				<legend>$i18n.getString( "suggested_values" )</legend>
-				<select multiple size="10" id='suggestedDEValues' style="width:20em; height: 17em" ondblclick="insertSingleValue('suggestedDEValues');" >
-				</select>
-			</td>
-			<td>
-				<img src="../images/move_down.png" alt="$i18n.getString( 'add_all_values' )" title="$i18n.getString( 'add_all_values' )" style='cursor:pointer;' onclick="insertMultiValues('suggestedDEValues');">
-			</td>
+	  <table>
+        <tr>
+			<td><label for="dataelement">$i18n.getString( "dataelement" )</label></td>
+			<td>
+				<label for="availableValues">$i18n.getString( "available_values" )</label>&nbsp;
+				<button title="$i18n.getString( 'insert_selected_values' )" class='arrow-down' onClick="insertMultiValues('suggestedDEValues');" />			</td>
+        </tr>
+        
+        <tr>
+			<td>
+				<input type='text' id='txtSearchValue' name='txtSearchValue' onKeyUp="filterDE(event, this.value, 'dataElements');" style='width:270px'/>
+				<input type='button' value='$i18n.getString("clear")' onClick="setFieldValue('txtSearchValue', '');" style='width:50px'>			</td>
+            <td rowspan="4">
+				<select name="suggestedDEValues" size="10" multiple id='suggestedDEValues' ondblclick="insertSingleValue('suggestedDEValues');" >
+			    </select>			</td>
+        </tr>
+        <tr>
+			<td>
+				<select id="dataElements" name="dataElements" size="8" ondblclick="insertDataElement(this);" onclick="getSuggestedValues(this.id, 'suggestedDEValues' )"></select>			</td>
 		</tr>
-		</table>
+      </table>
 	</div>
 	
 	<div id="tab-2">
 		<table>
 			<tr>
-				<td>
-					<fieldset style="border: 1px solid #3f5d8e; ">
-					<legend>$i18n.getString( "attribute" )</legend>
-				
-					<table>
-						<tr>
-							<td>
-								<select id="caseProperty" name="caseProperty" size="8" ondblclick="insertInfo(this);" style="width:18em; height:16.5em" onclick="getSuggestedValues(this.id, 'caSuggestedValues' )">
-									<option value="[PT:count]" suggestedValues=''>$i18n.getString( "patients_registered" )</option>
-									<option value="[CP:gender]" suggestedValues='F, M' title='$i18n.getString( "gender" )'>$i18n.getString( "gender" )</option>
-									<option value="[CP:dobType]" suggestedValues='V, D, A' title='$i18n.getString( "dob_type" )'>$i18n.getString( "dob_type" )</option>
-									<option value="[CP:age]" title='$i18n.getString( "age_month" )'>$i18n.getString( "age_month" )</option>
-									
-									#foreach( $patientAttribute in $patientAttributes )
-									<option value="[CA:$patientAttribute.id]" suggestedValues='$patientAttribute.attributeOptions' title='$patientAttribute.name'>$encoder.htmlEncode( $patientAttribute.name )</option>
-									#end
-								</select>
-							</td>
-						</tr>
-					</table>
-					</fieldset>
-				</td>
-				</td>
-				<td>
-					<fieldset style="border: 1px solid #3f5d8e; ">
-						<legend>$i18n.getString( "suggested_values" )</legend>
-						<select multiple size="10" id='caSuggestedValues' style="width:20em; height: 17em" ondblclick="insertSingleValue('caSuggestedValues');">
-						</select>
-					</fieldset>
-				</td>
-				<td>
-					<img src="../images/move_down.png" alt="$i18n.getString( 'add_all_values' )" title="$i18n.getString( 'add_all_values' )" style='cursor:pointer;' onclick="insertMultiValues('caSuggestedValues');">
+				<td><label>$i18n.getString( "patient_attributes" )</label></td>
+				<td>
+					<label>$i18n.getString( "available_values" )</label>
+					<button title="$i18n.getString( 'insert_selected_values' )" class='arrow-down' onClick="insertMultiValues('caSuggestedValues');" />
+				</td>
+			</tr>
+			<tr>
+				<td>
+					<select id="caseProperty" name="caseProperty" size="10" ondblclick="insertInfo(this, false);" onclick="getSuggestedValues(this.id, 'caSuggestedValues' )"></select>
+				</td>
+				<td>
+					<select multiple size="10" id='caSuggestedValues' ondblclick="insertSingleValue('caSuggestedValues');"></select>
 				</td>
 			</tr>
 		</table>
@@ -170,52 +133,22 @@
 	<div id="tab-3">
 		<table>
 			<tr>
+				<td><label>$i18n.getString('program_properties')</label></td>
+				<td><label>$i18n.getString('program_stage_properties')</label></td>
+			</tr>
+			<tr>
 				<td>
-					<fieldset style="border: 1px solid #3f5d8e; ">
-					<legend>$i18n.getString( "program_properties" )</legend>
-					<table>
-						<tr>
-							<td>
-								<select id="programProperty" name="programProperty" size="4" ondblclick="insertInfo(this);" style="width:18em; height:16.5em" >
-									#foreach( $program in $programs )
-										<option value="[PG:$program.id]" title='$program.name'>$i18n.getString('program'): $encoder.htmlEncode( $program.name )</option>
-									#end
-									<option value="[PP:enrollmentdate - dateofincident]">$i18n.getString( "enrolldate_minus_incidentdate" )</option>
-									<option value="[PP:enrollmentdate]">$i18n.getString( "date_of_enrollment" )</option>
-									<option value="[PP:incidentdate]">$i18n.getString( "date_of_incident" )</option>
-								</select>
-							</td>
-						</tr>
-					</table>
-					</fieldset>
+					<select id="programProperty" name="programProperty" size="10" ondblclick="insertInfo(this, false);" >
+						<option value="[PG:*]">$i18n.getString( "program_enrollment" )</option>
+						<option value="[PG:*] AND [PP:DATE@enrollmentdate#-DATE@dateofincident#]">$i18n.getString( "date_of_enrollment" ) - $i18n.getString( "date_of_incident" )</option>
+					</select>
 				</td>
 				<td>
-					<fieldset style="border: 1px solid #3f5d8e; ">
-					<legend>$i18n.getString( "program" )</legend>
-					<table>
-						<tr>
-							<td>
-								<select id="programFormula" name="programFormula" style="width:20em" onChange="getProgramStagesForFormula();">
-									<option value="0">[$i18n.getString('please_select')]</option>
-									#foreach( $program in $programs )
-										<option value="$program.id" title='$program.name'>$encoder.htmlEncode( $program.name )</option>
-									#end
-								</select>
-							</td>
-						</tr>
-						<tr>
-							<td>
-								<label for="programStageFormula">$i18n.getString( "program_stage" )</label>
-							</td>
-						</tr>
-						<tr>
-							<td>
-								<select multiple id="programStageFormula" name="programStageFormula" style="width:20em; height:12.5em" ondblclick="insertInfo(this);">
-								</select>
-							</td>
-						</tr>
-					</table>
-					</fieldset>
+					<select multiple id="programStageProperty" size="10"  name="programStageProperty" ondblclick="insertInfo(this, true);">
+						<option value="[PS:*]">$i18n.getString( "visit_program_stage" )</option>
+						<option value="[PS:*] AND [PSP:DATE@executionDate#-DATE@dueDate#]">$i18n.getString( "report_date" ) - $i18n.getString( "due_date" )</option>
+					</select>
+					</select>
 				</td>
 			</tr>
 		</table>
@@ -247,21 +180,21 @@
 			<img src="../images/and.png" alt="$i18n.getString( 'and' )" onclick='insertOperator( "AND" );' style="cursor:pointer;"/>
 			<img src="../images/or.png" alt="$i18n.getString( 'or' )" onclick='insertOperator( "OR" );' style="cursor:pointer;"/>
 			
-			<img src="../images/clear.png" align="right" alt="$i18n.getString( 'clear' )" onclick="byId('aggregationCondition').value='';" style="cursor:pointer;"/>
+			<img src="../images/clear.png" align="right" alt="$i18n.getString( 'clear' )" onClick="byId('aggregationCondition').value='';" style="cursor:pointer;"/>
 		</td>
 	</tr>
 		
 	<tr>
 		<td>
-			<fieldset style="border: 1px solid #3f5d8e;">
+			<fieldset>
 				<legend>$i18n.getString( "condition" )</legend>
-				<textarea id="aggregationCondition" name="aggregationCondition" style="width:80.5em; height:10em" class="{validate:{required:true}}" onkeyup='getConditionDescription();'></textarea>
+				<textarea id="aggregationCondition" name="aggregationCondition" class="{validate:{required:true}}" onkeyup='getConditionDescription();'></textarea>
 			</fieldset>
 		</td>
 	</tr>
 	<tr>
 		<td>
-			<fieldset style="border: 1px solid #3f5d8e; ">
+			<fieldset>
 				<legend>$i18n.getString( "description" )</legend>
 				<div id='aggregationDescription'></div>
 			</fieldset>
@@ -272,7 +205,7 @@
 		<td>
 			<input type="submit" value="$i18n.getString( 'add' )" />
 			<input type="button" value="$i18n.getString( 'test_condition' )" onclick='testCaseAggregationCondition();'/>
-			<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='caseAggregation.action?dataSetId=$!dataSetId'" />
+			<input type="button" value="$i18n.getString( 'cancel' )" onClick="window.location.href='caseAggregation.action?dataSetId=$!dataSetId'" />
 		</td>
 	</tr>
 </table>
@@ -287,4 +220,5 @@
 	var i18n_run_success = '$encoder.jsEscape( $i18n.getString( "run_success" ) , "'" )';
 	var i18n_run_fail = '$encoder.jsEscape( $i18n.getString( "run_fail" ) , "'" )';
 	var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_item" ) , "'" )';
+	var i18n_all = '[' + '$encoder.jsEscape( $i18n.getString( "all" ) , "'" )' + ']';
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm	2012-03-19 07:56:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm	2012-06-04 04:06:04 +0000
@@ -48,7 +48,7 @@
 				<div style="float:right">
 					<a href="javascript:hideDetails()" title="$i18n.getString( "hide_details" )"><img src="../images/close.png" alt="$i18n.getString( 'hide_details' )"></a>
 				</div>				
-                <p><label class="bold">$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>
+                <p><label class="bold">$i18n.getString( "name" ):</label><br><span id="nameField"></span></p>
                 <p><label class="bold">$i18n.getString( "operator" ):</label><br><span id="operatorField"></span></p>
                 <p><label class="bold">$i18n.getString( "aggregation_data_element" ):</label><br><span id="aggregationDataElementField"></span></p>
 				<p><label class="bold">$i18n.getString( "option_combo" ):</label><br><span id="optionComboField"></span></p>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm	2012-03-21 09:24:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm	2012-06-04 04:06:04 +0000
@@ -2,11 +2,11 @@
 #foreach( $aggregationCondition in $aggregationConditions )
 	<tr  id="tr${aggregationCondition.id}" #alternate( $mark )>
 
-		<td>$encoder.htmlEncode( $aggregationCondition.description )</td>                
+		<td>$encoder.htmlEncode( $aggregationCondition.name )</td>                
 
 		<td>
 		  <a href="showUpdateCaseAggregationForm.action?id=$aggregationCondition.id&dataSetId=$!dataSetId" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
-		  <a href="javascript:removeCaseAggregation( '$aggregationCondition.id', '$encoder.jsEncode( $aggregationCondition.description )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+		  <a href="javascript:removeCaseAggregation( '$aggregationCondition.id', '$encoder.jsEncode( $aggregationCondition.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
 		  <a href="javascript:showCaseAggregationDetails( $aggregationCondition.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
 		</td>
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addCaseAggregationForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addCaseAggregationForm.js	2012-03-19 09:35:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addCaseAggregationForm.js	2012-06-04 04:06:04 +0000
@@ -5,5 +5,5 @@
 	
 	jQuery("#tabs").tabs();
 	checkValueIsExist( "aggregationDataElementId", "validateCaseAggregation.action");
-	byId('description').focus();
+	byId('name').focus();
 });	
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js	2012-05-23 18:02:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js	2012-06-04 04:06:04 +0000
@@ -3,6 +3,8 @@
 	validation( 'addProgramStageForm', function( form ){ 
 		form.submit();
 	}, function(){
+		selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
+		selectedDataElementsValidator.empty();
 		
 		compulsories = jQuery( "#compulsories" );
 		compulsories.empty();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2012-05-28 03:47:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2012-06-04 04:06:04 +0000
@@ -7,7 +7,7 @@
 {
 	var dataSets = document.getElementById( 'dataSets' );
 	var dataSetId = dataSets.options[ dataSets.selectedIndex ].value;
-	clearList( byId('aggregationDataElementId'));
+	clearListById('aggregationDataElementId');
 	
 	if( dataSetId == "" ){
 		disable( 'dataElementsButton' );
@@ -21,7 +21,7 @@
 		}, function( json )
         {
 			var de = byId( 'aggregationDataElementId' );
-			clearList( de );
+			clearListById( 'aggregationDataElementId' );
 		  
 			for ( i in json.dataElements ) 
 			{ 
@@ -88,8 +88,7 @@
 					}
 				}
 			}
-		})
-		.addClass( "ui-widget ui-widget-content ui-corner-left" );
+		});
 
 	input.data( "autocomplete" )._renderItem = function( ul, item ) {
 		return $( "<li></li>" )
@@ -98,17 +97,8 @@
 			.appendTo( ul );
 	};
 
-	showById('dataElementsButton');
-	var button = $( "#dataElementsButton" )
+	/* var button = $( "#dataElementsButton" )
 		.attr( "title", i18n_show_all_items )
-		.button({
-			icons: {
-				primary: "ui-icon-triangle-1-s"
-			},
-			text: false
-		})
-		.removeClass( "ui-corner-all" )
-		.addClass( "ui-corner-right ui-button-icon" )
 		.click(function() {
 			// close if already visible
 			if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
@@ -122,126 +112,116 @@
 			// pass empty string as value to search for, displaying all results
 			input.autocomplete( "search", "" );
 			input.focus();
-		});
+		}); */
 }
 
 //------------------------------------------------------------------------------
 // Get Program Stages
 //------------------------------------------------------------------------------
 
-function getProgramStages()
-{
-	clearListById( 'programStage' );
-  	clearListById( 'programstageDE' );
-	
-	var program = document.getElementById( 'program' );
-	var programId = program.options[ program.selectedIndex ].value;
-	if( programId == '0' ){
-		return;  
-	}
-
-	$.get( 'getProgramStages.action', { programId:programId }, getProgramStagesCompleted, 'xml');
-}
-
-function getProgramStagesCompleted( programstageElement )
-{
-	var programstage = document.getElementById( 'programStage' );
-	var programstageList = $(programstageElement).find( 'programstage' );
-
-	$( programstageList ).each( function( i, item )
-	{
-		var id = $( item ).find("id").text();
-		var name = $( item ).find("name").text();
-
-		var option = document.createElement("option");
-		option.value = id;
-		option.text = name;
-		option.title = name;
-
-		programstage.add(option, null);       	
-	});
-
-	if( programstage.options.length > 0 )
-	{
-		programstage.options[0].selected = true;
-		getPrgramStageDataElements();
-	}   
-}
-
-
-function getProgramStagesForFormula()
-{
-	clearListById( 'programStageFormula' );
-	
-	var program = document.getElementById( 'programFormula' );
-	var programId = program.options[ program.selectedIndex ].value;
-	if( programId == '0' ){
-		return;  
-	}
-
-	$.get( 'getProgramStages.action', { programId:programId }, getProgramStagesFomulaCompleted, 'xml' );
-}
-
-function getProgramStagesFomulaCompleted( programstageElement )
-{
-	var programstage = document.getElementById( 'programStageFormula' );
-	var programstageList = $(programstageElement).find( 'programstage' );
-
-	$( programstageList ).each( function( i, item )
-	{
-		var id = $( item ).find("id").text();
-		var name = $( item ).find("name").text();
-
-		var option = document.createElement("option");
-		option.value = "[PS:" + id + "]";
-		option.text = name;
-		option.title = name;
-
-		programstage.add(option, null);       	
-	});
-
-	if( programstage.options.length > 0 )
-	{
-		programstage.options[0].selected = true;
-	}   
+function getParams()
+{
+	clearListById( 'programStageId' );
+  	clearListById( 'dataElements' );
+	
+	jQuery.getJSON( 'getParamsByProgram.action',{ programId:getFieldValue( 'programId' ) }
+		,function( json ) 
+		{
+			var programstage = jQuery('#programStageId');
+			
+			for ( i in json.programStages ) 
+			{ 
+				var id = json.programStages[i].id;
+				var formularId = "[PS:" + id + "]";
+				var name = json.programStages[i].name;
+
+				programstage.append( "<option value='" + id + "' title='" + name + "'>" + name + "</option>" );
+			}
+			
+			if( json.programStages.length > 0 )
+			{
+				programstage.prepend( "<option value='' title='" + i18n_all + "'>" + i18n_all + "</option>" );
+				byId('programStageId').options[0].selected = true;
+				getPatientDataElements();
+			}  
+			
+			clearListById( 'caseProperty' );
+			var type = jQuery('#programId option:selected').attr('type');
+			if( type!='3')
+			{
+				var caseProperty = jQuery( '#caseProperty' );
+				for ( i in json.fixedAttributes )
+				{
+					var id = json.fixedAttributes[i].id;
+					var name = json.fixedAttributes[i].name;
+					
+					caseProperty.append( "<option value='" + id + "' title='" + name + "'>" + name + "</option>" );
+				}
+				
+				for ( i in json.patientAttributes )
+				{ 
+					var id = json.patientAttributes[i].id;
+					var name = json.patientAttributes[i].name;
+					var suggested = json.patientAttributes[i].suggested;
+					
+					caseProperty.append( "<option value='" + id + "' title='" + name + "' suggested='" + suggested + "'>" + name + "</option>" );	
+				}
+			}
+		});
 }
 
 //------------------------------------------------------------------------------
 // Get DataElements of Program-Stage
 //------------------------------------------------------------------------------
 
-function getPrgramStageDataElements()
+function getPatientDataElements()
 {
-	clearListById( 'programstageDE' );
-
+	clearListById( 'dataElements' );
 	var programStage = document.getElementById( 'programStage' );
-	var psId = programStage.options[ programStage.selectedIndex ].value;
-	
-	$.get( 'getPSDataElements.action', { psId:psId }, getPrgramStageDataElementsCompleted, 'xml' );
-}
-
-function getPrgramStageDataElementsCompleted( dataelementElement )
-{
-	var programstageDE = jQuery('#programstageDE');
-	var psDataElements = $(dataelementElement).find( 'dataelement' );
-
-	$( psDataElements ).each( function( i, item )
-	{
-		var id = $(item).find("id").text();
-		var name = $(item).find("name").text();
-		var optionset =$(item).find("optionset").text();
-		
-		programstageDE.append( "<option value='" + id + "' title='" + name + "' suggestedValues='" + optionset + "'>" + name + "</option>" );
-	} );	    
+	jQuery.getJSON( 'getPatientDataElements.action',
+		{ 
+			programId:getFieldValue( 'programId' ),
+			progamStageId: getFieldValue('progamStageId')  
+		}
+		,function( json )
+		{
+			var dataElements = jQuery('#dataElements');
+			for ( i in json.dataElements )
+			{ 
+				dataElements.append( "<option value='" + json.dataElements[i].id + "' title='" + json.dataElements[i].name + "' suggested='" + json.dataElements[i].optionset + "'>" + json.dataElements[i].name + "</option>" );
+			}
+		});
 }
 
 //-----------------------------------------------------------------
 // Insert items into Condition
 //-----------------------------------------------------------------
 
-function insertInfo( element )
-{
-	insertTextCommon('aggregationCondition', element.options[element.selectedIndex].value );
+function insertDataElement( element )
+{
+	var progamId = getFieldValue('programId');
+	var progamStageId = getFieldValue('programStageId');
+	progamStageId = ( progamStageId == "" ) ? "*" : progamStageId;
+	var dataElementId = element.options[element.selectedIndex].value;
+	
+	insertTextCommon( 'aggregationCondition', "[DE:" + progamId + "." + progamStageId + "." + dataElementId + "]" );
+	getConditionDescription();
+}
+
+function insertInfo( element, isProgramStageProperty )
+{
+	var id = "";
+	if( isProgramStageProperty )
+	{
+		id = getFieldValue('programId');
+	}
+	else
+	{
+		id = getFieldValue('programStageId');
+	}
+	
+	value = element.options[element.selectedIndex].value.replace( '*', id );
+	insertTextCommon('aggregationCondition', value );
 	getConditionDescription();
 }
 
@@ -268,7 +248,7 @@
 {
     jQuery.getJSON( 'getCaseAggregation.action', { id:caseAggregationId }, function ( json )
 	{
-		setInnerHTML( 'descriptionField', json.caseAggregation.description );	
+		setInnerHTML( 'nameField', json.caseAggregation.name );	
 		setInnerHTML( 'operatorField', json.caseAggregation.operator );
 		setInnerHTML( 'aggregationDataElementField', json.caseAggregation.aggregationDataElement );
 		setInnerHTML( 'optionComboField', json.caseAggregation.optionCombo );	
@@ -321,21 +301,23 @@
 {
 	clearListById( targetId );
 	
-	var suggestedValues = jQuery('select[id=' + sourceId + '] option:selected').attr('suggestedValues');	
-	
-	var arrValues = new Array();
-	arrValues = suggestedValues.replace(/[//[]+/g,'').replace(/]/g, '').split(', ');
-
-	var suggestedValueSelector = byId( targetId );
-	for( var i=0; i< arrValues.length; i++ )
+	var suggestedValues = jQuery('select[id=' + sourceId + '] option:selected').attr('suggested');	
+	if( suggestedValues )
 	{
-		var option = document.createElement("option");
-		var value = jQuery.trim( arrValues[i] );
-		option.value = "'" + value + "'";
-		option.text = value;
-		option.title = value;
-
-		suggestedValueSelector.add(option, null); 
+		var arrValues = new Array();
+		arrValues = suggestedValues.replace(/[//[]+/g,'').replace(/]/g, '').split(', ');
+
+		var suggestedValueSelector = byId( targetId );
+		for( var i=0; i< arrValues.length; i++ )
+		{
+			var option = document.createElement("option");
+			var value = jQuery.trim( arrValues[i] );
+			option.value = "'" + value + "'";
+			option.text = value;
+			option.title = value;
+
+			suggestedValueSelector.add(option, null); 
+		}
 	}
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js	2011-08-01 02:39:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js	2012-06-04 04:06:04 +0000
@@ -1,28 +1,4 @@
 
-function dobTypeOnChange( container ){
-
-	var type = jQuery('#' + container + ' [id=dobType]').val();
-	
-	if(type == 'V' || type == 'D'){
-		jQuery('#' + container + ' [id=age]').rules("remove","required");
-		jQuery('#' + container + ' [id=birthDate]').rules("add",{required:true});
-		
-		showById(container + ' [id=birthdaySpan]');
-		hideById(container + ' [id=ageSpan]');
-	}else if(type == 'A'){
-		jQuery('#' + container + ' [id=birthDate]').rules("remove","required");
-		jQuery('#' + container + ' [id=age]').rules("add",{required:true});
-		
-		hideById(container + ' [id=birthdaySpan]');
-		showById(container + ' [id=ageSpan]');
-	}else {
-		hideById(container + ' [id=birthdaySpan]');
-		hideById(container + ' [id=ageSpan]');
-		jQuery('#' + container + ' [id=age]').rules("remove","required");
-		jQuery('#' + container + ' [id=birthDate]').rules("remove","required");
-	}
-}
-
 // ----------------------------------------------------------------------------
 // Search patients by name
 // ----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateCaseAggregationForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateCaseAggregationForm.js	2012-03-19 09:35:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateCaseAggregationForm.js	2012-06-04 04:06:04 +0000
@@ -6,7 +6,7 @@
 	
 	checkValueIsExist( "aggregationDataElementId", "validateCaseAggregation.action", {id:getFieldValue('id')});
 	
-	byId('description').focus();
+	byId('name').focus();
 	jQuery("#tabs").tabs();
 		
 });	
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js	2012-05-23 18:02:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js	2012-06-04 04:06:04 +0000
@@ -9,10 +9,6 @@
 		compulsories = jQuery( "#compulsories" );
 		compulsories.empty();
 		
-		showOnReport = jQuery( "#showOnReport" );
-		showOnReport.empty();
-		
-		var hasDeShowReport = false;
 		jQuery("#selectedList").find("tr").each( function( i, item ){ 
 			selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
 			var compulsory = jQuery( item ).find( "input[name='compulsory']:first");
@@ -20,14 +16,6 @@
 
 			var checked = compulsory.attr('checked') ? true : false;
 			compulsories.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
-			
-			checked = isShow.attr('checked') ? true : false;
-			showOnReport.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
-			if( checked )
-			{
-				hasDeShowReport = true;
-				jQuery( "#checkShowOnReport" ).append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
-			}
 		});
 	});
 	

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonParamsByProgram.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonParamsByProgram.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonParamsByProgram.vm	2012-06-04 04:06:04 +0000
@@ -0,0 +1,42 @@
+{ #set( $size = $!{programStages.size()} )
+  "programStages": [
+  #foreach( ${programStage} in $!{programStages} )
+  {
+	"id": "${programStage.id}",
+	"name": "$!encoder.jsonEncode( ${programStage.name} )"
+  }#if( $velocityCount < $size ),#end
+  #end
+  ],
+  "fixedAttributes": [
+	{
+		"id": "[PT:count]",
+		"name": "$i18n.getString( 'total_of_patient_registration' )",
+		"suggested": ""
+	},
+	{
+		"id": "[CP:gender]",
+		"name": "$i18n.getString( 'gender' )",
+		"suggested": "F, M"
+	},
+	{
+		"id": "[CP:dobType]",
+		"name": "$i18n.getString( 'dob_type' )",
+		"suggested": "V, D, A"
+	},
+	{
+		"id": "[CP:age]",
+		"name": "$i18n.getString( "age_days" )",
+		"suggested": ""
+	}
+  ],
+  "patientAttributes":[
+	#set( $size = $!{patientAttributes.size()} )
+	#foreach( $patientAttribute in $!{patientAttributes} )
+	{
+		"id": "[CA:${patientAttribute.id}]",
+		"name": "$!encoder.jsonEncode( ${patientAttribute.name} )",
+		"suggested":"$patientAttribute.attributeOptions"
+	}#if( $velocityCount < $size ),#end
+	#end
+  ]
+}
\ No newline at end of file

=== renamed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responsePSDataElement.vm' => 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonPatientDataElements.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responsePSDataElement.vm	2012-02-20 02:02:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonPatientDataElements.vm	2012-06-04 04:06:04 +0000
@@ -1,14 +1,16 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<dataelements>
-	#foreach( $dataElement in $dataElementList )
-		<dataelement>
-			<id>[DE:$psId.$dataElement.id]</id>
-			<name>$encoder.xmlEncode( $dataElement.name )</name>
-			<optionset>
-				#if( $!dataElement.optionSet.options )
-					$encoder.xmlEncode($!dataElement.optionSet.options.toString())
-				#end
-			</optionset>
-		</dataelement>	
-	#end
-</dataelements>
\ No newline at end of file
+{ #set( $size = $!{dataElements.size()} )
+  "dataElements": [
+  #foreach( ${dataElement} in $!{dataElements} )
+  {
+	"id": "${dataElement.id}",
+	"name": "$!encoder.jsonEncode( ${dataElement.name} )",
+	"optionset": 
+		#if( $!dataElement.optionSet )
+			"$encoder.xmlEncode($!dataElement.optionSet.options.toString())"
+		#else
+			""
+		#end
+  }#if( $velocityCount < $size ),#end
+  #end
+  ]
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css	2012-03-21 05:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css	2012-06-04 04:06:04 +0000
@@ -1,10 +1,9 @@
-.heading-column { width : 30.5em;}
-td.input-column { width : 30.5em;}
-td.input-column input, td.input-column select { width: 28.5em;}
-td.error {padding-left:1em}
+
+td{ padding-right : 10px;}
 
 textarea{
-	width:320px; 
+	width:660px; 
+	height: 100px;
 	text-align:left;
 }
 
@@ -76,15 +75,18 @@
 	width:100%;
 }
 
-.small-button {
-	font-size: .8em !important;
+.arrow-down {
+	width: 15px;
+	height: 20px;
+	border-left: 1px solid #CCCCCC;
+	border-right: 1px solid #CCCCCC;
+	border-top: 1px solid #CCCCCC;
+	border-bottom: 1px solid #CCCCCC;
+	background: url('../../images/asc.gif') no-repeat center;
+	cursor: pointer;
 }
 
-.ui-autocomplete { height: 100px; overflow-y: scroll; overflow-x: hidden; }
-
-
-input.autocompleted-field
+fieldset
 {
-	width:25em; 
-	text-align:left;
+	border: 1px solid #3f5d8e;
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2012-03-21 09:19:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2012-06-04 04:06:04 +0000
@@ -15,8 +15,8 @@
     <tbody>
 	
     <tr>
-        <td><label>$i18n.getString( "description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-        <td><input type="text" id="description" name="description" class="{validate:{required:true}}" value="$caseAggregation.description"></td>
+        <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+        <td><input type="text" id="name" name="name" class="{validate:{required:true}}" value="$caseAggregation.name"></td>
     </tr>
     
     <tr>
@@ -37,7 +37,8 @@
 			<select id="aggregationDataElementId" name="aggregationDataElementId" class="{validate:{required:true}} hidden" >
 				<option value="$caseAggregation.aggregationDataElement.id.$caseAggregation.optionCombo.id">$caseAggregation.aggregationDataElement.name $caseAggregation.optionCombo.name</option>
 			</select>
-			<input id="aggregationDataElementInput" name="aggregationDataElementInput" class='autocompleted-field' value='$caseAggregation.aggregationDataElement.name $caseAggregation.optionCombo.name'><button type='button' id='dataElementsButton' class='small-button' disabled>&nbsp;</button>
+			<input id="aggregationDataElementInput" name="aggregationDataElementInput" value='$caseAggregation.aggregationDataElement.name $caseAggregation.optionCombo.name' style='width:303px'>
+			<button type='button' id='dataElementsButton' class='arrow-down' disabled>&nbsp;</button>
 		</td>				
 	</tr>
 	<tr>
@@ -48,121 +49,81 @@
 		</td>
 	</tr>
 	<tr>
+		<td>
+			<label for="programId">$i18n.getString( "program" )</label>
+		</td>
+		<td>
+			<select id="programId" name="programId" onChange="getParams();">
+				<option value="0">[$i18n.getString('please_select')]</option>
+				#foreach( $program in $programs )
+					<option value="$program.id" title='$program.name'>$encoder.htmlEncode( $program.name )</option>
+				#end
+			</select>
+		</td>
+	</tr>
+	
+	<tr>
+		<td>
+			<label for="programStage">$i18n.getString( "program_stage" )</label>
+		</td>
+		<td>
+			<select id="programStageId" name="programStageId" onChange="getPatientDataElements();" ondblclick="insertProgramStage(this);"></select>
+		</td>
+	</tr>
+	
+	<tr>
         <td colspan="2"><p></p></td>
     </tr>
 	
     </tbody>
 </table>
 
-
 <div id="tabs">
 	<ul>
-		<li><a href="#tab-1">$i18n.getString("dataelement")</a></li>
-		<li><a href="#tab-2">$i18n.getString("case_attributes")</a></li>
+		<li><a href="#tab-1">$i18n.getString("dataelements")</a></li>
+		<li><a href="#tab-2">$i18n.getString("patient_attributes")</a></li>
 		<li><a href="#tab-3">$i18n.getString("program")</a></li>
 	</ul>	
 	
 	<div id="tab-1">
-		<table>
-			<tr>
-				<td>
-				<fieldset style="border: 1px solid #3f5d8e; ">
-				<legend>$i18n.getString( "data_element" )</legend>
-				<table>
-					<tr>
-						<td>
-							<label for="program">$i18n.getString( "program" )</label>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<select id="program" name="program" onChange="getProgramStages();">
-								<option value="0">[$i18n.getString('please_select')]</option>
-								#foreach( $program in $programs )
-									<option value="$program.id" title='$program.name'>$encoder.htmlEncode( $program.name )</option>
-								#end
-							</select>
-						</td>
-					</tr>
-					
-					<tr>
-						<td>
-							<label for="programStage">$i18n.getString( "program_stage" )</label>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<select id="programStage" name="programStage" onchange="getPrgramStageDataElements();" ondblclick="insertProgramStage(this);">
-							</select>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<label for="dataelement">$i18n.getString( "dataelement" )</label>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<input type='text' onkeyup="filterDE(event, this.value, 'programstageDE');"/>
-						</td>
-					</tr>
-					<tr>
-						<td>
-							<select id="programstageDE" name="programstageDE" size="5" style="width:20em; height: 6em" ondblclick="insertInfo(this);" onclick="getSuggestedValues(this.id, 'suggestedDEValues' )">
-							</select>
-						</td>
-					</tr>
-				</table>
-				</fieldset>
-			</td>
-			<td>
-				<fieldset style="border: 1px solid #3f5d8e; ">
-				<legend>$i18n.getString( "suggested_values" )</legend>
-				<select multiple size="10" id='suggestedDEValues' style="width:20em; height: 17em" ondblclick="insertSingleValue('suggestedDEValues');" >
-				</select>
-			</td>
-			<td>
-				<img src="../images/move_down.png" alt="$i18n.getString( 'add_all_values' )" title="$i18n.getString( 'add_all_values' )" style='cursor:pointer;' onclick="insertMultiValues('suggestedDEValues');">
-			</td>
+	  <table>
+        <tr>
+			<td><label for="dataelement">$i18n.getString( "dataelement" )</label></td>
+			<td>
+				<label for="availableValues">$i18n.getString( "available_values" )</label>&nbsp;
+				<button title="$i18n.getString( 'insert_selected_values' )" class='arrow-down' onClick="insertMultiValues('suggestedDEValues');" />			</td>
+        </tr>
+        
+        <tr>
+			<td>
+				<input type='text' id='txtSearchValue' name='txtSearchValue' onKeyUp="filterDE(event, this.value, 'dataElements');" style='width:270px'/>
+				<input type='button' value='$i18n.getString("clear")' onClick="setFieldValue('txtSearchValue', '');" style='width:50px'>			</td>
+            <td rowspan="4">
+				<select name="suggestedDEValues" size="10" multiple id='suggestedDEValues' ondblclick="insertSingleValue('suggestedDEValues');" >
+			    </select>			</td>
+        </tr>
+        <tr>
+			<td>
+				<select id="dataElements" name="dataElements" size="8" ondblclick="insertDataElement(this);" onclick="getSuggestedValues(this.id, 'suggestedDEValues' )"></select>			</td>
 		</tr>
-		</table>
+      </table>
 	</div>
 	
 	<div id="tab-2">
 		<table>
 			<tr>
-				<td>
-					<fieldset style="border: 1px solid #3f5d8e; ">
-					<legend>$i18n.getString( "attribute" )</legend>
-				
-					<table>
-						<tr>
-							<td>
-								<select id="caseProperty" name="caseProperty" size="8" ondblclick="insertInfo(this);" style="width:18em; height:16.5em" onclick="getSuggestedValues(this.id, 'caSuggestedValues' )">
-									<option value="[PT:count]" suggestedValues=''>$i18n.getString( "patients_registered" )</option>
-									<option value="[CP:gender]" suggestedValues='F, M' title='$i18n.getString( "gender" )'>$i18n.getString( "gender" )</option>
-									<option value="[CP:dobType]" suggestedValues='V, D, A' title='$i18n.getString( "dob_type" )'>$i18n.getString( "dob_type" )</option>
-									<option value="[CP:age]" title='$i18n.getString( "age_month" )'>$i18n.getString( "age_month" )</option>
-									
-									#foreach( $patientAttribute in $patientAttributes )
-									<option value="[CA:$patientAttribute.id]" suggestedValues='$patientAttribute.attributeOptions' title='$patientAttribute.name'>$encoder.htmlEncode( $patientAttribute.name )</option>
-									#end
-								</select>
-							</td>
-						</tr>
-					</table>
-					</fieldset>
-				</td>
-				</td>
-				<td>
-					<fieldset style="border: 1px solid #3f5d8e; ">
-						<legend>$i18n.getString( "suggested_values" )</legend>
-						<select multiple size="10" id='caSuggestedValues' style="width:20em; height: 17em" ondblclick="insertSingleValue('caSuggestedValues');" >
-						</select>
-					</fieldset>
-				</td>
-				<td>
-					<img src="../images/move_down.png" alt="$i18n.getString( 'add_all_values' )" title="$i18n.getString( 'add_all_values' )" style='cursor:pointer;' onclick="insertMultiValues('caSuggestedValues');">
+				<td><label>$i18n.getString( "patient_attributes" )</label></td>
+				<td>
+					<label>$i18n.getString( "available_values" )</label>
+					<button title="$i18n.getString( 'insert_selected_values' )" class='arrow-down' onClick="insertMultiValues('caSuggestedValues');" />
+				</td>
+			</tr>
+			<tr>
+				<td>
+					<select id="caseProperty" name="caseProperty" size="10" ondblclick="insertInfo(this, false);" onclick="getSuggestedValues(this.id, 'caSuggestedValues' )"></select>
+				</td>
+				<td>
+					<select multiple size="10" id='caSuggestedValues' ondblclick="insertSingleValue('caSuggestedValues');"></select>
 				</td>
 			</tr>
 		</table>
@@ -171,52 +132,22 @@
 	<div id="tab-3">
 		<table>
 			<tr>
+				<td><label>$i18n.getString('program_properties')</label></td>
+				<td><label>$i18n.getString('program_stage_properties')</label></td>
+			</tr>
+			<tr>
 				<td>
-					<fieldset style="border: 1px solid #3f5d8e; ">
-					<legend>$i18n.getString( "program_properties" )</legend>
-					<table>
-						<tr>
-							<td>
-								<select id="programProperty" name="programProperty" size="4" ondblclick="insertInfo(this);" style="width:18em; height:16.5em" >
-									#foreach( $program in $programs )
-										<option value="[PG:$program.id]" title='$program.name'>$i18n.getString('program'): $encoder.htmlEncode( $program.name )</option>
-									#end
-									<option value="[PP:enrollmentdate - dateofincident]">$i18n.getString( "enrolldate_minus_incidentdate" )</option>
-									<option value="[PP:enrollmentdate]">$i18n.getString( "date_of_enrollment" )</option>
-									<option value="[PP:incidentdate]">$i18n.getString( "date_of_incident" )</option>
-								</select>
-							</td>
-						</tr>
-					</table>
-					</fieldset>
+					<select id="programProperty" name="programProperty" size="10" ondblclick="insertInfo(this, false);" >
+						<option value="[PG:*]">$i18n.getString( "program_enrollment" )</option>
+						<option value="[PG:*] AND [PP:DATE@enrollmentdate#-DATE@dateofincident#]">$i18n.getString( "date_of_enrollment" ) - $i18n.getString( "date_of_incident" )</option>
+					</select>
 				</td>
 				<td>
-					<fieldset style="border: 1px solid #3f5d8e; ">
-					<legend>$i18n.getString( "program" )</legend>
-					<table>
-						<tr>
-							<td>
-								<select id="programFormula" name="programFormula" onChange="getProgramStagesForFormula();">
-									<option value="0">[$i18n.getString('please_select')]</option>
-									#foreach( $program in $programs )
-										<option value="$program.id" title='$program.name'>$encoder.htmlEncode( $program.name )</option>
-									#end
-								</select>
-							</td>
-						</tr>
-						<tr>
-							<td>
-								<label for="programStageFormula">$i18n.getString( "program_stage" )</label>
-							</td>
-						</tr>
-						<tr>
-							<td>
-								<select multiple id="programStageFormula" name="programStageFormula" style="width:20em; height:12.5em" ondblclick="insertInfo(this);">
-								</select>
-							</td>
-						</tr>
-					</table>
-					</fieldset>
+					<select multiple id="programStageProperty" size="10"  name="programStageProperty" ondblclick="insertInfo(this, true);">
+						<option value="[PS:*]">$i18n.getString( "visit_program_stage" )</option>
+						<option value="[PS:*] AND [PSP:DATE@executionDate#-DATE@dueDate#]">$i18n.getString( "report_date" ) - $i18n.getString( "due_date" )</option>
+					</select>
+					</select>
 				</td>
 			</tr>
 		</table>
@@ -225,7 +156,6 @@
 </div>
 
 <p></p>
-
 <table>
 	<tr>
 		<td>
@@ -254,16 +184,16 @@
     </tbody>
 	<tr>
 		<td>
-			<fieldset style="border: 1px solid #3f5d8e; ">
+			<fieldset>
 				<legend>$i18n.getString( "condition" )</legend>
-				<textarea id="aggregationCondition" name="aggregationCondition" style="width:80.5em; height:10em" class="{validate:{required:true}}" onkeyup='getConditionDescription();'>$caseAggregation.aggregationExpression</textarea>
+				<textarea id="aggregationCondition" name="aggregationCondition" class="{validate:{required:true}}" onkeyup='getConditionDescription();'>$caseAggregation.aggregationExpression</textarea>
 			</fieldset>
 		</td>
 	</tr>
 	
 	<tr>
 		<td>
-			<fieldset style="border: 1px solid #3f5d8e; ">
+			<fieldset>
 				<legend>$i18n.getString( "description" )</legend>
 				<div id='aggregationDescription'>$!description</div>
 			</fieldset>
@@ -290,4 +220,5 @@
 	var i18n_run_success = '$encoder.jsEscape( $i18n.getString( "run_success" ) , "'" )';
 	var i18n_run_fail = '$encoder.jsEscape( $i18n.getString( "run_fail" ) , "'" )';
 	var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_item" ) , "'" )';
+	var i18n_all = '[' + '$encoder.jsEscape( $i18n.getString( "all" ) , "'" )' + ']';
 </script>