fluent-cerner-js 1.0.0 → 1.1.0-1
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/dist/index.cjs +1091 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +796 -0
- package/dist/index.d.ts +796 -226
- package/dist/index.js +1050 -5
- package/dist/index.js.map +1 -0
- package/package.json +37 -37
- package/src/createNewDocumentAsync.spec.ts +1 -1
- package/src/getValidEncountersAsync.spec.ts +1 -1
- package/src/index.ts +1 -1
- package/src/manageAppointmentAsync.spec.ts +1 -1
- package/src/openApplicationAsync.spec.ts +1 -1
- package/src/submitOrdersAsync.spec.ts +1 -1
- package/src/submitOrdersAsync.ts +5 -2
- package/src/submitPowerOrdersAsync.spec.ts +1 -1
- package/dist/addAddendumToDocumentAsync.d.ts +0 -13
- package/dist/createNewDocumentAsync.d.ts +0 -17
- package/dist/fluent-cerner-js.cjs.development.js +0 -2027
- package/dist/fluent-cerner-js.cjs.development.js.map +0 -1
- package/dist/fluent-cerner-js.cjs.production.min.js +0 -2
- package/dist/fluent-cerner-js.cjs.production.min.js.map +0 -1
- package/dist/fluent-cerner-js.esm.js +0 -2003
- package/dist/fluent-cerner-js.esm.js.map +0 -1
- package/dist/getValidEncountersAsync.d.ts +0 -10
- package/dist/launchClinicalNoteAsync.d.ts +0 -49
- package/dist/launchDischargeProcessAsync.d.ts +0 -6
- package/dist/launchPatientEducationAsync.d.ts +0 -9
- package/dist/launchPowerFormAsync.d.ts +0 -18
- package/dist/launchPowerNoteAsync.d.ts +0 -16
- package/dist/manageAppointmentAsync.d.ts +0 -20
- package/dist/openApplicationAsync.d.ts +0 -37
- package/dist/openOrganizerTabAsync.d.ts +0 -13
- package/dist/openPatientTabAsync.d.ts +0 -22
- package/dist/openWebsiteByUrlAsync.d.ts +0 -12
- package/dist/submitOrdersAsync.d.ts +0 -261
- package/dist/submitPowerOrdersAsync.d.ts +0 -88
- package/dist/utils/addNewOrdersToScratchPadAsync.d.ts +0 -15
- package/dist/utils/addPowerPlanWithDetailsAsync.d.ts +0 -14
- package/dist/utils/calculateMOEWBitmask.d.ts +0 -13
- package/dist/utils/createMOEWAsync.d.ts +0 -14
- package/dist/utils/createOrderString.d.ts +0 -17
- package/dist/utils/destroyMOEWAsync.d.ts +0 -10
- package/dist/utils/displayMOEWAsync.d.ts +0 -13
- package/dist/utils/getOrdersPlacedAsync.d.ts +0 -192
- package/dist/utils/index.d.ts +0 -12
- package/dist/utils/signOrdersAsync.d.ts +0 -12
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1091 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
CclCallParam: () => import_easy_ccl_request.CclCallParam,
|
|
24
|
+
CclRequestResponse: () => import_easy_ccl_request.CclRequestResponse,
|
|
25
|
+
XmlCclReadyState: () => import_easy_ccl_request.XmlCclReadyState,
|
|
26
|
+
XmlCclResult: () => import_easy_ccl_request.XmlCclResult,
|
|
27
|
+
addAddendumToDocumentAsync: () => addAddendumToDocumentAsync,
|
|
28
|
+
createNewDocumentAsync: () => createNewDocumentAsync,
|
|
29
|
+
getValidEncountersAsync: () => getValidEncountersAsync,
|
|
30
|
+
launchClinicalNoteAsync: () => launchClinicalNoteAsync,
|
|
31
|
+
launchDischargeProcessAsync: () => launchDischargeProcessAsync,
|
|
32
|
+
launchPatientEducationAsync: () => launchPatientEducationAsync,
|
|
33
|
+
launchPowerFormAsync: () => launchPowerFormAsync,
|
|
34
|
+
launchPowerNoteAsync: () => launchPowerNoteAsync,
|
|
35
|
+
makeCclRequestAsync: () => import_easy_ccl_request.makeCclRequestAsync,
|
|
36
|
+
manageAppointmentAsync: () => manageAppointmentAsync,
|
|
37
|
+
openApplicationAsync: () => openApplicationAsync,
|
|
38
|
+
openOrganizerTabAsync: () => openOrganizerTabAsync,
|
|
39
|
+
openPatientTabAsync: () => openPatientTabAsync,
|
|
40
|
+
openWebsiteByUrlAsync: () => openWebsiteByUrlAsync,
|
|
41
|
+
submitOrdersAsync: () => submitOrdersAsync,
|
|
42
|
+
submitPowerOrdersAsync: () => submitPowerOrdersAsync
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(index_exports);
|
|
45
|
+
var import_easy_ccl_request = require("easy-ccl-request");
|
|
46
|
+
|
|
47
|
+
// src/utils/index.ts
|
|
48
|
+
function outsideOfPowerChartError(e) {
|
|
49
|
+
return e instanceof TypeError && /(MPAGES_EVENT|XMLCclRequest|APPLINK|DiscernObjectFactory) is not a function/i.test(
|
|
50
|
+
e.message
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
var warnAttemptedOrdersOutsideOfPowerChart = (eventString) => {
|
|
54
|
+
console.warn(`window.MPAGES_EVENT('ORDERS', '${eventString}')`);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/addAddendumToDocumentAsync.ts
|
|
58
|
+
async function addAddendumToDocumentAsync(patientId, encounterId, eventId) {
|
|
59
|
+
let retVal = {
|
|
60
|
+
inPowerChart: true,
|
|
61
|
+
success: false
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
const dcof = await window.external.DiscernObjectFactory("DYNDOC");
|
|
65
|
+
let response = null;
|
|
66
|
+
response = await dcof.ModifyExistingDocumentByEventId(
|
|
67
|
+
patientId,
|
|
68
|
+
encounterId,
|
|
69
|
+
eventId
|
|
70
|
+
);
|
|
71
|
+
retVal.success = Boolean(response);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
if (outsideOfPowerChartError(e)) {
|
|
74
|
+
retVal.inPowerChart = false;
|
|
75
|
+
return retVal;
|
|
76
|
+
} else {
|
|
77
|
+
throw e;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return retVal;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/createNewDocumentAsync.ts
|
|
84
|
+
async function createNewDocumentAsync(method, patientId, encounterId, id, noteTypeCd) {
|
|
85
|
+
let retVal = {
|
|
86
|
+
inPowerChart: true,
|
|
87
|
+
success: false
|
|
88
|
+
};
|
|
89
|
+
try {
|
|
90
|
+
const dcof = await window.external.DiscernObjectFactory("DYNDOC");
|
|
91
|
+
let response = null;
|
|
92
|
+
if (method !== "by workflow" && method !== "by reference template") {
|
|
93
|
+
throw new Error(`createNewDocumentAsync: ${method} is not supported`);
|
|
94
|
+
}
|
|
95
|
+
if (method === "by workflow" && noteTypeCd) {
|
|
96
|
+
console.warn(
|
|
97
|
+
"The noteTypeCd is not used when creating a document by workflow."
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
if (method === "by workflow") {
|
|
101
|
+
response = await dcof.OpenDynDocByWorkFlowId(patientId, encounterId, id);
|
|
102
|
+
}
|
|
103
|
+
if (method === "by reference template" && !noteTypeCd) {
|
|
104
|
+
response = await dcof.OpenNewDocumentByReferenceTemplateId(
|
|
105
|
+
patientId,
|
|
106
|
+
encounterId,
|
|
107
|
+
id
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
if (method === "by reference template" && noteTypeCd) {
|
|
111
|
+
response = await dcof.OpenNewDocumentByReferenceTemplateIdAndNoteType(
|
|
112
|
+
patientId,
|
|
113
|
+
encounterId,
|
|
114
|
+
id,
|
|
115
|
+
noteTypeCd
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
retVal.success = Boolean(response);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
if (outsideOfPowerChartError(e)) {
|
|
121
|
+
retVal.inPowerChart = false;
|
|
122
|
+
} else {
|
|
123
|
+
throw e;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return retVal;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// src/getValidEncountersAsync.ts
|
|
130
|
+
async function getValidEncountersAsync(personId) {
|
|
131
|
+
const retData = {
|
|
132
|
+
inPowerChart: true,
|
|
133
|
+
encounterIds: []
|
|
134
|
+
};
|
|
135
|
+
try {
|
|
136
|
+
const dcof = await window.external.DiscernObjectFactory("PVCONTXTMPAGE");
|
|
137
|
+
const response = await dcof.GetValidEncounters(personId);
|
|
138
|
+
const eidStr = response.trim();
|
|
139
|
+
if (eidStr === "") return retData;
|
|
140
|
+
eidStr.split(",").forEach((e) => {
|
|
141
|
+
const eid = parseFloat(e);
|
|
142
|
+
if (isNaN(eid)) {
|
|
143
|
+
console.warn(
|
|
144
|
+
`getValidEncountersAsync: encounter ID ${e} could not be parsed to a number.`
|
|
145
|
+
);
|
|
146
|
+
} else {
|
|
147
|
+
retData.encounterIds.push(eid);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
} catch (e) {
|
|
151
|
+
if (outsideOfPowerChartError(e)) {
|
|
152
|
+
retData.inPowerChart = false;
|
|
153
|
+
} else {
|
|
154
|
+
throw e;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return retData;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/launchClinicalNoteAsync.ts
|
|
161
|
+
var launchClinicalNoteAsync = async (patientId, encounterId, eventIds, opts) => {
|
|
162
|
+
const { viewOptionFlags, inheritanceProps, windowTitle } = opts || {};
|
|
163
|
+
const { viewName, viewSeq, compName, compSeq } = inheritanceProps || {};
|
|
164
|
+
let inPowerChart = true;
|
|
165
|
+
const params = [`${patientId}`, `${encounterId}`];
|
|
166
|
+
const _viewOptsFlags = !viewOptionFlags || viewOptionFlags.length === 0 ? ["view-only"] : viewOptionFlags;
|
|
167
|
+
params.push(`[${eventIds.join("|")}]`);
|
|
168
|
+
params.push(
|
|
169
|
+
`${windowTitle || `Clinical Note for patient with PID ${patientId} on encounter with EID ${encounterId}`}`
|
|
170
|
+
);
|
|
171
|
+
params.push(`${calculateViewOptionFlag(_viewOptsFlags)}`);
|
|
172
|
+
params.push(`${viewName || ""}`);
|
|
173
|
+
params.push(`${viewSeq || ""}`);
|
|
174
|
+
params.push(`${compName || ""}`);
|
|
175
|
+
params.push(`${compSeq || ""}`);
|
|
176
|
+
const eventString = `${params.join("|")}`;
|
|
177
|
+
try {
|
|
178
|
+
await window.external.MPAGES_EVENT("CLINICALNOTE", eventString);
|
|
179
|
+
} catch (e) {
|
|
180
|
+
if (outsideOfPowerChartError(e)) {
|
|
181
|
+
inPowerChart = false;
|
|
182
|
+
console.warn(`window.MPAGES_EVENT('CLINICALNOTE', '${eventString}')`);
|
|
183
|
+
} else {
|
|
184
|
+
throw e;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return { inPowerChart, eventString };
|
|
188
|
+
};
|
|
189
|
+
function calculateViewOptionFlag(viewOptionFlags) {
|
|
190
|
+
let total = 0;
|
|
191
|
+
viewOptionFlags.forEach((flag) => {
|
|
192
|
+
if (flag === "menu") total += 1;
|
|
193
|
+
if (flag === "buttons") total += 2;
|
|
194
|
+
if (flag === "toolbar") total += 4;
|
|
195
|
+
if (flag === "calculator") total += 8;
|
|
196
|
+
if (flag === "view-only") total += 16;
|
|
197
|
+
});
|
|
198
|
+
return total;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/launchDischargeProcessAsync.ts
|
|
202
|
+
async function launchDischargeProcessAsync(patientId, encounterId, providerId) {
|
|
203
|
+
const retData = {
|
|
204
|
+
inPowerChart: true
|
|
205
|
+
};
|
|
206
|
+
try {
|
|
207
|
+
const dcof = await window.external.DiscernObjectFactory("DISCHARGEPROCESS");
|
|
208
|
+
dcof.person_id = patientId;
|
|
209
|
+
dcof.encounter_id = encounterId;
|
|
210
|
+
dcof.user_id = providerId;
|
|
211
|
+
dcof.LaunchDischargeDialog();
|
|
212
|
+
} catch (e) {
|
|
213
|
+
if (outsideOfPowerChartError(e)) {
|
|
214
|
+
retData.inPowerChart = false;
|
|
215
|
+
} else {
|
|
216
|
+
throw e;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return retData;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/launchPatientEducationAsync.ts
|
|
223
|
+
async function launchPatientEducationAsync(patientId, encounterId, targetTab) {
|
|
224
|
+
const retData = {
|
|
225
|
+
inPowerChart: true
|
|
226
|
+
};
|
|
227
|
+
try {
|
|
228
|
+
const dcof = await window.external.DiscernObjectFactory("PATIENTEDUCATION");
|
|
229
|
+
await dcof.SetPatient(patientId, encounterId);
|
|
230
|
+
await dcof.SetDefaultTab(targetTab === "instruction" ? 0 : 1);
|
|
231
|
+
await dcof.DoModal();
|
|
232
|
+
} catch (e) {
|
|
233
|
+
if (outsideOfPowerChartError(e)) {
|
|
234
|
+
return {
|
|
235
|
+
inPowerChart: false
|
|
236
|
+
};
|
|
237
|
+
} else {
|
|
238
|
+
throw e;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return retData;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/launchPowerFormAsync.ts
|
|
245
|
+
var launchPowerFormAsync = async (target, patientId, encounterId, targetId) => {
|
|
246
|
+
const requiresTargetId = target === "new form" || target === "view form" || target === "modify form";
|
|
247
|
+
if (requiresTargetId && !targetId) {
|
|
248
|
+
throw new Error(
|
|
249
|
+
"'targetId' is required for all targets except 'new form search'."
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
const params = [`${patientId}`, `${encounterId}`];
|
|
253
|
+
switch (target) {
|
|
254
|
+
case "new form":
|
|
255
|
+
params.push(`${targetId}`);
|
|
256
|
+
params.push("0");
|
|
257
|
+
break;
|
|
258
|
+
case "view form":
|
|
259
|
+
case "modify form":
|
|
260
|
+
params.push("0");
|
|
261
|
+
params.push(`${targetId}`);
|
|
262
|
+
break;
|
|
263
|
+
case "new form search":
|
|
264
|
+
params.push("0");
|
|
265
|
+
params.push("0");
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
params.push(target === "view form" ? "1" : "0");
|
|
269
|
+
const retData = {
|
|
270
|
+
eventString: `${params.join("|")}`,
|
|
271
|
+
inPowerChart: true
|
|
272
|
+
};
|
|
273
|
+
try {
|
|
274
|
+
await window.external.MPAGES_EVENT("POWERFORM", retData.eventString);
|
|
275
|
+
} catch (e) {
|
|
276
|
+
if (outsideOfPowerChartError(e)) {
|
|
277
|
+
retData.inPowerChart = false;
|
|
278
|
+
console.warn(
|
|
279
|
+
`window.MPAGES_EVENT('POWERFORM', '${retData.eventString}')`
|
|
280
|
+
);
|
|
281
|
+
} else {
|
|
282
|
+
throw e;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return retData;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// src/launchPowerNoteAsync.ts
|
|
289
|
+
var launchPowerNoteAsync = async (target, patientId, encounterId, targetId) => {
|
|
290
|
+
if (target === "new" && typeof targetId !== "string") {
|
|
291
|
+
throw new Error(
|
|
292
|
+
"targetId (for CKI) must be a string when launching a new PowerNote."
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
if (target === "existing" && typeof targetId !== "number") {
|
|
296
|
+
throw new Error(
|
|
297
|
+
"targetId must be a number when loading an existing PowerNote."
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
const params = [
|
|
301
|
+
`${patientId}`,
|
|
302
|
+
`${encounterId}`,
|
|
303
|
+
`${target === "new" ? targetId : ""}`,
|
|
304
|
+
`${target === "existing" ? targetId : 0}`
|
|
305
|
+
];
|
|
306
|
+
const eventString = `${params.join("|")}`;
|
|
307
|
+
let inPowerChart = true;
|
|
308
|
+
try {
|
|
309
|
+
await window.external.MPAGES_EVENT("POWERNOTE", eventString);
|
|
310
|
+
} catch (e) {
|
|
311
|
+
if (outsideOfPowerChartError(e)) {
|
|
312
|
+
inPowerChart = false;
|
|
313
|
+
console.warn(`window.MPAGES_EVENT('POWERNOTE', '${eventString}')`);
|
|
314
|
+
} else {
|
|
315
|
+
throw e;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return { eventString, inPowerChart };
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/manageAppointmentAsync.ts
|
|
322
|
+
async function manageAppointmentAsync(action, eventId) {
|
|
323
|
+
let actionSuccess = 0;
|
|
324
|
+
let inPowerChart = true;
|
|
325
|
+
try {
|
|
326
|
+
const dcof = await window.external.DiscernObjectFactory(
|
|
327
|
+
"PEXSCHEDULINGACTIONS"
|
|
328
|
+
);
|
|
329
|
+
switch (action) {
|
|
330
|
+
case "check in":
|
|
331
|
+
actionSuccess = await dcof.CheckInAppointment(eventId);
|
|
332
|
+
break;
|
|
333
|
+
case "check out":
|
|
334
|
+
actionSuccess = await dcof.CheckOutAppointment(eventId);
|
|
335
|
+
break;
|
|
336
|
+
case "cancel":
|
|
337
|
+
actionSuccess = await dcof.CancelAppointment(eventId);
|
|
338
|
+
break;
|
|
339
|
+
case "no show":
|
|
340
|
+
actionSuccess = await dcof.NoShowAppointment(eventId);
|
|
341
|
+
break;
|
|
342
|
+
case "view appt dialog":
|
|
343
|
+
actionSuccess = await dcof.ShowView(eventId);
|
|
344
|
+
break;
|
|
345
|
+
case "view appt history":
|
|
346
|
+
actionSuccess = await dcof.ShowHistoryView(eventId);
|
|
347
|
+
break;
|
|
348
|
+
default:
|
|
349
|
+
throw new Error("Invalid appointment action");
|
|
350
|
+
}
|
|
351
|
+
} catch (e) {
|
|
352
|
+
if (outsideOfPowerChartError(e)) {
|
|
353
|
+
inPowerChart = false;
|
|
354
|
+
} else {
|
|
355
|
+
throw e;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
success: actionSuccess === 1,
|
|
360
|
+
inPowerChart
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/openApplicationAsync.ts
|
|
365
|
+
async function openApplicationAsync(mode, target, args) {
|
|
366
|
+
const retVal = {
|
|
367
|
+
inPowerChart: true,
|
|
368
|
+
eventString: "",
|
|
369
|
+
badInput: false
|
|
370
|
+
};
|
|
371
|
+
if (mode === "by solution name" && !args) {
|
|
372
|
+
throw new Error(
|
|
373
|
+
"openApplicationAsync: 'by solution name' mode requires arguments"
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
if (mode === "by application object" && !args) {
|
|
377
|
+
throw new Error(
|
|
378
|
+
"openApplicationAsync: 'by application object' mode requires arguments"
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
const argString = generateOpenApplicationArgumentString(args || []);
|
|
382
|
+
const modeValue = modeMap.get(mode);
|
|
383
|
+
if (modeValue === void 0) {
|
|
384
|
+
throw new Error("openApplicationAsync: invalid mode");
|
|
385
|
+
}
|
|
386
|
+
retVal.eventString = argString;
|
|
387
|
+
try {
|
|
388
|
+
const response = await window.APPLINK(modeValue, target, argString);
|
|
389
|
+
retVal.badInput = response === null ? true : false;
|
|
390
|
+
} catch (e) {
|
|
391
|
+
if (outsideOfPowerChartError(e)) {
|
|
392
|
+
retVal.inPowerChart = false;
|
|
393
|
+
} else {
|
|
394
|
+
throw e;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return retVal;
|
|
398
|
+
}
|
|
399
|
+
function generateOpenApplicationArgumentString(args) {
|
|
400
|
+
return args.map(({ argument: arg, value, quickOpen: qo }) => {
|
|
401
|
+
const isOrgLevel = /organizertab/i.test(arg);
|
|
402
|
+
const isTab = /firsttab/i.test(arg) || /organizertab/i.test(arg);
|
|
403
|
+
const quickOpen = qo;
|
|
404
|
+
const quickOpenStr = quickOpen && isTab && !isOrgLevel ? "+" : "";
|
|
405
|
+
const surroundStr = isTab ? "^" : "";
|
|
406
|
+
return `/${arg}=${surroundStr}${value}${quickOpenStr}${surroundStr}`;
|
|
407
|
+
}).join(" ").toUpperCase();
|
|
408
|
+
}
|
|
409
|
+
var modeMap = /* @__PURE__ */ new Map();
|
|
410
|
+
modeMap.set("by solution name", 0);
|
|
411
|
+
modeMap.set("by application object", 1);
|
|
412
|
+
modeMap.set("by file", 100);
|
|
413
|
+
modeMap.set("by url", 100);
|
|
414
|
+
modeMap.set("by executable", 100);
|
|
415
|
+
|
|
416
|
+
// src/openOrganizerTabAsync.ts
|
|
417
|
+
async function openOrganizerTabAsync(tab) {
|
|
418
|
+
const args = [
|
|
419
|
+
{
|
|
420
|
+
argument: "ORGANIZERTAB",
|
|
421
|
+
value: tab
|
|
422
|
+
}
|
|
423
|
+
];
|
|
424
|
+
return await openApplicationAsync("by executable", "Powerchart.exe", args);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// src/openPatientTabAsync.ts
|
|
428
|
+
async function openPatientTabAsync(patientId, encounterId, tab, quickOpen) {
|
|
429
|
+
const args = [
|
|
430
|
+
{
|
|
431
|
+
argument: "PERSONID",
|
|
432
|
+
value: patientId
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
argument: "ENCNTRID",
|
|
436
|
+
value: encounterId
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
argument: "FIRSTTAB",
|
|
440
|
+
value: tab,
|
|
441
|
+
quickOpen
|
|
442
|
+
}
|
|
443
|
+
];
|
|
444
|
+
return await openApplicationAsync("by executable", "$APP_APPNAME$", args);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// src/openWebsiteByUrlAsync.ts
|
|
448
|
+
async function openWebsiteByUrlAsync(url) {
|
|
449
|
+
if (!url.toLowerCase().includes("http://") && !url.toLowerCase().includes("https://")) {
|
|
450
|
+
throw new Error(
|
|
451
|
+
"openWebsiteByUrlAsync: URL must include the protocol 'http://' or 'https://'"
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
return await openApplicationAsync("by url", url);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// src/submitOrdersAsync.ts
|
|
458
|
+
var import_fast_xml_parser = require("fast-xml-parser");
|
|
459
|
+
|
|
460
|
+
// src/utils/createOrderString.ts
|
|
461
|
+
var _createOrderString = (action, id, opts) => {
|
|
462
|
+
const { orderSentenceId, nomenclatureIds, origination, interactionCheck } = opts || {};
|
|
463
|
+
let params = [orderActionMap.get(action)];
|
|
464
|
+
const nids = nomenclatureIds || [];
|
|
465
|
+
switch (action) {
|
|
466
|
+
case "launch moew":
|
|
467
|
+
params = params.concat(["0", "0", "0", "0", "0"]);
|
|
468
|
+
break;
|
|
469
|
+
case "new order":
|
|
470
|
+
if (!id)
|
|
471
|
+
throw new Error(
|
|
472
|
+
`id (as synonym ID) is required for the '${action}' action`
|
|
473
|
+
);
|
|
474
|
+
params = params.concat([
|
|
475
|
+
`${id}`,
|
|
476
|
+
`${originationMap.get(origination) || 0}`,
|
|
477
|
+
`${orderSentenceId || 0}`,
|
|
478
|
+
nids.length > 1 ? `[${nids.join("|")}]` : `${nids[0] || 0}`,
|
|
479
|
+
`${interactionMap.get(interactionCheck) || 0}`
|
|
480
|
+
]);
|
|
481
|
+
break;
|
|
482
|
+
default:
|
|
483
|
+
if (!id)
|
|
484
|
+
throw new Error(
|
|
485
|
+
`id (as the existing order ID) is required for the '${action}' action`
|
|
486
|
+
);
|
|
487
|
+
params = params.concat([`${id}`]);
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
return `{${params.join("|")}}`;
|
|
491
|
+
};
|
|
492
|
+
var orderActionMap = (/* @__PURE__ */ new Map()).set("launch moew", "ORDER").set("activate existing", "ACTIVATE").set("cancel-discontinue", "CANCEL DC").set("cancel-reorder", "CANCEL REORD").set("clear actions", "CLEAR").set("convert inpatient", "CONVERT_INPAT").set("convert prescription", "CONVERT_RX").set("modify", "MODIFY").set("new order", "ORDER").set("renew", "RENEW").set("renew prescription", "RENEW_RX").set("copy existing", "REPEAT").set("resume", "RESUME").set("suspend", "SUSPEND");
|
|
493
|
+
var originationMap = (/* @__PURE__ */ new Map()).set("satellite", "5").set("prescription", "1").set("normal", "0");
|
|
494
|
+
var interactionMap = (/* @__PURE__ */ new Map()).set("on sign", "1").set("default", "0");
|
|
495
|
+
var createOrderString = (action, id, opts) => _createOrderString(action, id, opts);
|
|
496
|
+
var LAUNCH_MOEW_ORDER_STRING = _createOrderString("launch moew");
|
|
497
|
+
|
|
498
|
+
// src/submitOrdersAsync.ts
|
|
499
|
+
var launchViewMap = (/* @__PURE__ */ new Map()).set("search", 8).set("profile", 16).set("signature", 32);
|
|
500
|
+
var tabsMap = (/* @__PURE__ */ new Map()).set("orders", { tab: 2, display: 0 }).set("power orders", { tab: 2, display: 127 }).set("medications", { tab: 3, display: 0 }).set("power medications", { tab: 3, display: 127 });
|
|
501
|
+
var submitOrdersAsync = async (patientId, encounterId, orders, opts) => {
|
|
502
|
+
let { targetTab, launchView, signSilently, dryRun } = opts || {};
|
|
503
|
+
if (!targetTab) targetTab = "orders";
|
|
504
|
+
if (!launchView) launchView = "signature";
|
|
505
|
+
const enablePowerPlans = targetTab === "power orders" || targetTab === "power medications";
|
|
506
|
+
const s = orders.map(
|
|
507
|
+
({ action, id, opts: opts2 }) => createOrderString(action, id, opts2)
|
|
508
|
+
);
|
|
509
|
+
let params = [`${patientId}`, `${encounterId}`, s.join("")];
|
|
510
|
+
params.push(enablePowerPlans ? "24" : "0");
|
|
511
|
+
const { tab, display } = tabsMap.get(targetTab) || { tab: 2, display: 127 };
|
|
512
|
+
params.push(`{${tab}|${display}}`);
|
|
513
|
+
params.push(`${launchViewMap.get(launchView) || 32}`);
|
|
514
|
+
params.push(`${signSilently ? "1" : "0"}`);
|
|
515
|
+
const eventString = params.join("|");
|
|
516
|
+
const retVal = {
|
|
517
|
+
eventString,
|
|
518
|
+
inPowerChart: true,
|
|
519
|
+
status: "success",
|
|
520
|
+
response: null,
|
|
521
|
+
ordersPlaced: null
|
|
522
|
+
};
|
|
523
|
+
if (dryRun) {
|
|
524
|
+
retVal.status = "dry run";
|
|
525
|
+
return retVal;
|
|
526
|
+
}
|
|
527
|
+
try {
|
|
528
|
+
const response = await window.external.MPAGES_EVENT(
|
|
529
|
+
"ORDERS",
|
|
530
|
+
eventString
|
|
531
|
+
);
|
|
532
|
+
if (response === null) {
|
|
533
|
+
retVal.status = "failed";
|
|
534
|
+
return retVal;
|
|
535
|
+
}
|
|
536
|
+
if (typeof response !== "string") {
|
|
537
|
+
retVal.status = "invalid data returned";
|
|
538
|
+
return retVal;
|
|
539
|
+
}
|
|
540
|
+
switch (response.trim()) {
|
|
541
|
+
case "":
|
|
542
|
+
retVal.status = "cancelled";
|
|
543
|
+
break;
|
|
544
|
+
default:
|
|
545
|
+
retVal.status = "success";
|
|
546
|
+
const parser = new import_fast_xml_parser.XMLParser();
|
|
547
|
+
try {
|
|
548
|
+
const parsed = parser.parse(response);
|
|
549
|
+
retVal.response = parsed;
|
|
550
|
+
if (!(parsed.Orders.Order instanceof Array)) {
|
|
551
|
+
parsed.Orders.Order = [parsed.Orders.Order];
|
|
552
|
+
}
|
|
553
|
+
retVal.ordersPlaced = parsed.Orders.Order.map((o) => ({
|
|
554
|
+
name: o.OrderedAsMnemonic,
|
|
555
|
+
oid: o.OrderId,
|
|
556
|
+
display: o.ClinDisplayLine
|
|
557
|
+
}));
|
|
558
|
+
} catch {
|
|
559
|
+
retVal.status = "xml parse error";
|
|
560
|
+
}
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
} catch (e) {
|
|
564
|
+
if (outsideOfPowerChartError(e)) {
|
|
565
|
+
retVal.inPowerChart = false;
|
|
566
|
+
retVal.status = "invalid data returned";
|
|
567
|
+
warnAttemptedOrdersOutsideOfPowerChart(eventString);
|
|
568
|
+
} else {
|
|
569
|
+
throw e;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return retVal;
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
// src/utils/calculateMOEWBitmask.ts
|
|
576
|
+
var calculateMOEWBitmask = (targetTab, inputFlags) => {
|
|
577
|
+
let dwCustomizeFlag = 0;
|
|
578
|
+
let dwTabFlag = 0;
|
|
579
|
+
let dwTabDisplayOptionsFlag = 0;
|
|
580
|
+
if (targetTab === "orders tab") {
|
|
581
|
+
dwTabFlag = 2;
|
|
582
|
+
}
|
|
583
|
+
if (targetTab === "medications tab") {
|
|
584
|
+
dwTabFlag = 3;
|
|
585
|
+
}
|
|
586
|
+
const defaultOpts = [
|
|
587
|
+
"show refresh and print buttons",
|
|
588
|
+
"allow power plan doc",
|
|
589
|
+
"allow power plans",
|
|
590
|
+
"show list details",
|
|
591
|
+
"show scratchpad",
|
|
592
|
+
"show order profile",
|
|
593
|
+
"show orders search",
|
|
594
|
+
"show related res",
|
|
595
|
+
"show diag and probs",
|
|
596
|
+
"show nav tree",
|
|
597
|
+
"show demographics",
|
|
598
|
+
"show med rec"
|
|
599
|
+
];
|
|
600
|
+
const userFlags = !inputFlags || inputFlags.length === 0 ? defaultOpts : inputFlags;
|
|
601
|
+
const cernerFlags = [];
|
|
602
|
+
userFlags.forEach((flag) => {
|
|
603
|
+
if (flag === "show demographics") {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (flag === "show med rec") {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
return cernerFlags.push(flag);
|
|
610
|
+
});
|
|
611
|
+
if (!userFlags.includes("show demographics")) {
|
|
612
|
+
cernerFlags.push("hide demographics");
|
|
613
|
+
}
|
|
614
|
+
if (!userFlags.includes("show med rec")) {
|
|
615
|
+
cernerFlags.push("hide med rec");
|
|
616
|
+
}
|
|
617
|
+
cernerFlags.forEach((option) => {
|
|
618
|
+
switch (option) {
|
|
619
|
+
// Calculate the dwCustomizeFlagParamater
|
|
620
|
+
case "sign later":
|
|
621
|
+
dwCustomizeFlag += 1;
|
|
622
|
+
break;
|
|
623
|
+
case "read only":
|
|
624
|
+
dwCustomizeFlag += 4;
|
|
625
|
+
break;
|
|
626
|
+
case "allow power plans":
|
|
627
|
+
dwCustomizeFlag += 8;
|
|
628
|
+
break;
|
|
629
|
+
case "allow power plan doc":
|
|
630
|
+
dwCustomizeFlag += 16;
|
|
631
|
+
break;
|
|
632
|
+
case "allow only inpatient and outpatient orders":
|
|
633
|
+
dwCustomizeFlag += 32;
|
|
634
|
+
break;
|
|
635
|
+
case "show refresh and print buttons":
|
|
636
|
+
dwCustomizeFlag += 128;
|
|
637
|
+
break;
|
|
638
|
+
case "documented meds only":
|
|
639
|
+
dwCustomizeFlag += 256;
|
|
640
|
+
break;
|
|
641
|
+
case "hide med rec":
|
|
642
|
+
dwCustomizeFlag += 512;
|
|
643
|
+
break;
|
|
644
|
+
case "disallow EOL":
|
|
645
|
+
dwCustomizeFlag += 1024;
|
|
646
|
+
break;
|
|
647
|
+
case "hide demographics":
|
|
648
|
+
dwCustomizeFlag += 2048;
|
|
649
|
+
break;
|
|
650
|
+
case "add rx to filter":
|
|
651
|
+
dwCustomizeFlag += 4096;
|
|
652
|
+
break;
|
|
653
|
+
case "disable auto search":
|
|
654
|
+
dwCustomizeFlag += 8192;
|
|
655
|
+
break;
|
|
656
|
+
case "allow regimen":
|
|
657
|
+
dwCustomizeFlag += 16384;
|
|
658
|
+
break;
|
|
659
|
+
// Calculate the dwTabDisplayOptionsFlag parameter
|
|
660
|
+
case "show nav tree":
|
|
661
|
+
dwTabDisplayOptionsFlag += 1;
|
|
662
|
+
break;
|
|
663
|
+
case "show diag and probs":
|
|
664
|
+
dwTabDisplayOptionsFlag += 2;
|
|
665
|
+
break;
|
|
666
|
+
case "show related res":
|
|
667
|
+
dwTabDisplayOptionsFlag += 4;
|
|
668
|
+
break;
|
|
669
|
+
case "show orders search":
|
|
670
|
+
dwTabDisplayOptionsFlag += 8;
|
|
671
|
+
break;
|
|
672
|
+
case "show order profile":
|
|
673
|
+
dwTabDisplayOptionsFlag += 16;
|
|
674
|
+
break;
|
|
675
|
+
case "show scratchpad":
|
|
676
|
+
dwTabDisplayOptionsFlag += 32;
|
|
677
|
+
break;
|
|
678
|
+
case "show list details":
|
|
679
|
+
dwTabDisplayOptionsFlag += 64;
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
return {
|
|
684
|
+
dwCustomizeFlag,
|
|
685
|
+
dwTabFlag,
|
|
686
|
+
dwTabDisplayOptionsFlag
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// src/utils/addNewOrdersToScratchPadAsync.ts
|
|
691
|
+
async function addNewOrdersToScratchpadAsync(dcof, moewHandle, standaloneOrders, interactionChecking) {
|
|
692
|
+
let retData = {
|
|
693
|
+
inPowerChart: true,
|
|
694
|
+
result: "successfully added"
|
|
695
|
+
};
|
|
696
|
+
if (standaloneOrders.length < 1) {
|
|
697
|
+
throw new RangeError(
|
|
698
|
+
"There should be at least one standalone order provided."
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
let standaloneOrdersXML = "";
|
|
702
|
+
standaloneOrders.forEach((standaloneOrder) => {
|
|
703
|
+
standaloneOrdersXML += `<Order><EOrderOriginationFlag>${standaloneOrder.origination === "inpatient order" ? 0 : 1}</EOrderOriginationFlag><SynonymId>${standaloneOrder.synonymId}</SynonymId>
|
|
704
|
+
<OrderSentenceId>${standaloneOrder.sentenceId ? standaloneOrder.sentenceId : ""}</OrderSentenceId></Order>`;
|
|
705
|
+
});
|
|
706
|
+
standaloneOrdersXML = "<Orders>" + standaloneOrdersXML;
|
|
707
|
+
standaloneOrdersXML += "</Orders>";
|
|
708
|
+
standaloneOrdersXML = standaloneOrdersXML.replace(/[\r\n\s]/g, "");
|
|
709
|
+
try {
|
|
710
|
+
const response = await dcof.AddNewOrdersToScratchpad(
|
|
711
|
+
moewHandle,
|
|
712
|
+
standaloneOrdersXML,
|
|
713
|
+
interactionChecking
|
|
714
|
+
);
|
|
715
|
+
switch (response) {
|
|
716
|
+
case 0:
|
|
717
|
+
retData.result = "successfully added";
|
|
718
|
+
break;
|
|
719
|
+
case 1:
|
|
720
|
+
retData.result = "added and signed";
|
|
721
|
+
break;
|
|
722
|
+
case 2:
|
|
723
|
+
retData.result = "cancelled by user";
|
|
724
|
+
break;
|
|
725
|
+
case 3:
|
|
726
|
+
retData.result = "add failed";
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
} catch (e) {
|
|
730
|
+
if (outsideOfPowerChartError(e)) {
|
|
731
|
+
retData.inPowerChart = false;
|
|
732
|
+
retData.result = "add failed";
|
|
733
|
+
} else {
|
|
734
|
+
throw e;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
return retData;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
// src/utils/addPowerPlanWithDetailsAsync.ts
|
|
741
|
+
async function addPowerPlanWithDetailsAsync(dcof, moewHandle, powerPlanOrders) {
|
|
742
|
+
let retData = {
|
|
743
|
+
inPowerChart: true,
|
|
744
|
+
powerPlansAdded: true
|
|
745
|
+
};
|
|
746
|
+
if (powerPlanOrders.length < 1) {
|
|
747
|
+
throw new RangeError(
|
|
748
|
+
"There should be at least one PowerPlan order provided."
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
let powerPlanOrdersXML = "";
|
|
752
|
+
powerPlanOrders.forEach(
|
|
753
|
+
({
|
|
754
|
+
pathwayCatalogId: cid,
|
|
755
|
+
personalizedPlanId: pid,
|
|
756
|
+
diagnosisIds: dids
|
|
757
|
+
}) => {
|
|
758
|
+
powerPlanOrdersXML += `<Plan><PathwayCatalogId>${cid}</PathwayCatalogId><PersonalizedPlanId>${pid ? pid : ""}</PersonalizedPlanId><Diagnoses>
|
|
759
|
+
${dids ? dids.map((diagnosisSynonymID) => {
|
|
760
|
+
return "<DiagnosisId>" + diagnosisSynonymID + "</DiagnosisId>";
|
|
761
|
+
}) : ""}
|
|
762
|
+
</Diagnoses></Plan>`;
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
powerPlanOrdersXML = "<Plans>" + powerPlanOrdersXML;
|
|
766
|
+
powerPlanOrdersXML += "</Plans>";
|
|
767
|
+
powerPlanOrdersXML = powerPlanOrdersXML.replace(/[\r\n\s]/g, "");
|
|
768
|
+
try {
|
|
769
|
+
const response = await dcof.AddPowerPlanWithDetails(
|
|
770
|
+
moewHandle,
|
|
771
|
+
powerPlanOrdersXML
|
|
772
|
+
);
|
|
773
|
+
retData.powerPlansAdded = response === 0 ? false : true;
|
|
774
|
+
} catch (e) {
|
|
775
|
+
if (outsideOfPowerChartError(e)) {
|
|
776
|
+
retData.inPowerChart = false;
|
|
777
|
+
retData.powerPlansAdded = false;
|
|
778
|
+
} else {
|
|
779
|
+
throw e;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return retData;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// src/utils/createMOEWAsync.ts
|
|
786
|
+
async function createMOEWAsync(dcof, personId, encounterId, dwCustomizeFlag, dwTabFlag, dwTabDisplayOptionsFlag) {
|
|
787
|
+
let retData = {
|
|
788
|
+
inPowerChart: true,
|
|
789
|
+
moewHandle: null
|
|
790
|
+
};
|
|
791
|
+
try {
|
|
792
|
+
const response = await dcof.CreateMOEW(
|
|
793
|
+
personId,
|
|
794
|
+
encounterId,
|
|
795
|
+
dwCustomizeFlag,
|
|
796
|
+
dwTabFlag,
|
|
797
|
+
dwTabDisplayOptionsFlag
|
|
798
|
+
);
|
|
799
|
+
retData.moewHandle = response === 0 ? null : response;
|
|
800
|
+
} catch (e) {
|
|
801
|
+
if (outsideOfPowerChartError(e)) {
|
|
802
|
+
retData.inPowerChart = false;
|
|
803
|
+
retData.moewHandle = null;
|
|
804
|
+
} else {
|
|
805
|
+
throw e;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return retData;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// src/utils/destroyMOEWAsync.ts
|
|
812
|
+
async function destroyMOEWAsync(dcof, moewHandle) {
|
|
813
|
+
let retData = {
|
|
814
|
+
inPowerChart: true
|
|
815
|
+
};
|
|
816
|
+
try {
|
|
817
|
+
const response = await dcof.DestroyMOEW(moewHandle);
|
|
818
|
+
console.log("Response from DestroyMOEW() is: ", response);
|
|
819
|
+
} catch (e) {
|
|
820
|
+
if (outsideOfPowerChartError(e)) {
|
|
821
|
+
retData.inPowerChart = false;
|
|
822
|
+
} else {
|
|
823
|
+
throw e;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return retData;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// src/utils/displayMOEWAsync.ts
|
|
830
|
+
async function displayMOEWAsync(dcof, moewHandle) {
|
|
831
|
+
let retData = {
|
|
832
|
+
inPowerChart: true,
|
|
833
|
+
signed: false
|
|
834
|
+
};
|
|
835
|
+
try {
|
|
836
|
+
const response = await dcof.DisplayMOEW(moewHandle);
|
|
837
|
+
retData.signed = Boolean(response);
|
|
838
|
+
} catch (e) {
|
|
839
|
+
if (outsideOfPowerChartError(e)) {
|
|
840
|
+
retData.inPowerChart = false;
|
|
841
|
+
} else {
|
|
842
|
+
throw e;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return retData;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
// src/utils/getOrdersPlacedAsync.ts
|
|
849
|
+
var import_fast_xml_parser2 = require("fast-xml-parser");
|
|
850
|
+
async function getOrdersPlacedAsync(dcof, moewHandle) {
|
|
851
|
+
let retData = {
|
|
852
|
+
inPowerChart: true,
|
|
853
|
+
ordersPlaced: [],
|
|
854
|
+
parsedXML: null,
|
|
855
|
+
rawXML: "",
|
|
856
|
+
status: "success"
|
|
857
|
+
};
|
|
858
|
+
try {
|
|
859
|
+
retData.rawXML = await dcof.GetXMLOrdersMOEW(moewHandle);
|
|
860
|
+
if (typeof retData.rawXML !== "string") {
|
|
861
|
+
retData.status = "invalid data returned";
|
|
862
|
+
return retData;
|
|
863
|
+
}
|
|
864
|
+
if (retData.rawXML.trim() === "") {
|
|
865
|
+
retData.status = "cancelled, failed, or invalid parameters provided";
|
|
866
|
+
return retData;
|
|
867
|
+
}
|
|
868
|
+
const parser = new import_fast_xml_parser2.XMLParser();
|
|
869
|
+
try {
|
|
870
|
+
const parsed = parser.parse(retData.rawXML);
|
|
871
|
+
retData.parsedXML = parsed;
|
|
872
|
+
if (!(parsed.Orders.Order instanceof Array)) {
|
|
873
|
+
parsed.Orders.Order = [parsed.Orders.Order];
|
|
874
|
+
}
|
|
875
|
+
retData.ordersPlaced = parsed.Orders.Order.map((o) => ({
|
|
876
|
+
name: o.OrderedAsMnemonic,
|
|
877
|
+
oid: o.OrderId,
|
|
878
|
+
display: o.ClinDisplayLine
|
|
879
|
+
}));
|
|
880
|
+
} catch {
|
|
881
|
+
retData.status = "xml parse error";
|
|
882
|
+
}
|
|
883
|
+
} catch (e) {
|
|
884
|
+
if (outsideOfPowerChartError(e)) {
|
|
885
|
+
retData.inPowerChart = false;
|
|
886
|
+
retData.parsedXML = null;
|
|
887
|
+
retData.ordersPlaced = [];
|
|
888
|
+
retData.rawXML = "";
|
|
889
|
+
retData.status = "dry run";
|
|
890
|
+
} else {
|
|
891
|
+
throw e;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return retData;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// src/utils/signOrdersAsync.ts
|
|
898
|
+
async function signOrdersAsync(dcof, moewHandle) {
|
|
899
|
+
let retData = {
|
|
900
|
+
inPowerChart: true
|
|
901
|
+
};
|
|
902
|
+
try {
|
|
903
|
+
const response = await dcof.SignOrders(moewHandle);
|
|
904
|
+
console.log("Response from SignMOEW() is: ", response);
|
|
905
|
+
} catch (e) {
|
|
906
|
+
if (outsideOfPowerChartError(e)) {
|
|
907
|
+
retData.inPowerChart = false;
|
|
908
|
+
} else {
|
|
909
|
+
throw e;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
return retData;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
// src/submitPowerOrdersAsync.ts
|
|
916
|
+
var submitPowerOrdersAsync = async (patientId, encounterId, orders, opts, moewFlags, targetTab) => {
|
|
917
|
+
opts = !opts ? { signSilently: false, interactionChecking: true } : opts;
|
|
918
|
+
moewFlags = !moewFlags ? [] : moewFlags;
|
|
919
|
+
const {
|
|
920
|
+
dwCustomizeFlag,
|
|
921
|
+
dwTabFlag,
|
|
922
|
+
dwTabDisplayOptionsFlag
|
|
923
|
+
} = calculateMOEWBitmask(targetTab || "orders tab", moewFlags);
|
|
924
|
+
let retData = {
|
|
925
|
+
inPowerChart: true,
|
|
926
|
+
status: "success",
|
|
927
|
+
ordersPlaced: null
|
|
928
|
+
};
|
|
929
|
+
if (orders.length < 1) {
|
|
930
|
+
throw new Error(
|
|
931
|
+
"At least one order to submit must be provided to this function."
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
let powerPlanOrders = [];
|
|
935
|
+
let standaloneOrders = [];
|
|
936
|
+
orders.forEach((order) => {
|
|
937
|
+
if (isPowerPlanOrder(order)) {
|
|
938
|
+
powerPlanOrders.push(order);
|
|
939
|
+
} else if (isStandaloneOrder(order)) {
|
|
940
|
+
standaloneOrders.push(order);
|
|
941
|
+
} else {
|
|
942
|
+
throw new SyntaxError(
|
|
943
|
+
"Each order provided must be of either a PowerPlanOrder or StandaloneOrder type."
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
try {
|
|
948
|
+
let moewId = 0;
|
|
949
|
+
const dcof = await window.external.DiscernObjectFactory("POWERORDERS");
|
|
950
|
+
const createMOEW = await createMOEWAsync(
|
|
951
|
+
dcof,
|
|
952
|
+
patientId,
|
|
953
|
+
encounterId,
|
|
954
|
+
dwCustomizeFlag,
|
|
955
|
+
dwTabFlag,
|
|
956
|
+
dwTabDisplayOptionsFlag
|
|
957
|
+
);
|
|
958
|
+
if (createMOEW.inPowerChart === false) {
|
|
959
|
+
retData.inPowerChart = false;
|
|
960
|
+
retData.ordersPlaced = null;
|
|
961
|
+
retData.status = "dry run";
|
|
962
|
+
return retData;
|
|
963
|
+
}
|
|
964
|
+
if (createMOEW.moewHandle === null) {
|
|
965
|
+
retData.inPowerChart = true;
|
|
966
|
+
retData.ordersPlaced = null;
|
|
967
|
+
retData.status = "invalid data returned";
|
|
968
|
+
return retData;
|
|
969
|
+
}
|
|
970
|
+
moewId = createMOEW.moewHandle;
|
|
971
|
+
if (powerPlanOrders && powerPlanOrders.length >= 1) {
|
|
972
|
+
const addPowerPlans = await addPowerPlanWithDetailsAsync(
|
|
973
|
+
dcof,
|
|
974
|
+
moewId,
|
|
975
|
+
powerPlanOrders
|
|
976
|
+
);
|
|
977
|
+
if (addPowerPlans.inPowerChart === false) {
|
|
978
|
+
retData.inPowerChart = false;
|
|
979
|
+
retData.ordersPlaced = null;
|
|
980
|
+
retData.status = "dry run";
|
|
981
|
+
return retData;
|
|
982
|
+
}
|
|
983
|
+
if (addPowerPlans.powerPlansAdded === false) {
|
|
984
|
+
retData.inPowerChart = true;
|
|
985
|
+
retData.ordersPlaced = null;
|
|
986
|
+
retData.status = "cancelled, failed, or invalid parameters provided";
|
|
987
|
+
return retData;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
if (standaloneOrders && standaloneOrders.length >= 1) {
|
|
991
|
+
const addStandaloneOrders = await addNewOrdersToScratchpadAsync(
|
|
992
|
+
dcof,
|
|
993
|
+
moewId,
|
|
994
|
+
standaloneOrders,
|
|
995
|
+
opts.interactionChecking
|
|
996
|
+
);
|
|
997
|
+
if (addStandaloneOrders.inPowerChart === false) {
|
|
998
|
+
retData.inPowerChart = false;
|
|
999
|
+
retData.ordersPlaced = null;
|
|
1000
|
+
retData.status = "dry run";
|
|
1001
|
+
return retData;
|
|
1002
|
+
}
|
|
1003
|
+
if (addStandaloneOrders.result === "add failed" || addStandaloneOrders.result === "cancelled by user") {
|
|
1004
|
+
retData.inPowerChart = true;
|
|
1005
|
+
retData.ordersPlaced = null;
|
|
1006
|
+
retData.status = "cancelled, failed, or invalid parameters provided";
|
|
1007
|
+
return retData;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
if (opts.signSilently) {
|
|
1011
|
+
const signOrders = await signOrdersAsync(dcof, moewId);
|
|
1012
|
+
if (signOrders.inPowerChart === false) {
|
|
1013
|
+
retData.inPowerChart = false;
|
|
1014
|
+
retData.ordersPlaced = null;
|
|
1015
|
+
retData.status = "dry run";
|
|
1016
|
+
return retData;
|
|
1017
|
+
}
|
|
1018
|
+
} else {
|
|
1019
|
+
const displayMOEW = await displayMOEWAsync(dcof, moewId);
|
|
1020
|
+
if (displayMOEW.inPowerChart === false) {
|
|
1021
|
+
retData.inPowerChart = false;
|
|
1022
|
+
retData.ordersPlaced = null;
|
|
1023
|
+
retData.status = "dry run";
|
|
1024
|
+
return retData;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
const getPlacedOrders = await getOrdersPlacedAsync(dcof, moewId);
|
|
1028
|
+
if (getPlacedOrders.inPowerChart === false) {
|
|
1029
|
+
retData.inPowerChart = false;
|
|
1030
|
+
retData.ordersPlaced = null;
|
|
1031
|
+
retData.status = "dry run";
|
|
1032
|
+
return retData;
|
|
1033
|
+
}
|
|
1034
|
+
if (getPlacedOrders.ordersPlaced === null || getPlacedOrders.ordersPlaced.length === 0) {
|
|
1035
|
+
retData.inPowerChart = true;
|
|
1036
|
+
retData.ordersPlaced = null;
|
|
1037
|
+
retData.status = getPlacedOrders.status;
|
|
1038
|
+
return retData;
|
|
1039
|
+
}
|
|
1040
|
+
retData.inPowerChart = true;
|
|
1041
|
+
retData.ordersPlaced = getPlacedOrders.ordersPlaced;
|
|
1042
|
+
retData.status = getPlacedOrders.status;
|
|
1043
|
+
const destroyMOEW = await destroyMOEWAsync(dcof, moewId);
|
|
1044
|
+
if (destroyMOEW.inPowerChart === false) {
|
|
1045
|
+
retData.inPowerChart = false;
|
|
1046
|
+
retData.ordersPlaced = null;
|
|
1047
|
+
retData.status = "dry run";
|
|
1048
|
+
return retData;
|
|
1049
|
+
}
|
|
1050
|
+
} catch (e) {
|
|
1051
|
+
if (outsideOfPowerChartError(e)) {
|
|
1052
|
+
retData.inPowerChart = false;
|
|
1053
|
+
retData.ordersPlaced = null;
|
|
1054
|
+
retData.status = "dry run";
|
|
1055
|
+
return retData;
|
|
1056
|
+
} else {
|
|
1057
|
+
throw e;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
return retData;
|
|
1061
|
+
};
|
|
1062
|
+
var isPowerPlanOrder = (o) => {
|
|
1063
|
+
return o.hasOwnProperty("pathwayCatalogId");
|
|
1064
|
+
};
|
|
1065
|
+
var isStandaloneOrder = (o) => {
|
|
1066
|
+
return o.hasOwnProperty("synonymId") && o.hasOwnProperty("origination");
|
|
1067
|
+
};
|
|
1068
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1069
|
+
0 && (module.exports = {
|
|
1070
|
+
CclCallParam,
|
|
1071
|
+
CclRequestResponse,
|
|
1072
|
+
XmlCclReadyState,
|
|
1073
|
+
XmlCclResult,
|
|
1074
|
+
addAddendumToDocumentAsync,
|
|
1075
|
+
createNewDocumentAsync,
|
|
1076
|
+
getValidEncountersAsync,
|
|
1077
|
+
launchClinicalNoteAsync,
|
|
1078
|
+
launchDischargeProcessAsync,
|
|
1079
|
+
launchPatientEducationAsync,
|
|
1080
|
+
launchPowerFormAsync,
|
|
1081
|
+
launchPowerNoteAsync,
|
|
1082
|
+
makeCclRequestAsync,
|
|
1083
|
+
manageAppointmentAsync,
|
|
1084
|
+
openApplicationAsync,
|
|
1085
|
+
openOrganizerTabAsync,
|
|
1086
|
+
openPatientTabAsync,
|
|
1087
|
+
openWebsiteByUrlAsync,
|
|
1088
|
+
submitOrdersAsync,
|
|
1089
|
+
submitPowerOrdersAsync
|
|
1090
|
+
});
|
|
1091
|
+
//# sourceMappingURL=index.cjs.map
|