← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17881: completed enrollments are now available for viewing

 

------------------------------------------------------------
revno: 17881
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-01-05 11:20:46 +0100
message:
  completed enrollments are now available for viewing
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/dataentry/dataentry.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html
  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.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes.html
  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/relationship/relationship-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/i18n/i18n_app.properties
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/angular/plugins/dhis2/services.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	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js	2015-01-05 10:20:46 +0000
@@ -62,7 +62,7 @@
 
                         var selectedEnrollment = null;
                         if(response.enrollments.length === 1 && response.enrollments[0].status === 'ACTIVE'){
-                            selectedEnrollment = response.enrollments[0];                            
+                            selectedEnrollment = response.enrollments[0];
                         }
                         
                         ProgramFactory.getAll().then(function(programs){
@@ -81,7 +81,7 @@
                             }); 
 
                             //broadcast selected items for dashboard controllers
-                            CurrentSelection.set({tei: $scope.selectedTei, te: $scope.trackedEntity, prs: $scope.programs, pr: $scope.selectedProgram, enrollment: selectedEnrollment, optionSets: $scope.optionSets});
+                            CurrentSelection.set({tei: $scope.selectedTei, te: $scope.trackedEntity, prs: $scope.programs, pr: $scope.selectedProgram, enrollments: response.enrollments, selectedEnrollment: selectedEnrollment, optionSets: $scope.optionSets});
                             $scope.broadCastSelections();                        
                         });
                     });
@@ -109,8 +109,8 @@
         $scope.selectedTei = selections.tei;
         $scope.trackedEntity = selections.te;
         $scope.optionSets = selections.optionSets;
