dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27545
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13715: Fixed bug - Don't remove fixed attribtues from patient object and don't create dynamic attributes...
------------------------------------------------------------
revno: 13715
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-14 17:21:12 +0700
message:
Fixed bug - Don't remove fixed attribtues from patient object and don't create dynamic attributes for fixed attributesremoved.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.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/DefaultPatientAttributeService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java 2014-01-13 09:22:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java 2014-01-14 10:21:12 +0000
@@ -29,6 +29,7 @@
*/
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import org.hisp.dhis.program.Program;
@@ -135,20 +136,15 @@
Collection<PatientAttribute> patientAttributes = patientAttributeStore.getAll();
Iterator<PatientAttribute> iterator = patientAttributes.iterator();
+ Collection<PatientAttribute> programAttributes = new HashSet<PatientAttribute>();
Collection<Program> programs = programService.getAllPrograms();
- while ( iterator.hasNext() )
+ for ( Program program : programs )
{
- for ( Program program : programs )
- {
- PatientAttribute attribute = iterator.next();
- if ( program.getAttributes().contains( attribute ) )
- {
- iterator.remove();
- break;
- }
- }
+ programAttributes.addAll( program.getAttributes() );
}
+ patientAttributes.removeAll( programAttributes );
+
return patientAttributes;
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2014-01-13 15:30:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2014-01-14 10:21:12 +0000
@@ -496,7 +496,7 @@
ResultSet resultSet = statement.executeQuery( "SELECT gender FROM patient" );
// Only execute once
- if ( !resultSet.next() )
+ if ( resultSet.next() )
{
Integer max = jdbcTemplate.queryForObject( "select max(patientattributeid) from patientattribute",
Integer.class );
@@ -544,9 +544,7 @@
// Update custom entry form && validation criteria
removeFixedAttributeInCustomRegistrationForm( "gender", uid );
- executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
- + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
- + " and property='gender' " );
+ executeSql( "UPDATE validationcriteria SET property='gender' WHERE property='gender' " );
// ---------------------------------------------------------------------
// Death date
@@ -567,9 +565,7 @@
// Update custom entry form && Validation criteria
removeFixedAttributeInCustomRegistrationForm( "deathDate", uid );
- executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
- + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
- + " and property='deathDate' " );
+ executeSql( "UPDATE validationcriteria SET property='deathDate' WHERE property='deathDate' " );
// ---------------------------------------------------------------------
// registrationDate
@@ -591,9 +587,7 @@
// Update custom entry form && validation criteria
removeFixedAttributeInCustomRegistrationForm( "registrationDate", uid );
- executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
- + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
- + " and property='registrationDate' " );
+ executeSql( "UPDATE validationcriteria SET property='registrationDate' WHERE property='registrationDate' " );
// ---------------------------------------------------------------------
// isDead
@@ -614,9 +608,7 @@
// Update custom entry form && validation criteria
removeFixedAttributeInCustomRegistrationForm( "isDead", uid );
- executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
- + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
- + " and property='isDead' " );
+ executeSql( "UPDATE validationcriteria SET property='isDead' WHERE property='isDead' " );
// ---------------------------------------------------------------------
// underAge
@@ -637,9 +629,7 @@
// Update custom entry form && validation criteria
removeFixedAttributeInCustomRegistrationForm( "underAge", uid );
- executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
- + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
- + " and property='underAge' " );
+ executeSql( "UPDATE validationcriteria SET property='underAge' WHERE property='underAge' " );
// ---------------------------------------------------------------------
// DobType
@@ -684,9 +674,7 @@
// Update custom entry form && validation criteria
removeFixedAttributeInCustomRegistrationForm( "dobType", uid );
- executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
- + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
- + " and property='dobType' " );
+ executeSql( "UPDATE validationcriteria SET property='dobType' WHERE property='dobType' " );
// -------------------------------------------------------------
// Birthdate
@@ -707,9 +695,7 @@
// Update custom entry form && validation criteria
removeFixedAttributeInCustomRegistrationForm( "birthDate", uid );
- executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
- + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
- + " and property='birthDate' " );
+ executeSql( "UPDATE validationcriteria SET property='birthDate' WHERE property='birthDate' " );
// -------------------------------------------------------------
// Age
@@ -730,9 +716,7 @@
// Update custom entry form && validation criteria
removeFixedAttributeInCustomRegistrationForm( "age", uid );
- executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
- + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
- + " and property='age' " );
+ executeSql( "UPDATE validationcriteria SET property='age' WHERE property='age' " );
// -------------------------------------------------------------
// Phone number