=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java 2013-04-17 08:45:28 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java 2013-04-17 11:03:44 +0000 @@ -190,19 +190,15 @@ PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance, dataElement ); - if ( patientDataValue == null && value != null ) - { - patientDataValue = new PatientDataValue( programStageInstance, dataElement, new Date(), value ); - patientDataValue.setStoredBy( storedBy ); - patientDataValue.setProvidedElsewhere( providedElsewhere ); - - patientDataValueService.savePatientDataValue( patientDataValue ); - } - else - { - if ( value == null ) + if ( value != null ) + { + if ( patientDataValue == null ) { - patientDataValueService.deletePatientDataValue( patientDataValue ); + patientDataValue = new PatientDataValue( programStageInstance, dataElement, new Date(), value ); + patientDataValue.setStoredBy( storedBy ); + patientDataValue.setProvidedElsewhere( providedElsewhere ); + + patientDataValueService.savePatientDataValue( patientDataValue ); } else { @@ -214,5 +210,9 @@ patientDataValueService.updatePatientDataValue( patientDataValue ); } } + else if ( patientDataValue != null ) + { + patientDataValueService.deletePatientDataValue( patientDataValue ); + } } }