=== 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-02-08 12:43:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2012-06-04 04:06:04 +0000 @@ -27,6 +27,7 @@ package org.hisp.dhis.caseaggregation; +import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; @@ -36,48 +37,46 @@ * @version CaseAggregationCondition.java Nov 17, 2010 10:47:12 AM */ public class CaseAggregationCondition + extends BaseIdentifiableObject { + private static final long serialVersionUID = -5746649805915250424L; + public static final String SEPARATOR_ID = "\\."; public static final String SEPARATOR_OBJECT = ":"; - public static final String AGGRERATION_COUNT = "COUNT"; public static final String AGGRERATION_SUM = "SUM"; - - + public static final String OPERATOR_AND = "AND"; public static final String OPERATOR_OR = "OR"; - public static String OBJECT_PROGRAM_STAGE_DATAELEMENT = "DE"; public static String OBJECT_PATIENT_ATTRIBUTE = "CA"; public static String OBJECT_PATIENT_PROPERTY = "CP"; - + public static String OBJECT_PROGRAM_PROPERTY = "PP"; - + 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"; // ------------------------------------------------------------------------- // Fields // ------------------------------------------------------------------------- - private Integer id; - private String operator; private String aggregationExpression; - private String description; - private DataElement aggregationDataElement; private DataElementCategoryOptionCombo optionCombo; @@ -91,10 +90,10 @@ } - public CaseAggregationCondition( String description, String operator, String aggregationExpression, + public CaseAggregationCondition( String name, String operator, String aggregationExpression, DataElement aggregationDataElement, DataElementCategoryOptionCombo optionCombo ) { - this.description = description; + this.name = name; this.operator = operator; this.aggregationExpression = aggregationExpression; this.aggregationDataElement = aggregationDataElement; @@ -146,11 +145,6 @@ // Getters && Setters // ------------------------------------------------------------------------- - public Integer getId() - { - return id; - } - public DataElement getAggregationDataElement() { return aggregationDataElement; @@ -195,15 +189,4 @@ { this.aggregationExpression = aggregationExpression; } - - public String getDescription() - { - return description; - } - - public void setDescription( String description ) - { - this.description = description; - } - } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionDeletionHandler.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionDeletionHandler.java 2012-02-11 13:58:02 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionDeletionHandler.java 2012-06-04 04:06:04 +0000 @@ -121,7 +121,7 @@ if ( programs != null && programs.contains( program ) ) { - return condition.getDescription(); + return condition.getName(); } } @@ -142,7 +142,7 @@ if ( patientAttributes != null && patientAttributes.contains( patientAttribute ) ) { - return condition.getDescription(); + return condition.getName(); } } === 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-03-21 09:19:26 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2012-06-04 04:06:04 +0000 @@ -35,6 +35,7 @@ import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY; 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.OPERATOR_AND; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT; @@ -78,8 +79,9 @@ implements CaseAggregationConditionService { private final String regExp = "\\[(" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE + "|" - + 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_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"; @@ -87,7 +89,9 @@ private final String INVALID_CONDITION = "Invalid condition"; - private final String NUMBER_PATIENTS_REGISTERED = "Registered Beneficiaries No"; + private final String TOTAL_OF_PATIENTS_REGISTERED = "Total of patient registration"; + + private final String IN_CONDITION_GET_ALL = "*"; private final String IN_CONDITION_START_SIGN = "@"; @@ -210,7 +214,7 @@ Period period ) { String sql = convertCondition( aggregationCondition, orgunit, period ); - + System.out.println( "\n === \n sql : " + sql ); Collection patientIds = aggregationConditionStore.executeSQL( sql ); if ( patientIds == null ) @@ -261,19 +265,16 @@ { Collection result = new HashSet(); - // get params - int orgunitId = orgunit.getId(); - String startDate = DateUtils.getMediumDateString( period.getStartDate() ); - String endDate = DateUtils.getMediumDateString( period.getEndDate() ); - - String sql = createSQL( aggregationCondition.getAggregationExpression(), aggregationCondition.getOperator(), - orgunitId, startDate, endDate ); + String sql = convertCondition( aggregationCondition, orgunit, period ); Collection patientIds = aggregationConditionStore.executeSQL( sql ); - for ( Integer patientId : patientIds ) + if ( patientIds != null ) { - result.add( patientService.getPatient( patientId ) ); + for ( Integer patientId : patientIds ) + { + result.add( patientService.getPatient( patientId ) ); + } } return result; @@ -322,19 +323,24 @@ { String[] ids = info[1].split( SEPARATOR_ID ); - int programStageId = Integer.parseInt( ids[0] ); - ProgramStage programStage = programStageService.getProgramStage( programStageId ); + int programId = Integer.parseInt( ids[0] ); + Program program = programService.getProgram( programId ); - int dataElementId = Integer.parseInt( ids[1] ); + String programStage = ids[1]; + if ( !programStage.equals( IN_CONDITION_GET_ALL ) ) + { + programStage = programStageService.getProgramStage( Integer.parseInt( programStage ) ).getName(); + } + int dataElementId = Integer.parseInt( ids[2] ); DataElement dataElement = dataElementService.getDataElement( dataElementId ); - if ( programStage == null || dataElement == null ) + if ( program == null || dataElement == null ) { return INVALID_CONDITION; } - matcher.appendReplacement( description, "[" + programStage.getName() + SEPARATOR_ID - + dataElement.getName() + "]" ); + matcher.appendReplacement( description, "[" + program.getName() + SEPARATOR_ID + programStage + + SEPARATOR_ID + dataElement.getName() + "]" ); } else { @@ -343,7 +349,7 @@ if ( info[0].equalsIgnoreCase( OBJECT_PATIENT ) ) { matcher.appendReplacement( description, "[" + OBJECT_PATIENT + SEPARATOR_OBJECT - + NUMBER_PATIENTS_REGISTERED + "]" ); + + TOTAL_OF_PATIENTS_REGISTERED + "]" ); } else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) ) { @@ -399,7 +405,7 @@ public Collection getDataElementsInCondition( String aggregationExpression ) { String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "[0-9]+" + SEPARATOR_ID - + "[0-9]+" + "\\]"; + + "[0-9]+" + SEPARATOR_ID + "[0-9]+" + "\\]"; Collection dataElements = new HashSet(); @@ -419,7 +425,7 @@ String[] info = match.split( SEPARATOR_OBJECT ); String[] ids = info[1].split( SEPARATOR_ID ); - int dataElementId = Integer.parseInt( ids[1] ); + int dataElementId = Integer.parseInt( ids[2] ); DataElement dataElement = dataElementService.getDataElement( dataElementId ); dataElements.add( dataElement ); @@ -430,7 +436,8 @@ public Collection getProgramsInCondition( String aggregationExpression ) { - String regExp = "\\[" + OBJECT_PROGRAM + SEPARATOR_OBJECT + "[0-9]+\\]"; + String regExp = "\\[(" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + ")" + SEPARATOR_OBJECT + + "[a-zA-Z0-9\\- ]+"; Collection programs = new HashSet(); @@ -448,9 +455,9 @@ match = match.replaceAll( "[\\[\\]]", "" ); String[] info = match.split( SEPARATOR_OBJECT ); - - int programId = Integer.parseInt( info[1] ); - + String[] ids = info[1].split( SEPARATOR_ID ); + + int programId = Integer.parseInt( ids[0] ); Program program = programService.getProgram( programId ); programs.add( program ); @@ -609,22 +616,23 @@ { String[] ids = info[1].split( SEPARATOR_ID ); - int programStageId = Integer.parseInt( ids[0] ); - int dataElementId = Integer.parseInt( ids[1] ); + int programId = Integer.parseInt( ids[0] ); + String programStageId = ids[1]; + int dataElementId = Integer.parseInt( ids[2] ); String valueToCompare = expression[i].replace( "[" + match + "]", "" ).trim(); if ( valueToCompare.equalsIgnoreCase( IS_NULL ) ) { - condition = getConditionForNotDataElement( programStageId, operator, dataElementId, orgunitId, - startDate, endDate ); + condition = getConditionForNotDataElement( programId, programStageId, operator, dataElementId, + orgunitId, startDate, endDate ); expression[i] = expression[i].replace( valueToCompare, "" ); } else { - condition = getConditionForDataElement( programStageId, operator, dataElementId, orgunitId, - startDate, endDate ); + condition = getConditionForDataElement( programId, programStageId, operator, dataElementId, + orgunitId, startDate, endDate ); if ( !expression[i].contains( "+" ) ) { condition += " AND pd.value "; @@ -638,16 +646,25 @@ else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_PROPERTY ) ) { - condition = getConditionForProgramProperty( operator, startDate, endDate ) + info[1]; + condition = getConditionForProgramProperty( operator, startDate, endDate, info[1] ); } else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM ) ) { - condition = getConditionForProgram( info[1], operator, orgunitId, startDate, endDate ); + String[] ids = info[1].split( SEPARATOR_ID ); + condition = getConditionForProgram( ids[0], operator, orgunitId, startDate, endDate ); + if ( ids.length > 1 ) + { + condition += ids[1]; + } } else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_STAGE ) ) { condition = getConditionForProgramStage( info[1], operator, orgunitId, startDate, endDate ); } + else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_STAGE_PROPERTY ) ) + { + condition = getConditionForProgramStageProperty( info[1], operator, orgunitId, startDate, endDate ); + } // ------------------------------------------------------------- // Replacing the operand with 1 in order to later be able to @@ -690,8 +707,8 @@ return getSQL( operator, conditions, operators ); } - private String getConditionForNotDataElement( int programStageId, String operator, int dataElementId, - int orgunitId, String startDate, String endDate ) + private String getConditionForNotDataElement( int programId, String programStageId, String operator, + int dataElementId, int orgunitId, String startDate, String endDate ) { String sql = "SELECT distinct(pi.patientid) "; String condition = "pi.patientid"; @@ -722,21 +739,25 @@ + "INNER JOIN patientdatavalue as pd ON psi.programstageinstanceid = pd.programstageinstanceid " + "WHERE psi.organisationunitid = " + orgunitId - + " AND ps.programstageid = " - + programStageId - + " " + + " AND pgi.programid = " + + programId + "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' " - + "AND pd.dataelementid = " + dataElementId + " " + " ) "; - - return sql; + + "AND pd.dataelementid = " + dataElementId + " "; + + if ( !programStageId.equals( IN_CONDITION_GET_ALL ) ) + { + sql += " AND ps.programstageid = " + programStageId; + } + + return sql + " ) "; } - private String getConditionForDataElement( int programStageId, String operator, int dataElementId, int orgunitId, - String startDate, String endDate ) + private String getConditionForDataElement( int programId, String programStageId, String operator, + int dataElementId, int orgunitId, String startDate, String endDate ) { String sql = "SELECT distinct(pi.patientid) "; @@ -745,14 +766,20 @@ sql = "SELECT psi.programstageinstanceid "; } - return sql + "FROM programstageinstance as psi " + sql += "FROM programstageinstance as psi " + "INNER JOIN programstage as ps ON psi.programstageid = ps.programstageid " + "INNER JOIN patientdatavalue as pd ON psi.programstageinstanceid = pd.programstageinstanceid " + "INNER JOIN programstage_dataelements as psd ON ps.programstageid = psd.programstageid " + "INNER JOIN programinstance as pi ON pi.programinstanceid = psi.programinstanceid " - + "WHERE psd.dataelementid = " + dataElementId + " " + "AND psi.organisationunitid = " + orgunitId - + " AND ps.programstageid = " + programStageId + " " + "AND psi.executionDate >= '" + startDate - + "' AND psi.executionDate <= '" + endDate + "' "; + + "WHERE psd.dataelementid = " + dataElementId + " " + "AND psi.organisationunitid = " + orgunitId + " " + + "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' "; + + if ( !programStageId.equals( IN_CONDITION_GET_ALL ) ) + { + sql += " AND ps.programstageid = " + programStageId; + } + + return sql; } private String getConditionForPatientAttribute( int attributeId, String operator ) @@ -764,7 +791,7 @@ sql = "SELECT pi.patientid "; } - return sql + "FROM patient as pi " + "INNER JOIN patientattributevalue as pav ON pav.patientid = pi.patientid " + return sql + "FROM patient as pi INNER JOIN patientattributevalue as pav ON pav.patientid = pi.patientid " + "WHERE pav.patientattributeid = " + attributeId + " " + "AND pav.value "; } @@ -801,8 +828,7 @@ if ( propertyName.equals( PROPERTY_AGE ) ) { - sql += "(( 12 * ( EXTRACT(YEAR FROM DATE '" + startDate + "' ) - EXTRACT(YEAR FROM birthdate ) ) ) + " - + "EXTRACT( MONTH FROM DATE '" + startDate + "' ) - EXTRACT( MONTH FROM birthdate ) )" + " "; + sql += "DATE('" + startDate + "') - DATE(birthdate) "; } else { @@ -812,7 +838,7 @@ return sql; } - private String getConditionForProgramProperty( String operator, String startDate, String endDate ) + private String getConditionForProgramProperty( String operator, String startDate, String endDate, String property ) { String sql = "SELECT distinct(pi.patientid) "; @@ -823,7 +849,8 @@ return sql + "FROM programstageinstance as psi " + "INNER JOIN programinstance as pi ON psi.programinstanceid = pi.programinstanceid " - + "WHERE psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' AND "; + + "WHERE psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' AND " + + property; } private String getConditionForProgram( String programId, String operator, int orgunitId, String startDate, @@ -858,6 +885,21 @@ + "' AND psi.organisationunitid = " + orgunitId + " "; } + private String getConditionForProgramStageProperty( String property, String operator, int orgunitId, + String startDate, String endDate ) + { + String select = "SELECT distinct(pi.patientid) "; + + if ( operator.equals( AGGRERATION_SUM ) ) + { + select = "SELECT psi.programstageinstanceid "; + } + + 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; + } + private String getSQL( String aggregateOperator, List conditions, List operators ) { String sql = conditions.get( 0 ); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2012-05-30 03:30:10 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2012-06-04 04:06:04 +0000 @@ -27,8 +27,13 @@ package org.hisp.dhis.patient.startup; +import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT; +import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID; +import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT; + import java.sql.ResultSet; import java.sql.Statement; +import java.util.regex.Matcher; import java.util.regex.Pattern; import org.amplecode.quick.StatementHolder; @@ -88,7 +93,7 @@ executeSql( "ALTER TABLE program DROP COLUMN singleevent" ); executeSql( "ALTER TABLE program DROP COLUMN anonymous" ); executeSql( "UPDATE program SET type=1 where type is null" ); - + executeSql( "UPDATE programstage set irregular=false where irregular is null" ); executeSql( "DROP TABLE programattributevalue" ); @@ -98,9 +103,13 @@ executeSql( "ALTER TABLE patientattribute DROP COLUMN noChars" ); executeSql( "ALTER TABLE programstageinstance ALTER executiondate TYPE date" ); - + executeSql( "ALTER TABLE patientidentifier ALTER COLUMN patientid DROP NOT NULL" ); executeSql( "ALTER TABLE patient DROP COLUMN bloodgroup" ); + executeSql( "ALTER TABLE patientmobilesetting DROP COLUMN bloodGroup" ); + + executeSql( "ALTER TABLE caseaggregationcondition RENAME description TO name" ); + updateCaseAggregationCondition(); } // ------------------------------------------------------------------------- @@ -139,6 +148,70 @@ } } + private void updateCaseAggregationCondition() + { + String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "[0-9]+" + SEPARATOR_ID + + "[0-9]+" + "\\]"; + + try + { + StatementHolder holder = statementManager.getHolder(); + + Statement statement = holder.getStatement(); + + ResultSet resultSet = statement + .executeQuery( "SELECT caseaggregationconditionid, aggregationExpression FROM caseaggregationcondition" ); + + while ( resultSet.next() ) + { + StringBuffer formular = new StringBuffer(); + + // --------------------------------------------------------------------- + // parse expressions + // --------------------------------------------------------------------- + + Pattern pattern = Pattern.compile( regExp ); + + Matcher matcher = pattern.matcher( resultSet.getString( 2 ) ); + + while ( matcher.find() ) + { + String match = matcher.group(); + match = match.replaceAll( "[\\[\\]]", "" ); + + String[] info = match.split( SEPARATOR_OBJECT ); + String[] ids = info[1].split( SEPARATOR_ID ); + int programStageId = Integer.parseInt( ids[0] ); + + StatementHolder _holder = statementManager.getHolder(); + Statement _statement = _holder.getStatement(); + ResultSet rsProgramId = _statement + .executeQuery( "SELECT programid FROM programstage where programstageid=" + programStageId ); + + if ( rsProgramId.next() ) + { + int programId = rsProgramId.getInt( 1 ); + + String aggregationExpression = "[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + + programId + "." + programStageId + "." + ids[1] + "]"; + + matcher.appendReplacement( formular, aggregationExpression ); + } + } + + matcher.appendTail( formular ); + + executeSql( "UPDATE caseaggregationcondition SET aggregationExpression='" + formular.toString() + + "' WHERE caseaggregationconditionid=" + resultSet.getInt( 1 ) ); + + } + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + private int executeSql( String sql ) { try === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/caseaggregation/hibernate/CaseAggregationCondition.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/caseaggregation/hibernate/CaseAggregationCondition.hbm.xml 2011-05-28 21:25:46 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/caseaggregation/hibernate/CaseAggregationCondition.hbm.xml 2012-06-04 04:06:04 +0000 @@ -1,7 +1,9 @@ + "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" + [] +> @@ -9,13 +11,13 @@ + + &identifiableProperties; - - === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm 2011-09-28 07:11:18 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm 2012-06-04 04:06:04 +0000 @@ -1,7 +1,7 @@ { "caseAggregation": { "id": "${caseAggregation.id}", - "description": "$!encoder.jsonEncode( ${caseAggregation.description} )", + "name": "$!encoder.jsonEncode( ${caseAggregation.name} )", "operator": "${caseAggregation.operator}", "aggregationDataElement": "$!encoder.jsonEncode( ${caseAggregation.aggregationDataElement.name} )", "optionCombo": "$!encoder.jsonEncode( ${caseAggregation.optionCombo.name} )", === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/AddCaseAggregationConditionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/AddCaseAggregationConditionAction.java 2012-01-11 05:31:53 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/AddCaseAggregationConditionAction.java 2012-06-04 04:06:04 +0000 @@ -62,7 +62,7 @@ private String aggregationCondition; - private String description; + private String name; private String aggregationDataElementId; @@ -100,9 +100,9 @@ this.aggregationCondition = aggregationCondition; } - public void setDescription( String description ) + public void setName( String name ) { - this.description = description; + this.name = name; } // ------------------------------------------------------------------------- @@ -120,7 +120,7 @@ DataElementCategoryOptionCombo optionCombo = dataElementCategoryService .getDataElementCategoryOptionCombo( Integer.parseInt( ids[1] ) ); - CaseAggregationCondition condition = new CaseAggregationCondition( description, operator, aggregationCondition, + CaseAggregationCondition condition = new CaseAggregationCondition( name, operator, aggregationCondition, aggregationDataElement, optionCombo ); aggregationConditionService.addCaseAggregationCondition( condition ); === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetParamsByProgramAction.java 2012-06-04 04:06:04 +0000 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.patient.action.caseaggregation; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; + +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramStage; + +import com.opensymphony.xwork2.Action; + +/** + * @author Chau Thu Tran + * + * @version $Id: GetParamsByProgramAction.java Jun 02, 2012 02:24:49 PM $ + */ +public class GetParamsByProgramAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Dependency + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private PatientAttributeService attributeService; + + public void setAttributeService( PatientAttributeService attributeService ) + { + this.attributeService = attributeService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List programStages; + + public List getProgramStages() + { + return programStages; + } + + private Integer programId; + + public void setProgramId( Integer programId ) + { + this.programId = programId; + } + + private Collection patientAttributes = new HashSet(); + + public Collection getPatientAttributes() + { + return patientAttributes; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + public String execute() + { + Program program = programService.getProgram( programId ); + programStages = new ArrayList( program.getProgramStages() ); + + if ( program.isRegistration() ) + { + patientAttributes.addAll( attributeService.getPatientAttributes( null, null ) ); + patientAttributes.addAll( attributeService.getPatientAttributes( program ) ); + } + + return SUCCESS; + } +} === renamed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPSDataElementsAction.java' => 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPatientDataElementsAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPSDataElementsAction.java 2012-02-11 13:58:02 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetPatientDataElementsAction.java 2012-06-04 04:06:04 +0000 @@ -28,15 +28,25 @@ package org.hisp.dhis.patient.action.caseaggregation; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageDataElementService; import org.hisp.dhis.program.ProgramStageService; import com.opensymphony.xwork2.Action; -public class GetPSDataElementsAction +/** + * @author Chau Thu Tran + * + * @version $Id: GetPatientDataElementsAction.java Mar 09, 2011 01:24:49 PM $ + */ +public class GetPatientDataElementsAction implements Action { @@ -44,6 +54,13 @@ // Dependencies // ------------------------------------------------------------------------- + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + private ProgramStageService programStageService; public void setProgramStageService( ProgramStageService programStageService ) @@ -62,60 +79,51 @@ // Input & Output // ------------------------------------------------------------------------- - private List optionComboNames; - - public List getOptionComboNames() - { - return optionComboNames; - } - - private List optionComboIds; - - public List getOptionComboIds() - { - return optionComboIds; - } - - private List optionComboType; - - public List getOptionComboType() - { - return optionComboType; - } - - private Integer psId; - - public void setPsId( Integer psId ) - { - this.psId = psId; - } - - public Integer getPsId() - { - return psId; - } - - private List dataElementList; - - public List getDataElementList() - { - return dataElementList; + private Integer programId; + + public void setProgramId( Integer programId ) + { + this.programId = programId; + } + + private Integer programStageId; + + public void setProgramStageId( Integer programStageId ) + { + this.programStageId = programStageId; + } + + private List dataElements; + + public List getDataElements() + { + return dataElements; } // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- - + public String execute() { - optionComboNames = new ArrayList(); - - optionComboIds = new ArrayList(); - - optionComboType = new ArrayList(); - - dataElementList = new ArrayList( programStageDataElementService - .getListDataElement( programStageService.getProgramStage( psId ) ) ); + if ( programStageId == null ) + { + Program program = programService.getProgram( programId ); + + Set dataElementsInProgram = new HashSet(); + + for ( ProgramStage programStage : program.getProgramStages() ) + { + dataElementsInProgram.addAll( programStageDataElementService.getListDataElement( programStage ) ); + } + + dataElements = new ArrayList( dataElementsInProgram ); + } + else + { + dataElements = new ArrayList( programStageDataElementService + .getListDataElement( programStageService.getProgramStage( programStageId ) ) ); + } return SUCCESS; } === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetProgramStagesAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetProgramStagesAction.java 2012-01-11 05:31:53 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/GetProgramStagesAction.java 1970-01-01 00:00:00 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2004-2012, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.hisp.dhis.patient.action.caseaggregation; - -import java.util.ArrayList; -import java.util.List; - -import org.hisp.dhis.program.ProgramService; -import org.hisp.dhis.program.ProgramStage; - -import com.opensymphony.xwork2.Action; - -public class GetProgramStagesAction implements Action -{ - - // ------------------------------------------------------------------------- - // Dependency - // ------------------------------------------------------------------------- - - private ProgramService programService; - - public void setProgramService( ProgramService programService ) - { - this.programService = programService; - } - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private List programStages; - - public List getProgramStages() - { - return programStages; - } - - private Integer programId; - - public void setProgramId( Integer programId ) - { - this.programId = programId; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - public String execute() - { - programStages = new ArrayList( programService.getProgram( programId ).getProgramStages() ); - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/UpdateCaseAggregationConditionAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/UpdateCaseAggregationConditionAction.java 2012-01-11 05:31:53 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/UpdateCaseAggregationConditionAction.java 2012-06-04 04:06:04 +0000 @@ -64,7 +64,7 @@ private String aggregationCondition; - private String description; + private String name; private String aggregationDataElementId; @@ -96,7 +96,7 @@ { this.aggregationDataElementId = aggregationDataElementId; } - + public void setOperator( String operator ) { this.operator = operator; @@ -107,9 +107,9 @@ this.aggregationCondition = aggregationCondition; } - public void setDescription( String description ) + public void setName( String name ) { - this.description = description; + this.name = name; } // ------------------------------------------------------------------------- @@ -127,15 +127,15 @@ .getDataElementCategoryOptionCombo( Integer.parseInt( ids[1] ) ); CaseAggregationCondition expression = aggregationConditionService.getCaseAggregationCondition( id ); - + expression.setOperator( operator ); expression.setAggregationExpression( aggregationCondition ); - expression.setDescription( description ); + expression.setName( name ); expression.setAggregationDataElement( aggregationDataElement ); expression.setOptionCombo( optionCombo ); - + aggregationConditionService.updateCaseAggregationCondition( expression ); - + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2012-05-24 05:13:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2012-06-04 04:06:04 +0000 @@ -553,23 +553,21 @@ - + - - - + + - - - + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2012-05-30 07:22:33 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2012-06-04 04:06:04 +0000 @@ -20,7 +20,7 @@ create_new_relationship_type=Create new relationship type relationship_type_management=Relationship type management or=or -age_month=Age(months) +age_days=Age(days) value_must_integer=Value must be an integer program_stage=Program Stage close=Close @@ -70,8 +70,8 @@ beneficiary_aggregation_query_builder=Person Aggregation Query Builder beneficiary_aggregation_query_builder_management=Person aggregation query builder management dataelement_group=Data Element Group -dataelement=Data Element -case_attributes=Person Attributes +dataelements=Data elements +patient_attributes=Person attributes operator=Operator dataentryform_management_for_program_stage=Data entry form management for Program stage choose_existing_dataentry=Choose existing data entry form @@ -162,7 +162,6 @@ condition=Condition condition_detail=Condition details edit_case_aggregation_condition=Edit person aggregation query builder -enrolldate_minus_incidentdate=Date of Enrollment - Date of Incident program_properties=Program properties orgunit=Organisation unit validation_criteria_details=Validation criteria details @@ -203,7 +202,7 @@ test_condition=Test condition run_success=Run successful run_fail=Run failed -patients_registered=Registered Persons No +total_of_patient_registration=Total of patient registration repeatable=Repeatable date_of_birth=Date of Birth anonymous=Anonymous @@ -226,16 +225,22 @@ no_date_data_element_in_selected_program_stage=No data elements with date-type in the selected program stage shown_on_reports=Shown on reports show_provided_provided_elsewhere=Show provided elsewhere -suggested_values=Suggested values -add_all_values=Add all values +available_values=Available values +insert_selected_values=Insert selected values display_provided_other_facility_column=Display provided other facility column aggregation_query_builder=Aggregation Query Builder patient_org_unit_registration=Person Org Unit Registration -dataset= Dataset -filter_by_data_set = Filter by dataset -show_all_item = Show All Items -multiple_events_with_registration = Multiple events with registration -single_event_with_registration = Single event with registration -single_event_without_registration = Single event without registration -for = for -standard_interval_days = Standard interval days \ No newline at end of file +dataset=Dataset +filter_by_data_set=Filter by dataset +show_all_item=Show All Items +multiple_events_with_registration=Multiple events with registration +single_event_with_registration=Single event with registration +single_event_without_registration=Single event without registration +for=for +standard_interval_days=Standard interval days +times=Times +program_enrollment=Program enrollment +due_date=Due date +stage_visited = Stage visited +report_date = Report date +program_stage_properties = Program stage properties \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2012-05-24 05:13:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2012-06-04 04:06:04 +0000 @@ -598,18 +598,18 @@ /dhis-web-maintenance-patient/responseAggerateDataElement.vm - - - - /dhis-web-maintenance-patient/responseProgramStages.vm + + + + /dhis-web-maintenance-patient/jsonParamsByProgram.vm - - - - /dhis-web-maintenance-patient/responsePSDataElement.vm + + + + /dhis-web-maintenance-patient/jsonPatientDataElements.vm === 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-03-21 09:19:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm 2012-06-04 04:06:04 +0000 @@ -14,14 +14,16 @@ - - + + + + - #foreach( $dataSet in $dataSets) @@ -32,21 +34,44 @@ - - - - - + + + + + $i18n.getString('count') - $i18n.getString('sum') - - + $i18n.getString('times') + + + + + + + + + + + + + + + + + + + + +

@@ -56,112 +81,50 @@
- - - - - +
-
- $i18n.getString( "data_element" ) - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
- -
-
-
-
- $i18n.getString( "suggested_values" ) - -
- $i18n.getString( 'add_all_values' ) -
+ + + + + + + + + + + -
+   +
+ + +
+
+
- - - - + + + + +
-
- $i18n.getString( "attribute" ) - - - - - -
- -
-
-
-
- $i18n.getString( "suggested_values" ) - -
-
- $i18n.getString( 'add_all_values' ) + + +
+ + +
@@ -170,52 +133,22 @@
+ + + +
-
- $i18n.getString( "program_properties" ) - - - - -
- -
-
+
-
- $i18n.getString( "program" ) - - - - - - - - - - -
- -
- -
- -
-
+ +
@@ -247,21 +180,21 @@ $i18n.getString( 'and' ) $i18n.getString( 'or' ) - $i18n.getString( 'clear' ) + $i18n.getString( 'clear' ) -
+
$i18n.getString( "condition" ) - +
-
+
$i18n.getString( "description" )
@@ -272,7 +205,7 @@ - + @@ -287,4 +220,5 @@ var i18n_run_success = '$encoder.jsEscape( $i18n.getString( "run_success" ) , "'" )'; var i18n_run_fail = '$encoder.jsEscape( $i18n.getString( "run_fail" ) , "'" )'; var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_item" ) , "'" )'; + var i18n_all = '[' + '$encoder.jsEscape( $i18n.getString( "all" ) , "'" )' + ']'; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm 2012-03-19 07:56:03 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm 2012-06-04 04:06:04 +0000 @@ -48,7 +48,7 @@
$i18n.getString( 'hide_details' )
-


+





=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm 2012-03-21 09:24:08 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationList.vm 2012-06-04 04:06:04 +0000 @@ -2,11 +2,11 @@ #foreach( $aggregationCondition in $aggregationConditions ) - $encoder.htmlEncode( $aggregationCondition.description ) + $encoder.htmlEncode( $aggregationCondition.name ) $i18n.getString( 'edit' ) - $i18n.getString( 'remove' ) + $i18n.getString( 'remove' ) $i18n.getString( 'show_details' ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addCaseAggregationForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addCaseAggregationForm.js 2012-03-19 09:35:42 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addCaseAggregationForm.js 2012-06-04 04:06:04 +0000 @@ -5,5 +5,5 @@ jQuery("#tabs").tabs(); checkValueIsExist( "aggregationDataElementId", "validateCaseAggregation.action"); - byId('description').focus(); + byId('name').focus(); }); \ 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/javascript/addProgramStageForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js 2012-05-23 18:02:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js 2012-06-04 04:06:04 +0000 @@ -3,6 +3,8 @@ validation( 'addProgramStageForm', function( form ){ form.submit(); }, function(){ + selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" ); + selectedDataElementsValidator.empty(); compulsories = jQuery( "#compulsories" ); compulsories.empty(); === 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-05-28 03:47:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2012-06-04 04:06:04 +0000 @@ -7,7 +7,7 @@ { var dataSets = document.getElementById( 'dataSets' ); var dataSetId = dataSets.options[ dataSets.selectedIndex ].value; - clearList( byId('aggregationDataElementId')); + clearListById('aggregationDataElementId'); if( dataSetId == "" ){ disable( 'dataElementsButton' ); @@ -21,7 +21,7 @@ }, function( json ) { var de = byId( 'aggregationDataElementId' ); - clearList( de ); + clearListById( 'aggregationDataElementId' ); for ( i in json.dataElements ) { @@ -88,8 +88,7 @@ } } } - }) - .addClass( "ui-widget ui-widget-content ui-corner-left" ); + }); input.data( "autocomplete" )._renderItem = function( ul, item ) { return $( "
  • " ) @@ -98,17 +97,8 @@ .appendTo( ul ); }; - showById('dataElementsButton'); - var button = $( "#dataElementsButton" ) + /* var button = $( "#dataElementsButton" ) .attr( "title", i18n_show_all_items ) - .button({ - icons: { - primary: "ui-icon-triangle-1-s" - }, - text: false - }) - .removeClass( "ui-corner-all" ) - .addClass( "ui-corner-right ui-button-icon" ) .click(function() { // close if already visible if ( input.autocomplete( "widget" ).is( ":visible" ) ) { @@ -122,126 +112,116 @@ // pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); input.focus(); - }); + }); */ } //------------------------------------------------------------------------------ // Get Program Stages //------------------------------------------------------------------------------ -function getProgramStages() -{ - clearListById( 'programStage' ); - clearListById( 'programstageDE' ); - - var program = document.getElementById( 'program' ); - var programId = program.options[ program.selectedIndex ].value; - if( programId == '0' ){ - return; - } - - $.get( 'getProgramStages.action', { programId:programId }, getProgramStagesCompleted, 'xml'); -} - -function getProgramStagesCompleted( programstageElement ) -{ - var programstage = document.getElementById( 'programStage' ); - var programstageList = $(programstageElement).find( 'programstage' ); - - $( programstageList ).each( function( i, item ) - { - var id = $( item ).find("id").text(); - var name = $( item ).find("name").text(); - - var option = document.createElement("option"); - option.value = id; - option.text = name; - option.title = name; - - programstage.add(option, null); - }); - - if( programstage.options.length > 0 ) - { - programstage.options[0].selected = true; - getPrgramStageDataElements(); - } -} - - -function getProgramStagesForFormula() -{ - clearListById( 'programStageFormula' ); - - var program = document.getElementById( 'programFormula' ); - var programId = program.options[ program.selectedIndex ].value; - if( programId == '0' ){ - return; - } - - $.get( 'getProgramStages.action', { programId:programId }, getProgramStagesFomulaCompleted, 'xml' ); -} - -function getProgramStagesFomulaCompleted( programstageElement ) -{ - var programstage = document.getElementById( 'programStageFormula' ); - var programstageList = $(programstageElement).find( 'programstage' ); - - $( programstageList ).each( function( i, item ) - { - var id = $( item ).find("id").text(); - var name = $( item ).find("name").text(); - - var option = document.createElement("option"); - option.value = "[PS:" + id + "]"; - option.text = name; - option.title = name; - - programstage.add(option, null); - }); - - if( programstage.options.length > 0 ) - { - programstage.options[0].selected = true; - } +function getParams() +{ + clearListById( 'programStageId' ); + clearListById( 'dataElements' ); + + jQuery.getJSON( 'getParamsByProgram.action',{ programId:getFieldValue( 'programId' ) } + ,function( json ) + { + var programstage = jQuery('#programStageId'); + + for ( i in json.programStages ) + { + var id = json.programStages[i].id; + var formularId = "[PS:" + id + "]"; + var name = json.programStages[i].name; + + programstage.append( "" ); + } + + if( json.programStages.length > 0 ) + { + programstage.prepend( "" ); + byId('programStageId').options[0].selected = true; + getPatientDataElements(); + } + + clearListById( 'caseProperty' ); + var type = jQuery('#programId option:selected').attr('type'); + if( type!='3') + { + var caseProperty = jQuery( '#caseProperty' ); + for ( i in json.fixedAttributes ) + { + var id = json.fixedAttributes[i].id; + var name = json.fixedAttributes[i].name; + + caseProperty.append( "" ); + } + + for ( i in json.patientAttributes ) + { + var id = json.patientAttributes[i].id; + var name = json.patientAttributes[i].name; + var suggested = json.patientAttributes[i].suggested; + + caseProperty.append( "" ); + } + } + }); } //------------------------------------------------------------------------------ // Get DataElements of Program-Stage //------------------------------------------------------------------------------ -function getPrgramStageDataElements() +function getPatientDataElements() { - clearListById( 'programstageDE' ); - + clearListById( 'dataElements' ); var programStage = document.getElementById( 'programStage' ); - var psId = programStage.options[ programStage.selectedIndex ].value; - - $.get( 'getPSDataElements.action', { psId:psId }, getPrgramStageDataElementsCompleted, 'xml' ); -} - -function getPrgramStageDataElementsCompleted( dataelementElement ) -{ - var programstageDE = jQuery('#programstageDE'); - var psDataElements = $(dataelementElement).find( 'dataelement' ); - - $( psDataElements ).each( function( i, item ) - { - var id = $(item).find("id").text(); - var name = $(item).find("name").text(); - var optionset =$(item).find("optionset").text(); - - programstageDE.append( "" ); - } ); + jQuery.getJSON( 'getPatientDataElements.action', + { + programId:getFieldValue( 'programId' ), + progamStageId: getFieldValue('progamStageId') + } + ,function( json ) + { + var dataElements = jQuery('#dataElements'); + for ( i in json.dataElements ) + { + dataElements.append( "" ); + } + }); } //----------------------------------------------------------------- // Insert items into Condition //----------------------------------------------------------------- -function insertInfo( element ) -{ - insertTextCommon('aggregationCondition', element.options[element.selectedIndex].value ); +function insertDataElement( element ) +{ + var progamId = getFieldValue('programId'); + var progamStageId = getFieldValue('programStageId'); + progamStageId = ( progamStageId == "" ) ? "*" : progamStageId; + var dataElementId = element.options[element.selectedIndex].value; + + insertTextCommon( 'aggregationCondition', "[DE:" + progamId + "." + progamStageId + "." + dataElementId + "]" ); + getConditionDescription(); +} + +function insertInfo( element, isProgramStageProperty ) +{ + var id = ""; + if( isProgramStageProperty ) + { + id = getFieldValue('programId'); + } + else + { + id = getFieldValue('programStageId'); + } + + value = element.options[element.selectedIndex].value.replace( '*', id ); + insertTextCommon('aggregationCondition', value ); getConditionDescription(); } @@ -268,7 +248,7 @@ { jQuery.getJSON( 'getCaseAggregation.action', { id:caseAggregationId }, function ( json ) { - setInnerHTML( 'descriptionField', json.caseAggregation.description ); + setInnerHTML( 'nameField', json.caseAggregation.name ); setInnerHTML( 'operatorField', json.caseAggregation.operator ); setInnerHTML( 'aggregationDataElementField', json.caseAggregation.aggregationDataElement ); setInnerHTML( 'optionComboField', json.caseAggregation.optionCombo ); @@ -321,21 +301,23 @@ { clearListById( targetId ); - var suggestedValues = jQuery('select[id=' + sourceId + '] option:selected').attr('suggestedValues'); - - var arrValues = new Array(); - arrValues = suggestedValues.replace(/[//[]+/g,'').replace(/]/g, '').split(', '); - - var suggestedValueSelector = byId( targetId ); - for( var i=0; i< arrValues.length; i++ ) + var suggestedValues = jQuery('select[id=' + sourceId + '] option:selected').attr('suggested'); + if( suggestedValues ) { - var option = document.createElement("option"); - var value = jQuery.trim( arrValues[i] ); - option.value = "'" + value + "'"; - option.text = value; - option.title = value; - - suggestedValueSelector.add(option, null); + var arrValues = new Array(); + arrValues = suggestedValues.replace(/[//[]+/g,'').replace(/]/g, '').split(', '); + + var suggestedValueSelector = byId( targetId ); + for( var i=0; i< arrValues.length; i++ ) + { + var option = document.createElement("option"); + var value = jQuery.trim( arrValues[i] ); + option.value = "'" + value + "'"; + option.text = value; + option.title = value; + + suggestedValueSelector.add(option, null); + } } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js 2011-08-01 02:39:52 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/commons.js 2012-06-04 04:06:04 +0000 @@ -1,28 +1,4 @@ -function dobTypeOnChange( container ){ - - var type = jQuery('#' + container + ' [id=dobType]').val(); - - if(type == 'V' || type == 'D'){ - jQuery('#' + container + ' [id=age]').rules("remove","required"); - jQuery('#' + container + ' [id=birthDate]').rules("add",{required:true}); - - showById(container + ' [id=birthdaySpan]'); - hideById(container + ' [id=ageSpan]'); - }else if(type == 'A'){ - jQuery('#' + container + ' [id=birthDate]').rules("remove","required"); - jQuery('#' + container + ' [id=age]').rules("add",{required:true}); - - hideById(container + ' [id=birthdaySpan]'); - showById(container + ' [id=ageSpan]'); - }else { - hideById(container + ' [id=birthdaySpan]'); - hideById(container + ' [id=ageSpan]'); - jQuery('#' + container + ' [id=age]').rules("remove","required"); - jQuery('#' + container + ' [id=birthDate]').rules("remove","required"); - } -} - // ---------------------------------------------------------------------------- // Search patients by name // ---------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateCaseAggregationForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateCaseAggregationForm.js 2012-03-19 09:35:42 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateCaseAggregationForm.js 2012-06-04 04:06:04 +0000 @@ -6,7 +6,7 @@ checkValueIsExist( "aggregationDataElementId", "validateCaseAggregation.action", {id:getFieldValue('id')}); - byId('description').focus(); + byId('name').focus(); jQuery("#tabs").tabs(); }); \ 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/javascript/updateProgramStageForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js 2012-05-23 18:02:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js 2012-06-04 04:06:04 +0000 @@ -9,10 +9,6 @@ compulsories = jQuery( "#compulsories" ); compulsories.empty(); - showOnReport = jQuery( "#showOnReport" ); - showOnReport.empty(); - - var hasDeShowReport = false; jQuery("#selectedList").find("tr").each( function( i, item ){ selectedDataElementsValidator.append( "" ); var compulsory = jQuery( item ).find( "input[name='compulsory']:first"); @@ -20,14 +16,6 @@ var checked = compulsory.attr('checked') ? true : false; compulsories.append( "" ); - - checked = isShow.attr('checked') ? true : false; - showOnReport.append( "" ); - if( checked ) - { - hasDeShowReport = true; - jQuery( "#checkShowOnReport" ).append( "" ); - } }); }); === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonParamsByProgram.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonParamsByProgram.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonParamsByProgram.vm 2012-06-04 04:06:04 +0000 @@ -0,0 +1,42 @@ +{ #set( $size = $!{programStages.size()} ) + "programStages": [ + #foreach( ${programStage} in $!{programStages} ) + { + "id": "${programStage.id}", + "name": "$!encoder.jsonEncode( ${programStage.name} )" + }#if( $velocityCount < $size ),#end + #end + ], + "fixedAttributes": [ + { + "id": "[PT:count]", + "name": "$i18n.getString( 'total_of_patient_registration' )", + "suggested": "" + }, + { + "id": "[CP:gender]", + "name": "$i18n.getString( 'gender' )", + "suggested": "F, M" + }, + { + "id": "[CP:dobType]", + "name": "$i18n.getString( 'dob_type' )", + "suggested": "V, D, A" + }, + { + "id": "[CP:age]", + "name": "$i18n.getString( "age_days" )", + "suggested": "" + } + ], + "patientAttributes":[ + #set( $size = $!{patientAttributes.size()} ) + #foreach( $patientAttribute in $!{patientAttributes} ) + { + "id": "[CA:${patientAttribute.id}]", + "name": "$!encoder.jsonEncode( ${patientAttribute.name} )", + "suggested":"$patientAttribute.attributeOptions" + }#if( $velocityCount < $size ),#end + #end + ] +} \ No newline at end of file === renamed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responsePSDataElement.vm' => 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonPatientDataElements.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responsePSDataElement.vm 2012-02-20 02:02:22 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/jsonPatientDataElements.vm 2012-06-04 04:06:04 +0000 @@ -1,14 +1,16 @@ - - - #foreach( $dataElement in $dataElementList ) - - [DE:$psId.$dataElement.id] - $encoder.xmlEncode( $dataElement.name ) - - #if( $!dataElement.optionSet.options ) - $encoder.xmlEncode($!dataElement.optionSet.options.toString()) - #end - - - #end - \ No newline at end of file +{ #set( $size = $!{dataElements.size()} ) + "dataElements": [ + #foreach( ${dataElement} in $!{dataElements} ) + { + "id": "${dataElement.id}", + "name": "$!encoder.jsonEncode( ${dataElement.name} )", + "optionset": + #if( $!dataElement.optionSet ) + "$encoder.xmlEncode($!dataElement.optionSet.options.toString())" + #else + "" + #end + }#if( $velocityCount < $size ),#end + #end + ] +} \ 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/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-03-21 05:48:22 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/style/basic.css 2012-06-04 04:06:04 +0000 @@ -1,10 +1,9 @@ -.heading-column { width : 30.5em;} -td.input-column { width : 30.5em;} -td.input-column input, td.input-column select { width: 28.5em;} -td.error {padding-left:1em} + +td{ padding-right : 10px;} textarea{ - width:320px; + width:660px; + height: 100px; text-align:left; } @@ -76,15 +75,18 @@ width:100%; } -.small-button { - font-size: .8em !important; +.arrow-down { + width: 15px; + height: 20px; + border-left: 1px solid #CCCCCC; + border-right: 1px solid #CCCCCC; + border-top: 1px solid #CCCCCC; + border-bottom: 1px solid #CCCCCC; + background: url('../../images/asc.gif') no-repeat center; + cursor: pointer; } -.ui-autocomplete { height: 100px; overflow-y: scroll; overflow-x: hidden; } - - -input.autocompleted-field +fieldset { - width:25em; - text-align:left; + border: 1px solid #3f5d8e; } \ 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-03-21 09:19:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm 2012-06-04 04:06:04 +0000 @@ -15,8 +15,8 @@ - - + + @@ -37,7 +37,8 @@ - + + @@ -48,121 +49,81 @@ + + + + + + + + + + + + + + + + + +

    -
    - - - - - +
    -
    - $i18n.getString( "data_element" ) - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    -
    -
    -
    - $i18n.getString( "suggested_values" ) - -
    - $i18n.getString( 'add_all_values' ) -
    + + + + + + + + + + + -
    +   +
    + + +
    +
    +
    - - - - + + + + +
    -
    - $i18n.getString( "attribute" ) - - - - - -
    - -
    -
    -
    -
    - $i18n.getString( "suggested_values" ) - -
    -
    - $i18n.getString( 'add_all_values' ) + + +
    + + +
    @@ -171,52 +132,22 @@
    + + + +
    -
    - $i18n.getString( "program_properties" ) - - - - -
    - -
    -
    +
    -
    - $i18n.getString( "program" ) - - - - - - - - - - -
    - -
    - -
    - -
    -
    + +
    @@ -225,7 +156,6 @@

    -
    @@ -254,16 +184,16 @@
    -
    +
    $i18n.getString( "condition" ) - +
    -
    +
    $i18n.getString( "description" )
    $!description
    @@ -290,4 +220,5 @@ var i18n_run_success = '$encoder.jsEscape( $i18n.getString( "run_success" ) , "'" )'; var i18n_run_fail = '$encoder.jsEscape( $i18n.getString( "run_fail" ) , "'" )'; var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_item" ) , "'" )'; + var i18n_all = '[' + '$encoder.jsEscape( $i18n.getString( "all" ) , "'" )' + ']';