← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21441: tracker-capture: it is now possible to re-activeate a completed enrollment. But this is possible ...

 

------------------------------------------------------------
revno: 21441
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-12-14 16:05:21 +0100
message:
  tracker-capture: it is now possible to re-activeate a completed enrollment. But this is possible only if there is no other active enrollment going on.
modified:
  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/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/i18n/i18n_app.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/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/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-12-14 08:59:22 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-12-14 15:05:21 +0000
@@ -382,7 +382,7 @@
     };
 
     $scope.stageNeedsEvent = function (stage) {
-
+        
         //In case the event is a table, we sould always allow adding more events(rows)
         if (stage.displayEventsInTable) {
             return true;
@@ -931,7 +931,7 @@
         };
 
         ModalService.showModal({}, modalOptions).then(function (result) {
-            EnrollmentService.complete($scope.selectedEnrollment).then(function (data) {
+            EnrollmentService.completeIncomplete($scope.selectedEnrollment, 'completed').then(function (data) {
                 $scope.selectedEnrollment.status = 'COMPLETED';
             });
         });

=== 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	2015-12-10 13:40:47 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2015-12-14 15:05:21 +0000
@@ -94,7 +94,7 @@
                                max-date="0"
                                min-date=""
                                ng-model="currentEvent.eventDate"
-                               ng-disabled="currentEvent.status === 'SKIPPED' || currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed"    
+                               ng-disabled="currentEvent.status === 'SKIPPED' || selectedEnrollment.status !== 'ACTIVE' || currentEvent.editingNotAllowed"    
                                ng-required="true"
                                blur-or-change="saveEventDate()"/>
                         <span ng-if="invalidDate" class="error">{{'date_required'| translate}}</span>
@@ -113,7 +113,7 @@
                                d2-date                                
                                ng-model="currentEvent.dueDate"
                                blur-or-change="saveDueDate()" 
-                               ng-disabled="currentEvent.eventDate || !schedulingEnabled || currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed"/>
+                               ng-disabled="currentEvent.eventDate || !schedulingEnabled || selectedEnrollment.status !== 'ACTIVE' || currentEvent.editingNotAllowed"/>
                         <span ng-if="invalidDate" class="error">{{'date_required'| translate}}</span>
                     </div>                        
                 </div>
@@ -168,22 +168,22 @@
                     <div class='row'><hr></div>
                     <a href ng-click="completeIncompleteEvent()" 
                        class="btn btn-warning" 
-                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id"
+                       ng-disabled="selectedEnrollment.status !== 'ACTIVE' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id"
                        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 !== 'ACTIVE' || currentEvent.editingNotAllowed && currentEvent.status !== 'COMPLETED' || currentEvent.orgUnit !== selectedOrgUnit.id"
+                       ng-disabled="selectedEnrollment.status !== 'ACTIVE' || currentEvent.editingNotAllowed && currentEvent.status !== 'COMPLETED' || currentEvent.orgUnit !== selectedOrgUnit.id"
                        ng-if="currentEvent.eventDate && currentEvent.status === 'COMPLETED'">{{'incomplete'| translate}}</a>
                     <a href ng-click="validateEvent()" 
                        class="btn btn-info" 
-                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id" 
+                       ng-disabled="selectedEnrollment.status !== 'ACTIVE' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id" 
                        ng-if="currentEvent.eventDate">{{'validate'| translate}}</a>                        
                     <a href ng-click="skipUnskipEvent()" 
                        class="btn btn-warning" 
-                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id"
+                       ng-disabled="selectedEnrollment.status !== 'ACTIVE' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id"
                        ng-if="!currentEvent.eventDate">{{currentEvent.status === 'SKIPPED' ? 'unskip' : 'skip'| translate}}</a>
                     <a href ng-click="deleteEvent()" 
-                       ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id"
+                       ng-disabled="selectedEnrollment.status === 'COMPLETED' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id"
                        class="btn btn-danger">{{'delete'| translate}}</a>
                     <a href class="btn btn-primary" ng-click="print('print-div');">{{'print_form'| translate}}</a>
                 </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	2015-12-14 10:17:47 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js	2015-12-14 15:05:21 +0000
@@ -11,6 +11,7 @@
                 CurrentSelection,
                 OrgUnitService,
                 EnrollmentService,
+                DialogService,
                 ModalService) {
     
     $scope.today = DateUtils.getToday();
@@ -192,15 +193,31 @@
 
         var modalOptions = {
             closeButtonText: 'cancel',
-            actionButtonText: 'complete',
-            headerText: 'complete_enrollment',
-            bodyText: 'are_you_sure_to_complete_enrollment'
+            actionButtonText: $scope.selectedEnrollment.status === 'ACTIVE' ? 'complete' : 'incomplete',
+            headerText: $scope.selectedEnrollment.status === 'ACTIVE' ? 'complete_enrollment' : 'incomplete_enrollment',
+            bodyText: $scope.selectedEnrollment.status === 'ACTIVE' ? 'are_you_sure_to_complete_enrollment' : 'are_you_sure_to_incomplete_enrollment'
         };
 
         ModalService.showModal({}, modalOptions).then(function(result){            
-            EnrollmentService.complete($scope.selectedEnrollment).then(function(data){                
-                $scope.selectedEnrollment.status = 'COMPLETED';
+            
+            var status = 'completed';            
+            
+            if($scope.selectedEnrollment.status === 'COMPLETED'){
+                status = 'incompleted';
+            }
+            
+            EnrollmentService.completeIncomplete($scope.selectedEnrollment, status).then(function(data){                                
+                $scope.selectedEnrollment.status = $scope.selectedEnrollment.status === 'ACTIVE' ? 'COMPLETED' : 'ACTIVE';
                 $scope.loadEnrollmentDetails($scope.selectedEnrollment);                
+            }, function(response){
+                if(response && response.data && response.data.status === "ERROR"){
+                    //notify user
+                    var dialogOptions = {
+                            headerText: response.data.status,
+                            bodyText: response.data.message
+                        };
+                    DialogService.showDialog({}, dialogOptions);
+                }
             });
         });
     };
@@ -220,4 +237,18 @@
             $location.path('/dashboard').search({tei: $scope.selectedTeiId, program: program});
         }
     };
+    
+    $scope.canUseEnrollment = function(){
+        
+        if($scope.selectedTei.inactive){
+            return false;
+        }
+        
+        if($scope.currentEnrollment && $scope.selectedEnrollment.enrollment !== $scope.currentEnrollment.enrollment){
+            if($scope.currentEnrollment.status === 'ACTIVE'){
+                return false;
+            }
+        }        
+        return true;        
+    };
 });

