=== 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-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/NotAllowedException.java 2013-09-08 11:40:48 +0000 @@ -52,6 +52,8 @@ public static final NotAllowedException NO_PROGRAM_FOUND = new NotAllowedException( "NO_PROGRAM_FOUND"); + public static final NotAllowedException NO_PROGRAM_BELONG_ORGUNIT = new NotAllowedException( "NO_PROGRAM_BELONG_ORGUNIT"); + 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-09-08 09:00:11 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-08 11:40:48 +0000 @@ -1883,6 +1883,23 @@ List tempPatients = (List) patientService.getPatients( orgUnit, program, null, null ); patients.retainAll( tempPatients ); } + + if ( programId != 0 && orgUnitId != 0 ) + { + boolean isProgramBelongToOrgUnit = false; + for( Program program: programService.getPrograms( orgUnit )) + { + if ( program.getId() == programId ) + { + isProgramBelongToOrgUnit = true; + break; + } + } + if ( isProgramBelongToOrgUnit == false ) + { + throw NotAllowedException.NO_PROGRAM_BELONG_ORGUNIT; + } + } if ( patients.size() > 1 ) {