dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21871
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10458: Don't run query builder formulas to get total persons registered.
------------------------------------------------------------
revno: 10458
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-04-03 13:20:25 +0700
message:
Don't run query builder formulas to get total persons registered.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java
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/patient/DefaultPatientService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.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/patient/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-03-08 09:38:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-04-03 06:20:25 +0000
@@ -241,4 +241,6 @@
Integer max);
Collection<Patient> getPatientByFullname(String fullName, Integer orgunitId);
+
+ Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-03-06 08:07:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-04-03 06:20:25 +0000
@@ -84,4 +84,6 @@
Collection<Patient> getByFullName( String fullName, Integer orgunitId );
+ Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date 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 2013-04-01 05:56:41 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionStore.java 2013-04-03 06:20:25 +0000
@@ -66,6 +66,7 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.jdbc.StatementBuilder;
+import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -136,6 +137,13 @@
this.periodService = periodService;
}
+ private PatientService patientService;
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
// -------------------------------------------------------------------------
// Implementation Methods
// -------------------------------------------------------------------------
@@ -205,7 +213,6 @@
return null;
}
-
public Double getAggregateValue( String caseExpression, String operator, String deType, Integer deSumId,
Integer orgunitId, Period period )
{
@@ -215,7 +222,7 @@
if ( operator.equals( CaseAggregationCondition.AGGRERATION_COUNT )
|| operator.equals( CaseAggregationCondition.AGGRERATION_SUM ) )
{
- String sql = parseExpressionToSql( caseExpression, operator, deType, deSumId, orgunitId, startDate, endDate );
+ String sql = parseExpressionToSql( caseExpression, operator, deType, deSumId, orgunitId, startDate, endDate );
Collection<Integer> ids = this.executeSQL( sql );
return (ids == null) ? null : ids.size() + 0.0;
}
@@ -231,13 +238,14 @@
if ( caseExpression != null && !caseExpression.isEmpty() )
{
sql = sql + " AND pdv.programstageinstanceid in ( "
- + parseExpressionToSql( caseExpression, operator, deType, deSumId, orgunitId, startDate, endDate ) + " ) ";
+ + parseExpressionToSql( caseExpression, operator, deType, deSumId, orgunitId, startDate, endDate )
+ + " ) ";
}
Collection<Integer> ids = this.executeSQL( sql );
return (ids == null) ? null : ids.iterator().next() + 0.0;
}
-
+
public String parseExpressionToSql( String aggregationExpression, String operator, String deType, Integer deSumId,
Integer orgunitId, String startDate, String endDate )
{
@@ -278,7 +286,7 @@
IN_CONDITION_END_SIGN, ")" );
return sql;
}
-
+
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
@@ -317,6 +325,10 @@
Collection<Integer> _orgunitIds = programStageInstanceService.getOrganisationUnitIds(
period.getStartDate(), period.getEndDate() );
+ Collection<Integer> _registrationOrgunit = patientService.getRegistrationOrgunitIds(
+ period.getStartDate(), period.getEndDate() );
+ _orgunitIds.addAll( _registrationOrgunit );
+
if ( orgunitIds == null )
{
orgunitIds = new HashSet<Integer>();
@@ -326,6 +338,7 @@
{
orgunitIds.retainAll( _orgunitIds );
}
+
// ---------------------------------------------------------------------
// Aggregation
// ---------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-03-21 07:56:35 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-04-03 06:20:25 +0000
@@ -351,7 +351,7 @@
@Override
public Collection<Patient> sortPatientsByAttribute( Collection<Patient> patients, PatientAttribute patientAttribute )
{
- Collection<Patient> sortedPatients = new ArrayList<Patient>();
+ Collection<Patient> sortedPatients = new ArrayList<Patient>();
// ---------------------------------------------------------------------
// Better to fetch all attribute values at once than fetching the
@@ -540,8 +540,8 @@
return patientStore.getPatientPhoneNumbers( searchKeys, orgunit, min, max );
}
- public List<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit,
- Integer min, Integer max )
+ public List<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min,
+ Integer max )
{
return patientStore.getProgramStageInstances( searchKeys, orgunit, min, max );
}
@@ -571,7 +571,7 @@
grid.setTitle( i18n.getString( "activity_plan" ) );
if ( !startDate.isEmpty() && !endDate.isEmpty() )
{
- grid.setSubtitle( i18n.getString( "from" ) + " " + startDate + " " + i18n.getString( "to" ) + " " + endDate );
+ grid.setSubtitle( i18n.getString( "from" ) + " " + startDate + " " + i18n.getString( "to" ) + " " + endDate );
}
grid.addHeader( new GridHeader( "patientid", true, true ) );
@@ -594,4 +594,10 @@
return patientStore.getByFullName( fullName, orgunitId );
}
+ @Override
+ public Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate )
+ {
+ return patientStore.getRegistrationOrgunitIds( startDate, endDate );
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-03-21 07:56:35 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-04-03 06:20:25 +0000
@@ -673,6 +673,21 @@
return patients;
}
+ @SuppressWarnings( "unchecked" )
+ public Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate )
+ {
+ Criteria criteria = getCriteria();
+ criteria.add( Restrictions.between( "registrationDate", startDate, endDate ) );
+ criteria.createAlias( "organisationUnit", "orgunit" );
+ criteria.setProjection( Projections.distinct( Projections.projectionList().add(
+ Projections.property( "orgunit.id" ), "orgunitid" ) ) );
+ return criteria.list();
+ }
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
private Collection<Integer> getOrgunitChildren( OrganisationUnit orgunit )
{
Collection<Integer> orgunitIds = new HashSet<Integer>();
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-02 15:14:17 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-04-03 06:20:25 +0000
@@ -13,6 +13,7 @@
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+ <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
</bean>
<bean id="org.hisp.dhis.relationship.RelationshipStore"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java 2013-03-29 04:26:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java 2013-04-03 06:20:25 +0000
@@ -34,15 +34,12 @@
import org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager;
import org.hisp.dhis.patient.scheduling.CaseAggregateConditionTask;
-import org.hisp.dhis.scheduling.DataMartTask;
-import org.hisp.dhis.scheduling.ScheduledTasks;
import org.hisp.dhis.scheduling.TaskCategory;
import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.system.notification.Notifier;
import org.hisp.dhis.system.scheduling.Scheduler;
import org.hisp.dhis.user.CurrentUserService;
-import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;