← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18221: tracker-capture: apply openAfterEnrollment property of program stage; some refactoring of enrollm...

 

------------------------------------------------------------
revno: 18221
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-02-11 12:52:21 +0100
message:
  tracker-capture: apply openAfterEnrollment property of program stage; some refactoring of enrollment date conversion
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/tei-report-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js


--
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-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js	2015-02-09 17:04:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js	2015-02-11 11:52:21 +0000
@@ -118,11 +118,17 @@
                         ProgramFactory.getAll().then(function(programs){
                             $scope.programs = [];
 
+                            $scope.programNames = [];  
+                            $scope.programStageNames = [];                            
                             //get programs valid for the selected ou and tei
                             angular.forEach(programs, function(program){
                                 if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnit.id) &&
                                    program.trackedEntity.id === $scope.selectedTei.trackedEntity){
                                     $scope.programs.push(program);
+                                    $scope.programNames[program.id] = {id: program.id, name: program.name};
+                                    angular.forEach(program.programStages, function(stage){                
+                                        $scope.programStageNames[stage.id] = {id: stage.id, name: stage.name};
+                                    });
                                 }
 
                                 if($scope.selectedProgramId && program.id === $scope.selectedProgramId || selectedEnrollment && selectedEnrollment.program === program.id){
@@ -133,7 +139,7 @@
                             getDashboardLayout();                            
 
                             //broadcast selected items for dashboard controllers
-                            CurrentSelection.set({tei: $scope.selectedTei, te: $scope.trackedEntity, prs: $scope.programs, pr: $scope.selectedProgram, enrollments: response.enrollments, selectedEnrollment: selectedEnrollment, optionSets: $scope.optionSets});
+                            CurrentSelection.set({tei: $scope.selectedTei, te: $scope.trackedEntity, prs: $scope.programs, pr: $scope.selectedProgram, prNames: $scope.programNames, prStNames: $scope.programStageNames, enrollments: response.enrollments, selectedEnrollment: selectedEnrollment, optionSets: $scope.optionSets});
                             $scope.broadCastSelections();                        
                         });
                     });
@@ -192,7 +198,7 @@
         $scope.trackedEntity = selections.te;
         $scope.optionSets = selections.optionSets;
         
-        CurrentSelection.set({tei: $scope.selectedTei, te: $scope.trackedEntity, prs: $scope.programs, pr: $scope.selectedProgram, enrollments: selections.enrollments, selectedEnrollment: null, optionSets: $scope.optionSets});
+        CurrentSelection.set({tei: $scope.selectedTei, te: $scope.trackedEntity, prs: $scope.programs, pr: $scope.selectedProgram, prNames: $scope.programNames, prStNames: $scope.programStageNames, enrollments: selections.enrollments, selectedEnrollment: null, optionSets: $scope.optionSets});
         $timeout(function() { 
             $rootScope.$broadcast('selectedItems', {programExists: $scope.programs.length > 0});            
         }, 100); 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-02-04 12:53:26 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-02-11 11:52:21 +0000
