fluent-cerner-js 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -101,15 +101,9 @@ As:
101
101
  - Customizing the **Order List Profile** with **PowerOrder** functionality
102
102
  - Defaulting to the **Order Profile** view.
103
103
 
104
- ## API In Action [Under Construction]
105
-
106
- Add order's one at a time (or via a loop):
104
+ ## API In Action: Create and Send Orders to MOEW
107
105
 
108
106
  ```js
109
- const fcjs = require('fluent-cerner-js');
110
- const MPageOrder = fcjs.MPageOrder;
111
- const MPageOrderEvent = fcjs.MPageOrderEvent;
112
-
113
107
  // Make a new order from an existing order which serves as a template for copy.
114
108
  const order1 = new MPageOrder();
115
109
  order1.willCopyExistingOrder(12345);
@@ -144,7 +138,7 @@ event
144
138
  event.send();
145
139
  ```
146
140
 
147
- You can also invoke the "toString()" override method to confirm your order string is correct.
141
+ You can also invoke the `toString()` override method to confirm your order string is correct.
148
142
 
149
143
  ```js
150
144
  console.log(`MPage Event String:\n${mpageEvent}\n`);
@@ -155,3 +149,56 @@ Result:
155
149
  ```sh
156
150
  1231251|812388|{REPEAT|12345}{ORDER|1343|1|0|0|0}{ORDER|3428|0|3|14|1}|24|{2|127}|16|0
