dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #06826
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1888: Bug fix for saving date values in name-based module
------------------------------------------------------------
revno: 1888
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: cbhis-mobile
timestamp: Wed 2010-08-04 11:18:54 +0200
message:
Bug fix for saving date values in name-based module
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java 2009-11-24 15:39:07 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveDateValueAction.java 2010-08-04 09:18:54 +0000
@@ -177,6 +177,11 @@
PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance,
dataElement, organisationUnit );
+ if ( value != null && value.trim().length() == 0 )
+ {
+ value = null;
+ }
+
if ( value != null )
{
Date dateValue = format.parseDate( value );
@@ -217,7 +222,7 @@
patientDataValueService.updatePatientDataValue( patientDataValue );
}
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java 2010-07-27 11:43:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java 2010-08-04 09:18:54 +0000
@@ -26,7 +26,6 @@
*/
package org.hisp.dhis.caseentry.action.caseentry;
-
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
@@ -51,7 +50,6 @@
import org.hisp.dhis.program.ProgramStageInstanceService;
import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.i18n.I18nFormat;
/**
* @author Abyot Asalefew Gizaw
@@ -111,12 +109,6 @@
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
- private I18nFormat format;
-
- public void setFormat( I18nFormat format )
- {
- this.format = format;
- }
private boolean providedByAnotherFacility;
@@ -198,13 +190,13 @@
value = value.trim();
}
-
DataElementCategoryOptionCombo optionCombo = null;
if ( optionComboId == 0 )
{
optionCombo = dataElement.getCategoryCombo().getOptionCombos().iterator().next();
- } else
+ }
+ else
{
Set<DataElementCategoryOptionCombo> options = dataElement.getCategoryCombo().getOptionCombos();
if ( options != null && options.size() > 0 )
@@ -224,7 +216,8 @@
PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance,
dataElement, organisationUnit );
- if ( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_STRING ) && dataElement.isMultiDimensional() )
+ if ( dataElement.getType().equalsIgnoreCase( DataElement.VALUE_TYPE_STRING )
+ && dataElement.isMultiDimensional() )
{
if ( value != null )
{
@@ -233,52 +226,37 @@
}
if ( patientDataValue == null )
- {
- if ( value != null )
- {
- Date dateValue = format.parseDate( value );
- if ( dateValue != null )
- {
- LOG.debug( "Adding PatientDataValue, value added" );
-
- if ( programStageInstance.getExecutionDate() == null )
- {
- programStageInstance.setExecutionDate( new Date() );
- programStageInstanceService.updateProgramStageInstance( programStageInstance );
- }
-
- patientDataValue = new PatientDataValue( programStageInstance, dataElement, optionCombo,
- organisationUnit, new Date(), value, providedByAnotherFacility );
-
- patientDataValueService.savePatientDataValue( patientDataValue );
- } else
- {
- statusCode = 1;
- }
- }
- } else
- {
- Date dateValue = format.parseDate( value );
- if ( dateValue != null )
- {
- LOG.debug( "Updating PatientDataValue, value added/changed" );
-
- if ( programStageInstance.getExecutionDate() == null )
- {
- programStageInstance.setExecutionDate( new Date() );
- programStageInstanceService.updateProgramStageInstance( programStageInstance );
- }
-
- patientDataValue.setValue( value );
- patientDataValue.setOptionCombo( optionCombo );
- patientDataValue.setProvidedByAnotherFacility( providedByAnotherFacility );
- patientDataValue.setTimestamp( new Date() );
-
- patientDataValueService.updatePatientDataValue( patientDataValue );
- } else
- {
- statusCode = 1;
- }
+ {
+
+ LOG.debug( "Adding PatientDataValue, value added" );
+
+ if ( programStageInstance.getExecutionDate() == null )
+ {
+ programStageInstance.setExecutionDate( new Date() );
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ }
+
+ patientDataValue = new PatientDataValue( programStageInstance, dataElement, optionCombo, organisationUnit,
+ new Date(), value, providedByAnotherFacility );
+
+ patientDataValueService.savePatientDataValue( patientDataValue );
+ }
+ else
+ {
+ LOG.debug( "Updating PatientDataValue, value added/changed" );
+
+ if ( programStageInstance.getExecutionDate() == null )
+ {
+ programStageInstance.setExecutionDate( new Date() );
+ programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ }
+
+ patientDataValue.setValue( value );
+ patientDataValue.setOptionCombo( optionCombo );
+ patientDataValue.setProvidedByAnotherFacility( providedByAnotherFacility );
+ patientDataValue.setTimestamp( new Date() );
+
+ patientDataValueService.updatePatientDataValue( patientDataValue );
}
return SUCCESS;