-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.component.ts
226 lines (213 loc) · 6.62 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import { Component } from '@angular/core';
import { ResultRenderer } from '@samply/lens-core';
import {
BarChartComponent,
PieChartComponent,
} from '@samply/lens-components/chart-js';
import { ResultSummaryBarComponent } from '@samply/lens-components/result-summary-bar';
import { ResultTableComponent } from '@samply/lens-components/result-table';
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', 'Patienten')
.set('specimen', 'Proben')
.set('diagnosis', 'Diagnosen');
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(
'Ergebnisse',
[{ key: 'sites' }, { key: 'patients' }],
ResultSummaryBarComponent,
{
headers: this.summaryBarHeaders,
clickDisabled: true,
showNegotiationButton: true,
}
);
public diagrams: ResultRenderer[] = [
new ResultRenderer(
'Patienten pro Standort',
[{ key: 'sites', subset: '*' }],
PieChartComponent,
{ headers: this.siteHeaders, clickDisabled: true }
),
new ResultRenderer(
'',
[{ key: 'patients', subset: 'sites' }],
ResultTableComponent,
{
headers: this.siteHeaders,
clickDisabled: true,
displayProperties: ['wide-diagram'],
}
),
new ResultRenderer(
'Geschlecht',
[{ key: 'patients', subset: 'Gender' }],
PieChartComponent,
{ headers: this.genderHeaders }
),
new ResultRenderer(
'Diagnosen',
[{ key: 'diagnosis', subset: 'diagnosis' }],
BarChartComponent,
{
indexAxis: 'y',
aggregators: this.diagnosisAggregators,
displayProperties: ['high-diagram'],
xAxisTitle: 'Anzahl der Diagnosen',
yAxisTitle: 'ICD-10-Codes',
}
),
new ResultRenderer(
'Alter bei Erstdiagnose',
[{ key: 'patients', subset: 'Age' }],
BarChartComponent,
{
headers: this.ageHeaders,
sorters: this.ageSorters,
clickDisabled: true,
displayProperties: ['wide-diagram'],
xAxisTitle: 'Alter',
yAxisTitle: 'Anzahl der Primärdiagnosen',
}
),
new ResultRenderer(
'Vitalstatus*',
[{ key: 'patients', subset: '75186-7' }],
PieChartComponent,
{ hints: this.vitalStateHints }
),
new ResultRenderer(
'Therapieart',
[
{ key: 'procedures', subset: 'ProcedureType' },
{ key: 'medicationStatements' },
],
BarChartComponent,
{
headers: this.therapyHeaders,
clickDisabled: true,
yAxisTitle: 'Anzahl der Therapien',
}
),
new ResultRenderer(
'Systemische Therapien',
[{ key: 'medicationStatements', subset: 'MedicationType' }],
BarChartComponent,
{ clickDisabled: true, yAxisTitle: 'Anzahl der Therapien' }
),
new ResultRenderer(
'Proben',
[{ key: 'specimen', subset: 'sample_kind' }],
BarChartComponent,
{ xAxisTitle: 'Probentypen', yAxisTitle: 'Probenanzahl' }
),
];
}