157
151
  ```
152
+
153
+ ## API in Action: Make a CCL call to pull data into you MPage
154
+
155
+ ```js
156
+ const cclOpts = {
157
+ prg: 'MP_GET_ORDER_LIST',
158
+ params: [
159
+ { type: 'number', param: 12345 },
160
+ { type: 'string', param: 'joe' },
161
+ ],
162
+ };
163
+
164
+ let result = undefined;
165
+
166
+ makeCclRequest(cclOpts)
167
+ .then(data => (result = data))
168
+ .catch(console.error);
169
+ ```
170
+
171
+ ## TypeScript Support
172
+
173
+ This library was developedin typescript and all relevant types are exported.
174
+
175
+ ```tsx
176
+ import { makeCclRequest, CclCallParam, CclOpts } from 'fluent-cerner-js';
177
+ import { MyCustomResponse } from '../types';
178
+ // Other imports omitted in this example for clarity
179
+
180
+ const MyComponent = ({ user }) => {
181
+ const [data, setData] = useState<MyCustomResponse>({});
182
+
183
+ const handleButtonClick = () => {
184
+ const userPidParam: CclCallParam = { type: 'number', param: user.pid };
185
+
186
+ const opts: CclOpts = {
187
+ prg: 'MY_CUSTOM_PRG_FILENAME',
188
+ params: [userPidParam],
189
+ };
190
+
191
+ makeCclRequest<MyCustomResponse>(opts)
192
+ .then(data => setData(data))
193
+ .catch(error => addErrorToast(error));
194
+ };
195
+
196
+ return (
197
+ <div>
198
+ <h2>My Custom Component</h2>
199
+ <p>Welcome, {user.name}</p>
200
+ <button onClick={handleButtonClick}>Click Me to Get Data</button>
201
+ </div>
202
+ );
203
+ };
204
+ ```
@@ -1,24 +1,4 @@
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
- };
1
+ import { NewOrderOpts } from './types';
22
2
  export declare class MPageOrder {
23
3
  private _orderAction;
24
4
  getOrderAction: () => string;
@@ -128,7 +128,7 @@ var MPageOrderEvent = /*#__PURE__*/function () {
128
128
  _proto.send = function send() {
129
129
  try {
130
130
  // @ts-ignore
131
- w.MPAGES_EVENT('ORDERS', this.toString());
131
+ window.MPAGES_EVENT('ORDERS', this.toString());
132
132
  } catch (e) {
133
133
  if (e instanceof ReferenceError) {
134
134
  console.warn("We're likely not inside PowerChart. The output would be an MPAGES_EVENT: " + this.toString());
@@ -418,6 +418,49 @@ var MPageOrder = /*#__PURE__*/function () {
418
418
  return MPageOrder;
419
419
  }();
420
420
 
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
+
421
463
  exports.MPageOrder = MPageOrder;
422
464
  exports.MPageOrderEvent = MPageOrderEvent;
465
+ exports.makeCclRequest = makeCclRequest;
423
466
  //# 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"],"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 w.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":["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","w","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"],"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,GAAiB;AAAA,aAAM,KAAI,CAACC,YAAX;AAAA,KAAjB;;AAEQ,uBAAA,GAAyB,CAAzB;;AACR,yBAAA,GAAmB;AAAA,aAAM,KAAI,CAACC,cAAX;AAAA,KAAnB;;AAEQ,wBAAA,GAA0B,CAA1B;;AACR,0BAAA,GAAoB;AAAA,aAAM,KAAI,CAACC,eAAX;AAAA,KAApB;;AAEQ,wBAAA,GAA0B,CAA1B;;AACR,0BAAA,GAAoB;AAAA,aAAM,KAAI,CAACC,eAAX;AAAA,KAApB;;AAGE,SAAKR,OAAL,GAAe,EAAf;AACA,SAAKG,QAAL,GAAgB;AAAEF,MAAAA,GAAG,EAAE,CAAP;AAAUC,MAAAA,cAAc,EAA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YAAL,GAAoB,QAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AACD;;;;;;;AA/LF;;AAAA,SAsMEoB,WAtMF,GAsME,qBAAYpB,OAAZ;AACE,SAAKR,YAAL,GAAoB,SAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AAED;;;;;;AA5MF;;AAAA,SAkNEnB,QAlNF,GAkNE;AACE,WAAO,KAAKW,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
+ {"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,KAA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DP,UAD5D,gBAC+EH,GAD/E,QAAN;AAGD,OAJD,MAIO;AACL,cAAMxC,CAAN;AACD;AACF;AACF,GAzBM,CAAP;AA0BD;;;;;;"}
@@ -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{w.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||{},n=i.isRxOrder,e=i.isSatelliteOrder,o=i.orderSentenceId,s=i.nomenclatureId,h=i.skipInteractionCheckUntilSign;if(n&&e)throw new Error("must select either isRxOrder or isSatelliteOrder");return this._orderAction="ORDER",this._synonymId=t,this._orderSentenceId=o||0,this._nomenclatureId=s||0,this._signTimeInteraction=h?1:0,this._orderOrigination=e?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=t;
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+'"')}}))};
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"],"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 w.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":["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","w","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"],"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,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,eACfR,aAAe,iBACfC,SAAWO,EACTjC,QASTmC,kBAAA,SAAkBF,eACXR,aAAe,oBACfC,SAAWO,EACTjC,QASToC,UAAA,SAAUH,eACHR,aAAe,aACfC,SAAWO,EACTjC,QASTqC,qBAAA,SAAqBJ,eACdR,aAAe,qBACfC,SAAWO,EACTjC,QASTsC,+BAAA,SAA+BL,eACxBR,aAAe,kBACfC,SAAWO,EACTjC,QASTuC,WAAA,SAAWN,eACJR,aAAe,cACfC,SAAWO,EACTjC,QAiBTwC,iBAAA,SAAiBC,EAAmBC,SAO9BA,GAAQ,GALVC,IAAAA,UACAC,IAAAA,iBACAC,IAAAA,gBACAC,IAAAA,eACAC,IAAAA,iCAGEJ,GAAaC,EACf,MAAM,IAAII,MAAM,gEACbvB,aAAe,aACfE,WAAac,OACbZ,iBAAmBgB,GAAmB,OACtCf,gBAAkBgB,GAAkB,OACpCf,qBAAuBgB,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"}
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,QA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
124
124
  _proto.send = function send() {
125
125
  try {
126
126
  // @ts-ignore
127
- w.MPAGES_EVENT('ORDERS', this.toString());
127
+ window.MPAGES_EVENT('ORDERS', this.toString());
128
128
  } catch (e) {
129
129
  if (e instanceof ReferenceError) {
130
130
  console.warn("We're likely not inside PowerChart. The output would be an MPAGES_EVENT: " + this.toString());
@@ -414,5 +414,47 @@ var MPageOrder = /*#__PURE__*/function () {
414
414
  return MPageOrder;
415
415
  }();
416
416
 
417
- export { MPageOrder, MPageOrderEvent };
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 };
418
460
  //# sourceMappingURL=fluent-cerner-js.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fluent-cerner-js.esm.js","sources":["../src/MPageOrderEvent.ts","../src/MPageOrder.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 w.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":["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","w","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"],"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,GAAiB;AAAA,aAAM,KAAI,CAACC,YAAX;AAAA,KAAjB;;AAEQ,uBAAA,GAAyB,CAAzB;;AACR,yBAAA,GAAmB;AAAA,aAAM,KAAI,CAACC,cAAX;AAAA,KAAnB;;AAEQ,wBAAA,GAA0B,CAA1B;;AACR,0BAAA,GAAoB;AAAA,aAAM,KAAI,CAACC,eAAX;AAAA,KAApB;;AAEQ,wBAAA,GAA0B,CAA1B;;AACR,0BAAA,GAAoB;AAAA,aAAM,KAAI,CAACC,eAAX;AAAA,KAApB;;AAGE,SAAKR,OAAL,GAAe,EAAf;AACA,SAAKG,QAAL,GAAgB;AAAEF,MAAAA,GAAG,EAAE,CAAP;AAAUC,MAAAA,cAAc,EAAE;AAA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GAAoB,QAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AACD;;;;;;;AA/LF;;AAAA,SAsMEoB,WAtMF,GAsME,qBAAYpB,OAAZ;AACE,SAAKR,YAAL,GAAoB,SAApB;AACA,SAAKC,QAAL,GAAgBO,OAAhB;AACA,WAAO,IAAP;AACD;AAED;;;;;;AA5MF;;AAAA,SAkNEnB,QAlNF,GAkNE;AACE,WAAO,KAAKW,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
+ {"version":3,"file":"fluent-cerner-js.esm.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;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C+EH,GAD/E,QAAN;AAGD,OAJD,MAIO;AACL,cAAMxC,CAAN;AACD;AACF;AACF,GAzBM,CAAP;AA0BD;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import { MPageOrderEvent } from './MPageOrderEvent';
2
- import { MPageOrder, NewOrderOpts } from './MPageOrder';
3
- export { MPageOrderEvent, MPageOrder, NewOrderOpts };
2
+ import { MPageOrder } from './MPageOrder';
3
+ import { makeCclRequest } from './utils';
4
+ import { NewOrderOpts, CclOpts, CclCallParam } from './types';
5
+ export { CclCallParam, CclOpts, NewOrderOpts, MPageOrderEvent, MPageOrder, makeCclRequest, };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * A type which represents the input parameter for an `XmlCclRequest`, which is wrapped by `makeCclRequest`.
3
+ * The parameters are passed in a string, and numbers and strings are interpreted within this string by
4
+ * the presence of quotes within quotes (e.g. single within double or vice versa). By strongly typing
5
+ * the CclCallParam we can ensure that the parameters are always passed in a way that properly represents
6
+ * their type.
7
+ * @param {'string'|'number'} type - The type of the parameter.
8
+ * @param {string} param - The string representing the parameters value.
9
+ */
10
+ export declare type CclCallParam = {
11
+ type: 'string' | 'number';
12
+ param: string | number;
13
+ };
14
+ /**
15
+ * A type which represents the full set of data required to make an XmlCclRequest, which is wrapped
16
+ * by `makeCclRequest`.
17
+ * @param {string} prg - The name of the CCL program to run, e.g. 12_USER_DETAILS.
18
+ * @param {boolean?} excludeMine - Determines whether or not to include the "MINE" parameter as the
19
+ * first parameter in the CCL call. This defaults to `false`, and almost all cases will require
20
+ * the "MINE" parameter to be included.
21
+ * @param {CclCallParam[]} params - An array of CclCallParam objects, each of which represents
22
+ * a strongly typed parameter.
23
+ */
24
+ export declare type CclOpts = {
25
+ prg: string;
26
+ excludeMine?: boolean;
27
+ params: Array<CclCallParam>;
28
+ };
29
+ /**
30
+ * Options for a new order
31
+ * @param {boolean} isRxOrder Marks the order order as a prescription. Is mutually exclusive from
32
+ * isSatelliteOrder. Field will be set to false if left undefined; this resolves to 0 when built.
33
+ * @param {boolean} isSatelliteOrder Moarks the order origination as satellite. Is mutually
34
+ * exclusive from isRxOrder. Field will be set to false if left undefined; this resolves to 0 when built.
35
+ * @param {number} orderSentenceId The optional Cerner order_sentence_id to be associated with
36
+ * the new order. Field will be set to 0 if undefined.
37
+ * @param {number} nomenclatureId The optional Cerner nomenclature_id to be associated with the
38
+ * new order. Field will be set to 0 if undefined.
39
+ * @param {boolean} skipInteractionCheckUntilSign Determines cerner sign-time interaction
40
+ * checking. A value of true skips checking for interactions until orders are signed, false
41
+ * will not. Field will be set to false if left undefined; this resolves to 0 when built.
42
+ */
43
+ export declare type NewOrderOpts = {
44
+ isRxOrder?: boolean;
45
+ isSatelliteOrder?: boolean;
46
+ orderSentenceId?: number;
47
+ nomenclatureId?: number;
48
+ skipInteractionCheckUntilSign?: boolean;
49
+ };
@@ -0,0 +1,10 @@
1
+ import { CclOpts } from '../types';
2
+ /**
3
+ * A generic wrapper function for `XMLCclRequest` which simplifies it's use.
4
+ * @param {CclOpts} opts - Required options for the CCL request.
5
+ * @returns a promise of type `T` where `T` is the type or interface which represents
6
+ * the resolved data from the CCL request.
7
+ * @resolves the resolved data of type `T` from the CCL request.
8
+ * @rejects with an error message if the CCL request fails.
9
+ */
10
+ export declare function makeCclRequest<T>(opts: CclOpts): Promise<T>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.0",
2
+ "version": "0.1.1",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -46,10 +46,13 @@
46
46
  ],
47
47
  "devDependencies": {
48
48
  "@size-limit/preset-small-lib": "^7.0.5",
49
+ "@size-limit/webpack": "^7.0.5",
50
+ "@size-limit/webpack-why": "^7.0.5",
49
51
  "husky": "^7.0.4",
50
52
  "size-limit": "^7.0.5",
51
53
  "tsdx": "^0.14.1",
52
54
  "tslib": "^2.3.1",
53
55
  "typescript": "^4.5.4"
54
- }
56
+ },
57
+ "dependencies": {}
55
58
  }
package/src/MPageOrder.ts CHANGED
@@ -1,24 +1,4 @@
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 type NewOrderOpts = {
16
- isRxOrder?: boolean;
17
- isSatelliteOrder?: boolean;
18
- orderSentenceId?: number;
19
- nomenclatureId?: number;
20
- skipInteractionCheckUntilSign?: boolean;
21
- };
1
+ import { NewOrderOpts } from './types';
22
2
 
23
3
  export class MPageOrder {
24
4
  private _orderAction: string = '';
@@ -99,7 +99,7 @@ class MPageOrderEvent {
99
99
  send() {
100
100
  try {
101
101
  // @ts-ignore
102
- w.MPAGES_EVENT('ORDERS', this.toString());
102
+ window.MPAGES_EVENT('ORDERS', this.toString());
103
103
  } catch (e) {
104
104
  if (e instanceof ReferenceError) {
105
105
  console.warn(
package/src/index.ts CHANGED
@@ -1,4 +1,13 @@
1
1
  import { MPageOrderEvent } from './MPageOrderEvent';
2
- import { MPageOrder, NewOrderOpts } from './MPageOrder';
2
+ import { MPageOrder } from './MPageOrder';
3
+ import { makeCclRequest } from './utils';
4
+ import { NewOrderOpts, CclOpts, CclCallParam } from './types';
3
5
 
4
- export { MPageOrderEvent, MPageOrder, NewOrderOpts };
6
+ export {
7
+ CclCallParam,
8
+ CclOpts,
9
+ NewOrderOpts,
10
+ MPageOrderEvent,
11
+ MPageOrder,
12
+ makeCclRequest,
13
+ };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * A type which represents the input parameter for an `XmlCclRequest`, which is wrapped by `makeCclRequest`.
3
+ * The parameters are passed in a string, and numbers and strings are interpreted within this string by
4
+ * the presence of quotes within quotes (e.g. single within double or vice versa). By strongly typing
5
+ * the CclCallParam we can ensure that the parameters are always passed in a way that properly represents
6
+ * their type.
7
+ * @param {'string'|'number'} type - The type of the parameter.
8
+ * @param {string} param - The string representing the parameters value.
9
+ */
10
+ export type CclCallParam = {
11
+ type: 'string' | 'number';
12
+ param: string | number;
13
+ };
14
+
15
+ /**
16
+ * A type which represents the full set of data required to make an XmlCclRequest, which is wrapped
17
+ * by `makeCclRequest`.
18
+ * @param {string} prg - The name of the CCL program to run, e.g. 12_USER_DETAILS.
19
+ * @param {boolean?} excludeMine - Determines whether or not to include the "MINE" parameter as the
20
+ * first parameter in the CCL call. This defaults to `false`, and almost all cases will require
21
+ * the "MINE" parameter to be included.
22
+ * @param {CclCallParam[]} params - An array of CclCallParam objects, each of which represents
23
+ * a strongly typed parameter.
24
+ */
25
+ export type CclOpts = {
26
+ prg: string;
27
+ excludeMine?: boolean;
28
+ params: Array<CclCallParam>;
29
+ };
30
+
31
+ /**
32
+ * Options for a new order
33
+ * @param {boolean} isRxOrder Marks the order order as a prescription. Is mutually exclusive from
34
+ * isSatelliteOrder. Field will be set to false if left undefined; this resolves to 0 when built.
35
+ * @param {boolean} isSatelliteOrder Moarks the order origination as satellite. Is mutually
36
+ * exclusive from isRxOrder. Field will be set to false if left undefined; this resolves to 0 when built.
37
+ * @param {number} orderSentenceId The optional Cerner order_sentence_id to be associated with
38
+ * the new order. Field will be set to 0 if undefined.
39
+ * @param {number} nomenclatureId The optional Cerner nomenclature_id to be associated with the
40
+ * new order. Field will be set to 0 if undefined.
41
+ * @param {boolean} skipInteractionCheckUntilSign Determines cerner sign-time interaction
42
+ * checking. A value of true skips checking for interactions until orders are signed, false
43
+ * will not. Field will be set to false if left undefined; this resolves to 0 when built.
44
+ */
45
+ export type NewOrderOpts = {
46
+ isRxOrder?: boolean;
47
+ isSatelliteOrder?: boolean;
48
+ orderSentenceId?: number;
49
+ nomenclatureId?: number;
50
+ skipInteractionCheckUntilSign?: boolean;
51
+ };
@@ -0,0 +1,44 @@
1
+ import { CclOpts } from '../types';
2
+
3
+ /**
4
+ * A generic wrapper function for `XMLCclRequest` which simplifies it's use.
5
+ * @param {CclOpts} opts - Required options for the CCL request.
6
+ * @returns a promise of type `T` where `T` is the type or interface which represents
7
+ * the resolved data from the CCL request.
8
+ * @resolves the resolved data of type `T` from the CCL request.
9
+ * @rejects with an error message if the CCL request fails.
10
+ */
11
+ export function makeCclRequest<T>(opts: CclOpts): Promise<T> {
12
+ const { prg, excludeMine, params } = opts;
13
+ const paramsList =
14
+ (excludeMine ? '' : "'MINE',") +
15
+ params
16
+ .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))
17
+ .join(',');
18
+ return new Promise((resolve, reject) => {
19
+ try {
20
+ // @ts-ignore - exists in PowerChart
21
+ const request = new window.XMLCclRequest();
22
+ request.open('GET', `${prg}`);
23
+ request.send(paramsList);
24
+ request.onreadystatechange = function() {
25
+ if (request.readyState === 4 && request.status === 200) {
26
+ const data: T = JSON.parse(request.responseText);
27
+ resolve(data);
28
+ } else {
29
+ reject(
30
+ `error with status ${request.status} and readyState ${request.readyState} on ${prg} with params ${paramsList}`
31
+ );
32
+ }
33
+ };
34
+ } catch (e) {
35
+ if (e instanceof ReferenceError) {
36
+ reject(
37
+ `We're likely not inside PowerChart. We cannot send request: "${paramsList}" to "${prg}"`
38
+ );
39
+ } else {
40
+ throw e;
41
+ }
42
+ }
43
+ });
44
+ }