dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31493
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16054: tracker capture - tei based report
------------------------------------------------------------
revno: 16054
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Wed 2014-07-09 14:49:49 +0200
message:
tracker capture - tei based report
modified:
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/eventDetails.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/report-controller.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/report.html
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/teiReport.html
--
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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js 2014-06-27 10:57:20 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js 2014-07-09 12:49:49 +0000
@@ -17,7 +17,7 @@
if(!angular.isUndefined( $scope.selectedEnrollment.notes)){
$scope.selectedEnrollment.notes = orderByFilter($scope.selectedEnrollment.notes, '-storedDate');
angular.forEach($scope.selectedEnrollment.notes, function(note){
- note.storedDate = moment(note.storedDate).format('DD.MM.YYYY @ hh:mm A');
+ note.storedDate = moment(note.storedDate).format('YYYY-MM-DD @ hh:mm A');
});
}
});
@@ -50,8 +50,7 @@
EnrollmentService.update(e).then(function(data){
$scope.note = '';
$scope.addNoteField = false; //note is added, hence no need to show note field.
- CurrentSelection.set({enrollment: $scope.selectedEnrollment});
- //$rootScope.$broadcast('notesController', {selectedEnrollment: $scope.selectedEnrollment.enrollment});
+ CurrentSelection.set({enrollment: $scope.selectedEnrollment});
$rootScope.$broadcast('notesController', {});
});
}
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/eventDetails.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/eventDetails.html 2014-07-08 19:07:43 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/eventDetails.html 2014-07-09 12:49:49 +0000
@@ -2,7 +2,7 @@
<h2>{{'details'| translate}}</h2>
</div>
<div class="modal-body">
- <div class='row'>
+ <div class='row' ng-if="reportMode === 'PROGRAM'">
<table class="table-borderless table-striped">
<tr>
<th colspan="2">
@@ -20,9 +20,9 @@
</table>
</div>
<div class='row' ng-if='currentEvent'>
- <hr>
+ <hr ng-if="reportMode === 'PROGRAM'">
<span class="bold">
- {{currentEvent.name}} | {{currentEvent.orgUnitName}} | {{currentEvent.eventDate}}
+ <span ng-if="reportMode === 'TEI'">{{currentEvent.programName}} | </span>{{currentEvent.name}} | {{currentEvent.orgUnitName}} | {{currentEvent.eventDate}}
</span>
<table class="table-borderless table-striped">
<thead>
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/report-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/report-controller.js 2014-07-08 19:07:43 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/report-controller.js 2014-07-09 12:49:49 +0000
@@ -56,6 +56,7 @@
angular.forEach(eventList, function(ev){
if(ev.trackedEntityInstance){
ev.name = $scope.programStages[ev.programStage].name;
+ ev.programName = $scope.selectedProgram.name
ev.statusColor = EventUtils.getEventStatusColor(ev);
ev.eventDate = DateUtils.format(ev.eventDate);
@@ -89,6 +90,9 @@
},
entityName: function(){
return $scope.selectedProgram.trackedEntity.name;
+ },
+ reportMode: function(){
+ return 'PROGRAM';
}
}
});
@@ -107,18 +111,20 @@
dhis2Event,
selectedTei,
gridColumns,
- entityName){
+ entityName,
+ reportMode){
$scope.selectedTei = selectedTei;
$scope.gridColumns = gridColumns;
$scope.entityName = entityName;
+ $scope.reportMode = reportMode;
$scope.currentEvent = dhis2Event;
$scope.currentEvent.providedElsewhere = [];
if(!angular.isUndefined( $scope.currentEvent.notes)){
$scope.currentEvent.notes = orderByFilter($scope.currentEvent.notes, '-storedDate');
angular.forEach($scope.currentEvent.notes, function(note){
- note.storedDate = moment(note.storedDate).format('DD.MM.YYYY @ hh:mm A');
+ note.storedDate = moment(note.storedDate).format('YYYY-MM-DD @ hh:mm A');
});
}
@@ -147,51 +153,114 @@
});
$scope.close = function () {
- $modalInstance.close();
+ $modalInstance.close();
};
})
//conroller for tei report
.controller('TeiReportController',
function($scope,
+ $modal,
CurrentSelection,
storage,
DateUtils,
EventUtils,
TranslationService,
+ ProgramFactory,
DHIS2EventFactory) {
- TranslationService.translate();
+ TranslationService.translate();
+
+ $scope.programs = [];
+ $scope.programNames = [];
+ $scope.programStageNames = [];
+ ProgramFactory.getAll().then(function(programs){
+
+ angular.forEach(programs, function(pr){
+ $scope.programs.push({id: pr.id, name: pr.name});
+ $scope.programNames[pr.id] = {id: pr.id, name: pr.name};
+ angular.forEach(pr.programStages, function(stage){
+ $scope.programStageNames[stage.id] = stage;
+ });
+ });
+ });
$scope.$on('dashboard', function(event, args) {
var selections = CurrentSelection.get();
$scope.selectedOrgUnit = storage.get('SELECTED_OU');
- $scope.selectedEntity = selections.tei;
+ $scope.selectedTei = selections.tei;
+ $scope.selectedEntity = selections.te;
$scope.selectedProgram = selections.pr;
$scope.selectedEnrollment = selections.enrollment;
- if($scope.selectedOrgUnit &&
- $scope.selectedProgram &&
- $scope.selectedEntity &&
- $scope.selectedEnrollment){
-
+ if($scope.selectedTei){
$scope.getEvents();
}
});
$scope.getEvents = function(){
- $scope.dhis2Events = '';
+ $scope.dataFetched = false;
$scope.dataExists = false;
- DHIS2EventFactory.getEventsByProgram($scope.selectedEntity.trackedEntityInstance, $scope.selectedOrgUnit.id, $scope.selectedProgram.id).then(function(data){
- $scope.dhis2Events = data;
- if(!angular.isUndefined($scope.dhis2Events) ){
- for(var i=0; i<$scope.dhis2Events.length && !$scope.dataExists; i++){
- if(!angular.isUndefined($scope.dhis2Events[i].dataValues)){
- $scope.dataExists = true;
- }
- }
+ var programId = null, orgUnitId = null;
+
+ if($scope.selectedProgram){
+ programId = $scope.selectedProgram.id;
+ }
+
+ /*if($scope.selectedOrgUnit){
+ orgUnitId = $scope.selectedOrgUnit.id;
+ }*/
+
+ $scope.report = [];
+ angular.forEach($scope.programs, function(pr){
+ $scope.report[pr.id] = {events: []};
+ });
+
+ DHIS2EventFactory.getEventsByProgram($scope.selectedTei.trackedEntityInstance, orgUnitId, programId).then(function(eventList){
+
+ angular.forEach(eventList, function(ev){
+ if(ev.program){
+ ev.name = $scope.programStageNames[ev.programStage].name;
+ ev.programName = $scope.programNames[ev.program].name;
+ ev.statusColor = EventUtils.getEventStatusColor(ev);
+ ev.eventDate = DateUtils.format(ev.eventDate);
+ $scope.report[ev.program].events.push(ev);
+ ev = EventUtils.setEventOrgUnitName(ev);
+ }
+ });
+ if(eventList){
+ $scope.dataExists = true;
}
- });
+ $scope.dataFetched = true;
+ });
};
+
+ $scope.showEventDetails = function(dhis2Event){
+
+ var modalInstance = $modal.open({
+ templateUrl: 'components/report/eventDetails.html',
+ controller: 'EventDetailsController',
+ resolve: {
+ dhis2Event: function () {
+ return dhis2Event;
+ },
+ gridColumns: function(){
+ return $scope.gridColumns;
+ },
+ selectedTei: function(){
+ return $scope.selectedTei;
+ },
+ entityName: function(){
+ return $scope.selectedEntity.name;
+ },
+ reportMode: function(){
+ return 'TEI';
+ }
+ }
+ });
+
+ modalInstance.result.then({
+ });
+ };
});
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/report.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/report.html 2014-07-08 19:07:43 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/report.html 2014-07-09 12:49:49 +0000
@@ -32,7 +32,7 @@
</div>
<div class="col-md-6 trim">
<button type="button" class="btn btn-primary" ng-click="generateReport()" ng-disabled="!selectedProgram">{{'go'| translate}}</button>
- <button type="button" class="btn btn-default small-horizonal-spacing" ng-click="showReport()">{{'cancel'| translate}}</button>
+ <button type="button" class="btn btn-default small-horizonal-spacing" ng-click="showReport()">{{'close'| translate}}</button>
</div>
</div>
</form>
@@ -71,7 +71,7 @@
</span>
</td>
<td>
- <div class='bold vertical-center' ng-if='!dhis2Events[tei.id]'>{{'no_visit_made' | translate}}</div>
+ <div class='bold inline-block vertical-center' ng-if='!dhis2Events[tei.id]'>{{'no_visit_made' | translate}}</div>
<div class="inline-block vertical-center" ng-repeat="ev in dhis2Events[tei.id] | orderBy: 'eventDate'">
<div class="block align-center">{{ev.orgUnitName}}</div>
<div class="empty-stage-container"
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/teiReport.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/teiReport.html 2014-07-07 15:04:56 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/report/teiReport.html 2014-07-09 12:49:49 +0000
@@ -9,10 +9,39 @@
<a class="small-horizonal-spacing" href ng-click="removeWidget(reportWidget)" title="{{'remove'| translate}}"><i class="fa fa-times-circle"></i></a>
</span>
</div>
- <div ng-show="reportWidget.expand" class="panel-body dashboard-widget-container">
-
- <div ng-if="!dataExists && selectedEnrollment" class="alert alert-warning">{{'no_data_report'| translate}}</div>
- <div ng-if="!selectedEnrollment" class="alert alert-warning">{{'not_yet_enrolled_report'| translate}}</div>
+ <div ng-show="reportWidget.expand" class="panel-body dashboard-widget-container">
+ <div ng-if="!dataExists" class="alert alert-warning">{{'no_data_report'| translate}}</div>
+ <div ng-if="dataExists" class="remove-default-padding">
+ <table class="table table-compact table-striped">
+ <tr ng-repeat="pr in programs" ng-if="report[pr.id].events">
+ <td>
+ <div class="bold inline-block vertical-center">{{pr.name}}</div>
+ </td>
+ <td>
+ <div class='bold vertical-center' ng-if='report[pr.id].events.length < 1'>{{'no_visit_made'| translate}}</div>
+ <div class="inline-block vertical-center" ng-repeat="ev in report[pr.id].events | orderBy: 'eventDate'">
+ <div class="block align-center">{{ev.orgUnitName}}</div>
+ <div class="empty-stage-container"
+ title="{{ev.dataValues ? 'details' : 'no_data_registerd'| translate}}"
+ ng-class="{'{{ev.statusColor}}': true}"
+ ng-if='!ev.dataValues'>
+ {{ev.name}}<br/>
+ {{ev.eventDate}}
+ </div>
+ <div class="stage-container"
+ title="{{ev.dataValues ? 'details' : 'no_data_registerd'| translate}}"
+ ng-class="{'{{ev.statusColor}}': true}"
+ ng-if='ev.dataValues'
+ ng-click="showEventDetails(ev)">
+ {{ev.name}}<br/>
+ {{ev.eventDate}}
+ </div>
+ <i class="fa fa-arrow-right" ng-show="$index < report[pr.id].events.length - 1"></i>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
</div>
</div>
\ No newline at end of file