dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21632
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10287: [mobile] fix bug empty data values
------------------------------------------------------------
revno: 10287
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Mon 2013-03-18 15:35:00 +0700
message:
[mobile] fix bug empty data values
modified:
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/singleevent/action/SaveSingleEventAction.java
--
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-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<PatientDataValue> patientDataValues = new ArrayList<PatientDataValue>();
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<ProgramValidationResult> 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 );
+ }
}
}
}