← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5319: Update the patient-attribute-value when option-attribute-values are changes automatically.

 

------------------------------------------------------------
revno: 5319
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-12-07 09:20:11 +0700
message:
  Update the patient-attribute-value when option-attribute-values are changes automatically.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.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-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java	2011-08-02 09:12:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueService.java	2011-12-07 02:20:11 +0000
@@ -84,4 +84,6 @@
     
     int countSearchPatients( List<Integer> patientAttributeIds, List<String> searchTexts );
     
+    void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption);
+    
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueStore.java	2011-08-13 13:55:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueStore.java	2011-12-07 02:20:11 +0000
@@ -72,4 +72,6 @@
     int countSearchPatientAttributeValue(  PatientAttribute patientAttribute, String searchText );
     
     int countSearchPatients( List<Integer> patientAttributeIds, List<String> searchTexts );
+    
+    void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption);
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java	2011-08-02 09:12:51 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/DefaultPatientAttributeValueService.java	2011-12-07 02:20:11 +0000
@@ -240,4 +240,9 @@
     {
         return patientAttributeValueStore.countSearchPatients( patientAttributeIds, searchTexts );
     }
+
+    public void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption )
+    {
+        patientAttributeValueStore.updatePatientAttributeValues( patientAttributeOption );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java	2011-09-27 06:46:37 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java	2011-12-07 02:20:11 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.patient.PatientAttributeOption;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueStore;
+import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
  * @author Abyot Asalefew
@@ -48,6 +49,22 @@
     extends HibernateGenericStore<PatientAttributeValue>
     implements PatientAttributeValueStore
 {
+
+    // -------------------------------------------------------------------------
+    // Dependency
+    // -------------------------------------------------------------------------
+
+    private JdbcTemplate jdbcTemplate;
+
+    public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+    {
+        this.jdbcTemplate = jdbcTemplate;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation methods
+    // -------------------------------------------------------------------------
+
     public void saveVoid( PatientAttributeValue patientAttributeValue )
     {
         sessionFactory.getCurrentSession().save( patientAttributeValue );
@@ -236,9 +253,9 @@
 
             hql += " ( SELECT p" + index + " FROM Patient as p" + index + " JOIN p" + index
                 + ".identifiers as identifier" + index + " " + "WHERE lower(identifier" + index
-                + ".identifier)=lower('" + searchText + "') " + "OR (lower(p" + index
-                + ".firstName) LIKE lower('%" + firstName + "%') " + "AND lower(p" + index + ".middleName) = lower('"
-                + middleName + "') " + "AND lower(p" + index + ".lastName) LIKE lower('%" + lastName + "%')) ";
+                + ".identifier)=lower('" + searchText + "') " + "OR (lower(p" + index + ".firstName) LIKE lower('%"
+                + firstName + "%') " + "AND lower(p" + index + ".middleName) = lower('" + middleName + "') "
+                + "AND lower(p" + index + ".lastName) LIKE lower('%" + lastName + "%')) ";
 
             isSearchByAttribute = false;
         }
@@ -278,4 +295,12 @@
         return hql;
 
     }
+
+    public void updatePatientAttributeValues( PatientAttributeOption patientAttributeOption )
+    {
+        String sql = "UPDATE patientattributevalue SET value='" + patientAttributeOption.getName()
+            + "' WHERE patientattributeoptionid='" + patientAttributeOption.getId() + "'";
+        
+        jdbcTemplate.execute( sql );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2011-11-30 06:38:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2011-12-07 02:20:11 +0000
@@ -89,6 +89,7 @@
 		class="org.hisp.dhis.patientattributevalue.hibernate.HibernatePatientAttributeValueStore">
 		<property name="clazz" value="org.hisp.dhis.patientattributevalue.PatientAttributeValue" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="jdbcTemplate" ref="jdbcTemplate"/>
 	</bean>
 	
    <bean id="org.hisp.dhis.patient.PatientAttributeOptionStore"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java	2010-12-10 05:57:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/UpdatePatientAttributeAction.java	2011-12-07 02:20:11 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.patient.PatientAttributeOption;
 import org.hisp.dhis.patient.PatientAttributeOptionService;
 import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -68,6 +69,13 @@
         this.patientAttributeOptionService = patientAttributeOptionService;
     }
 
+    private PatientAttributeValueService patientAttributeValueService;
+
+    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
+    {
+        this.patientAttributeValueService = patientAttributeValueService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -127,7 +135,7 @@
     {
         this.noChars = noChars;
     }
-    
+
     private boolean groupBy;
 
     public void setGroupBy( boolean groupBy )
@@ -150,7 +158,7 @@
         patientAttribute.setMandatory( mandatory );
         patientAttribute.setInheritable( inheritable );
         patientAttribute.setNoChars( noChars );
-        
+
         if ( groupBy )
         {
             PatientAttribute patientAtt = patientAttributeService.getPatientAttributeByGroupBy( true );
@@ -162,8 +170,7 @@
             patientAttribute.setMandatory( true );
         }
         patientAttribute.setGroupBy( groupBy );
-        
-        
+
         HttpServletRequest request = ServletActionContext.getRequest();
 
         Collection<PatientAttributeOption> attributeOptions = patientAttributeOptionService.get( patientAttribute );
@@ -178,6 +185,7 @@
                 {
                     option.setName( value.trim() );
                     patientAttributeOptionService.updatePatientAttributeOption( option );
+                    patientAttributeValueService.updatePatientAttributeValues( option );
                 }
             }
         }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2011-11-14 12:19:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2011-12-07 02:20:11 +0000
@@ -106,6 +106,8 @@
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 		<property name="patientAttributeOptionService"
 			ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
+		<property name="patientAttributeValueService"
+			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
 
 	<bean