-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
193 lines (168 loc) · 4.62 KB
/
options.js
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
// Import steps configuration
// --------------------------
import metadataDictionary from "../metadata";
import { stackMetadata, stackTools } from "../defaults";
// Preview canvas tools
const defaultCanvasTools = stackTools.preview;
// Loaded series extracted metadata and table headers
const patientMetadata = stackMetadata.patient;
const studyMetadata = stackMetadata.study;
const defaultMetadata = [
...patientMetadata,
...studyMetadata,
...stackMetadata.series
];
const requiredMetadata = [
metadataDictionary.StudyInstanceUID,
"larvitarSeriesInstanceUID",
"anonymized"
];
const defaultDisclaimer =
"THIS VERSION IS NOT CERTIFIED AS A MEDICAL DEVICE FOR PRIMARY DIAGNOSIS. <br /> THERE ARE NO CERTIFICATIONS. <br /> IT'S POSSIBLE USE IT ONLY AS A REVIEWING AND SCIENTIFIC SOFTWARE, <br /> NOT FOR PRIMARY DIAGNOSTICS.";
const computeHeaders = (metadata, allowAnonymization) => {
const list = [{ sortable: false, text: "", value: "preview" }];
if (allowAnonymization) {
list.push({ sortable: false, text: "anonymize", value: "anonymized" });
}
return [
...list,
...metadata.map(value => ({
cellClass: `cell-${value}`,
sortable: true,
text: `metadata-${value}`,
value
}))
];
};
// Loaded series actions
const defaultActions = [
{
cacheStacks: false,
closeOnEmit: false,
disabled: true,
emitter: "dicom-import-upload",
hint: "series will be saved in your dashboard",
storeStacks: true, // TODO clear once uploaded
text: "upload series"
},
// {
// cacheStacks: false,
// closeOnEmit: false,
// disabled: true,
// emitter: "dicom-import-upload-and-open",
// hint: "series will be saved in your dashboard",
// storeStacks: true,
// text: "upload series and open viewer"
// },
{
cacheStacks: false,
closeOnEmit: true,
default: true,
disabled: false,
emitter: "dicom-import-open",
hint:
"you won't be able to access these series again once the browser session is closed",
storeStacks: true,
text: "open viewer without uploading"
}
];
// Default import steps configuration
const defaultSteps = [
{
component: () => import("./steps/Step1"),
label: "import-files",
back: () => false,
next: series => series.length > 0
},
{
actions: defaultActions,
component: () => import("./steps/Step2"),
label: "select-series",
back: () => true,
next: () => false
},
{
component: () => import("./steps/Step3"),
label: "upload",
back: () => false,
next: () => false,
closeConfirmation: status => status.completed,
status: null // { completed: false, loading: false, errors: null, progress: {} }
}
];
// Exports
// -------
export const getCanvasTools = options => options.tools || defaultCanvasTools;
export const getMetadata = options => {
if (options.metadata) {
// Add required keys if missing
requiredMetadata.forEach(key => {
if (!options.metadata.find(value => key == value)) {
options.metadata.push(key);
}
});
return options.metadata;
}
return defaultMetadata;
};
export const getDisclaimer = options => {
return options.disclaimer ? options.disclaimer : defaultDisclaimer;
};
export const getHeaders = options => {
if (options.headers) {
return options.headers;
}
if (options.metadata) {
return computeHeaders(
options.metadata.filter(v => !studyMetadata.find(vv => vv == v)),
options.allowAnonymization
);
}
const omit = [
...patientMetadata,
...studyMetadata,
...requiredMetadata,
metadataDictionary.SeriesTime,
"isMultiframe"
];
let headers = computeHeaders(
defaultMetadata.filter(v => !omit.find(vv => vv == v)),
options.allowAnonymization
);
// Merge date and time
let seriesDateHeader = headers.find(
h => h.value == metadataDictionary.SeriesDate
);
seriesDateHeader.keys = [
metadataDictionary.SeriesDate,
metadataDictionary.SeriesTime
];
seriesDateHeader.keyTag = "span";
seriesDateHeader.keyClass = "ml-1";
// Add patient header
headers.splice(1, 0, {
cellClass: "cell-patient",
keys: patientMetadata,
sortable: false,
text: "patient",
value: "patient"
});
return headers;
};
export const getSteps = (options = {}) => {
let steps = [...defaultSteps];
if (options.steps) {
options.steps.forEach((step, i) => {
if (step) {
if (step.actions && steps[i].actions) {
step.actions = steps[i].actions.map((a, j) => ({
...a,
...step.actions[j]
}));
}
steps[i] = { ...steps[i], ...step };
}
});
}
return steps;
};