← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13763: Fixed bug in tablealterator.

 

------------------------------------------------------------
revno: 13763
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-01-17 13:59:51 +0700
message:
  Fixed bug in tablealterator.
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/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.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-17 06:08:31 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2014-01-17 06:59:51 +0000
@@ -290,13 +290,13 @@
         updateCoordinatesProgramStageInstance();
 
         addPatientAttributes();
-        
+
         executeSql( "ALTER TABLE program DROP COLUMN useBirthDateAsIncidentDate" );
         executeSql( "ALTER TABLE program DROP COLUMN useBirthDateAsEnrollmentDate" );
 
         executeSql( "UPDATE patientattribute SET displayinlistnoprogram=false WHERE displayinlistnoprogram is null" );
         executeSql( "UPDATE patientidentifiertype SET displayinlistnoprogram=false WHERE displayinlistnoprogram is null" );
-        
+
         executeSql( "ALTER TABLE patientidentifiertype DROP COLUMN persondisplayname" );
 
         updateProgramAttributes();
@@ -333,7 +333,7 @@
 
         executeSql( "DROP TABLE program_patientidentifiertypes." );
         log.info( "Dropped program_patientidentifiertypes table." );
-        
+
     }
 
     private void updateUid()
@@ -775,6 +775,15 @@
                 executeSql( "UPDATE validationcriteria SET property='age' WHERE property='age' " );
 
                 // -------------------------------------------------------------
+                // Update Case Aggregate Query Builder
+                // -------------------------------------------------------------
+
+                source = "[CP" + CaseAggregationCondition.SEPARATOR_OBJECT + "age]";
+                target = "[" + CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE
+                    + CaseAggregationCondition.SEPARATOR_OBJECT + max + ".age]";
+                updateFixedAttributeInCaseAggregate( source, target );
+
+                // -------------------------------------------------------------
                 // Phone number
                 // -------------------------------------------------------------
 
@@ -800,20 +809,12 @@
                 removeFixedAttributeInCustomRegistrationForm( "phoneNumber", uid );
 
                 // -------------------------------------------------------------
-                // Update Case Aggregate Query Builder
-                // -------------------------------------------------------------
-
-                source = "[CP" + CaseAggregationCondition.SEPARATOR_OBJECT + "age]";
-                target = "[" + CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE
-                    + CaseAggregationCondition.SEPARATOR_OBJECT + max + ".age]";
-                updateFixedAttributeInCaseAggregate( source, target );
-
-                // -------------------------------------------------------------
                 // Patient full name
                 // -------------------------------------------------------------
 
                 log.info( "Inserting dynamic atribute called Full name" );
-
+               
+                max ++;
                 uid = CodeGenerator.generateCode();
                 executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES ("
                     + max
@@ -827,7 +828,7 @@
                 log.info( "Inserting data into Full name" );
 
                 executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid,"
-                    + max + ",name from patient where name is not null" );
+                    + max + ",\"name\" from patient where name is not null" );
 
                 // Update custom entry form
                 removeFixedAttributeInCustomRegistrationForm( "fullName", uid );
@@ -897,7 +898,6 @@
         }
         catch ( Exception ex )
         {
-            ex.printStackTrace();
         }
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2014-01-16 06:21:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2014-01-17 06:59:51 +0000
@@ -329,7 +329,7 @@
             + " INNER JOIN userinfo uif " 
             + " ON pav.value=concat(uif.userinfoid ,'') "
             + "    WHERE pi.status = " + ProgramInstance.STATUS_ACTIVE
-            + "      and pa.valueType='phoneNumber' "
+            + "      and pa.valueType='users' "
             + "      and uif.phonenumber is not NULL and uif.phonenumber != '' "
             + "      and prm.templatemessage is not NULL and prm.templatemessage != '' "
             + "      and pg.type=1 and prm.daysallowedsendmessage is not null " 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2014-01-16 06:21:47 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2014-01-17 06:59:51 +0000
@@ -619,7 +619,7 @@
             + "               ON pav.value=concat(uif.userinfoid ,'') "
             + " WHERE pi.status="
             + ProgramInstance.STATUS_ACTIVE
-            + " and pa.valueType='phoneNumber' and uif.phonenumber is not NULL and uif.phonenumber != '' "
+            + " and pa.valueType='users' and uif.phonenumber is not NULL and uif.phonenumber != '' "
             + "               and prm.templatemessage is not NULL and prm.templatemessage != '' "
             + "               and pg.type=1 and prm.daysallowedsendmessage is not null "
             + "               and psi.executiondate is null "