fluent-cerner-js 1.1.1 → 1.2.0-0
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 +135 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +160 -142
- package/dist/index.d.ts +160 -142
- package/dist/index.js +134 -120
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +4 -0
- package/src/launchMOEWAsync.spec.ts +20 -0
- package/src/launchMOEWAsync.ts +41 -0
- package/src/submitOrdersAsync.spec.ts +10 -0
- package/src/submitOrdersAsync.ts +13 -7
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
getValidEncountersAsync: () => getValidEncountersAsync,
|
|
26
26
|
launchClinicalNoteAsync: () => launchClinicalNoteAsync,
|
|
27
27
|
launchDischargeProcessAsync: () => launchDischargeProcessAsync,
|
|
28
|
+
launchMOEWAsync: () => launchMOEWAsync,
|
|
28
29
|
launchPatientEducationAsync: () => launchPatientEducationAsync,
|
|
29
30
|
launchPowerFormAsync: () => launchPowerFormAsync,
|
|
30
31
|
launchPowerNoteAsync: () => launchPowerNoteAsync,
|
|
@@ -215,6 +216,139 @@ async function launchDischargeProcessAsync(patientId, encounterId, providerId) {
|
|
|
215
216
|
return retData;
|
|
216
217
|
}
|
|
217
218
|
|
|
219
|
+
// src/submitOrdersAsync.ts
|
|
220
|
+
var import_fast_xml_parser = require("fast-xml-parser");
|
|
221
|
+
|
|
222
|
+
// src/utils/createOrderString.ts
|
|
223
|
+
var _createOrderString = (action, id, opts) => {
|
|
224
|
+
const { orderSentenceId, nomenclatureIds, origination, interactionCheck } = opts || {};
|
|
225
|
+
let params = [orderActionMap.get(action)];
|
|
226
|
+
const nids = nomenclatureIds || [];
|
|
227
|
+
switch (action) {
|
|
228
|
+
case "launch moew":
|
|
229
|
+
params = params.concat(["0", "0", "0", "0", "0"]);
|
|
230
|
+
break;
|
|
231
|
+
case "new order":
|
|
232
|
+
if (!id)
|
|
233
|
+
throw new Error(
|
|
234
|
+
`id (as synonym ID) is required for the '${action}' action`
|
|
235
|
+
);
|
|
236
|
+
params = params.concat([
|
|
237
|
+
`${id}`,
|
|
238
|
+
`${originationMap.get(origination) || 0}`,
|
|
239
|
+
`${orderSentenceId || 0}`,
|
|
240
|
+
nids.length > 1 ? `[${nids.join("|")}]` : `${nids[0] || 0}`,
|
|
241
|
+
`${interactionMap.get(interactionCheck) || 0}`
|
|
242
|
+
]);
|
|
243
|
+
break;
|
|
244
|
+
default:
|
|
245
|
+
if (!id)
|
|
246
|
+
throw new Error(
|
|
247
|
+
`id (as the existing order ID) is required for the '${action}' action`
|
|
248
|
+
);
|
|
249
|
+
params = params.concat([`${id}`]);
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
return `{${params.join("|")}}`;
|
|
253
|
+
};
|
|
254
|
+
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");
|
|
255
|
+
var originationMap = (/* @__PURE__ */ new Map()).set("satellite", "5").set("prescription", "1").set("normal", "0");
|
|
256
|
+
var interactionMap = (/* @__PURE__ */ new Map()).set("on sign", "1").set("default", "0");
|
|
257
|
+
var createOrderString = (action, id, opts) => _createOrderString(action, id, opts);
|
|
258
|
+
var LAUNCH_MOEW_ORDER_STRING = _createOrderString("launch moew");
|
|
259
|
+
|
|
260
|
+
// src/submitOrdersAsync.ts
|
|
261
|
+
var launchViewMap = (/* @__PURE__ */ new Map()).set("search", 8).set("profile", 16).set("signature", 32);
|
|
262
|
+
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 });
|
|
263
|
+
var submitOrdersAsync = async (patientId, encounterId, orders, opts) => {
|
|
264
|
+
let { targetTab, launchView, signSilently, dryRun } = opts || {};
|
|
265
|
+
if (!targetTab) targetTab = "orders";
|
|
266
|
+
if (!launchView) launchView = "signature";
|
|
267
|
+
const enablePowerPlans = targetTab === "power orders" || targetTab === "power medications";
|
|
268
|
+
const orderList = orders.length === 0 ? LAUNCH_MOEW_ORDER_STRING : orders.map(({ action, id, opts: opts2 }) => createOrderString(action, id, opts2)).join("");
|
|
269
|
+
let params = [`${patientId}`, `${encounterId}`, orderList];
|
|
270
|
+
params.push(enablePowerPlans ? "24" : "0");
|
|
271
|
+
const { tab, display } = tabsMap.get(targetTab) || { tab: 2, display: 127 };
|
|
272
|
+
params.push(`{${tab}|${display}}`);
|
|
273
|
+
params.push(`${launchViewMap.get(launchView) || 32}`);
|
|
274
|
+
params.push(`${signSilently ? "1" : "0"}`);
|
|
275
|
+
const eventString = params.join("|");
|
|
276
|
+
const retVal = {
|
|
277
|
+
eventString,
|
|
278
|
+
inPowerChart: true,
|
|
279
|
+
status: "success",
|
|
280
|
+
response: null,
|
|
281
|
+
ordersPlaced: null,
|
|
282
|
+
rawResponse: null
|
|
283
|
+
};
|
|
284
|
+
if (dryRun) {
|
|
285
|
+
retVal.status = "dry run";
|
|
286
|
+
return retVal;
|
|
287
|
+
}
|
|
288
|
+
try {
|
|
289
|
+
const response = await window.external.MPAGES_EVENT(
|
|
290
|
+
"ORDERS",
|
|
291
|
+
eventString
|
|
292
|
+
);
|
|
293
|
+
retVal.rawResponse = response;
|
|
294
|
+
if (response === null) {
|
|
295
|
+
retVal.status = "failed";
|
|
296
|
+
return retVal;
|
|
297
|
+
}
|
|
298
|
+
if (typeof response !== "string") {
|
|
299
|
+
retVal.status = "invalid data returned";
|
|
300
|
+
return retVal;
|
|
301
|
+
}
|
|
302
|
+
switch (response.trim()) {
|
|
303
|
+
case "":
|
|
304
|
+
retVal.status = "cancelled";
|
|
305
|
+
break;
|
|
306
|
+
default:
|
|
307
|
+
retVal.status = "success";
|
|
308
|
+
const parser = new import_fast_xml_parser.XMLParser();
|
|
309
|
+
try {
|
|
310
|
+
const parsed = parser.parse(response);
|
|
311
|
+
retVal.response = parsed;
|
|
312
|
+
if (!(parsed.Orders.Order instanceof Array)) {
|
|
313
|
+
parsed.Orders.Order = [parsed.Orders.Order];
|
|
314
|
+
}
|
|
315
|
+
retVal.ordersPlaced = parsed.Orders.Order.map((o) => ({
|
|
316
|
+
name: o.OrderedAsMnemonic,
|
|
317
|
+
oid: o.OrderId,
|
|
318
|
+
display: o.ClinDisplayLine
|
|
319
|
+
}));
|
|
320
|
+
} catch {
|
|
321
|
+
retVal.status = "xml parse error";
|
|
322
|
+
}
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
} catch (e) {
|
|
326
|
+
if (outsideOfPowerChartError(e)) {
|
|
327
|
+
retVal.inPowerChart = false;
|
|
328
|
+
retVal.status = "invalid data returned";
|
|
329
|
+
warnAttemptedOrdersOutsideOfPowerChart(eventString);
|
|
330
|
+
} else {
|
|
331
|
+
throw e;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return retVal;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// src/launchMOEWAsync.ts
|
|
338
|
+
var launchMOEWAsync = async (patientId, encounterId, opts) => {
|
|
339
|
+
const {
|
|
340
|
+
targetTab = "power orders",
|
|
341
|
+
launchView = "search",
|
|
342
|
+
dryRun
|
|
343
|
+
} = opts || {};
|
|
344
|
+
return submitOrdersAsync(patientId, encounterId, [], {
|
|
345
|
+
targetTab,
|
|
346
|
+
launchView,
|
|
347
|
+
dryRun,
|
|
348
|
+
signSilently: false
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
|
|
218
352
|
// src/launchPatientEducationAsync.ts
|
|
219
353
|
async function launchPatientEducationAsync(patientId, encounterId, targetTab) {
|
|
220
354
|
const retData = {
|
|
@@ -450,126 +584,6 @@ async function openWebsiteByUrlAsync(url) {
|
|
|
450
584
|
return await openApplicationAsync("by url", url);
|
|
451
585
|
}
|
|
452
586
|
|
|
453
|
-
// src/submitOrdersAsync.ts
|
|
454
|
-
var import_fast_xml_parser = require("fast-xml-parser");
|
|
455
|
-
|
|
456
|
-
// src/utils/createOrderString.ts
|
|
457
|
-
var _createOrderString = (action, id, opts) => {
|
|
458
|
-
const { orderSentenceId, nomenclatureIds, origination, interactionCheck } = opts || {};
|
|
459
|
-
let params = [orderActionMap.get(action)];
|
|
460
|
-
const nids = nomenclatureIds || [];
|
|
461
|
-
switch (action) {
|
|
462
|
-
case "launch moew":
|
|
463
|
-
params = params.concat(["0", "0", "0", "0", "0"]);
|
|
464
|
-
break;
|
|
465
|
-
case "new order":
|
|
466
|
-
if (!id)
|
|
467
|
-
throw new Error(
|
|
468
|
-
`id (as synonym ID) is required for the '${action}' action`
|
|
469
|
-
);
|
|
470
|
-
params = params.concat([
|
|
471
|
-
`${id}`,
|
|
472
|
-
`${originationMap.get(origination) || 0}`,
|
|
473
|
-
`${orderSentenceId || 0}`,
|
|
474
|
-
nids.length > 1 ? `[${nids.join("|")}]` : `${nids[0] || 0}`,
|
|
475
|
-
`${interactionMap.get(interactionCheck) || 0}`
|
|
476
|
-
]);
|
|
477
|
-
break;
|
|
478
|
-
default:
|
|
479
|
-
if (!id)
|
|
480
|
-
throw new Error(
|
|
481
|
-
`id (as the existing order ID) is required for the '${action}' action`
|
|
482
|
-
);
|
|
483
|
-
params = params.concat([`${id}`]);
|
|
484
|
-
break;
|
|
485
|
-
}
|
|
486
|
-
return `{${params.join("|")}}`;
|
|
487
|
-
};
|
|
488
|
-
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");
|
|
489
|
-
var originationMap = (/* @__PURE__ */ new Map()).set("satellite", "5").set("prescription", "1").set("normal", "0");
|
|
490
|
-
var interactionMap = (/* @__PURE__ */ new Map()).set("on sign", "1").set("default", "0");
|
|
491
|
-
var createOrderString = (action, id, opts) => _createOrderString(action, id, opts);
|
|
492
|
-
var LAUNCH_MOEW_ORDER_STRING = _createOrderString("launch moew");
|
|
493
|
-
|
|
494
|
-
// src/submitOrdersAsync.ts
|
|
495
|
-
var launchViewMap = (/* @__PURE__ */ new Map()).set("search", 8).set("profile", 16).set("signature", 32);
|
|
496
|
-
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 });
|
|
497
|
-
var submitOrdersAsync = async (patientId, encounterId, orders, opts) => {
|
|
498
|
-
let { targetTab, launchView, signSilently, dryRun } = opts || {};
|
|
499
|
-
if (!targetTab) targetTab = "orders";
|
|
500
|
-
if (!launchView) launchView = "signature";
|
|
501
|
-
const enablePowerPlans = targetTab === "power orders" || targetTab === "power medications";
|
|
502
|
-
const s = orders.map(
|
|
503
|
-
({ action, id, opts: opts2 }) => createOrderString(action, id, opts2)
|
|
504
|
-
);
|
|
505
|
-
let params = [`${patientId}`, `${encounterId}`, s.join("")];
|
|
506
|
-
params.push(enablePowerPlans ? "24" : "0");
|
|
507
|
-
const { tab, display } = tabsMap.get(targetTab) || { tab: 2, display: 127 };
|
|
508
|
-
params.push(`{${tab}|${display}}`);
|
|
509
|
-
params.push(`${launchViewMap.get(launchView) || 32}`);
|
|
510
|
-
params.push(`${signSilently ? "1" : "0"}`);
|
|
511
|
-
const eventString = params.join("|");
|
|
512
|
-
const retVal = {
|
|
513
|
-
eventString,
|
|
514
|
-
inPowerChart: true,
|
|
515
|
-
status: "success",
|
|
516
|
-
response: null,
|
|
517
|
-
ordersPlaced: null,
|
|
518
|
-
rawResponse: null
|
|
519
|
-
};
|
|
520
|
-
if (dryRun) {
|
|
521
|
-
retVal.status = "dry run";
|
|
522
|
-
return retVal;
|
|
523
|
-
}
|
|
524
|
-
try {
|
|
525
|
-
const response = await window.external.MPAGES_EVENT(
|
|
526
|
-
"ORDERS",
|
|
527
|
-
eventString
|
|
528
|
-
);
|
|
529
|
-
retVal.rawResponse = response;
|
|
530
|
-
if (response === null) {
|
|
531
|
-
retVal.status = "failed";
|
|
532
|
-
return retVal;
|
|
533
|
-
}
|
|
534
|
-
if (typeof response !== "string") {
|
|
535
|
-
retVal.status = "invalid data returned";
|
|
536
|
-
return retVal;
|
|
537
|
-
}
|
|
538
|
-
switch (response.trim()) {
|
|
539
|
-
case "":
|
|
540
|
-
retVal.status = "cancelled";
|
|
541
|
-
break;
|
|
542
|
-
default:
|
|
543
|
-
retVal.status = "success";
|
|
544
|
-
const parser = new import_fast_xml_parser.XMLParser();
|
|
545
|
-
try {
|
|
546
|
-
const parsed = parser.parse(response);
|
|
547
|
-
retVal.response = parsed;
|
|
548
|
-
if (!(parsed.Orders.Order instanceof Array)) {
|
|
549
|
-
parsed.Orders.Order = [parsed.Orders.Order];
|
|
550
|
-
}
|
|
551
|
-
retVal.ordersPlaced = parsed.Orders.Order.map((o) => ({
|
|
552
|
-
name: o.OrderedAsMnemonic,
|
|
553
|
-
oid: o.OrderId,
|
|
554
|
-
display: o.ClinDisplayLine
|
|
555
|
-
}));
|
|
556
|
-
} catch {
|
|
557
|
-
retVal.status = "xml parse error";
|
|
558
|
-
}
|
|
559
|
-
break;
|
|
560
|
-
}
|
|
561
|
-
} catch (e) {
|
|
562
|
-
if (outsideOfPowerChartError(e)) {
|
|
563
|
-
retVal.inPowerChart = false;
|
|
564
|
-
retVal.status = "invalid data returned";
|
|
565
|
-
warnAttemptedOrdersOutsideOfPowerChart(eventString);
|
|
566
|
-
} else {
|
|
567
|
-
throw e;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
return retVal;
|
|
571
|
-
};
|
|
572
|
-
|
|
573
587
|
// src/utils/calculateMOEWBitmask.ts
|
|
574
588
|
var calculateMOEWBitmask = (targetTab, inputFlags) => {
|
|
575
589
|
let dwCustomizeFlag = 0;
|
|
@@ -1066,6 +1080,7 @@ var isStandaloneOrder = (o) => {
|
|
|
1066
1080
|
getValidEncountersAsync,
|
|
1067
1081
|
launchClinicalNoteAsync,
|
|
1068
1082
|
launchDischargeProcessAsync,
|
|
1083
|
+
launchMOEWAsync,
|
|
1069
1084
|
launchPatientEducationAsync,
|
|
1070
1085
|
launchPowerFormAsync,
|
|
1071
1086
|
launchPowerNoteAsync,
|