=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-10-14 10:24:31 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-10-14 11:13:33 +0000 @@ -230,7 +230,7 @@ Collection getPatientsByPhone( String phoneNumber, Integer min, Integer max ); - Collection getPatientByFullname( String fullName, Integer orgunitId ); + Collection getPatientByFullname( String fullName, OrganisationUnit organisationUnit ); Collection getRegistrationOrgunitIds( Date startDate, Date endDate ); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-10-14 10:24:31 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-10-14 11:13:33 +0000 @@ -71,7 +71,7 @@ Collection getByPhoneNumber( String phoneNumber, Integer min, Integer max ); - Collection getByFullName( String fullName, Integer orgunitId ); + Collection getByFullName( String fullName, OrganisationUnit organisationUnit ); Collection getRegistrationOrgunitIds( Date startDate, Date endDate ); === 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-13 18:14:00 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-10-14 11:13:33 +0000 @@ -562,7 +562,9 @@ { if ( isNumber( keyword ) == false ) { - List patients = (List) this.patientService.getPatientByFullname( keyword, orgUnitId ); + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId ); + + List patients = (List) this.patientService.getPatientByFullname( keyword, organisationUnit ); if ( patients.size() > 1 ) { @@ -1395,8 +1397,11 @@ } else { + + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId ); + String fullName = enrollmentRelationship.getPersonBName(); - List patients = (List) this.patientService.getPatientByFullname( fullName, orgUnitId ); + List patients = (List) this.patientService.getPatientByFullname( fullName, organisationUnit ); // remove the own searcher patients = removeIfDuplicated( patients, enrollmentRelationship.getPersonAId() ); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-10-14 10:24:31 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-10-14 11:13:33 +0000 @@ -652,9 +652,9 @@ } @Override - public Collection getPatientByFullname( String fullName, Integer orgunitId ) + public Collection getPatientByFullname( String fullName, OrganisationUnit organisationUnit ) { - return patientStore.getByFullName( fullName, orgunitId ); + return patientStore.getByFullName( fullName, organisationUnit ); } @Override === 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-14 10:30:06 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-10-14 11:13:33 +0000 @@ -795,16 +795,16 @@ @Override //TODO this method must be changed - cannot retrieve one by one - public Collection getByFullName( String fullName, Integer orgunitId ) + public Collection getByFullName( String fullName, OrganisationUnit organisationUnit ) { List patients = new ArrayList(); fullName = fullName.toLowerCase(); String sql = "SELECT patientid FROM patient where lower(name) = '" + fullName + "'"; - if ( orgunitId != null && orgunitId != 0 ) + if ( organisationUnit != null ) { - sql += " and organisationunitid=" + orgunitId; + sql += " and organisationunitid=" + organisationUnit.getId(); } try