← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9900: Improve loading PatientDashboard.

 

------------------------------------------------------------
revno: 9900
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-02-26 10:21:49 +0700
message:
  Improve loading PatientDashboard.
modified:
  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/webapp/dhis-web-caseentry/patientDashboard.vm


--
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-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	2013-02-18 08:23:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2013-02-26 03:21:49 +0000
@@ -41,7 +41,6 @@
 import org.hisp.dhis.patient.PatientAudit;
 import org.hisp.dhis.patient.PatientAuditService;
 import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
@@ -50,7 +49,6 @@
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
-import org.hisp.dhis.relationship.RelationshipTypeService;
 import org.hisp.dhis.user.CurrentUserService;
 
 import com.opensymphony.xwork2.Action;
@@ -81,12 +79,6 @@
 
     private PatientAttributeService patientAttributeService;
 
-    private PatientIdentifierTypeService identifierTypeService;
-
-    private ProgramService programService;
-
-    private RelationshipTypeService relationshipTypeService;
-
     private I18nFormat format;
 
     // -------------------------------------------------------------------------
@@ -109,13 +101,9 @@
 
     private Collection<PatientAudit> patientAudits;
 
-    private Map<String, String> attributeMap = new HashMap<String, String>();
-
-    private Map<String, String> identifierMap = new HashMap<String, String>();
-
-    private Map<Integer, String> programMap = new HashMap<Integer, String>();
-
-    private Map<String, Relationship> relationshipMap = new HashMap<String, Relationship>();
+    private Map<PatientAttribute, String> attributeMap = new HashMap<PatientAttribute, String>();
+    
+    Collection<Relationship> relationships = new HashSet<Relationship>();
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -125,57 +113,17 @@
     {
         this.patientAuditService = patientAuditService;
     }
-
-    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
-    {
-        this.identifierTypeService = identifierTypeService;
-    }
-
-    public Map<String, String> getAttributeMap()
+    
+    public Map<PatientAttribute, String> getAttributeMap()
     {
         return attributeMap;
     }
-
-    public Map<String, String> getIdentifierMap()
-    {
-        return identifierMap;
-    }
-
-    public Map<Integer, String> getProgramMap()
-    {
-        return programMap;
-    }
-
-    public Map<String, Relationship> getRelationshipMap()
-    {
-        return relationshipMap;
-    }
-
-    public void setProgramService( ProgramService programService )
-    {
-        this.programService = programService;
-    }
-
-    public void setRelationshipTypeService( RelationshipTypeService relationshipTypeService )
-    {
-        this.relationshipTypeService = relationshipTypeService;
-    }
-
+    
     public void setFormat( I18nFormat format )
     {
         this.format = format;
     }
-
-    public void setAttributeValues( Collection<PatientAttributeValue> attributeValues )
-    {
-        this.attributeValues = attributeValues;
-    }
-
-    public void setActiveProgramInstances( Collection<ProgramInstance> activeProgramInstances )
-    {
-        this.activeProgramInstances = activeProgramInstances;
-    }
-
+    
     public void setPatientAttributeService( PatientAttributeService patientAttributeService )
     {
         this.patientAttributeService = patientAttributeService;
@@ -262,13 +210,6 @@
 
         attributeValues = patientAttributeValueService.getPatientAttributeValues( patient );
 
-        for ( PatientAttributeValue attributeValue : attributeValues )
-        {
-            Integer id = attributeValue.getPatientAttribute().getId();
-            attributeMap.put( patientAttributeService.getPatientAttribute( id ).getDisplayName(),
-                attributeValue.getValue() );
-        }
-
         Collection<PatientAttribute> calAttributes = patientAttributeService
             .getPatientAttributesByValueType( PatientAttribute.TYPE_CALCULATED );
 
@@ -278,7 +219,7 @@
                 format );
             if ( value != null )
             {
-                attributeMap.put( calAttribute.getDisplayName(), value + "" );
+                attributeMap.put( calAttribute, value + "" );
             }
         }
 
