Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAH 1109, BAH 1106 | Shriram , Gopi , Rakesh , Aakash , Som | Zipping and importing AddressHierarchy & OfflineConcepts Data in BahmniConnect & Selective Sync Strategy #22

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 0 additions & 35 deletions .github/workflows/node.js.yml

This file was deleted.

26 changes: 22 additions & 4 deletions ui/Gruntfile.js
Expand Up @@ -136,7 +136,9 @@ module.exports = function (grunt) {
"dist/offline/index.html": "dist/offline/index.html",
"dist/registration/index.html": "dist/registration/index.html",
"dist/clinical/index.html": "dist/clinical/index.html",
"dist/home/index.html": "dist/home/index.html"
"dist/home/index.html": "dist/home/index.html",
"dist/syncdatarules/index.html": "dist/syncdatarules/index.html"

}
}
},
Expand Down Expand Up @@ -219,7 +221,9 @@ module.exports = function (grunt) {
'<%= yeoman.app %>/**/*.html',
'<%= yeoman.app %>/common/**/*.html',
'<%= yeoman.app %>/home/**/*.html',
'<%= yeoman.app %>/registration/**/*.html'
'<%= yeoman.app %>/registration/**/*.html',
'<%= yeoman.app %>/syncdatarules/**/*.html'

],
css: '<%= yeoman.app %>/styles/**/*.css',
options: {
Expand Down Expand Up @@ -286,7 +290,8 @@ module.exports = function (grunt) {
'common/**/*.html',
'home/**/*.html',
'offline/**/*.html',
'registration/**/*.html'
'registration/**/*.html',
'syncdatarules/**/*.html'
],
dest: '<%= yeoman.dist %>'
}
Expand Down Expand Up @@ -390,6 +395,12 @@ module.exports = function (grunt) {
src: ['registration.*.js'],
dest: '<%= yeoman.dist %>/registration/'
},
{
expand: true,
cwd: '<%= yeoman.dist %>',
src: ['syncdatarules.*.js'],
dest: '<%= yeoman.dist %>/syncdatarules/'
},
{
expand: true,
cwd: '<%= yeoman.dist %>',
Expand All @@ -413,6 +424,12 @@ module.exports = function (grunt) {
cwd: '<%= yeoman.dist %>',
src: ['registration.*.css'],
dest: '<%= yeoman.dist %>/registration/'
},
{
expand: true,
cwd: '<%= yeoman.dist %>',
src: ['syncdatarules.*.css'],
dest: '<%= yeoman.dist %>/syncdatarules/'
}
]
}
Expand Down Expand Up @@ -457,7 +474,8 @@ module.exports = function (grunt) {
files: {
'<%= yeoman.dist %>/registration.min.js': '<%= yeoman.dist %>/registration.min.js',
'<%= yeoman.dist %>/home.min.js': '<%= yeoman.dist %>/home.min.js',
'<%= yeoman.dist %>/clinical.min.js': '<%= yeoman.dist %>/clinical.min.js'
'<%= yeoman.dist %>/clinical.min.js': '<%= yeoman.dist %>/clinical.min.js',
'<%= yeoman.dist %>/syncdatarules.min.js': '<%= yeoman.dist %>/syncdatarules.min.js'
}
},
chrome: {
Expand Down
24 changes: 20 additions & 4 deletions ui/Gruntfile_ci.js
Expand Up @@ -136,7 +136,8 @@ module.exports = function (grunt) {
"dist/offline/index.html": "dist/offline/index.html",
"dist/registration/index.html": "dist/registration/index.html",
"dist/clinical/index.html": "dist/clinical/index.html",
"dist/home/index.html": "dist/home/index.html"
"dist/home/index.html": "dist/home/index.html",
"dist/syncdatarules/index.html": "dist/syncdatarules/index.html"
}
}
},
Expand Down Expand Up @@ -219,7 +220,8 @@ module.exports = function (grunt) {
'<%= yeoman.app %>/**/*.html',
'<%= yeoman.app %>/common/**/*.html',
'<%= yeoman.app %>/home/**/*.html',
'<%= yeoman.app %>/registration/**/*.html'
'<%= yeoman.app %>/registration/**/*.html',
'<%= yeoman.app %>/syncdatarules/**/*.html'
],
css: '<%= yeoman.app %>/styles/**/*.css',
options: {
Expand Down Expand Up @@ -286,7 +288,8 @@ module.exports = function (grunt) {
'common/**/*.html',
'home/**/*.html',
'offline/**/*.html',
'registration/**/*.html'
'registration/**/*.html',
'syncdatarules/**/*.html'
],
dest: '<%= yeoman.dist %>'
}
Expand Down Expand Up @@ -390,6 +393,12 @@ module.exports = function (grunt) {
src: ['registration.*.js'],
dest: '<%= yeoman.dist %>/registration/'
},
{
expand: true,
cwd: '<%= yeoman.dist %>',
src: ['syncdatarules.*.js'],
dest: '<%= yeoman.dist %>/syncdatarules/'
},
{
expand: true,
cwd: '<%= yeoman.dist %>',
Expand All @@ -413,6 +422,12 @@ module.exports = function (grunt) {
cwd: '<%= yeoman.dist %>',
src: ['registration.*.css'],
dest: '<%= yeoman.dist %>/registration/'
},
{
expand: true,
cwd: '<%= yeoman.dist %>',
src: ['syncdatarules.*.css'],
dest: '<%= yeoman.dist %>/syncdatarules/'
}
]
}
Expand Down Expand Up @@ -457,7 +472,8 @@ module.exports = function (grunt) {
files: {
'<%= yeoman.dist %>/registration.min.js': '<%= yeoman.dist %>/registration.min.js',
'<%= yeoman.dist %>/home.min.js': '<%= yeoman.dist %>/home.min.js',
'<%= yeoman.dist %>/clinical.min.js': '<%= yeoman.dist %>/clinical.min.js'
'<%= yeoman.dist %>/clinical.min.js': '<%= yeoman.dist %>/clinical.min.js',
'<%= yeoman.dist %>/syncdatarules.min.js': '<%= yeoman.dist %>/syncdatarules.min.js'
}
},
chrome: {
Expand Down
21 changes: 18 additions & 3 deletions ui/app/clinical/common/controllers/patientListHeaderController.js
@@ -1,8 +1,8 @@
'use strict';

angular.module('bahmni.clinical')
.controller('PatientListHeaderController', ['$scope', '$rootScope', '$bahmniCookieStore', 'providerService', 'spinner', 'locationService', '$window', 'ngDialog', 'retrospectiveEntryService', 'offlineService', 'schedulerService', 'offlineStatusService',
function ($scope, $rootScope, $bahmniCookieStore, providerService, spinner, locationService, $window, ngDialog, retrospectiveEntryService, offlineService, schedulerService, offlineStatusService) {
.controller('PatientListHeaderController', ['$scope', '$rootScope', '$bahmniCookieStore', 'providerService', 'spinner', 'locationService', '$window', 'ngDialog', 'retrospectiveEntryService', 'offlineService', 'schedulerService', 'offlineStatusService', '$http',
function ($scope, $rootScope, $bahmniCookieStore, providerService, spinner, locationService, $window, ngDialog, retrospectiveEntryService, offlineService, schedulerService, offlineStatusService, $http) {
var DateUtil = Bahmni.Common.Util.DateUtil;
$scope.maxStartDate = DateUtil.getDateWithoutTime(DateUtil.today());
var selectedProvider = {};
Expand All @@ -11,6 +11,19 @@ angular.module('bahmni.clinical')
$scope.onBehalfOfPrivilege = Bahmni.Common.Constants.onBehalfOfPrivilege;
$scope.selectedLocationUuid = {};
$rootScope.isOfflineApp = offlineService.isOfflineApp();
$scope.isSelectiveSyncStrategy = false;

var verifySelectiveSync = function () {
$http.get('/openmrs/ws/rest/v1/eventlog/filter/globalProperty/', {
method: "GET",
params: { q: 'bahmniOfflineSync.strategy' },
withCredentials: true,
headers: { "Accept": "application/text", "Content-Type": "text/plain" }
}).then((response) => {
let value = response.data;
if (value.includes("SelectiveSyncStrategy")) { $scope.isSelectiveSyncStrategy = true; }
});
};

offlineStatusService.setOfflineOptions();
$scope.getProviderList = function () {
Expand Down Expand Up @@ -51,7 +64,8 @@ angular.module('bahmni.clinical')
};

$scope.popUpHandler = function () {
$scope.dialog = ngDialog.open({ template: 'consultation/views/defaultDataPopUp.html', className: 'test ngdialog-theme-default',
$scope.dialog = ngDialog.open({ template: 'consultation/views/defaultDataPopUp.html',
className: 'test ngdialog-theme-default',
controller: 'PatientListHeaderController'});
$('body').addClass('show-controller-back');
};
Expand Down Expand Up @@ -115,6 +129,7 @@ angular.module('bahmni.clinical')
};

var init = function () {
verifySelectiveSync();
var retrospectiveDate = retrospectiveEntryService.getRetrospectiveDate();
$scope.date = retrospectiveDate ? new Date(retrospectiveDate) : new Date($scope.maxStartDate);
$scope.encounterProvider = getCurrentProvider();
Expand Down
4 changes: 2 additions & 2 deletions ui/app/clinical/dashboard/views/clinicalDashboardHeader.html
Expand Up @@ -33,7 +33,7 @@
</div>

<div class="fr offlin-sync-wrapper" ng-controller="PatientListHeaderController">
<button class="btn fl offline-sync" ng-click="sync()" ng-show="isOfflineApp && !isSyncing">
<button class="btn fl offline-sync" ng-click="sync()" ng-show="!isSelectiveSyncStrategy && isOfflineApp && !isSyncing">
{{::'HEADER_LABEL_SYNC_KEY' | translate}}
</button>
<button class="btn fl offline-sync offline-sync-image" ng-show="isOfflineApp && isSyncing" disabled>
Expand Down Expand Up @@ -133,7 +133,7 @@
<div ng-if="isOfflineApp" class="offline-sync fl" ng-controller="AppUpdateController">
<button class="btn" ng-if="isUpdateAvailable()" ng-click="update()">Update</button>
</div>
<button class="btn fl offline-sync" ng-click="sync()" ng-show="isOfflineApp && !isSyncing">
<button class="btn fl offline-sync" ng-click="sync()" ng-show="!isSelectiveSyncStrategy && isOfflineApp && !isSyncing">
{{::'HEADER_LABEL_SYNC_KEY' | translate}}
</button>
<button class="btn fl offline-sync offline-sync-image" ng-show="isOfflineApp && isSyncing" disabled>
Expand Down
5 changes: 5 additions & 0 deletions ui/app/common/constants.js
Expand Up @@ -247,10 +247,15 @@ Bahmni.Common = Bahmni.Common || {};
eventLogServicePatientUrl: hostUrl + "/event-log-service/rest/eventlog/events/patient",
eventLogServiceEncounterUrl: hostUrl + "/event-log-service/rest/eventlog/events/encounter",
preprocessedPatientUrl: RESTWS_V1 + "/bahmniconnect/patient?filename=",
preprocessedOfflineConceptsUrl: RESTWS_V1 + "/bahmniconnect/offlineconcepts?filename=",
preprocessedPatientFilesUrl: RESTWS_V1 + "/bahmniconnect/patientfiles?filter=",
preprocessedOfflineConceptsFilesUrl: RESTWS_V1 + "/bahmniconnect/offlineconceptfiles?filter=",
preprocessedAddressHierarchyUrl: RESTWS_V1 + "/bahmniconnect/addresshierarchy?filename=",
preprocessedAddressHierarchyFilesUrl: RESTWS_V1 + "/bahmniconnect/addresshierarchy?filter=",
eventLogServiceConceptUrl: hostUrl + "/event-log-service/rest/eventlog/concepts",
eventLogServiceFormUrl: hostUrl + "/event-log-service/rest/eventlog/forms",
offlineMetadataUrl: hostUrl + "/offlineMetadata.json",
startArchivingURL: RESTWS_V1 + "/bahmniconnect/initSync",
faviconUrl: hostUrl + "/bahmni/favicon.ico",
platformType: {
chrome: 'chrome',
Expand Down
19 changes: 18 additions & 1 deletion ui/app/common/offline/dbservices/dao/encounterDbService.js
Expand Up @@ -73,11 +73,28 @@ angular.module('bahmni.common.offline')
});
};

var deleteAllEncounterRecords = function (db) {
var encounter = db.getSchema().table('encounter');
return db.delete().from(encounter).exec();
};

var getEncountersCount = function (db) {
var encounter = db.getSchema().table('encounter');
return db.select(encounter.encounterJson.as('encounter'))
.from(encounter)
.where().exec()
.then(function (result) {
return result.length;
});
};

return {
insertEncounterData: insertEncounterData,
getEncountersByPatientUuid: getEncountersByPatientUuid,
findActiveEncounter: findActiveEncounter,
getEncounterByEncounterUuid: getEncounterByEncounterUuid,
getEncountersByVisits: getEncountersByVisits
getEncountersByVisits: getEncountersByVisits,
deleteAllEncounterRecords: deleteAllEncounterRecords,
getEncountersCount: getEncountersCount
};
});
Expand Up @@ -96,8 +96,8 @@ angular.module('bahmni.common.offline')
.from(addressHierarchyEntryTable)
.where(lf.op.and(
addressHierarchyEntryTable.levelId.eq(level.addressHierarchyLevelId),
addressHierarchyEntryTable.name.match(new RegExp(params.searchString, 'i')
)))
addressHierarchyEntryTable.name.match(new RegExp(params.searchString, 'i'))
))
.limit(params.limit).exec()
.then(
function (result) {
Expand Down Expand Up @@ -151,10 +151,48 @@ angular.module('bahmni.common.offline')
});
};

var getParentAddressByLevelId = function (id) {
var addressHierarchyEntryTable = db.getSchema().table('address_hierarchy_entry');
return db.select()
.from(addressHierarchyEntryTable)
.where(addressHierarchyEntryTable.levelId.eq(id))
.exec()
.then(function (result) {
return result;
});
};

var getAddressesHeirarchyLevels = function () {
var addressHierarchyLevelTable = db.getSchema().table('address_hierarchy_level');
return db.select()
.from(addressHierarchyLevelTable)
.orderBy(addressHierarchyLevelTable.addressHierarchyLevelId)
.exec()
.then(function (result) {
return result;
});
};

var getAddressesHeirarchyLevelsById = function (levelId) {
var addressHierarchyLevelTable = db.getSchema().table('address_hierarchy_level');
return db.select()
.from(addressHierarchyLevelTable)
.where(addressHierarchyLevelTable.addressHierarchyLevelId.eq(levelId))
.orderBy(addressHierarchyLevelTable.addressHierarchyLevelId)
.exec()
.then(function (result) {
return result;
});
};

return {
init: init,
insertAddressHierarchy: insertAddressHierarchy,
insertAddressHierarchyLevel: insertAddressHierarchyLevel,
search: search,
getParentAddressById: getParentAddressById
getParentAddressById: getParentAddressById,
getParentAddressByLevelId: getParentAddressByLevelId,
getAddressesHeirarchyLevels: getAddressesHeirarchyLevels,
getAddressesHeirarchyLevelsById: getAddressesHeirarchyLevelsById
};
}]);