=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java 2013-02-10 13:06:34 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java 2013-03-18 08:35:00 +0000 @@ -93,7 +93,7 @@ { this.dataElementService = dataElementService; } - + private PatientService patientService; public PatientService getPatientService() @@ -421,7 +421,7 @@ List patientDataValues = new ArrayList(); patient = patientService.getPatient( patientId ); - + if ( programStageSectionId != null && programStageSectionId != 0 ) { this.programStageSection = programStageSectionService.getProgramStageSection( this.programStageSectionId ); @@ -472,11 +472,11 @@ prevDataValues.put( key, value ); prevDataValues.put( "CB" + dataElement.getId(), parameterMap.get( "CB" + dataElement.getId() ) ); - + // build patient data value PatientDataValue patientDataValue = new PatientDataValue( programStageInstance, dataElement, new Date(), value ); - + String providedElseWhereValue = parameterMap.get( "CB" + dataElementId ); if ( providedElseWhereValue != null ) @@ -543,10 +543,17 @@ } else { - previousPatientDataValue.setValue( patientDataValue.getValue() ); - previousPatientDataValue.setTimestamp( new Date() ); - previousPatientDataValue.setProvidedElsewhere( patientDataValue.getProvidedElsewhere() ); - patientDataValueService.updatePatientDataValue( previousPatientDataValue ); + if ( patientDataValue.getValue().trim().equals( "" ) ) + { + patientDataValueService.deletePatientDataValue( previousPatientDataValue ); + } + else + { + previousPatientDataValue.setValue( patientDataValue.getValue() ); + previousPatientDataValue.setTimestamp( new Date() ); + previousPatientDataValue.setProvidedElsewhere( patientDataValue.getProvidedElsewhere() ); + patientDataValueService.updatePatientDataValue( previousPatientDataValue ); + } } } @@ -566,7 +573,7 @@ { Collection validationResults = programValidationService.validate( validations, programStageInstance ); - + for ( ProgramValidationResult validationResult : validationResults ) { if ( validationResult != null ) === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java 2013-03-13 14:17:15 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java 2013-03-18 08:35:00 +0000 @@ -314,7 +314,7 @@ } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public String execute() throws Exception { @@ -426,13 +426,20 @@ } else if ( patientDataValue != null && value != null ) { - patientDataValue.setValue( value ); - - patientDataValue.setTimestamp( new Date() ); - - patientDataValue.setProvidedElsewhere( false ); - - patientDataValueService.updatePatientDataValue( patientDataValue ); + if ( value.trim().equals( "" ) ) + { + patientDataValueService.deletePatientDataValue( patientDataValue ); + } + else + { + patientDataValue.setValue( value ); + + patientDataValue.setTimestamp( new Date() ); + + patientDataValue.setProvidedElsewhere( false ); + + patientDataValueService.updatePatientDataValue( patientDataValue ); + } } } }