dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14793
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5123: Re-organize Beneficiary Aggregation module.
------------------------------------------------------------
revno: 5123
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-11-07 14:56:20 +0700
message:
Re-organize Beneficiary Aggregation module.
modified:
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/jdbc/JdbcCaseAggregationConditionStore.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResultDetails.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js
--
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-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 2011-11-04 06:13:38 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2011-11-07 07:56:20 +0000
@@ -204,7 +204,7 @@
Period period )
{
String sql = convertCondition( aggregationCondition, orgunit, period );
-
+
Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sql );
if ( patientIds == null )
@@ -219,10 +219,15 @@
public Collection<PatientDataValue> getPatientDataValues( CaseAggregationCondition aggregationCondition,
OrganisationUnit orgunit, Period period )
{
+ // get params
+ int orgunitId = orgunit.getId();
+ String startDate = DateUtils.getMediumDateString( period.getStartDate() );
+ String endDate = DateUtils.getMediumDateString( period.getEndDate() );
+
Collection<PatientDataValue> result = new HashSet<PatientDataValue>();
String sql = createSQL( aggregationCondition.getAggregationExpression(), aggregationCondition.getOperator(),
- orgunit, period );
+ orgunitId, startDate, endDate );
Collection<DataElement> dataElements = getDataElementsInCondition( aggregationCondition
.getAggregationExpression() );
@@ -241,16 +246,22 @@
result.addAll( dataValues );
}
}
+
return result;
}
public Collection<Patient> getPatients( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit,
Period period )
{
+ // get params
+ int orgunitId = orgunit.getId();
+ String startDate = DateUtils.getMediumDateString( period.getStartDate() );
+ String endDate = DateUtils.getMediumDateString( period.getEndDate() );
+
Collection<Patient> result = new HashSet<Patient>();
String sql = createSQL( aggregationCondition.getAggregationExpression(), aggregationCondition.getOperator(),
- orgunit, period );
+ orgunitId, startDate, endDate );
Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sql );
@@ -479,6 +490,11 @@
private String convertCondition( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit,
Period period )
{
+ // get params
+ int orgunitId = orgunit.getId();
+ String startDate = DateUtils.getMediumDateString( period.getStartDate() );
+ String endDate = DateUtils.getMediumDateString( period.getEndDate() );
+
// Get operators between ( )
Pattern patternOperator = Pattern.compile( "(\\)\\s*(OR|AND)\\s*\\( )" );
@@ -498,7 +514,7 @@
// Create SQL statement for the first condition
String condition = conditions[0].replace( "(", "" ).replace( ")", "" );
- String sql = createSQL( condition, aggregationCondition.getOperator(), orgunit, period );
+ String sql = createSQL( condition, aggregationCondition.getOperator(), orgunitId, startDate, endDate );
subSQL.add( sql );
@@ -507,7 +523,7 @@
{
condition = conditions[index].replace( "(", "" ).replace( ")", "" );
- sql = "(" + createSQL( condition, aggregationCondition.getOperator(), orgunit, period ) + ")";
+ sql = "(" + createSQL( condition, aggregationCondition.getOperator(), orgunitId, startDate, endDate ) + ")";
subSQL.add( sql );
}
@@ -515,12 +531,9 @@
return getSQL( subSQL, operators );
}
- private String createSQL( String aggregationExpression, String operator, OrganisationUnit orgunit, Period period )
+ private String createSQL( String aggregationExpression, String operator, int orgunitId, String startDate, String endDate )
{
- int orgunitId = orgunit.getId();
- String startDate = DateUtils.getMediumDateString( period.getStartDate() );
- String endDate = DateUtils.getMediumDateString( period.getEndDate() );
-
+
// ---------------------------------------------------------------------
// get operators
// ---------------------------------------------------------------------
@@ -700,8 +713,9 @@
return 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 pd.categoryoptioncomboid = " + optionComboId + " AND pd.dataelementid = " + dataElementId + " "
+ + "WHERE pd.categoryoptioncomboid = " + optionComboId + " AND psd.dataelementid = " + dataElementId + " "
+ "AND pd.organisationunitid = " + orgunitId + " AND ps.programstageid = " + programStageId + " "
+ "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' ";
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionStore.java 2011-11-02 07:04:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionStore.java 2011-11-07 07:56:20 +0000
@@ -31,7 +31,6 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import org.amplecode.quick.StatementHolder;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2011-11-07 03:12:09 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2011-11-07 07:56:20 +0000
@@ -270,6 +270,7 @@
{
DataValue dvalue = new DataValue( dElement, period, orgUnit, "", storedBy, new Date(),
null, optionCombo );
+
dvalue.setValue( dataValue.getValue() + " " + i18n.getString( "old_value" ) );
dataValueService.deleteDataValue( dataValue );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-10-27 05:51:06 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-11-07 07:56:20 +0000
@@ -438,6 +438,7 @@
enroll_to_program = Enroll to program
add_dependent = Add dependent
edit_profile = Edit profile
+case_aggregation_result = Beneficiary aggregation result
aggregate_details = Aggregate details
show_details = Show details
representative_info = Representative's Information
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2011-11-07 03:15:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2011-11-07 07:56:20 +0000
@@ -234,7 +234,7 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-caseentry/caseAggregationForm.vm</param>
<param name="menu">/dhis-web-caseentry/caseAggregationMenu.vm</param>
- <param name="javascripts">javascript/caseagg.js,javascript/caseAggregationForm.js</param>
+ <param name="javascripts">javascript/caseagg.js,javascript/date.js,javascript/caseAggregationForm.js</param>
</action>
<action name="loadPeriods"
@@ -255,10 +255,10 @@
<action name="caseAggregationResult"
class="org.hisp.dhis.caseentry.action.caseaggregation.CaseAggregationResultAction">
- <result name="success" type="velocity">/main.vm</result>
+ <result name="success" type="velocity">/content.vm</result>
<param name="page">/dhis-web-caseentry/caseAggregationResult.vm</param>
<param name="menu">/dhis-web-caseentry/caseAggregationMenu.vm</param>
- <param name="javascripts">javascript/caseagg.js,javascript/caseAggregationForm.js</param>
+ <param name="javascripts">javascript/caseagg.js</param>
</action>
<action name="caseAggregationResultDetails"
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm 2011-08-04 06:25:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm 2011-11-07 07:56:20 +0000
@@ -4,75 +4,83 @@
var isSubmit = true;
</script>
-<h1> $i18n.getString( "case_aggregation_form" ) #openHelp('run_case_aggregation')</h1>
-<hr/>
-<form id="caseAggregationForm" name="caseAggregationForm" action="caseAggregationResult.action" method="post">
- <table>
- <tr>
- <td>
- $i18n.getString( "dataset_list" )
- </td>
- <td>
- <select id="dataSetId" name="dataSetId" onchange="dataSetSelected()" style="width: 30em">
- <option value=''>[$i18n.getString('please_select')]</option>
- #foreach ( $dataSet in $datasets )
- <option value='$dataSet.id' title='$dataSet.name'>$dataSet.name</option>
- #end
- </select>
- </td>
- </tr>
-
- <tr>
- <td>
- $i18n.getString( "from" )
- </td>
- <td>
- <input type="button" value="<<" onclick="getPreviousPeriodForStart()" id="previousPeriodForStartBtn" disabled />
- <select id="sDateLB" name="sDateLB" style="width: 23em"></select>
- <input type="button" value=">>" onclick="getNextPeriodForStart()" id="nextPeriodForStartBtn" disabled />
- </td>
- </tr>
-
- <tr>
- <td>
- $i18n.getString( "to" )
- </td>
- <td>
- <input type="button" value="<<" onclick="getPreviousPeriodForEnd()" id="previousPeriodForEndBtn" disabled />
- <select id="eDateLB" name="eDateLB" style="width: 23em"></select>
- <input type="button" value=">>" onclick="getNextPeriodForEnd()" id="nextPeriodForEndBtn" disabled />
- <i><span id='warningMessage' style="color:red"></span></i>
- </td>
-
- </tr>
- <tr>
- <td>
- $i18n.getString( "ga_facilityby" )
- </td>
- <td>
- <select id="facilityLB" name="facilityLB" style="width: 30em">
- <option value="random" selected>$i18n.getString( "selected" )</option>
- <option value="immChildren" >$i18n.getString( "immediate_children" )</option>
- <option value="children" >$i18n.getString( "child_tree" )</option>
- </select>
- </td>
- </tr>
-
- <tr><td colspan='2' style="height:1em"></td></tr>
-
- <tr>
- <td colspan='2'>
- #organisationUnitSelectionTree( true, false, false )
- </td>
- </tr>
-
- <tr>
- <td>
- <input type="submit" name="Aggregate" value="$i18n.getString( 'aggregate' )"/></td>
- </td>
- <td></td>
- </tr>
- </table>
-
- <span id='message'></span>
-</form>
+<div id='caseAggregationDiv'>
+
+ <h1> $i18n.getString( "case_aggregation_form" ) #openHelp('run_case_aggregation')</h1>
+ <hr/>
+ <form id="caseAggregationForm" name="caseAggregationForm" action="caseAggregationResult.action" method="post">
+ <table>
+ <tr>
+ <td>
+ $i18n.getString( "dataset_list" )
+ </td>
+ <td>
+ <select id="dataSetId" name="dataSetId" onchange="dataSetSelected()" style="width: 30em">
+ <option value=''>[$i18n.getString('please_select')]</option>
+ #foreach ( $dataSet in $datasets )
+ <option value='$dataSet.id' title='$dataSet.name'>$dataSet.name</option>
+ #end
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ $i18n.getString( "from" )
+ </td>
+ <td>
+ <input type="button" value="<<" onclick="getPreviousPeriodForStart()" id="previousPeriodForStartBtn" disabled />
+ <select id="sDateLB" name="sDateLB" style="width: 23em"></select>
+ <input type="button" value=">>" onclick="getNextPeriodForStart()" id="nextPeriodForStartBtn" disabled />
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ $i18n.getString( "to" )
+ </td>
+ <td>
+ <input type="button" value="<<" onclick="getPreviousPeriodForEnd()" id="previousPeriodForEndBtn" disabled />
+ <select id="eDateLB" name="eDateLB" style="width: 23em"></select>
+ <input type="button" value=">>" onclick="getNextPeriodForEnd()" id="nextPeriodForEndBtn" disabled />
+ <i><span id='warningMessage' style="color:red"></span></i>
+ </td>
+
+ </tr>
+ <tr>
+ <td>
+ $i18n.getString( "ga_facilityby" )
+ </td>
+ <td>
+ <select id="facilityLB" name="facilityLB" style="width: 30em">
+ <option value="random" selected>$i18n.getString( "selected" )</option>
+ <option value="immChildren" >$i18n.getString( "immediate_children" )</option>
+ <option value="children" >$i18n.getString( "child_tree" )</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr><td colspan='2' style="height:1em"></td></tr>
+
+ <tr>
+ <td colspan='2'>
+ #organisationUnitSelectionTree( true, false, false )
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <input type="submit" name="Aggregate" value="$i18n.getString( 'aggregate' )"/></td>
+ </td>
+ <td></td>
+ </tr>
+ </table>
+ </form>
+</div>
+
+#parse( "dhis-web-commons/loader/loader.vm" )
+
+<div id='caseAggregationResult' style='none'></div>
+
+<span id='message'></span>
+
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm 2011-10-06 05:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm 2011-11-07 07:56:20 +0000
@@ -1,6 +1,7 @@
-
+<h4> $i18n.getString( "case_aggregation_result" )</h4>
+
<div>
- <input type="button" value="$i18n.getString( "back" )" onclick="window.location.href='caseAggregationForm.action'" style="width:10em">
+ <input type="button" value="$i18n.getString( "back" )" onclick="backBtnOnClick();" style="width:10em">
</div>
<p></p>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResultDetails.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResultDetails.vm 2011-11-02 07:04:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResultDetails.vm 2011-11-07 07:56:20 +0000
@@ -29,6 +29,7 @@
<td>$i18n.getString('program_stage')</td>
<td>$i18n.getString('data_element')</td>
<td>$i18n.getString('value')</td>
+ <td>$i18n.getString('period')</td>
</tr>
#set( $mark = false )
#foreach( $dataValue in $dataValues )
@@ -36,6 +37,7 @@
<td>$dataValue.programStageInstance.programStage.name</td>
<td>$dataValue.dataElement.name</td>
<td>$dataValue.value</td>
+ <td>$format.formatDate($dataValue.timestamp)</td>
</tr>
#set( $mark = !$mark)
#end
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js 2011-10-06 05:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js 2011-11-07 07:56:20 +0000
@@ -95,7 +95,7 @@
if( type == "success" )
{
- document.forms[ 'caseAggregationForm' ].submit();
+ caseAggregationResult();
}
else
{
@@ -105,6 +105,7 @@
function viewResultDetails( orgunitId, periodId, aggregationConditionId )
{
+ $('#contentDetails' ).val('');
var url = 'caseAggregationResultDetails.action?';
url+= 'orgunitId=' + orgunitId;
url+= '&periodId=' + periodId;
@@ -121,3 +122,24 @@
});
}
+function caseAggregationResult()
+{
+ hideById('caseAggregationForm');
+ showLoader();
+
+ $('#caseAggregationResult').load("caseAggregationResult.action",
+ {
+ facilityLB: getFieldValue('facilityLB'),
+ dataSetId: getFieldValue('dataSetId')
+ }
+ , function(){
+ $( "#loaderDiv" ).hide();
+ showById('caseAggregationResult');
+ });
+}
+
+function backBtnOnClick()
+{
+ hideById('caseAggregationResult');
+ showById('caseAggregationForm');
+}