dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27083
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13432: Exception thrown when to run Aggregate.
------------------------------------------------------------
revno: 13432
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-26 10:01:38 +0700
message:
Exception thrown when to run Aggregate.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java
dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java
dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.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-12-16 04:27:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2013-12-26 03:01:38 +0000
@@ -70,8 +70,6 @@
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";
@@ -92,11 +90,10 @@
public static String AUTO_STORED_BY = "DHIS-SYSTEM";
- public static final String regExp = "\\[(" + OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE + "|" + OBJECT_PATIENT + "|"
- + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE + "|"
- + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|"
- + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+["
- + SEPARATOR_ID + "[a-zA-Z0-9]*]*)" + "\\]";
+ public static final String regExp = "\\[(" + OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE + "|" + OBJECT_PROGRAM + "|"
+ + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY
+ + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PROGRAM_PROPERTY + ")"
+ + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)" + "\\]";
public static final String dataelementRegExp = MINUS_OPERATOR + "{1}\\s*\\(\\s*(\\["
+ OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+" + SEPARATOR_ID + "[0-9]+" + SEPARATOR_ID
=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2013-11-29 09:24:58 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2013-12-26 03:01:38 +0000
@@ -29,7 +29,6 @@
*/
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE;
@@ -76,8 +75,6 @@
{
private final String INVALID_CONDITION = "Invalid condition";
- private final String TOTAL_OF_PATIENTS_REGISTERED = "Total of patient registration";
-
private final String IN_CONDITION_GET_ALL = "*";
// -------------------------------------------------------------------------
@@ -225,12 +222,7 @@
{
String[] ids = info[1].split( SEPARATOR_ID );
- if ( info[0].equalsIgnoreCase( OBJECT_PATIENT ) )
- {
- matcher.appendReplacement( description, "[" + OBJECT_PATIENT + SEPARATOR_OBJECT
- + TOTAL_OF_PATIENTS_REGISTERED + "]" );
- }
- else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) )
+ if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) )
{
int objectId = Integer.parseInt( ids[0] );
=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2013-12-19 06:41:31 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2013-12-26 03:01:38 +0000
@@ -29,7 +29,6 @@
*/
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE;
-import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM;
@@ -154,8 +153,7 @@
public Grid getAggregateValue( CaseAggregationCondition caseAggregationCondition, Collection<Integer> orgunitIds,
Period period, I18nFormat format, I18n i18n )
{
- Collection<Integer> _orgunitIds = getServiceOrgunit( DateUtils.getMediumDateString( period.getStartDate() ),
- DateUtils.getMediumDateString( period.getEndDate() ) );
+ Collection<Integer> _orgunitIds = getServiceOrgunit();
_orgunitIds.retainAll( orgunitIds );
if ( _orgunitIds.size() > 0 )
@@ -380,9 +378,7 @@
String caseOperator = rs.getString( "caseoperator" );
int deSumId = rs.getInt( "desumid" );
- Collection<Integer> _orgunitIds = getServiceOrgunit(
- DateUtils.getMediumDateString( period.getStartDate() ),
- DateUtils.getMediumDateString( period.getEndDate() ) );
+ Collection<Integer> _orgunitIds = getServiceOrgunit();
if ( orgunitIds == null )
{
@@ -498,11 +494,7 @@
match = match.replaceAll( "[\\[\\]]", "" );
String[] info = match.split( SEPARATOR_OBJECT );
- if ( info[0].equalsIgnoreCase( OBJECT_PATIENT ) )
- {
- condition = getConditionForPatient( orgunitIds, operator, startDate, endDate );
- }
- else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) )
+ if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) )
{
String attributeId = info[1];
@@ -640,17 +632,18 @@
}
/**
- * Return standard SQL of a dynamic patient-attribute expression. E.g [CA:1] OR [CA:1.age]
+ * Return standard SQL of a dynamic patient-attribute expression. E.g [CA:1]
+ * OR [CA:1.age]
*
*/
- private String getConditionForPatientAttribute( String attributeId, Collection<Integer> orgunitIds,
- boolean isExist )
+ private String getConditionForPatientAttribute( String attributeId, Collection<Integer> orgunitIds, boolean isExist )
{
String sql = " EXISTS ( SELECT * FROM patientattributevalue _pav " + " WHERE _pav.patientid=pi.patientid ";
- if ( attributeId.split( SEPARATOR_ID ).length==2)
+ if ( attributeId.split( SEPARATOR_ID ).length == 2 )
{
- sql += " AND _pav.patientattributeid=" + attributeId.split( "." )[0] + " AND DATE(now) - DATE( _pav.value ) ";
+ sql += " AND _pav.patientattributeid=" + attributeId.split( "." )[0]
+ + " AND DATE(now) - DATE( _pav.value ) ";
}
if ( isExist )
{
@@ -665,21 +658,6 @@
}
/**
- * Return standard SQL of the expression which is used for calculating total
- * of person registration
- *
- */
- private String getConditionForPatient( Collection<Integer> orgunitIds, String operator, String startDate,
- String endDate )
- {
- String sql = " EXISTS ( SELECT * FROM patient _p WHERE _p.patientid = pi.patientid "
- + "AND _p.registrationdate>='" + startDate + "' AND _p.registrationdate<='" + endDate + "' "
- + "AND _p.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgunitIds ) + ") ";
-
- return sql;
- }
-
- /**
* Return standard SQL of the program-property expression. E.g
* [PC:executionDate]
*
@@ -868,19 +846,9 @@
* happened.
*
*/
- private Collection<Integer> getServiceOrgunit( String startDate, String endDate )
+ private Collection<Integer> getServiceOrgunit()
{
- String sql = "(select organisationunitid from programstageinstance where executiondate>= '" + startDate
- + "' and executiondate<='" + endDate + "')";
- sql += " UNION ";
- sql += "( select distinct organisationunitid from patient where registrationdate BETWEEN '" + startDate
- + "' AND '" + endDate + "')";
- sql += " UNION ";
- sql += "( select distinct organisationunitid from patient p INNER JOIN programinstance pi ON p.patientid=pi.patientid "
- + " where pi.enrollmentdate BETWEEN '" + startDate + "' AND '" + endDate + "')";
- sql += " UNION ";
- sql += "( select distinct organisationunitid from patient p INNER JOIN programinstance pi ON p.patientid=pi.patientid "
- + " where pi.enrollmentdate BETWEEN '" + startDate + "' AND '" + endDate + "')";
+ String sql = "select distinct organisationunitid from patient";
Collection<Integer> orgunitIds = new HashSet<Integer>();
orgunitIds = jdbcTemplate.query( sql, new RowMapper<Integer>()
@@ -1074,8 +1042,7 @@
String[] info = match.split( SEPARATOR_OBJECT );
- if ( info[0].equalsIgnoreCase( CaseAggregationCondition.OBJECT_PATIENT )
- || info[0].equalsIgnoreCase( CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE ) )
+ if ( info[0].equalsIgnoreCase( CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE ) )
{
return true;
}
@@ -1084,31 +1051,6 @@
return false;
}
- // private boolean hasProgramInstanceCriteria( String expresstion )
- // {
- // Pattern pattern = Pattern.compile( CaseAggregationCondition.regExp );
- // Matcher matcher = pattern.matcher( expresstion );
- // while ( matcher.find() )
- // {
- // String match = matcher.group();
- //
- // match = match.replaceAll( "[\\[\\]]", "" );
- //
- // String[] info = match.split( SEPARATOR_OBJECT );
- //
- // if ( info[0].equalsIgnoreCase(
- // CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY )
- // || info[0].equalsIgnoreCase( CaseAggregationCondition.OBJECT_PROGRAM )
- // || info[0].equalsIgnoreCase(
- // CaseAggregationCondition.OBJECT_PROGRAM_STAGE ) )
- // {
- // return true;
- // }
- // }
- //
- // return false;
- // }
-
private boolean hasDataelementCriteria( String expresstion )
{
Pattern pattern = Pattern.compile( CaseAggregationCondition.regExp );