@@ -61,9 +61,8 @@
         
         $scope.selectedProgramWithStage = [];        
         if($scope.selectedOrgUnit && $scope.selectedProgram && $scope.selectedEntity && $scope.selectedEnrollment){
-            
-            ProgramStageFactory.getByProgram($scope.selectedProgram).then(function(stages){
-                
+
+            ProgramStageFactory.getByProgram($scope.selectedProgram).then(function(stages){                
                 angular.forEach(stages, function(stage){
                     if(stage.openAfterEnrollment){
                         $scope.currentStage = stage;

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js	2015-02-09 17:04:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js	2015-02-11 11:52:21 +0000
@@ -1,7 +1,6 @@
 trackerCapture.controller('EnrollmentController',
         function($rootScope,
                 $scope,  
-                $timeout,
                 $location,
                 DateUtils,
                 EventUtils,
@@ -39,7 +38,6 @@
         $scope.hasEnrollmentHistory = false;
         $scope.selectedEnrollment = null;
         $scope.currentEnrollment = null;
-        var selectedEnrollment = null;
         $scope.newEnrollment = {};
         
         selections = CurrentSelection.get();        
@@ -49,15 +47,11 @@
         $scope.selectedProgram = selections.pr;
         $scope.optionSets = selections.optionSets;
         $scope.programs = selections.prs;
-        selectedEnrollment = selections.selectedEnrollment;
-        $scope.enrollments = selections.enrollments ? selections.enrollments : [];
-        
-        if(selectedEnrollment){//enrollment exists
-            selectedEnrollment.dateOfIncident = DateUtils.formatFromApiToUser(selectedEnrollment.dateOfIncident);
-            selectedEnrollment.dateOfEnrollment = DateUtils.formatFromApiToUser(selectedEnrollment.dateOfEnrollment);
-        }
-        
+        var selectedEnrollment = selections.selectedEnrollment;
+        $scope.enrollments = selections.enrollments ? selections.enrollments : [];        
         $scope.programExists = args.programExists;
+        $scope.programNames = selections.prNames;
+        $scope.programStageNames = selections.prStNames;
         
         if($scope.selectedProgram){
             
@@ -68,10 +62,6 @@
             
             angular.forEach($scope.enrollments, function(enrollment){
                 if(enrollment.program === $scope.selectedProgram.id ){
-                    
-                    enrollment.dateOfIncident = DateUtils.formatFromApiToUser(enrollment.dateOfIncident);
-                    enrollment.dateOfEnrollment = DateUtils.formatFromApiToUser(enrollment.dateOfEnrollment);
-                
                     if(enrollment.status === 'ACTIVE'){
                         selectedEnrollment = enrollment;
                         $scope.currentEnrollment = enrollment;
@@ -143,8 +133,8 @@
                     $scope.registrationForm = teForm;
                 }                
                 $scope.selectedProgram.displayCustomForm = $scope.selectedProgram.hasCustomForm ? true:false;
-            });
-            $scope.broadCastSelections('dashboardWidgets');
+                $scope.broadCastSelections('dashboardWidgets');
+            });            
         }
     };
        
@@ -180,8 +170,8 @@
         var enrollment = {trackedEntityInstance: tei.trackedEntityInstance,
                             program: $scope.selectedProgram.id,
                             status: 'ACTIVE',
-                            dateOfEnrollment: DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfEnrollment),
-                            dateOfIncident: $scope.newEnrollment.dateOfIncident ? DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfIncident) : DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfEnrollment)
+                            dateOfEnrollment: $scope.selectedEnrollment.dateOfEnrollment,
+                            dateOfIncident: $scope.selectedEnrollment.dateOfIncident ? $scope.selectedEnrollment.dateOfIncident : $scope.selectedEnrollment.dateOfEnrollment
                         };
                         
         TEIService.update(tei, $scope.optionSets).then(function(updateResponse){            
@@ -203,11 +193,7 @@
                     $scope.selectedEnrollment = enrollment;
                     $scope.enrollments.push($scope.selectedEnrollment);
                     
-                    $scope.autoGenerateEvents();
-                    
-                    $scope.showEnrollmentDiv = false;
-                    $scope.outerForm.submitted = false;      
-                    $scope.broadCastSelections('dashboardWidgets');
+                    $scope.autoGenerateEvents(tei, $scope.selectedProgram, $scope.selectedOrgUnit, $scope.selectedEnrollment);                    
                 });
             }
             else{
@@ -223,16 +209,15 @@
     };
     
     $scope.broadCastSelections = function(listeners){
-        var tei = getProcessedForm().tei;
+        var selections = CurrentSelection.get();
+        var tei = selections.tei;
+        var pr = selections.pr;;
         var enrollment = null;      
         if($scope.selectedEnrollment && $scope.selectedEnrollment.enrollment){
             enrollment = $scope.selectedEnrollment;
         }
-            
-        CurrentSelection.set({tei: tei, te: $scope.selectedEntity, prs: $scope.programs, pr: $scope.selectedProgram, enrollments: $scope.enrollments, selectedEnrollment: enrollment, optionSets: $scope.optionSets});
-        $timeout(function(){
-            $rootScope.$broadcast(listeners, {});
-        }, 200);
+        CurrentSelection.set({tei: tei, te: $scope.selectedEntity, prs: $scope.programs, pr: pr, prNames: $scope.programNames, prStNames: $scope.programStageNames, enrollments: $scope.enrollments, selectedEnrollment: enrollment, optionSets: $scope.optionSets});
+        $rootScope.$broadcast(listeners, {});
     };    
     
     var getProcessedForm = function(){        
@@ -251,7 +236,6 @@
     };
     
     var processSelectedTei = function(){
-        $scope.selectedTei = null;
         $scope.selectedTei = angular.copy(selections.tei);
         angular.forEach($scope.selectedTei.attributes, function(att){
             $scope.selectedTei[att.attribute] = att.value;
@@ -306,26 +290,26 @@
         });
     };
             
-    $scope.autoGenerateEvents = function(){
-        if($scope.selectedTei && $scope.selectedProgram && $scope.selectedOrgUnit && $scope.selectedEnrollment){            
+    $scope.autoGenerateEvents = function(tei, program, orgUnit, enrollment){
+        if(tei && program && orgUnit && enrollment){            
             var dhis2Events = {events: []};
-            angular.forEach($scope.selectedProgram.programStages, function(stage){
+            angular.forEach(program.programStages, function(stage){
                 if(stage.autoGenerateEvent){
                     var newEvent = {
-                            trackedEntityInstance: $scope.selectedTei.trackedEntityInstance,
-                            program: $scope.selectedProgram.id,
+                            trackedEntityInstance: tei.trackedEntityInstance,
+                            program: program.id,
                             programStage: stage.id,
-                            orgUnit: $scope.selectedOrgUnit.id,                        
-                            dueDate: DateUtils.formatFromUserToApi( EventUtils.getEventDueDate(dhis2Events.events, stage, $scope.selectedEnrollment) ),
+                            orgUnit: orgUnit.id,                        
+                            dueDate: DateUtils.formatFromUserToApi( EventUtils.getEventDueDate(dhis2Events.events, stage, enrollment) ),
                             status: 'SCHEDULE'
                         };
                     
                     if(stage.openAfterEnrollment){
                         if(stage.reportDateToUse === 'dateOfIncident'){
-                            newEvent.eventDate = DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfIncident);
+                            newEvent.eventDate = DateUtils.formatFromUserToApi(enrollment.dateOfIncident);
                         }
                         else{
-                            newEvent.eventDate = DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfEnrollment);
+                            newEvent.eventDate = DateUtils.formatFromUserToApi(enrollment.dateOfEnrollment);
                         }
                     }
                     
@@ -333,10 +317,18 @@
                 }
             });
             
+            $scope.showEnrollmentDiv = false;
+            $scope.outerForm.submitted = false;
+            
+            CurrentSelection.set({tei: tei, te: $scope.selectedEntity, prs: $scope.programs, pr: program, prNames: $scope.programNames, prStNames: $scope.programStageNames, enrollments: $scope.enrollments, selectedEnrollment: enrollment, optionSets: $scope.optionSets});
             if(dhis2Events.events.length > 0){
                 DHIS2EventFactory.create(dhis2Events).then(function(data) {
+                    $scope.broadCastSelections('dashboardWidgets');
                 });
             }
+            else{
+                $scope.broadCastSelections('dashboardWidgets');
+            }
         }
     };
     

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js	2015-02-09 17:04:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js	2015-02-11 11:52:21 +0000
@@ -24,7 +24,6 @@
     //listen for the selected entity
     var selections = {};
     $scope.$on('dashboardWidgets', function(event, args) {
-        $scope.enrollmentEditing = args.enrollmentEditing;
         selections = CurrentSelection.get();
         $scope.selectedTei = angular.copy(selections.tei);
         $scope.trackedEntity = selections.te;
@@ -62,6 +61,7 @@
     
     //listen for enrollment editing
     $scope.$on('enrollmentEditing', function(event, args) { 
+        console.log('the editing:  ', args.enrollmentEditing);
         $scope.enrollmentEditing = args.enrollmentEditing;
     });
     

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-02-04 12:53:26 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-02-11 11:52:21 +0000
@@ -122,8 +122,8 @@
                     var enrollment = {trackedEntityInstance: teiId,
                                 program: $scope.selectedProgram.id,
                                 status: 'ACTIVE',
-                                dateOfEnrollment: DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfEnrollment),
-                                dateOfIncident: $scope.selectedEnrollment.dateOfIncident === '' ? DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfEnrollment) : DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfIncident)
+                                dateOfEnrollment: $scope.selectedEnrollment.dateOfEnrollment,
+                                dateOfIncident: $scope.selectedEnrollment.dateOfIncident === '' ? $scope.selectedEnrollment.dateOfEnrollment : $scope.selectedEnrollment.dateOfIncident
                             };                           
                     EnrollmentService.enroll(enrollment).then(function(data){
                         if(data.status !== 'SUCCESS'){
@@ -137,10 +137,13 @@
                         }
                         else{
                             enrollment.enrollment = data.reference;
-                            $scope.autoGenerateEvents(teiId,$scope.selectedProgram, $scope.selectedOrgUnit, enrollment);                          
+                            $scope.autoGenerateEvents(teiId,$scope.selectedProgram, $scope.selectedOrgUnit, enrollment, destination);                          
                         }
                     });
                 }
+                else{
+                    goToDashboard(destination, teiId);
+                }
             }
             else{
                 //registration has failed
@@ -150,24 +153,7 @@
                     };
                 DialogService.showDialog({}, dialogOptions);
                 return;
-            }
-            
-            $timeout(function() { 
-                //reset form
-                $scope.selectedTei = {};
-                $scope.selectedEnrollment = {};
-                $scope.outerForm.submitted = false;
-
-                if(destination === 'DASHBOARD') {
-                    $location.path('/dashboard').search({tei: teiId,                                            
-                                            program: $scope.selectedProgram ? $scope.selectedProgram.id: null});
-                }            
-                else if(destination === 'RELATIONSHIP' ){
-                    $scope.tei.trackedEntityInstance = teiId;
-                    $scope.broadCastSelections();
-                }
-            }, 100);
-            
+            }            
         });
     };
     
