← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17213: tracker capture - open first stage after enrollment

 

------------------------------------------------------------
revno: 17213
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-10-22 17:02:50 +0200
message:
  tracker capture - open first stage after enrollment
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/enrollment/enrollment-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/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/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2014-10-22 14:22:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2014-10-22 15:02:50 +0000
@@ -109,16 +109,7 @@
                             //dhis2Event = EventUtils.setEventOrgUnitName(dhis2Event);
                             
                             if($scope.currentStage && $scope.currentStage.id === dhis2Event.programStage){
-                                $scope.currentEvent = dhis2Event;
-                                if(!dhis2Event.eventDate){
-                                    if($scope.currentStage.reportDateToUse === 'dateOfIncident'){
-                                        $scope.currentEvent.eventDate = $scope.selectedEnrollment.dateOfIncident;
-                                    }
-                                    else{
-                                        $scope.currentEvent.eventDate = $scope.selectedEnrollment.dateOfEnrollment;
-                                    }
-                                }
-                                $scope.saveEventDate();
+                                $scope.currentEvent = dhis2Event;                                
                                 $scope.showDataEntry($scope.currentEvent, true);
                             }
                         } 
@@ -361,8 +352,8 @@
                 value = DateUtils.formatFromUserToApi(value);
             }
             if(prStDe.dataElement.type === 'string'){                    
-                if(prStDe.dataElement.optionSet && $scope.optionCodesByName[  '"' + value + '"']){                        
-                    value = $scope.optionCodesByName[  '"' + value + '"'];                                                      
+                if(prStDe.dataElement.optionSet && $scope.optionSets.optionCodesByName[  '"' + value + '"']){                        
+                    value = $scope.optionSets.optionCodesByName[  '"' + value + '"'];                                                      
                 }                    
             }
 

=== 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-10-22 11:46:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js	2014-10-22 15:02:50 +0000
@@ -325,6 +325,16 @@
                             dueDate: DateUtils.formatFromUserToApi( EventUtils.getEventDueDate(dhis2Events.events, stage, $scope.selectedEnrollment) ),
                             status: 'SCHEDULE'
                         };
+                    
+                    if(stage.openAfterEnrollment){
+                        if(stage.reportDateToUse === 'dateOfIncident'){
+                            newEvent.eventDate = DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfIncident);
+                        }
+                        else{
+                            newEvent.eventDate = DateUtils.formatFromUserToApi($scope.selectedEnrollment.dateOfEnrollment);
+                        }
+                    }
+                    
                     dhis2Events.events.push(newEvent);    
                 }
             });

=== 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	2014-10-22 14:22:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2014-10-22 15:02:50 +0000
@@ -192,9 +192,20 @@
                             dueDate: DateUtils.formatFromUserToApi(EventUtils.getEventDueDate(null,stage, enrollment)),
                             status: 'SCHEDULE'
                         };
+                    
+                    if(stage.openAfterEnrollment){
+                        if(stage.reportDateToUse === 'dateOfIncident'){
+                            newEvent.eventDate = DateUtils.formatFromUserToApi(enrollment.dateOfIncident);
+                        }
+                        else{
+                            newEvent.eventDate = DateUtils.formatFromUserToApi(enrollment.dateOfEnrollment);
+                        }
+                    }
+                    
                     dhis2Events.events.push(newEvent);    
                 }
             });
+
             if(dhis2Events.events.length > 0){
                 DHIS2EventFactory.create(dhis2Events).then(function(data){
                 });

=== 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	2014-10-22 14:22:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-10-22 15:02:50 +0000
@@ -1176,19 +1176,18 @@
                         for(var i=5; i<row.length; i++){
                             if(row[i] && row[i] !== ''){
                                 isEmpty = false;
+                                var val = row[i];
                                 if(attributes[grid.headers[i].name] && 
                                         attributes[grid.headers[i].name].valueType === 'optionSet' && 
                                         optionNamesByCode &&    
-                                        optionNamesByCode[  '"' + row[i] + '"']){
-                                    
-                                    entity[grid.headers[i].name] = optionNamesByCode[  '"' + row[i] + '"'];
+                                        optionNamesByCode[  '"' + val + '"']){
+                                    val = optionNamesByCode[  '"' + val + '"'];
                                 }
                                 if(attributes[grid.headers[i].name] && attributes[grid.headers[i].name].valueType === 'date'){                                    
-                                    entity[grid.headers[i].name] = DateUtils.formatFromApiToUser( row[i] );
-                                }
-                                else{
-                                    entity[grid.headers[i].name] = row[i];
-                                }
+                                    val = DateUtils.formatFromApiToUser( val );
+                                }
+                                
+                                entity[grid.headers[i].name] = val;
                             }
                         }
 

=== 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	2014-10-22 14:22:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2014-10-22 15:02:50 +0000
@@ -397,7 +397,7 @@
         return $.ajax( {
             url: '../api/programs.json',
             type: 'GET',
-            data: 'paging=false&filter=id:eq:' + id +'&fields=id,name,version,dataEntryMethod,relationshipText,relationshipFromA,dateOfEnrollmentDescription,dateOfIncidentDescription,displayIncidentDate,ignoreOverdueEvents,realionshipText,relationshipFromA,selectEnrollmentDatesInFuture,selectIncidentDatesInFuture,onlyEnrollOnce,externalAccess,displayOnAllOrgunit,registration,trackedEntity[id,name,description],userRoles[id,name],organisationUnits[id,name],programStages[id,name,version,minDaysFromStart,standardInterval,generatedByEnrollmentDate,reportDateDescription,repeatable,autoGenerateEvent],programTrackedEntityAttributes[displayInList,mandatory,allowFutureDate,trackedEntityAttribute[id]]'
+            data: 'paging=false&filter=id:eq:' + id +'&fields=id,name,version,dataEntryMethod,relationshipText,relationshipFromA,dateOfEnrollmentDescription,dateOfIncidentDescription,displayIncidentDate,ignoreOverdueEvents,realionshipText,relationshipFromA,selectEnrollmentDatesInFuture,selectIncidentDatesInFuture,onlyEnrollOnce,externalAccess,displayOnAllOrgunit,registration,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]]'
         }).done( function( response ){
             
             _.each( _.values( response.programs ), function ( program ) {