generio-sdk 1.0.92 → 1.0.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/index.cjs +334 -1
- package/dist/index.js +294 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1,334 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let uuid = require("uuid");
|
|
25
|
+
uuid = __toESM(uuid);
|
|
26
|
+
|
|
27
|
+
//#region src/models/FormTypeEnum.ts
|
|
28
|
+
let FormTypeEnum = /* @__PURE__ */ function(FormTypeEnum$1) {
|
|
29
|
+
FormTypeEnum$1[FormTypeEnum$1["NewLine"] = 0] = "NewLine";
|
|
30
|
+
FormTypeEnum$1[FormTypeEnum$1["Text"] = 1] = "Text";
|
|
31
|
+
FormTypeEnum$1[FormTypeEnum$1["BoldText"] = 2] = "BoldText";
|
|
32
|
+
FormTypeEnum$1[FormTypeEnum$1["CheckBox"] = 3] = "CheckBox";
|
|
33
|
+
FormTypeEnum$1[FormTypeEnum$1["DropDownList"] = 4] = "DropDownList";
|
|
34
|
+
FormTypeEnum$1[FormTypeEnum$1["InputText"] = 5] = "InputText";
|
|
35
|
+
FormTypeEnum$1[FormTypeEnum$1["ConditionAndOr"] = 6] = "ConditionAndOr";
|
|
36
|
+
FormTypeEnum$1[FormTypeEnum$1["Function"] = 7] = "Function";
|
|
37
|
+
FormTypeEnum$1[FormTypeEnum$1["Condition"] = 8] = "Condition";
|
|
38
|
+
FormTypeEnum$1[FormTypeEnum$1["Button"] = 9] = "Button";
|
|
39
|
+
FormTypeEnum$1[FormTypeEnum$1["Append"] = 10] = "Append";
|
|
40
|
+
FormTypeEnum$1[FormTypeEnum$1["DigitBox"] = 11] = "DigitBox";
|
|
41
|
+
FormTypeEnum$1[FormTypeEnum$1["Merge"] = 12] = "Merge";
|
|
42
|
+
FormTypeEnum$1[FormTypeEnum$1["Listing"] = 13] = "Listing";
|
|
43
|
+
FormTypeEnum$1[FormTypeEnum$1["Bilateral"] = 14] = "Bilateral";
|
|
44
|
+
FormTypeEnum$1[FormTypeEnum$1["Matrix"] = 15] = "Matrix";
|
|
45
|
+
FormTypeEnum$1[FormTypeEnum$1["RememberedText"] = 17] = "RememberedText";
|
|
46
|
+
FormTypeEnum$1[FormTypeEnum$1["InputTable"] = 18] = "InputTable";
|
|
47
|
+
FormTypeEnum$1[FormTypeEnum$1["AppendDiagnose"] = 19] = "AppendDiagnose";
|
|
48
|
+
FormTypeEnum$1[FormTypeEnum$1["MoveByExtParams"] = 20] = "MoveByExtParams";
|
|
49
|
+
return FormTypeEnum$1;
|
|
50
|
+
}({});
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/services/ExaminationDataHelpers.ts
|
|
54
|
+
var ExaminationDataHelpers = class {
|
|
55
|
+
constructor() {}
|
|
56
|
+
/**
|
|
57
|
+
* Convert DB items into hbs object. Used in FindingGenerator.handlebars
|
|
58
|
+
* @param items ExaminationData entries
|
|
59
|
+
* @returns entry array for hbs
|
|
60
|
+
*/
|
|
61
|
+
ConvertExaminationDataToGeneratorRows(items) {
|
|
62
|
+
const rows = [];
|
|
63
|
+
let i = 0;
|
|
64
|
+
let rowIndexRef = 0;
|
|
65
|
+
let row = { subRows: [] };
|
|
66
|
+
let subRows = [];
|
|
67
|
+
let columns = [];
|
|
68
|
+
do {
|
|
69
|
+
do {
|
|
70
|
+
do {
|
|
71
|
+
if (items[i]?.formType == FormTypeEnum.NewLine) break;
|
|
72
|
+
if (items[i]) switch (items[i].formType) {
|
|
73
|
+
case FormTypeEnum.DropDownList: {
|
|
74
|
+
const elementColumn = this.CreateColumnFromExaminationData(items[i]);
|
|
75
|
+
elementColumn.elementIndex = i;
|
|
76
|
+
const elementSelectOptions = [];
|
|
77
|
+
let optionIndex = 1;
|
|
78
|
+
do {
|
|
79
|
+
const elementSelectOption = this.CreateColumnFromExaminationData(items[i]);
|
|
80
|
+
elementSelectOption.elementIndex = i;
|
|
81
|
+
const _value = items[i]?.formValue?.trim();
|
|
82
|
+
if (optionIndex === 1 && _value && !_value.startsWith("-") && !_value.endsWith("-")) elementColumn.preselected = true;
|
|
83
|
+
elementSelectOptions.push(elementSelectOption);
|
|
84
|
+
i++;
|
|
85
|
+
optionIndex++;
|
|
86
|
+
} while (items[i]?.formType == FormTypeEnum.DropDownList && i < items.length);
|
|
87
|
+
elementColumn.elementSelectOptions = elementSelectOptions;
|
|
88
|
+
columns.push(elementColumn);
|
|
89
|
+
i--;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case FormTypeEnum.Text:
|
|
93
|
+
case FormTypeEnum.Append:
|
|
94
|
+
if (items[i]?.formValue) {
|
|
95
|
+
const column = this.CreateColumnFromExaminationData(items[i]);
|
|
96
|
+
column.elementIndex = i;
|
|
97
|
+
columns.push(column);
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
case FormTypeEnum.InputText: {
|
|
101
|
+
const elementColumn = this.CreateColumnFromExaminationData(items[i]);
|
|
102
|
+
elementColumn.elementIndex = i;
|
|
103
|
+
elementColumn.isDistance = this.IsDistanceDefinition(items[i + 1]?.formValue ?? "");
|
|
104
|
+
columns.push(elementColumn);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case FormTypeEnum.BoldText:
|
|
108
|
+
case FormTypeEnum.CheckBox:
|
|
109
|
+
case FormTypeEnum.Button:
|
|
110
|
+
case FormTypeEnum.DigitBox:
|
|
111
|
+
case FormTypeEnum.RememberedText:
|
|
112
|
+
case FormTypeEnum.InputTable:
|
|
113
|
+
case FormTypeEnum.MoveByExtParams: {
|
|
114
|
+
const column = this.CreateColumnFromExaminationData(items[i]);
|
|
115
|
+
column.elementIndex = i;
|
|
116
|
+
columns.push(column);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
default: break;
|
|
120
|
+
}
|
|
121
|
+
i++;
|
|
122
|
+
} while (i < items.length);
|
|
123
|
+
if (columns.length > 0) {
|
|
124
|
+
const subRow = {
|
|
125
|
+
columns,
|
|
126
|
+
rowIndexRef
|
|
127
|
+
};
|
|
128
|
+
subRows.push(subRow);
|
|
129
|
+
}
|
|
130
|
+
columns = [];
|
|
131
|
+
rowIndexRef++;
|
|
132
|
+
if (!row.showHideElementId || !items[i]?.formValue || row.showHideElementId != items[i]?.formValue) break;
|
|
133
|
+
i++;
|
|
134
|
+
} while (i < items.length);
|
|
135
|
+
if (subRows.length > 0) {
|
|
136
|
+
row.subRows = subRows;
|
|
137
|
+
rows.push(row);
|
|
138
|
+
}
|
|
139
|
+
subRows = [];
|
|
140
|
+
row = {};
|
|
141
|
+
if (items[i]?.formType == FormTypeEnum.NewLine && items[i]?.formValue) row.showHideElementId = items[i].formValue ?? "";
|
|
142
|
+
else row.showHideElementId = "";
|
|
143
|
+
if (items[i]?.formType == FormTypeEnum.NewLine && items[i]?.conclusion && items[i]?.conclusion == "hr") row.hrBeforeRow = true;
|
|
144
|
+
else row.hrBeforeRow = false;
|
|
145
|
+
i++;
|
|
146
|
+
} while (i < items.length);
|
|
147
|
+
return rows;
|
|
148
|
+
}
|
|
149
|
+
CreateColumn(formType, formValue, finding, conclusion, guid, radLexId, extParam) {
|
|
150
|
+
return {
|
|
151
|
+
formTypeId: formType,
|
|
152
|
+
formValue,
|
|
153
|
+
finding,
|
|
154
|
+
conclusion,
|
|
155
|
+
guid: guid ?? (0, uuid.v4)(),
|
|
156
|
+
radLexId,
|
|
157
|
+
extParam
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
CreateColumnFromExaminationData(item) {
|
|
161
|
+
return this.CreateColumn(item.formType, item.formValue, item.finding, item.conclusion, item.guid, item.radLexId, item.extParam);
|
|
162
|
+
}
|
|
163
|
+
IsDistanceDefinition(originFormValue) {
|
|
164
|
+
if (originFormValue) return originFormValue.includes("mm") || originFormValue.trim() === "x";
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/index.ts
|
|
171
|
+
const GENERIO_ORIGIN = "https://gener.io";
|
|
172
|
+
async function login(model, origin) {
|
|
173
|
+
if ((await fetch((origin ?? GENERIO_ORIGIN) + "/api/cookiesAuth/login", {
|
|
174
|
+
method: "POST",
|
|
175
|
+
credentials: "include",
|
|
176
|
+
headers: { "Content-Type": "application/json" },
|
|
177
|
+
body: JSON.stringify(model)
|
|
178
|
+
})).ok) return { isSuccess: true };
|
|
179
|
+
return { isSuccess: false };
|
|
180
|
+
}
|
|
181
|
+
async function logout(origin) {
|
|
182
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/cookiesAuth/logout", {
|
|
183
|
+
method: "POST",
|
|
184
|
+
credentials: "include",
|
|
185
|
+
headers: { "Content-Type": "application/json" }
|
|
186
|
+
});
|
|
187
|
+
return response.ok || response.status === 401 || response.status === 403 ? { isSuccess: true } : { isSuccess: false };
|
|
188
|
+
}
|
|
189
|
+
async function recognizeExamination(model, origin) {
|
|
190
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/generioApp/recognizeExaminationCookiesAuth";
|
|
191
|
+
const response = await fetch(url, {
|
|
192
|
+
method: "POST",
|
|
193
|
+
credentials: "include",
|
|
194
|
+
body: JSON.stringify(model),
|
|
195
|
+
headers: { "Content-Type": "application/json" }
|
|
196
|
+
});
|
|
197
|
+
return response.ok ? response.json() : { isSuccess: false };
|
|
198
|
+
}
|
|
199
|
+
async function loadFormData(examinationId, studyInstanceUId, origin) {
|
|
200
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/GenerioApp/loadFormData", {
|
|
201
|
+
method: "POST",
|
|
202
|
+
credentials: "include",
|
|
203
|
+
headers: { "Content-Type": "application/json" },
|
|
204
|
+
body: JSON.stringify({
|
|
205
|
+
examinationId,
|
|
206
|
+
studyInstanceUId
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
return response.ok ? response.json() : Promise.reject(/* @__PURE__ */ new Error("Network issue"));
|
|
210
|
+
}
|
|
211
|
+
async function loadStudy(examinationId, studyInstanceUId, origin) {
|
|
212
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/GenerioApp/loadStudy", {
|
|
213
|
+
method: "POST",
|
|
214
|
+
credentials: "include",
|
|
215
|
+
headers: { "Content-Type": "application/json" },
|
|
216
|
+
body: JSON.stringify({
|
|
217
|
+
examinationId,
|
|
218
|
+
studyInstanceUId
|
|
219
|
+
})
|
|
220
|
+
});
|
|
221
|
+
return response.ok ? response.json() : Promise.reject(/* @__PURE__ */ new Error("Network issue"));
|
|
222
|
+
}
|
|
223
|
+
async function updateStudy(model, origin) {
|
|
224
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/GenerioApp/updateStudy", {
|
|
225
|
+
method: "POST",
|
|
226
|
+
credentials: "include",
|
|
227
|
+
headers: { "Content-Type": "application/json" },
|
|
228
|
+
body: JSON.stringify(model)
|
|
229
|
+
});
|
|
230
|
+
return response.ok ? response.json() : Promise.reject(/* @__PURE__ */ new Error("Network issue"));
|
|
231
|
+
}
|
|
232
|
+
async function getExtParamValueByStudyInstanceUId(model, origin) {
|
|
233
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/datasetsCookiesAuth/getExtParamValueByStudyInstanceUId";
|
|
234
|
+
const response = await fetch(url, {
|
|
235
|
+
method: "POST",
|
|
236
|
+
credentials: "include",
|
|
237
|
+
body: JSON.stringify(model),
|
|
238
|
+
headers: { "Content-Type": "application/json" }
|
|
239
|
+
});
|
|
240
|
+
return response.ok ? response.json() : {};
|
|
241
|
+
}
|
|
242
|
+
async function getAnnotationPlacements(model, origin) {
|
|
243
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/annotationPlacements/getAnnotationPlacements", {
|
|
244
|
+
method: "POST",
|
|
245
|
+
credentials: "include",
|
|
246
|
+
body: JSON.stringify(model),
|
|
247
|
+
headers: { "Content-Type": "application/json" }
|
|
248
|
+
});
|
|
249
|
+
return response.ok ? response.json() : {
|
|
250
|
+
isSuccess: false,
|
|
251
|
+
errorMessage: response.statusText,
|
|
252
|
+
annotationPlacements: []
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
async function setExtParams(model, origin) {
|
|
256
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/generioApp/setExtParamsCookiesAuth";
|
|
257
|
+
const response = await fetch(url, {
|
|
258
|
+
method: "POST",
|
|
259
|
+
credentials: "include",
|
|
260
|
+
body: JSON.stringify(model),
|
|
261
|
+
headers: { "Content-Type": "application/json" }
|
|
262
|
+
});
|
|
263
|
+
return response.ok ? response.json() : {
|
|
264
|
+
isSuccess: false,
|
|
265
|
+
errorMessage: "Network issue"
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function setExtParamsPostMessage(window$1, model, origin) {
|
|
269
|
+
window$1.postMessage({
|
|
270
|
+
action: "setExtParams",
|
|
271
|
+
model
|
|
272
|
+
}, { targetOrigin: origin ?? GENERIO_ORIGIN });
|
|
273
|
+
}
|
|
274
|
+
async function sendMeasurements(model, origin) {
|
|
275
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/generioApp/sendMeasurementsCookiesAuth";
|
|
276
|
+
const response = await fetch(url, {
|
|
277
|
+
method: "POST",
|
|
278
|
+
credentials: "include",
|
|
279
|
+
body: JSON.stringify(model),
|
|
280
|
+
headers: { "Content-Type": "application/json" }
|
|
281
|
+
});
|
|
282
|
+
return response.ok ? response.json() : {
|
|
283
|
+
isSuccess: false,
|
|
284
|
+
errorMessage: "Network issue"
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
async function getExaminationMessage(model, origin) {
|
|
288
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/generioApp/getExaminationMessageCookiesAuth";
|
|
289
|
+
const response = await fetch(url, {
|
|
290
|
+
method: "POST",
|
|
291
|
+
credentials: "include",
|
|
292
|
+
body: JSON.stringify(model),
|
|
293
|
+
headers: { "Content-Type": "application/json" }
|
|
294
|
+
});
|
|
295
|
+
return response.ok ? response.json() : {
|
|
296
|
+
isSuccess: false,
|
|
297
|
+
errorMessage: "Network issue"
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function setupPostMessageListeners(generioReadyHandler, origin) {
|
|
301
|
+
window.addEventListener("message", (event) => {
|
|
302
|
+
if ((origin ?? GENERIO_ORIGIN) != event.origin) return;
|
|
303
|
+
console.info(`PostMessageListener: Received message from origin: ${event.origin}`, event.data);
|
|
304
|
+
if (event.data.action == "generioReady") {
|
|
305
|
+
if (generioReadyHandler) generioReadyHandler(event.data.model, event);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
}, false);
|
|
309
|
+
}
|
|
310
|
+
function getGenerioRecognizeExaminationUrl(studyInstanceUId, modality, studyDescription, bodyPartExamined, origin) {
|
|
311
|
+
let url = `${origin ?? GENERIO_ORIGIN}/generator/recognizeExamination?studyInstanceUId=${studyInstanceUId}&modality=${modality}`;
|
|
312
|
+
if (studyDescription) url = url + `&studyDescription=${studyDescription}`;
|
|
313
|
+
if (bodyPartExamined) url = url + `&bodyPartExamined=${bodyPartExamined}`;
|
|
314
|
+
return url;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//#endregion
|
|
318
|
+
exports.ExaminationDataHelpers = ExaminationDataHelpers;
|
|
319
|
+
exports.FormTypeEnum = FormTypeEnum;
|
|
320
|
+
exports.GENERIO_ORIGIN = GENERIO_ORIGIN;
|
|
321
|
+
exports.getAnnotationPlacements = getAnnotationPlacements;
|
|
322
|
+
exports.getExaminationMessage = getExaminationMessage;
|
|
323
|
+
exports.getExtParamValueByStudyInstanceUId = getExtParamValueByStudyInstanceUId;
|
|
324
|
+
exports.getGenerioRecognizeExaminationUrl = getGenerioRecognizeExaminationUrl;
|
|
325
|
+
exports.loadFormData = loadFormData;
|
|
326
|
+
exports.loadStudy = loadStudy;
|
|
327
|
+
exports.login = login;
|
|
328
|
+
exports.logout = logout;
|
|
329
|
+
exports.recognizeExamination = recognizeExamination;
|
|
330
|
+
exports.sendMeasurements = sendMeasurements;
|
|
331
|
+
exports.setExtParams = setExtParams;
|
|
332
|
+
exports.setExtParamsPostMessage = setExtParamsPostMessage;
|
|
333
|
+
exports.setupPostMessageListeners = setupPostMessageListeners;
|
|
334
|
+
exports.updateStudy = updateStudy;
|
package/dist/index.js
CHANGED
|
@@ -1 +1,294 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
|
|
3
|
+
//#region src/models/FormTypeEnum.ts
|
|
4
|
+
let FormTypeEnum = /* @__PURE__ */ function(FormTypeEnum$1) {
|
|
5
|
+
FormTypeEnum$1[FormTypeEnum$1["NewLine"] = 0] = "NewLine";
|
|
6
|
+
FormTypeEnum$1[FormTypeEnum$1["Text"] = 1] = "Text";
|
|
7
|
+
FormTypeEnum$1[FormTypeEnum$1["BoldText"] = 2] = "BoldText";
|
|
8
|
+
FormTypeEnum$1[FormTypeEnum$1["CheckBox"] = 3] = "CheckBox";
|
|
9
|
+
FormTypeEnum$1[FormTypeEnum$1["DropDownList"] = 4] = "DropDownList";
|
|
10
|
+
FormTypeEnum$1[FormTypeEnum$1["InputText"] = 5] = "InputText";
|
|
11
|
+
FormTypeEnum$1[FormTypeEnum$1["ConditionAndOr"] = 6] = "ConditionAndOr";
|
|
12
|
+
FormTypeEnum$1[FormTypeEnum$1["Function"] = 7] = "Function";
|
|
13
|
+
FormTypeEnum$1[FormTypeEnum$1["Condition"] = 8] = "Condition";
|
|
14
|
+
FormTypeEnum$1[FormTypeEnum$1["Button"] = 9] = "Button";
|
|
15
|
+
FormTypeEnum$1[FormTypeEnum$1["Append"] = 10] = "Append";
|
|
16
|
+
FormTypeEnum$1[FormTypeEnum$1["DigitBox"] = 11] = "DigitBox";
|
|
17
|
+
FormTypeEnum$1[FormTypeEnum$1["Merge"] = 12] = "Merge";
|
|
18
|
+
FormTypeEnum$1[FormTypeEnum$1["Listing"] = 13] = "Listing";
|
|
19
|
+
FormTypeEnum$1[FormTypeEnum$1["Bilateral"] = 14] = "Bilateral";
|
|
20
|
+
FormTypeEnum$1[FormTypeEnum$1["Matrix"] = 15] = "Matrix";
|
|
21
|
+
FormTypeEnum$1[FormTypeEnum$1["RememberedText"] = 17] = "RememberedText";
|
|
22
|
+
FormTypeEnum$1[FormTypeEnum$1["InputTable"] = 18] = "InputTable";
|
|
23
|
+
FormTypeEnum$1[FormTypeEnum$1["AppendDiagnose"] = 19] = "AppendDiagnose";
|
|
24
|
+
FormTypeEnum$1[FormTypeEnum$1["MoveByExtParams"] = 20] = "MoveByExtParams";
|
|
25
|
+
return FormTypeEnum$1;
|
|
26
|
+
}({});
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/services/ExaminationDataHelpers.ts
|
|
30
|
+
var ExaminationDataHelpers = class {
|
|
31
|
+
constructor() {}
|
|
32
|
+
/**
|
|
33
|
+
* Convert DB items into hbs object. Used in FindingGenerator.handlebars
|
|
34
|
+
* @param items ExaminationData entries
|
|
35
|
+
* @returns entry array for hbs
|
|
36
|
+
*/
|
|
37
|
+
ConvertExaminationDataToGeneratorRows(items) {
|
|
38
|
+
const rows = [];
|
|
39
|
+
let i = 0;
|
|
40
|
+
let rowIndexRef = 0;
|
|
41
|
+
let row = { subRows: [] };
|
|
42
|
+
let subRows = [];
|
|
43
|
+
let columns = [];
|
|
44
|
+
do {
|
|
45
|
+
do {
|
|
46
|
+
do {
|
|
47
|
+
if (items[i]?.formType == FormTypeEnum.NewLine) break;
|
|
48
|
+
if (items[i]) switch (items[i].formType) {
|
|
49
|
+
case FormTypeEnum.DropDownList: {
|
|
50
|
+
const elementColumn = this.CreateColumnFromExaminationData(items[i]);
|
|
51
|
+
elementColumn.elementIndex = i;
|
|
52
|
+
const elementSelectOptions = [];
|
|
53
|
+
let optionIndex = 1;
|
|
54
|
+
do {
|
|
55
|
+
const elementSelectOption = this.CreateColumnFromExaminationData(items[i]);
|
|
56
|
+
elementSelectOption.elementIndex = i;
|
|
57
|
+
const _value = items[i]?.formValue?.trim();
|
|
58
|
+
if (optionIndex === 1 && _value && !_value.startsWith("-") && !_value.endsWith("-")) elementColumn.preselected = true;
|
|
59
|
+
elementSelectOptions.push(elementSelectOption);
|
|
60
|
+
i++;
|
|
61
|
+
optionIndex++;
|
|
62
|
+
} while (items[i]?.formType == FormTypeEnum.DropDownList && i < items.length);
|
|
63
|
+
elementColumn.elementSelectOptions = elementSelectOptions;
|
|
64
|
+
columns.push(elementColumn);
|
|
65
|
+
i--;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case FormTypeEnum.Text:
|
|
69
|
+
case FormTypeEnum.Append:
|
|
70
|
+
if (items[i]?.formValue) {
|
|
71
|
+
const column = this.CreateColumnFromExaminationData(items[i]);
|
|
72
|
+
column.elementIndex = i;
|
|
73
|
+
columns.push(column);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case FormTypeEnum.InputText: {
|
|
77
|
+
const elementColumn = this.CreateColumnFromExaminationData(items[i]);
|
|
78
|
+
elementColumn.elementIndex = i;
|
|
79
|
+
elementColumn.isDistance = this.IsDistanceDefinition(items[i + 1]?.formValue ?? "");
|
|
80
|
+
columns.push(elementColumn);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case FormTypeEnum.BoldText:
|
|
84
|
+
case FormTypeEnum.CheckBox:
|
|
85
|
+
case FormTypeEnum.Button:
|
|
86
|
+
case FormTypeEnum.DigitBox:
|
|
87
|
+
case FormTypeEnum.RememberedText:
|
|
88
|
+
case FormTypeEnum.InputTable:
|
|
89
|
+
case FormTypeEnum.MoveByExtParams: {
|
|
90
|
+
const column = this.CreateColumnFromExaminationData(items[i]);
|
|
91
|
+
column.elementIndex = i;
|
|
92
|
+
columns.push(column);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
default: break;
|
|
96
|
+
}
|
|
97
|
+
i++;
|
|
98
|
+
} while (i < items.length);
|
|
99
|
+
if (columns.length > 0) {
|
|
100
|
+
const subRow = {
|
|
101
|
+
columns,
|
|
102
|
+
rowIndexRef
|
|
103
|
+
};
|
|
104
|
+
subRows.push(subRow);
|
|
105
|
+
}
|
|
106
|
+
columns = [];
|
|
107
|
+
rowIndexRef++;
|
|
108
|
+
if (!row.showHideElementId || !items[i]?.formValue || row.showHideElementId != items[i]?.formValue) break;
|
|
109
|
+
i++;
|
|
110
|
+
} while (i < items.length);
|
|
111
|
+
if (subRows.length > 0) {
|
|
112
|
+
row.subRows = subRows;
|
|
113
|
+
rows.push(row);
|
|
114
|
+
}
|
|
115
|
+
subRows = [];
|
|
116
|
+
row = {};
|
|
117
|
+
if (items[i]?.formType == FormTypeEnum.NewLine && items[i]?.formValue) row.showHideElementId = items[i].formValue ?? "";
|
|
118
|
+
else row.showHideElementId = "";
|
|
119
|
+
if (items[i]?.formType == FormTypeEnum.NewLine && items[i]?.conclusion && items[i]?.conclusion == "hr") row.hrBeforeRow = true;
|
|
120
|
+
else row.hrBeforeRow = false;
|
|
121
|
+
i++;
|
|
122
|
+
} while (i < items.length);
|
|
123
|
+
return rows;
|
|
124
|
+
}
|
|
125
|
+
CreateColumn(formType, formValue, finding, conclusion, guid, radLexId, extParam) {
|
|
126
|
+
return {
|
|
127
|
+
formTypeId: formType,
|
|
128
|
+
formValue,
|
|
129
|
+
finding,
|
|
130
|
+
conclusion,
|
|
131
|
+
guid: guid ?? v4(),
|
|
132
|
+
radLexId,
|
|
133
|
+
extParam
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
CreateColumnFromExaminationData(item) {
|
|
137
|
+
return this.CreateColumn(item.formType, item.formValue, item.finding, item.conclusion, item.guid, item.radLexId, item.extParam);
|
|
138
|
+
}
|
|
139
|
+
IsDistanceDefinition(originFormValue) {
|
|
140
|
+
if (originFormValue) return originFormValue.includes("mm") || originFormValue.trim() === "x";
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/index.ts
|
|
147
|
+
const GENERIO_ORIGIN = "https://gener.io";
|
|
148
|
+
async function login(model, origin) {
|
|
149
|
+
if ((await fetch((origin ?? GENERIO_ORIGIN) + "/api/cookiesAuth/login", {
|
|
150
|
+
method: "POST",
|
|
151
|
+
credentials: "include",
|
|
152
|
+
headers: { "Content-Type": "application/json" },
|
|
153
|
+
body: JSON.stringify(model)
|
|
154
|
+
})).ok) return { isSuccess: true };
|
|
155
|
+
return { isSuccess: false };
|
|
156
|
+
}
|
|
157
|
+
async function logout(origin) {
|
|
158
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/cookiesAuth/logout", {
|
|
159
|
+
method: "POST",
|
|
160
|
+
credentials: "include",
|
|
161
|
+
headers: { "Content-Type": "application/json" }
|
|
162
|
+
});
|
|
163
|
+
return response.ok || response.status === 401 || response.status === 403 ? { isSuccess: true } : { isSuccess: false };
|
|
164
|
+
}
|
|
165
|
+
async function recognizeExamination(model, origin) {
|
|
166
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/generioApp/recognizeExaminationCookiesAuth";
|
|
167
|
+
const response = await fetch(url, {
|
|
168
|
+
method: "POST",
|
|
169
|
+
credentials: "include",
|
|
170
|
+
body: JSON.stringify(model),
|
|
171
|
+
headers: { "Content-Type": "application/json" }
|
|
172
|
+
});
|
|
173
|
+
return response.ok ? response.json() : { isSuccess: false };
|
|
174
|
+
}
|
|
175
|
+
async function loadFormData(examinationId, studyInstanceUId, origin) {
|
|
176
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/GenerioApp/loadFormData", {
|
|
177
|
+
method: "POST",
|
|
178
|
+
credentials: "include",
|
|
179
|
+
headers: { "Content-Type": "application/json" },
|
|
180
|
+
body: JSON.stringify({
|
|
181
|
+
examinationId,
|
|
182
|
+
studyInstanceUId
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
return response.ok ? response.json() : Promise.reject(/* @__PURE__ */ new Error("Network issue"));
|
|
186
|
+
}
|
|
187
|
+
async function loadStudy(examinationId, studyInstanceUId, origin) {
|
|
188
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/GenerioApp/loadStudy", {
|
|
189
|
+
method: "POST",
|
|
190
|
+
credentials: "include",
|
|
191
|
+
headers: { "Content-Type": "application/json" },
|
|
192
|
+
body: JSON.stringify({
|
|
193
|
+
examinationId,
|
|
194
|
+
studyInstanceUId
|
|
195
|
+
})
|
|
196
|
+
});
|
|
197
|
+
return response.ok ? response.json() : Promise.reject(/* @__PURE__ */ new Error("Network issue"));
|
|
198
|
+
}
|
|
199
|
+
async function updateStudy(model, origin) {
|
|
200
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/GenerioApp/updateStudy", {
|
|
201
|
+
method: "POST",
|
|
202
|
+
credentials: "include",
|
|
203
|
+
headers: { "Content-Type": "application/json" },
|
|
204
|
+
body: JSON.stringify(model)
|
|
205
|
+
});
|
|
206
|
+
return response.ok ? response.json() : Promise.reject(/* @__PURE__ */ new Error("Network issue"));
|
|
207
|
+
}
|
|
208
|
+
async function getExtParamValueByStudyInstanceUId(model, origin) {
|
|
209
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/datasetsCookiesAuth/getExtParamValueByStudyInstanceUId";
|
|
210
|
+
const response = await fetch(url, {
|
|
211
|
+
method: "POST",
|
|
212
|
+
credentials: "include",
|
|
213
|
+
body: JSON.stringify(model),
|
|
214
|
+
headers: { "Content-Type": "application/json" }
|
|
215
|
+
});
|
|
216
|
+
return response.ok ? response.json() : {};
|
|
217
|
+
}
|
|
218
|
+
async function getAnnotationPlacements(model, origin) {
|
|
219
|
+
const response = await fetch((origin ?? GENERIO_ORIGIN) + "/api/annotationPlacements/getAnnotationPlacements", {
|
|
220
|
+
method: "POST",
|
|
221
|
+
credentials: "include",
|
|
222
|
+
body: JSON.stringify(model),
|
|
223
|
+
headers: { "Content-Type": "application/json" }
|
|
224
|
+
});
|
|
225
|
+
return response.ok ? response.json() : {
|
|
226
|
+
isSuccess: false,
|
|
227
|
+
errorMessage: response.statusText,
|
|
228
|
+
annotationPlacements: []
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
async function setExtParams(model, origin) {
|
|
232
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/generioApp/setExtParamsCookiesAuth";
|
|
233
|
+
const response = await fetch(url, {
|
|
234
|
+
method: "POST",
|
|
235
|
+
credentials: "include",
|
|
236
|
+
body: JSON.stringify(model),
|
|
237
|
+
headers: { "Content-Type": "application/json" }
|
|
238
|
+
});
|
|
239
|
+
return response.ok ? response.json() : {
|
|
240
|
+
isSuccess: false,
|
|
241
|
+
errorMessage: "Network issue"
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function setExtParamsPostMessage(window$1, model, origin) {
|
|
245
|
+
window$1.postMessage({
|
|
246
|
+
action: "setExtParams",
|
|
247
|
+
model
|
|
248
|
+
}, { targetOrigin: origin ?? GENERIO_ORIGIN });
|
|
249
|
+
}
|
|
250
|
+
async function sendMeasurements(model, origin) {
|
|
251
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/generioApp/sendMeasurementsCookiesAuth";
|
|
252
|
+
const response = await fetch(url, {
|
|
253
|
+
method: "POST",
|
|
254
|
+
credentials: "include",
|
|
255
|
+
body: JSON.stringify(model),
|
|
256
|
+
headers: { "Content-Type": "application/json" }
|
|
257
|
+
});
|
|
258
|
+
return response.ok ? response.json() : {
|
|
259
|
+
isSuccess: false,
|
|
260
|
+
errorMessage: "Network issue"
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
async function getExaminationMessage(model, origin) {
|
|
264
|
+
const url = (origin ?? GENERIO_ORIGIN) + "/api/generioApp/getExaminationMessageCookiesAuth";
|
|
265
|
+
const response = await fetch(url, {
|
|
266
|
+
method: "POST",
|
|
267
|
+
credentials: "include",
|
|
268
|
+
body: JSON.stringify(model),
|
|
269
|
+
headers: { "Content-Type": "application/json" }
|
|
270
|
+
});
|
|
271
|
+
return response.ok ? response.json() : {
|
|
272
|
+
isSuccess: false,
|
|
273
|
+
errorMessage: "Network issue"
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function setupPostMessageListeners(generioReadyHandler, origin) {
|
|
277
|
+
window.addEventListener("message", (event) => {
|
|
278
|
+
if ((origin ?? GENERIO_ORIGIN) != event.origin) return;
|
|
279
|
+
console.info(`PostMessageListener: Received message from origin: ${event.origin}`, event.data);
|
|
280
|
+
if (event.data.action == "generioReady") {
|
|
281
|
+
if (generioReadyHandler) generioReadyHandler(event.data.model, event);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
}, false);
|
|
285
|
+
}
|
|
286
|
+
function getGenerioRecognizeExaminationUrl(studyInstanceUId, modality, studyDescription, bodyPartExamined, origin) {
|
|
287
|
+
let url = `${origin ?? GENERIO_ORIGIN}/generator/recognizeExamination?studyInstanceUId=${studyInstanceUId}&modality=${modality}`;
|
|
288
|
+
if (studyDescription) url = url + `&studyDescription=${studyDescription}`;
|
|
289
|
+
if (bodyPartExamined) url = url + `&bodyPartExamined=${bodyPartExamined}`;
|
|
290
|
+
return url;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
//#endregion
|
|
294
|
+
export { ExaminationDataHelpers, FormTypeEnum, GENERIO_ORIGIN, getAnnotationPlacements, getExaminationMessage, getExtParamValueByStudyInstanceUId, getGenerioRecognizeExaminationUrl, loadFormData, loadStudy, login, logout, recognizeExamination, sendMeasurements, setExtParams, setExtParamsPostMessage, setupPostMessageListeners, updateStudy };
|