Skip to content

Commit

Permalink
Check for empty data condition. (OHDSI#2834)
Browse files Browse the repository at this point in the history
Fixes OHDSI#2832.

(cherry picked from commit 1af7708)
  • Loading branch information
chrisknoll authored and anton-abushkevich committed Mar 6, 2023
1 parent 7f2685f commit aeea21e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
4 changes: 1 addition & 3 deletions js/pages/pathways/components/tabs/pathway-tableview.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
<div>
The number of people that have unique event cohorts or conbimations found across all ranks of the pathway analysis results.
</div>
<table data-bind="dataTable: $component.getDistinctEventCohortCountsDatatable($data)"></table>

<table data-bind="dataTable: $component.getDistinctEventCohortCountsDatatable($data)"></table>
<hr>

</div>
</div>
39 changes: 24 additions & 15 deletions js/pages/pathways/components/tabs/pathway-tableview.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,27 @@ define([
prepareReportData() {
const design = this.results.design;
const pathwayGroups = this.results.data.pathwayGroups;

return({
cohorts: design.targetCohorts.filter(c => this.filterList.selectedValues().includes(c.id)).map(c => {

const pathwayGroup = pathwayGroups.find(p => p.targetCohortId == c.id);
return {
id: c.id,
name: c.name,
cohortCount: pathwayGroup.targetCohortCount,
pathwayCount: pathwayGroup.totalPathwaysCount,
pathways: pathwayGroup.pathways.map(p => ({ // split pathway paths into paths and counts
path : p.path.split('-')
.filter(step => step != "end") // remove end markers from pathway
.map(p => +p)
.concat(Array(MAX_PATH_LENGTH).fill(null)) // pad end of paths to be at least MAX_PATH_LENGTH
.slice(0,MAX_PATH_LENGTH), // limit path to MAX_PATH_LENGTH.
personCount: p.personCount
}))
if (pathwayGroup) {
return {
id: c.id,
name: c.name,
cohortCount: pathwayGroup.targetCohortCount,
pathwayCount: pathwayGroup.totalPathwaysCount,
pathways: pathwayGroup.pathways.map(p => ({ // split pathway paths into paths and counts
path : p.path.split('-')
.filter(step => step != "end") // remove end markers from pathway
.map(p => +p)
.concat(Array(MAX_PATH_LENGTH).fill(null)) // pad end of paths to be at least MAX_PATH_LENGTH
.slice(0,MAX_PATH_LENGTH), // limit path to MAX_PATH_LENGTH.
personCount: p.personCount
}))
}
} else {
return null;
}
}),
eventCodes: this.results.data.eventCodes
Expand Down Expand Up @@ -114,7 +118,7 @@ define([
return col;
});
let statCols = [columnValueBuilder(ko.i18n('columns.count', 'Count')(), "personCount")];
let data = this.getPathwayGroupData(pathwayGroup, pathLength);
let data = pathwayGroup ? this.getPathwayGroupData(pathwayGroup, pathLength) : [];

statCols.push(columnValueBuilder(ko.i18n('columns.pctWithPathway', '% with Pathway')(), "pathwayPercent", percentFormat));
statCols.push(columnValueBuilder(ko.i18n('columns.pctOfCohort', '% of Cohort')(), "cohortPercent", percentFormat));
Expand Down Expand Up @@ -154,6 +158,8 @@ define([

getEventCohortsByRank(pathwayGroup)
{
if (!pathwayGroup) return []; // default to empty data

const pathways = pathwayGroup.pathways;
const eventCodes = this.reportData().eventCodes;
let groups = pathways.reduce((acc,cur) => { // reduce pathways an Array of ranks containing a Map of counts by event cohort
Expand Down Expand Up @@ -225,6 +231,7 @@ define([

getEventCohortCounts(pathwayGroup)
{
if (!pathwayGroup) return []; // default to empty data
const pathways = pathwayGroup.pathways;
const eventCodes = this.reportData().eventCodes;
let dataMap = pathways.reduce((acc,cur) => { // reduce pathways an Array of ranks containing a Map of counts by event cohort
Expand Down Expand Up @@ -292,6 +299,8 @@ define([

getDistinctEventCohortCounts(pathwayGroup)
{
if (!pathwayGroup) return []; // default to empty data

const pathways = pathwayGroup.pathways;
let dataMap = pathways.reduce((acc,cur) => { // reduce pathways an Array of ranks containing a Map of counts by comboId
const visited = new Map();
Expand Down

0 comments on commit aeea21e

Please sign in to comment.