← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12005: [mobile] support j2me to register and enroll in one flow

 

------------------------------------------------------------
revno: 12005
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Tue 2013-09-10 16:00:47 +0700
message:
  [mobile] support j2me to register and enroll in one flow
modified:
  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-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.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-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-09-08 08:36:32 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2013-09-10 09:00:47 +0000
@@ -94,7 +94,7 @@
     public Patient findLatestPatient()
         throws NotAllowedException;
 
-    public Integer savePatient( Patient patient, int orgUnitId )
+    public Integer savePatient( Patient patient, int orgUnitId, String programId )
         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-09-10 07:22:13 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-09-10 09:00:47 +0000
@@ -1702,11 +1702,12 @@
     {
         patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
 
-        Collection<Program> programs = programService.getAllPrograms();
-        for ( Program program : programs )
-        {
-            patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
-        }
+        // Collection<Program> programs = programService.getAllPrograms();
+        // for ( Program program : programs )
+        // {
+        // patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes()
+        // );
+        // }
         return patientIdentifierTypes;
 
     }
@@ -1796,7 +1797,7 @@
     }
 
     @Override
-    public Integer savePatient( org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient, int orgUnitId )
+    public Integer savePatient( org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient, int orgUnitId, String programIdText )
         throws NotAllowedException
     {
         org.hisp.dhis.patient.Patient patientWeb = new org.hisp.dhis.patient.Patient();
@@ -1900,6 +1901,17 @@
         patientWeb.setAttributes( patientAttributeSet );
 
         patientId = patientService.createPatient( patientWeb, null, null, patientAttributeValues );
+        
+        try
+        {
+            int programId = Integer.parseInt( programIdText );
+            this.enrollProgram( patientId + "-" + programId );
+        }
+        catch ( Exception e )
+        {
+            return patientId;
+        }
+        
 
         return patientId;
 

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java	2013-09-10 09:00:47 +0000
@@ -55,8 +55,8 @@
         Patient patientA = this.createLWUITPatient( 'A' );
         Patient patientB = this.createLWUITPatient( 'B' );
 
-        int patientAId = activityReportingService.savePatient( patientA, 779 );
-        int patientBId = activityReportingService.savePatient( patientB, 779 );
+        int patientAId = activityReportingService.savePatient( patientA, 779, "" );
+        int patientBId = activityReportingService.savePatient( patientB, 779, "" );
 
         patientA = activityReportingService.findPatient( patientAId );
         assertEquals( patientAId, patientA.getId() );

=== 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-09-10 07:22:13 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-09-10 09:00:47 +0000
@@ -446,10 +446,10 @@
 
     @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/registerPerson" )
     @ResponseBody
-    public String savePatient( @PathVariable int id, @RequestBody Patient patient )
+    public String savePatient( @PathVariable int id, @RequestBody Patient patient, @RequestHeader( "programid" ) String programId )
         throws NotAllowedException
     {
-        if ( activityReportingService.savePatient( patient, id ) != null )
+        if ( activityReportingService.savePatient( patient, id, programId ) != null )
         {
             return PATIENT_REGISTERED;
         }