=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java 2013-09-19 07:57:50 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java 2013-09-19 08:51:41 +0000 @@ -43,6 +43,8 @@ import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; import org.hisp.dhis.program.Program; +import org.hisp.dhis.relationship.Relationship; +import org.hisp.dhis.relationship.RelationshipService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; @@ -79,6 +81,9 @@ private PatientAttributeValueService patientAttributeValueService; @Autowired + private RelationshipService relationshipService; + + @Autowired private IdentifiableObjectManager manager; // ------------------------------------------------------------------------- @@ -212,6 +217,17 @@ person.setDateOfRegistration( patient.getRegistrationDate() ); + Collection relationshipsForPatient = relationshipService.getRelationshipsForPatient( patient ); + + for ( Relationship relationshipPatient : relationshipsForPatient ) + { + org.hisp.dhis.dxf2.events.person.Relationship relationship = new org.hisp.dhis.dxf2.events.person.Relationship(); + relationship.setPerson( relationshipPatient.getPatientA().getUid() ); + relationship.setType( relationshipPatient.getRelationshipType().getUid() ); + + person.getRelationships().add( relationship ); + } + for ( PatientIdentifier patientIdentifier : patient.getIdentifiers() ) { String identifierType = patientIdentifier.getIdentifierType() == null ? null : patientIdentifier.getIdentifierType().getUid(); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java 2013-09-17 12:15:39 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java 2013-09-19 08:51:41 +0000 @@ -40,7 +40,7 @@ /** * @author Morten Olav Hansen */ -@JacksonXmlRootElement(localName = "person", namespace = DxfNamespaces.DXF_2_0) +@JacksonXmlRootElement( localName = "person", namespace = DxfNamespaces.DXF_2_0 ) public class Person { private String person; @@ -61,6 +61,8 @@ private Contact contact; + private List relationships = new ArrayList(); + private List identifiers = new ArrayList(); private List attributes = new ArrayList(); @@ -179,6 +181,18 @@ @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public List getRelationships() + { + return relationships; + } + + public void setRelationships( List relationships ) + { + this.relationships = relationships; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public List getIdentifiers() { return identifiers; @@ -221,6 +235,7 @@ if ( name != null ? !name.equals( person1.name ) : person1.name != null ) return false; if ( orgUnit != null ? !orgUnit.equals( person1.orgUnit ) : person1.orgUnit != null ) return false; if ( person != null ? !person.equals( person1.person ) : person1.person != null ) return false; + if ( relationships != null ? !relationships.equals( person1.relationships ) : person1.relationships != null ) return false; return true; } @@ -237,6 +252,7 @@ result = 31 * result + (dateOfDeath != null ? dateOfDeath.hashCode() : 0); result = 31 * result + (dateOfRegistration != null ? dateOfRegistration.hashCode() : 0); result = 31 * result + (contact != null ? contact.hashCode() : 0); + result = 31 * result + (relationships != null ? relationships.hashCode() : 0); result = 31 * result + (identifiers != null ? identifiers.hashCode() : 0); result = 31 * result + (attributes != null ? attributes.hashCode() : 0); return result; @@ -254,6 +270,7 @@ ", dateOfDeath=" + dateOfDeath + ", dateOfRegistration=" + dateOfRegistration + ", contact=" + contact + + ", relationships=" + relationships + ", identifiers=" + identifiers + ", attributes=" + attributes + '}'; === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java 2013-09-19 08:38:29 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java 2013-09-19 08:51:41 +0000 @@ -39,9 +39,7 @@ @JacksonXmlRootElement( localName = "relationship", namespace = DxfNamespaces.DXF_2_0 ) public class Relationship { - private String personA; - - private String personB; + private String person; private String type; @@ -51,26 +49,14 @@ @JsonProperty @JacksonXmlProperty( isAttribute = true ) - public String getPersonA() - { - return personA; - } - - public void setPersonA( String personA ) - { - this.personA = personA; - } - - @JsonProperty - @JacksonXmlProperty( isAttribute = true ) - public String getPersonB() - { - return personB; - } - - public void setPersonB( String personB ) - { - this.personB = personB; + public String getPerson() + { + return person; + } + + public void setPerson( String person ) + { + this.person = person; } @JsonProperty @@ -84,4 +70,34 @@ { this.type = type; } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) return true; + if ( o == null || getClass() != o.getClass() ) return false; + + Relationship that = (Relationship) o; + + if ( person != null ? !person.equals( that.person ) : that.person != null ) return false; + if ( type != null ? !type.equals( that.type ) : that.type != null ) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = person != null ? person.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + return result; + } + + @Override public String toString() + { + return "Relationship{" + + "person='" + person + '\'' + + ", type='" + type + '\'' + + '}'; + } }