← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12630: PatientStore, using entities instead of integers as arguments

 

------------------------------------------------------------
revno: 12630
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-10-14 13:13:33 +0200
message:
  PatientStore, using entities instead of integers as arguments
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.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-api/src/main/java/org/hisp/dhis/patient/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2013-10-14 10:24:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2013-10-14 11:13:33 +0000
@@ -230,7 +230,7 @@
 
     Collection<Patient> getPatientsByPhone( String phoneNumber, Integer min, Integer max );
 
-    Collection<Patient> getPatientByFullname( String fullName, Integer orgunitId );
+    Collection<Patient> getPatientByFullname( String fullName, OrganisationUnit organisationUnit );
 
     Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate );
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2013-10-14 10:24:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2013-10-14 11:13:33 +0000
@@ -71,7 +71,7 @@
 
     Collection<Patient> getByPhoneNumber( String phoneNumber, Integer min, Integer max );
 
-    Collection<Patient> getByFullName( String fullName, Integer orgunitId );
+    Collection<Patient> getByFullName( String fullName, OrganisationUnit organisationUnit );
 
     Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate );
 

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-10-13 18:14:00 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-10-14 11:13:33 +0000
@@ -562,7 +562,9 @@
     {
         if ( isNumber( keyword ) == false )
         {
-            List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( keyword, orgUnitId );
+            OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+            
+            List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( keyword, organisationUnit );
 
             if ( patients.size() > 1 )
             {
@@ -1395,8 +1397,11 @@
         }
         else
         {
+
+            OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+            
             String fullName = enrollmentRelationship.getPersonBName();
-            List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( fullName, orgUnitId );
+            List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( fullName, organisationUnit );
 
             // remove the own searcher
             patients = removeIfDuplicated( patients, enrollmentRelationship.getPersonAId() );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2013-10-14 10:24:31 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2013-10-14 11:13:33 +0000
@@ -652,9 +652,9 @@
     }
 
     @Override
-    public Collection<Patient> getPatientByFullname( String fullName, Integer orgunitId )
+    public Collection<Patient> getPatientByFullname( String fullName, OrganisationUnit organisationUnit )
     {
-        return patientStore.getByFullName( fullName, orgunitId );
+        return patientStore.getByFullName( fullName, organisationUnit );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-10-14 10:30:06 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-10-14 11:13:33 +0000
@@ -795,16 +795,16 @@
 
     @Override
     //TODO this method must be changed - cannot retrieve one by one
-    public Collection<Patient> getByFullName( String fullName, Integer orgunitId )
+    public Collection<Patient> getByFullName( String fullName, OrganisationUnit organisationUnit )
     {
         List<Patient> patients = new ArrayList<Patient>();
 
         fullName = fullName.toLowerCase();
         String sql = "SELECT patientid FROM patient where lower(name) = '" + fullName + "'";
         
-        if ( orgunitId != null && orgunitId != 0 )
+        if ( organisationUnit != null )
         {
-            sql += " and organisationunitid=" + orgunitId;
+            sql += " and organisationunitid=" + organisationUnit.getId();
         }
 
         try