dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21371
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10093: Minor fix program statistics.
------------------------------------------------------------
revno: 10093
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-03-09 12:42:33 +0700
message:
Minor fix program statistics.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-03-09 04:40:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-03-09 05:42:33 +0000
@@ -364,8 +364,7 @@
// Average number of stages for complete programs
int stageCount = program.getProgramStages().size();
- int stageCompleted = getProgramStageInstanceCount( program, orgunitIds, startDate, endDate, true );
-System.out.println("\n\n ===== \n stageCompleted : " + stageCompleted );
+ int stageCompleted = getProgramStageInstanceCount( program, orgunitIds, startDate, endDate, true );
double average = 0.0;
if ( total != 0 && stageCompleted != 0 )
{
@@ -418,7 +417,7 @@
grid.addValue( i18n.getString( "visits_overdue_percent" ) );
// Add values for stage details
-
+
for ( ProgramStage programStage : program.getProgramStages() )
{
grid.addRow();
@@ -471,7 +470,7 @@
}
grid.addValue( format.formatValue( percent ) + "%" );
}
-
+
return grid;
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-03-09 04:40:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-03-09 05:42:33 +0000
@@ -30,6 +30,7 @@
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -61,6 +62,7 @@
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.patientreport.PatientAggregateReport;
import org.hisp.dhis.patientreport.TabularReportColumn;
+import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
@@ -705,17 +707,26 @@
public int getOverDueCount( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate )
{
+ Calendar yesterday = Calendar.getInstance();
+ yesterday.add( Calendar.DATE, -1 );
+ CalendarPeriodType.clearTimeOfDay( yesterday );
+ Date now = yesterday.getTime();
+
+ if ( endDate.before( now ) )
+ {
+ now = endDate;
+ }
+
Criteria criteria = getCriteria();
criteria.createAlias( "programInstance", "programInstance" );
- criteria.createAlias( "programStage", "programStage" );
criteria.createAlias( "programInstance.patient", "patient" );
criteria.createAlias( "patient.organisationUnit", "regOrgunit" );
criteria.add( Restrictions.eq( "programStage", programStage ) );
criteria.add( Restrictions.isNull( "programInstance.endDate" ) );
- criteria.add( Restrictions.and( Restrictions.isNull( "executionDate" ),
- Restrictions.between( "dueDate", startDate, new Date() ), Restrictions.in( "regOrgunit.id", orgunitIds ) ) );
+ criteria.add( Restrictions.between( "dueDate", startDate, now ) );
+ criteria.add( Restrictions.in( "regOrgunit.id", orgunitIds ) );
criteria.setProjection( Projections.rowCount() ).uniqueResult();
-
+
Number rs = (Number) criteria.setProjection( Projections.rowCount() ).uniqueResult();
return rs != null ? rs.intValue() : 0;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-03-08 09:15:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-03-09 05:42:33 +0000
@@ -27,6 +27,7 @@
package org.hisp.dhis.caseentry.action.patient;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -42,6 +43,7 @@
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
import org.hisp.dhis.relationship.Relationship;
@@ -227,10 +229,9 @@
patientAudits = patientAuditService.getPatientAudits( patient );
- long millisInDay = 60 * 60 * 24 * 1000;
- long currentTime = new Date().getTime();
- long dateOnly = (currentTime / millisInDay) * millisInDay;
- Date date = new Date( dateOnly );
+ Calendar today = Calendar.getInstance();
+ CalendarPeriodType.clearTimeOfDay( today );
+ Date date = today.getTime();
String visitor = currentUserService.getCurrentUsername();
PatientAudit patientAudit = patientAuditService.getPatientAudit( patientId, visitor, date,
PatientAudit.MODULE_PATIENT_DASHBOARD );