dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13101
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4147: An Exception is thrown when show aggregation-result details ( Patient module ).
------------------------------------------------------------
revno: 4147
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-07-15 10:35:57 +0700
message:
An Exception is thrown when show aggregation-result details ( Patient module ).
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueService.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/CaseAggregationResultAction.java
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/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResultDetails.vm
--
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/patientdatavalue/PatientDataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueService.java 2011-07-08 05:52:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueService.java 2011-07-15 03:35:57 +0000
@@ -97,7 +97,7 @@
Collection<PatientDataValue> getPatientDataValues( DataElement dataElement, boolean providedByAnotherFacility );
Collection<PatientDataValue> getPatientDataValues( Patient patient, Collection<DataElement> dataElements,
- Date date, java.util.Date date2 );
+ Date startDate, Date endDate );
Collection<PatientDataValue> getAllPatientDataValues();
}
=== 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-07-14 09:31:24 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2011-07-15 03:35:57 +0000
@@ -70,9 +70,9 @@
public class DefaultCaseAggregationConditionService
implements CaseAggregationConditionService
{
- private final String regExp = "\\[(" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|"
- + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
- + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
+ private final String regExp = "\\[(" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|"
+ + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")"
+ + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+[" + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
private final String IS_NULL = "is null";
@@ -196,18 +196,20 @@
Collection<DataElement> dataElements = getDataElementsInCondition( aggregationCondition
.getAggregationExpression() );
- Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sql );
-
- for ( Integer patientId : patientIds )
+ if ( dataElements.size() > 0 )
{
- Patient patient = patientService.getPatient( patientId );
-
- Collection<PatientDataValue> dataValues = dataValueService.getPatientDataValues( patient, dataElements,
- period.getStartDate(), period.getEndDate() );
-
- result.addAll( dataValues );
+ Collection<Integer> patientIds = aggregationConditionStore.executeSQL( sql );
+
+ for ( Integer patientId : patientIds )
+ {
+ Patient patient = patientService.getPatient( patientId );
+
+ Collection<PatientDataValue> dataValues = dataValueService.getPatientDataValues( patient, dataElements,
+ period.getStartDate(), period.getEndDate() );
+
+ result.addAll( dataValues );
+ }
}
-
return result;
}
@@ -258,16 +260,17 @@
DataElement dataElement = dataElementService.getDataElement( dataElementId );
int categoryOptionId = Integer.parseInt( ids[2] );
- DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( categoryOptionId );
+ DataElementCategoryOptionCombo optionCombo = categoryService
+ .getDataElementCategoryOptionCombo( categoryOptionId );
- if( programStage == null || dataElement == null || optionCombo == null )
+ if ( programStage == null || dataElement == null || optionCombo == null )
{
return "Invalid condition";
-
+
}
-
+
matcher.appendReplacement( decription, "[" + programStage.getName() + SEPARATOR_ID + dataElement.getName()
- + optionCombo.getName() + "]" );
+ + optionCombo.getName() + "]" );
}
matcher.appendTail( decription );
@@ -332,7 +335,8 @@
String[] ids = info[1].split( SEPARATOR_ID );
int optionComboId = Integer.parseInt( ids[2] );
- DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
+ DataElementCategoryOptionCombo optionCombo = categoryService
+ .getDataElementCategoryOptionCombo( optionComboId );
optionCombos.add( optionCombo );
}
@@ -443,7 +447,7 @@
{
condition = getConditionForProgram( info[1], orgunitId, startDate, endDate );
}
-
+
// -------------------------------------------------------------
// Replacing the operand with 1 in order to later be able to
// verify
@@ -492,17 +496,32 @@
+ "INNER JOIN programstage as ps ON psi.programstageid = ps.programstageid "
+ "INNER JOIN programinstance as pi ON pi.programinstanceid = psi.programinstanceid "
+ "LEFT OUTER JOIN patientdatavalue as pd ON psi.programstageinstanceid = pd.programstageinstanceid "
- + "WHERE psi.executionDate >= '" + startDate
- + "' AND psi.executionDate <= '" + endDate + "' "
+ + "WHERE psi.executionDate >= '"
+ + startDate
+ + "' AND psi.executionDate <= '"
+ + endDate
+ + "' "
+ "AND pd.value IS NULL AND pi.patientid NOT IN ( "
+ "SELECT distinct(pi.patientid) FROM programstageinstance as psi "
+ "INNER JOIN programstage as ps ON psi.programstageid = ps.programstageid "
+ "INNER JOIN programinstance as pi ON pi.programinstanceid = psi.programinstanceid "
+ "INNER JOIN patientdatavalue as pd ON psi.programstageinstanceid = pd.programstageinstanceid "
- + "WHERE pd.organisationunitid = " + orgunitId + " AND ps.programstageid = " + programStageId + " "
- + "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' "
- + "AND pd.dataelementid = " + dataElementId + " "
- + "AND pd.categoryoptioncomboid = " + optionComboId + " ) ";
+ + "WHERE pd.organisationunitid = "
+ + orgunitId
+ + " AND ps.programstageid = "
+ + programStageId
+ + " "
+ + "AND psi.executionDate >= '"
+ + startDate
+ + "' AND psi.executionDate <= '"
+ + endDate
+ + "' "
+ + "AND pd.dataelementid = "
+ + dataElementId
+ + " "
+ + "AND pd.categoryoptioncomboid = "
+ + optionComboId
+ + " ) ";
}
private String getConditionForDataElement( int programStageId, int dataElementId, int optionComboId, int orgunitId,
@@ -548,14 +567,13 @@
+ "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' AND ";
}
- private String getConditionForProgram ( String programId, int orgunitId, String startDate, String endDate )
+ private String getConditionForProgram( String programId, int orgunitId, String startDate, String endDate )
{
return "SELECT distinct(p.patientid) FROM programstageinstance as psi "
- + "INNER JOIN programinstance as pi ON psi.programinstanceid = pi.programinstanceid "
- + "INNER JOIN patient as p ON p.patientid = pi.patientid "
- + "WHERE pi.programid=" + programId + " "
- + "AND p.organisationunitid = " + orgunitId + " "
- + "AND pi.enrollmentdate >= '" + startDate + "' AND pi.enrollmentdate <= '" + endDate + "' ";
+ + "INNER JOIN programinstance as pi ON psi.programinstanceid = pi.programinstanceid "
+ + "INNER JOIN patient as p ON p.patientid = pi.patientid " + "WHERE pi.programid=" + programId + " "
+ + "AND p.organisationunitid = " + orgunitId + " " + "AND pi.enrollmentdate >= '" + startDate
+ + "' AND pi.enrollmentdate <= '" + endDate + "' ";
}
private String getSQL( List<String> conditions, List<String> operators )
@@ -580,7 +598,7 @@
sqlAnd = "";
}
}
-
+
sql += sqlAnd;
return sql;
=== 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-07-13 02:28:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2011-07-15 03:35:57 +0000
@@ -232,7 +232,6 @@
if ( condition != null )
{
-
for ( Period period : periodList )
{
String message = i18n.getString( "in" ) + " " + format.formatPeriod( period );
=== 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 2011-05-01 09:07:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultDetailsAction.java 2011-07-15 03:35:57 +0000
@@ -29,6 +29,7 @@
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
@@ -143,12 +144,17 @@
Collection<DataElement> dataElements = aggregationConditionService.getDataElementsInCondition( aggCondition
.getAggregationExpression() );
- Collection<PatientDataValue> dataValues = patientDataValueService.getPatientDataValues( patient,
- dataElements, period.getStartDate(), period.getEndDate() );
+ 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;
}
}
=== 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-06-23 14:44:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2011-07-15 03:35:57 +0000
@@ -208,7 +208,7 @@
<action name="caseAggregationResult" class="org.hisp.dhis.caseentry.action.caseaggregation.CaseAggregationResultAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-caseentry/caseAggregationResult.vm</param>
- <param name="menu">/dhis-web-caseentry/menu.vm</param>
+ <param name="menu">/dhis-web-caseentry/caseAggregationMenu.vm</param>
<param name="javascripts">javascript/caseagg.js,javascript/date.js,javascript/caseAggregationForm.js</param>
</action>
=== 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-03-24 03:34:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResultDetails.vm 2011-07-15 03:35:57 +0000
@@ -1,33 +1,42 @@
<table class='mainPageTable listTable'>
- <thead>
- <th>$i18n.getString('full_name')</th>
- <th>$i18n.getString('program_stage')</th>
- <th>$i18n.getString('data_element')</th>
- <th>$i18n.getString('value')</th>
- </thead>
<tbody>
+ #set($hasDataValue = true )
#foreach( $patient in $mapPatients.keySet())
- <tr id="tr${patientDataValue.dataElement.id}" style='background-color: #cccccc'>
- <td>$patient.getFullName()</td>
- <td></td>
- <td></td>
- <td></td>
+ #if( $hasDataValue == true)
+ <tr height='5em'>
+ <th>$i18n.getString( "full_name" )</th>
+ <th>$i18n.getString( "age" )</th>
+ <th>$i18n.getString( "gender" )</th>
+ </tr>
+ #end
+ <tr>
+ <td>$!patient.getFullName()</td>
+ <td>$!patient.getAge()</td>
+ <td>$!patient.gender</td>
</tr>
#set($dataValues = $mapPatients.get($patient) )
- #if( $!dataValues )
+ #if ( $!dataValues.size() == 0 )
+ #set($hasDataValue = false )
+ <tr>
+ <td colspan='3'></td>
+ </tr>
+ #else
+ #set($hasDataValue = true )
+ <tr style='background-color: #cccccc'>
+ <td>$i18n.getString('program_stage')</td>
+ <td>$i18n.getString('data_element')</td>
+ <td>$i18n.getString('value')</td>
+ </tr>
+ #set( $mark = false )
#foreach( $dataValue in $dataValues )
- <tr>
- <td></td>
+ <tr #alternate( $mark )>
<td>$dataValue.programStageInstance.programStage.name</td>
<td>$dataValue.dataElement.name</td>
<td>$dataValue.value</td>
</tr>
+ #set( $mark = !$mark)
#end
- #else
- <tr>
- <td colspan='4'></td>
- </tr>
#end
#end
</tbody>