dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20918
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9770: Minor fix.
------------------------------------------------------------
revno: 9770
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-02-07 21:28:18 +0700
message:
Minor fix.
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/DefaultCaseAggregationConditionService.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultDetailsAction.java
--
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 2013-02-07 13:44:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2013-02-07 14:28:18 +0000
@@ -56,7 +56,7 @@
public static final String AGGRERATION_AVG_MIN = "min";
public static final String AGGRERATION_AVG_MAX = "max";
-
+
public static final String OPERATOR_AND = "AND";
public static final String OPERATOR_OR = "OR";
=== 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 2013-02-07 14:02:41 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2013-02-07 14:28:18 +0000
@@ -249,7 +249,7 @@
sql = sql + " AND pdv.programstageinstanceid in ( "
+ convertCondition( aggregationCondition, orgunit, period ) + " ) ";
}
-System.out.println("\n\n --- \n " + sql );
+
Collection<Integer> ids = aggregationConditionStore.executeSQL( sql );
return (ids == null) ? null : ids.iterator().next();
}
@@ -313,16 +313,39 @@
OrganisationUnit orgunit, Period period )
{
Collection<ProgramStageInstance> result = new HashSet<ProgramStageInstance>();
- aggregationCondition.setOperator( AGGRERATION_SUM );
// 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 operator = aggregationCondition.getOperator();
+ String sql = "";
+ if ( operator.equals( CaseAggregationCondition.AGGRERATION_COUNT )
+ || operator.equals( CaseAggregationCondition.AGGRERATION_SUM ) )
+ {
+ aggregationCondition.setOperator( AGGRERATION_SUM );
+ sql = createSQL( aggregationCondition.getAggregationExpression(),
+ aggregationCondition.getOperator(), orgunitId, startDate, endDate );
+ }
+ else
+ {
+ sql = "SELECT psi.programstageinstanceid ";
+ sql += "FROM patientdatavalue pdv ";
+ sql += " INNER JOIN programstageinstance psi ";
+ sql += " ON psi.programstageinstanceid = pdv.programstageinstanceid ";
+ sql += "WHERE executiondate >='" + DateUtils.getMediumDateString( period.getStartDate() ) + "' ";
+ sql += " AND executiondate <='" + DateUtils.getMediumDateString( period.getEndDate() )
+ + "' AND pdv.dataelementid=" + aggregationCondition.getDeSum().getId();
+ if ( aggregationCondition.getAggregationExpression() != null
+ && !aggregationCondition.getAggregationExpression().isEmpty() )
+ {
+ sql = sql + " AND pdv.programstageinstanceid in ( "
+ + convertCondition( aggregationCondition, orgunit, period ) + " ) ";
+ }
+ }
+
Collection<Integer> stageInstanceIds = aggregationConditionStore.executeSQL( sql );
for ( Integer stageInstanceId : stageInstanceIds )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultDetailsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultDetailsAction.java 2012-02-27 06:09:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultDetailsAction.java 2013-02-07 14:28:18 +0000
@@ -160,7 +160,29 @@
CaseAggregationCondition aggCondition = aggregationConditionService
.getCaseAggregationCondition( aggregationConditionId );
- if ( aggCondition.getOperator().equals( CaseAggregationCondition.AGGRERATION_SUM ) )
+ if ( aggCondition.getOperator().equals( CaseAggregationCondition.AGGRERATION_COUNT ) )
+ {
+ mapPatients = new HashMap<Patient, Collection<PatientDataValue>>();
+
+ Collection<Patient> patients = aggregationConditionService.getPatients( aggCondition, orgunit, period );
+
+ for ( Patient patient : patients )
+ {
+ Collection<DataElement> dataElements = aggregationConditionService
+ .getDataElementsInCondition( aggCondition.getAggregationExpression() );
+
+ Collection<PatientDataValue> dataValues = new HashSet<PatientDataValue>();
+
+ if ( dataElements.size() > 0 )
+ {
+ dataValues = patientDataValueService.getPatientDataValues( patient, dataElements, period
+ .getStartDate(), period.getEndDate() );
+ }
+
+ mapPatients.put( patient, dataValues );
+ }
+ }
+ else
{
mapEvents = new HashMap<ProgramStageInstance, Collection<PatientDataValue>>();
@@ -182,28 +204,6 @@
mapEvents.put( programStageInstance, dataValues );
}
}
- else
- {
- mapPatients = new HashMap<Patient, Collection<PatientDataValue>>();
-
- Collection<Patient> patients = aggregationConditionService.getPatients( aggCondition, orgunit, period );
-
- for ( Patient patient : patients )
- {
- Collection<DataElement> dataElements = aggregationConditionService
- .getDataElementsInCondition( aggCondition.getAggregationExpression() );
-
- Collection<PatientDataValue> dataValues = new HashSet<PatientDataValue>();
-
- if ( dataElements.size() > 0 )
- {
- dataValues = patientDataValueService.getPatientDataValues( patient, dataElements, period
- .getStartDate(), period.getEndDate() );
- }
-
- mapPatients.put( patient, dataValues );
- }
- }
return SUCCESS;
}