=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java 2013-02-27 14:39:27 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java 2013-03-08 09:15:27 +0000 @@ -54,8 +54,6 @@ public static final String TYPE_COMBO = "combo"; - public static final String TYPE_CALCULATED = "calculated"; - private String description; private String valueType; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java 2012-12-21 09:23:20 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java 2013-03-08 09:15:27 +0000 @@ -29,7 +29,6 @@ import java.util.Collection; import java.util.Map; -import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientAttributeOption; @@ -76,5 +75,4 @@ void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption); - Double getCalculatedPatientAttributeValue( Patient patient, PatientAttribute patientAttribute, I18nFormat format); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java 2012-12-21 13:15:04 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java 2013-03-08 09:15:27 +0000 @@ -26,22 +26,7 @@ */ package org.hisp.dhis.patientattributevalue; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROPERTY; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM; -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.OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_OBJECT; - import java.util.Collection; -import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -49,19 +34,10 @@ import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientAttributeOption; -import org.hisp.dhis.patient.PatientAttributeService; -import org.hisp.dhis.program.Program; -import org.hisp.dhis.program.ProgramInstance; -import org.hisp.dhis.program.ProgramInstanceService; -import org.hisp.dhis.program.ProgramService; -import org.nfunk.jep.JEP; import org.springframework.transaction.annotation.Transactional; /** @@ -72,13 +48,6 @@ public class DefaultPatientAttributeValueService implements PatientAttributeValueService { - private final String CURRENT_DATE = "current_date"; - - private final String regExp = "\\[(" + CURRENT_DATE + "|" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" - + OBJECT_PROGRAM_STAGE + "|" + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY - + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|" - + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([0-9]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)" + "\\]"; - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -90,27 +59,6 @@ this.patientAttributeValueStore = patientAttributeValueStore; } - private PatientAttributeService patientAttributeService; - - public void setPatientAttributeService( PatientAttributeService patientAttributeService ) - { - this.patientAttributeService = patientAttributeService; - } - - private ProgramService programService; - - public void setProgramService( ProgramService programService ) - { - this.programService = programService; - } - - private ProgramInstanceService programInstanceService; - - public void setProgramInstanceService( ProgramInstanceService programInstanceService ) - { - this.programInstanceService = programInstanceService; - } - // ------------------------------------------------------------------------- // Implementation methods // ------------------------------------------------------------------------- @@ -271,95 +219,4 @@ patientAttributeValueStore.updatePatientAttributeValues( patientAttributeOption ); } - public Double getCalculatedPatientAttributeValue( Patient patient, PatientAttribute patientAttribute, - I18nFormat format ) - { - StringBuffer result = new StringBuffer(); - - String expression = patientAttribute.getExpression(); - - Pattern patternCondition = Pattern.compile( regExp ); - - Matcher matcher = patternCondition.matcher( expression ); - - Date currentDate = new Date(); - - while ( matcher.find() ) - { - String match = matcher.group(); - match = match.replaceAll( "[\\[\\]]", "" ); - String property = matcher.group( 1 ); - if ( CURRENT_DATE.equals( property ) ) - { - matcher.appendReplacement( result, "0" ); - } - else - { - String[] infor = matcher.group( 2 ).split( SEPARATOR_ID ); - int id = Integer.parseInt( infor[0] ); - - if ( property.equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) ) - { - PatientAttribute attribute = patientAttributeService.getPatientAttribute( id ); - PatientAttributeValue attributeValue = patientAttributeValueStore.get( patient, attribute ); - - if ( attributeValue != null ) - { - if ( PatientAttribute.TYPE_INT.equals( attributeValue.getPatientAttribute().getValueType() ) ) - { - matcher.appendReplacement( result, attributeValue.getValue() ); - } - else if ( PatientAttribute.TYPE_DATE.equals( attributeValue.getPatientAttribute() - .getValueType() ) ) - { - matcher.appendReplacement( result, - getDays( currentDate, format.parseDate( attributeValue.getValue() ) ) + "" ); - } - } - } - else if ( property.equalsIgnoreCase( OBJECT_PATIENT_PROPERTY ) ) - { - matcher.appendReplacement( result, getDays( currentDate, patient.getBirthDate() ) + "" ); - } - else if ( property.equalsIgnoreCase( OBJECT_PROGRAM ) ) - { - Program program = programService.getProgram( id ); - Collection programInstances = programInstanceService.getProgramInstances( patient, - program, false ); - - Date value = null; - if ( programInstances != null && programInstances.size() > 0 ) - { - ProgramInstance programInstance = programInstances.iterator().next(); - String propProgram = infor[1]; - if ( OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE.equals( propProgram ) ) - { - value = programInstance.getDateOfIncident(); - } - else if ( OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE.equals( propProgram ) ) - { - value = programInstance.getEnrollmentDate(); - } - } - else - { - return null; - } - matcher.appendReplacement( result, getDays( currentDate, value ) + "" ); - } - } - } - - final JEP parser = new JEP(); - - parser.parseExpression( result.toString() ); - - return parser.getValue(); - } - - private long getDays( Date currentDate, Date dateValue ) - { - long interval = currentDate.getTime() - dateValue.getTime(); - return (-interval / 86400000); - } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-02-27 14:39:27 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-03-08 09:15:27 +0000 @@ -286,12 +286,6 @@ class="org.hisp.dhis.patientattributevalue.DefaultPatientAttributeValueService"> - - - calAttributes = patientAttributeService - .getPatientAttributesByValueType( PatientAttribute.TYPE_CALCULATED ); - - for ( PatientAttribute calAttribute : calAttributes ) - { - Double value = patientAttributeValueService.getCalculatedPatientAttributeValue( patient, - calAttribute, format ); - if ( value != null ) - { - calAttributeValueMap.put( calAttribute.getName(), value ); - } - } } // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-02-28 08:50:43 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-03-08 09:15:27 +0000 @@ -34,10 +34,8 @@ import java.util.Map; import java.util.Set; -import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientAttribute; -import org.hisp.dhis.patient.PatientAttributeService; import org.hisp.dhis.patient.PatientAudit; import org.hisp.dhis.patient.PatientAuditService; import org.hisp.dhis.patient.PatientIdentifier; @@ -76,10 +74,6 @@ private CurrentUserService currentUserService; - private PatientAttributeService patientAttributeService; - - private I18nFormat format; - // ------------------------------------------------------------------------- // Input && Output // ------------------------------------------------------------------------- @@ -115,17 +109,7 @@ { return attributeMap; } - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - - public void setPatientAttributeService( PatientAttributeService patientAttributeService ) - { - this.patientAttributeService = patientAttributeService; - } - + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) { this.patientAttributeValueService = patientAttributeValueService; @@ -207,19 +191,6 @@ attributeValues = patientAttributeValueService.getPatientAttributeValues( patient ); - Collection calAttributes = patientAttributeService - .getPatientAttributesByValueType( PatientAttribute.TYPE_CALCULATED ); - - for ( PatientAttribute calAttribute : calAttributes ) - { - Double value = patientAttributeValueService.getCalculatedPatientAttributeValue( patient, calAttribute, - format ); - if ( value != null ) - { - attributeMap.put( calAttribute, value + "" ); - } - } - // --------------------------------------------------------------------- // Get patient-identifiers // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-03-07 16:01:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-03-08 09:15:27 +0000 @@ -101,10 +101,6 @@ ref="org.hisp.dhis.program.ProgramStageInstanceService" /> - - @@ -1075,8 +1071,6 @@ - === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/identifierAndAttributeForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/identifierAndAttributeForm.vm 2013-03-07 16:01:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/identifierAndAttributeForm.vm 2013-03-08 09:15:27 +0000 @@ -9,7 +9,6 @@ #end #foreach($attribute in $program.patientAttributes ) - #if( $attribute.valueType!='calculated') #set( $attributeValue = '') @@ -37,5 +36,4 @@ #end - #end #end \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-03-07 08:55:02 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-03-08 09:15:27 +0000 @@ -143,7 +143,6 @@ #foreach($attribute in $attributes ) #set($value = "") #set($value = $patientAttributeValueMap.get($attribute.id)) - #if( $attribute.valueType != 'calculated') @@ -170,7 +169,6 @@ #end - #end #end #end === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2013-03-07 16:01:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2013-03-08 09:15:27 +0000 @@ -71,7 +71,6 @@ #foreach($attribute in $patientAttributes ) - #if( $attribute.valueType!='calculated') #set( $attributeValue = '') #set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) ) @@ -100,7 +99,6 @@ #end - #end #set( $mark = !$mark ) #end   === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm 2013-03-05 13:55:46 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm 2013-03-08 09:15:27 +0000 @@ -26,12 +26,6 @@ $i18n.getString('program_stage'): $programStageInstance.programStage.displayName - #foreach( $attributeName in $calAttributeValueMap.keySet() ) - - $attributeName - $calAttributeValueMap.get($attributeName) - - #end   #end === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2013-03-07 15:11:33 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm 2013-03-08 09:15:27 +0000 @@ -73,9 +73,7 @@ #foreach( $attribute in $patientAttributes ) - #if($attribute.valueType!='calculated') - #end #end * === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientAttribute.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientAttribute.vm 2012-12-21 09:23:20 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonPatientAttribute.vm 2013-03-08 09:15:27 +0000 @@ -5,7 +5,6 @@ "description": "$!encoder.jsonEncode( ${patientAttribute.description} )", "mandatory": "$!{patientAttribute.mandatory}", "valueType": "$!patientAttribute.valueType", - "inherit": "$!patientAttribute.inherit", - "expression": "$!patientAttribute.expression" + "inherit": "$!patientAttribute.inherit" } } \ 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/addPatientAttributeForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm 2013-02-28 07:12:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm 2013-03-08 09:15:27 +0000 @@ -46,7 +46,6 @@ - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js 2013-02-28 07:12:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js 2013-03-08 09:15:27 +0000 @@ -13,7 +13,6 @@ var inherit = ( json.patientAttribute.inherit == 'true') ? i18n_yes : i18n_no; setInnerHTML( 'inheritField', inherit ); setInnerHTML( 'valueTypeField', json.patientAttribute.valueType ); - setInnerHTML( 'expressionField', json.patientAttribute.expression ); showDetails(); }); @@ -32,7 +31,7 @@ { selectValueType : function (this_) { - if ( jQuery(this_).val() == "COMBO" ) + if ( jQuery(this_).val() == "combo" ) { hideById("calculatedAttrTR"); hideById("expressionTR"); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm 2013-01-28 09:09:20 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm 2013-03-08 09:15:27 +0000 @@ -53,7 +53,6 @@




-


=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm 2013-02-28 07:12:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm 2013-03-08 09:15:27 +0000 @@ -49,7 +49,6 @@ -