@@ -188,7 +174,7 @@
         }, 100);
     };
     
-    $scope.autoGenerateEvents = function(teiId, program, orgUnit, enrollment){            
+    $scope.autoGenerateEvents = function(teiId, program, orgUnit, enrollment, destination){            
             
         if(teiId && program && orgUnit && enrollment){            
             var dhis2Events = {events: []};
@@ -218,11 +204,30 @@
 
             if(dhis2Events.events.length > 0){
                 DHIS2EventFactory.create(dhis2Events).then(function(data){
+                    goToDashboard(destination, teiId);
                 });
+            }else{
+                goToDashboard(destination, teiId);
             }
         }
     };
     
+    var goToDashboard = function(destination, teiId){
+        //reset form
+        $scope.selectedTei = {};
+        $scope.selectedEnrollment = {};
+        $scope.outerForm.submitted = false;
+
+        if(destination === 'DASHBOARD') {
+            $location.path('/dashboard').search({tei: teiId,                                            
+                                    program: $scope.selectedProgram ? $scope.selectedProgram.id: null});
+        }            
+        else if(destination === 'RELATIONSHIP' ){
+            $scope.tei.trackedEntityInstance = teiId;
+            $scope.broadCastSelections();
+        }
+    };
+    
     $scope.switchRegistrationForm = function(){
         $scope.selectedProgram.displayCustomForm = !$scope.selectedProgram.displayCustomForm;
     };

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/tei-report-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/tei-report-controller.js	2015-02-04 14:39:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/tei-report-controller.js	2015-02-11 11:52:21 +0000
@@ -11,10 +11,12 @@
                 EnrollmentService,
                 DHIS2EventFactory) {  
     $scope.showProgramReportDetailsDiv = false;
-    $scope.programs = [];  
+    $scope.enrollmentsByProgram = [];
+    
+    /*$scope.programs = [];  
     $scope.programNames = [];  
     $scope.programStageNames = [];
-    $scope.enrollmentsByProgram = [];
+    
     ProgramFactory.getAll().then(function(programs){     
         $scope.programs = programs;
         angular.forEach($scope.programs, function(pr){
@@ -24,7 +26,7 @@
                 $scope.programStageNames[stage.id] = {id: stage.id, name: stage.name};
             });
         });
-    });
+    });*/
         
     $scope.$on('dashboardWidgets', function(event, args) {
         $scope.showProgramReportDetailsDiv = false;
@@ -34,6 +36,9 @@
         $scope.selectedEntity = selections.te;
         $scope.selectedProgram = selections.pr;
         $scope.optionSets = selections.optionSets;
+        $scope.programs = selections.prs;
+        $scope.programNames = selections.prNames;  
+        $scope.programStageNames = selections.prStNames;
     
         if($scope.selectedTei && $scope.selectedOrgUnit){            
             $scope.getEvents();

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-02-09 17:04:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-02-11 11:52:21 +0000
@@ -334,41 +334,62 @@
 })
 
 /* Service to deal with enrollment */
-.service('EnrollmentService', function($http) {
+.service('EnrollmentService', function($http, DateUtils) {
     
+    var convertFromApiToUser = function(enrollment){
+        if(enrollment.enrollments){
+            angular.forEach(enrollment.enrollments, function(enrollment){
+                enrollment.dateOfIncident = DateUtils.formatFromApiToUser(enrollment.dateOfIncident);
+                enrollment.dateOfEnrollment = DateUtils.formatFromApiToUser(enrollment.dateOfEnrollment);                
+            });
+        }
+        else{
+            enrollment.dateOfIncident = DateUtils.formatFromApiToUser(enrollment.dateOfIncident);
+            enrollment.dateOfEnrollment = DateUtils.formatFromApiToUser(enrollment.dateOfEnrollment);
+        }
+        
+        return enrollment;
+    };
+    var convertFromUserToApi = function(enrollment){
+        enrollment.dateOfIncident = DateUtils.formatFromUserToApi(enrollment.dateOfIncident);
+        enrollment.dateOfEnrollment = DateUtils.formatFromUserToApi(enrollment.dateOfEnrollment);
+        return enrollment;
+    };
     return {        
         get: function( enrollmentUid ){
             var promise = $http.get(  '../api/enrollments/' + enrollmentUid ).then(function(response){
-                return response.data;
+                return convertFromApiToUser(response.data);
             });
             return promise;
         },
         getByEntity: function( entity ){
             var promise = $http.get(  '../api/enrollments?trackedEntityInstance=' + entity ).then(function(response){
-                return response.data;
+                return convertFromApiToUser(response.data);
             });
             return promise;
         },
         getByEntityAndProgram: function( entity, program ){
             var promise = $http.get(  '../api/enrollments?trackedEntityInstance=' + entity + '&program=' + program ).then(function(response){
-                return response.data;
+                return convertFromApiToUser(response.data);
             });
             return promise;
         },
         getByStartAndEndDate: function( program, orgUnit, ouMode, startDate, endDate ){
             var promise = $http.get(  '../api/enrollments.json?program=' + program + '&orgUnit=' + orgUnit + '&ouMode='+ ouMode + '&startDate=' + startDate + '&endDate=' + endDate + '&paging=false').then(function(response){
-                return response.data;
+                return convertFromApiToUser(response.data);
             });
             return promise;
         },
         enroll: function( enrollment ){
-            var promise = $http.post(  '../api/enrollments', enrollment ).then(function(response){
+            var en = convertFromUserToApi(angular.copy(enrollment));
+            var promise = $http.post(  '../api/enrollments', en ).then(function(response){
                 return response.data;
             });
             return promise;
         },
         update: function( enrollment ){
-            var promise = $http.put( '../api/enrollments/' + enrollment.enrollment , enrollment).then(function(response){
+            var en = convertFromUserToApi(angular.copy(enrollment));
+            var promise = $http.put( '../api/enrollments/' + en.enrollment , en ).then(function(response){
                 return response.data;
             });
             return promise;

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-02-09 17:04:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-02-11 11:52:21 +0000
@@ -257,7 +257,7 @@
     $.ajax({
         url: '../api/programs.json',
         type: 'GET',
-        data:'filter=type:eq:1&paging=false&fields=id,version,programTrackedEntityAttributes[trackedEntityAttribute[id,optionSet[id,version]]],programStages[id,version,programStageDataElements[dataElement[optionSet[id,version]]]]'
+        data:'filter=type:eq:1&paging=false&fields=id,version,programTrackedEntityAttributes[trackedEntityAttribute[id,optionSet[id,version]]],programStages[id,name,version,minDaysFromStart,standardInterval,generatedByEnrollmentDate,reportDateDescription,repeatable,autoGenerateEvent,openAfterEnrollment,reportDateToUse,programStageDataElements[dataElement[optionSet[id,version]]]]'
     }).done( function(response) {          
         var programs = [];
         _.each( _.values( response.programs ), function ( program ) { 
@@ -324,7 +324,7 @@
         return $.ajax( {
             url: '../api/programs.json',
             type: 'GET',
-            data: 'paging=false&filter=id:eq:' + id +'&fields=id,name,type,version,dataEntryMethod,dateOfEnrollmentDescription,dateOfIncidentDescription,displayIncidentDate,ignoreOverdueEvents,selectEnrollmentDatesInFuture,selectIncidentDatesInFuture,onlyEnrollOnce,externalAccess,displayOnAllOrgunit,registration,relationshipText,relationshipFromA,relatedProgram[id,name],relationshipType[id,name],trackedEntity[id,name,description],userRoles[id,name],organisationUnits[id,name],programStages[id,name,sortOrder,version,minDaysFromStart,reportDateDescription,repeatable,autoGenerateEvent,generatedByEnrollmentDate],programTrackedEntityAttributes[displayInList,mandatory,allowFutureDate,trackedEntityAttribute[id,unique]]'
+            data: 'paging=false&filter=id:eq:' + id +'&fields=id,name,type,version,dataEntryMethod,dateOfEnrollmentDescription,dateOfIncidentDescription,displayIncidentDate,ignoreOverdueEvents,selectEnrollmentDatesInFuture,selectIncidentDatesInFuture,onlyEnrollOnce,externalAccess,displayOnAllOrgunit,registration,relationshipText,relationshipFromA,relatedProgram[id,name],relationshipType[id,name],trackedEntity[id,name,description],userRoles[id,name],organisationUnits[id,name],programStages[id,name,version,minDaysFromStart,standardInterval,generatedByEnrollmentDate,reportDateDescription,repeatable,autoGenerateEvent,openAfterEnrollment,reportDateToUse],programTrackedEntityAttributes[displayInList,mandatory,allowFutureDate,trackedEntityAttribute[id,unique]]'
         }).done( function( response ){
             
             _.each( _.values( response.programs ), function ( program ) { 
@@ -528,7 +528,7 @@
         return $.ajax( {
             url: '../api/programStages.json',
             type: 'GET',
-            data: 'filter=id:eq:' + id +'&fields=id,name,sortOrder,version,dataEntryForm,captureCoordinates,blockEntryForm,autoGenerateEvent,generatedByEnrollmentDate,reportDateDescription,minDaysFromStart,repeatable,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,code,name,formName,type,optionSet[id]]]'
+            data: 'filter=id:eq:' + id +'&fields=id,name,sortOrder,version,dataEntryForm,captureCoordinates,blockEntryForm,autoGenerateEvent,generatedByEnrollmentDate,reportDateDescription,minDaysFromStart,repeatable,openAfterEnrollment,reportDateToUse,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,code,name,formName,type,optionSet[id]]]'
         }).done( function( response ){            
             _.each( _.values( response.programStages ), function( programStage ) {
                 dhis2.tc.store.set( 'programStages', programStage );