← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2314: Fix bug: Exception when sorting patients by an attribute.

 

------------------------------------------------------------
revno: 2314
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-10-05 13:44:36 +0700
message:
  Fix bug: Exception when sorting patients by an attribute.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.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-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java	2010-09-27 09:48:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java	2010-10-05 06:44:36 +0000
@@ -267,7 +267,7 @@
 
             //System.out.println("listAll startPos "+  startPos+" endPos "+ endPos );
             patients = patientService.getPatientsByOrgUnitAttr( organisationUnit , startPos,endPos, patientAttribute );
-            
+
             if( patients != null && patients.size() > 0 ) 
             {
                 //System.out.println("patients size = "+patients.size());
@@ -280,8 +280,10 @@
                     mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
                     if(sortPatientAttributeId!=null && patientAttribute!=null)
                     {
-                        mapPatientPatientAttr.put(patient, 
-                        		patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+                        PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute );
+                        String value = (attributeValue == null )?"" : attributeValue.getValue();
+                    
+                        mapPatientPatientAttr.put(patient, value);
                     }
                 }
             }
@@ -325,11 +327,14 @@
                     mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
                     if(sortPatientAttributeId!=null && patientAttribute!=null)
                     {
-                        mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+                        PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute );
+                        String value = (attributeValue == null )?"" : attributeValue.getValue();
+                    
+                        mapPatientPatientAttr.put(patient, value);
                     }
                 }
             }
-System.out.println("\n patientAttributeValueService.searchPatientAttributeValue : " + patients);       
+
             return SUCCESS;
         }
 
@@ -360,7 +365,10 @@
                 {
                     if(sortPatientAttributeId!=null && patientAttribute!=null)
                     {
-                        mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+                        PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute );
+                        String value = (attributeValue == null )?"" : attributeValue.getValue();
+                    
+                        mapPatientPatientAttr.put(patient, value);
                     }
                 }
             }
@@ -398,7 +406,10 @@
                     mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
                     if(sortPatientAttributeId!=null && patientAttribute!=null)
                     {
-                        mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+                        PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute );
+                        String value = (attributeValue == null )?"" : attributeValue.getValue();
+                    
+                        mapPatientPatientAttr.put(patient, value);
                     }
                 }
             }
@@ -439,7 +450,10 @@
                 {
                     if(sortPatientAttributeId!=null && patientAttribute!=null)
                     {
-                        mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+                        PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute );
+                        String value = (attributeValue == null )?"" : attributeValue.getValue();
+                    
+                        mapPatientPatientAttr.put(patient, value);
                     }
                 }
             }
@@ -467,7 +481,10 @@
                 mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
                 if(sortPatientAttributeId!=null && patientAttribute!=null)
                 {
-                    mapPatientPatientAttr.put(patient, patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ).getValue());
+                    PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute );
+                    String value = (attributeValue == null )?"" : attributeValue.getValue();
+                
+                    mapPatientPatientAttr.put(patient, value);
                 }
             }
         }