diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..62c8935
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea/
\ No newline at end of file
diff --git a/app/admin/admin.controllers.js b/app/admin/admin.controllers.js
index a915a5e..88574f7 100644
--- a/app/admin/admin.controllers.js
+++ b/app/admin/admin.controllers.js
@@ -178,22 +178,23 @@ adminModule.controller('adminMainController', ['$scope', '$translate', 'adminOUG
$scope.submitDS = function() {
console.log($scope.selectedDS);
- adminDSFactory.get_DS_set.query($scope.selectedDS,function(response1){
- adminDSFactory.upd_DS.query($scope.selectedDS,function(response2){
+ adminDSFactory.get_DS_set.query($scope.selectedDS).$promise.then(function(response1){
+ return adminDSFactory.upd_DS.query($scope.selectedDS,function(response2){
console.log(response2);
if (response2) {
$scope.blacklist_datasets = $scope.selectedDS;
}
});
}, function() {
- adminDSFactory.set_DS.query($scope.selectedDS,function(response2){
+ return adminDSFactory.set_DS.query($scope.selectedDS,function(response2){
console.log(response2);
if (response2) {
$scope.blacklist_datasets = $scope.selectedDS;
}
});
+ }).then(function(){
+ window.location.reload(true)
});
- window.location.reload(true);
};
if ($scope.blacklist_indicatorgroups) {
@@ -201,22 +202,23 @@ adminModule.controller('adminMainController', ['$scope', '$translate', 'adminOUG
}
$scope.submitIG = function() {
- console.log($scope.selectedIG);;
- adminIGFactory.get_IG_set.query($scope.selectedIG,function(response1){
- adminIGFactory.upd_IG.query($scope.selectedIG,function(response2){
- console.log(response);
- if (response) {
+ console.log($scope.selectedIG);
+ adminIGFactory.get_IG_set.query($scope.selectedIG).$promise.then(function(response1){
+ return adminIGFactory.upd_IG.query($scope.selectedIG,function(response2){
+ console.log(response2);
+ if (response2) {
$scope.blacklist_indicatorgroups = $scope.selectedIG;
}
});
}, function() {
- adminIGFactory.set_IG.query($scope.selectedIG,function(response){
+ return adminIGFactory.set_IG.query($scope.selectedIG,function(response){
console.log(response);
if (response) {
$scope.blacklist_indicatorgroups = $scope.selectedIG;
}
});
+ }).then(function(){
+ window.location.reload(true)
});
- window.location.reload(true);
};
}]);
diff --git a/app/search/search.controllers.js b/app/search/search.controllers.js
index 429a42e..3bfb3d8 100644
--- a/app/search/search.controllers.js
+++ b/app/search/search.controllers.js
@@ -170,7 +170,7 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
if (result !== null) {
return result.length > 1 ? result[2] : "x";
}
- }
+ };
$scope.getDenominator = function(indicator) {
var re = /(DENOM:)(.*)/;
@@ -178,7 +178,7 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
if (result !== null) {
return result.length > 1 ? result[2] : "x";
}
- }
+ };
$scope.getDescription = function(indicator) {
var re = /(.*)(NUM:)/;
@@ -188,147 +188,115 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
} else {
return indicator.displayDescription;
}
- }
+ };
+
+ $scope.parseFormula = function(formula, dataElements, categoryOptionCombos) {
+ var operatorRegex = /}\s*[\+\-\*]\s*#/g;
+ var dataElementRegex = /#\{\w*}/g;
+ var dataElementCatRegex = /#\{\w*.\w*}/g;
+ return formula
+ .replace(operatorRegex, function (nexus) {
+ var operator = nexus.split("}")[1].trim().charAt(0);
+ return "}
" + operator + " #";
+ })
+ .replace(dataElementRegex, function (dataElementWithCurlyBraces) {
+ var deId = dataElementWithCurlyBraces.substr(0, dataElementWithCurlyBraces.length - 1).substr(2);
+
+ return dataElements[deId] ? dataElements[deId].object_name : deId;;
+ })
+ .replace(dataElementCatRegex, function (dataElementCatWithCurlyBraces) {
+ var deId = dataElementCatWithCurlyBraces.split("{")[1].split(".")[0];
+ var catId = dataElementCatWithCurlyBraces.split(".")[1].split("}")[0];
+
+ var dataElement = dataElements[deId] ? dataElements[deId].object_name : deId;
+ var categoryOptionCombo = categoryOptionCombos[catId] ? categoryOptionCombos[catId].object_name : catId;
+
+ return dataElement + " (" + categoryOptionCombo + ")";
+ });
+ };
$scope.$watch('servicesList', function(){
+
+ var start = new Date();
//console.log('servicesList available?', $scope.servicesList);
if ($scope.servicesList) {
var temp = {};
+ var categoryOptionCombosTemp = {};
- searchAllFactory.get_dataElements.query(function(response){
+ searchAllFactory.qry_dataElementsAll.query().$promise.then(function(response){
//console.log('get_dataElements', response);
response.dataElements.forEach(function(obj) {
if(filterObjects(obj,"dataElement")){
- temp[obj.id] = {
- object_type: 'dataElement',
- object_id: obj.id,
- object_code: obj.code,
- object_name: obj.displayName,
- object_form: obj.displayFormName,
+ //objectGroup + service
+ var temp_arr = {
+ objectGroup_id: [],
+ objectGroup_code: [],
+ objectGroup_name: [],
+ service_id: [],
+ service_code: [],
+ service_name: []
};
- }
- });
- //console.log('get_dataElements refactored', temp);
- $scope.loaded.get_dataElements = true;
- $scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });
-
- searchAllFactory.get_dataElementsDescriptions.query(function(response){
- //console.log('get_dataElementsDescriptions', response);
- response.dataElements.forEach(function(obj) {
- if(filterObjects(obj,"dataElement")){
-
- temp[obj.id].object_description = obj.displayDescription;
-
- };
- });
- //console.log('get_dataElementsDescriptions refactored', temp);
- $scope.loaded.get_dataElementsDescriptions = true;
- $scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });
-
- });
- searchAllFactory.get_dataElementsGroups.query(function(response){
- //console.log('get_dataElementsGroups', response);
- response.dataElements.forEach(function(obj) {
-
- if(filterObjects(obj,"dataElement")){
-
- //objectGroup + service
- var temp_arr = {
- objectGroup_id: [],
- objectGroup_code: [],
- objectGroup_name: [],
- service_id: [],
- service_code: [],
- service_name: []
- };
-
- obj.dataSetElements.forEach(function(grp) {
- if(grp.dataSet.attributeValues.length > 0 && grp.dataSet.attributeValues[0].value){
- var servicesCode = grp.dataSet.attributeValues[0].value.split('_');
- servicesCode.shift();
- servicesCode.forEach(function(code) {
- if($scope.servicesList[code]){
- temp_arr.service_id.push($scope.servicesList[code].service_id);
- temp_arr.service_code.push($scope.servicesList[code].service_code);
- temp_arr.service_name.push($scope.servicesList[code].service_name);
- }else{
- console.log("search: Cannot find any service with code: " + code);
- }
- });
- }
- temp_arr.objectGroup_id.push(grp.dataSet.id);
- temp_arr.objectGroup_code.push(grp.dataSet.code);
- temp_arr.objectGroup_name.push(grp.dataSet.displayName);
-
-
- });
-
- temp[obj.id].objectGroup_id = temp_arr.objectGroup_id.join(', ');
- temp[obj.id].objectGroup_code = temp_arr.objectGroup_code.join(', ');
- temp[obj.id].objectGroup_name = temp_arr.objectGroup_name.join(', ');
- temp[obj.id].service_id = temp_arr.service_id.join(', ');
- temp[obj.id].service_code = temp_arr.service_code.join(', ');
- temp[obj.id].service_name =temp_arr.service_name.join(', ');
-
- }
-
- });
- //console.log('get_dataElementsGroups refactored', temp);
- $scope.loaded.get_dataElementsGroups = true;
- $scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });
-
- });
- });
-
-
-
- searchAllFactory.get_indicators.query(function(response){
- //console.log('get_indicators', response);
- response.indicators.forEach(function(obj) {
-
- if(filterObjects(obj,"indicator")){
+ obj.dataSetElements.forEach(function(grp) {
+ if(grp.dataSet.attributeValues.length > 0 && grp.dataSet.attributeValues[0].value){
+ var servicesCode = grp.dataSet.attributeValues[0].value.split('_');
+ servicesCode.shift();
+ servicesCode.forEach(function(code) {
+ if($scope.servicesList[code]){
+ temp_arr.service_id.push($scope.servicesList[code].service_id);
+ temp_arr.service_code.push($scope.servicesList[code].service_code);
+ temp_arr.service_name.push($scope.servicesList[code].service_name);
+ }else{
+ console.log("search: Cannot find any service with code: " + code);
+ }
+ });
+ }
+ temp_arr.objectGroup_id.push(grp.dataSet.id);
+ temp_arr.objectGroup_code.push(grp.dataSet.code);
+ temp_arr.objectGroup_name.push(grp.dataSet.displayName);
+
+
+ });
temp[obj.id] = {
- object_type: 'indicator',
+ object_type: 'dataElement',
object_id: obj.id,
object_code: obj.code,
object_name: obj.displayName,
object_form: obj.displayFormName,
+ object_description: obj.displayDescription,
+ objectGroup_id: temp_arr.objectGroup_id.join(', '),
+ objectGroup_code: temp_arr.objectGroup_code.join(', '),
+ objectGroup_name: temp_arr.objectGroup_name.join(', '),
+ service_id: temp_arr.service_id.join(', '),
+ service_code: temp_arr.service_code.join(', '),
+ service_name: temp_arr.service_name.join(', ')
};
-
}
-
});
- //console.log('get_indicators refactored', temp);
- $scope.loaded.get_indicators = true;
- $scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });
-
- searchAllFactory.get_indicatorsDescriptions.query(function(response){
- //console.log('get_indicatorsDescriptions', response);
- response.indicators.forEach(function(obj) {
- if(filterObjects(obj,"indicator")){
+ //console.log('get_dataElements refactored', temp);
+ $scope.loaded.get_dataElements = true;
+ $scope.loaded.get_dataElementsDescriptions = true;
+ $scope.loaded.get_dataElementsGroups = true;
- temp[obj.id].object_den_description = $scope.getDenominator(obj);
- temp[obj.id].object_den_ids = obj.denominator;
- temp[obj.id].object_num_description = $scope.getNumerator(obj);
- temp[obj.id].object_num_ids = obj.numerator;
- temp[obj.id].object_description = $scope.getDescription(obj);
+ return "done";
+ }).then(function() {
+ return searchAllFactory.get_categoryOptionCombosAll.query().$promise.then(function(response){
+ response.categoryOptionCombos.forEach(function(obj) {
+ categoryOptionCombosTemp[obj.id] = {
+ id: obj.id,
+ object_name: obj.displayName
}
-
});
- //console.log('get_indicatorsDescriptions refactored', temp);
- $scope.loaded.get_indicatorsDescriptions = true;
- $scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });
-
});
- searchAllFactory.get_indicatorGroups.query(function(response){
- //console.log('get_indicatorGroups', response);
+ }).then(function(){
+ return searchAllFactory.get_indicatorsAll.query().$promise.then(function(response){
+ //console.log('get_indicators', response);
response.indicators.forEach(function(obj) {
if(filterObjects(obj,"indicator")){
@@ -363,22 +331,38 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
});
- temp[obj.id].objectGroup_id = temp_arr.objectGroup_id.join(', ');
- temp[obj.id].objectGroup_code = temp_arr.objectGroup_code.join(', ');
- temp[obj.id].objectGroup_name = temp_arr.objectGroup_name.join(', ');
- temp[obj.id].service_id = temp_arr.service_id.join(', ');
- temp[obj.id].service_code = temp_arr.service_code.join(', ');
- temp[obj.id].service_name =temp_arr.service_name.join(', ');
+ temp[obj.id] = {
+ object_type: 'indicator',
+ object_id: obj.id,
+ object_code: obj.code,
+ object_name: obj.displayName,
+ object_form: obj.displayFormName,
+ object_den_description: $scope.getDenominator(obj),
+ object_den_ids: $scope.parseFormula(obj.denominator, temp, categoryOptionCombosTemp),
+ object_num_description: $scope.getNumerator(obj),
+ object_num_ids: $scope.parseFormula(obj.numerator,temp, categoryOptionCombosTemp),
+ object_description: $scope.getDescription(obj),
+ objectGroup_id: temp_arr.objectGroup_id.join(', '),
+ objectGroup_code: temp_arr.objectGroup_code.join(', '),
+ objectGroup_name: temp_arr.objectGroup_name.join(', '),
+ service_id: temp_arr.service_id.join(', '),
+ service_code: temp_arr.service_code.join(', '),
+ service_name: temp_arr.service_name.join(', ')
+ };
}
});
- //console.log('get_indicatorGroups refactored', temp);
+ //console.log('get_indicators refactored', temp);
+ $scope.loaded.get_indicators = true;
+ $scope.loaded.get_indicatorsDescriptions = true;
$scope.loaded.get_indicatorGroups = true;
$scope.allObjects = Object.keys(temp).map(function(key) { return temp[key]; });
+ return "done";
});
-
+ }).then(function log(){
+ console.log("Loading time of search table: " + (Date.now() - start) + " milliseconds.");
});
}
});
diff --git a/app/search/search.services.js b/app/search/search.services.js
index 86d051d..e627e8c 100644
--- a/app/search/search.services.js
+++ b/app/search/search.services.js
@@ -13,6 +13,10 @@ var qry_dataElementsDescriptions = dhisUrl + 'dataElements.json?fields=id,displa
//dataSets - 258 KB as of 20/11/2106
var qry_dataElementsGroups = dhisUrl + 'dataElements.json?fields=id,dataSetElements[dataSet[displayName,id,code,attributeValues[value]]]&paging=false&filter=domainType\\:eq\\:AGGREGATE';
+var qry_dataElementsAll = dhisUrl + 'dataElements.json?' +
+ 'fields=id,code,displayName,displayDescription,displayFormName,dataSetElements[dataSet[displayName,id,code,attributeValues[value]]]' +
+ '&paging=false&filter=domainType\\:eq\\:AGGREGATE';
+
//indicators - 55 KB as of 20/11/2106
var qry_indicators = dhisUrl + 'indicators.json?fields=id,code,displayName,indicatorGroups&paging=false';
@@ -23,6 +27,14 @@ var qry_indicatorsDescriptions = dhisUrl + 'indicators.json?fields=id,displayDes
//indicators - 80 KB as of 20/11/2106
var qry_indicatorGroups = dhisUrl + 'indicators.json?fields=id,indicatorGroups[id,code,displayName,attributeValues[value]]&paging=false';
+var qry_indicatorsAll = dhisUrl + 'indicators.json?' +
+ 'fields=id,code,displayName,displayDescription,numerator,denominator,indicatorGroups[id,code,displayName,attributeValues[value]]' +
+ '&paging=false';
+
+
+var qry_categoryComobosAll = dhisUrl + 'categoryOptionCombos.json?' +
+ 'fields=id,displayName' +
+ '&paging=false';
//organisationUnitGroupSets - 231 B as of 20/11/2106
var qry_organisationUnitGroupSets = dhisUrl + 'organisationUnitGroupSets/:ougsUID?fields=organisationUnitGroups[id,code,displayName]&paging=false';
@@ -35,11 +47,16 @@ searchModule.factory('searchAllFactory', ['$resource',function($resource) {
get_dataElements: $resource(qry_dataElements, {}, { query: { method: 'GET', isArray: false } }),
get_dataElementsDescriptions: $resource(qry_dataElementsDescriptions, {}, { query: { method: 'GET', isArray: false } }),
get_dataElementsGroups: $resource(qry_dataElementsGroups, {}, { query: { method: 'GET', isArray: false } }),
+ qry_dataElementsAll: $resource(qry_dataElementsAll, {}, { query: { method: 'GET', isArray: false } }),
//indicators
get_indicators: $resource(qry_indicators, {}, { query: { method: 'GET', isArray: false } }),
get_indicatorsDescriptions: $resource(qry_indicatorsDescriptions, {}, { query: { method: 'GET', isArray: false } }),
get_indicatorGroups: $resource(qry_indicatorGroups, {}, { query: { method: 'GET', isArray: false } }),
+ get_indicatorsAll: $resource(qry_indicatorsAll, {}, { query: { method: 'GET', isArray: false } }),
+
+ //categoryOptionCombos
+ get_categoryOptionCombosAll: $resource(qry_categoryComobosAll, {}, { query: { method: 'GET', isArray: false } }),
//organisationUnitGroupSet
get_organisationUnitGroupSets: $resource(qry_organisationUnitGroupSets,{ougsUID: '@ougsUID'}, { query: { method: 'GET', isArray: false } }),
diff --git a/deploy_HMIS_Dictionary.bat b/deploy_HMIS_Dictionary.bat
index 4f5eb1a..bd9fefd 100644
--- a/deploy_HMIS_Dictionary.bat
+++ b/deploy_HMIS_Dictionary.bat
@@ -1 +1,2 @@
-xcopy /s "D:\GitHub\HMIS_Dictionary" "C:\Program Files (x86)\DHIS2\DHIS\apps\HMIS_Dictionary"
+cd "%~dp0"
+xcopy /y /s "." "C:\Program Files (x86)\DHIS2\DHIS\apps\HMIS_Dictionary"
diff --git a/languages/en.json b/languages/en.json
index ea3fd12..69c0fbf 100644
--- a/languages/en.json
+++ b/languages/en.json
@@ -59,8 +59,8 @@
"object_description": "Description",
"object_den_description": "Denominator Description (ind. only)",
"object_num_description": "Numerator Description (ind. only)",
- "object_den_ids": "Denominator IDs (ind. only)",
- "object_num_ids": "Numerator IDs (ind. only)",
+ "object_den_ids": "Denominator Formula (ind. only)",
+ "object_num_ids": "Numerator Formula (ind. only)",
"srch_SelectColumns_grpBasics": "Data Sets or Indicator Groups - Basics",
"objectGroup_name": "Group Name",
diff --git a/languages/es.json b/languages/es.json
index d1fe123..5a8e13b 100644
--- a/languages/es.json
+++ b/languages/es.json
@@ -59,8 +59,8 @@
"object_description": "Descripción",
"object_den_description": "Descripción de Denominador (solo ind.)",
"object_num_description": "Descripción de Numerador (solo ind.)",
- "object_den_ids": "IDs de Denominador (solo ind.)",
- "object_num_ids": "IDs de Numerador (solo ind.)",
+ "object_den_ids": "Fórmula Denominador (solo ind.)",
+ "object_num_ids": "Fórmula Numerador (solo ind.)",
"srch_SelectColumns_grpBasics": "Sets de Datos o Grupos de Indicadores - Basicos",
"objectGroup_name": "Nombre de Grupo",
diff --git a/languages/fr.json b/languages/fr.json
index 35d2268..3c5107f 100644
--- a/languages/fr.json
+++ b/languages/fr.json
@@ -59,8 +59,8 @@
"object_description": "Description",
"object_den_description": "Description du Dénominateur (ind. seulement)",
"object_num_description": "Description du Numérateur (ind. seulement)",
- "object_den_ids": "IDs du Dénominateur (ind. seulement)",
- "object_num_ids": "IDs du Numérateur (ind. seulement)",
+ "object_den_ids": "Formule du Dénominateur (ind. seulement)",
+ "object_num_ids": "Formule du Numérateur (ind. seulement)",
"srch_SelectColumns_grpBasics": "Ensembles de Données ou Groupes Indicateurs - Essentiel",
"objectGroup_name": "Nom du Groupe",
diff --git a/languages/pt.json b/languages/pt.json
index aae0925..1c3eb66 100644
--- a/languages/pt.json
+++ b/languages/pt.json
@@ -59,8 +59,8 @@
"object_description": "Descrição",
"object_den_description": "Denominador Descrição (ind. Somente)",
"object_num_description": "Numerador Descrição (ind. Somente)",
- "object_den_ids": "Denominador IDs (ind. Somente)",
- "object_num_ids": "Numerador IDs (somente ind.)",
+ "object_den_ids": "Fórmula Denominador (ind. Somente)",
+ "object_num_ids": "Fórmula Numerador (ind. Somente)",
"srch_SelectColumns_grpBasics": "Conjuntos de Dados ou Grupos de Indicadores - Noções Básicas",
"objectGroup_name": "Nome do Grupo",
diff --git a/manifest.webapp b/manifest.webapp
index becda43..e1f3780 100644
--- a/manifest.webapp
+++ b/manifest.webapp
@@ -1,5 +1,5 @@
{
- "version":"1.0.0",
+ "version":"1.0.1",
"name":"HMIS Dictionary",
"description":"HMIS Dictionary",
"launch_path":"index.html",