← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13701: Reverted r 13694 and parts of 13695

 

------------------------------------------------------------
revno: 13701
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-01-13 16:30:27 +0100
message:
  Reverted r 13694 and parts of 13695
modified:
  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/resources/org/hisp/dhis/program/hibernate/ProgramPatientAttribute.hbm.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientIdentifierType.hbm.xml


--
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-13 01:42:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2014-01-13 15:30:27 +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,28 +307,24 @@
     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" );
@@ -500,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 );
@@ -548,7 +544,9 @@
 
                 // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "gender", uid );
-                executeSql( "UPDATE validationcriteria SET property='" + uid + "' WHERE property='gender' " );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
+                    + " and property='gender' " );
 
                 // ---------------------------------------------------------------------
                 // Death date
@@ -569,7 +567,9 @@
 
                 // Update custom entry form && Validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "deathDate", uid );
-                executeSql( "UPDATE validationcriteria SET property='" + uid + "' WHERE property='deathDate' " );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
+                    + " and property='deathDate' " );
 
                 // ---------------------------------------------------------------------
                 // registrationDate
@@ -591,8 +591,9 @@
 
                 // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "registrationDate", uid );
-
-                executeSql( "UPDATE validationcriteria SET property='" + uid + "' WHERE property='registrationDate' " );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
+                    + " and property='registrationDate' " );
 
                 // ---------------------------------------------------------------------
                 // isDead
@@ -613,7 +614,9 @@
 
                 // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "isDead", uid );
-                executeSql( "UPDATE validationcriteria SET property='" + uid + "' WHERE property='isDead' " );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
+                    + " and property='isDead' " );
 
                 // ---------------------------------------------------------------------
                 // underAge
@@ -630,10 +633,13 @@
                     + "','Is under age', 'Is under age','"
                     + PatientAttribute.TYPE_TRACKER_ASSOCIATE + "', false, false, false)" );
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
-                    + max + ",underage from patient where underAge=true" );
+                    + max + ",isDead 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
@@ -678,7 +684,9 @@
 
                 // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "dobType", uid );
-                executeSql( "UPDATE validationcriteria SET property='" + uid + "' WHERE property='dobType' " );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
+                    + " and property='dobType' " );
 
                 // -------------------------------------------------------------
                 // Birthdate
@@ -699,7 +707,9 @@
 
                 // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "birthDate", uid );
-                executeSql( "UPDATE validationcriteria SET property='" + uid + "' WHERE property='birthdate' " );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
+                    + " and property='birthDate' " );
 
                 // -------------------------------------------------------------
                 // Age
@@ -720,7 +730,9 @@
 
                 // Update custom entry form && validation criteria
                 removeFixedAttributeInCustomRegistrationForm( "age", uid );
-                executeSql( "UPDATE validationcriteria SET property='" + uid + "' WHERE property='age' " );
+                executeSql( "UPDATE validationcriteria SET property='" + resultSet.getInt( "property" )
+                    + "' WHERE validationcriteriaid=" + resultSet.getInt( "validationcriteriaid" )
+                    + " and property='age' " );
 
                 // -------------------------------------------------------------
                 // Phone number
@@ -795,7 +807,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" );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientAttribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientAttribute.hbm.xml	2014-01-13 03:25:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientAttribute.hbm.xml	2014-01-13 15:30:27 +0000
@@ -11,7 +11,7 @@
     </id>
     
     <many-to-one name="patientAttribute" class="org.hisp.dhis.patient.PatientAttribute" 
-        column="patientattributeid" foreign-key="fk_program_attributeid" />
+        column="attributeid" foreign-key="fk_program_attributeid" />
 
     <property name="sortOrder" column="sort_order" />
     

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientIdentifierType.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientIdentifierType.hbm.xml	2014-01-13 03:25:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramPatientIdentifierType.hbm.xml	2014-01-13 15:30:27 +0000
@@ -11,7 +11,7 @@
     </id>
     
 	<many-to-one name="patientIdentifierType" class="org.hisp.dhis.patient.PatientIdentifierType" 
-	   column="patientidentifiertypeid" foreign-key="fk_program_identifiertypeid" />
+	   column="identifiertypeid" foreign-key="fk_program_identifiertypeid" />
 
     <property name="sortOrder" column="sort_order" />