dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09336
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2446: Fix Integers compared with !=, refactored somewhat
------------------------------------------------------------
revno: 2446
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-12-30 01:45:01 +0530
message:
Fix Integers compared with !=, refactored somewhat
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.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-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2010-12-27 07:59:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2010-12-29 20:15:01 +0000
@@ -455,42 +455,42 @@
patientAttributeValueService.deletePatientAttributeValue( av );
}
- // -------------------------------------------------------------------------
- // If underAge = true : save representative information.
- // -------------------------------------------------------------------------
-
- if ( patient.isUnderAge() )
+ if ( shouldSaveRepresentativeInformation( patient, representativeId ))
{
+ Patient representative = patientStore.get( representativeId );
- if ( representativeId != null )
+ if ( representative != null )
{
- if ( patient.getRepresentative() == null || patient.getRepresentative().getId() != representativeId )
+ patient.setRepresentative( representative );
+
+ Relationship rel = new Relationship();
+ rel.setPatientA( representative );
+ rel.setPatientB( patient );
+
+ if ( relationshipTypeId != null )
{
- Patient representative = patientStore.get( representativeId );
-
- if ( representative != null )
+ RelationshipType relType = relationshipTypeService.getRelationshipType( relationshipTypeId );
+ if ( relType != null )
{
- patient.setRepresentative( representative );
-
- Relationship rel = new Relationship();
- rel.setPatientA( representative );
- rel.setPatientB( patient );
-
- if ( relationshipTypeId != null )
- {
- RelationshipType relType = relationshipTypeService.getRelationshipType( relationshipTypeId );
- if ( relType != null )
- {
- rel.setRelationshipType( relType );
- relationshipService.saveRelationship( rel );
- }
- }
+ rel.setRelationshipType( relType );
+ relationshipService.saveRelationship( rel );
}
}
}
}
}
+ private boolean shouldSaveRepresentativeInformation( Patient patient, Integer representativeId )
+ {
+ if (!patient.isUnderAge())
+ return false;
+
+ if (representativeId == null)
+ return false;
+
+ return patient.getRepresentative() == null || !patient.getRepresentative().getId().equals( representativeId );
+ }
+
public Collection<Patient> getPatients( OrganisationUnit organisationUnit, Program program, int min, int max )
{
return patientStore.getByOrgUnitProgram( organisationUnit, program, min, max );