-        
-        CurrentSelection.set({tei: $scope.selectedTei, te: $scope.trackedEntity, prs: $scope.programs, pr: $scope.selectedProgram, enrollment: null, optionSets: $scope.optionSets});
+      
+        CurrentSelection.set({tei: $scope.selectedTei, te: $scope.trackedEntity, prs: $scope.programs, pr: $scope.selectedProgram, 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	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-01-05 10:20:46 +0000
@@ -56,10 +56,10 @@
         $scope.selectedOrgUnit = storage.get('SELECTED_OU');
         $scope.selectedEntity = selections.tei;      
         $scope.selectedProgram = selections.pr;        
-        $scope.selectedEnrollment = selections.enrollment;   
+        $scope.selectedEnrollment = selections.selectedEnrollment;   
         $scope.optionSets = selections.optionSets;
-        $scope.selectedProgramWithStage = [];
         
+        $scope.selectedProgramWithStage = [];        
         if($scope.selectedOrgUnit && $scope.selectedProgram && $scope.selectedEntity && $scope.selectedEnrollment){
             
             ProgramStageFactory.getByProgram($scope.selectedProgram).then(function(stages){
@@ -79,7 +79,7 @@
     
     $scope.getEvents = function(){        
         $scope.dhis2Events = '';
-        DHIS2EventFactory.getEventsByStatus($scope.selectedEntity.trackedEntityInstance, $scope.selectedOrgUnit.id, $scope.selectedProgram.id, 'ACTIVE').then(function(data){
+        DHIS2EventFactory.getEventsByProgram($scope.selectedEntity.trackedEntityInstance, $scope.selectedOrgUnit.id, $scope.selectedProgram.id).then(function(data){
             $scope.dhis2Events = data;
             if(angular.isObject($scope.dhis2Events)){
                 angular.forEach($scope.dhis2Events, function(dhis2Event){                    
@@ -300,9 +300,9 @@
         
         $scope.currentStage = $scope.selectedProgramWithStage[$scope.currentEvent.programStage];
 
-        $scope.programStageDataElements = [];                  
+        $scope.prStDes = [];                  
         angular.forEach($scope.currentStage.programStageDataElements, function(prStDe){
-            $scope.programStageDataElements[prStDe.dataElement.id] = prStDe; 
+            $scope.prStDes[prStDe.dataElement.id] = prStDe; 
         }); 
 
         $scope.customForm = CustomFormService.getForProgramStage($scope.currentStage);
@@ -337,13 +337,13 @@
     };
     
     $scope.saveDatavalue = function(prStDe){
-        
+
         //check for input validity
         $scope.dataEntryOuterForm.submitted = true;        
         if( $scope.dataEntryOuterForm.$invalid ){            
             return false;
         }
-         
+
         //input is valid        
         var value = $scope.currentEvent[prStDe.dataElement.id];
         

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2015-01-05 10:20:46 +0000
@@ -93,7 +93,7 @@
                            ng-class="{'input-success': eventDateSaved}"
                            d2-date 
                            ng-model="currentEvent.eventDate"
-                           ng-disabled="currentEvent.status === 'SKIPPED'"    
+                           ng-disabled="currentEvent.status === 'SKIPPED' || currentEvent.enrollmentStatus === 'COMPLETED'"    
                            ng-required="true"
                            blur-or-change="saveEventDate()"/>
                     <span ng-if="invalidDate" class="error">{{'date_required'| translate}}</span>
@@ -112,7 +112,7 @@
                            d2-date 
                            ng-model="currentEvent.dueDate"
                            blur-or-change="saveDueDate()" 
-                           ng-disabled="currentEvent.eventDate || !schedulingEnabled"/>
+                           ng-disabled="currentEvent.eventDate || !schedulingEnabled || currentEvent.enrollmentStatus === 'COMPLETED'"/>
                     <span ng-if="invalidDate" class="error">{{'date_required'| translate}}</span>
                 </div>                        
             </div>
@@ -126,11 +126,25 @@
 
             <div class="form-group">
                 <div class='row'><hr></div>
-                <a href ng-click="completeIncompleteEvent()" class="btn btn-warning" ng-if="currentEvent.eventDate && ( currentEvent.status === 'SCHEDULE' || currentEvent.status === 'ACTIVE' || currentEvent.status === 'VISITED')">{{'complete'| translate}}</a>
-                <a href ng-click="completeIncompleteEvent()" class="btn btn-warning" ng-if="currentEvent.eventDate && currentEvent.status === 'COMPLETED'">{{'incomplete'| translate}}</a>                       
-                <a href ng-click="validateEvent()" class="btn btn-info" ng-disabled="true" ng-if="currentEvent.eventDate">{{'validate'| translate}}</a>                        
-                <a href ng-click="skipUnskipEvent()" class="btn btn-warning" ng-if="!currentEvent.eventDate">{{currentEvent.status === 'SKIPPED' ? 'unskip' : 'skip'| translate}}</a>
-                <a href ng-click="deleteEvent()" class="btn btn-danger">{{'delete'| translate}}</a>
+                <a href ng-click="completeIncompleteEvent()" 
+                   class="btn btn-warning" 
+                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'"
+                   ng-if="currentEvent.eventDate && ( currentEvent.status === 'SCHEDULE' || currentEvent.status === 'ACTIVE' || currentEvent.status === 'VISITED')">{{'complete'| translate}}</a>
+                <a href ng-click="completeIncompleteEvent()" 
+                   class="btn btn-warning"
+                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'"
+                   ng-if="currentEvent.eventDate && currentEvent.status === 'COMPLETED'">{{'incomplete'| translate}}</a>                       
+                <a href ng-click="validateEvent()" 
+                   class="btn btn-info" 
+                   ng-disabled="true || currentEvent.enrollmentStatus === 'COMPLETED'" 
+                   ng-if="currentEvent.eventDate">{{'validate'| translate}}</a>                        
+                <a href ng-click="skipUnskipEvent()" 
+                   class="btn btn-warning" 
+                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'"
+                   ng-if="!currentEvent.eventDate">{{currentEvent.status === 'SKIPPED' ? 'unskip' : 'skip'| translate}}</a>
+                <a href ng-click="deleteEvent()" 
+                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'"
+                   class="btn btn-danger">{{'delete'| translate}}</a>
             </div>
         </div>
 
@@ -156,7 +170,7 @@
                         <d2-pop-over content="note" template="popover.html" details="{{'details'| translate}}">
                             <div>{{note.value}}</div>
                         </d2-pop-over>
-                        <script type="text/ng-template" id="note.html">
+                        <script type="text/ng-template" id="popover.html">
                             <p>{{content.value}}</p>
                             <hr>
                             <p><strong>{{'created_by' | translate}}: </strong>{{content.storedBy}}</p>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html	2014-12-16 15:44:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html	2015-01-05 10:20:46 +0000
@@ -25,6 +25,7 @@
                                    ng-class='getInputNotifcationClass(prStDe.dataElement.id,false)'
                                    ng-model="currentEvent[prStDe.dataElement.id]" 
                                    ng-required={{prStDe.compulsory}}
+                                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
                                    ng-blur="saveDatavalue(prStDe)" 
                                    name="foo"/>
                             <span ng-show="dataEntryOuterForm.submitted && dataEntryInnerForm.foo.$invalid" class="error">{{'number_required'| translate}}</span>
@@ -36,6 +37,7 @@
                                         ng-class='getInputNotifcationClass(prStDe.dataElement.id,false)'
                                         ng-model="currentEvent[prStDe.dataElement.id]" 
                                         ng-required={{prStDe.compulsory}} 
+                                        ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
                                         typeahead="option.name as option.name for option in optionSets[prStDe.dataElement.optionSet.id].options | filter:$viewValue | limitTo:20" 
                                         typeahead-open-on-focus 
                                         typeahead-editable="false"
@@ -49,6 +51,7 @@
                                             ng-class='getInputNotifcationClass(prStDe.dataElement.id,true)'
                                             name={{currentEvent[prStDe.dataElement.id]}}
                                             ng-required={{prStDe.compulsory}} 
+                                            ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
                                             ng-model="currentEvent[prStDe.dataElement.id]"
                                             ng-change="saveDatavalue(prStDe)" 
                                             value=""> {{'no_value' | translate}}<br>                                       
@@ -59,6 +62,7 @@
                                                 ng-class='getInputNotifcationClass(prStDe.dataElement.id,true)'
                                                 name={{currentEvent[prStDe.dataElement.id]}}
                                                 ng-required={{prStDe.compulsory}} 
+                                                ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
                                                 ng-model="currentEvent[prStDe.dataElement.id]"
                                                 ng-change="saveDatavalue(prStDe)" 
                                                 value={{option.name}}> {{option.name}}
@@ -70,7 +74,8 @@
                                 <input type="text"
                                     ng-class='getInputNotifcationClass(prStDe.dataElement.id,false)'
                                     ng-model="currentEvent[prStDe.dataElement.id]" 
-                                    ng-required={{prStDe.compulsory}}
+                                    ng-required={{prStDe.compulsory}} 
+                                    ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
                                     ng-blur="saveDatavalue(prStDe)" 
                                     name="foo"/>
                             </div>
@@ -79,6 +84,7 @@
                             <select ng-class='getInputNotifcationClass(prStDe.dataElement.id,false)'
                                     ng-model="currentEvent[prStDe.dataElement.id]" 
                                     ng-required={{prStDe.compulsory}} 
+                                    ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
                                     ng-change="saveDatavalue(prStDe)" 
                                     name="foo">
                                 <option value="">{{'please_select'| translate}}</option>                        
@@ -95,6 +101,7 @@
                                    ng-class='getInputNotifcationClass(prStDe.dataElement.id,false)'
                                    ng-model="currentEvent[prStDe.dataElement.id]"
                                    ng-required={{prStDe.compulsory}}  
+                                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
                                    blur-or-change="saveDatavalue(prStDe)"
                                    name="foo"/>
                         </div>
@@ -102,7 +109,8 @@
                             <input type="checkbox"                         
                                    ng-class='getInputNotifcationClass(prStDe.dataElement.id,false)'
                                    ng-model="currentEvent[prStDe.dataElement.id]"                                                               
-                                   ng-required={{prStDe.compulsory}}
+                                   ng-required={{prStDe.compulsory}} 
+                                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
                                    ng-change="saveDatavalue(prStDe)" 
                                    name="foo"/>
                         </div>

=== 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	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js	2015-01-05 10:20:46 +0000
@@ -16,15 +16,18 @@
                 DialogService) {
     
     $scope.today = DateUtils.getToday();
+    $scope.selectedOrgUnit = storage.get('SELECTED_OU');
     
     //listen for the selected items
     $scope.$on('selectedItems', function(event, args) {   
         $scope.enrollments = [];
+        $scope.cancelledEnrollments = [];
+        $scope.completedEnrollments = [];
         $scope.showEnrollmentDiv = false;
-        $scope.showReSchedulingDiv = false;
         $scope.showEnrollmentHistoryDiv = false;
         $scope.hasEnrollmentHistory = false;
         $scope.selectedEnrollment = null;
+        var selectedEnrollment = null;
         $scope.newEnrollment = {};
         
         var selections = CurrentSelection.get();
@@ -33,42 +36,34 @@
         $scope.selectedProgram = selections.pr;
         $scope.optionSets = selections.optionSets;
         $scope.programs = selections.prs;
-        $scope.selectedEnrollment = selections.enrollment;
+        selectedEnrollment = selections.selectedEnrollment;
+        $scope.enrollments = selections.enrollments;
+        
+        if(selectedEnrollment){//enrollment exists
+            selectedEnrollment.dateOfIncident = DateUtils.formatFromApiToUser(selectedEnrollment.dateOfIncident);
+            selectedEnrollment.dateOfEnrollment = DateUtils.formatFromApiToUser(selectedEnrollment.dateOfEnrollment);
+        }
         
         $scope.programExists = args.programExists;
         
-        $scope.selectedOrgUnit = storage.get('SELECTED_OU');
-        
-        if($scope.selectedProgram){             
-            EnrollmentService.getByEntityAndProgram($scope.selectedTei.trackedEntityInstance, $scope.selectedProgram.id).then(function(data){
-                $scope.enrollments = data.enrollments;                
-                $scope.loadEnrollmentDetails();                
-            });
-        }
-        else{
-            $scope.broadCastSelections('dashboardWidgets');
-        }
-    });
-    
-    $scope.loadEnrollmentDetails = function() {
-        
-        if($scope.selectedProgram){           
+        if($scope.selectedProgram){
             
             $scope.selectedProgramWithStage = [];        
             angular.forEach($scope.selectedProgram.programStages, function(stage){
                 $scope.selectedProgramWithStage[stage.id] = stage;
             });
-          
-            //check for possible enrollment, there is only one active enrollment
-            $scope.terminatedEnrollments = [];
-            $scope.completedEnrollments = [];
+            
             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'){
-                        $scope.selectedEnrollment = enrollment;
+                        selectedEnrollment = enrollment;
                     }
                     if(enrollment.status === 'CANCELLED'){//check for cancelled ones
-                        $scope.terminatedEnrollments.push(enrollment);
+                        $scope.cancelledEnrollments.push(enrollment);
                         $scope.hasEnrollmentHistory = true;
                     }
                     if(enrollment.status === 'COMPLETED'){//check for completed ones
@@ -76,29 +71,41 @@
                         $scope.hasEnrollmentHistory = true;
                     }
                 }
-            }); 
+            });
             
-            if($scope.selectedEnrollment){//enrollment exists
-                $scope.selectedEnrollment.dateOfIncident = DateUtils.formatFromApiToUser($scope.selectedEnrollment.dateOfIncident);
-                $scope.selectedEnrollment.dateOfEnrollment = DateUtils.formatFromApiToUser($scope.selectedEnrollment.dateOfEnrollment);
-            }
-            else{//prepare for possible enrollment
-                AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
-                    $scope.attributesForEnrollment = [];
-                    for(var i=0; i<atts.length; i++){
-                        var exists = false;
-                        for(var j=0; j<$scope.selectedTei.attributes.length && !exists; j++){
-                            if(atts[i].id === $scope.selectedTei.attributes[j].attribute){
-                                exists = true;                                
-                            }
-                        }
-                        if(!exists){
-                            $scope.attributesForEnrollment.push(atts[i]);
-                        }
-                    }
-                });                
-            }           
-        }
+            if(selectedEnrollment){
+                $scope.selectedEnrollment = selectedEnrollment;
+                $scope.loadEnrollmentDetails(selectedEnrollment);
+            }
+            else{
+                $scope.selectedEnrollment = null;
+                $scope.broadCastSelections('dashboardWidgets');
+            }
+        }
+    });
+    
+    $scope.loadEnrollmentDetails = function(enrollment) {        
+        
+        //$scope.showEnrollmentHistoryDiv = false;
+        $scope.selectedEnrollment = enrollment;
+        
+        if(!$scope.selectedEnrollment){//prepare for possible enrollment
+            AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
+                $scope.attributesForEnrollment = [];
+                for(var i=0; i<atts.length; i++){
+                    var exists = false;
+                    for(var j=0; j<$scope.selectedTei.attributes.length && !exists; j++){
+                        if(atts[i].id === $scope.selectedTei.attributes[j].attribute){
+                            exists = true;                                
+                        }
+                    }
+                    if(!exists){
+                        $scope.attributesForEnrollment.push(atts[i]);
+                    }
+                }                
+            });                
+        }
+        
         $scope.broadCastSelections('dashboardWidgets');
     };
         
@@ -107,10 +114,15 @@
             $scope.hideEnrollmentDiv();
         }
         
+        if($scope.showEnrollmentHistoryDiv){
+            $scope.showEnrollmentHistoryDiv = !$scope.showEnrollmentHistoryDiv;
+        }
+        
         $scope.showEnrollmentDiv = !$scope.showEnrollmentDiv;
         
         if($scope.showEnrollmentDiv){
-            
+            $scope.selectedEnrollment = null;
+            $scope.broadCastSelections('dashboardWidgets');            
             $scope.selectedProgram.hasCustomForm = false;
             $scope.registrationForm = '';
             TEFormService.getByProgram($scope.selectedProgram.id).then(function(teForm){
@@ -123,8 +135,11 @@
         }
     };
        
-    $scope.showReScheduling = function(){        
-        $scope.showReSchedulingDiv = !$scope.showReSchedulingDiv;
+    $scope.showEnrollmentHistory = function(){
+        if($scope.showEnrollmentDiv){
+            $scope.showEnrollmentDiv = !$scope.showEnrollmentDiv;
+        }        
+        $scope.showEnrollmentHistoryDiv = !$scope.showEnrollmentHistoryDiv;
     };
     
     $scope.enroll = function(){    
@@ -172,6 +187,8 @@
                     $scope.selectedEnrollment = enrollment;
                     $scope.selectedEnrollment.dateOfEnrollment = DateUtils.formatFromApiToUser(enrollment.dateOfEnrollment);
                     $scope.selectedEnrollment.dateOfIncident = DateUtils.formatFromApiToUser(enrollment.dateOfIncident);
+                    $scope.enrollments.push($scope.selectedEnrollment);
+                    
                     $scope.autoGenerateEvents();                    
                     $scope.broadCastSelections('dashboardWidgets'); 
                     
@@ -191,8 +208,8 @@
         });
     };
     
-    $scope.broadCastSelections = function(listeners){
-        CurrentSelection.set({tei: $scope.selectedTei, te: $scope.selectedEntity, prs: $scope.programs, pr: $scope.selectedProgram, enrollment: $scope.selectedEnrollment, optionSets: $scope.optionSets});
+    $scope.broadCastSelections = function(listeners){        
+        CurrentSelection.set({tei: $scope.selectedTei, te: $scope.selectedEntity, prs: $scope.programs, pr: $scope.selectedProgram, enrollments: $scope.enrollments, selectedEnrollment: $scope.selectedEnrollment, optionSets: $scope.optionSets});
         $timeout(function(){
             $rootScope.$broadcast(listeners, {});
         }, 100);
@@ -243,11 +260,6 @@
             });
         });
     };
