fluent-cerner-js 0.1.1 → 0.2.1-alpha.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/README.md CHANGED
@@ -4,7 +4,7 @@ A fluent `MPAGE_EVENT` string generation library.
4
4
 
5
5
  | Environment | CI | Publish |
6
6
  | ----------- | ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
7
- | Production | ![Main Build](https://github.com/geekmdtravis/fluent-cerner-js/actions/workflows/main.yml/badge.svg?branch=main) | ![Main Publish](https://github.com/geekmdtravis/fluent-cerner-js/actions/workflows/publish.yml/badge.svg?branch=main) |
7
+ | Production | ![Main Build](https://github.com/geekmdtravis/fluent-cerner-js/actions/workflows/main.yml/badge.svg?branch=main) | ![Main Publish](https://github.com/geekmdtravis/fluent-cerner-js/actions/workflows/publish.yml/badge.svg) |
8
8
  | Development | ![Development Build](https://github.com/geekmdtravis/fluent-cerner-js/actions/workflows/main.yml/badge.svg?branch=development) | Not Applicable |
9
9
 
10
10
  ## Resources
@@ -1,4 +1,24 @@
1
- import { NewOrderOpts } from './types';
1
+ /**
2
+ * Options for a new order
3
+ * @param {boolean} isRxOrder Marks the order order as a prescription. Is mutually exclusive from
4
+ * isSatelliteOrder. Field will be set to false if left undefined; this resolves to 0 when built.
5
+ * @param {boolean} isSatelliteOrder Moarks the order origination as satellite. Is mutually
6
+ * exclusive from isRxOrder. Field will be set to false if left undefined; this resolves to 0 when built.
7
+ * @param {number} orderSentenceId The optional Cerner order_sentence_id to be associated with
8
+ * the new order. Field will be set to 0 if undefined.
9
+ * @param {number} nomenclatureId The optional Cerner nomenclature_id to be associated with the
10
+ * new order. Field will be set to 0 if undefined.
11
+ * @param {boolean} skipInteractionCheckUntilSign Determines cerner sign-time interaction
12
+ * checking. A value of true skips checking for interactions until orders are signed, false
13
+ * will not. Field will be set to false if left undefined; this resolves to 0 when built.
14
+ */
15
+ export declare type NewOrderOpts = {
16
+ isRxOrder?: boolean;
17
+ isSatelliteOrder?: boolean;
18
+ orderSentenceId?: number;
19
+ nomenclatureId?: number;
20
+ skipInteractionCheckUntilSign?: boolean;
21
+ };
2
22
  export declare class MPageOrder {
3
23
  private _orderAction;
4
24
  getOrderAction: () => string;
@@ -2,6 +2,104 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var statusCodeMap = /*#__PURE__*/new Map();
6
+ statusCodeMap.set(200, 'success');
7
+ statusCodeMap.set(405, 'method not allowed');
8
+ statusCodeMap.set(409, 'invalid state');
9
+ statusCodeMap.set(492, 'non-fatal error');
10
+ statusCodeMap.set(493, 'memory error');
11
+ statusCodeMap.set(500, 'internal server exception');
12
+ /**
13
+ * A generic wrapper function for `XMLCclRequest` which simplifies it's use. Of note,
14
+ * use of this requires the `head` of the HTML document contain the following
15
+ * `meta` tag: `<META content='XMLCCLREQUEST' name='discern'>` so that it might
16
+ * interface with the appropriate COM object.
17
+ * @param {CclOpts} opts - Required options for the CCL request.
18
+ * @returns a promise of type `CclRequestResponse<T>` where `T` is the type
19
+ * or interface which represents the resolved data from the CCL request. If
20
+ * no data are returned, that is an empty string, from the XMLCclRequest then
21
+ * the `data` field will be set to `undefined`. The objects `meta` field
22
+ * includes `responseText`, `status`, and `statusTest` fields.
23
+ * @resolves the `CclRequestResponse<T>` where `T` is the type
24
+ * or interface which represents the resolved data from the CCL request. If
25
+ * no data are returned, that is an empty string, from the XMLCclRequest then
26
+ * the `data` field will be set to `undefined`. The objects `meta` field
27
+ * includes `responseText`, `status`, and `statusTest` fields.
28
+ * @rejects with an error message if the CCL request fails.
29
+ */
30
+
31
+ function makeCclRequest(opts) {
32
+ var prg = opts.prg,
33
+ excludeMine = opts.excludeMine,
34
+ params = opts.params;
35
+ var paramsList = (excludeMine ? '' : "'MINE',") + params.map(function (_ref) {
36
+ var type = _ref.type,
37
+ param = _ref.param;
38
+ return type === 'string' ? "'" + param + "'" : param;
39
+ }).join(',');
40
+ return new Promise(function (resolve, reject) {
41
+ try {
42
+ // @ts-ignore - From Powerchart context
43
+ var request = window.XMLCclRequest();
44
+ request.open('GET', "" + prg);
45
+ request.send(paramsList);
46
+
47
+ request.onreadystatechange = function () {
48
+ var data = {
49
+ meta: {
50
+ responseText: request.responseText,
51
+ status: request.status,
52
+ statusText: statusCodeMap.get(request.status) || 'status refers to unknown error'
53
+ },
54
+ data: request.responseText === '' ? undefined : JSON.parse(request.responseText)
55
+ };
56
+
57
+ if (request.readyState === 4) {
58
+ resolve(data);
59
+ } else {
60
+ reject("error with status " + request.status + " and readyState " + request.readyState + " on " + prg + " with params " + paramsList + " returning response text: " + (request.responseText || 'no response text'));
61
+ }
62
+ };
63
+ } catch (e) {
64
+ if (e instanceof ReferenceError) {
65
+ reject("We're likely not inside PowerChart. We cannot send request: \"" + paramsList + "\" to \"" + prg + "\"");
66
+ } else {
67
+ throw e;
68
+ }
69
+ }
70
+ });
71
+ }
72
+ /**
73
+ * Attempts to open a tab with the name given to the `tab` variable in a
74
+ * patients chart given in the context of a given encounter.
75
+ * @param pid The patients person id.
76
+ * @param eid The patients encounter id.
77
+ * @param tab The string which represents the tab to open
78
+ * (case insensitive). Navigation will be made to the first
79
+ * upper-level tab in the chart that that matches the `tab` string
80
+ * If no match is found, then sub-tab names will be searched and
81
+ * navigation made to the first sub-tab that matches
82
+ * the `tab` string. If no matches are found, no navigation will occur.
83
+ * @param quickAdd {boolean} - If true, will attempt to open the window
84
+ * in a quick add mode. E.g. if the Orders tab is connected to it will
85
+ * attempt to launch the Add Order window so long as Enhanced Navigation is
86
+ * supported by your installation.
87
+ */
88
+
89
+ function openPatientTab(pid, eid, tab, quickAdd) {
90
+ var args = "/PERSONID=" + pid + " /ENCNTRID=" + eid + " /FIRSTTAB=^" + tab.toUpperCase() + (quickAdd ? '+' : '') + "^";
91
+
92
+ try {
93
+ window.APPLINK(1, '$APP_APPNAME$', args);
94
+ } catch (e) {
95
+ if (e instanceof ReferenceError) {
96
+ console.warn("We're likely not inside PowerChart. The input given would be: '1, \"$APP_NAME$\", " + args + "'");
97
+ } else {
98
+ throw e;
99
+ }
100
+ }
101
+ }
102
+
5
103
  var MPageOrderEvent = /*#__PURE__*/function () {
6
104
  function MPageOrderEvent() {
7
105
  var _this = this;
@@ -127,7 +225,6 @@ var MPageOrderEvent = /*#__PURE__*/function () {
127
225
 
128
226
  _proto.send = function send() {
129
227
  try {
130
- // @ts-ignore
131
228
  window.MPAGES_EVENT('ORDERS', this.toString());
132
229
  } catch (e) {
133
230
  if (e instanceof ReferenceError) {
@@ -418,49 +515,8 @@ var MPageOrder = /*#__PURE__*/function () {
418
515
  return MPageOrder;
419
516
  }();
420
517
 
421
- /**
422
- * A generic wrapper function for `XMLCclRequest` which simplifies it's use.
423
- * @param {CclOpts} opts - Required options for the CCL request.
424
- * @returns a promise of type `T` where `T` is the type or interface which represents
425
- * the resolved data from the CCL request.
426
- * @resolves the resolved data of type `T` from the CCL request.
427
- * @rejects with an error message if the CCL request fails.
428
- */
429
- function makeCclRequest(opts) {
430
- var prg = opts.prg,
431
- excludeMine = opts.excludeMine,
432
- params = opts.params;
433
- var paramsList = (excludeMine ? '' : "'MINE',") + params.map(function (_ref) {
434
- var type = _ref.type,
435
- param = _ref.param;
436
- return type === 'string' ? "'" + param + "'" : param;
437
- }).join(',');
438
- return new Promise(function (resolve, reject) {
439
- try {
440
- // @ts-ignore - exists in PowerChart
441
- var request = new window.XMLCclRequest();
442
- request.open('GET', "" + prg);
443
- request.send(paramsList);
444
-
445
- request.onreadystatechange = function () {
446
- if (request.readyState === 4 && request.status === 200) {
447
- var data = JSON.parse(request.responseText);
448
- resolve(data);
449
- } else {
450
- reject("error with status " + request.status + " and readyState " + request.readyState + " on " + prg + " with params " + paramsList);
451
- }
452
- };
453
- } catch (e) {
454
- if (e instanceof ReferenceError) {
455
- reject("We're likely not inside PowerChart. We cannot send request: \"" + paramsList + "\" to \"" + prg + "\"");
456
- } else {
457
- throw e;
458
- }
459
- }
460
- });
461
- }
462
-
463
518
  exports.MPageOrder = MPageOrder;
464
519
  exports.MPageOrderEvent = MPageOrderEvent;
465
520
  exports.makeCclRequest = makeCclRequest;
521
+ exports.openPatientTab = openPatientTab;
466
522
  //# sourceMappingURL=fluent-cerner-js.cjs.development.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fluent-cerner-js.cjs.development.js","sources":["../src/MPageOrderEvent.ts","../src/MPageOrder.ts","../src/utils/index.ts"],"sourcesContent":["import { MPageOrder } from '.';\n\nclass MPageOrderEvent {\n private _orders: Array<MPageOrder>;\n getOrders = () => this._orders;\n\n private _tabList: { tab: number; tabDisplayFlag: number } = {\n tab: 0,\n tabDisplayFlag: 0,\n };\n getTabList = () => this._tabList;\n\n private _personId: number = 0;\n getPersonId = () => this._personId;\n\n private _encounterId: number = 0;\n getEncounterId = () => this._encounterId;\n\n private _powerPlanFlag: number = 0;\n getPowerPlanFlag = () => this._powerPlanFlag;\n\n private _defaultDisplay: number = 0;\n getDefaultDisplay = () => this._defaultDisplay;\n\n private _silentSignFlag: number = 0;\n getSilentSignFlag = () => this._silentSignFlag;\n\n constructor() {\n this._orders = [];\n this._tabList = { tab: 0, tabDisplayFlag: 0 };\n // Disable PowerPlans by default\n this._powerPlanFlag = 0;\n // Disable PowerOrders by default\n this._tabList.tabDisplayFlag = 0;\n this.customizeOrderListProfile();\n this.launchOrderProfile();\n // Do NOT sign silently by default\n this._silentSignFlag = 0;\n }\n\n forPerson(id: number) {\n this._personId = id;\n return this;\n }\n\n forEncounter(id: number) {\n this._encounterId = id;\n return this;\n }\n\n addOrders(orders: Array<MPageOrder> | MPageOrder) {\n if (!Array.isArray(orders)) {\n orders = [orders];\n }\n this._orders = this._orders.concat(orders);\n return this;\n }\n\n enablePowerPlans() {\n this._powerPlanFlag = 24;\n return this;\n }\n\n customizeOrderListProfile() {\n this._tabList.tab = 2;\n return this;\n }\n\n customizeMedicationListProfile() {\n this._tabList.tab = 3;\n return this;\n }\n\n enablePowerOrders() {\n this._tabList.tabDisplayFlag = 127;\n return this;\n }\n\n launchOrderSearch() {\n this._defaultDisplay = 8;\n return this;\n }\n\n launchOrderProfile() {\n this._defaultDisplay = 16;\n return this;\n }\n\n launchOrdersForSignature() {\n this._defaultDisplay = 32;\n return this;\n }\n\n signSilently() {\n this._silentSignFlag = 1;\n return this;\n }\n\n send() {\n try {\n // @ts-ignore\n window.MPAGES_EVENT('ORDERS', this.toString());\n } catch (e) {\n if (e instanceof ReferenceError) {\n console.warn(\n `We're likely not inside PowerChart. The output would be an MPAGES_EVENT: ${this.toString()}`\n );\n } else {\n throw e;\n }\n }\n }\n\n toString(): string {\n const head = `${this._personId}|${this._encounterId}|`;\n let body: string = '';\n this._orders.forEach(order => {\n body += order.toString();\n });\n const tail = `|${this._powerPlanFlag}|{${this._tabList.tab}|${this._tabList.tabDisplayFlag}}|${this._defaultDisplay}|${this._silentSignFlag}`;\n\n return `${head}${body}${tail}`;\n }\n}\n\nexport { MPageOrderEvent };\n","import { NewOrderOpts } from './types';\n\nexport class MPageOrder {\n private _orderAction: string = '';\n getOrderAction = () => this._orderAction;\n\n private _orderId: number = 0;\n getOrderId = () => this._orderId;\n\n private _synonymId: number = 0;\n getSynonymId = () => this._synonymId;\n\n private _orderOrigination: number = 0;\n getOrderOrigination = () => this._orderOrigination;\n\n private _orderSentenceId: number = 0;\n getOrderSentenceId = () => this._orderSentenceId;\n\n private _nomenclatureId: number = 0;\n getNomenclatureId = () => this._nomenclatureId;\n\n private _signTimeInteraction: number = 0;\n getSignTimeInteraction = () => this._signTimeInteraction;\n\n /**\n * Creates a new MPageOrder with the order action 'ACTIVATE', which is the prototype for activating an existing future order.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willActivate(orderId: number) {\n this._orderAction = 'ACTIVATE';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL DC', which is the prototype for canceling and discontinuing an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelDiscontinue(orderId: number) {\n this._orderAction = 'CANCEL DC';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL REORD', which is the prototype for cancelling and reordering an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelReorder(orderId: number) {\n this._orderAction = 'CANCEL REORD';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CLEAR', which is the prototype for clearing actions of an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willClear(orderId: number) {\n this._orderAction = 'CLEAR';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_INPAT', which is the prototype for converting a prescription order into an inpatient order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertInpatient(orderId: number) {\n this._orderAction = 'CONVERT_INPAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_RX', which is the prototype for converting an inpatient order into a prescription.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertToPrescriptionOrder(orderId: number) {\n this._orderAction = 'CONVERT_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'MODIFY', which is the prototype for modifying an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willModify(orderId: number) {\n this._orderAction = 'MODIFY';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPage Order with order action 'ORDER'.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} synonymId The Cerner synonym_id to be associated with the new order. Must be set.\n * @param {NewOrderOpts} options required when making a new order\n * @returns {this} Returns itself to continue chaining method calls.\n * default to a normal order type.\n * @throws Error if `isRxOrder` and `isSatelliteOrder` are both set to true. These two are mutually exclusive and setting\n * both creates underfined behavior with respect the order origination field.\n * @example\n * m.willMakeNewOrder(34, true, 13, 42, true).toString() => \"{'ORDER'|34|5|1342|1}\"\n */\n\n willMakeNewOrder(synonymId: number, opts?: NewOrderOpts) {\n const {\n isRxOrder,\n isSatelliteOrder,\n orderSentenceId,\n nomenclatureId,\n skipInteractionCheckUntilSign,\n } = opts || {};\n\n if (isRxOrder && isSatelliteOrder)\n throw new Error('must select either isRxOrder or isSatelliteOrder');\n this._orderAction = 'ORDER';\n this._synonymId = synonymId;\n this._orderSentenceId = orderSentenceId || 0;\n this._nomenclatureId = nomenclatureId || 0;\n this._signTimeInteraction = skipInteractionCheckUntilSign ? 1 : 0;\n this._orderOrigination = isSatelliteOrder ? 5 : isRxOrder ? 1 : 0;\n\n return this;\n }\n\n /**\n * Creates a new MPageOrder with the order action 'RENEW', which is the prototype for reviewing an existing non-prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewNonPrescription(orderId: number) {\n this._orderAction = 'RENEW';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RENEW_RX', which is the prototype for renewing an existing prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewPrescription(orderId: number) {\n this._orderAction = 'RENEW_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'REPEAT', which is the prototype for copying an order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCopyExistingOrder(orderId: number) {\n this._orderAction = 'REPEAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RESUME', which is the prototype for resuming a suspended order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willResumeSuspendedOrder(orderId: number) {\n this._orderAction = 'RESUME';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'SUSPEND', which is the prototype for suspending an existing order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willSuspend(orderId: number) {\n this._orderAction = 'SUSPEND';\n this._orderId = orderId;\n return this;\n }\n\n /**\n * Overrides the toString() method for representing the objects internal state as a string.\n *\n * @since 0.1.0\n * @returns {string} string representation of MPageOrder's internal state\n */\n toString(): string {\n return this._orderAction === 'ORDER'\n ? `{${this._orderAction}|${this._synonymId}|${this._orderOrigination}|${this._orderSentenceId}|${this._nomenclatureId}|${this._signTimeInteraction}}`\n : `{${this._orderAction}|${this._orderId}}`;\n }\n}\n","import { CclOpts } from '../types';\n\n/**\n * A generic wrapper function for `XMLCclRequest` which simplifies it's use.\n * @param {CclOpts} opts - Required options for the CCL request.\n * @returns a promise of type `T` where `T` is the type or interface which represents\n * the resolved data from the CCL request.\n * @resolves the resolved data of type `T` from the CCL request.\n * @rejects with an error message if the CCL request fails.\n */\nexport function makeCclRequest<T>(opts: CclOpts): Promise<T> {\n const { prg, excludeMine, params } = opts;\n const paramsList =\n (excludeMine ? '' : \"'MINE',\") +\n params\n .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))\n .join(',');\n return new Promise((resolve, reject) => {\n try {\n // @ts-ignore - exists in PowerChart\n const request = new window.XMLCclRequest();\n request.open('GET', `${prg}`);\n request.send(paramsList);\n request.onreadystatechange = function() {\n if (request.readyState === 4 && request.status === 200) {\n const data: T = JSON.parse(request.responseText);\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${request.readyState} on ${prg} with params ${paramsList}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n"],"names":["MPageOrderEvent","_orders","tab","tabDisplayFlag","_tabList","_personId","_encounterId","_powerPlanFlag","_defaultDisplay","_silentSignFlag","customizeOrderListProfile","launchOrderProfile","forPerson","id","forEncounter","addOrders","orders","Array","isArray","concat","enablePowerPlans","customizeMedicationListProfile","enablePowerOrders","launchOrderSearch","launchOrdersForSignature","signSilently","send","window","MPAGES_EVENT","toString","e","ReferenceError","console","warn","head","body","forEach","order","tail","MPageOrder","_orderAction","_orderId","_synonymId","_orderOrigination","_orderSentenceId","_nomenclatureId","_signTimeInteraction","willActivate","orderId","willCancelDiscontinue","willCancelReorder","willClear","willConvertInpatient","willConvertToPrescriptionOrder","willModify","willMakeNewOrder","synonymId","opts","isRxOrder","isSatelliteOrder","orderSentenceId","nomenclatureId","skipInteractionCheckUntilSign","Error","willRenewNonPrescription","willRenewPrescription","willCopyExistingOrder","willResumeSuspendedOrder","willSuspend","makeCclRequest","prg","excludeMine","params","paramsList","map","type","param","join","Promise","resolve","reject","request","XMLCclRequest","open","onreadystatechange","readyState","status","data","JSON","parse","responseText"],"mappings":";;;;IAEMA;AAyBJ;;;AAvBA,kBAAA,GAAY;AAAA,aAAM,KAAI,CAACC,OAAX;AAAA,KAAZ;;AAEQ,iBAAA,GAAoD;AAC1DC,MAAAA,GAAG,EAAE,CADqD;AAE1DC,MAAAA,cAAc,EAAE;AAF0C,KAApD;;AAIR,mBAAA,GAAa;AAAA,aAAM,KAAI,CAACC,QAAX;AAAA,KAAb;;AAEQ,kBAAA,GAAoB,CAApB;;AACR,oBAAA,GAAc;AAAA,aAAM,KAAI,CAACC,SAAX;AAAA,KAAd;;AAEQ,qBAAA,GAAuB,CAAvB;;AACR,uBAAA,GAA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AGC,IAAH,QAAGA,IAAH;AAAA,QAASC,KAAT,QAASA,KAAT;AAAA,WAAsBD,IAAI,KAAK,QAAT,SAAwBC,KAAxB,SAAmCA,KAAzD;AAAA,GADP,EAEGC,IAFH,CAEQ,GAFR,CAFF;AAKA,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV;AACjB,QAAI;AACF;AACA,UAAMC,OAAO,GAAG,IAAItD,MAAM,CAACuD,aAAX,EAAhB;AACAD,MAAAA,OAAO,CAACE,IAAR,CAAa,KAAb,OAAuBb,GAAvB;AACAW,MAAAA,OAAO,CAACvD,IAAR,CAAa+C,UAAb;;AACAQ,MAAAA,OAAO,CAACG,kBAAR,GAA6B;AAC3B,YAAIH,OAAO,CAACI,UAAR,KAAuB,CAAvB,IAA4BJ,OAAO,CAACK,MAAR,KAAmB,GAAnD,EAAwD;AACtD,cAAMC,IAAI,GAAMC,IAAI,CAACC,KAAL,CAAWR,OAAO,CAACS,YAAnB,CAAhB;AACAX,UAAAA,OAAO,CAACQ,IAAD,CAAP;AACD,SAHD,MAGO;AACLP,UAAAA,MAAM,wBACiBC,OAAO,CAACK,MADzB,wBACkDL,OAAO,CAACI,UAD1D,YAC2Ef,GAD3E,qBAC8FG,UAD9F,CAAN;AAGD;AACF,OATD;AAUD,KAfD,CAeE,OAAO3C,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYC,cAAjB,EAAiC;AAC/BiD,QAAAA,MAAM,oEAC4DP,UAD5D,gBAC+EH,GAD/E,QAAN;AAGD,OAJD,MAIO;AACL,cAAMxC,CAAN;AACD;AACF;AACF,GAzBM,CAAP;AA0BD;;;;;;"}
1
+ {"version":3,"file":"fluent-cerner-js.cjs.development.js","sources":["../src/utils/index.ts","../src/MPageOrderEvent.ts","../src/MPageOrder.ts"],"sourcesContent":["/**\n * A type which represents the input parameter for an `XmlCclRequest`, which is wrapped by `makeCclRequest`.\n * The parameters are passed in a string, and numbers and strings are interpreted within this string by\n * the presence of quotes within quotes (e.g. single within double or vice versa). By strongly typing\n * the CclCallParam we can ensure that the parameters are always passed in a way that properly represents\n * their type.\n * @param {'string'|'number'} type - The type of the parameter.\n * @param {string} param - The string representing the parameters value.\n */\nexport type CclCallParam = {\n type: 'string' | 'number';\n param: string | number;\n};\n\n/**\n * A type which represents the full set of data required to make an XmlCclRequest, which is wrapped\n * by `makeCclRequest`.\n * @param {string} prg - The name of the CCL program to run, e.g. 12_USER_DETAILS.\n * @param {boolean?} excludeMine - Determines whether or not to include the \"MINE\" parameter as the\n * first parameter in the CCL call. This defaults to `false`, and almost all cases will require\n * the \"MINE\" parameter to be included.\n * @param {CclCallParam[]} params - An array of CclCallParam objects, each of which represents\n * a strongly typed parameter.\n */\nexport type CclOpts = {\n prg: string;\n excludeMine?: boolean;\n params: Array<CclCallParam>;\n};\n\n/**\n * A type functioning as a convience wrapper for several status\n * codes, respresented as strings, that are returned by XMLCclRequest.\n */\nexport type XmlCclStatus =\n | 'success'\n | 'method not allowed'\n | 'invalid state'\n | 'non-fatal error'\n | 'memory error'\n | 'internal server exception'\n | 'status refers to unknown error';\n\n/**\n * A type which represents the full set of data returned from an XmlCclRequest and important, formatted\n * metadata to help with debugging and error management. This is a generic type and data will represent\n * the type `T` which is the type or interface which represents the resolved data from the CCL request.\n */\nexport type CclRequestResponse<T> = {\n meta: {\n responseText: string;\n status: number;\n statusText: XmlCclStatus;\n };\n data: T | undefined;\n};\n\nconst statusCodeMap: Map<number, XmlCclStatus> = new Map();\nstatusCodeMap.set(200, 'success');\nstatusCodeMap.set(405, 'method not allowed');\nstatusCodeMap.set(409, 'invalid state');\nstatusCodeMap.set(492, 'non-fatal error');\nstatusCodeMap.set(493, 'memory error');\nstatusCodeMap.set(500, 'internal server exception');\n\n/**\n * A generic wrapper function for `XMLCclRequest` which simplifies it's use. Of note,\n * use of this requires the `head` of the HTML document contain the following\n * `meta` tag: `<META content='XMLCCLREQUEST' name='discern'>` so that it might\n * interface with the appropriate COM object.\n * @param {CclOpts} opts - Required options for the CCL request.\n * @returns a promise of type `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @resolves the `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @rejects with an error message if the CCL request fails.\n */\nexport function makeCclRequest<T>(\n opts: CclOpts\n): Promise<CclRequestResponse<T>> {\n const { prg, excludeMine, params } = opts;\n const paramsList =\n (excludeMine ? '' : \"'MINE',\") +\n params\n .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))\n .join(',');\n return new Promise((resolve, reject) => {\n try {\n // @ts-ignore - From Powerchart context\n const request: XMLCclRequest = window.XMLCclRequest();\n\n request.open('GET', `${prg}`);\n request.send(paramsList);\n request.onreadystatechange = function() {\n const data: CclRequestResponse<T> = {\n meta: {\n responseText: request.responseText,\n status: request.status,\n statusText:\n statusCodeMap.get(request.status) ||\n 'status refers to unknown error',\n },\n data:\n request.responseText === ''\n ? undefined\n : JSON.parse(request.responseText),\n };\n if (request.readyState === 4) {\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${\n request.readyState\n } on ${prg} with params ${paramsList} returning response text: ${request.responseText ||\n 'no response text'}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n\n/**\n * Attempts to open a tab with the name given to the `tab` variable in a\n * patients chart given in the context of a given encounter.\n * @param pid The patients person id.\n * @param eid The patients encounter id.\n * @param tab The string which represents the tab to open\n * (case insensitive). Navigation will be made to the first\n * upper-level tab in the chart that that matches the `tab` string\n * If no match is found, then sub-tab names will be searched and\n * navigation made to the first sub-tab that matches\n * the `tab` string. If no matches are found, no navigation will occur.\n * @param quickAdd {boolean} - If true, will attempt to open the window\n * in a quick add mode. E.g. if the Orders tab is connected to it will\n * attempt to launch the Add Order window so long as Enhanced Navigation is\n * supported by your installation.\n */\nexport function openPatientTab(\n pid: number,\n eid: number,\n tab: string,\n quickAdd: boolean\n): void {\n const args = `/PERSONID=${pid} /ENCNTRID=${eid} /FIRSTTAB=^${tab.toUpperCase()}${\n quickAdd ? '+' : ''\n }^`;\n\n try {\n window.APPLINK(1, '$APP_APPNAME$', args);\n } catch (e) {\n if (e instanceof ReferenceError) {\n console.warn(\n `We're likely not inside PowerChart. The input given would be: '1, \"$APP_NAME$\", ${args}'`\n );\n } else {\n throw e;\n }\n }\n}\n","import { MPageOrder } from '.';\n\nclass MPageOrderEvent {\n private _orders: Array<MPageOrder>;\n getOrders = () => this._orders;\n\n private _tabList: { tab: number; tabDisplayFlag: number } = {\n tab: 0,\n tabDisplayFlag: 0,\n };\n getTabList = () => this._tabList;\n\n private _personId: number = 0;\n getPersonId = () => this._personId;\n\n private _encounterId: number = 0;\n getEncounterId = () => this._encounterId;\n\n private _powerPlanFlag: number = 0;\n getPowerPlanFlag = () => this._powerPlanFlag;\n\n private _defaultDisplay: number = 0;\n getDefaultDisplay = () => this._defaultDisplay;\n\n private _silentSignFlag: number = 0;\n getSilentSignFlag = () => this._silentSignFlag;\n\n constructor() {\n this._orders = [];\n this._tabList = { tab: 0, tabDisplayFlag: 0 };\n // Disable PowerPlans by default\n this._powerPlanFlag = 0;\n // Disable PowerOrders by default\n this._tabList.tabDisplayFlag = 0;\n this.customizeOrderListProfile();\n this.launchOrderProfile();\n // Do NOT sign silently by default\n this._silentSignFlag = 0;\n }\n\n forPerson(id: number) {\n this._personId = id;\n return this;\n }\n\n forEncounter(id: number) {\n this._encounterId = id;\n return this;\n }\n\n addOrders(orders: Array<MPageOrder> | MPageOrder) {\n if (!Array.isArray(orders)) {\n orders = [orders];\n }\n this._orders = this._orders.concat(orders);\n return this;\n }\n\n enablePowerPlans() {\n this._powerPlanFlag = 24;\n return this;\n }\n\n customizeOrderListProfile() {\n this._tabList.tab = 2;\n return this;\n }\n\n customizeMedicationListProfile() {\n this._tabList.tab = 3;\n return this;\n }\n\n enablePowerOrders() {\n this._tabList.tabDisplayFlag = 127;\n return this;\n }\n\n launchOrderSearch() {\n this._defaultDisplay = 8;\n return this;\n }\n\n launchOrderProfile() {\n this._defaultDisplay = 16;\n return this;\n }\n\n launchOrdersForSignature() {\n this._defaultDisplay = 32;\n return this;\n }\n\n signSilently() {\n this._silentSignFlag = 1;\n return this;\n }\n\n send() {\n try {\n window.MPAGES_EVENT('ORDERS', this.toString());\n } catch (e) {\n if (e instanceof ReferenceError) {\n console.warn(\n `We're likely not inside PowerChart. The output would be an MPAGES_EVENT: ${this.toString()}`\n );\n } else {\n throw e;\n }\n }\n }\n\n toString(): string {\n const head = `${this._personId}|${this._encounterId}|`;\n let body: string = '';\n this._orders.forEach(order => {\n body += order.toString();\n });\n const tail = `|${this._powerPlanFlag}|{${this._tabList.tab}|${this._tabList.tabDisplayFlag}}|${this._defaultDisplay}|${this._silentSignFlag}`;\n\n return `${head}${body}${tail}`;\n }\n}\n\nexport { MPageOrderEvent };\n","/**\n * Options for a new order\n * @param {boolean} isRxOrder Marks the order order as a prescription. Is mutually exclusive from\n * isSatelliteOrder. Field will be set to false if left undefined; this resolves to 0 when built.\n * @param {boolean} isSatelliteOrder Moarks the order origination as satellite. Is mutually\n * exclusive from isRxOrder. Field will be set to false if left undefined; this resolves to 0 when built.\n * @param {number} orderSentenceId The optional Cerner order_sentence_id to be associated with\n * the new order. Field will be set to 0 if undefined.\n * @param {number} nomenclatureId The optional Cerner nomenclature_id to be associated with the\n * new order. Field will be set to 0 if undefined.\n * @param {boolean} skipInteractionCheckUntilSign Determines cerner sign-time interaction\n * checking. A value of true skips checking for interactions until orders are signed, false\n * will not. Field will be set to false if left undefined; this resolves to 0 when built.\n */\nexport type NewOrderOpts = {\n isRxOrder?: boolean;\n isSatelliteOrder?: boolean;\n orderSentenceId?: number;\n nomenclatureId?: number;\n skipInteractionCheckUntilSign?: boolean;\n};\n\nexport class MPageOrder {\n private _orderAction: string = '';\n getOrderAction = () => this._orderAction;\n\n private _orderId: number = 0;\n getOrderId = () => this._orderId;\n\n private _synonymId: number = 0;\n getSynonymId = () => this._synonymId;\n\n private _orderOrigination: number = 0;\n getOrderOrigination = () => this._orderOrigination;\n\n private _orderSentenceId: number = 0;\n getOrderSentenceId = () => this._orderSentenceId;\n\n private _nomenclatureId: number = 0;\n getNomenclatureId = () => this._nomenclatureId;\n\n private _signTimeInteraction: number = 0;\n getSignTimeInteraction = () => this._signTimeInteraction;\n\n /**\n * Creates a new MPageOrder with the order action 'ACTIVATE', which is the prototype for activating an existing future order.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willActivate(orderId: number) {\n this._orderAction = 'ACTIVATE';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL DC', which is the prototype for canceling and discontinuing an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelDiscontinue(orderId: number) {\n this._orderAction = 'CANCEL DC';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL REORD', which is the prototype for cancelling and reordering an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelReorder(orderId: number) {\n this._orderAction = 'CANCEL REORD';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CLEAR', which is the prototype for clearing actions of an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willClear(orderId: number) {\n this._orderAction = 'CLEAR';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_INPAT', which is the prototype for converting a prescription order into an inpatient order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertInpatient(orderId: number) {\n this._orderAction = 'CONVERT_INPAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_RX', which is the prototype for converting an inpatient order into a prescription.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertToPrescriptionOrder(orderId: number) {\n this._orderAction = 'CONVERT_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'MODIFY', which is the prototype for modifying an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willModify(orderId: number) {\n this._orderAction = 'MODIFY';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPage Order with order action 'ORDER'.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} synonymId The Cerner synonym_id to be associated with the new order. Must be set.\n * @param {NewOrderOpts} options required when making a new order\n * @returns {this} Returns itself to continue chaining method calls.\n * default to a normal order type.\n * @throws Error if `isRxOrder` and `isSatelliteOrder` are both set to true. These two are mutually exclusive and setting\n * both creates underfined behavior with respect the order origination field.\n * @example\n * m.willMakeNewOrder(34, true, 13, 42, true).toString() => \"{'ORDER'|34|5|1342|1}\"\n */\n\n willMakeNewOrder(synonymId: number, opts?: NewOrderOpts) {\n const {\n isRxOrder,\n isSatelliteOrder,\n orderSentenceId,\n nomenclatureId,\n skipInteractionCheckUntilSign,\n } = opts || {};\n\n if (isRxOrder && isSatelliteOrder)\n throw new Error('must select either isRxOrder or isSatelliteOrder');\n this._orderAction = 'ORDER';\n this._synonymId = synonymId;\n this._orderSentenceId = orderSentenceId || 0;\n this._nomenclatureId = nomenclatureId || 0;\n this._signTimeInteraction = skipInteractionCheckUntilSign ? 1 : 0;\n this._orderOrigination = isSatelliteOrder ? 5 : isRxOrder ? 1 : 0;\n\n return this;\n }\n\n /**\n * Creates a new MPageOrder with the order action 'RENEW', which is the prototype for reviewing an existing non-prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewNonPrescription(orderId: number) {\n this._orderAction = 'RENEW';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RENEW_RX', which is the prototype for renewing an existing prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewPrescription(orderId: number) {\n this._orderAction = 'RENEW_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'REPEAT', which is the prototype for copying an order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCopyExistingOrder(orderId: number) {\n this._orderAction = 'REPEAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RESUME', which is the prototype for resuming a suspended order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willResumeSuspendedOrder(orderId: number) {\n this._orderAction = 'RESUME';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'SUSPEND', which is the prototype for suspending an existing order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willSuspend(orderId: number) {\n this._orderAction = 'SUSPEND';\n this._orderId = orderId;\n return this;\n }\n\n /**\n * Overrides the toString() method for representing the objects internal state as a string.\n *\n * @since 0.1.0\n * @returns {string} string representation of MPageOrder's internal state\n */\n toString(): string {\n return this._orderAction === 'ORDER'\n ? `{${this._orderAction}|${this._synonymId}|${this._orderOrigination}|${this._orderSentenceId}|${this._nomenclatureId}|${this._signTimeInteraction}}`\n : `{${this._orderAction}|${this._orderId}}`;\n }\n}\n"],"names":["statusCodeMap","Map","set","makeCclRequest","opts","prg","excludeMine","params","paramsList","map","type","param","join","Promise","resolve","reject","request","window","XMLCclRequest","open","send","onreadystatechange","data","meta","responseText","status","statusText","get","undefined","JSON","parse","readyState","e","ReferenceError","openPatientTab","pid","eid","tab","quickAdd","args","toUpperCase","APPLINK","console","warn","MPageOrderEvent","_orders","tabDisplayFlag","_tabList","_personId","_encounterId","_powerPlanFlag","_defaultDisplay","_silentSignFlag","customizeOrderListProfile","launchOrderProfile","forPerson","id","forEncounter","addOrders","orders","Array","isArray","concat","enablePowerPlans","customizeMedicationListProfile","enablePowerOrders","launchOrderSearch","launchOrdersForSignature","signSilently","MPAGES_EVENT","toString","head","body","forEach","order","tail","MPageOrder","_orderAction","_orderId","_synonymId","_orderOrigination","_orderSentenceId","_nomenclatureId","_signTimeInteraction","willActivate","orderId","willCancelDiscontinue","willCancelReorder","willClear","willConvertInpatient","willConvertToPrescriptionOrder","willModify","willMakeNewOrder","synonymId","isRxOrder","isSatelliteOrder","orderSentenceId","nomenclatureId","skipInteractionCheckUntilSign","Error","willRenewNonPrescription","willRenewPrescription","willCopyExistingOrder","willResumeSuspendedOrder","willSuspend"],"mappings":";;;;AAyDA,IAAMA,aAAa,gBAA8B,IAAIC,GAAJ,EAAjD;AACAD,aAAa,CAACE,GAAd,CAAkB,GAAlB,EAAuB,SAAvB;AACAF,aAAa,CAACE,GAAd,CAAkB,GAAlB,EAAuB,oBAAvB;AACAF,aAAa,CAACE,GAAd,CAAkB,GAAlB,EAAuB,eAAvB;AACAF,aAAa,CAACE,GAAd,CAAkB,GAAlB,EAAuB,iBAAvB;AACAF,aAAa,CAACE,GAAd,CAAkB,GAAlB,EAAu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KR,YAAL,GAAoB,OAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AACD;;;;;;;AA3JF;;AAAA,SAkKEgB,qBAlKF,GAkKE,+BAAsBhB,OAAtB;AACE,SAAKR,YAAL,GAAoB,UAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AACD;;;;;;;AAvKF;;AAAA,SA8KEiB,qBA9KF,GA8KE,+BAAsBjB,OAAtB;AACE,SAAKR,YAAL,GAAoB,QAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AACD;;;;;;;AAnLF;;AAAA,SA0LEkB,wBA1LF,GA0LE,kCAAyBlB,OAAzB;AACE,SAAKR,YAAL,GAAoB,QAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AACD;;;;;;;AA/LF;;AAAA,SAsMEmB,WAtMF,GAsME,qBAAYnB,OAAZ;AACE,SAAKR,YAAL,GAAoB,SAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AAED;;;;;;AA5MF;;AAAA,SAkNEf,QAlNF,GAkNE;AACE,WAAO,KAAKO,YAAL,KAAsB,OAAtB,SACC,KAAKA,YADN,SACsB,KAAKE,UAD3B,SACyC,KAAKC,iBAD9C,SACmE,KAAKC,gBADxE,SAC4F,KAAKC,eADjG,SACoH,KAAKC,oBADzH,eAEC,KAAKN,YAFN,SAEsB,KAAKC,QAF3B,MAAP;AAGD,GAtNH;;AAAA;AAAA;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(){var t=this;this.getOrders=function(){return t._orders},this._tabList={tab:0,tabDisplayFlag:0},this.getTabList=function(){return t._tabList},this._personId=0,this.getPersonId=function(){return t._personId},this._encounterId=0,this.getEncounterId=function(){return t._encounterId},this._powerPlanFlag=0,this.getPowerPlanFlag=function(){return t._powerPlanFlag},this._defaultDisplay=0,this.getDefaultDisplay=function(){return t._defaultDisplay},this._silentSignFlag=0,this.getSilentSignFlag=function(){return t._silentSignFlag},this._orders=[],this._tabList={tab:0,tabDisplayFlag:0},this._powerPlanFlag=0,this._tabList.tabDisplayFlag=0,this.customizeOrderListProfile(),this.launchOrderProfile(),this._silentSignFlag=0}var r=t.prototype;return r.forPerson=function(t){return this._personId=t,this},r.forEncounter=function(t){return this._encounterId=t,this},r.addOrders=function(t){return Array.isArray(t)||(t=[t]),this._orders=this._orders.concat(t),this},r.enablePowerPlans=function(){return this._powerPlanFlag=24,this},r.customizeOrderListProfile=function(){return this._tabList.tab=2,this},r.customizeMedicationListProfile=function(){return this._tabList.tab=3,this},r.enablePowerOrders=function(){return this._tabList.tabDisplayFlag=127,this},r.launchOrderSearch=function(){return this._defaultDisplay=8,this},r.launchOrderProfile=function(){return this._defaultDisplay=16,this},r.launchOrdersForSignature=function(){return this._defaultDisplay=32,this},r.signSilently=function(){return this._silentSignFlag=1,this},r.send=function(){try{window.MPAGES_EVENT("ORDERS",this.toString())}catch(t){if(!(t instanceof ReferenceError))throw t;console.warn("We're likely not inside PowerChart. The output would be an MPAGES_EVENT: "+this.toString())}},r.toString=function(){var t=this._personId+"|"+this._encounterId+"|",r="";return this._orders.forEach((function(t){r+=t.toString()})),""+t+r+"|"+this._powerPlanFlag+"|{"+this._tabList.tab+"|"+this._tabList.tabDisplayFlag+"}|"+this._defaultDisplay+"|"+this._silentSignFlag},t}();exports.MPageOrder=function(){function t(){var t=this;this._orderAction="",this.getOrderAction=function(){return t._orderAction},this._orderId=0,this.getOrderId=function(){return t._orderId},this._synonymId=0,this.getSynonymId=function(){return t._synonymId},this._orderOrigination=0,this.getOrderOrigination=function(){return t._orderOrigination},this._orderSentenceId=0,this.getOrderSentenceId=function(){return t._orderSentenceId},this._nomenclatureId=0,this.getNomenclatureId=function(){return t._nomenclatureId},this._signTimeInteraction=0,this.getSignTimeInteraction=function(){return t._signTimeInteraction}}var r=t.prototype;return r.willActivate=function(t){return this._orderAction="ACTIVATE",this._orderId=t,this},r.willCancelDiscontinue=function(t){return this._orderAction="CANCEL DC",this._orderId=t,this},r.willCancelReorder=function(t){return this._orderAction="CANCEL REORD",this._orderId=t,this},r.willClear=function(t){return this._orderAction="CLEAR",this._orderId=t,this},r.willConvertInpatient=function(t){return this._orderAction="CONVERT_INPAT",this._orderId=t,this},r.willConvertToPrescriptionOrder=function(t){return this._orderAction="CONVERT_RX",this._orderId=t,this},r.willModify=function(t){return this._orderAction="MODIFY",this._orderId=t,this},r.willMakeNewOrder=function(t,r){var i=r||{},e=i.isRxOrder,n=i.isSatelliteOrder,s=i.orderSentenceId,o=i.nomenclatureId,a=i.skipInteractionCheckUntilSign;if(e&&n)throw new Error("must select either isRxOrder or isSatelliteOrder");return this._orderAction="ORDER",this._synonymId=t,this._orderSentenceId=s||0,this._nomenclatureId=o||0,this._signTimeInteraction=a?1:0,this._orderOrigination=n?5:e?1:0,this},r.willRenewNonPrescription=function(t){return this._orderAction="RENEW",this._orderId=t,this},r.willRenewPrescription=function(t){return this._orderAction="RENEW_RX",this._orderId=t,this},r.willCopyExistingOrder=function(t){return this._orderAction="REPEAT",this._orderId=t,this},r.willResumeSuspendedOrder=function(t){return this._orderAction="RESUME",this._orderId=t,this},r.willSuspend=function(t){return this._orderAction="SUSPEND",this._orderId=t,this},r.toString=function(){return"ORDER"===this._orderAction?"{"+this._orderAction+"|"+this._synonymId+"|"+this._orderOrigination+"|"+this._orderSentenceId+"|"+this._nomenclatureId+"|"+this._signTimeInteraction+"}":"{"+this._orderAction+"|"+this._orderId+"}"},t}(),exports.MPageOrderEvent=t,exports.makeCclRequest=function(t){var r=t.prg,i=(t.excludeMine?"":"'MINE',")+t.params.map((function(t){var r=t.param;return"string"===t.type?"'"+r+"'":r})).join(",");return new Promise((function(t,e){try{var n=new window.XMLCclRequest;n.open("GET",""+r),n.send(i),n.onreadystatechange=function(){if(4===n.readyState&&200===n.status){var s=JSON.parse(n.responseText);t(s)}else e("error with status "+n.status+" and readyState "+n.readyState+" on "+r+" with params "+i)}}catch(t){if(!(t instanceof ReferenceError))throw t;e("We're likely not inside PowerChart. We cannot send request: \""+i+'" to "'+r+'"')}}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=new Map;t.set(200,"success"),t.set(405,"method not allowed"),t.set(409,"invalid state"),t.set(492,"non-fatal error"),t.set(493,"memory error"),t.set(500,"internal server exception");var r=function(){function t(){var t=this;this.getOrders=function(){return t._orders},this._tabList={tab:0,tabDisplayFlag:0},this.getTabList=function(){return t._tabList},this._personId=0,this.getPersonId=function(){return t._personId},this._encounterId=0,this.getEncounterId=function(){return t._encounterId},this._powerPlanFlag=0,this.getPowerPlanFlag=function(){return t._powerPlanFlag},this._defaultDisplay=0,this.getDefaultDisplay=function(){return t._defaultDisplay},this._silentSignFlag=0,this.getSilentSignFlag=function(){return t._silentSignFlag},this._orders=[],this._tabList={tab:0,tabDisplayFlag:0},this._powerPlanFlag=0,this._tabList.tabDisplayFlag=0,this.customizeOrderListProfile(),this.launchOrderProfile(),this._silentSignFlag=0}var r=t.prototype;return r.forPerson=function(t){return this._personId=t,this},r.forEncounter=function(t){return this._encounterId=t,this},r.addOrders=function(t){return Array.isArray(t)||(t=[t]),this._orders=this._orders.concat(t),this},r.enablePowerPlans=function(){return this._powerPlanFlag=24,this},r.customizeOrderListProfile=function(){return this._tabList.tab=2,this},r.customizeMedicationListProfile=function(){return this._tabList.tab=3,this},r.enablePowerOrders=function(){return this._tabList.tabDisplayFlag=127,this},r.launchOrderSearch=function(){return this._defaultDisplay=8,this},r.launchOrderProfile=function(){return this._defaultDisplay=16,this},r.launchOrdersForSignature=function(){return this._defaultDisplay=32,this},r.signSilently=function(){return this._silentSignFlag=1,this},r.send=function(){try{window.MPAGES_EVENT("ORDERS",this.toString())}catch(t){if(!(t instanceof ReferenceError))throw t;console.warn("We're likely not inside PowerChart. The output would be an MPAGES_EVENT: "+this.toString())}},r.toString=function(){var t=this._personId+"|"+this._encounterId+"|",r="";return this._orders.forEach((function(t){r+=t.toString()})),""+t+r+"|"+this._powerPlanFlag+"|{"+this._tabList.tab+"|"+this._tabList.tabDisplayFlag+"}|"+this._defaultDisplay+"|"+this._silentSignFlag},t}();exports.MPageOrder=function(){function t(){var t=this;this._orderAction="",this.getOrderAction=function(){return t._orderAction},this._orderId=0,this.getOrderId=function(){return t._orderId},this._synonymId=0,this.getSynonymId=function(){return t._synonymId},this._orderOrigination=0,this.getOrderOrigination=function(){return t._orderOrigination},this._orderSentenceId=0,this.getOrderSentenceId=function(){return t._orderSentenceId},this._nomenclatureId=0,this.getNomenclatureId=function(){return t._nomenclatureId},this._signTimeInteraction=0,this.getSignTimeInteraction=function(){return t._signTimeInteraction}}var r=t.prototype;return r.willActivate=function(t){return this._orderAction="ACTIVATE",this._orderId=t,this},r.willCancelDiscontinue=function(t){return this._orderAction="CANCEL DC",this._orderId=t,this},r.willCancelReorder=function(t){return this._orderAction="CANCEL REORD",this._orderId=t,this},r.willClear=function(t){return this._orderAction="CLEAR",this._orderId=t,this},r.willConvertInpatient=function(t){return this._orderAction="CONVERT_INPAT",this._orderId=t,this},r.willConvertToPrescriptionOrder=function(t){return this._orderAction="CONVERT_RX",this._orderId=t,this},r.willModify=function(t){return this._orderAction="MODIFY",this._orderId=t,this},r.willMakeNewOrder=function(t,r){var e=r||{},n=e.isRxOrder,i=e.isSatelliteOrder,s=e.orderSentenceId,o=e.nomenclatureId,a=e.skipInteractionCheckUntilSign;if(n&&i)throw new Error("must select either isRxOrder or isSatelliteOrder");return this._orderAction="ORDER",this._synonymId=t,this._orderSentenceId=s||0,this._nomenclatureId=o||0,this._signTimeInteraction=a?1:0,this._orderOrigination=i?5:n?1:0,this},r.willRenewNonPrescription=function(t){return this._orderAction="RENEW",this._orderId=t,this},r.willRenewPrescription=function(t){return this._orderAction="RENEW_RX",this._orderId=t,this},r.willCopyExistingOrder=function(t){return this._orderAction="REPEAT",this._orderId=t,this},r.willResumeSuspendedOrder=function(t){return this._orderAction="RESUME",this._orderId=t,this},r.willSuspend=function(t){return this._orderAction="SUSPEND",this._orderId=t,this},r.toString=function(){return"ORDER"===this._orderAction?"{"+this._orderAction+"|"+this._synonymId+"|"+this._orderOrigination+"|"+this._orderSentenceId+"|"+this._nomenclatureId+"|"+this._signTimeInteraction+"}":"{"+this._orderAction+"|"+this._orderId+"}"},t}(),exports.MPageOrderEvent=r,exports.makeCclRequest=function(r){var e=r.prg,n=(r.excludeMine?"":"'MINE',")+r.params.map((function(t){var r=t.param;return"string"===t.type?"'"+r+"'":r})).join(",");return new Promise((function(r,i){try{var s=window.XMLCclRequest();s.open("GET",""+e),s.send(n),s.onreadystatechange=function(){var o={meta:{responseText:s.responseText,status:s.status,statusText:t.get(s.status)||"status refers to unknown error"},data:""===s.responseText?void 0:JSON.parse(s.responseText)};4===s.readyState?r(o):i("error with status "+s.status+" and readyState "+s.readyState+" on "+e+" with params "+n+" returning response text: "+(s.responseText||"no response text"))}}catch(t){if(!(t instanceof ReferenceError))throw t;i("We're likely not inside PowerChart. We cannot send request: \""+n+'" to "'+e+'"')}}))},exports.openPatientTab=function(t,r,e,n){var i="/PERSONID="+t+" /ENCNTRID="+r+" /FIRSTTAB=^"+e.toUpperCase()+(n?"+":"")+"^";try{window.APPLINK(1,"$APP_APPNAME$",i)}catch(t){if(!(t instanceof ReferenceError))throw t;console.warn("We're likely not inside PowerChart. The input given would be: '1, \"$APP_NAME$\", "+i+"'")}};
2
2
  //# sourceMappingURL=fluent-cerner-js.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fluent-cerner-js.cjs.production.min.js","sources":["../src/MPageOrderEvent.ts","../src/MPageOrder.ts","../src/utils/index.ts"],"sourcesContent":["import { MPageOrder } from '.';\n\nclass MPageOrderEvent {\n private _orders: Array<MPageOrder>;\n getOrders = () => this._orders;\n\n private _tabList: { tab: number; tabDisplayFlag: number } = {\n tab: 0,\n tabDisplayFlag: 0,\n };\n getTabList = () => this._tabList;\n\n private _personId: number = 0;\n getPersonId = () => this._personId;\n\n private _encounterId: number = 0;\n getEncounterId = () => this._encounterId;\n\n private _powerPlanFlag: number = 0;\n getPowerPlanFlag = () => this._powerPlanFlag;\n\n private _defaultDisplay: number = 0;\n getDefaultDisplay = () => this._defaultDisplay;\n\n private _silentSignFlag: number = 0;\n getSilentSignFlag = () => this._silentSignFlag;\n\n constructor() {\n this._orders = [];\n this._tabList = { tab: 0, tabDisplayFlag: 0 };\n // Disable PowerPlans by default\n this._powerPlanFlag = 0;\n // Disable PowerOrders by default\n this._tabList.tabDisplayFlag = 0;\n this.customizeOrderListProfile();\n this.launchOrderProfile();\n // Do NOT sign silently by default\n this._silentSignFlag = 0;\n }\n\n forPerson(id: number) {\n this._personId = id;\n return this;\n }\n\n forEncounter(id: number) {\n this._encounterId = id;\n return this;\n }\n\n addOrders(orders: Array<MPageOrder> | MPageOrder) {\n if (!Array.isArray(orders)) {\n orders = [orders];\n }\n this._orders = this._orders.concat(orders);\n return this;\n }\n\n enablePowerPlans() {\n this._powerPlanFlag = 24;\n return this;\n }\n\n customizeOrderListProfile() {\n this._tabList.tab = 2;\n return this;\n }\n\n customizeMedicationListProfile() {\n this._tabList.tab = 3;\n return this;\n }\n\n enablePowerOrders() {\n this._tabList.tabDisplayFlag = 127;\n return this;\n }\n\n launchOrderSearch() {\n this._defaultDisplay = 8;\n return this;\n }\n\n launchOrderProfile() {\n this._defaultDisplay = 16;\n return this;\n }\n\n launchOrdersForSignature() {\n this._defaultDisplay = 32;\n return this;\n }\n\n signSilently() {\n this._silentSignFlag = 1;\n return this;\n }\n\n send() {\n try {\n // @ts-ignore\n window.MPAGES_EVENT('ORDERS', this.toString());\n } catch (e) {\n if (e instanceof ReferenceError) {\n console.warn(\n `We're likely not inside PowerChart. The output would be an MPAGES_EVENT: ${this.toString()}`\n );\n } else {\n throw e;\n }\n }\n }\n\n toString(): string {\n const head = `${this._personId}|${this._encounterId}|`;\n let body: string = '';\n this._orders.forEach(order => {\n body += order.toString();\n });\n const tail = `|${this._powerPlanFlag}|{${this._tabList.tab}|${this._tabList.tabDisplayFlag}}|${this._defaultDisplay}|${this._silentSignFlag}`;\n\n return `${head}${body}${tail}`;\n }\n}\n\nexport { MPageOrderEvent };\n","import { NewOrderOpts } from './types';\n\nexport class MPageOrder {\n private _orderAction: string = '';\n getOrderAction = () => this._orderAction;\n\n private _orderId: number = 0;\n getOrderId = () => this._orderId;\n\n private _synonymId: number = 0;\n getSynonymId = () => this._synonymId;\n\n private _orderOrigination: number = 0;\n getOrderOrigination = () => this._orderOrigination;\n\n private _orderSentenceId: number = 0;\n getOrderSentenceId = () => this._orderSentenceId;\n\n private _nomenclatureId: number = 0;\n getNomenclatureId = () => this._nomenclatureId;\n\n private _signTimeInteraction: number = 0;\n getSignTimeInteraction = () => this._signTimeInteraction;\n\n /**\n * Creates a new MPageOrder with the order action 'ACTIVATE', which is the prototype for activating an existing future order.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willActivate(orderId: number) {\n this._orderAction = 'ACTIVATE';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL DC', which is the prototype for canceling and discontinuing an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelDiscontinue(orderId: number) {\n this._orderAction = 'CANCEL DC';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL REORD', which is the prototype for cancelling and reordering an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelReorder(orderId: number) {\n this._orderAction = 'CANCEL REORD';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CLEAR', which is the prototype for clearing actions of an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willClear(orderId: number) {\n this._orderAction = 'CLEAR';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_INPAT', which is the prototype for converting a prescription order into an inpatient order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertInpatient(orderId: number) {\n this._orderAction = 'CONVERT_INPAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_RX', which is the prototype for converting an inpatient order into a prescription.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertToPrescriptionOrder(orderId: number) {\n this._orderAction = 'CONVERT_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'MODIFY', which is the prototype for modifying an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willModify(orderId: number) {\n this._orderAction = 'MODIFY';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPage Order with order action 'ORDER'.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} synonymId The Cerner synonym_id to be associated with the new order. Must be set.\n * @param {NewOrderOpts} options required when making a new order\n * @returns {this} Returns itself to continue chaining method calls.\n * default to a normal order type.\n * @throws Error if `isRxOrder` and `isSatelliteOrder` are both set to true. These two are mutually exclusive and setting\n * both creates underfined behavior with respect the order origination field.\n * @example\n * m.willMakeNewOrder(34, true, 13, 42, true).toString() => \"{'ORDER'|34|5|1342|1}\"\n */\n\n willMakeNewOrder(synonymId: number, opts?: NewOrderOpts) {\n const {\n isRxOrder,\n isSatelliteOrder,\n orderSentenceId,\n nomenclatureId,\n skipInteractionCheckUntilSign,\n } = opts || {};\n\n if (isRxOrder && isSatelliteOrder)\n throw new Error('must select either isRxOrder or isSatelliteOrder');\n this._orderAction = 'ORDER';\n this._synonymId = synonymId;\n this._orderSentenceId = orderSentenceId || 0;\n this._nomenclatureId = nomenclatureId || 0;\n this._signTimeInteraction = skipInteractionCheckUntilSign ? 1 : 0;\n this._orderOrigination = isSatelliteOrder ? 5 : isRxOrder ? 1 : 0;\n\n return this;\n }\n\n /**\n * Creates a new MPageOrder with the order action 'RENEW', which is the prototype for reviewing an existing non-prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewNonPrescription(orderId: number) {\n this._orderAction = 'RENEW';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RENEW_RX', which is the prototype for renewing an existing prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewPrescription(orderId: number) {\n this._orderAction = 'RENEW_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'REPEAT', which is the prototype for copying an order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCopyExistingOrder(orderId: number) {\n this._orderAction = 'REPEAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RESUME', which is the prototype for resuming a suspended order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willResumeSuspendedOrder(orderId: number) {\n this._orderAction = 'RESUME';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'SUSPEND', which is the prototype for suspending an existing order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willSuspend(orderId: number) {\n this._orderAction = 'SUSPEND';\n this._orderId = orderId;\n return this;\n }\n\n /**\n * Overrides the toString() method for representing the objects internal state as a string.\n *\n * @since 0.1.0\n * @returns {string} string representation of MPageOrder's internal state\n */\n toString(): string {\n return this._orderAction === 'ORDER'\n ? `{${this._orderAction}|${this._synonymId}|${this._orderOrigination}|${this._orderSentenceId}|${this._nomenclatureId}|${this._signTimeInteraction}}`\n : `{${this._orderAction}|${this._orderId}}`;\n }\n}\n","import { CclOpts } from '../types';\n\n/**\n * A generic wrapper function for `XMLCclRequest` which simplifies it's use.\n * @param {CclOpts} opts - Required options for the CCL request.\n * @returns a promise of type `T` where `T` is the type or interface which represents\n * the resolved data from the CCL request.\n * @resolves the resolved data of type `T` from the CCL request.\n * @rejects with an error message if the CCL request fails.\n */\nexport function makeCclRequest<T>(opts: CclOpts): Promise<T> {\n const { prg, excludeMine, params } = opts;\n const paramsList =\n (excludeMine ? '' : \"'MINE',\") +\n params\n .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))\n .join(',');\n return new Promise((resolve, reject) => {\n try {\n // @ts-ignore - exists in PowerChart\n const request = new window.XMLCclRequest();\n request.open('GET', `${prg}`);\n request.send(paramsList);\n request.onreadystatechange = function() {\n if (request.readyState === 4 && request.status === 200) {\n const data: T = JSON.parse(request.responseText);\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${request.readyState} on ${prg} with params ${paramsList}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n"],"names":["MPageOrderEvent","_this","_orders","tab","tabDisplayFlag","_tabList","_personId","_encounterId","_powerPlanFlag","_defaultDisplay","_silentSignFlag","customizeOrderListProfile","launchOrderProfile","forPerson","id","this","forEncounter","addOrders","orders","Array","isArray","concat","enablePowerPlans","customizeMedicationListProfile","enablePowerOrders","launchOrderSearch","launchOrdersForSignature","signSilently","send","window","MPAGES_EVENT","toString","e","ReferenceError","console","warn","head","body","forEach","order","_orderAction","_orderId","_synonymId","_orderOrigination","_orderSentenceId","_nomenclatureId","_signTimeInteraction","willActivate","orderId","willCancelDiscontinue","willCancelReorder","willClear","willConvertInpatient","willConvertToPrescriptionOrder","willModify","willMakeNewOrder","synonymId","opts","isRxOrder","isSatelliteOrder","orderSentenceId","nomenclatureId","skipInteractionCheckUntilSign","Error","willRenewNonPrescription","willRenewPrescription","willCopyExistingOrder","willResumeSuspendedOrder","willSuspend","prg","paramsList","excludeMine","params","map","param","type","join","Promise","resolve","reject","request","XMLCclRequest","open","onreadystatechange","readyState","status","data","JSON","parse","responseText"],"mappings":"wEAEMA,oDAEQ,kBAAMC,EAAKC,uBAEqC,CAC1DC,IAAK,EACLC,eAAgB,mBAEL,kBAAMH,EAAKI,yBAEI,mBACd,kBAAMJ,EAAKK,6BAEM,sBACd,kBAAML,EAAKM,kCAEK,wBACd,kBAAMN,EAAKO,qCAEI,yBACd,kBAAMP,EAAKQ,sCAEG,yBACd,kBAAMR,EAAKS,sBAGxBR,QAAU,QACVG,SAAW,CAAEF,IAAK,EAAGC,eAAgB,QAErCI,eAAiB,OAEjBH,SAASD,eAAiB,OAC1BO,iCACAC,0BAEAF,gBAAkB,6BAGzBG,UAAA,SAAUC,eACHR,UAAYQ,EACVC,QAGTC,aAAA,SAAaF,eACNP,aAAeO,EACbC,QAGTE,UAAA,SAAUC,UACHC,MAAMC,QAAQF,KACjBA,EAAS,CAACA,SAEPhB,QAAUa,KAAKb,QAAQmB,OAAOH,GAC5BH,QAGTO,iBAAA,uBACOd,eAAiB,GACfO,QAGTJ,0BAAA,uBACON,SAASF,IAAM,EACbY,QAGTQ,+BAAA,uBACOlB,SAASF,IAAM,EACbY,QAGTS,kBAAA,uBACOnB,SAASD,eAAiB,IACxBW,QAGTU,kBAAA,uBACOhB,gBAAkB,EAChBM,QAGTH,mBAAA,uBACOH,gBAAkB,GAChBM,QAGTW,yBAAA,uBACOjB,gBAAkB,GAChBM,Q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BAAuBgB,EAAgC,EAAI,OAC3DnB,kBAAoBgB,EAAmB,EAAID,EAAY,EAAI,EAEzD3C,QAUTiD,yBAAA,SAAyBhB,eAClBR,aAAe,aACfC,SAAWO,EACTjC,QASTkD,sBAAA,SAAsBjB,eACfR,aAAe,gBACfC,SAAWO,EACTjC,QASTmD,sBAAA,SAAsBlB,eACfR,aAAe,cACfC,SAAWO,EACTjC,QASToD,yBAAA,SAAyBnB,eAClBR,aAAe,cACfC,SAAWO,EACTjC,QASTqD,YAAA,SAAYpB,eACLR,aAAe,eACfC,SAAWO,EACTjC,QASTgB,SAAA,iBAC+B,UAAtBhB,KAAKyB,iBACJzB,KAAKyB,iBAAgBzB,KAAK2B,eAAc3B,KAAK4B,sBAAqB5B,KAAK6B,qBAAoB7B,KAAK8B,oBAAmB9B,KAAK+B,6BACxH/B,KAAKyB,iBAAgBzB,KAAK0B,6EC7MJgB,OACxBY,EAA6BZ,EAA7BY,IACFC,GAD+Bb,EAAxBc,YAEI,GAAK,WAFed,EAAXe,OAIrBC,KAAI,gBAASC,IAAAA,YAAsB,aAA5BC,SAA2CD,MAAWA,KAC7DE,KAAK,YACH,IAAIC,SAAQ,SAACC,EAASC,WAGnBC,EAAU,IAAInD,OAAOoD,cAC3BD,EAAQE,KAAK,SAAUb,GACvBW,EAAQpD,KAAK0C,GACbU,EAAQG,mBAAqB,cACA,IAAvBH,EAAQI,YAAuC,MAAnBJ,EAAQK,OAAgB,KAChDC,EAAUC,KAAKC,MAAMR,EAAQS,cACnCX,EAAQQ,QAERP,uBACuBC,EAAQK,0BAAyBL,EAAQI,kBAAiBf,kBAAmBC,IAIxG,MAAOtC,QACHA,aAAaC,sBAKTD,EAJN+C,mEACkET,WAAmBD"}
1
+ {"version":3,"file":"fluent-cerner-js.cjs.production.min.js","sources":["../src/utils/index.ts","../src/MPageOrderEvent.ts","../src/MPageOrder.ts"],"sourcesContent":["/**\n * A type which represents the input parameter for an `XmlCclRequest`, which is wrapped by `makeCclRequest`.\n * The parameters are passed in a string, and numbers and strings are interpreted within this string by\n * the presence of quotes within quotes (e.g. single within double or vice versa). By strongly typing\n * the CclCallParam we can ensure that the parameters are always passed in a way that properly represents\n * their type.\n * @param {'string'|'number'} type - The type of the parameter.\n * @param {string} param - The string representing the parameters value.\n */\nexport type CclCallParam = {\n type: 'string' | 'number';\n param: string | number;\n};\n\n/**\n * A type which represents the full set of data required to make an XmlCclRequest, which is wrapped\n * by `makeCclRequest`.\n * @param {string} prg - The name of the CCL program to run, e.g. 12_USER_DETAILS.\n * @param {boolean?} excludeMine - Determines whether or not to include the \"MINE\" parameter as the\n * first parameter in the CCL call. This defaults to `false`, and almost all cases will require\n * the \"MINE\" parameter to be included.\n * @param {CclCallParam[]} params - An array of CclCallParam objects, each of which represents\n * a strongly typed parameter.\n */\nexport type CclOpts = {\n prg: string;\n excludeMine?: boolean;\n params: Array<CclCallParam>;\n};\n\n/**\n * A type functioning as a convience wrapper for several status\n * codes, respresented as strings, that are returned by XMLCclRequest.\n */\nexport type XmlCclStatus =\n | 'success'\n | 'method not allowed'\n | 'invalid state'\n | 'non-fatal error'\n | 'memory error'\n | 'internal server exception'\n | 'status refers to unknown error';\n\n/**\n * A type which represents the full set of data returned from an XmlCclRequest and important, formatted\n * metadata to help with debugging and error management. This is a generic type and data will represent\n * the type `T` which is the type or interface which represents the resolved data from the CCL request.\n */\nexport type CclRequestResponse<T> = {\n meta: {\n responseText: string;\n status: number;\n statusText: XmlCclStatus;\n };\n data: T | undefined;\n};\n\nconst statusCodeMap: Map<number, XmlCclStatus> = new Map();\nstatusCodeMap.set(200, 'success');\nstatusCodeMap.set(405, 'method not allowed');\nstatusCodeMap.set(409, 'invalid state');\nstatusCodeMap.set(492, 'non-fatal error');\nstatusCodeMap.set(493, 'memory error');\nstatusCodeMap.set(500, 'internal server exception');\n\n/**\n * A generic wrapper function for `XMLCclRequest` which simplifies it's use. Of note,\n * use of this requires the `head` of the HTML document contain the following\n * `meta` tag: `<META content='XMLCCLREQUEST' name='discern'>` so that it might\n * interface with the appropriate COM object.\n * @param {CclOpts} opts - Required options for the CCL request.\n * @returns a promise of type `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @resolves the `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @rejects with an error message if the CCL request fails.\n */\nexport function makeCclRequest<T>(\n opts: CclOpts\n): Promise<CclRequestResponse<T>> {\n const { prg, excludeMine, params } = opts;\n const paramsList =\n (excludeMine ? '' : \"'MINE',\") +\n params\n .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))\n .join(',');\n return new Promise((resolve, reject) => {\n try {\n // @ts-ignore - From Powerchart context\n const request: XMLCclRequest = window.XMLCclRequest();\n\n request.open('GET', `${prg}`);\n request.send(paramsList);\n request.onreadystatechange = function() {\n const data: CclRequestResponse<T> = {\n meta: {\n responseText: request.responseText,\n status: request.status,\n statusText:\n statusCodeMap.get(request.status) ||\n 'status refers to unknown error',\n },\n data:\n request.responseText === ''\n ? undefined\n : JSON.parse(request.responseText),\n };\n if (request.readyState === 4) {\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${\n request.readyState\n } on ${prg} with params ${paramsList} returning response text: ${request.responseText ||\n 'no response text'}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n\n/**\n * Attempts to open a tab with the name given to the `tab` variable in a\n * patients chart given in the context of a given encounter.\n * @param pid The patients person id.\n * @param eid The patients encounter id.\n * @param tab The string which represents the tab to open\n * (case insensitive). Navigation will be made to the first\n * upper-level tab in the chart that that matches the `tab` string\n * If no match is found, then sub-tab names will be searched and\n * navigation made to the first sub-tab that matches\n * the `tab` string. If no matches are found, no navigation will occur.\n * @param quickAdd {boolean} - If true, will attempt to open the window\n * in a quick add mode. E.g. if the Orders tab is connected to it will\n * attempt to launch the Add Order window so long as Enhanced Navigation is\n * supported by your installation.\n */\nexport function openPatientTab(\n pid: number,\n eid: number,\n tab: string,\n quickAdd: boolean\n): void {\n const args = `/PERSONID=${pid} /ENCNTRID=${eid} /FIRSTTAB=^${tab.toUpperCase()}${\n quickAdd ? '+' : ''\n }^`;\n\n try {\n window.APPLINK(1, '$APP_APPNAME$', args);\n } catch (e) {\n if (e instanceof ReferenceError) {\n console.warn(\n `We're likely not inside PowerChart. The input given would be: '1, \"$APP_NAME$\", ${args}'`\n );\n } else {\n throw e;\n }\n }\n}\n","import { MPageOrder } from '.';\n\nclass MPageOrderEvent {\n private _orders: Array<MPageOrder>;\n getOrders = () => this._orders;\n\n private _tabList: { tab: number; tabDisplayFlag: number } = {\n tab: 0,\n tabDisplayFlag: 0,\n };\n getTabList = () => this._tabList;\n\n private _personId: number = 0;\n getPersonId = () => this._personId;\n\n private _encounterId: number = 0;\n getEncounterId = () => this._encounterId;\n\n private _powerPlanFlag: number = 0;\n getPowerPlanFlag = () => this._powerPlanFlag;\n\n private _defaultDisplay: number = 0;\n getDefaultDisplay = () => this._defaultDisplay;\n\n private _silentSignFlag: number = 0;\n getSilentSignFlag = () => this._silentSignFlag;\n\n constructor() {\n this._orders = [];\n this._tabList = { tab: 0, tabDisplayFlag: 0 };\n // Disable PowerPlans by default\n this._powerPlanFlag = 0;\n // Disable PowerOrders by default\n this._tabList.tabDisplayFlag = 0;\n this.customizeOrderListProfile();\n this.launchOrderProfile();\n // Do NOT sign silently by default\n this._silentSignFlag = 0;\n }\n\n forPerson(id: number) {\n this._personId = id;\n return this;\n }\n\n forEncounter(id: number) {\n this._encounterId = id;\n return this;\n }\n\n addOrders(orders: Array<MPageOrder> | MPageOrder) {\n if (!Array.isArray(orders)) {\n orders = [orders];\n }\n this._orders = this._orders.concat(orders);\n return this;\n }\n\n enablePowerPlans() {\n this._powerPlanFlag = 24;\n return this;\n }\n\n customizeOrderListProfile() {\n this._tabList.tab = 2;\n return this;\n }\n\n customizeMedicationListProfile() {\n this._tabList.tab = 3;\n return this;\n }\n\n enablePowerOrders() {\n this._tabList.tabDisplayFlag = 127;\n return this;\n }\n\n launchOrderSearch() {\n this._defaultDisplay = 8;\n return this;\n }\n\n launchOrderProfile() {\n this._defaultDisplay = 16;\n return this;\n }\n\n launchOrdersForSignature() {\n this._defaultDisplay = 32;\n return this;\n }\n\n signSilently() {\n this._silentSignFlag = 1;\n return this;\n }\n\n send() {\n try {\n window.MPAGES_EVENT('ORDERS', this.toString());\n } catch (e) {\n if (e instanceof ReferenceError) {\n console.warn(\n `We're likely not inside PowerChart. The output would be an MPAGES_EVENT: ${this.toString()}`\n );\n } else {\n throw e;\n }\n }\n }\n\n toString(): string {\n const head = `${this._personId}|${this._encounterId}|`;\n let body: string = '';\n this._orders.forEach(order => {\n body += order.toString();\n });\n const tail = `|${this._powerPlanFlag}|{${this._tabList.tab}|${this._tabList.tabDisplayFlag}}|${this._defaultDisplay}|${this._silentSignFlag}`;\n\n return `${head}${body}${tail}`;\n }\n}\n\nexport { MPageOrderEvent };\n","/**\n * Options for a new order\n * @param {boolean} isRxOrder Marks the order order as a prescription. Is mutually exclusive from\n * isSatelliteOrder. Field will be set to false if left undefined; this resolves to 0 when built.\n * @param {boolean} isSatelliteOrder Moarks the order origination as satellite. Is mutually\n * exclusive from isRxOrder. Field will be set to false if left undefined; this resolves to 0 when built.\n * @param {number} orderSentenceId The optional Cerner order_sentence_id to be associated with\n * the new order. Field will be set to 0 if undefined.\n * @param {number} nomenclatureId The optional Cerner nomenclature_id to be associated with the\n * new order. Field will be set to 0 if undefined.\n * @param {boolean} skipInteractionCheckUntilSign Determines cerner sign-time interaction\n * checking. A value of true skips checking for interactions until orders are signed, false\n * will not. Field will be set to false if left undefined; this resolves to 0 when built.\n */\nexport type NewOrderOpts = {\n isRxOrder?: boolean;\n isSatelliteOrder?: boolean;\n orderSentenceId?: number;\n nomenclatureId?: number;\n skipInteractionCheckUntilSign?: boolean;\n};\n\nexport class MPageOrder {\n private _orderAction: string = '';\n getOrderAction = () => this._orderAction;\n\n private _orderId: number = 0;\n getOrderId = () => this._orderId;\n\n private _synonymId: number = 0;\n getSynonymId = () => this._synonymId;\n\n private _orderOrigination: number = 0;\n getOrderOrigination = () => this._orderOrigination;\n\n private _orderSentenceId: number = 0;\n getOrderSentenceId = () => this._orderSentenceId;\n\n private _nomenclatureId: number = 0;\n getNomenclatureId = () => this._nomenclatureId;\n\n private _signTimeInteraction: number = 0;\n getSignTimeInteraction = () => this._signTimeInteraction;\n\n /**\n * Creates a new MPageOrder with the order action 'ACTIVATE', which is the prototype for activating an existing future order.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willActivate(orderId: number) {\n this._orderAction = 'ACTIVATE';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL DC', which is the prototype for canceling and discontinuing an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelDiscontinue(orderId: number) {\n this._orderAction = 'CANCEL DC';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL REORD', which is the prototype for cancelling and reordering an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelReorder(orderId: number) {\n this._orderAction = 'CANCEL REORD';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CLEAR', which is the prototype for clearing actions of an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willClear(orderId: number) {\n this._orderAction = 'CLEAR';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_INPAT', which is the prototype for converting a prescription order into an inpatient order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertInpatient(orderId: number) {\n this._orderAction = 'CONVERT_INPAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_RX', which is the prototype for converting an inpatient order into a prescription.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertToPrescriptionOrder(orderId: number) {\n this._orderAction = 'CONVERT_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'MODIFY', which is the prototype for modifying an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willModify(orderId: number) {\n this._orderAction = 'MODIFY';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPage Order with order action 'ORDER'.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} synonymId The Cerner synonym_id to be associated with the new order. Must be set.\n * @param {NewOrderOpts} options required when making a new order\n * @returns {this} Returns itself to continue chaining method calls.\n * default to a normal order type.\n * @throws Error if `isRxOrder` and `isSatelliteOrder` are both set to true. These two are mutually exclusive and setting\n * both creates underfined behavior with respect the order origination field.\n * @example\n * m.willMakeNewOrder(34, true, 13, 42, true).toString() => \"{'ORDER'|34|5|1342|1}\"\n */\n\n willMakeNewOrder(synonymId: number, opts?: NewOrderOpts) {\n const {\n isRxOrder,\n isSatelliteOrder,\n orderSentenceId,\n nomenclatureId,\n skipInteractionCheckUntilSign,\n } = opts || {};\n\n if (isRxOrder && isSatelliteOrder)\n throw new Error('must select either isRxOrder or isSatelliteOrder');\n this._orderAction = 'ORDER';\n this._synonymId = synonymId;\n this._orderSentenceId = orderSentenceId || 0;\n this._nomenclatureId = nomenclatureId || 0;\n this._signTimeInteraction = skipInteractionCheckUntilSign ? 1 : 0;\n this._orderOrigination = isSatelliteOrder ? 5 : isRxOrder ? 1 : 0;\n\n return this;\n }\n\n /**\n * Creates a new MPageOrder with the order action 'RENEW', which is the prototype for reviewing an existing non-prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewNonPrescription(orderId: number) {\n this._orderAction = 'RENEW';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RENEW_RX', which is the prototype for renewing an existing prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewPrescription(orderId: number) {\n this._orderAction = 'RENEW_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'REPEAT', which is the prototype for copying an order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCopyExistingOrder(orderId: number) {\n this._orderAction = 'REPEAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RESUME', which is the prototype for resuming a suspended order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willResumeSuspendedOrder(orderId: number) {\n this._orderAction = 'RESUME';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'SUSPEND', which is the prototype for suspending an existing order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willSuspend(orderId: number) {\n this._orderAction = 'SUSPEND';\n this._orderId = orderId;\n return this;\n }\n\n /**\n * Overrides the toString() method for representing the objects internal state as a string.\n *\n * @since 0.1.0\n * @returns {string} string representation of MPageOrder's internal state\n */\n toString(): string {\n return this._orderAction === 'ORDER'\n ? `{${this._orderAction}|${this._synonymId}|${this._orderOrigination}|${this._orderSentenceId}|${this._nomenclatureId}|${this._signTimeInteraction}}`\n : `{${this._orderAction}|${this._orderId}}`;\n }\n}\n"],"names":["statusCodeMap","Map","set","MPageOrderEvent","_this","_orders","tab","tabDisplayFlag","_tabList","_personId","_encounterId","_powerPlanFlag","_defaultDisplay","_silentSignFlag","customizeOrderListProfile","launchOrderProfile","forPerson","id","this","forEncounter","addOrders","orders","Array","isArray","concat","enablePowerPlans","customizeMedicationListProfile","enablePowerOrders","launchOrderSearch","launchOrdersForSignature","signSilently","send","window","MPAGES_EVENT","toString","e","ReferenceError","console","warn","head","body","forEach","order","_orderAction","_orderId","_synonymId","_orderOrigination","_orderSentenceId","_nomenclatureId","_signTimeInteraction","willActivate","orderId","willCancelDiscontinue","willCancelReorder","willClear","willConvertInpatient","willConvertToPrescriptionOrder","willModify","willMakeNewOrder","synonymId","opts","isRxOrder","isSatelliteOrder","orderSentenceId","nomenclatureId","skipInteractionCheckUntilSign","Error","willRenewNonPrescription","willRenewPrescription","willCopyExistingOrder","willResumeSuspendedOrder","willSuspend","prg","paramsList","excludeMine","params","map","param","type","join","Promise","resolve","reject","request","XMLCclRequest","open","onreadystatechange","data","meta","responseText","status","statusText","get","undefined","JSON","parse","readyState","pid","eid","quickAdd","args","toUpperCase","APPLINK"],"mappings":"oEAyDA,IAAMA,EAA2C,IAAIC,IACrDD,EAAcE,IAAI,IAAK,WACvBF,EAAcE,IAAI,IAAK,sBACvBF,EAAcE,IAAI,IAAK,iBACvBF,EAAcE,IAAI,IAAK,mBACvBF,EAAcE,IAAI,IAAK,gBACvBF,EAAcE,IAAI,IAAK,iCC7DjBC,oDAEQ,kBAAMC,EAAKC,uBAEqC,CAC1DC,IAAK,EACLC,eAAgB,mBAEL,kBAAMH,EAAK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BAAmB9B,KAAK+B,6BACxH/B,KAAKyB,iBAAgBzB,KAAK0B,6EFvJpCgB,OAEQY,EAA6BZ,EAA7BY,IACFC,GAD+Bb,EAAxBc,YAEI,GAAK,WAFed,EAAXe,OAIrBC,KAAI,gBAASC,IAAAA,YAAsB,aAA5BC,SAA2CD,MAAWA,KAC7DE,KAAK,YACH,IAAIC,SAAQ,SAACC,EAASC,WAGnBC,EAAyBnD,OAAOoD,gBAEtCD,EAAQE,KAAK,SAAUb,GACvBW,EAAQpD,KAAK0C,GACbU,EAAQG,mBAAqB,eACrBC,EAA8B,CAClCC,KAAM,CACJC,aAAcN,EAAQM,aACtBC,OAAQP,EAAQO,OAChBC,WACE3F,EAAc4F,IAAIT,EAAQO,SAC1B,kCAEJH,KAC2B,KAAzBJ,EAAQM,kBACJI,EACAC,KAAKC,MAAMZ,EAAQM,eAEA,IAAvBN,EAAQa,WACVf,EAAQM,GAERL,uBACuBC,EAAQO,0BAC3BP,EAAQa,kBACHxB,kBAAmBC,gCAAuCU,EAAQM,cACvE,sBAIR,MAAOtD,QACHA,aAAaC,sBAKTD,EAJN+C,mEACkET,WAAmBD,4CA0B3FyB,EACAC,EACA5F,EACA6F,OAEMC,eAAoBH,gBAAiBC,iBAAkB5F,EAAI+F,eAC/DF,EAAW,IAAM,YAIjBnE,OAAOsE,QAAQ,EAAG,gBAAiBF,GACnC,MAAOjE,QACHA,aAAaC,sBAKTD,EAJNE,QAAQC,0FAC6E8D"}
@@ -1,3 +1,101 @@
1
+ var statusCodeMap = /*#__PURE__*/new Map();
2
+ statusCodeMap.set(200, 'success');
3
+ statusCodeMap.set(405, 'method not allowed');
4
+ statusCodeMap.set(409, 'invalid state');
5
+ statusCodeMap.set(492, 'non-fatal error');
6
+ statusCodeMap.set(493, 'memory error');
7
+ statusCodeMap.set(500, 'internal server exception');
8
+ /**
9
+ * A generic wrapper function for `XMLCclRequest` which simplifies it's use. Of note,
10
+ * use of this requires the `head` of the HTML document contain the following
11
+ * `meta` tag: `<META content='XMLCCLREQUEST' name='discern'>` so that it might
12
+ * interface with the appropriate COM object.
13
+ * @param {CclOpts} opts - Required options for the CCL request.
14
+ * @returns a promise of type `CclRequestResponse<T>` where `T` is the type
15
+ * or interface which represents the resolved data from the CCL request. If
16
+ * no data are returned, that is an empty string, from the XMLCclRequest then
17
+ * the `data` field will be set to `undefined`. The objects `meta` field
18
+ * includes `responseText`, `status`, and `statusTest` fields.
19
+ * @resolves the `CclRequestResponse<T>` where `T` is the type
20
+ * or interface which represents the resolved data from the CCL request. If
21
+ * no data are returned, that is an empty string, from the XMLCclRequest then
22
+ * the `data` field will be set to `undefined`. The objects `meta` field
23
+ * includes `responseText`, `status`, and `statusTest` fields.
24
+ * @rejects with an error message if the CCL request fails.
25
+ */
26
+
27
+ function makeCclRequest(opts) {
28
+ var prg = opts.prg,
29
+ excludeMine = opts.excludeMine,
30
+ params = opts.params;
31
+ var paramsList = (excludeMine ? '' : "'MINE',") + params.map(function (_ref) {
32
+ var type = _ref.type,
33
+ param = _ref.param;
34
+ return type === 'string' ? "'" + param + "'" : param;
35
+ }).join(',');
36
+ return new Promise(function (resolve, reject) {
37
+ try {
38
+ // @ts-ignore - From Powerchart context
39
+ var request = window.XMLCclRequest();
40
+ request.open('GET', "" + prg);
41
+ request.send(paramsList);
42
+
43
+ request.onreadystatechange = function () {
44
+ var data = {
45
+ meta: {
46
+ responseText: request.responseText,
47
+ status: request.status,
48
+ statusText: statusCodeMap.get(request.status) || 'status refers to unknown error'
49
+ },
50
+ data: request.responseText === '' ? undefined : JSON.parse(request.responseText)
51
+ };
52
+
53
+ if (request.readyState === 4) {
54
+ resolve(data);
55
+ } else {
56
+ reject("error with status " + request.status + " and readyState " + request.readyState + " on " + prg + " with params " + paramsList + " returning response text: " + (request.responseText || 'no response text'));
57
+ }
58
+ };
59
+ } catch (e) {
60
+ if (e instanceof ReferenceError) {
61
+ reject("We're likely not inside PowerChart. We cannot send request: \"" + paramsList + "\" to \"" + prg + "\"");
62
+ } else {
63
+ throw e;
64
+ }
65
+ }
66
+ });
67
+ }
68
+ /**
69
+ * Attempts to open a tab with the name given to the `tab` variable in a
70
+ * patients chart given in the context of a given encounter.
71
+ * @param pid The patients person id.
72
+ * @param eid The patients encounter id.
73
+ * @param tab The string which represents the tab to open
74
+ * (case insensitive). Navigation will be made to the first
75
+ * upper-level tab in the chart that that matches the `tab` string
76
+ * If no match is found, then sub-tab names will be searched and
77
+ * navigation made to the first sub-tab that matches
78
+ * the `tab` string. If no matches are found, no navigation will occur.
79
+ * @param quickAdd {boolean} - If true, will attempt to open the window
80
+ * in a quick add mode. E.g. if the Orders tab is connected to it will
81
+ * attempt to launch the Add Order window so long as Enhanced Navigation is
82
+ * supported by your installation.
83
+ */
84
+
85
+ function openPatientTab(pid, eid, tab, quickAdd) {
86
+ var args = "/PERSONID=" + pid + " /ENCNTRID=" + eid + " /FIRSTTAB=^" + tab.toUpperCase() + (quickAdd ? '+' : '') + "^";
87
+
88
+ try {
89
+ window.APPLINK(1, '$APP_APPNAME$', args);
90
+ } catch (e) {
91
+ if (e instanceof ReferenceError) {
92
+ console.warn("We're likely not inside PowerChart. The input given would be: '1, \"$APP_NAME$\", " + args + "'");
93
+ } else {
94
+ throw e;
95
+ }
96
+ }
97
+ }
98
+
1
99
  var MPageOrderEvent = /*#__PURE__*/function () {
2
100
  function MPageOrderEvent() {
3
101
  var _this = this;
@@ -123,7 +221,6 @@ var MPageOrderEvent = /*#__PURE__*/function () {
123
221
 
124
222
  _proto.send = function send() {
125
223
  try {
126
- // @ts-ignore
127
224
  window.MPAGES_EVENT('ORDERS', this.toString());
128
225
  } catch (e) {
129
226
  if (e instanceof ReferenceError) {
@@ -414,47 +511,5 @@ var MPageOrder = /*#__PURE__*/function () {
414
511
  return MPageOrder;
415
512
  }();
416
513
 
417
- /**
418
- * A generic wrapper function for `XMLCclRequest` which simplifies it's use.
419
- * @param {CclOpts} opts - Required options for the CCL request.
420
- * @returns a promise of type `T` where `T` is the type or interface which represents
421
- * the resolved data from the CCL request.
422
- * @resolves the resolved data of type `T` from the CCL request.
423
- * @rejects with an error message if the CCL request fails.
424
- */
425
- function makeCclRequest(opts) {
426
- var prg = opts.prg,
427
- excludeMine = opts.excludeMine,
428
- params = opts.params;
429
- var paramsList = (excludeMine ? '' : "'MINE',") + params.map(function (_ref) {
430
- var type = _ref.type,
431
- param = _ref.param;
432
- return type === 'string' ? "'" + param + "'" : param;
433
- }).join(',');
434
- return new Promise(function (resolve, reject) {
435
- try {
436
- // @ts-ignore - exists in PowerChart
437
- var request = new window.XMLCclRequest();
438
- request.open('GET', "" + prg);
439
- request.send(paramsList);
440
-
441
- request.onreadystatechange = function () {
442
- if (request.readyState === 4 && request.status === 200) {
443
- var data = JSON.parse(request.responseText);
444
- resolve(data);
445
- } else {
446
- reject("error with status " + request.status + " and readyState " + request.readyState + " on " + prg + " with params " + paramsList);
447
- }
448
- };
449
- } catch (e) {
450
- if (e instanceof ReferenceError) {
451
- reject("We're likely not inside PowerChart. We cannot send request: \"" + paramsList + "\" to \"" + prg + "\"");
452
- } else {
453
- throw e;
454
- }
455
- }
456
- });
457
- }
458
-
459
- export { MPageOrder, MPageOrderEvent, makeCclRequest };
514
+ export { MPageOrder, MPageOrderEvent, makeCclRequest, openPatientTab };
460
515
  //# sourceMappingURL=fluent-cerner-js.esm.js.map