← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11105: Add description for program indicator..

 

------------------------------------------------------------
revno: 11105
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-05-30 13:08:13 +0700
message:
  Add description for program indicator..
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorAction.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/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramIndicator.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programIndicator.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramIndicator.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java	2013-05-30 06:08:13 +0000
@@ -38,6 +38,12 @@
 {
     private static final long serialVersionUID = 7920320128945484331L;
 
+    public static String OBJECT_PROGRAM_STAGE_DATAELEMENT = "DE";
+    
+    public static String SEPARATOR_OBJECT = ":";
+    
+    public static final String SEPARATOR_ID = "\\.";
+
     public static final String VALUE_TYPE_DATE = "date";
 
     public static final String VALUE_TYPE_INT = "int";
@@ -48,6 +54,9 @@
 
     public static final String CURRENT_DATE = "current_date";
 
+    public static final String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
+    + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
+    
     private String valueType;
 
     private String expression;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java	2013-05-30 06:08:13 +0000
@@ -58,4 +58,6 @@
 
     Map<String, String> getProgramIndicatorValues( ProgramInstance programInstance );
 
+    String getExpressionDescription( String expression );
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-05-30 03:26:58 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-05-30 06:08:13 +0000
@@ -214,8 +214,6 @@
         executeSql( "ALTER TABLE patient ALTER COLUMN underage DROP NOT NULL");
         executeSql( "ALTER TABLE program ALTER COLUMN dateofenrollmentdescription DROP NOT NULL");
         executeSql( "UPDATE program SET displayOnAllOrgunit=true where displayOnAllOrgunit is null" );
-        executeSql( "ALTER TABLE programstage DROP CONSTRAINT programstage_name_key");
-        executeSql( "ALTER TABLE programstagesection DROP CONSTRAINT programstagesection_name_key;");
         
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java	2013-04-17 09:20:46 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java	2013-05-30 06:08:13 +0000
@@ -27,9 +27,6 @@
 
 package org.hisp.dhis.program;
 
-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 static org.hisp.dhis.i18n.I18nUtils.i18n;
 
 import java.util.Collection;
@@ -57,9 +54,6 @@
 public class DefaultProgramIndicatorService
     implements ProgramIndicatorService
 {
-    private final String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
-        + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -212,6 +206,48 @@
         return result;
     }
 
+    public String getExpressionDescription( String expression )
+    {
+        StringBuffer description = new StringBuffer();
+
+        Pattern patternCondition = Pattern.compile( ProgramIndicator.regExp );
+
+        Matcher matcher = patternCondition.matcher( expression );
+
+        while ( matcher.find() )
+        {
+            String match = matcher.group();
+            match = match.replaceAll( "[\\[\\]]", "" );
+
+            String[] info = match.split( ProgramIndicator.SEPARATOR_OBJECT );
+
+            String[] ids = info[1].split( ProgramIndicator.SEPARATOR_ID );
+
+            int programStageId = Integer.parseInt( ids[0] );
+            ProgramStage programStage = programStageService.getProgramStage( programStageId );
+            String programStageName = "The program stage not exist";
+            if ( programStage != null )
+            {
+                programStageName = programStage.getDisplayName();
+            }
+
+            int dataElementId = Integer.parseInt( ids[1] );
+            DataElement dataElement = dataElementService.getDataElement( dataElementId );
+            String dataelementName = "The data element not exist";
+            if ( dataElement != null )
+            {
+                dataelementName = dataElement.getDisplayName();
+            }
+
+            matcher.appendReplacement( description, "[" + ProgramIndicator.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramIndicator.SEPARATOR_OBJECT + programStageName + ProgramIndicator.SEPARATOR_ID
+                + dataelementName + "]" );
+        }
+
+        matcher.appendTail( description );
+
+        return description.toString();
+    }
+
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
@@ -232,15 +268,15 @@
 
         StringBuffer description = new StringBuffer();
 
-        Pattern pattern = Pattern.compile( regExp );
+        Pattern pattern = Pattern.compile( ProgramIndicator.regExp );
         Matcher matcher = pattern.matcher( expression );
         while ( matcher.find() )
         {
             DataElement dataElement = null;
 
-            String key = matcher.group().replaceAll( "[\\[\\]]", "" ).split( SEPARATOR_OBJECT )[1];
-            String[] infor = key.split( SEPARATOR_ID );
-            
+            String key = matcher.group().replaceAll( "[\\[\\]]", "" ).split( ProgramIndicator.SEPARATOR_OBJECT )[1];
+            String[] infor = key.split( ProgramIndicator.SEPARATOR_ID );
+
             Integer programStageId = Integer.parseInt( infor[0] );
             ProgramStage programStage = programStageService.getProgramStage( programStageId );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorAction.java	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programtindicator/GetProgramIndicatorAction.java	2013-05-30 06:08:13 +0000
@@ -68,6 +68,13 @@
         return programIndicator;
     }
 
+    private String description;
+
+    public String getDescription()
+    {
+        return description;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -78,6 +85,8 @@
     {
         programIndicator = programIndicatorService.getProgramIndicator( id );
 
+        description = programIndicatorService.getExpressionDescription( programIndicator.getExpression() );
+        
         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	2013-05-24 09:10:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2013-05-30 06:08:13 +0000
@@ -1144,5 +1144,14 @@
 			<ref bean="org.hisp.dhis.program.ProgramIndicatorService" />
 		</property>
 	</bean>
+	
+	<bean
+		id="org.hisp.dhis.patient.action.programtindicator.GetProgramIndicatorDescripttionAction"
+		class="org.hisp.dhis.patient.action.programtindicator.GetProgramIndicatorDescripttionAction"
+		scope="prototype">
+		<property name="programIndicatorService">
+			<ref bean="org.hisp.dhis.program.ProgramIndicatorService" />
+		</property>
+	</bean>
 
 </beans>
\ 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	2013-05-24 09:10:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2013-05-30 06:08:13 +0000
@@ -1176,6 +1176,13 @@
 			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
+		
+		<action name="getProgramIndicatorDescripttion"
+			class="org.hisp.dhis.patient.action.programtindicator.GetProgramIndicatorDescripttionAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
+		</action>
 
 	</package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramIndicator.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramIndicator.vm	2013-04-17 09:20:46 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramIndicator.vm	2013-05-30 06:08:13 +0000
@@ -58,7 +58,7 @@
 			<td>
 				<select style="width:336px;" id="rootDate" name="rootDate" class="{validate:{required:true}}">
 					<option value='incident_date'>$i18n.getString('incident_date')</option>
-					<option value='execution_date'>$i18n.getString('execution_date')</option>
+					<option value='execution_date'>$i18n.getString('report_date')</option>
 					<option value='current_date'>$i18n.getString('current_date')</option>
 				</select>
 			</td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programIndicator.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programIndicator.js	2013-04-17 07:58:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programIndicator.js	2013-05-30 06:08:13 +0000
@@ -49,10 +49,13 @@
 			var deSumId = jQuery('#deSumId');
 			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>" );
-				if( json.dataElements[i].type=='int')
+				if( json.dataElements[i].type=='int' || json.dataElements[i].type=='date'  )
 				{
-					deSumId.append( "<option value='" + json.dataElements[i].id + "' title='" + json.dataElements[i].name + "' suggested='" + json.dataElements[i].optionset + "'>" + json.dataElements[i].name + "</option>" );
+					dataElements.append( "<option value='" + json.dataElements[i].id + "' title='" + json.dataElements[i].name + "' suggested='" + json.dataElements[i].optionset + "'>" + json.dataElements[i].name + "</option>" );
+					if( json.dataElements[i].type=='int')
+					{
+						deSumId.append( "<option value='" + json.dataElements[i].id + "' title='" + json.dataElements[i].name + "' suggested='" + json.dataElements[i].optionset + "'>" + json.dataElements[i].name + "</option>" );
+					}
 				}
 			}
 			
@@ -93,13 +96,13 @@
 
 function getConditionDescription ()
 {
-	var valueType = getFieldValue('valueType');
-	if( valueType == 'int' ){
-		hideById('rootDateTR');
-	}
-	else{
-		showById('rootDateTR');
-	}
+	$.postJSON( 'getProgramIndicatorDescripttion.action', 
+	{ 
+		expression:getFieldValue('expression') 
+	},function (json)
+	{
+		byId('aggregationDescription').innerHTML = json.message;
+	})
 }
 
 function programIndicatorOnChange()

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramIndicator.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramIndicator.vm	2013-05-16 06:09:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramIndicator.vm	2013-05-30 06:08:13 +0000
@@ -58,7 +58,7 @@
 		<td>
 			<select style="width:336px;" id="rootDate" name="rootDate" class="{validate:{required:true}}">
 				<option value='incident_date'>$i18n.getString('incident_date')</option>
-				<option value='execution_date'>$i18n.getString('execution_date')</option>
+				<option value='execution_date'>$i18n.getString('report_date')</option>
 				<option value='current_date'>$i18n.getString('current_date')</option>
 			</select>
 		</td>