generated from samply/lens-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.component.ts
166 lines (154 loc) · 5.2 KB
/
main.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import { Component } from '@angular/core';
import { ResultTableComponent } from '@samply/lens-components/result-table';
import { ResultRenderer } from '@samply/lens-core';
import { ResultRendererGridComponent } from '@samply/lens-components/result-renderer-grid';
import {
BarChartComponent,
PieChartComponent,
} from '@samply/lens-components/chart-js';
import { ResultSummaryBarComponent } from '@samply/lens-components/result-summary-bar';
const DIAGNOSIS_REGEX = /C|D0|D4|D37|D38|D39/gm;
@Component({
selector: 'app-main',
templateUrl: './main.component.html',
styleUrls: ['./main.component.css'],
})
export class MainComponent {
private siteHeaders: Map<string, string> = new Map<string, string>()
.set('berlin', 'Berlin')
.set('bonn', 'Bonn')
.set('dresden', 'Dresden')
.set('essen', 'Essen')
.set('frankfurt', 'Frankfurt')
.set('freiburg', 'Freiburg')
.set('hannover', 'Hannover')
.set('mainz', 'Mainz')
.set('mannheim', 'Mannheim')
.set('muenchen-lmu', 'München(LMU)')
.set('muenchen-tum', 'München(TUM)')
.set('ulm', 'Ulm')
.set('wuerzburg', 'Würzburg')
.set('dktk-test', 'DKTK-Test');
private ageHeaders: Map<string, string> = new Map<string, string>()
.set('0', '0-9')
.set('10', '10-19')
.set('20', '20-29')
.set('30', '30-39')
.set('40', '40-49')
.set('50', '50-59')
.set('60', '60-69')
.set('70', '70-79')
.set('80', '80-89')
.set('90', '90-99')
.set('100', '100-109')
.set('110', '110-119');
private ageSorters: Array<
(
a: { key: string; population: number },
b: { key: string; population: number }
) => number
> = [
(a, b) => {
return parseInt(a.key) - parseInt(b.key);
},
];
private genderHeaders: Map<string, string> = new Map<string, string>()
.set('male', 'männlich')
.set('female', 'weiblich')
.set('other', 'sonstiges / intersexuell')
.set('unknown', 'unbekannt');
private vitalStateHeaders: Map<string, string> = new Map<string, string>()
.set('lebend', 'alive')
.set('verstorben', 'deceased')
.set('unbekannt', 'unknown');
private vitalStateHints: string[] = [
'"verstorben" bedeutet, dass ein Todesdatum dokumentiert wurde. Die anderen Werte dieser Übersicht wurden noch nicht harmonisiert.',
];
private therapyHeaders: Map<string, string> = new Map<string, string>()
.set('OP', 'Operationen')
.set('ST', 'Strahlentherapien')
.set('medicationStatements', 'Systemische Therapien');
private summaryBarHeaders: Map<string, string> = new Map<string, string>()
.set('sites', 'Standorte')
.set('patients', 'Patients')
.set('specimen', 'Proben')
.set('diagnosis', 'Diagnosen')
.set('collections', 'Collections');
private diagnosisAggregators: Array<
(
values: Array<{ key: string; population: number }>
) => Array<{ key: string; population: number }>
> = [
// Filter the Input
(values) => {
return values.filter((value) => DIAGNOSIS_REGEX.test(value.key));
},
// Sort alphabetically
(values) => {
return values.sort((a, b) => a.key.localeCompare(b.key));
},
(values) => {
if (values.every((value) => value.key.indexOf(values[0].key) !== -1)) {
return values;
} else {
// 1) Reduce the key to the necessary part (for later aggregation leave the .)
const adjustedIcdCodes = values.map((value) => {
return {
key: value.key.substring(0, 4),
population: value.population,
};
});
// 2) Aggregate the populations
let aggregatedResults: Array<{ key: string; population: number }> = [];
adjustedIcdCodes.forEach((value) => {
const index = aggregatedResults.findIndex(
(icdCode) => icdCode.key === value.key
);
if (index != -1) {
aggregatedResults[index].population += value.population;
} else {
aggregatedResults = [...aggregatedResults, value];
}
});
// 3) Add % for wildcards on codes with .
const result = aggregatedResults.map((value) => {
if (value.key.indexOf('.') !== -1) {
return { key: value.key + '%', population: value.population };
} else {
return value;
}
});
return result;
}
},
];
public summaryBar = new ResultRenderer(
'Results',
[{ key: 'collections' }, { key: 'patients' }],
ResultSummaryBarComponent,
{
headers: this.summaryBarHeaders,
clickDisabled: true,
showNegotiationButton: true,
}
);
public diagrams: ResultRenderer[] = [
new ResultRenderer(
'Studies per collection',
[{ key: 'collections', subset: 'studies' }],
PieChartComponent,
{ headers: this.siteHeaders, clickDisabled: true }
),
// new ResultRenderer("Subjects per collection", [{ key: "collections", subset: 'subjects' }], PieChartComponent, { headers: this.siteHeaders, clickDisabled: true}),
new ResultRenderer(
'',
[{ key: 'patients', subset: 'sites' }],
ResultTableComponent,
{
headers: this.siteHeaders,
clickDisabled: true,
displayProperties: ['wide-diagram'],
}
),
];
}