← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12406: fix bugs, support lost to follow up [j2me]

 

------------------------------------------------------------
revno: 12406
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-03 11:59:39 +0700
message:
  fix bugs, support lost to follow up [j2me]
modified:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/NotAllowedException.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/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-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/NotAllowedException.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/NotAllowedException.java	2013-09-08 11:40:48 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/NotAllowedException.java	2013-10-03 04:59:39 +0000
@@ -54,6 +54,8 @@
     
     public static final NotAllowedException NO_PROGRAM_BELONG_ORGUNIT = new NotAllowedException( "NO_PROGRAM_BELONG_ORGUNIT");
     
+    public static final NotAllowedException NO_EVENT_FOUND = new NotAllowedException( "NO_EVENT_FOUND");
+    
     private String reason;
 
     public NotAllowedException( String reason )

=== 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-02 11:24:32 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-10-03 04:59:39 +0000
@@ -660,9 +660,9 @@
     public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient enrollProgram( String enrollInfo )
         throws NotAllowedException
     {
-        String[] enrollProgramInfos = enrollInfo.split( "-" );
-        int patientId = Integer.parseInt( enrollProgramInfos[0] );
-        int programId = Integer.parseInt( enrollProgramInfos[1] );
+        String[] enrollProgramInfo = enrollInfo.split( "-" );
+        int patientId = Integer.parseInt( enrollProgramInfo[0] );
+        int programId = Integer.parseInt( enrollProgramInfo[1] );
 
         Patient patient = patientService.getPatient( patientId );
         Program program = programService.getProgram( programId );
@@ -839,7 +839,7 @@
         List<org.hisp.dhis.patient.PatientAttribute> atts;
 
         patientModel.setId( patient.getId() );
-        
+
         if ( patient.getName() != null )
         {
             patientModel.setName( patient.getName() );
@@ -871,7 +871,7 @@
             {
                 patientModel.setDobType( patient.getDobType() );
             }
-            if ( setting.getBirthdate() && patient.getBirthDate()!=null )
+            if ( setting.getBirthdate() && patient.getBirthDate() != null )
             {
                 DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" );
                 patientModel.setBirthDate( dateFormat.format( patient.getBirthDate() ) );
@@ -1327,16 +1327,18 @@
         OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
 
         List<Program> tempPrograms = null;
-        
-        if ( Integer.valueOf( programType )==( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) )
-        {
-            tempPrograms = new ArrayList<Program>( programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
-        }
-        else if ( Integer.valueOf( programType )==( Program.MULTIPLE_EVENTS_WITH_REGISTRATION ) )
-        {
-            tempPrograms = new ArrayList<Program>( programService.getProgramsByCurrentUser( Program.MULTIPLE_EVENTS_WITH_REGISTRATION ) );
-        }
-            
+
+        if ( Integer.valueOf( programType ) == (Program.SINGLE_EVENT_WITHOUT_REGISTRATION) )
+        {
+            tempPrograms = new ArrayList<Program>(
+                programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
+        }
+        else if ( Integer.valueOf( programType ) == (Program.MULTIPLE_EVENTS_WITH_REGISTRATION) )
+        {
+            tempPrograms = new ArrayList<Program>(
+                programService.getProgramsByCurrentUser( Program.MULTIPLE_EVENTS_WITH_REGISTRATION ) );
+        }
+
         List<Program> programs = new ArrayList<Program>();
 
         for ( Program program : tempPrograms )
@@ -1433,9 +1435,9 @@
         mobileProgramStage.setRepeatable( false );
         mobileProgramStage.setSingleEvent( true );
         mobileProgramStage.setSections( new ArrayList<Section>() );
-        
+
         // get report date
-        mobileProgramStage.setReportDate( PeriodUtil.dateToString( new Date()) );
+        mobileProgramStage.setReportDate( PeriodUtil.dateToString( new Date() ) );
 
         if ( programStage.getReportDateDescription() == null )
         {
@@ -1933,7 +1935,7 @@
                 {
                     break;
                 }
-                
+
                 if ( each.getName() != null )
                 {
                     name = each.getName();
@@ -1976,26 +1978,51 @@
     public String findLostToFollowUp( int orgUnitId, String programId )
         throws NotAllowedException
     {
-        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String eventsInfo = "";
+        Boolean followUp = false;
+        DateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd" );
         List<String> searchTextList = new ArrayList<String>();
-        List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>();
+        Collection<OrganisationUnit> orgUnitList = new HashSet<OrganisationUnit>();
 
         Calendar toCalendar = new GregorianCalendar();
         toCalendar.add( Calendar.DATE, -1 );
         toCalendar.add( Calendar.YEAR, 100 );
         Date toDate = toCalendar.getTime();
-        
+
         Calendar fromCalendar = new GregorianCalendar();
         fromCalendar.add( Calendar.DATE, -1 );
         fromCalendar.add( Calendar.YEAR, -100 );
-        Date fromDate = toCalendar.getTime();
-        
-        String searchText = Patient.PREFIX_PROGRAM_EVENT_BY_STATUS+"_"+programId+"_"+formatter.format( fromDate )+"_"+formatter.format( toDate )+"_"+orgUnitId+"_"+true+"_"+ProgramStageInstance.LATE_VISIT_STATUS;
-        
+        Date fromDate = fromCalendar.getTime();
+
+        String searchText = Patient.PREFIX_PROGRAM_EVENT_BY_STATUS + "_" + programId + "_"
+            + formatter.format( fromDate ) + "_" + formatter.format( toDate ) + "_" + orgUnitId + "_" + true + "_"
+            + ProgramStageInstance.LATE_VISIT_STATUS;
+
         searchTextList.add( searchText );
         orgUnitList.add( organisationUnitService.getOrganisationUnit( orgUnitId ) );
-        
-        List<Integer> stageInstanceIds = patientService.getProgramStageInstances( searchTextList, orgUnitList, true, ProgramInstance.STATUS_ACTIVE, null, null );
-        return searchText;
+
+        List<Integer> stageInstanceIds = patientService.getProgramStageInstances( searchTextList, orgUnitList,
+            followUp, ProgramInstance.STATUS_ACTIVE, null, null );
+
+        if ( stageInstanceIds.size() == 0 )
+        {
+            throw NotAllowedException.NO_EVENT_FOUND;
+        }
+        else if ( stageInstanceIds.size() > 0 )
+        {
+            for ( Integer stageInstanceId : stageInstanceIds )
+            {
+                ProgramStageInstance programStageInstance = programStageInstanceService
+                    .getProgramStageInstance( stageInstanceId );
+                Patient patient = programStageInstance.getProgramInstance().getPatient();
+                eventsInfo += programStageInstance.getId() + "/" + patient.getName() + "/"
+                    + programStageInstance.getProgramStage().getName() + "/" + programStageInstance.getDueDate() + "$";
+            }
+            throw new NotAllowedException( eventsInfo );
+        }
+        else
+        {
+            return "";
+        }
     }
 }

=== 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-02 11:24:32 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-10-03 04:59:39 +0000
@@ -804,7 +804,8 @@
                 + " inner join programstageinstance psi on " + " (psi.programinstanceid=pgi.programinstanceid) "
                 + " inner join programstage pgs on (pgs.programstageid=psi.programstageid) ";
 
-            patientGroupBy += ",psi.programstageinstanceid, pgs.name ";
+            //patientGroupBy += ",psi.programstageinstanceid, pgs.name ";
+            patientGroupBy += ",psi.programstageinstanceid, pgs.name, psi.duedate ";
 
             from = " ";
         }

=== 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-01 16:44:42 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2013-10-03 04:59:39 +0000
@@ -397,8 +397,9 @@
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findLostToFollowUp" )
     @ResponseBody
     public String findLostToFollowUp( @PathVariable int id, @RequestHeader( "programId" ) String programId )
+        throws NotAllowedException
     {
-        return "";
+        return activityReportingService.findLostToFollowUp( id, programId );
     }
 
     // Supportive methods