dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24612
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12098: more fixes for update person
------------------------------------------------------------
revno: 12098
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-16 12:10:25 +0200
message:
more fixes for update person
modified:
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/DateOfBirth.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 08:06:49 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 2013-09-16 10:10:25 +0000
@@ -408,6 +408,14 @@
new ImportConflict( "OrganisationUnit", "orgUnit " + person.getOrgUnit() + " does not point to valid organisation unit" ) );
}
+ DateOfBirth dateOfBirth = person.getDateOfBirth();
+
+ if ( dateOfBirth == null )
+ {
+ importConflicts.add(
+ new ImportConflict( "DateOfBirth", "dateOfBirth is not present" ) );
+ }
+
importSummary.setConflicts( importConflicts );
if ( !importConflicts.isEmpty() )
@@ -427,6 +435,14 @@
String phoneNumber = person.getContact() != null ? person.getContact().getPhoneNumber() : null;
patient.setPhoneNumber( phoneNumber );
+ if ( DateOfBirthType.APPROXIMATE.equals( dateOfBirth.getType() ) )
+ {
+ dateOfBirth = new DateOfBirth( dateOfBirth.getAge() );
+ }
+
+ patient.setDobType( dateOfBirth.getType().getValue().charAt( 0 ) );
+ patient.setBirthDate( dateOfBirth.getDate() );
+
patientService.updatePatient( patient );
System.err.println( "Patient: " + getPerson( patient ) );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirth.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirth.java 2013-09-12 11:20:41 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirth.java 2013-09-16 10:10:25 +0000
@@ -39,7 +39,7 @@
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
-@JacksonXmlRootElement(localName = "dateOfBirth", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "dateOfBirth", namespace = DxfNamespaces.DXF_2_0 )
public class DateOfBirth
{
private Date date;
@@ -50,31 +50,33 @@
public DateOfBirth()
{
+ this.type = DateOfBirthType.APPROXIMATE;
+ this.age = 0;
}
public DateOfBirth( Date date )
{
- this.date = date;
- this.age = Patient.getIntegerValueOfAge( date );
this.type = DateOfBirthType.VERIFIED;
+ this.age = Patient.getIntegerValueOfAge( date );
+ this.date = date;
}
public DateOfBirth( Date date, DateOfBirthType type )
{
- this.date = date;
- this.age = Patient.getIntegerValueOfAge( date );
this.type = type;
+ this.age = Patient.getIntegerValueOfAge( date );
+ this.date = date;
}
public DateOfBirth( Integer age )
{
+ this.type = DateOfBirthType.APPROXIMATE;
this.age = age;
this.date = Patient.getBirthFromAge( age, Patient.AGE_TYPE_YEAR );
- this.type = DateOfBirthType.APPROXIMATE;
}
- @JsonProperty(required = true)
- @JacksonXmlProperty(isAttribute = true)
+ @JsonProperty( required = true )
+ @JacksonXmlProperty( isAttribute = true )
public Date getDate()
{
return date;
@@ -102,6 +104,7 @@
DateOfBirth that = (DateOfBirth) o;
+ if ( age != null ? !age.equals( that.age ) : that.age != null ) return false;
if ( date != null ? !date.equals( that.date ) : that.date != null ) return false;
if ( type != that.type ) return false;
@@ -113,6 +116,7 @@
{
int result = date != null ? date.hashCode() : 0;
result = 31 * result + (type != null ? type.hashCode() : 0);
+ result = 31 * result + (age != null ? age.hashCode() : 0);
return result;
}
@@ -122,6 +126,7 @@
return "DateOfBirth{" +
"date=" + date +
", type=" + type +
+ ", age=" + age +
'}';
}
}