← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10858: [mobile] fix find last patient error

 

------------------------------------------------------------
revno: 10858
committer: Hong Em <em.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-05-16 15:40:58 +0700
message:
  [mobile] fix find last patient error
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/api/mobile/ActivityReportingService.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
  dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.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-05-15 03:23:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2013-05-16 08:40:58 +0000
@@ -244,5 +244,5 @@
 	
 	Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate );
 
-        Patient getLatestPatient(Integer orgunitId);
+        Patient getLatestPatient(Integer patientId);
 }

=== 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-05-15 03:23:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2013-05-16 08:40:58 +0000
@@ -85,6 +85,6 @@
 
     Collection<Integer> getRegistrationOrgunitIds( Date startDate, Date endDate );
 
-    Patient getLatestPatient(Integer orgunitId);
+    Patient getLatestPatient(Integer patientId);
 
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2013-05-16 03:53:39 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2013-05-16 08:40:58 +0000
@@ -83,7 +83,7 @@
 
     public Program findProgram( String programInfo )
         throws NotAllowedException;
-    public Patient findLatestPatient(int orgUnitId) throws NotAllowedException;
+    public Patient findLatestPatient() throws NotAllowedException;
     
     public String savePatient(Patient patient, int orgUnitId) throws NotAllowedException;
 

=== 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-05-16 08:06:31 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-05-16 08:40:58 +0000
@@ -1670,11 +1670,10 @@
     }
 
     @Override
-    public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findLatestPatient( int orgUnitId )
+    public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findLatestPatient()
         throws NotAllowedException
     {
-
-        Patient patient = (Patient) this.patientService.getLatestPatient( orgUnitId );
+        Patient patient = (Patient) this.patientService.getLatestPatient( this.getPatientId() );
 
         org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile = getPatientModel( patient );
         return patientMobile;
@@ -1782,7 +1781,6 @@
         patientWeb.setAttributes( patientAttributeSet );
 
         patientId = patientService.createPatient( patientWeb, null, null, patientAttributeValues );
-        
 
         return PATIENT_REGISTERED;
 

=== 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-05-15 03:23:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2013-05-16 08:40:58 +0000
@@ -601,10 +601,10 @@
     }
 
     @Override
-    public Patient getLatestPatient(Integer orgunitId)
+    public Patient getLatestPatient(Integer patientId)
     {
         
-        return patientStore.getLatestPatient(orgunitId);
+        return patientStore.getLatestPatient(patientId);
     }
 
 }

=== 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-05-15 03:23:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-05-16 08:40:58 +0000
@@ -713,12 +713,13 @@
     }
 
     @Override
-    public Patient getLatestPatient(Integer orgunitId)
+    public Patient getLatestPatient( Integer patientId )
     {
         Patient patient = new Patient();
-        String hql = "select p from Patient p where p.organisationUnit.id = " + orgunitId + " order by p.id DESC";
+        String hql = "select p from Patient p where p.id = " + patientId;
         Query query = getQuery( hql );
         query.setMaxResults( 1 );
+
         patient = (Patient) query.uniqueResult();
 
         return patient;

=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-05-16 03:53:39 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-05-16 08:40:58 +0000
@@ -462,10 +462,9 @@
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findLatestPerson" )
     @ResponseBody
-    public Patient findLatestPerson( @PathVariable
-    int id )
+    public Patient findLatestPerson()
         throws NotAllowedException
     {
-        return activityReportingService.findLatestPatient( id );
+        return activityReportingService.findLatestPatient();
     }
 }