← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2201: When updating patient, cannot remove patientIdentifier with empty values from database.

 

------------------------------------------------------------
revno: 2201
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-29 12:40:21 +0700
message:
  When updating patient, cannot remove patientIdentifier with empty values from database.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/AddPatientIdentifierTypeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/UpdatePatientIdentifierTypeAction.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-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java	2010-11-09 09:07:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java	2010-11-29 05:40:21 +0000
@@ -178,13 +178,13 @@
                 {
                     value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + identifierType.getId() );
                 }
-                
+
+                identifier = patientIdentifierService.getPatientIdentifier( identifierType, patient );
+               
                 if ( StringUtils.isNotBlank( value ) )
                 {
                     value = value.trim();
-
-                    identifier = patientIdentifierService.getPatientIdentifier( identifierType, patient );
-
+                    
                     if ( identifier == null )
                     {
                         identifier = new PatientIdentifier();
@@ -199,6 +199,11 @@
                         patient.getIdentifiers().add( identifier );
                     }
                 }
+                else if ( identifier != null )
+                { 
+                   patient.getIdentifiers().remove( identifier );
+                   patientIdentifierService.deletePatientIdentifier( identifier );
+                }
             }
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/AddPatientIdentifierTypeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/AddPatientIdentifierTypeAction.java	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/AddPatientIdentifierTypeAction.java	2010-11-29 05:40:21 +0000
@@ -73,7 +73,7 @@
         PatientIdentifierType patientIdentifierType = new PatientIdentifierType();
         patientIdentifierType.setName( name );
         patientIdentifierType.setDescription( description );
-        patientIdentifierType.setFormat( formater );
+        patientIdentifierType.setFormat( formater == null ? "" : formater );
         patientIdentifierType.setRelated( related.booleanValue() );
         patientIdentifierType.setMandatory( mandatory.booleanValue() );
         patientIdentifierType.setNoChars( noChars );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/UpdatePatientIdentifierTypeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/UpdatePatientIdentifierTypeAction.java	2010-11-16 05:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientidentifiertype/UpdatePatientIdentifierTypeAction.java	2010-11-29 05:40:21 +0000
@@ -76,7 +76,7 @@
         {
             identifierType.setName( name );
             identifierType.setDescription( description );
-            identifierType.setFormat( formater );
+            identifierType.setFormat( formater == null ? "" : formater );
             identifierType.setMandatory( mandatory.booleanValue() );
             identifierType.setRelated( related.booleanValue() );
             identifierType.setNoChars( noChars );