=== 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	2015-12-14 12:49:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html	2015-12-14 15:05:21 +0000
@@ -60,17 +60,20 @@
                     <div class="vertical-spacing">
                         <button type="button" 
                                 class="btn btn-primary"
+                                ng-disabled="!canUseEnrollment()"
                                 ng-click="completeEnrollment()">
-                            {{'complete'| translate}}
+                            {{selectedEnrollment.status === 'ACTIVE' ? 'complete' : 'incomplete' | translate}}
                         </button>
                         <button type="button" 
                                 class="btn btn-warning"
+                                ng-disabled="selectedEnrollment.status !== 'ACTIVE' || selectedTei.inactive"
                                 ng-click="cancelEnrollment()">
                             {{'cancel'| translate}}
                         </button>
                         <button type="button"
                                 title="{{selectedEnrollment.followup ? 'unmark_for_followup' : 'mark_for_followup' | translate}}"
                                 ng-class="{true: 'btn btn-danger', false: 'btn btn-default'} [selectedEnrollment.followup]"
+                                ng-disabled="selectedEnrollment.status !== 'ACTIVE' || selectedTei.inactive"
                                 ng-click="markForFollowup()">
                             <i class="fa fa-exclamation-triangle"></i>
                         </button>
@@ -142,6 +145,6 @@
         <!-- new enrollment registration form begins -->
         <div ng-if="showEnrollmentDiv" ng-include="'components/registration/registration.html'"></div>
         <!-- new enrollment registration form ends -->
-
+        
     </div>
 </div>

=== 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	2015-12-11 19:41:20 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-12-14 15:05:21 +0000
@@ -129,6 +129,7 @@
 delete_enrollment=Delete enrollment
 cancel_enrollment=Cancel enrollment
 complete_enrollment=Complete enrollment
+incomplete_enrollment=Incomplete enrollment
 enrollment_date=Enrollment date
 notes=Notes
 relationship=Relationship
@@ -301,6 +302,7 @@
 would_you_like_to_complete_enrollment=Would you like to complete the current enrollment?
 are_you_sure_to_complete_enrollment=Are you sure you want to complete the selected enrollment?
 are_you_sure_to_cancel_enrollment=Are you sure you want to cancel the selected enrollment?
+are_you_sure_to_incomplete_enrollment=Are you sure you want to incomplete the selected enrollment?
 are_you_sure_to_delete_event=Are you sure you want to delete the selected event?
 are_you_sure_to_complete_event=Are you sure you want to complete the selected event?
 please_fix_errors_before_completing=Please review and fix the following error(s) before completing the event:

=== 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-12-11 15:18:54 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-12-14 15:05:21 +0000
@@ -624,11 +624,11 @@
             });
             return promise;           
         },
-        complete: function(enrollment){
-            var promise = $http.put('../api/enrollments/' + enrollment.enrollment + '/completed').then(function(response){
+        completeIncomplete: function(enrollment, status){
+            var promise = $http.put('../api/enrollments/' + enrollment.enrollment + '/' + status).then(function(response){
                 return response.data;               
             });
-            return promise;           
+            return promise; 
         }
     };   
 })