Skip to content

Commit

Permalink
Merge pull request #58 from msf-ocba/Dictionayicd10
Browse files Browse the repository at this point in the history
Show ICD10 coding
  • Loading branch information
vgarciabnz authored Nov 3, 2017
2 parents c7499d9 + 54695eb commit ba8edf3
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 63 deletions.
139 changes: 80 additions & 59 deletions app/search/search.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
Please refer to the LICENSE.md and LICENSES-DEP.md for complete licenses.
------------------------------------------------------------------------------------*/

searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope', '$translate', 'NgTableParams', 'searchAllFactory', function(ExcelFactory, $timeout, $scope, $translate, NgTableParams, searchAllFactory) {
searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope', '$translate', 'NgTableParams', 'searchAllFactory', function (ExcelFactory, $timeout, $scope, $translate, NgTableParams, searchAllFactory) {

$('#search').tab('show');


if ($scope.show_dossiers) {
console.log("searchModule: Service set defined " + $scope.serviceSetUID);
searchAllFactory.get_organisationUnitGroupSets.query({
ougsUID: $scope.serviceSetUID
}, function(response){
}, function (response) {
var temp = {};
response.organisationUnitGroups.forEach(function(serv) {
response.organisationUnitGroups.forEach(function (serv) {
temp[serv.code.split('_')[2]] = {
service_id: serv.id,
service_code: serv.code,
Expand All @@ -28,10 +29,10 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
load_table_info();
}

var concatObjects = function(tablesList) {
var concatObjects = function (tablesList) {
var temp = [];
tablesList.forEach(function(table) {
table.a.forEach(function(elem) {
tablesList.forEach(function (table) {
table.a.forEach(function (elem) {
elem.type = table.t;
temp.push(elem);
});
Expand All @@ -55,21 +56,21 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
*/
console.log("searchModule: Blacklisted dataSets: " + $scope.blacklist_datasets);
console.log("searchModule: Blacklisted indicatorGroups: " + $scope.blacklist_indicatorgroups);
var filterObjects = function(obj,type) {
if(type == 'dataElement'){
var filterObjects = function (obj, type) {
if (type == 'dataElement') {
var temp = obj.dataSetElements.length > 0;
if (temp && $scope.blacklist_datasets.length > 0) {
temp = false;
obj.dataSetElements.forEach(function(dse) {
temp = false;
obj.dataSetElements.forEach(function (dse) {
temp = temp || ($scope.blacklist_datasets.indexOf(dse.dataSet.id) == -1);
});
});
}
return temp;
}else if (type == 'indicator') {
} else if (type == 'indicator') {
var temp = obj.indicatorGroups.length > 0;
if (temp && $scope.blacklist_indicatorgroups.length > 0) {
temp = false;
obj.indicatorGroups.forEach(function(ig) {
obj.indicatorGroups.forEach(function (ig) {
temp = temp || ($scope.blacklist_indicatorgroups.indexOf(ig.id) == -1);
});
}
Expand All @@ -80,7 +81,7 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
var self = this;
self.isFiltersVisible = false;

self.applyGlobalSearch = function() {
self.applyGlobalSearch = function () {
var term = self.globalSearchTerm;
//var term_or = self.globalSearchTerm.split('||');
var filter_content = self.tableParams.filter();
Expand All @@ -98,7 +99,8 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
};
$scope.cols_object_advanced = {
object_id: true,
object_code: true
object_code: true,
object_ICD10: false
};
$scope.cols_object_desc = {
object_description: true,
Expand Down Expand Up @@ -128,26 +130,27 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope

$scope.loaded = {
//dataElements
get_dataElements: false,
get_dataElementsDescriptions: false,
get_dataElementsGroups: false,
get_dataElements: false,
get_dataElementsDescriptions: false,
get_dataElementsGroups: false,
//indicators
get_indicators: false,
get_indicatorsDescriptions: false,
get_indicatorGroups: false
get_indicators: false,
get_indicatorsDescriptions: false,
get_indicatorGroups: false
};

$scope.allObjects = [];
$scope.$watch('allObjects', function(){
$scope.$watch('allObjects', function () {
//console.log('$scope.allObjects update', $scope.allObjects);
var loaded_array = Object.keys($scope.loaded).map(function(key) { return $scope.loaded[key]; });
if(loaded_array.indexOf(false) == -1){
var loaded_array = Object.keys($scope.loaded).map(function (key) { return $scope.loaded[key]; });
if (loaded_array.indexOf(false) == -1) {
self.tableParams.settings({
filterOptions: { filterFilterName: "filterOR" },
dataset: $scope.allObjects
});
if($scope.table.cols){
$scope.table.cols.forEach(function(col) {
if ($scope.table.cols) {
$scope.table.cols.forEach(function (col) {
// console.log(col);
col.code = Object.keys(col.filter())[0];
});
}
Expand All @@ -158,23 +161,23 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
// The next three functions are repeated from dossiers controllers!
// numerator and denominator description is in indicator description
// (translatation doesn't work for denom and num columns) so have be extracted
$scope.getNumerator = function(indicator) {
$scope.getNumerator = function (indicator) {
var re = /(NUM:)(.*)(DENOM:)/;
var result = re.exec(indicator.displayDescription);
if (result !== null) {
return result.length > 1 ? result[2] : "x";
}
};

$scope.getDenominator = function(indicator) {
$scope.getDenominator = function (indicator) {
var re = /(DENOM:)(.*)/;
var result = re.exec(indicator.displayDescription);
if (result !== null) {
return result.length > 1 ? result[2] : "x";
}
};

$scope.getDescription = function(indicator) {
$scope.getDescription = function (indicator) {
var re = /(.*)(NUM:)/;
var result = re.exec(indicator.displayDescription);
if (result !== null) {
Expand All @@ -184,7 +187,7 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
}
};

$scope.parseFormula = function(formula, dataElements, categoryOptionCombos) {
$scope.parseFormula = function (formula, dataElements, categoryOptionCombos) {
var operatorRegex = /}\s*[\+\-\*]\s*#/g;
var dataElementRegex = /#\{\w*}/g;
var dataElementCatRegex = /#\{\w*.\w*}/g;
Expand All @@ -210,11 +213,11 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
};

function getDataElementHtml(dataElementObject) {
return "<span class='tooltipcontainer'>" + dataElementObject.object_name +
"<span class='tooltiptext'>" + dataElementObject.object_description +
"</span>" +
return "<span class='tooltipcontainer'>" + dataElementObject.object_name +
"<span class='tooltiptext'>" + dataElementObject.object_description +
"</span>" +
"</span>";
}
}

function load_table_info() {

Expand All @@ -223,11 +226,11 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
var temp = {};
var categoryOptionCombosTemp = {};

searchAllFactory.qry_dataElementsAll.query().$promise.then(function(response){
response.dataElements.forEach(function(obj) {

if(filterObjects(obj,"dataElement")){
searchAllFactory.qry_dataElementsAll.query().$promise.then(function (response) {
response.dataElements.forEach(function (obj) {

if (filterObjects(obj, "dataElement")) {
var attribute = "";
//objectGroup + service
var temp_arr = {
objectGroup_id: [],
Expand All @@ -238,16 +241,16 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
service_name: []
};

obj.dataSetElements.forEach(function(grp) {
if($scope.servicesList && grp.dataSet.attributeValues.length > 0 && grp.dataSet.attributeValues[0].value){
obj.dataSetElements.forEach(function (grp) {
if ($scope.servicesList && 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]){
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{
} else {
console.log("searchModule: Cannot find any service with code: " + code);
}
});
Expand All @@ -257,10 +260,26 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
temp_arr.objectGroup_name.push(grp.dataSet.displayName);
});


if (obj.attributeValues != undefined) {

obj.attributeValues.forEach(function (att) {

if (att.attribute.id == "zC3TBJnSxar") {
attribute = att.value;
$scope.cols_object_advanced.object_ICD10 = true;
} else { attribute = "" }

});
}



temp[obj.id] = {
object_type: 'dataElement',
object_id: obj.id,
object_code: obj.code,
object_ICD10: attribute,
object_name: obj.displayName,
object_form: obj.displayFormName,
object_description: obj.displayDescription,
Expand All @@ -271,6 +290,8 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
service_code: temp_arr.service_code.join(', '),
service_name: temp_arr.service_name.join(', ')
};


}
});

Expand All @@ -282,20 +303,20 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope

return "done";

}).then(function() {
return searchAllFactory.get_categoryOptionCombosAll.query().$promise.then(function(response){
response.categoryOptionCombos.forEach(function(obj) {
}).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
}
});
});
}).then(function(){
return searchAllFactory.get_indicatorsAll.query().$promise.then(function(response){
response.indicators.forEach(function(obj) {
}).then(function () {
return searchAllFactory.get_indicatorsAll.query().$promise.then(function (response) {
response.indicators.forEach(function (obj) {

if(filterObjects(obj,"indicator")){
if (filterObjects(obj, "indicator")) {

//objectGroup + service
var temp_arr = {
Expand All @@ -307,16 +328,16 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
service_name: []
};

obj.indicatorGroups.forEach(function(grp) {
if($scope.servicesList && grp.attributeValues.length > 0 && grp.attributeValues[0].value){
obj.indicatorGroups.forEach(function (grp) {
if ($scope.servicesList && grp.attributeValues.length > 0 && grp.attributeValues[0].value) {
var servicesCode = grp.attributeValues[0].value.split('_');
servicesCode.shift();
servicesCode.forEach(function(code) {
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{
} else {
console.log("searchModule: Cannot find any service with code: " + code);
}
});
Expand All @@ -335,7 +356,7 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
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_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(', '),
Expand All @@ -352,19 +373,19 @@ searchModule.controller('searchController', ['ExcelFactory', '$timeout', '$scope
$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]; });
$scope.allObjects = Object.keys(temp).map(function (key) { return temp[key]; });

console.log("searchModule: Indicators loaded")

return "done";
});
}).then(function log(){
}).then(function log() {
console.log("searchModule: Loading time of search table: " + (Date.now() - start) + " milliseconds.");
});
}

$scope.exportToExcel = function(tableId){ // ex: '#my-table'
var exportHref = ExcelFactory.tableToExcel(tableId,'hmis_table');
$scope.exportToExcel = function (tableId) { // ex: '#my-table'
var exportHref = ExcelFactory.tableToExcel(tableId, 'hmis_table');
var a = document.createElement('a');
a.href = exportHref;
a.download = 'hmis_table.xls';
Expand Down
8 changes: 4 additions & 4 deletions app/search/search.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
------------------------------------------------------------------------------------*/

//dataElements - 255 KB as of 20/11/2106
var qry_dataElements = dhisUrl + 'dataElements.json?fields=id,code,displayName,displayFormName,dataSetElements[dataSet[id]]&paging=false&filter=domainType\\:eq\\:AGGREGATE';
var qry_dataElements = dhisUrl + 'dataElements.json?fields=id,code,attributeValues[value,attribute[id]],displayName,displayFormName,dataSetElements[dataSet[id]]&paging=false&filter=domainType\\:eq\\:AGGREGATE';


//descriptions - 286 KB as of 20/11/2106
Expand All @@ -14,7 +14,7 @@ var qry_dataElementsDescriptions = dhisUrl + 'dataElements.json?fields=id,displa
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]]]' +
'fields=id,code,attributeValues[value, attribute[id]],displayName,displayDescription,displayFormName,dataSetElements[dataSet[displayName,id,code,attributeValues[value]]]' +
'&paging=false&filter=domainType\\:eq\\:AGGREGATE';


Expand Down Expand Up @@ -64,7 +64,7 @@ searchModule.factory('searchAllFactory', ['$resource',function($resource) {
}]);


var qryAllDataElements = dhisUrl + 'dataElements.json?fields=code,displayName,id,displayFormName,displayDescription,sections[displayName,id],dataSets[displayName,id]&paging=false';
var qryAllDataElements = dhisUrl + 'dataElements.json?fields=code,displayName,id,displayFormName,displayDescription,sections[displayName,id],dataSets[displayName,id], attributeValues[value,attribute[id]]&paging=false';

searchModule.factory('searchAllDataElementsFactory', ['$resource',
function($resource) {
Expand Down Expand Up @@ -92,7 +92,7 @@ searchModule.factory('searchAllIndicatorsFactory', ['$resource',
]);


var qryAllDataElementsBis = dhisUrl + 'dataSets.json?fields=id,code,displayName,sections[id,displayName,dataElements[code,displayName,id,displayDescription]]&paging=false';
var qryAllDataElementsBis = dhisUrl + 'dataSets.json?fields=id,code,attributeValues[value,attribute[id]],displayName,sections[id,displayName,dataElements[code,displayName,id,displayDescription]]&paging=false';
//var qryAllDataElementsBis = dhisUrl + 'dataSets.json?fields=id,code,displayName,sections[id,displayName,dataElements[code,displayName,id,displayDescription]],organisationUnits[parent[parent[parent[name,id,level],name,id,level],name,id,level],name,id,level]&paging=false';

searchModule.factory('searchAllDataElementsBisFactory', ['$resource',
Expand Down
Loading

0 comments on commit ba8edf3

Please sign in to comment.