← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12069: if person have no birthdate/gender, use todays date and female to generate person system identifier

 

------------------------------------------------------------
revno: 12069
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-09-13 09:08:33 +0200
message:
  if person have no birthdate/gender, use todays date and female to generate person system identifier
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java	2013-09-12 13:21:17 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java	2013-09-13 07:08:33 +0000
@@ -42,6 +42,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 
@@ -315,18 +316,22 @@
 
     private void addSystemIdentifier( Patient patient )
     {
-        if ( patient.getBirthDate() == null || patient.getGender() == null )
+        Date birthDate = patient.getBirthDate();
+        String gender = patient.getGender();
+
+        if ( birthDate == null || gender == null )
         {
-            return;
+            birthDate = new Date();
+            gender = "F";
         }
 
-        String systemId = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() );
+        String systemId = PatientIdentifierGenerator.getNewIdentifier( birthDate, gender );
 
         PatientIdentifier patientIdentifier = patientIdentifierService.get( null, systemId );
 
         while ( patientIdentifier != null )
         {
-            systemId = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() );
+            systemId = PatientIdentifierGenerator.getNewIdentifier( birthDate, gender );
             patientIdentifier = patientIdentifierService.get( null, systemId );
         }