@@ -288,32 +229,12 @@
 
         identifiers = patient.getIdentifiers();
 
-        for ( PatientIdentifier identifier : identifiers )
-        {
-            if ( identifier.getIdentifierType() != null )
-            {
-                identifierMap.put(
-                    identifierTypeService.getPatientIdentifierType( identifier.getIdentifierType().getId() )
-                        .getDisplayName(), identifier.getIdentifier() );
-            }
-            else
-            {
-                identifierMap.put( null, identifier.getIdentifier() );
-            }
-        }
-
         // ---------------------------------------------------------------------
         // Get relationship
         // ---------------------------------------------------------------------
 
-        Collection<Relationship> relationships = relationshipService.getRelationshipsForPatient( patient );
-
-        for ( Relationship relationship : relationships )
-        {
-            relationshipMap.put( relationshipTypeService.getRelationshipType( relationship.getId() ).getDisplayName(),
-                relationship );
-        }
-
+        relationships = relationshipService.getRelationshipsForPatient( patient );
+        
         Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient );
 
         activeProgramInstances = new HashSet<ProgramInstance>();
@@ -330,12 +251,6 @@
             {
                 activeProgramInstances.add( programInstance );
             }
-
-            Integer programId = programInstance.getProgram().getId();
-            if ( !programMap.containsKey( programId ) )
-            {
-                programMap.put( programId, programService.getProgram( programId ).getDisplayName() );
-            }
         }
 
         // ---------------------------------------------------------------------

=== 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	2013-02-22 04:49:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-02-26 03:21:49 +0000
@@ -1063,11 +1063,6 @@
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="identifierTypeService"
-			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="relationshipTypeService"
-			ref="org.hisp.dhis.relationship.RelationshipTypeService" />
-		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<!-- Comment -->

=== 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	2013-02-21 04:05:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientDashboard.vm	2013-02-26 03:21:49 +0000
@@ -1,6 +1,3 @@
-$identifierMap
-
-
 <h3>
  <a name="mainPagelink" href="javascript:onClickBackBtn();">$i18n.getString( 'patient_management' )</a>
  &#8226; $i18n.getString( 'patient_dashboard' )
@@ -55,27 +52,38 @@
 						#end
 					</td>
 				</tr>
-				#foreach( $identifierTypeName in $identifierMap.ketSet() )
+				#foreach( $identifier in $identifiers )
 				<tr>
-					#if($!identifier)
-						<td>$identifierTypeName</td>
+					#if($!identifier.identifierType)
+						<td>$identifier.identifierType.displayName</td>
 					#else
 						<td>$i18n.getString("system_identifier")</td>
 					#end
-					<td>$identifierMap.get($identifierTypeName)</td>
-				</tr>
-				#end
-				#foreach( $attributeName in $attributeMap.keySet() )
+					<td>$identifier.identifier</td>
+				</tr>
+				#end
+				
+				#foreach( $attribute in $attributeMap.keySet() )
+				<tr class='bold'>
+					<td>$attribute.displayName</td>
+					<td>
+						 $attributeMap.get( $attribute)
+					</td>
+				</tr>
+				#end
+				
+				#foreach( $attributeValue in $attributeValues )
 				<tr>
-					#set( $attributeValue=$$attributeMap.get($attributeName) )
-					<td>$attributeName</td>
+					<td>$attributeValue.patientAttribute.displayName</td>
 					<td>
-						#if($attributeValue=='true')
-							$i18n.getString("yes")
-						#elseif( $attributeValue=='false')
-							$i18n.getString("no")
+						#if($attributeValue.patientAttribute.valueType=='YES/NO')
+							#if($attributeValue.value)
+								$i18n.getString("yes")
+							#else
+								$i18n.getString("no")
+							#end
 						#else
-							$encoder.htmlEncode($attributeValue)
+							$encoder.htmlEncode($attributeValue.value)
 						#end	
 					</td>
 				</tr>