← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8352: Add visitor property for PatientAudit object and display it into dashboard history.

 

------------------------------------------------------------
revno: 8352
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-03 13:04:22 +0700
message:
  Add visitor property for PatientAudit object and display it into dashboard history.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAudit.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAuditService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAuditStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAudit.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties


--
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/patient/PatientAudit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAudit.java	2012-09-26 05:19:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAudit.java	2012-10-03 06:04:22 +0000
@@ -39,6 +39,8 @@
     private int id;
 
     private Patient patient;
+    
+    private String visitor;
 
     private Date date;
 
@@ -51,11 +53,11 @@
 
     }
 
-    public PatientAudit( Patient patient, Date date )
+    public PatientAudit( Patient patient, Date date, String visitor )
     {
-        super();
         this.patient = patient;
         this.date = date;
+        this.visitor = visitor;
     }
 
     // -------------------------------------------------------------------------
@@ -92,4 +94,14 @@
         this.date = date;
     }
 
+    public String getVisitor()
+    {
+        return visitor;
+    }
+
+    public void setVisitor( String visitor )
+    {
+        this.visitor = visitor;
+    }
+
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditService.java	2012-09-26 05:19:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditService.java	2012-10-03 06:04:22 +0000
@@ -49,6 +49,6 @@
 
     Collection<PatientAudit> getPatientAudits( Patient patient );
 
-    PatientAudit get( Patient patient, Date date );
+    PatientAudit getPatientAudit( String visitor, Date date );
 
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditStore.java	2012-09-26 05:19:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAuditStore.java	2012-10-03 06:04:22 +0000
@@ -41,5 +41,5 @@
 {
     Collection<PatientAudit> get( Patient patient );
 
-    PatientAudit get( Patient patient, Date date );
+    PatientAudit get( String visitor, Date date );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAuditService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAuditService.java	2012-09-26 05:19:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAuditService.java	2012-10-03 06:04:22 +0000
@@ -79,9 +79,9 @@
     }
 
     @Override
-    public PatientAudit get( Patient patient, Date date )
+    public PatientAudit getPatientAudit( String visitor, Date date )
     {
-        return patientAuditStore.get( patient, date );
+        return patientAuditStore.get( visitor, date );
     }
 
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAuditStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAuditStore.java	2012-09-26 05:19:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAuditStore.java	2012-10-03 06:04:22 +0000
@@ -53,9 +53,9 @@
     }
 
     @Override
-    public PatientAudit get( Patient patient, Date date )
+    public PatientAudit get( String visitor, Date date )
     {
-        return (PatientAudit) getCriteria( Restrictions.eq( "patient", patient ), Restrictions.eq( "date", date ) )
+        return (PatientAudit) getCriteria( Restrictions.eq( "visitor", visitor ), Restrictions.eq( "date", date ) )
             .uniqueResult();
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAudit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAudit.hbm.xml	2012-09-26 05:19:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/PatientAudit.hbm.xml	2012-10-03 06:04:22 +0000
@@ -14,6 +14,7 @@
 			class="org.hisp.dhis.patient.Patient" foreign-key="fk_patientauditid_patientid" />
 
 		<property name="date" />
-
+		
+		<property name="visitor" />
 	</class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2012-09-26 05:19:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2012-10-03 06:04:22 +0000
@@ -43,6 +43,7 @@
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
+import org.hisp.dhis.user.CurrentUserService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -68,6 +69,8 @@
 
     private PatientAuditService patientAuditService;
 
+    private CurrentUserService currentUserService;
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -85,7 +88,7 @@
     private Collection<ProgramInstance> activeProgramInstances;
 
     private Collection<ProgramInstance> completedProgramInstances;
-    
+
     private Collection<PatientAudit> patientAudits;
 
     // -------------------------------------------------------------------------
@@ -102,6 +105,11 @@
         this.patientAttributeValueService = patientAttributeValueService;
     }
 
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
     public Collection<ProgramInstance> getActiveProgramInstances()
     {
         return activeProgramInstances;
@@ -192,15 +200,16 @@
         }
 
         patientAudits = patientAuditService.getPatientAudits( patient );
-       
+
         long millisInDay = 60 * 60 * 24 * 1000;
         long currentTime = new Date().getTime();
         long dateOnly = (currentTime / millisInDay) * millisInDay;
-        Date date = new Date(dateOnly);        
-        PatientAudit patientAudit = patientAuditService.get( patient, date );
+        Date date = new Date( dateOnly );
+        String visitor = currentUserService.getCurrentUsername();
+        PatientAudit patientAudit = patientAuditService.getPatientAudit( visitor, date );
         if ( patientAudit == null )
         {
-            patientAudit = new PatientAudit( patient, date );
+            patientAudit = new PatientAudit( patient, date, visitor );
             patientAuditService.savePatientAudit( patientAudit );
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-09-27 08:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-10-03 06:04:22 +0000
@@ -997,6 +997,7 @@
 			ref="org.hisp.dhis.relationship.RelationshipService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="patientAuditService" ref="org.hisp.dhis.patient.PatientAuditService" />
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 	</bean>
 
 	<!-- Comment -->

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-10-02 08:42:42 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-10-03 06:04:22 +0000
@@ -461,7 +461,7 @@
 move_to_dashboard_of = Move to dashboard of
 management = Management
 change_location = Change location
-user_access = User access
+visitor = Visitor
 history = History
 use_calendar = Use calendar
 export_xls = Export XLS

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2012-10-02 06:59:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2012-10-03 06:04:22 +0000
@@ -207,14 +207,14 @@
 	<table class='mainPageTable'>
 		<thead>
 		<tr>
-			<th>$i18n.getString("user_access")</th>
+			<th>$i18n.getString("visitor")</th>
 			<th>$i18n.getString("date")</th>
 		</tr>
 		</thead>
 		#set( $mark = false )
 		#foreach( $patientAudit in $patientAudits )
 		<tr #alternate( $mark )>
-			<td>$patientAudit.patient.getFullName()</td>
+			<td>$patientAudit.visitor</td>
 			<td>$format.formatDate($patientAudit.date)</td>
 		</tr>
 		#set( $mark = !$mark )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-10-03 04:27:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-10-03 06:04:22 +0000
@@ -143,7 +143,6 @@
 design_data_entry_form=Design data entry form
 no_of_char=Number of characters
 letter_only=Letters only
-duration_in_days=Duration in days
 program_attribute=Program Attribute
 program_attribute_management=Program attribute management
 create_new_program_attribute=Create new program attribute