dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18190
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7573: Add formula to calculate ages based on report-date in Query Builder.
------------------------------------------------------------
revno: 7573
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-07-11 14:24:20 +0700
message:
Add formula to calculate ages based on report-date in Query Builder.
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-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.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/caseaggregation/CaseAggregationCondition.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2012-07-11 07:24:20 +0000
@@ -68,6 +68,8 @@
public static String OBJECT_PROGRAM_STAGE = "PS";
public static String OBJECT_PROGRAM_STAGE_PROPERTY = "PSP";
+
+ public static String OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY = "PC";
// -------------------------------------------------------------------------
// Fields
=== 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 2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2012-07-11 07:24:20 +0000
@@ -36,6 +36,7 @@
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_PROPERTY;
+import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OPERATOR_AND;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID;
import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT;
@@ -79,9 +80,10 @@
implements CaseAggregationConditionService
{
private final String regExp = "\\[(" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE + "|"
- + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|"
- + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+["
- + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
+ + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY + "|"
+ + 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";
@@ -665,6 +667,10 @@
{
condition = getConditionForProgramStageProperty( info[1], operator, orgunitId, startDate, endDate );
}
+ else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY ) )
+ {
+ condition = getConditionForPatientProgramStageProperty( info[1], operator, startDate, endDate );
+ }
// -------------------------------------------------------------
// Replacing the operand with 1 in order to later be able to
@@ -838,6 +844,23 @@
return sql;
}
+ private String getConditionForPatientProgramStageProperty( String propertyName, String operator, String startDate,
+ String endDate )
+ {
+ String sql = "SELECT distinct(pi.patientid) ";
+
+ if ( operator.equals( AGGRERATION_SUM ) )
+ {
+ sql = "SELECT pi.patientid ";
+ }
+
+ sql += "FROM patient as pi INNER JOIN programinstance pgi ON pi.patientid = pgi.patientid "
+ + "INNER JOIN programstageinstance psi ON psi.programinstanceid = pgi.programinstanceid WHERE "
+ + propertyName;
+
+ return sql;
+ }
+
private String getConditionForProgramProperty( String operator, String startDate, String endDate, String property )
{
String sql = "SELECT distinct(pi.patientid) ";
@@ -897,7 +920,8 @@
return select + "FROM programinstance as pi INNER JOIN programstageinstance psi "
+ "ON pi.programinstanceid = psi.programinstanceid WHERE " + " psi.executiondate >= '" + startDate
- + "' AND psi.executiondate <= '" + endDate + "' AND psi.organisationunitid = " + orgunitId + " AND " + property;
+ + "' AND psi.executiondate <= '" + endDate + "' AND psi.organisationunitid = " + orgunitId + " AND "
+ + property;
}
private String getSQL( String aggregateOperator, List<String> conditions, List<String> operators )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm 2012-07-06 15:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm 2012-07-11 07:24:20 +0000
@@ -55,7 +55,7 @@
</td>
<td>
<select id="programId" name="programId" onChange="getParams();">
- <option value="0">[$i18n.getString('please_select')]</option>
+ <option value="">[$i18n.getString('please_select')]</option>
#foreach( $program in $programs )
<option value="$program.id" title='$program.name' type='$program.type'>$encoder.htmlEncode( $program.name )</option>
#end
@@ -121,7 +121,7 @@
</tr>
<tr>
<td>
- <select id="caseProperty" name="caseProperty" size="10" ondblclick="insertInfo(this, false);" onclick="getSuggestedValues(this.id, 'caSuggestedValues' )"></select>
+ <select id="caseProperty" name="caseProperty" size="10" ondblclick="insertInfo(this, false);" onclick="getSuggestedValues(this.id, 'caSuggestedValues' )" ></select>
</td>
<td>
<select multiple size="10" id='caSuggestedValues' ondblclick="insertSingleValue('caSuggestedValues');"></select>
@@ -138,15 +138,16 @@
</tr>
<tr>
<td>
- <select id="programProperty" name="programProperty" size="10" ondblclick="insertInfo(this, false);" >
+ <select id="programProperty" name="programProperty" size="10" ondblclick="insertInfo(this, false);" disabled >
<option value="[PG:*]">$i18n.getString( "program_enrollment" )</option>
<option value="[PG:*] AND [PP:DATE@enrollmentdate#-DATE@dateofincident#]">$i18n.getString( "date_of_enrollment" ) - $i18n.getString( "date_of_incident" )</option>
</select>
</td>
<td>
- <select multiple id="programStageProperty" size="10" name="programStageProperty" ondblclick="insertInfo(this, true);">
+ <select multiple id="programStageProperty" size="10" name="programStageProperty" ondblclick="insertInfo(this, true);" disabled>
<option value="[PS:*]">$i18n.getString( "visit_program_stage" )</option>
<option value="[PS:*] AND [PSP:DATE@executionDate#-DATE@dueDate#]">$i18n.getString( "report_date" ) - $i18n.getString( "due_date" )</option>
+ <option value="[PS:*] AND [PC:DATE@executionDate#-DATE@birthDate#]">$i18n.getString( "report_date" ) - $i18n.getString( "birthDate" )</option>
</select>
</select>
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2012-07-06 15:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2012-07-11 07:24:20 +0000
@@ -98,10 +98,17 @@
{
clearListById( 'programStageId' );
clearListById( 'dataElements' );
+ clearListById('caseProperty');
+ var programId = getFieldValue( 'programId' );
+ if( programId == ''){
+ disable('programProperty');
+ disable('programStageProperty');
+ }
- jQuery.getJSON( 'getParamsByProgram.action',{ programId:getFieldValue( 'programId' ) }
+ jQuery.getJSON( 'getParamsByProgram.action',{ programId:programId }
,function( json )
{
+ enable('programProperty');
var programstage = jQuery('#programStageId');
for ( i in json.programStages )
@@ -113,12 +120,12 @@
programstage.append( "<option value='" + id + "' title='" + name + "'>" + name + "</option>" );
}
- if( json.programStages.length > 0 )
+ if( json.programStages.length > 1 )
{
programstage.prepend( "<option value='' title='" + i18n_all + "'>" + i18n_all + "</option>" );
- byId('programStageId').options[0].selected = true;
- getPatientDataElements();
- }
+ }
+ byId('programStageId').options[0].selected = true;
+ getPatientDataElements();
clearListById( 'caseProperty' );
var type = jQuery('#programId option:selected').attr('type');
@@ -152,14 +159,21 @@
function getPatientDataElements()
{
clearListById( 'dataElements' );
- var programStage = document.getElementById( 'programStage' );
+ var programStageId = getFieldValue('programStageId');
+
jQuery.getJSON( 'getPatientDataElements.action',
{
programId:getFieldValue( 'programId' ),
- progamStageId: getFieldValue('progamStageId')
+ programStageId:programStageId
}
,function( json )
{
+ if( programStageId!='' ){
+ enable('programStageProperty');
+ }
+ else{
+ disable('programStageProperty');
+ }
var dataElements = jQuery('#dataElements');
for ( i in json.dataElements )
{
@@ -175,11 +189,11 @@
function insertDataElement( element )
{
var progamId = getFieldValue('programId');
- var progamStageId = getFieldValue('programStageId');
- progamStageId = ( progamStageId == "" ) ? "*" : progamStageId;
+ var programStageId = getFieldValue('programStageId');
+ programStageId = ( programStageId == "" ) ? "*" : programStageId;
var dataElementId = element.options[element.selectedIndex].value;
- insertTextCommon( 'aggregationCondition', "[DE:" + progamId + "." + progamStageId + "." + dataElementId + "]" );
+ insertTextCommon( 'aggregationCondition', "[DE:" + progamId + "." + programStageId + "." + dataElementId + "]" );
getConditionDescription();
}
@@ -188,12 +202,12 @@
var id = "";
if( isProgramStageProperty )
{
+ id = getFieldValue('programStageId');
+ }
+ else
+ {
id = getFieldValue('programId');
}
- else
- {
- id = getFieldValue('programStageId');
- }
value = element.options[element.selectedIndex].value.replace( '*', id );
insertTextCommon('aggregationCondition', value );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css 2012-06-05 06:46:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css 2012-07-11 07:24:20 +0000
@@ -89,4 +89,10 @@
fieldset
{
border: 1px solid #3f5d8e;
+}
+
+.ui-autocomplete {
+ max-height: 100px;
+ overflow-y: auto;
+ overflow-x: hidden;
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm 2012-07-06 15:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm 2012-07-11 07:24:20 +0000
@@ -52,7 +52,7 @@
</td>
<td>
<select id="programId" name="programId" onChange="getParams();">
- <option value="0">[$i18n.getString('please_select')]</option>
+ <option value="">[$i18n.getString('please_select')]</option>
#foreach( $program in $programs )
<option value="$program.id" title='$program.name'>$encoder.htmlEncode( $program.name )</option>
#end
@@ -135,15 +135,16 @@
</tr>
<tr>
<td>
- <select id="programProperty" name="programProperty" size="10" ondblclick="insertInfo(this, false);" >
+ <select id="programProperty" name="programProperty" size="10" ondblclick="insertInfo(this, false);" disabled>
<option value="[PG:*]">$i18n.getString( "program_enrollment" )</option>
<option value="[PG:*] AND [PP:DATE@enrollmentdate#-DATE@dateofincident#]">$i18n.getString( "date_of_enrollment" ) - $i18n.getString( "date_of_incident" )</option>
</select>
</td>
<td>
- <select multiple id="programStageProperty" size="10" name="programStageProperty" ondblclick="insertInfo(this, true);">
+ <select multiple id="programStageProperty" size="10" name="programStageProperty" ondblclick="insertInfo(this, true);" disabled >
<option value="[PS:*]">$i18n.getString( "visit_program_stage" )</option>
<option value="[PS:*] AND [PSP:DATE@executionDate#-DATE@dueDate#]">$i18n.getString( "report_date" ) - $i18n.getString( "due_date" )</option>
+ <option value="[PS:*] AND [PC:DATE@executionDate#-DATE@birthDate#]">$i18n.getString( "report_date" ) - $i18n.getString( "date_of_birth" )</option>
</select>
</select>
</td>