← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14956: [mobile] support for SEWR from client

 

------------------------------------------------------------
revno: 14956
committer: Long <long.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2014-04-24 14:21:13 +0700
message:
  [mobile] support for SEWR from client
modified:
  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/model/MobileOrgUnitLinks.java
  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/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java
  dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java
  dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.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/ActivityReportingService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java	2014-04-24 07:21:13 +0000
@@ -98,5 +98,8 @@
 
     public Patient generateRepeatableEvent( int orgUnitId, String eventInfo )
         throws NotAllowedException;
+    
+    public String saveSingleEventWithoutRegistration( ProgramStage programStage, int orgUnitId )
+        throws NotAllowedException;
 
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java	2014-03-21 07:07:24 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java	2014-04-24 07:21:13 +0000
@@ -90,6 +90,8 @@
     private String handleLostToFollowUpUrl;
 
     private String generateRepeatableEventUrl;
+    
+    private String uploadSingleEventWithoutRegistration;
 
     @XmlAttribute
     public int getId()
@@ -342,6 +344,16 @@
     {
         this.generateRepeatableEventUrl = generateRepeatableEventUrl;
     }
+    
+    public String getUploadSingleEventWithoutRegistration()
+    {
+        return uploadSingleEventWithoutRegistration;
+    }
+
+    public void setUploadSingleEventWithoutRegistration( String uploadSingleEventWithoutRegistration )
+    {
+        this.uploadSingleEventWithoutRegistration = uploadSingleEventWithoutRegistration;
+    }
 
     public void serialize( DataOutputStream dataOutputStream )
         throws IOException
@@ -370,6 +382,7 @@
         dataOutputStream.writeUTF( findLostToFollowUpUrl );
         dataOutputStream.writeUTF( handleLostToFollowUpUrl );
         dataOutputStream.writeUTF( generateRepeatableEventUrl );
+        dataOutputStream.writeUTF( uploadSingleEventWithoutRegistration);
     }
 
     public void deSerialize( DataInputStream dataInputStream )
@@ -399,6 +412,7 @@
         findLostToFollowUpUrl = dataInputStream.readUTF();
         handleLostToFollowUpUrl = dataInputStream.readUTF();
         generateRepeatableEventUrl = dataInputStream.readUTF();
+        uploadSingleEventWithoutRegistration = dataInputStream.readUTF();
     }
 
     @Override
@@ -463,5 +477,6 @@
         dataOutputStream.writeUTF( findLostToFollowUpUrl );
         dataOutputStream.writeUTF( handleLostToFollowUpUrl );
         dataOutputStream.writeUTF( generateRepeatableEventUrl );
+        dataOutputStream.writeUTF( uploadSingleEventWithoutRegistration );
     }
 }

=== 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-04-01 23:30:59 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-04-24 07:21:13 +0000
@@ -106,6 +106,8 @@
     private static final String PROGRAM_STAGE_SECTION_UPLOADED = "program_stage_section_uploaded";
 
     private static final String SINGLE_EVENT_UPLOADED = "single_event_uploaded";
+    
+    private static final String SINGLE_EVENT_WITHOUT_REGISTRATION_UPLOADED = "single_event_without_registration_uploaded";
 
     private ActivityComparator activityComparator = new ActivityComparator();
 