-    
-    $scope.showEnrollmentHistory = function(){
-        //$scope.showEnrollmentHistoryDiv = !$scope.showEnrollmentHistoryDiv;
-        console.log('need to figure out how to deal with previous enrollments'); 
-    };
         
     $scope.autoGenerateEvents = function(){
         if($scope.selectedTei && $scope.selectedProgram && $scope.selectedOrgUnit && $scope.selectedEnrollment){            

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html	2014-12-16 15:44:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html	2015-01-05 10:20:46 +0000
@@ -1,12 +1,13 @@
 <div class="panel panel-info" ng-controller="EnrollmentController">
     <div class="panel-heading handle bold">                                            
-        {{enrollmentWidget.title| translate}}
-        <span class="nav-pills" ng-show="selectedProgram && !selectedEnrollment">
-            | <a href ng-click="showNewEnrollment()" title="{{'new'| translate}}"><span class="bold">{{'new'| translate}}</span></a>
+        <span ng-class="{'light-blue': true}">{{enrollmentWidget.title| translate}}</span>
+        <span class="nav-pills" ng-show="selectedProgram && (!selectedEnrollment || selectedEnrollment.status === 'COMPLETED')">
+            | <a href ng-click="showNewEnrollment()" title="{{'new'| translate}}"><span ng-class="{'light-blue': !showEnrollmentDiv}">{{'new'| translate}}</span></a>
         </span>
         <span class="nav-pills" ng-show="terminatedEnrollments.length > 0 || completedEnrollments.length > 0">
-            | <a href ng-click="showEnrollmentHistory()" title="{{'history'| translate}}"><span class="bold">{{'history'| translate}}</span></a>
+            | <a href ng-click="showEnrollmentHistory()" title="{{'history'| translate}}"><span ng-class="{'light-blue': !showEnrollmentHistoryDiv}">{{'history'| translate}}</span></a>
         </span>        
+
         <span class="pull-right">
             <a class="small-horizonal-spacing" href ng-click="expandCollapse(enrollmentWidget)">
                 <span ng-show="enrollmentWidget.expand"><i class="fa fa-chevron-up" title="{{'collapse'| translate}}"></i></span>
@@ -17,7 +18,7 @@
     </div>
     <div ng-show="enrollmentWidget.expand" class="panel-body dashboard-widget-container">
         <!-- operations on selected enrollment begins -->
-        <div ng-if="selectedEnrollment && !showEnrollmentHistoryDiv && !showReSchedulingDiv">
+        <div ng-if="selectedEnrollment">
             <table class="table-borderless table-striped">
                 <tr class="col-md-12">
                     <td class="col-md-6">
@@ -36,36 +37,40 @@
                     </td>
                 </tr>                
             </table>
-            
-            
+
+
             <div class="vertical-spacing horizonal-spacing">
 
                 <button type="button" 
                         class="btn btn-primary"
+                        ng-disabled="selectedEnrollment.status === 'COMPLETED'"
                         ng-click="completeEnrollment()">
                     {{'complete'| translate}}
                 </button>
                 <button type="button" 
                         class="btn btn-warning"
+                        ng-disabled="selectedEnrollment.status === 'COMPLETED'"
                         ng-click="terminateEnrollment()">
                     {{'terminate'| translate}}
                 </button>   
-                
+
                 <button type="button"
-                        title="{{'unmark_for_followup' | translate}}"
+                        title="{{'unmark_for_followup'| translate}}"
                         class="btn btn-danger horizonal-spacing"
+                        ng-disabled="selectedEnrollment.status === 'COMPLETED'"
                         ng-if="selectedEnrollment.followup"
                         ng-click="markForFollowup()">
                     <i class="fa fa-exclamation-triangle"></i>
                 </button>
                 <button type="button" 
-                        title="{{'mark_for_followup' | translate}}"
+                        title="{{'mark_for_followup'| translate}}"
                         class="btn btn-default horizonal-spacing"
+                        ng-disabled="selectedEnrollment.status === 'COMPLETED'"
                         ng-if="!selectedEnrollment.followup"
                         ng-click="markForFollowup()">
                     <i class="fa fa-exclamation-triangle"></i>
                 </button>
-                
+
             </div>
         </div>
         <!-- operations on selected enrollment ends -->
@@ -106,86 +111,86 @@
                     </tr>
                 </table>
                 <hr ng-if='attributesForEnrollment'>
-                
+
                 <table class="table-borderless table-striped">
                     <tr class="col-md-12" ng-repeat="attribute in attributesForEnrollment">
                         <td class="col-md-6">
                             {{attribute.name}}
                         </td>
                         <td class="col-md-6">
-                            <ng-form name="innerForm">
-                                <div ng-switch="attribute.valueType">
-                                    <div ng-switch-when="date">
-                                        <input type="text" 
-                                               placeholder="{{dhis2CalendarFormat.keyDateFormat}}" 
-                                               class="form-control" 
-                                               name="foo" 
-                                               max-date="attribute.allowFutureDate ? '' : 0"
-                                               d2-date 
-                                               ng-model="attribute.value" 
-                                               ng-required="attribute.mandatory"/>                                        
-                                    </div>
-                                    <div ng-switch-when="trueOnly">
-                                        <input type="checkbox" class="form-control" name="foo" ng-model="attribute.value" ng-required="attribute.mandatory"/>                                        
-                                    </div>
-                                    <div ng-switch-when="bool">
-                                        <select ng-model="attribute.value" name="foo" class="form-control" ng-required="attribute.mandatory">
-                                            <option value="">{{'please_select'| translate}}</option>                        
-                                            <option value="false">{{'no'| translate}}</option>
-                                            <option value="true">{{'yes'| translate}}</option>
-                                        </select>                                        
-                                    </div>
-                                    <div ng-switch-when="optionSet">
-                                        <div ng-if="!selectedProgram.dataEntryMethod || optionSets[attribute.optionSet.id].options.length >= 7">
-                                            <input type="text" 
-                                               name="foo"
-                                               class="form-control"
-                                               ng-model="attribute.value"                                                 
-                                               typeahead="option.name as option.name for option in optionSets[attribute.optionSet.id].options | filter:$viewValue | limitTo:20" 
-                                               typeahead-open-on-focus
-                                               typeahead-editable="false"
-                                               ng-required="attribute.mandatory"/>
-                                        </div>
-                                        <div ng-if="selectedProgram.dataEntryMethod && optionSets[attribute.optionSet.id].options.length < 7">
-                                            <label>                                        
-                                                <input type="radio"
-                                                    name={{attribute.id}}
-                                                    ng-required="attribute.mandatory"
-                                                    ng-model="attribute.value"
-                                                    value=""> {{'no_value' | translate}}<br>                                       
-                                            </label><br>
-                                            <span ng-repeat="option in optionSets[attribute.optionSet.id].options">
-                                                <label>
-                                                    <input type="radio"
-                                                        name={{attribute.id}}
-                                                        ng-required="attribute.mandatory"
-                                                        ng-model="attribute.value" 
-                                                        value={{option.name}}> {{option.name}}
-                                                </label><br>
-                                            </span>                                            
-                                        </div>
-                                    </div>
-                                    <div ng-switch-when="number">
-                                        <input type="number" 
-                                               class="form-control" 
-                                               name="foo" 
-                                               ng-model="attribute.value" 
-                                               ng-required="attribute.mandatory"/>                                        
-                                    </div>
-                                    <div ng-switch-default>
-                                        <input type="text" 
-                                               class="form-control" 
-                                               name="foo" 
-                                               ng-model="attribute.value" 
-                                               ng-required="attribute.mandatory"/>                                        
-                                    </div>
-                                </div>
-                            </ng-form>
-                            <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
-                        </td>
+                    <ng-form name="innerForm">
+                        <div ng-switch="attribute.valueType">
+                            <div ng-switch-when="date">
+                                <input type="text" 
+                                       placeholder="{{dhis2CalendarFormat.keyDateFormat}}" 
+                                       class="form-control" 
+                                       name="foo" 
+                                       max-date="attribute.allowFutureDate ? '' : 0"
+                                       d2-date 
+                                       ng-model="attribute.value" 
+                                       ng-required="attribute.mandatory"/>                                        
+                            </div>
+                            <div ng-switch-when="trueOnly">
+                                <input type="checkbox" class="form-control" name="foo" ng-model="attribute.value" ng-required="attribute.mandatory"/>                                        
+                            </div>
+                            <div ng-switch-when="bool">
+                                <select ng-model="attribute.value" name="foo" class="form-control" ng-required="attribute.mandatory">
+                                    <option value="">{{'please_select'| translate}}</option>                        
+                                    <option value="false">{{'no'| translate}}</option>
+                                    <option value="true">{{'yes'| translate}}</option>
+                                </select>                                        
+                            </div>
+                            <div ng-switch-when="optionSet">
+                                <div ng-if="!selectedProgram.dataEntryMethod || optionSets[attribute.optionSet.id].options.length >= 7">
+                                    <input type="text" 
+                                           name="foo"
+                                           class="form-control"
+                                           ng-model="attribute.value"                                                 
+                                           typeahead="option.name as option.name for option in optionSets[attribute.optionSet.id].options | filter:$viewValue | limitTo:20" 
+                                           typeahead-open-on-focus
+                                           typeahead-editable="false"
+                                           ng-required="attribute.mandatory"/>
+                                </div>
+                                <div ng-if="selectedProgram.dataEntryMethod && optionSets[attribute.optionSet.id].options.length < 7">
+                                    <label>                                        
+                                        <input type="radio"
+                                               name={{attribute.id}}
+                                               ng-required="attribute.mandatory"
+                                               ng-model="attribute.value"
+                                               value=""> {{'no_value'| translate}}<br>                                       
+                                    </label><br>
+                                    <span ng-repeat="option in optionSets[attribute.optionSet.id].options">
+                                        <label>
+                                            <input type="radio"
+                                                   name={{attribute.id}}
+                                                   ng-required="attribute.mandatory"
+                                                   ng-model="attribute.value" 
+                                                   value={{option.name}}> {{option.name}}
+                                        </label><br>
+                                    </span>                                            
+                                </div>
+                            </div>
+                            <div ng-switch-when="number">
+                                <input type="number" 
+                                       class="form-control" 
+                                       name="foo" 
+                                       ng-model="attribute.value" 
+                                       ng-required="attribute.mandatory"/>                                        
+                            </div>
+                            <div ng-switch-default>
+                                <input type="text" 
+                                       class="form-control" 
+                                       name="foo" 
+                                       ng-model="attribute.value" 
+                                       ng-required="attribute.mandatory"/>                                        
+                            </div>
+                        </div>
+                    </ng-form>
+                    <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+                    </td>
                     </tr>                        
                 </table>
-                
+
                 <div class="vertical-spacing col-md-12">            
                     <button type="button" 
                             class="btn btn-primary"
@@ -203,16 +208,35 @@
         <!-- new enrollment registration form ends -->
 
         <!-- operations on historical enrollment begins -->
-        <div ng-if="showEnrollmentHistoryDiv">
-            enrollment history here...
+        <div ng-if="showEnrollmentHistoryDiv && !selectedEnrollment">
+            <div class="row">
+                <table class="table table-bordered table-striped dhis2-table-hover">
+                    <tr>
+                        <th>
+                            {{selectedProgram.dateOfEnrollmentDescription}}
+                        </th>
+                        <th>
+                            {{selectedProgram.dateOfIncidentDescription}}
+                        </th>
+                    </tr>
+                    <tr ng-click="loadEnrollmentDetails(en)" ng-repeat="en in completedEnrollments" title="{{'details'| translate}}">
+                        <td>
+                            {{en.dateOfEnrollment}}
+                        </td>
+                        <td>
+                            {{en.dateOfIncident}}
+                        </td>
+                    </tr>
+                </table>
+            </div>
         </div>
         <!-- operations on historical enrollment ends -->
 
         <div ng-if="selectedProgram && !selectedEnrollment && !showEnrollmentDiv && !hasEnrollmentHistory">
             <div class="alert alert-warning">{{'not_yet_enrolled_enrollment'| translate}}</div> 
         </div>
-        <div ng-if="selectedProgram && !selectedEnrollment && !showEnrollmentDiv && hasEnrollmentHistory">
-            <div class="alert alert-warning">{{'not_active_enrollment_exists'| translate}}</div> 
+        <div ng-if="selectedProgram && !selectedEnrollment && !showEnrollmentDiv && !showEnrollmentHistoryDiv && hasEnrollmentHistory">
+            <div class="alert alert-warning">{{'no_active_enrollment_exists'| translate}}</div> 
         </div>
         <div ng-if="!selectedProgram && programExists">
             <div class="alert alert-danger">{{'please_select_a_program_for_enrollment'| translate}}</div> 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js	2015-01-05 10:20:46 +0000
@@ -24,8 +24,8 @@
         $scope.selectedProgram = selections.pr;
         
         var selections = CurrentSelection.get();
-        if(selections.enrollment){
-            EnrollmentService.get(selections.enrollment.enrollment).then(function(data){    
+        if(selections.selectedEnrollment){
+            EnrollmentService.get(selections.selectedEnrollment.enrollment).then(function(data){    
                 $scope.selectedEnrollment = data;   
                 if(!angular.isUndefined( $scope.selectedEnrollment.notes)){
                     $scope.selectedEnrollment.notes = orderByFilter($scope.selectedEnrollment.notes, '-storedDate');            

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes.html	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes.html	2015-01-05 10:20:46 +0000
@@ -42,7 +42,7 @@
                             <d2-pop-over content="note" template="popover.html" details="{{'details'| translate}}">
                                 <div>{{note.value}}</div>
                             </d2-pop-over>
-                            <script type="text/ng-template" id="note.html">
+                            <script type="text/ng-template" id="popover.html">
                                 <p>{{content.value}}</p>
                                 <hr>
                                 <p><strong>{{'created_by' | translate}}: </strong>{{content.storedBy}}</p>

=== 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	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js	2015-01-05 10:20:46 +0000
@@ -24,7 +24,7 @@
 
         $scope.trackedEntity = selections.te;
         $scope.selectedProgram = selections.pr;   
-        $scope.selectedEnrollment = selections.enrollment;
+        $scope.selectedEnrollment = selections.selectedEnrollment;
         $scope.optionSets = selections.optionSets;
 
         //display only those attributes that belong to the selected program

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js	2015-01-05 10:20:46 +0000
@@ -27,7 +27,7 @@
         $scope.optionSets = $scope.selections.optionSets;
         $scope.selectedTei = angular.copy($scope.selections.tei);        
         $scope.trackedEntity = $scope.selections.te;
-        $scope.selectedEnrollment = $scope.selections.enrollment;
+        $scope.selectedEnrollment = $scope.selections.selectedEnrollment;
         $scope.selectedProgram = $scope.selections.pr;
         $scope.programs = $scope.selections.pr;
         

=== 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	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/tei-report-controller.js	2015-01-05 10:20:46 +0000
@@ -32,7 +32,7 @@
         $scope.selectedTei = selections.tei;  
         $scope.selectedEntity = selections.te;
         $scope.selectedProgram = selections.pr;        
-        $scope.selectedEnrollment = selections.enrollment;
+        $scope.selectedEnrollment = selections.selectedEnrollment;
         $scope.optionSets = selections.optionSets;
     
         if($scope.selectedTei && $scope.selectedOrgUnit){            

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-01-05 10:20:46 +0000
@@ -13,7 +13,7 @@
 no_program_exists_report=No program exists for the selected org unit. Reporting not possible.
 not_yet_enrolled_data_entry=Not yet enrolled. Data entry not possible.
 not_yet_enrolled_enrollment=Not yet enrolled. Please enroll.
-not_active_enrollment_exists=No active enrollment exists for the selected program
+no_active_enrollment_exists=No active enrollment exists for the selected program
 not_yet_enrolled_note=Not yet enrolled. Note recording not possible.
 not_yet_enrolled_report=Not yet enrolled. Reporting not possible
 no_data_report=No record exists for reporting

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/angular/plugins/dhis2/services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/angular/plugins/dhis2/services.js	2014-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/angular/plugins/dhis2/services.js	2015-01-05 10:20:46 +0000
@@ -222,6 +222,8 @@
                                             ' d2-number-validation ' +
                                             ' number-type="' + programStageDataElements[deId].dataElement.numberType + '" ' +
                                             ' ng-model="currentEvent.' + deId + '"' +
+                                            ' ng-class="getInputNotifcationClass(prStDes.' + deId + '.dataElement.id,true)"' +
+                                            ' ng-blur="saveDatavalue(prStDes.'+ deId + ')"' + 
                                             ' ng-required="prStDes.' + deId + '.compulsory"> ' + 
                                             '<span ng-show="outerForm.submitted && outerForm.'+ deId +'.$invalid" class="required">{{\'value_must_be\'| translate}} - {{ "' + programStageDataElements[deId].dataElement.numberType + '" | translate}}</span>';                                     
                         }
@@ -239,6 +241,8 @@
                                             ' d2-typeahead-validation ' +
                                             ' class="typeahead" ' +
                                             ' placeholder="&#xf0d7;&nbsp;&nbsp;" ' +
+                                            ' ng-class="getInputNotifcationClass(prStDes.' + deId + '.dataElement.id,true)"' +                                            
+                                            ' ng-blur="saveDatavalue(prStDes.'+ deId + ')"' +
                                             ' typeahead-open-on-focus ng-required="prStDes.'+deId+'.compulsory"> ' +
                                             '<span ng-show="outerForm.submitted && outerForm.'+ deId +'.$invalid" class="required">{{\'option_required\'| translate}}</span>';
                         	}
@@ -248,6 +252,8 @@
                                             ' d2-validation ' +
                                             ' ng-model="currentEvent.' + deId + '" ' +
                                             ' ng-disabled="currentEvent[uid] == \'uid\'" ' +
+                                            ' ng-class="getInputNotifcationClass(prStDes.' + deId + '.dataElement.id,true)"' +
+                                            ' ng-blur="saveDatavalue(prStDes.'+ deId + ')"' +
                                             ' ng-required="prStDes.' + deId + '.compulsory"> ' +
                                             '<span ng-show="outerForm.submitted && outerForm.'+ deId +'.$invalid" class="required">{{\'string_required\'| translate}}</span>';                                     
                         	}
@@ -257,6 +263,8 @@
                                             this.getAttributesAsString(attributes) +
                                             ' d2-validation ' +
                                             ' ng-model="currentEvent.' + deId + '" ' +
+                                            ' ng-class="getInputNotifcationClass(prStDes.' + deId + '.dataElement.id,true)"' +
+                                            ' ng-change="saveDatavalue(prStDes.'+ deId + ')"' + 
                                             ' ng-required="prStDes.' + deId + '.compulsory">' + 
                                             '<option value="">{{\'please_select\'| translate}}</option>' +
                                             '<option value="false">{{\'no\'| translate}}</option>' + 
@@ -271,6 +279,8 @@
                                             ' ng-model="currentEvent.' + deId + '"' +
                                             ' d2-date ' +
                                             ' max-date="' + maxDate + '"' + '\'' +
+                                            ' ng-class="getInputNotifcationClass(prStDes.' + deId + '.dataElement.id,true)"' +
+                                            ' blur-or-change="saveDatavalue(prStDes.'+ deId + ')"' + 
                                             ' ng-required="prStDes.' + deId + '.compulsory"> ' +
                                             '<span ng-show="outerForm.submitted && outerForm.'+ deId +'.$invalid" class="required">{{\'date_required\'| translate}}</span>'; 
                         }
@@ -279,6 +289,8 @@
                                             this.getAttributesAsString(attributes) +
                                             ' d2-validation ' +
                                             ' ng-model="currentEvent.' + deId + '"' +
+                                            ' ng-class="getInputNotifcationClass(prStDes.' + deId + '.dataElement.id,true)"' +
+                                            ' ng-change="saveDatavalue(prStDes.'+ deId + ')"' +
                                             ' ng-required="prStDes.' + deId + '.compulsory"> ' +
                                             '<span ng-show="outerForm.submitted && outerForm.'+ deId +'.$invalid" class="required">{{\'required\'| translate}}</span>';
                         }