← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13694: Minor fix

 

------------------------------------------------------------
revno: 13694
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-01-13 08:42:00 +0700
message:
  Minor fix
modified:
  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/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2014-01-12 14:48:54 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2014-01-13 01:42:00 +0000
@@ -106,7 +106,7 @@
 
     @Autowired
     private StatementBuilder statementBuilder;
-    
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -296,7 +296,7 @@
 
         executeSql( "UPDATE patientattribute SET displayInListNoProgram=false WHERE displayInListNoProgram is null" );
         executeSql( "UPDATE patientidentifiertype SET displayInListNoProgram=false WHERE displayInListNoProgram is null" );
-        
+
         updateProgramAttributes();
     }
 
@@ -307,24 +307,28 @@
     private void updateProgramAttributes()
     {
         String autoIncrVal = statementBuilder.getAutoIncrementValue();
-        
+
         String attributeSql = "INSERT INTO program_attributes (programattributeid, attributeid, sort_order, displayinlist, programid) "
-            + "SELECT " + autoIncrVal + ", pp.patientattributeid, pp.sort_order, false, pp.programid "
-            + "FROM program_patientattributes pp";        
+            + "SELECT "
+            + autoIncrVal
+            + ", pp.patientattributeid, pp.sort_order, false, pp.programid "
+            + "FROM program_patientattributes pp";
         executeSql( attributeSql );
 
         String identifierSql = "INSERT INTO program_identifiertypes (programidentifiertypeid, identifiertypeid, sort_order, displayinlist, programid) "
-            + "SELECT " + autoIncrVal + ", pp.patientidentifiertypeid, pp.sort_order, false, pp.programid "
-            + "FROM program_patientidentifiertypes pp";        
+            + "SELECT "
+            + autoIncrVal
+            + ", pp.patientidentifiertypeid, pp.sort_order, false, pp.programid "
+            + "FROM program_patientidentifiertypes pp";
         executeSql( identifierSql );
-        
+
         executeSql( "DROP TABLE program_patientattributes" );
         executeSql( "DROP TABLE program_patientidentifiertypes" );
 
         executeSql( "ALTER TABLE patientattribute DROP COLUMN displayedInList" );
         executeSql( "ALTER TABLE patientidentifiertype DROP COLUMN personDisplayName" );
     }
-    
+
     private void updateUid()
     {
         updateUidColumn( "patientattribute" );
@@ -496,7 +500,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 +548,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='" + uid + "' WHERE property='gender' " );
 
                 // ---------------------------------------------------------------------
                 // Death date
@@ -567,9 +569,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='" + uid + "' WHERE property='deathDate' " );
 
                 // ---------------------------------------------------------------------
                 // registrationDate
@@ -591,9 +591,8 @@
 
                 // 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='" + uid + "' WHERE property='registrationDate' " );
 
                 // ---------------------------------------------------------------------
                 // isDead
@@ -614,9 +613,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='" + uid + "' WHERE property='isDead' " );
 
                 // ---------------------------------------------------------------------
                 // underAge
@@ -633,13 +630,10 @@
                     + "','Is under age', 'Is under age','"
                     + PatientAttribute.TYPE_TRACKER_ASSOCIATE + "', false, false, false)" );
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
-                    + max + ",isDead from patient where underAge=true" );
+                    + max + ",underage from patient where underAge=true" );
 
                 // 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' " );
 
                 // ---------------------------------------------------------------------
                 // DobType
@@ -684,9 +678,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='" + uid + "' WHERE property='dobType' " );
 
                 // -------------------------------------------------------------
                 // Birthdate
@@ -707,9 +699,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='" + uid + "' WHERE property='birthdate' " );
 
                 // -------------------------------------------------------------
                 // Age
@@ -730,9 +720,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='" + uid + "' WHERE property='age' " );
 
                 // -------------------------------------------------------------
                 // Phone number
@@ -807,7 +795,7 @@
 
                 executeSql( "ALTER TABLE patient DROP COLUMN gender" );
                 executeSql( "ALTER TABLE patient DROP COLUMN deathDate" );
-                executeSql( "ALTER TABLE patient DROP COLUMN registrationDate" );
+                executeSql( "ALTER TABLE patient DROP COLUMN registrationdate" );
                 executeSql( "ALTER TABLE patient DROP COLUMN isDead" );
                 executeSql( "ALTER TABLE patient DROP COLUMN underAge" );
                 executeSql( "ALTER TABLE patient DROP COLUMN dobType" );