@@ -1456,7 +1458,8 @@
             for ( org.hisp.dhis.api.mobile.model.PatientAttribute paAtt : attributesMobile )
             {
 
-                TrackedEntityAttribute patientAttribute = attributeService.getTrackedEntityAttributeByName( paAtt.getName() );
+                TrackedEntityAttribute patientAttribute = attributeService.getTrackedEntityAttributeByName( paAtt
+                    .getName() );
 
                 patientAttributeSet.add( patientAttribute );
 
@@ -1512,7 +1515,8 @@
 
         for ( TrackedEntityAttribute displayAttribute : attributes )
         {
-            Collection<TrackedEntityInstance> resultPatients = attValueService.getTrackedEntityInstance( displayAttribute, keyword );
+            Collection<TrackedEntityInstance> resultPatients = attValueService.getTrackedEntityInstance(
+                displayAttribute, keyword );
             // Search in specific OrgUnit
             if ( orgUnitId != 0 )
             {
@@ -1539,14 +1543,16 @@
 
         String resultSet = "";
 
-        Collection<TrackedEntityAttribute> displayAttributes = attributeService.getTrackedEntityAttributesDisplayInList( true );
+        Collection<TrackedEntityAttribute> displayAttributes = attributeService
+            .getTrackedEntityAttributesDisplayInList( true );
         for ( TrackedEntityInstance patient : patients )
         {
             resultSet += patient.getId() + "/";
             String attText = "";
             for ( TrackedEntityAttribute displayAttribute : displayAttributes )
             {
-                TrackedEntityAttributeValue value = attValueService.getTrackedEntityAttributeValue( patient, displayAttribute );
+                TrackedEntityAttributeValue value = attValueService.getTrackedEntityAttributeValue( patient,
+                    displayAttribute );
                 if ( value != null )
                 {
                     attText += value.getValue() + " ";
@@ -1757,4 +1763,69 @@
     {
         this.patientMobile = patientMobile;
     }
+
+    @Override
+    public String saveSingleEventWithoutRegistration(
+        org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage mobileProgramStage, int orgUnitId )
+        throws NotAllowedException
+    {
+        ProgramStage programStage = programStageService.getProgramStage( mobileProgramStage.getId() );
+
+        Program program = programStage.getProgram();
+
+        ProgramInstance programInstance = new ProgramInstance();
+
+        programInstance.setEnrollmentDate( new Date() );
+
+        programInstance.setDateOfIncident( new Date() );
+
+        programInstance.setProgram( program );
+
+        programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
+
+        programInstanceService.addProgramInstance( programInstance );
+
+        ProgramStageInstance programStageInstance = new ProgramStageInstance();
+
+        programStageInstance.setProgramInstance( programInstance );
+
+        programStageInstance.setProgramStage( programStage );
+
+        programStageInstance.setDueDate( new Date() );
+
+        programStageInstance.setExecutionDate( new Date() );
+
+        programStageInstance.setCompleted( true );
+
+        programStageInstance.setOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) );
+
+        programStageInstanceService.addProgramStageInstance( programStageInstance );
+
+        for ( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement mobileDataElement : mobileProgramStage
+            .getDataElements() )
+        {
+
+            TrackedEntityDataValue trackedEntityDataValue = new TrackedEntityDataValue();
+
+            trackedEntityDataValue.setDataElement( dataElementService.getDataElement( mobileDataElement.getId() ) );
+
+            String value = mobileDataElement.getValue();
+
+            if ( value != null && !value.trim().equals( "" ) )
+            {
+
+                trackedEntityDataValue.setValue( value );
+
+                trackedEntityDataValue.setProgramStageInstance( programStageInstance );
+
+                trackedEntityDataValue.setProvidedElsewhere( false );
+
+                trackedEntityDataValue.setTimestamp( new Date() );
+
+                dataValueService.saveTrackedEntityDataValue( trackedEntityDataValue );
+            }
+
+        }
+        return SINGLE_EVENT_WITHOUT_REGISTRATION_UPLOADED;
+    }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java	2014-03-21 07:07:24 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java	2014-04-24 07:21:13 +0000
@@ -72,6 +72,7 @@
         unit.setFindLostToFollowUpUrl( "findLostToFollowUpUrl" );
         unit.setHandleLostToFollowUpUrl( "handleLostToFollowUpUrl" );
         unit.setGenerateRepeatableEventUrl( "generateRepeatableEventUrl" );
+        unit.setUploadSingleEventWithoutRegistration( "uploadSingleEventWithoutRegistration" );
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         DataOutputStream dos = new DataOutputStream( baos );

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java	2014-03-21 07:07:24 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java	2014-04-24 07:21:13 +0000
@@ -58,6 +58,7 @@
         units.setOrgUnits( Arrays.asList( new MobileOrgUnitLinks[] { unit } ) );
         units.serializeVersion2_10( dos );
         dos.flush();
+
         OrgUnits units2 = new OrgUnits();
         units2.deSerialize( new DataInputStream( new ByteArrayInputStream( baos.toByteArray() ) ) );
         List<MobileOrgUnitLinks> unitList = units2.getOrgUnits();
@@ -71,32 +72,58 @@
 
     private MobileOrgUnitLinks createOrgUnit()
     {
-        MobileOrgUnitLinks unit = new MobileOrgUnitLinks();
-
-        unit.setId( 1 );
-        unit.setName( "name" );
-        unit.setDownloadAllUrl( "downloadAllUrl" );
-        unit.setDownloadFacilityReportUrl( "downloadFacilityReportUrl" );
-        unit.setUpdateActivityPlanUrl( "updateActivityPlanUrl" );
-        unit.setUploadFacilityReportUrl( "uploadFacilityReportUrl" );
-        unit.setUploadActivityReportUrl( "uploadActivityReportUrl" );
-        unit.setUpdateDataSetUrl( "updateDataSetUrl" );
-        unit.setChangeUpdateDataSetLangUrl( "changeUpdateDataSetLangUrl" );
-        unit.setSearchUrl( "search" );
-        unit.setUpdateNewVersionUrl( "" );
-        unit.setUpdateContactUrl( "updateContactUrl" );
-        unit.setFindPatientUrl( "findPatientUrl" );
-        unit.setUploadProgramStageUrl( "uploadProgramStageUrl" );
-        unit.setEnrollProgramUrl( "enrollProgramUrl" );
-        unit.setRegisterPersonUrl( "registerPersonUrl" );
-        unit.setGetVariesInfoUrl( "getVariesInfoUrl" );
-        unit.setAddRelationshipUrl( "addRelationshipUrl" );
-        unit.setDownloadAnonymousProgramUrl( "downloadAnonymousProgramUrl" );
-        unit.setFindProgramUrl( "findProgramUrl" );
-        unit.setFindPatientInAdvancedUrl( "findPatientInAdvancedUrl" );
-        unit.setFindLostToFollowUpUrl( "findLostToFollowUpUrl" );
-        unit.setHandleLostToFollowUpUrl( "handleLostToFollowUpUrl" );
-        unit.setGenerateRepeatableEventUrl( "generateRepeatableEventUrl" );
-        return unit;
+        MobileOrgUnitLinks orgUnit = new MobileOrgUnitLinks();
+
+        orgUnit.setId( 1 );
+        orgUnit.setName( "name" );
+
+        orgUnit.setDownloadAllUrl( "all" );
+        orgUnit.setUpdateActivityPlanUrl( "activitiyplan" );
+        orgUnit.setUploadFacilityReportUrl( "dataSets" );
+        orgUnit.setDownloadFacilityReportUrl( "dataSetValue" );
+        orgUnit.setUploadActivityReportUrl( "activities" );
+        orgUnit.setUpdateDataSetUrl( "updateDataSets" );
+        orgUnit.setChangeUpdateDataSetLangUrl( "changeLanguageDataSet" );
+        orgUnit.setSearchUrl( "search" );
+        orgUnit.setUpdateNewVersionUrl( "updateNewVersionUrl" );
+        orgUnit.setUpdateContactUrl( "updateContactForMobile" );
+        orgUnit.setFindPatientUrl( "findPatient" );
+        orgUnit.setRegisterPersonUrl( "registerPerson" );
+        orgUnit.setUploadProgramStageUrl( "uploadProgramStage" );
+        orgUnit.setEnrollProgramUrl( "enrollProgram" );
+        orgUnit.setGetVariesInfoUrl( "getVariesInfo" );
+        orgUnit.setAddRelationshipUrl( "addRelationship" );
+        orgUnit.setDownloadAnonymousProgramUrl( "downloadAnonymousProgram" );
+        orgUnit.setFindProgramUrl( "findProgram" );
+        orgUnit.setFindPatientInAdvancedUrl( "findPatientInAdvanced" );
+        orgUnit.setFindLostToFollowUpUrl( "findLostToFollowUp" );
+        orgUnit.setHandleLostToFollowUpUrl( "handleLostToFollowUp" );
+        orgUnit.setGenerateRepeatableEventUrl( "generateRepeatableEvent" );
+        orgUnit.setUploadSingleEventWithoutRegistration( "uploadSingleEventWithoutRegistration" );
+        // unit.setDownloadAllUrl( "downloadAllUrl" );
+        // unit.setDownloadFacilityReportUrl( "downloadFacilityReportUrl" );
+        // unit.setUpdateActivityPlanUrl( "updateActivityPlanUrl" );
+        // unit.setUploadFacilityReportUrl( "uploadFacilityReportUrl" );
+        // unit.setUploadActivityReportUrl( "uploadActivityReportUrl" );
+        // unit.setUpdateDataSetUrl( "updateDataSetUrl" );
+        // unit.setChangeUpdateDataSetLangUrl( "changeUpdateDataSetLangUrl" );
+        // unit.setSearchUrl( "search" );
+        // unit.setUpdateNewVersionUrl( "" );
+        // unit.setUpdateContactUrl( "updateContactUrl" );
+        // unit.setFindPatientUrl( "findPatientUrl" );
+        // unit.setUploadProgramStageUrl( "uploadProgramStageUrl" );
+        // unit.setEnrollProgramUrl( "enrollProgramUrl" );
+        // unit.setRegisterPersonUrl( "registerPersonUrl" );
+        // unit.setGetVariesInfoUrl( "getVariesInfoUrl" );
+        // unit.setAddRelationshipUrl( "addRelationshipUrl" );
+        // unit.setDownloadAnonymousProgramUrl( "downloadAnonymousProgramUrl" );
+        // unit.setFindProgramUrl( "findProgramUrl" );
+        // unit.setFindPatientInAdvancedUrl( "findPatientInAdvancedUrl" );
+        // unit.setFindLostToFollowUpUrl( "findLostToFollowUpUrl" );
+        // unit.setHandleLostToFollowUpUrl( "handleLostToFollowUpUrl" );
+        // unit.setGenerateRepeatableEventUrl( "generateRepeatableEventUrl" );
+        // unit.setUploadSingleEventWithoutRegistration(
+        // "uploadSingleEventWithoutRegistration" );
+        return orgUnit;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java	2014-03-21 06:05:07 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java	2014-04-24 07:21:13 +0000
@@ -160,6 +160,7 @@
         orgUnit.setFindLostToFollowUpUrl( getUrl( request, unit.getId(), "findLostToFollowUp" ) );
         orgUnit.setHandleLostToFollowUpUrl( getUrl( request, unit.getId(), "handleLostToFollowUp" ) );
         orgUnit.setGenerateRepeatableEventUrl( getUrl( request, unit.getId(), "generateRepeatableEvent" ) );
+        orgUnit.setUploadSingleEventWithoutRegistration(getUrl( request, unit.getId(), "uploadSingleEventWithoutRegistration" ));
 
         // generate URL for download new version
         String full = UrlUtils.buildFullRequestUrl( request );

=== 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-03-21 06:05:07 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java	2014-04-24 07:21:13 +0000
@@ -348,6 +348,15 @@
     {
         return activityReportingService.saveProgramStage( programStage, patientId, id );
     }
+    
+    @RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/uploadSingleEventWithoutRegistration" )
+    @ResponseBody
+    public String saveSingleEventWithoutRegistration( @PathVariable int id,
+        @RequestBody ProgramStage programStage )
+        throws NotAllowedException
+    {
+        return activityReportingService.saveSingleEventWithoutRegistration( programStage, id );
+    }
 
     @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/enrollProgram" )
     @ResponseBody