dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24606
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12095: (person api) update of persons, wip
------------------------------------------------------------
revno: 12095
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-16 10:06:49 +0200
message:
(person api) update of persons, wip
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-16 07:42:02 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 2013-09-16 08:06:49 +0000
@@ -390,17 +390,24 @@
@Override
public ImportSummary updatePerson( Person person )
{
- System.err.println( "UPDATE: " + person );
+ System.err.println( "Person: " + person );
ImportSummary importSummary = new ImportSummary();
importSummary.setDataValueCount( null );
- Patient patient = patientService.getPatient( person.getPerson() );
+ Patient patient = manager.get( Patient.class, person.getPerson() );
+ OrganisationUnit organisationUnit = manager.get( OrganisationUnit.class, person.getOrgUnit() );
List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
importConflicts.addAll( checkForRequiredIdentifiers( person ) );
importConflicts.addAll( checkForRequiredAttributes( person ) );
+ if ( organisationUnit == null )
+ {
+ importConflicts.add(
+ new ImportConflict( "OrganisationUnit", "orgUnit " + person.getOrgUnit() + " does not point to valid organisation unit" ) );
+ }
+
importSummary.setConflicts( importConflicts );
if ( !importConflicts.isEmpty() )
@@ -410,6 +417,20 @@
return importSummary;
}
+ patient.setName( person.getName() );
+ patient.setGender( person.getGender().getValue() );
+ patient.setIsDead( person.isDeceased() );
+ patient.setDeathDate( person.getDateOfDeath() );
+ // TODO should we allow update of this property?
+ patient.setRegistrationDate( person.getDateOfRegistration() );
+
+ String phoneNumber = person.getContact() != null ? person.getContact().getPhoneNumber() : null;
+ patient.setPhoneNumber( phoneNumber );
+
+ patientService.updatePatient( patient );
+
+ System.err.println( "Patient: " + getPerson( patient ) );
+
importSummary.setStatus( ImportStatus.SUCCESS );
importSummary.setReference( patient.getUid() );
importSummary.getImportCount().incrementImported();
@@ -424,7 +445,6 @@
@Override
public void deletePerson( Person person )
{
- System.err.println( "DELETE:" + person );
Patient patient = patientService.getPatient( person.getPerson() );
if ( patient != null )