← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12829: generate repeatable event[j2me]

 

------------------------------------------------------------
revno: 12829
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-30 16:29:07 +0700
message:
  generate repeatable event[j2me]
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-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.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-10-28 09:53:18 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2013-10-30 09:29:07 +0000
@@ -105,5 +105,8 @@
 
     public Notification handleLostToFollowUp( LostEvent lostEvent )
         throws NotAllowedException;
+    
+    public Patient generateRepeatableEvent( int orgUnitId, String eventInfo )
+        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-10-29 10:27:23 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-10-30 09:29:07 +0000
@@ -152,6 +152,12 @@
     private org.hisp.dhis.mobile.service.ModelMapping modelMapping;
 
     private PatientIdentifierTypeService patientIdentifierTypeService;
+    
+    private CurrentUserService currentUserService;
+    
+    private MessageService messageService;
+    
+    private SmsSender smsSender;
 
     @Autowired
     private OrganisationUnitService organisationUnitService;
@@ -166,46 +172,23 @@
         this.patientIdentifierTypeService = patientIdentifierTypeService;
     }
 
-    private CurrentUserService currentUserService;
-
     @Required
     public void setCurrentUserService( CurrentUserService currentUserService )
     {
         this.currentUserService = currentUserService;
     }
 
-    private MessageService messageService;
-
     @Required
     public void setMessageService( MessageService messageService )
     {
         this.messageService = messageService;
     }
 
-    private SmsSender smsSender;
-
     public void setSmsSender( SmsSender smsSender )
     {
         this.smsSender = smsSender;
     }
 
-    public PatientIdentifierTypeService getPatientIdentifierTypeService()
-    {
-        return patientIdentifierTypeService;
-    }
-
-    private Collection<PatientIdentifier> patientIdentifiers;
-
-    public Collection<PatientIdentifier> getPatientIdentifiers()
-    {
-        return patientIdentifiers;
-    }
-
-    public void setPatientIdentifiers( Collection<PatientIdentifier> patientIdentifiers )
-    {
-        this.patientIdentifiers = patientIdentifiers;
-    }
-
     private Collection<PatientIdentifierType> patientIdentifierTypes;
 
     public Collection<PatientIdentifierType> getPatientIdentifierTypes()
@@ -249,7 +232,6 @@
         this.patientId = patientId;
     }
 
-    @Required
     public void setProgramStageInstanceService(
         org.hisp.dhis.program.ProgramStageInstanceService programStageInstanceService )
     {
@@ -1223,6 +1205,7 @@
 
                 // is repeatable
                 mobileProgramStage.setRepeatable( programStage.getIrregular() );
+                
                 if ( programStage.getStandardInterval() == null )
                 {
                     mobileProgramStage.setStandardInterval( 0 );
@@ -2138,6 +2121,38 @@
             return notification;
         }
     }
+    
+    
+    @Override
+    public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient generateRepeatableEvent( int orgUnitId, String eventInfo )
+        throws NotAllowedException
+    {
+        OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId ); 
+        
+        String mobileProgramStageId = eventInfo.substring( 0, eventInfo.indexOf( "$" ) );
+        
+        String nextDueDate = eventInfo.substring( eventInfo.indexOf( "$" )+1, eventInfo.length() );
+        
+        ProgramStageInstance oldProgramStageIntance = programStageInstanceService.getProgramStageInstance( Integer.valueOf( mobileProgramStageId ) );
+        
+        ProgramInstance programInstance = oldProgramStageIntance.getProgramInstance(); 
+        
+        ProgramStageInstance newProgramStageInstance = new ProgramStageInstance( programInstance, oldProgramStageIntance.getProgramStage() );
+        
+        newProgramStageInstance.setDueDate( PeriodUtil.stringToDate( nextDueDate ) );
+        
+        newProgramStageInstance.setOrganisationUnit( orgUnit );
+        
+        programInstance.getProgramStageInstances().add( newProgramStageInstance );
+        
+        programStageInstanceService.addProgramStageInstance( newProgramStageInstance );
+        
+        programInstanceService.updateProgramInstance( programInstance );
+        
+        org.hisp.dhis.api.mobile.model.LWUITmodel.Patient mobilePatient = getPatientModel( patientService.getPatient( programInstance.getPatient().getId() ));
+        
+        return mobilePatient;
+    }
 
     private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile;
 
@@ -2150,5 +2165,4 @@
     {
         this.patientMobile = patientMobile;
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java	2013-10-29 10:27:23 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java	2013-10-30 09:29:07 +0000
@@ -153,13 +153,13 @@
         orgUnit.setEnrollProgramUrl( getUrl( request, unit.getId(), "enrollProgram" ) );
         orgUnit.setGetVariesInfoUrl( getUrl( request, unit.getId(), "getVariesInfo" ) );
         orgUnit.setAddRelationshipUrl( getUrl( request, unit.getId(), "addRelationship" ) );
-        orgUnit.setDownloadAnonymousProgramUrl( getUrl( request, unit.getId(), "downloadAnonymousProgramUrl" ) );
+        orgUnit.setDownloadAnonymousProgramUrl( getUrl( request, unit.getId(), "downloadAnonymousProgram" ) );
         orgUnit.setFindProgramUrl( getUrl( request, unit.getId(), "findProgram" ) );
         orgUnit.setFindLatestPersonUrl( getUrl( request, unit.getId(), "findLatestPerson" ) );
         orgUnit.setFindPatientInAdvancedUrl( getUrl( request, unit.getId(), "findPatientInAdvanced" ) );
         orgUnit.setFindLostToFollowUpUrl( getUrl( request, unit.getId(), "findLostToFollowUp" ) );
-        orgUnit.setHandleLostToFollowUpUrl( getUrl( request, unit.getId(), "handleLostToFollowUpUrl" ) );
-        orgUnit.setGenerateRepeatableEventUrl( getUrl( request, unit.getId(), "generateRepeatableEventUrl" ) );
+        orgUnit.setHandleLostToFollowUpUrl( getUrl( request, unit.getId(), "handleLostToFollowUp" ) );
+        orgUnit.setGenerateRepeatableEventUrl( getUrl( request, unit.getId(), "generateRepeatableEvent" ) );
 
         // generate URL for download new version
         String full = UrlUtils.buildFullRequestUrl( request );

=== 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-10-22 04:01:39 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-10-30 09:29:07 +0000
@@ -380,7 +380,7 @@
         return activityReportingService.addRelationship( enrollmentRelationship, id );
     }
 
-    @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/downloadAnonymousProgramUrl" )
+    @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/downloadAnonymousProgram" )
     @ResponseBody
     public Program getAnonymousProgram( @PathVariable int id, @RequestHeader( "programType" ) String programType )
         throws NotAllowedException
@@ -404,13 +404,21 @@
         return activityReportingService.findLostToFollowUp( id, programId );
     }
     
-    @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/handleLostToFollowUpUrl" )
+    @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/handleLostToFollowUp" )
     @ResponseBody
     public Notification handleLostToFollowUp( @PathVariable int id, @RequestBody LostEvent lostEvent )
         throws NotAllowedException
     {
         return activityReportingService.handleLostToFollowUp( lostEvent );
     }
+    
+    @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/generateRepeatableEvent" )
+    @ResponseBody
+    public Patient generateRepeatableEvent( @PathVariable int id, @RequestHeader( "eventInfo" ) String eventInfo )
+        throws NotAllowedException
+    {
+        return activityReportingService.generateRepeatableEvent( id, eventInfo );
+    }
 
     // Supportive methods