dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24585
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12085: minor fix
------------------------------------------------------------
revno: 12085
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-09-13 15:39:22 +0200
message:
minor fix
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-13 13:27:19 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 2013-09-13 13:39:22 +0000
@@ -343,6 +343,85 @@
return importSummary;
}
+ private void addSystemIdentifier( Person person )
+ {
+ Date birthDate = person.getDateOfBirth() != null ? person.getDateOfBirth().getDate() : null;
+ String gender = person.getGender() != null ? person.getGender().getValue() : null;
+
+ if ( birthDate == null || gender == null )
+ {
+ birthDate = new Date();
+ gender = "F";
+ }
+
+ Iterator<Identifier> iterator = person.getIdentifiers().iterator();
+
+ // remove any old system identifiers
+ while ( iterator.hasNext() )
+ {
+ Identifier identifier = iterator.next();
+
+ if ( identifier.getType() == null )
+ {
+ iterator.remove();
+ }
+ }
+
+ String systemId = PatientIdentifierGenerator.getNewIdentifier( birthDate, gender );
+
+ PatientIdentifier patientIdentifier = patientIdentifierService.get( null, systemId );
+
+ while ( patientIdentifier != null )
+ {
+ systemId = PatientIdentifierGenerator.getNewIdentifier( birthDate, gender );
+ patientIdentifier = patientIdentifierService.get( null, systemId );
+ }
+
+ Identifier identifier = new Identifier();
+ identifier.setValue( systemId );
+
+ person.getIdentifiers().add( identifier );
+ }
+
+ // -------------------------------------------------------------------------
+ // UPDATE
+ // -------------------------------------------------------------------------
+
+ @Override
+ public ImportSummary updatePerson( Person person )
+ {
+ ImportSummary importSummary = new ImportSummary();
+
+ System.err.println( "UPDATE: " + person );
+ Patient patient = getPatient( person );
+
+ return importSummary;
+ }
+
+ // -------------------------------------------------------------------------
+ // DELETE
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void deletePerson( Person person )
+ {
+ System.err.println( "DELETE:" + person );
+ Patient patient = patientService.getPatient( person.getPerson() );
+
+ if ( patient != null )
+ {
+ patientService.deletePatient( patient );
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // HELPERS
+ // -------------------------------------------------------------------------
+
private List<ImportConflict> checkForRequiredIdentifiers( Person person )
{
List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
@@ -429,79 +508,4 @@
}
}
}
-
- private void addSystemIdentifier( Person person )
- {
- Date birthDate = person.getDateOfBirth() != null ? person.getDateOfBirth().getDate() : null;
- String gender = person.getGender() != null ? person.getGender().getValue() : null;
-
- if ( birthDate == null || gender == null )
- {
- birthDate = new Date();
- gender = "F";
- }
-
- Iterator<Identifier> iterator = person.getIdentifiers().iterator();
-
- // remove any old system identifiers
- while ( iterator.hasNext() )
- {
- Identifier identifier = iterator.next();
-
- if ( identifier.getType() == null )
- {
- iterator.remove();
- }
- }
-
- String systemId = PatientIdentifierGenerator.getNewIdentifier( birthDate, gender );
-
- PatientIdentifier patientIdentifier = patientIdentifierService.get( null, systemId );
-
- while ( patientIdentifier != null )
- {
- systemId = PatientIdentifierGenerator.getNewIdentifier( birthDate, gender );
- patientIdentifier = patientIdentifierService.get( null, systemId );
- }
-
- Identifier identifier = new Identifier();
- identifier.setValue( systemId );
-
- person.getIdentifiers().add( identifier );
- }
-
- // -------------------------------------------------------------------------
- // UPDATE
- // -------------------------------------------------------------------------
-
- @Override
- public ImportSummary updatePerson( Person person )
- {
- ImportSummary importSummary = new ImportSummary();
-
- System.err.println( "UPDATE: " + person );
- Patient patient = getPatient( person );
-
- return importSummary;
- }
-
- // -------------------------------------------------------------------------
- // DELETE
- // -------------------------------------------------------------------------
-
- @Override
- public void deletePerson( Person person )
- {
- System.err.println( "DELETE:" + person );
- Patient patient = patientService.getPatient( person.getPerson() );
-
- if ( patient != null )
- {
- patientService.deletePatient( patient );
- }
- else
- {
- throw new IllegalArgumentException();
- }
- }
}