=== 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-03-29 07:39:49 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2013-04-01 04:56:59 +0000 @@ -27,8 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Collection; - import org.hisp.dhis.api.mobile.model.ActivityPlan; import org.hisp.dhis.api.mobile.model.ActivityValue; import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient; @@ -66,5 +64,8 @@ public Program getAllAnonymousProgram( int orgUnitId ) throws NotAllowedException; + + public Program findProgram( String programInfo ) + 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-03-29 07:39:49 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-04-01 04:56:59 +0000 @@ -834,14 +834,7 @@ { for ( ProgramInstance each : listOfProgramInstance ) { - org.hisp.dhis.api.mobile.model.LWUITmodel.Program mobileProgram = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program(); - mobileProgram.setVersion( each.getProgram().getVersion() ); - mobileProgram.setId( each.getId() ); - mobileProgram.setName( each.getProgram().getName() ); - mobileProgram.setCompleted( each.isCompleted() ); - mobileProgram.setProgramStages( getMobileProgramStages( patient, each, each.getProgram() ) ); - - mobileProgramList.add( mobileProgram ); + mobileProgramList.add( getMobileProgram( patient, each )); } } @@ -902,13 +895,24 @@ patientModel.setEnrollmentRelationships( enrollmentRelationshipMobileList ); return patientModel; } - - private List getMobileProgramStages( Patient patient, - ProgramInstance programInstance, Program program ) + + private org.hisp.dhis.api.mobile.model.LWUITmodel.Program getMobileProgram( Patient patient, ProgramInstance programInstance) + { + org.hisp.dhis.api.mobile.model.LWUITmodel.Program mobileProgram = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program(); + + mobileProgram.setVersion( programInstance.getProgram().getVersion() ); + mobileProgram.setId( programInstance.getId() ); + mobileProgram.setName( programInstance.getProgram().getName() ); + mobileProgram.setCompleted( programInstance.isCompleted() ); + mobileProgram.setProgramStages( getMobileProgramStages( patient, programInstance ) ); + return mobileProgram; + } + + private List getMobileProgramStages( Patient patient, ProgramInstance programInstance ) { List mobileProgramStages = new ArrayList(); - for ( ProgramStage eachProgramStage : program.getProgramStages() ) + for ( ProgramStage eachProgramStage : programInstance.getProgram().getProgramStages() ) { ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( programInstance, eachProgramStage ); @@ -921,7 +925,7 @@ mobileProgramStage.setRepeatable( eachProgramStage.getIrregular() ); // is completed - mobileProgramStage.setCompleted( checkIfProgramStageCompleted( patient, program, eachProgramStage ) ); + mobileProgramStage.setCompleted( checkIfProgramStageCompleted( patient, programInstance.getProgram(), eachProgramStage ) ); // is single event mobileProgramStage.setSingleEvent( programInstance.getProgram().isSingleEvent() ); @@ -1172,6 +1176,29 @@ throw NotAllowedException.NO_PROGRAM_FOUND; } } + + + @Override + public org.hisp.dhis.api.mobile.model.LWUITmodel.Program findProgram( String programInfo ) + throws NotAllowedException + { + if ( isNumber( programInfo ) == false ) + { + return null; + } + else + { + Program program = programService.getProgram( Integer.parseInt( programInfo ) ); + if( program.isSingleEvent() ) + { + return getMobileAnonymousProgram( program ); + } + else + { + return null; + } + } + } private org.hisp.dhis.api.mobile.model.LWUITmodel.Program getMobileAnonymousProgram( Program anonymousProgram ) { === 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-03-29 09:19:53 +0000 +++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-04-01 04:56:59 +0000 @@ -351,12 +351,10 @@ @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/findProgram" ) @ResponseBody - public Program findProgram( @PathVariable int id, @RequestHeader( "info" ) String keyword ) + public Program findProgram( @PathVariable int id, @RequestHeader( "info" ) String programInfo ) throws NotAllowedException { - System.out.println(keyword); - //return activityReportingService.findPatient( keyword, id ); - return null; + return activityReportingService.findProgram( programInfo ); } // Supportive methods