=== 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 2014-05-21 07:51:28 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2014-05-21 08:14:27 +0000 @@ -84,10 +84,7 @@ Program findProgram( String programInfo ) throws NotAllowedException; - Patient findLatestPatient() - throws NotAllowedException; - - Integer savePatient( Patient patient, int orgUnitId, String programId ) + Patient savePatient( Patient patient, int orgUnitId, String programId ) throws NotAllowedException; String findLostToFollowUp( int orgUnitId, String programId ) === 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 2014-05-21 07:08:14 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-05-21 08:14:27 +0000 @@ -55,6 +55,7 @@ import org.hisp.dhis.api.mobile.model.Task; import org.hisp.dhis.api.mobile.model.LWUITmodel.LostEvent; import org.hisp.dhis.api.mobile.model.LWUITmodel.Notification; +import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient; import org.hisp.dhis.api.mobile.model.LWUITmodel.Section; import org.hisp.dhis.api.mobile.model.comparator.ActivityComparator; import org.hisp.dhis.common.Grid; @@ -1435,18 +1436,7 @@ } @Override - public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient findLatestPatient() - throws NotAllowedException - { - // Patient patient = entityInstanceService.getPatient( this.patientId ); - // - // org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile = - // getPatientModel( patient ); - return this.getPatientMobile(); - } - - @Override - public Integer savePatient( org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient, int orgUnitId, + public Patient savePatient( org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patient, int orgUnitId, String programIdText ) throws NotAllowedException { @@ -1480,7 +1470,8 @@ } patientId = entityInstanceService.createTrackedEntityInstance( patientWeb, null, null, patientAttributeValues ); - + TrackedEntityInstance newTrackedEntityInstance = entityInstanceService + .getTrackedEntityInstance( this.patientId ); try { for ( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramInstance mobileProgramInstance : patient @@ -1493,13 +1484,10 @@ } catch ( Exception e ) { - return patientId; + throw new NotAllowedException( e.getMessage() ); } - TrackedEntityInstance patientNew = entityInstanceService.getTrackedEntityInstance( this.patientId ); - setPatientMobile( getPatientModel( patientNew ) ); - - return patientId; + return getPatientModel( newTrackedEntityInstance ); } @@ -1793,20 +1781,6 @@ return mobilePatient; } - // TODO remove, we cannot have state like this in a singleton - - private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile; - - private org.hisp.dhis.api.mobile.model.LWUITmodel.Patient getPatientMobile() - { - return patientMobile; - } - - private void setPatientMobile( org.hisp.dhis.api.mobile.model.LWUITmodel.Patient patientMobile ) - { - this.patientMobile = patientMobile; - } - @Override public String saveSingleEventWithoutRegistration( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage mobileProgramStage, int orgUnitId ) === 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 2014-05-21 07:08:14 +0000 +++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2014-05-21 08:14:27 +0000 @@ -403,7 +403,7 @@ String enrollInfo ) throws NotAllowedException { - return activityReportingService.enrollProgram( enrollInfo,null, new Date() ); + return activityReportingService.enrollProgram( enrollInfo, null, new Date() ); } @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/addRelationship" ) @@ -524,14 +524,7 @@ String programId ) throws NotAllowedException { - if ( activityReportingService.savePatient( patient, id, programId ) != null ) - { - return activityReportingService.findLatestPatient(); - } - else - { - return null; - } + return activityReportingService.savePatient( patient, id, programId ); } @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/getVariesInfo" ) @@ -581,7 +574,7 @@ Message message ) throws NotAllowedException { - return activityReportingService.sendMessage(message); + return activityReportingService.sendMessage( message ); } }