fluent-cerner-js 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fluent-cerner-js.cjs.development.js +28 -6
- package/dist/fluent-cerner-js.cjs.development.js.map +1 -1
- package/dist/fluent-cerner-js.cjs.production.min.js +1 -1
- package/dist/fluent-cerner-js.cjs.production.min.js.map +1 -1
- package/dist/fluent-cerner-js.esm.js +28 -6
- package/dist/fluent-cerner-js.esm.js.map +1 -1
- package/dist/types/index.d.ts +18 -0
- package/dist/utils/index.d.ts +12 -5
- package/package.json +1 -1
- package/src/types/index.ts +27 -0
- package/src/utils/index.ts +36 -7
|
@@ -418,14 +418,29 @@ var MPageOrder = /*#__PURE__*/function () {
|
|
|
418
418
|
return MPageOrder;
|
|
419
419
|
}();
|
|
420
420
|
|
|
421
|
+
var statusCodeMap = /*#__PURE__*/new Map();
|
|
422
|
+
statusCodeMap.set(200, 'success');
|
|
423
|
+
statusCodeMap.set(405, 'method not allowed');
|
|
424
|
+
statusCodeMap.set(409, 'invalid state');
|
|
425
|
+
statusCodeMap.set(492, 'non-fatal error');
|
|
426
|
+
statusCodeMap.set(493, 'memory error');
|
|
427
|
+
statusCodeMap.set(500, 'internal server exception');
|
|
421
428
|
/**
|
|
422
429
|
* A generic wrapper function for `XMLCclRequest` which simplifies it's use.
|
|
423
430
|
* @param {CclOpts} opts - Required options for the CCL request.
|
|
424
|
-
* @returns a promise of type `T
|
|
425
|
-
* the resolved data from the CCL request.
|
|
426
|
-
*
|
|
431
|
+
* @returns a promise of type `CclRequestResponse<T>` where `T` is the type
|
|
432
|
+
* or interface which represents the resolved data from the CCL request. If
|
|
433
|
+
* no data are returned, that is an empty string, from the XMLCclRequest then
|
|
434
|
+
* the `data` field will be set to `undefined`. The objects `meta` field
|
|
435
|
+
* includes `responseText`, `status`, and `statusTest` fields.
|
|
436
|
+
* @resolves the `CclRequestResponse<T>` where `T` is the type
|
|
437
|
+
* or interface which represents the resolved data from the CCL request. If
|
|
438
|
+
* no data are returned, that is an empty string, from the XMLCclRequest then
|
|
439
|
+
* the `data` field will be set to `undefined`. The objects `meta` field
|
|
440
|
+
* includes `responseText`, `status`, and `statusTest` fields.
|
|
427
441
|
* @rejects with an error message if the CCL request fails.
|
|
428
442
|
*/
|
|
443
|
+
|
|
429
444
|
function makeCclRequest(opts) {
|
|
430
445
|
var prg = opts.prg,
|
|
431
446
|
excludeMine = opts.excludeMine,
|
|
@@ -443,9 +458,16 @@ function makeCclRequest(opts) {
|
|
|
443
458
|
request.send(paramsList);
|
|
444
459
|
|
|
445
460
|
request.onreadystatechange = function () {
|
|
446
|
-
var data =
|
|
447
|
-
|
|
448
|
-
|
|
461
|
+
var data = {
|
|
462
|
+
meta: {
|
|
463
|
+
responseText: request.responseText,
|
|
464
|
+
status: request.status,
|
|
465
|
+
statusText: statusCodeMap.get(request.status) || 'status refers to unknown error'
|
|
466
|
+
},
|
|
467
|
+
data: request.responseText === '' ? undefined : JSON.parse(request.responseText)
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
if (request.readyState === 4) {
|
|
449
471
|
resolve(data);
|
|
450
472
|
} else {
|
|
451
473
|
reject("error with status " + request.status + " and readyState " + request.readyState + " on " + prg + " with params " + paramsList + " returning response text: " + (request.responseText || 'no response text'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluent-cerner-js.cjs.development.js","sources":["../src/MPageOrderEvent.ts","../src/MPageOrder.ts","../src/utils/index.ts"],"sourcesContent":["import { MPageOrder } from '.';\n\nclass MPageOrderEvent {\n private _orders: Array<MPageOrder>;\n getOrders = () => this._orders;\n\n private _tabList: { tab: number; tabDisplayFlag: number } = {\n tab: 0,\n tabDisplayFlag: 0,\n };\n getTabList = () => this._tabList;\n\n private _personId: number = 0;\n getPersonId = () => this._personId;\n\n private _encounterId: number = 0;\n getEncounterId = () => this._encounterId;\n\n private _powerPlanFlag: number = 0;\n getPowerPlanFlag = () => this._powerPlanFlag;\n\n private _defaultDisplay: number = 0;\n getDefaultDisplay = () => this._defaultDisplay;\n\n private _silentSignFlag: number = 0;\n getSilentSignFlag = () => this._silentSignFlag;\n\n constructor() {\n this._orders = [];\n this._tabList = { tab: 0, tabDisplayFlag: 0 };\n // Disable PowerPlans by default\n this._powerPlanFlag = 0;\n // Disable PowerOrders by default\n this._tabList.tabDisplayFlag = 0;\n this.customizeOrderListProfile();\n this.launchOrderProfile();\n // Do NOT sign silently by default\n this._silentSignFlag = 0;\n }\n\n forPerson(id: number) {\n this._personId = id;\n return this;\n }\n\n forEncounter(id: number) {\n this._encounterId = id;\n return this;\n }\n\n addOrders(orders: Array<MPageOrder> | MPageOrder) {\n if (!Array.isArray(orders)) {\n orders = [orders];\n }\n this._orders = this._orders.concat(orders);\n return this;\n }\n\n enablePowerPlans() {\n this._powerPlanFlag = 24;\n return this;\n }\n\n customizeOrderListProfile() {\n this._tabList.tab = 2;\n return this;\n }\n\n customizeMedicationListProfile() {\n this._tabList.tab = 3;\n return this;\n }\n\n enablePowerOrders() {\n this._tabList.tabDisplayFlag = 127;\n return this;\n }\n\n launchOrderSearch() {\n this._defaultDisplay = 8;\n return this;\n }\n\n launchOrderProfile() {\n this._defaultDisplay = 16;\n return this;\n }\n\n launchOrdersForSignature() {\n this._defaultDisplay = 32;\n return this;\n }\n\n signSilently() {\n this._silentSignFlag = 1;\n return this;\n }\n\n send() {\n try {\n // @ts-ignore\n window.MPAGES_EVENT('ORDERS', this.toString());\n } catch (e) {\n if (e instanceof ReferenceError) {\n console.warn(\n `We're likely not inside PowerChart. The output would be an MPAGES_EVENT: ${this.toString()}`\n );\n } else {\n throw e;\n }\n }\n }\n\n toString(): string {\n const head = `${this._personId}|${this._encounterId}|`;\n let body: string = '';\n this._orders.forEach(order => {\n body += order.toString();\n });\n const tail = `|${this._powerPlanFlag}|{${this._tabList.tab}|${this._tabList.tabDisplayFlag}}|${this._defaultDisplay}|${this._silentSignFlag}`;\n\n return `${head}${body}${tail}`;\n }\n}\n\nexport { MPageOrderEvent };\n","import { NewOrderOpts } from './types';\n\nexport class MPageOrder {\n private _orderAction: string = '';\n getOrderAction = () => this._orderAction;\n\n private _orderId: number = 0;\n getOrderId = () => this._orderId;\n\n private _synonymId: number = 0;\n getSynonymId = () => this._synonymId;\n\n private _orderOrigination: number = 0;\n getOrderOrigination = () => this._orderOrigination;\n\n private _orderSentenceId: number = 0;\n getOrderSentenceId = () => this._orderSentenceId;\n\n private _nomenclatureId: number = 0;\n getNomenclatureId = () => this._nomenclatureId;\n\n private _signTimeInteraction: number = 0;\n getSignTimeInteraction = () => this._signTimeInteraction;\n\n /**\n * Creates a new MPageOrder with the order action 'ACTIVATE', which is the prototype for activating an existing future order.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willActivate(orderId: number) {\n this._orderAction = 'ACTIVATE';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL DC', which is the prototype for canceling and discontinuing an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelDiscontinue(orderId: number) {\n this._orderAction = 'CANCEL DC';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CANCEL REORD', which is the prototype for cancelling and reordering an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCancelReorder(orderId: number) {\n this._orderAction = 'CANCEL REORD';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CLEAR', which is the prototype for clearing actions of an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willClear(orderId: number) {\n this._orderAction = 'CLEAR';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_INPAT', which is the prototype for converting a prescription order into an inpatient order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertInpatient(orderId: number) {\n this._orderAction = 'CONVERT_INPAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'CONVERT_RX', which is the prototype for converting an inpatient order into a prescription.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willConvertToPrescriptionOrder(orderId: number) {\n this._orderAction = 'CONVERT_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'MODIFY', which is the prototype for modifying an existing future order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willModify(orderId: number) {\n this._orderAction = 'MODIFY';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPage Order with order action 'ORDER'.\n *\n * @since 0.1.0\n * @category MPage Events - Orders\n * @param {number} synonymId The Cerner synonym_id to be associated with the new order. Must be set.\n * @param {NewOrderOpts} options required when making a new order\n * @returns {this} Returns itself to continue chaining method calls.\n * default to a normal order type.\n * @throws Error if `isRxOrder` and `isSatelliteOrder` are both set to true. These two are mutually exclusive and setting\n * both creates underfined behavior with respect the order origination field.\n * @example\n * m.willMakeNewOrder(34, true, 13, 42, true).toString() => \"{'ORDER'|34|5|1342|1}\"\n */\n\n willMakeNewOrder(synonymId: number, opts?: NewOrderOpts) {\n const {\n isRxOrder,\n isSatelliteOrder,\n orderSentenceId,\n nomenclatureId,\n skipInteractionCheckUntilSign,\n } = opts || {};\n\n if (isRxOrder && isSatelliteOrder)\n throw new Error('must select either isRxOrder or isSatelliteOrder');\n this._orderAction = 'ORDER';\n this._synonymId = synonymId;\n this._orderSentenceId = orderSentenceId || 0;\n this._nomenclatureId = nomenclatureId || 0;\n this._signTimeInteraction = skipInteractionCheckUntilSign ? 1 : 0;\n this._orderOrigination = isSatelliteOrder ? 5 : isRxOrder ? 1 : 0;\n\n return this;\n }\n\n /**\n * Creates a new MPageOrder with the order action 'RENEW', which is the prototype for reviewing an existing non-prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewNonPrescription(orderId: number) {\n this._orderAction = 'RENEW';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RENEW_RX', which is the prototype for renewing an existing prescription order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willRenewPrescription(orderId: number) {\n this._orderAction = 'RENEW_RX';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'REPEAT', which is the prototype for copying an order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willCopyExistingOrder(orderId: number) {\n this._orderAction = 'REPEAT';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'RESUME', which is the prototype for resuming a suspended order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willResumeSuspendedOrder(orderId: number) {\n this._orderAction = 'RESUME';\n this._orderId = orderId;\n return this;\n }\n /**\n * Creates a new MPageOrder with the order action 'SUSPEND', which is the prototype for suspending an existing order.\n *\n * @since 0.1.0\n * @param {number} orderId The order id value for the order to activate.\n * @returns {this} Returns itself to continue chaining method calls.\n */\n willSuspend(orderId: number) {\n this._orderAction = 'SUSPEND';\n this._orderId = orderId;\n return this;\n }\n\n /**\n * Overrides the toString() method for representing the objects internal state as a string.\n *\n * @since 0.1.0\n * @returns {string} string representation of MPageOrder's internal state\n */\n toString(): string {\n return this._orderAction === 'ORDER'\n ? `{${this._orderAction}|${this._synonymId}|${this._orderOrigination}|${this._orderSentenceId}|${this._nomenclatureId}|${this._signTimeInteraction}}`\n : `{${this._orderAction}|${this._orderId}}`;\n }\n}\n","import { CclOpts } from '../types';\n\n/**\n * A generic wrapper function for `XMLCclRequest` which simplifies it's use.\n * @param {CclOpts} opts - Required options for the CCL request.\n * @returns a promise of type `T` where `T` is the type or interface which represents\n * the resolved data from the CCL request.\n * @resolves the resolved data of type `T` from the CCL request.\n * @rejects with an error message if the CCL request fails.\n */\nexport function makeCclRequest<T>(opts: CclOpts): Promise<T> {\n const { prg, excludeMine, params } = opts;\n const paramsList =\n (excludeMine ? '' : \"'MINE',\") +\n params\n .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))\n .join(',');\n return new Promise((resolve, reject) => {\n try {\n // @ts-ignore - exists in PowerChart\n const request = new window.XMLCclRequest();\n request.open('GET', `${prg}`);\n request.send(paramsList);\n request.onreadystatechange = function() {\n const data: T = JSON.parse(request.responseText);\n if (request.readyState === 4 && request.status === 200) {\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${\n request.readyState\n } on ${prg} with params ${paramsList} returning response text: ${request.responseText ||\n 'no response text'}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n"],"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","data","JSON","parse","responseText","readyState","status"],"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;AAA1B,KAAhB;;AAEA,SAAKI,cAAL,GAAsB,CAAtB;;AAEA,SAAKH,QAAL,CAAcD,cAAd,GAA+B,CAA/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O,CAACQ,UAAR,KAAuB,CAAvB,IAA4BR,OAAO,CAACS,MAAR,KAAmB,GAAnD,EAAwD;AACtDX,UAAAA,OAAO,CAACM,IAAD,CAAP;AACD,SAFD,MAEO;AACLL,UAAAA,MAAM,wBACiBC,OAAO,CAACS,MADzB,wBAEFT,OAAO,CAACQ,UAFN,YAGGnB,GAHH,qBAGsBG,UAHtB,mCAG6DQ,OAAO,CAACO,YAAR,IAC/D,kBAJE,EAAN;AAMD;AACF,OAZD;AAaD,KAlBD,CAkBE,OAAO1D,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYC,cAAjB,EAAiC;AAC/BiD,QAAAA,MAAM,oEAC4DP,UAD5D,gBAC+EH,GAD/E,QAAN;AAGD,OAJD,MAIO;AACL,cAAMxC,CAAN;AACD;AACF;AACF,GA5BM,CAAP;AA6BD;;;;;;"}
|
|
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, CclRequestResponse, XmlCclStatus } from '../types';\n\nconst statusCodeMap: Map<number, XmlCclStatus> = new Map();\nstatusCodeMap.set(200, 'success');\nstatusCodeMap.set(405, 'method not allowed');\nstatusCodeMap.set(409, 'invalid state');\nstatusCodeMap.set(492, 'non-fatal error');\nstatusCodeMap.set(493, 'memory error');\nstatusCodeMap.set(500, 'internal server exception');\n\n/**\n * A generic wrapper function for `XMLCclRequest` which simplifies it's use.\n * @param {CclOpts} opts - Required options for the CCL request.\n * @returns a promise of type `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @resolves the `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @rejects with an error message if the CCL request fails.\n */\nexport function makeCclRequest<T>(\n opts: CclOpts\n): Promise<CclRequestResponse<T>> {\n const { prg, excludeMine, params } = opts;\n const paramsList =\n (excludeMine ? '' : \"'MINE',\") +\n params\n .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))\n .join(',');\n return new Promise((resolve, reject) => {\n try {\n // @ts-ignore - exists in PowerChart\n const request = new window.XMLCclRequest();\n request.open('GET', `${prg}`);\n request.send(paramsList);\n request.onreadystatechange = function() {\n const data: CclRequestResponse<T> = {\n meta: {\n responseText: request.responseText,\n status: request.status,\n statusText:\n statusCodeMap.get(request.status) ||\n 'status refers to unknown error',\n },\n data:\n request.responseText === ''\n ? undefined\n : JSON.parse(request.responseText),\n };\n if (request.readyState === 4) {\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${\n request.readyState\n } on ${prg} with params ${paramsList} returning response text: ${request.responseText ||\n 'no response text'}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n"],"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","statusCodeMap","Map","set","makeCclRequest","prg","excludeMine","params","paramsList","map","type","param","join","Promise","resolve","reject","request","XMLCclRequest","open","onreadystatechange","data","meta","responseText","status","statusText","get","undefined","JSON","parse","readyState"],"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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D;AACF,OAxBD;AAyBD,KA9BD,CA8BE,OAAO5D,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYC,cAAjB,EAAiC;AAC/BoD,QAAAA,MAAM,oEAC4DP,UAD5D,gBAC+EH,GAD/E,QAAN;AAGD,OAJD,MAIO;AACL,cAAM3C,CAAN;AACD;AACF;AACF,GAxCM,CAAP;AAyCD;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(){var t=this;this.getOrders=function(){return t._orders},this._tabList={tab:0,tabDisplayFlag:0},this.getTabList=function(){return t._tabList},this._personId=0,this.getPersonId=function(){return t._personId},this._encounterId=0,this.getEncounterId=function(){return t._encounterId},this._powerPlanFlag=0,this.getPowerPlanFlag=function(){return t._powerPlanFlag},this._defaultDisplay=0,this.getDefaultDisplay=function(){return t._defaultDisplay},this._silentSignFlag=0,this.getSilentSignFlag=function(){return t._silentSignFlag},this._orders=[],this._tabList={tab:0,tabDisplayFlag:0},this._powerPlanFlag=0,this._tabList.tabDisplayFlag=0,this.customizeOrderListProfile(),this.launchOrderProfile(),this._silentSignFlag=0}var r=t.prototype;return r.forPerson=function(t){return this._personId=t,this},r.forEncounter=function(t){return this._encounterId=t,this},r.addOrders=function(t){return Array.isArray(t)||(t=[t]),this._orders=this._orders.concat(t),this},r.enablePowerPlans=function(){return this._powerPlanFlag=24,this},r.customizeOrderListProfile=function(){return this._tabList.tab=2,this},r.customizeMedicationListProfile=function(){return this._tabList.tab=3,this},r.enablePowerOrders=function(){return this._tabList.tabDisplayFlag=127,this},r.launchOrderSearch=function(){return this._defaultDisplay=8,this},r.launchOrderProfile=function(){return this._defaultDisplay=16,this},r.launchOrdersForSignature=function(){return this._defaultDisplay=32,this},r.signSilently=function(){return this._silentSignFlag=1,this},r.send=function(){try{window.MPAGES_EVENT("ORDERS",this.toString())}catch(t){if(!(t instanceof ReferenceError))throw t;console.warn("We're likely not inside PowerChart. The output would be an MPAGES_EVENT: "+this.toString())}},r.toString=function(){var t=this._personId+"|"+this._encounterId+"|",r="";return this._orders.forEach((function(t){r+=t.toString()})),""+t+r+"|"+this._powerPlanFlag+"|{"+this._tabList.tab+"|"+this._tabList.tabDisplayFlag+"}|"+this._defaultDisplay+"|"+this._silentSignFlag},t}()
|
|
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}(),r=function(){function t(){var t=this;this._orderAction="",this.getOrderAction=function(){return t._orderAction},this._orderId=0,this.getOrderId=function(){return t._orderId},this._synonymId=0,this.getSynonymId=function(){return t._synonymId},this._orderOrigination=0,this.getOrderOrigination=function(){return t._orderOrigination},this._orderSentenceId=0,this.getOrderSentenceId=function(){return t._orderSentenceId},this._nomenclatureId=0,this.getNomenclatureId=function(){return t._nomenclatureId},this._signTimeInteraction=0,this.getSignTimeInteraction=function(){return t._signTimeInteraction}}var r=t.prototype;return r.willActivate=function(t){return this._orderAction="ACTIVATE",this._orderId=t,this},r.willCancelDiscontinue=function(t){return this._orderAction="CANCEL DC",this._orderId=t,this},r.willCancelReorder=function(t){return this._orderAction="CANCEL REORD",this._orderId=t,this},r.willClear=function(t){return this._orderAction="CLEAR",this._orderId=t,this},r.willConvertInpatient=function(t){return this._orderAction="CONVERT_INPAT",this._orderId=t,this},r.willConvertToPrescriptionOrder=function(t){return this._orderAction="CONVERT_RX",this._orderId=t,this},r.willModify=function(t){return this._orderAction="MODIFY",this._orderId=t,this},r.willMakeNewOrder=function(t,r){var e=r||{},n=e.isRxOrder,i=e.isSatelliteOrder,s=e.orderSentenceId,o=e.nomenclatureId,a=e.skipInteractionCheckUntilSign;if(n&&i)throw new Error("must select either isRxOrder or isSatelliteOrder");return this._orderAction="ORDER",this._synonymId=t,this._orderSentenceId=s||0,this._nomenclatureId=o||0,this._signTimeInteraction=a?1:0,this._orderOrigination=i?5:n?1:0,this},r.willRenewNonPrescription=function(t){return this._orderAction="RENEW",this._orderId=t,this},r.willRenewPrescription=function(t){return this._orderAction="RENEW_RX",this._orderId=t,this},r.willCopyExistingOrder=function(t){return this._orderAction="REPEAT",this._orderId=t,this},r.willResumeSuspendedOrder=function(t){return this._orderAction="RESUME",this._orderId=t,this},r.willSuspend=function(t){return this._orderAction="SUSPEND",this._orderId=t,this},r.toString=function(){return"ORDER"===this._orderAction?"{"+this._orderAction+"|"+this._synonymId+"|"+this._orderOrigination+"|"+this._orderSentenceId+"|"+this._nomenclatureId+"|"+this._signTimeInteraction+"}":"{"+this._orderAction+"|"+this._orderId+"}"},t}(),e=new Map;e.set(200,"success"),e.set(405,"method not allowed"),e.set(409,"invalid state"),e.set(492,"non-fatal error"),e.set(493,"memory error"),e.set(500,"internal server exception"),exports.MPageOrder=r,exports.MPageOrderEvent=t,exports.makeCclRequest=function(t){var r=t.prg,n=(t.excludeMine?"":"'MINE',")+t.params.map((function(t){var r=t.param;return"string"===t.type?"'"+r+"'":r})).join(",");return new Promise((function(t,i){try{var s=new window.XMLCclRequest;s.open("GET",""+r),s.send(n),s.onreadystatechange=function(){var o={meta:{responseText:s.responseText,status:s.status,statusText:e.get(s.status)||"status refers to unknown error"},data:""===s.responseText?void 0:JSON.parse(s.responseText)};4===s.readyState?t(o):i("error with status "+s.status+" and readyState "+s.readyState+" on "+r+" with params "+n+" returning response text: "+(s.responseText||"no response text"))}}catch(t){if(!(t instanceof ReferenceError))throw t;i("We're likely not inside PowerChart. We cannot send request: \""+n+'" to "'+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","../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 const data: T = JSON.parse(request.responseText);\n if (request.readyState === 4 && request.status === 200) {\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${\n request.readyState\n } on ${prg} with params ${paramsList} returning response text: ${request.responseText ||\n 'no response text'}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n"],"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","data","JSON","parse","responseText","readyState","status"],"mappings":"wEAEMA,oDAEQ,kBAAMC,EAAKC,uBAEqC,CAC1DC,IAAK,EACLC,eAAgB,mBAEL,kBAAMH,EAAKI,yBAEI,mBACd,kBAAMJ,EAAKK,6BAEM,sBACd,kBAAML,EAAKM,kCAEK,wBACd,kBAAMN,EAAKO,qCAEI,yBACd,kBAAMP,EAAKQ,sCAEG,yBACd,kBAAMR,EAAKS,sBAGxBR,QAAU,QACVG,SAAW,CAAEF,IAAK,EAAGC,eAAgB,QAErCI,eAAiB,OAEjBH,SAASD,eAAiB,OAC1BO,iCACAC,0BAEAF,gBAAkB,6BAGzBG,UAAA,SAAUC,eACHR,UAAYQ,EACVC,QAGTC,aAAA,SAAaF,eACNP,aAAeO,EACbC,QAGTE,UAAA,SAAUC,UACHC,MAAMC,QAAQF,KACjBA,EAAS,CAACA,SAEPhB,QAAUa,KAAKb,QAAQmB,OAAOH,GAC5BH,QAGTO,iBAAA,uBACOd,eAAiB,GACfO,QAGTJ,0BAAA,uBACON,SAASF,IAAM,EACbY,QAGTQ,+BAAA,uBACOlB,SAASF,IAAM,EACbY,QAGTS,kBAAA,uBACOnB,SAASD,eAAiB,IACxBW,QAGTU,kBAAA,uBACOhB,gBAAkB,EAChBM,QAGTH,mBAAA,uBACOH,gBAAkB,GAChBM,QAGTW,yBAAA,uBACOjB,gBAAkB,GAChBM,QAGTY,aAAA,uBACOjB,gBAAkB,EAChBK,QAGTa,KAAA,eAGIC,OAAOC,aAAa,SAAUf,KAAKgB,YACnC,MAAOC,QACHA,aA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BR,aAAe,aACfC,SAAWO,EACTjC,QASTkD,sBAAA,SAAsBjB,eACfR,aAAe,gBACfC,SAAWO,EACTjC,QASTmD,sBAAA,SAAsBlB,eACfR,aAAe,cACfC,SAAWO,EACTjC,QASToD,yBAAA,SAAyBnB,eAClBR,aAAe,cACfC,SAAWO,EACTjC,QASTqD,YAAA,SAAYpB,eACLR,aAAe,eACfC,SAAWO,EACTjC,QASTgB,SAAA,iBAC+B,UAAtBhB,KAAKyB,iBACJzB,KAAKyB,iBAAgBzB,KAAK2B,eAAc3B,KAAK4B,sBAAqB5B,KAAK6B,qBAAoB7B,KAAK8B,oBAAmB9B,KAAK+B,6BACxH/B,KAAKyB,iBAAgBzB,KAAK0B,6EC7MJgB,OACxBY,EAA6BZ,EAA7BY,IACFC,GAD+Bb,EAAxBc,YAEI,GAAK,WAFed,EAAXe,OAIrBC,KAAI,gBAASC,IAAAA,YAAsB,aAA5BC,SAA2CD,MAAWA,KAC7DE,KAAK,YACH,IAAIC,SAAQ,SAACC,EAASC,WAGnBC,EAAU,IAAInD,OAAOoD,cAC3BD,EAAQE,KAAK,SAAUb,GACvBW,EAAQpD,KAAK0C,GACbU,EAAQG,mBAAqB,eACrBC,EAAUC,KAAKC,MAAMN,EAAQO,cACR,IAAvBP,EAAQQ,YAAuC,MAAnBR,EAAQS,OACtCX,EAAQM,GAERL,uBACuBC,EAAQS,0BAC3BT,EAAQQ,kBACHnB,kBAAmBC,gCAAuCU,EAAQO,cACvE,sBAIR,MAAOvD,QACHA,aAAaC,sBAKTD,EAJN+C,mEACkET,WAAmBD"}
|
|
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, CclRequestResponse, XmlCclStatus } from '../types';\n\nconst statusCodeMap: Map<number, XmlCclStatus> = new Map();\nstatusCodeMap.set(200, 'success');\nstatusCodeMap.set(405, 'method not allowed');\nstatusCodeMap.set(409, 'invalid state');\nstatusCodeMap.set(492, 'non-fatal error');\nstatusCodeMap.set(493, 'memory error');\nstatusCodeMap.set(500, 'internal server exception');\n\n/**\n * A generic wrapper function for `XMLCclRequest` which simplifies it's use.\n * @param {CclOpts} opts - Required options for the CCL request.\n * @returns a promise of type `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @resolves the `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @rejects with an error message if the CCL request fails.\n */\nexport function makeCclRequest<T>(\n opts: CclOpts\n): Promise<CclRequestResponse<T>> {\n const { prg, excludeMine, params } = opts;\n const paramsList =\n (excludeMine ? '' : \"'MINE',\") +\n params\n .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))\n .join(',');\n return new Promise((resolve, reject) => {\n try {\n // @ts-ignore - exists in PowerChart\n const request = new window.XMLCclRequest();\n request.open('GET', `${prg}`);\n request.send(paramsList);\n request.onreadystatechange = function() {\n const data: CclRequestResponse<T> = {\n meta: {\n responseText: request.responseText,\n status: request.status,\n statusText:\n statusCodeMap.get(request.status) ||\n 'status refers to unknown error',\n },\n data:\n request.responseText === ''\n ? undefined\n : JSON.parse(request.responseText),\n };\n if (request.readyState === 4) {\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${\n request.readyState\n } on ${prg} with params ${paramsList} returning response text: ${request.responseText ||\n 'no response text'}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n"],"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","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","statusCodeMap","Map","set","prg","paramsList","excludeMine","params","map","param","type","join","Promise","resolve","reject","request","XMLCclRequest","open","onreadystatechange","data","meta","responseText","status","statusText","get","undefined","JSON","parse","readyState"],"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,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AIC,IACrDD,EAAcE,IAAI,IAAK,WACvBF,EAAcE,IAAI,IAAK,sBACvBF,EAAcE,IAAI,IAAK,iBACvBF,EAAcE,IAAI,IAAK,mBACvBF,EAAcE,IAAI,IAAK,gBACvBF,EAAcE,IAAI,IAAK,4GAkBrBd,OAEQe,EAA6Bf,EAA7Be,IACFC,GAD+BhB,EAAxBiB,YAEI,GAAK,WAFejB,EAAXkB,OAIrBC,KAAI,gBAASC,IAAAA,YAAsB,aAA5BC,SAA2CD,MAAWA,KAC7DE,KAAK,YACH,IAAIC,SAAQ,SAACC,EAASC,WAGnBC,EAAU,IAAIvD,OAAOwD,cAC3BD,EAAQE,KAAK,SAAUb,GACvBW,EAAQxD,KAAK8C,GACbU,EAAQG,mBAAqB,eACrBC,EAA8B,CAClCC,KAAM,CACJC,aAAcN,EAAQM,aACtBC,OAAQP,EAAQO,OAChBC,WACEtB,EAAcuB,IAAIT,EAAQO,SAC1B,kCAEJH,KAC2B,KAAzBJ,EAAQM,kBACJI,EACAC,KAAKC,MAAMZ,EAAQM,eAEA,IAAvBN,EAAQa,WACVf,EAAQM,GAERL,uBACuBC,EAAQO,0BAC3BP,EAAQa,kBACHxB,kBAAmBC,gCAAuCU,EAAQM,cACvE,sBAIR,MAAO1D,QACHA,aAAaC,sBAKTD,EAJNmD,mEACkET,WAAmBD"}
|
|
@@ -414,14 +414,29 @@ var MPageOrder = /*#__PURE__*/function () {
|
|
|
414
414
|
return MPageOrder;
|
|
415
415
|
}();
|
|
416
416
|
|
|
417
|
+
var statusCodeMap = /*#__PURE__*/new Map();
|
|
418
|
+
statusCodeMap.set(200, 'success');
|
|
419
|
+
statusCodeMap.set(405, 'method not allowed');
|
|
420
|
+
statusCodeMap.set(409, 'invalid state');
|
|
421
|
+
statusCodeMap.set(492, 'non-fatal error');
|
|
422
|
+
statusCodeMap.set(493, 'memory error');
|
|
423
|
+
statusCodeMap.set(500, 'internal server exception');
|
|
417
424
|
/**
|
|
418
425
|
* A generic wrapper function for `XMLCclRequest` which simplifies it's use.
|
|
419
426
|
* @param {CclOpts} opts - Required options for the CCL request.
|
|
420
|
-
* @returns a promise of type `T
|
|
421
|
-
* the resolved data from the CCL request.
|
|
422
|
-
*
|
|
427
|
+
* @returns a promise of type `CclRequestResponse<T>` where `T` is the type
|
|
428
|
+
* or interface which represents the resolved data from the CCL request. If
|
|
429
|
+
* no data are returned, that is an empty string, from the XMLCclRequest then
|
|
430
|
+
* the `data` field will be set to `undefined`. The objects `meta` field
|
|
431
|
+
* includes `responseText`, `status`, and `statusTest` fields.
|
|
432
|
+
* @resolves the `CclRequestResponse<T>` where `T` is the type
|
|
433
|
+
* or interface which represents the resolved data from the CCL request. If
|
|
434
|
+
* no data are returned, that is an empty string, from the XMLCclRequest then
|
|
435
|
+
* the `data` field will be set to `undefined`. The objects `meta` field
|
|
436
|
+
* includes `responseText`, `status`, and `statusTest` fields.
|
|
423
437
|
* @rejects with an error message if the CCL request fails.
|
|
424
438
|
*/
|
|
439
|
+
|
|
425
440
|
function makeCclRequest(opts) {
|
|
426
441
|
var prg = opts.prg,
|
|
427
442
|
excludeMine = opts.excludeMine,
|
|
@@ -439,9 +454,16 @@ function makeCclRequest(opts) {
|
|
|
439
454
|
request.send(paramsList);
|
|
440
455
|
|
|
441
456
|
request.onreadystatechange = function () {
|
|
442
|
-
var data =
|
|
443
|
-
|
|
444
|
-
|
|
457
|
+
var data = {
|
|
458
|
+
meta: {
|
|
459
|
+
responseText: request.responseText,
|
|
460
|
+
status: request.status,
|
|
461
|
+
statusText: statusCodeMap.get(request.status) || 'status refers to unknown error'
|
|
462
|
+
},
|
|
463
|
+
data: request.responseText === '' ? undefined : JSON.parse(request.responseText)
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
if (request.readyState === 4) {
|
|
445
467
|
resolve(data);
|
|
446
468
|
} else {
|
|
447
469
|
reject("error with status " + request.status + " and readyState " + request.readyState + " on " + prg + " with params " + paramsList + " returning response text: " + (request.responseText || 'no response text'));
|
|
@@ -1 +1 @@
|
|
|
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 const data: T = JSON.parse(request.responseText);\n if (request.readyState === 4 && request.status === 200) {\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${\n request.readyState\n } on ${prg} with params ${paramsList} returning response text: ${request.responseText ||\n 'no response text'}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n"],"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","data","JSON","parse","responseText","readyState","status"],"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;;AA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EQ,GAFR,CAFF;AAKA,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV;AACjB,QAAI;AACF;AACA,UAAMC,OAAO,GAAG,IAAItD,MAAM,CAACuD,aAAX,EAAhB;AACAD,MAAAA,OAAO,CAACE,IAAR,CAAa,KAAb,OAAuBb,GAAvB;AACAW,MAAAA,OAAO,CAACvD,IAAR,CAAa+C,UAAb;;AACAQ,MAAAA,OAAO,CAACG,kBAAR,GAA6B;AAC3B,YAAMC,IAAI,GAAMC,IAAI,CAACC,KAAL,CAAWN,OAAO,CAACO,YAAnB,CAAhB;;AACA,YAAIP,OAAO,CAACQ,UAAR,KAAuB,CAAvB,IAA4BR,OAAO,CAACS,MAAR,KAAmB,GAAnD,EAAwD;AACtDX,UAAAA,OAAO,CAACM,IAAD,CAAP;AACD,SAFD,MAEO;AACLL,UAAAA,MAAM,wBACiBC,OAAO,CAACS,MADzB,wBAEFT,OAAO,CAACQ,UAFN,YAGGnB,GAHH,qBAGsBG,UAHtB,mCAG6DQ,OAAO,CAACO,YAAR,IAC/D,kBAJE,EAAN;AAMD;AACF,OAZD;AAaD,KAlBD,CAkBE,OAAO1D,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYC,cAAjB,EAAiC;AAC/BiD,QAAAA,MAAM,oEAC4DP,UAD5D,gBAC+EH,GAD/E,QAAN;AAGD,OAJD,MAIO;AACL,cAAMxC,CAAN;AACD;AACF;AACF,GA5BM,CAAP;AA6BD;;;;"}
|
|
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, CclRequestResponse, XmlCclStatus } from '../types';\n\nconst statusCodeMap: Map<number, XmlCclStatus> = new Map();\nstatusCodeMap.set(200, 'success');\nstatusCodeMap.set(405, 'method not allowed');\nstatusCodeMap.set(409, 'invalid state');\nstatusCodeMap.set(492, 'non-fatal error');\nstatusCodeMap.set(493, 'memory error');\nstatusCodeMap.set(500, 'internal server exception');\n\n/**\n * A generic wrapper function for `XMLCclRequest` which simplifies it's use.\n * @param {CclOpts} opts - Required options for the CCL request.\n * @returns a promise of type `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @resolves the `CclRequestResponse<T>` where `T` is the type\n * or interface which represents the resolved data from the CCL request. If\n * no data are returned, that is an empty string, from the XMLCclRequest then\n * the `data` field will be set to `undefined`. The objects `meta` field\n * includes `responseText`, `status`, and `statusTest` fields.\n * @rejects with an error message if the CCL request fails.\n */\nexport function makeCclRequest<T>(\n opts: CclOpts\n): Promise<CclRequestResponse<T>> {\n const { prg, excludeMine, params } = opts;\n const paramsList =\n (excludeMine ? '' : \"'MINE',\") +\n params\n .map(({ type, param }) => (type === 'string' ? `'${param}'` : param))\n .join(',');\n return new Promise((resolve, reject) => {\n try {\n // @ts-ignore - exists in PowerChart\n const request = new window.XMLCclRequest();\n request.open('GET', `${prg}`);\n request.send(paramsList);\n request.onreadystatechange = function() {\n const data: CclRequestResponse<T> = {\n meta: {\n responseText: request.responseText,\n status: request.status,\n statusText:\n statusCodeMap.get(request.status) ||\n 'status refers to unknown error',\n },\n data:\n request.responseText === ''\n ? undefined\n : JSON.parse(request.responseText),\n };\n if (request.readyState === 4) {\n resolve(data);\n } else {\n reject(\n `error with status ${request.status} and readyState ${\n request.readyState\n } on ${prg} with params ${paramsList} returning response text: ${request.responseText ||\n 'no response text'}`\n );\n }\n };\n } catch (e) {\n if (e instanceof ReferenceError) {\n reject(\n `We're likely not inside PowerChart. We cannot send request: \"${paramsList}\" to \"${prg}\"`\n );\n } else {\n throw e;\n }\n }\n });\n}\n"],"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","statusCodeMap","Map","set","makeCclRequest","prg","excludeMine","params","paramsList","map","type","param","join","Promise","resolve","reject","request","XMLCclRequest","open","onreadystatechange","data","meta","responseText","status","statusText","get","undefined","JSON","parse","readyState"],"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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ACFJ,OAAO,CAACM,YAAR,KAAyB,EAAzB,GACII,SADJ,GAEIC,IAAI,CAACC,KAAL,CAAWZ,OAAO,CAACM,YAAnB;AAX4B,SAApC;;AAaA,YAAIN,OAAO,CAACa,UAAR,KAAuB,CAA3B,EAA8B;AAC5Bf,UAAAA,OAAO,CAACM,IAAD,CAAP;AACD,SAFD,MAEO;AACLL,UAAAA,MAAM,wBACiBC,OAAO,CAACO,MADzB,wBAEFP,OAAO,CAACa,UAFN,YAGGxB,GAHH,qBAGsBG,UAHtB,mCAG6DQ,OAAO,CAACM,YAAR,IAC/D,kBAJE,EAAN;AAMD;AACF,OAxBD;AAyBD,KA9BD,CA8BE,OAAO5D,CAAP,EAAU;AACV,UAAIA,CAAC,YAAYC,cAAjB,EAAiC;AAC/BoD,QAAAA,MAAM,oEAC4DP,UAD5D,gBAC+EH,GAD/E,QAAN;AAGD,OAJD,MAIO;AACL,cAAM3C,CAAN;AACD;AACF;AACF,GAxCM,CAAP;AAyCD;;;;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -26,6 +26,24 @@ export declare type CclOpts = {
|
|
|
26
26
|
excludeMine?: boolean;
|
|
27
27
|
params: Array<CclCallParam>;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* A type functioning as a convience wrapper for several status
|
|
31
|
+
* codes, respresented as strings, that are returned by XMLCclRequest.
|
|
32
|
+
*/
|
|
33
|
+
export declare type XmlCclStatus = 'success' | 'method not allowed' | 'invalid state' | 'non-fatal error' | 'memory error' | 'internal server exception' | 'status refers to unknown error';
|
|
34
|
+
/**
|
|
35
|
+
* A type which represents the full set of data returned from an XmlCclRequest and important, formatted
|
|
36
|
+
* metadata to help with debugging and error management. This is a generic type and data will represent
|
|
37
|
+
* the type `T` which is the type or interface which represents the resolved data from the CCL request.
|
|
38
|
+
*/
|
|
39
|
+
export declare type CclRequestResponse<T> = {
|
|
40
|
+
meta: {
|
|
41
|
+
responseText: string;
|
|
42
|
+
status: number;
|
|
43
|
+
statusText: XmlCclStatus;
|
|
44
|
+
};
|
|
45
|
+
data: T | undefined;
|
|
46
|
+
};
|
|
29
47
|
/**
|
|
30
48
|
* Options for a new order
|
|
31
49
|
* @param {boolean} isRxOrder Marks the order order as a prescription. Is mutually exclusive from
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { CclOpts } from '../types';
|
|
1
|
+
import { CclOpts, CclRequestResponse } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* A generic wrapper function for `XMLCclRequest` which simplifies it's use.
|
|
4
4
|
* @param {CclOpts} opts - Required options for the CCL request.
|
|
5
|
-
* @returns a promise of type `T
|
|
6
|
-
* the resolved data from the CCL request.
|
|
7
|
-
*
|
|
5
|
+
* @returns a promise of type `CclRequestResponse<T>` where `T` is the type
|
|
6
|
+
* or interface which represents the resolved data from the CCL request. If
|
|
7
|
+
* no data are returned, that is an empty string, from the XMLCclRequest then
|
|
8
|
+
* the `data` field will be set to `undefined`. The objects `meta` field
|
|
9
|
+
* includes `responseText`, `status`, and `statusTest` fields.
|
|
10
|
+
* @resolves the `CclRequestResponse<T>` where `T` is the type
|
|
11
|
+
* or interface which represents the resolved data from the CCL request. If
|
|
12
|
+
* no data are returned, that is an empty string, from the XMLCclRequest then
|
|
13
|
+
* the `data` field will be set to `undefined`. The objects `meta` field
|
|
14
|
+
* includes `responseText`, `status`, and `statusTest` fields.
|
|
8
15
|
* @rejects with an error message if the CCL request fails.
|
|
9
16
|
*/
|
|
10
|
-
export declare function makeCclRequest<T>(opts: CclOpts): Promise<T
|
|
17
|
+
export declare function makeCclRequest<T>(opts: CclOpts): Promise<CclRequestResponse<T>>;
|
package/package.json
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -28,6 +28,33 @@ export type CclOpts = {
|
|
|
28
28
|
params: Array<CclCallParam>;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A type functioning as a convience wrapper for several status
|
|
33
|
+
* codes, respresented as strings, that are returned by XMLCclRequest.
|
|
34
|
+
*/
|
|
35
|
+
export type XmlCclStatus =
|
|
36
|
+
| 'success'
|
|
37
|
+
| 'method not allowed'
|
|
38
|
+
| 'invalid state'
|
|
39
|
+
| 'non-fatal error'
|
|
40
|
+
| 'memory error'
|
|
41
|
+
| 'internal server exception'
|
|
42
|
+
| 'status refers to unknown error';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A type which represents the full set of data returned from an XmlCclRequest and important, formatted
|
|
46
|
+
* metadata to help with debugging and error management. This is a generic type and data will represent
|
|
47
|
+
* the type `T` which is the type or interface which represents the resolved data from the CCL request.
|
|
48
|
+
*/
|
|
49
|
+
export type CclRequestResponse<T> = {
|
|
50
|
+
meta: {
|
|
51
|
+
responseText: string;
|
|
52
|
+
status: number;
|
|
53
|
+
statusText: XmlCclStatus;
|
|
54
|
+
};
|
|
55
|
+
data: T | undefined;
|
|
56
|
+
};
|
|
57
|
+
|
|
31
58
|
/**
|
|
32
59
|
* Options for a new order
|
|
33
60
|
* @param {boolean} isRxOrder Marks the order order as a prescription. Is mutually exclusive from
|
package/src/utils/index.ts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
import { CclOpts } from '../types';
|
|
1
|
+
import { CclOpts, CclRequestResponse, XmlCclStatus } from '../types';
|
|
2
|
+
|
|
3
|
+
const statusCodeMap: Map<number, XmlCclStatus> = new Map();
|
|
4
|
+
statusCodeMap.set(200, 'success');
|
|
5
|
+
statusCodeMap.set(405, 'method not allowed');
|
|
6
|
+
statusCodeMap.set(409, 'invalid state');
|
|
7
|
+
statusCodeMap.set(492, 'non-fatal error');
|
|
8
|
+
statusCodeMap.set(493, 'memory error');
|
|
9
|
+
statusCodeMap.set(500, 'internal server exception');
|
|
2
10
|
|
|
3
11
|
/**
|
|
4
12
|
* A generic wrapper function for `XMLCclRequest` which simplifies it's use.
|
|
5
13
|
* @param {CclOpts} opts - Required options for the CCL request.
|
|
6
|
-
* @returns a promise of type `T
|
|
7
|
-
* the resolved data from the CCL request.
|
|
8
|
-
*
|
|
14
|
+
* @returns a promise of type `CclRequestResponse<T>` where `T` is the type
|
|
15
|
+
* or interface which represents the resolved data from the CCL request. If
|
|
16
|
+
* no data are returned, that is an empty string, from the XMLCclRequest then
|
|
17
|
+
* the `data` field will be set to `undefined`. The objects `meta` field
|
|
18
|
+
* includes `responseText`, `status`, and `statusTest` fields.
|
|
19
|
+
* @resolves the `CclRequestResponse<T>` where `T` is the type
|
|
20
|
+
* or interface which represents the resolved data from the CCL request. If
|
|
21
|
+
* no data are returned, that is an empty string, from the XMLCclRequest then
|
|
22
|
+
* the `data` field will be set to `undefined`. The objects `meta` field
|
|
23
|
+
* includes `responseText`, `status`, and `statusTest` fields.
|
|
9
24
|
* @rejects with an error message if the CCL request fails.
|
|
10
25
|
*/
|
|
11
|
-
export function makeCclRequest<T>(
|
|
26
|
+
export function makeCclRequest<T>(
|
|
27
|
+
opts: CclOpts
|
|
28
|
+
): Promise<CclRequestResponse<T>> {
|
|
12
29
|
const { prg, excludeMine, params } = opts;
|
|
13
30
|
const paramsList =
|
|
14
31
|
(excludeMine ? '' : "'MINE',") +
|
|
@@ -22,8 +39,20 @@ export function makeCclRequest<T>(opts: CclOpts): Promise<T> {
|
|
|
22
39
|
request.open('GET', `${prg}`);
|
|
23
40
|
request.send(paramsList);
|
|
24
41
|
request.onreadystatechange = function() {
|
|
25
|
-
const data: T =
|
|
26
|
-
|
|
42
|
+
const data: CclRequestResponse<T> = {
|
|
43
|
+
meta: {
|
|
44
|
+
responseText: request.responseText,
|
|
45
|
+
status: request.status,
|
|
46
|
+
statusText:
|
|
47
|
+
statusCodeMap.get(request.status) ||
|
|
48
|
+
'status refers to unknown error',
|
|
49
|
+
},
|
|
50
|
+
data:
|
|
51
|
+
request.responseText === ''
|
|
52
|
+
? undefined
|
|
53
|
+
: JSON.parse(request.responseText),
|
|
54
|
+
};
|
|
55
|
+
if (request.readyState === 4) {
|
|
27
56
|
resolve(data);
|
|
28
57
|
} else {
|
|
29
58
|
reject(
|