fluent-cerner-js 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/index.ts","../src/addAddendumToDocumentAsync.ts","../src/createNewDocumentAsync.ts","../src/getValidEncountersAsync.ts","../src/launchClinicalNoteAsync.ts","../src/launchDischargeProcessAsync.ts","../src/launchPatientEducationAsync.ts","../src/launchPowerFormAsync.ts","../src/launchPowerNoteAsync.ts","../src/manageAppointmentAsync.ts","../src/openApplicationAsync.ts","../src/openOrganizerTabAsync.ts","../src/openPatientTabAsync.ts","../src/openWebsiteByUrlAsync.ts","../src/submitOrdersAsync.ts","../src/utils/createOrderString.ts","../src/utils/calculateMOEWBitmask.ts","../src/utils/addNewOrdersToScratchPadAsync.ts","../src/utils/addPowerPlanWithDetailsAsync.ts","../src/utils/createMOEWAsync.ts","../src/utils/destroyMOEWAsync.ts","../src/utils/displayMOEWAsync.ts","../src/utils/getOrdersPlacedAsync.ts","../src/utils/signOrdersAsync.ts","../src/submitPowerOrdersAsync.ts"],"sourcesContent":["import { makeCclRequestAsync } from 'easy-ccl-request';\nimport type {\n CclCallParam,\n CclRequestResponse,\n XmlCclResult,\n XmlCclReadyState,\n} from 'easy-ccl-request';\nimport { addAddendumToDocumentAsync } from './addAddendumToDocumentAsync';\nimport { createNewDocumentAsync } from './createNewDocumentAsync';\nimport { getValidEncountersAsync } from './getValidEncountersAsync';\nimport { launchClinicalNoteAsync } from './launchClinicalNoteAsync';\nimport type {\n ClinicalNoteOpts,\n InheretanceProps,\n ViewOption,\n} from './launchClinicalNoteAsync';\nimport { launchDischargeProcessAsync } from './launchDischargeProcessAsync';\nimport { launchPatientEducationAsync } from './launchPatientEducationAsync';\nimport { launchPowerFormAsync } from './launchPowerFormAsync';\nimport { launchPowerNoteAsync } from './launchPowerNoteAsync';\nimport { manageAppointmentAsync } from './manageAppointmentAsync';\nimport type {\n AppointmentAction,\n AppointmentReturn,\n} from './manageAppointmentAsync';\nimport { openApplicationAsync } from './openApplicationAsync';\nimport type {\n OpenApplicationArgument,\n OpenApplicationMode,\n} from './openApplicationAsync';\nimport { openOrganizerTabAsync } from './openOrganizerTabAsync';\nimport { openPatientTabAsync } from './openPatientTabAsync';\nimport { openWebsiteByUrlAsync } from './openWebsiteByUrlAsync';\nimport { submitOrdersAsync } from './submitOrdersAsync';\nimport type {\n SubmitOrderAsyncOpts,\n SubmitOrderAsyncReturn,\n SubmitOrdersAsyncStatus,\n OrderAction,\n OrderOpts,\n Order,\n} from './submitOrdersAsync';\nimport { submitPowerOrdersAsync } from './submitPowerOrdersAsync';\n\n// Export functions\nexport {\n addAddendumToDocumentAsync,\n createNewDocumentAsync,\n getValidEncountersAsync,\n launchClinicalNoteAsync,\n launchDischargeProcessAsync,\n launchPatientEducationAsync,\n launchPowerFormAsync,\n launchPowerNoteAsync,\n makeCclRequestAsync,\n manageAppointmentAsync,\n openApplicationAsync,\n openOrganizerTabAsync,\n openPatientTabAsync,\n openWebsiteByUrlAsync,\n submitOrdersAsync,\n submitPowerOrdersAsync,\n};\n\n// Export types\nexport type {\n AppointmentAction,\n AppointmentReturn,\n CclCallParam,\n CclRequestResponse,\n ClinicalNoteOpts,\n InheretanceProps,\n OpenApplicationArgument,\n OpenApplicationMode,\n Order,\n OrderAction,\n OrderOpts as OrderStrOpts,\n SubmitOrderAsyncOpts,\n SubmitOrderAsyncReturn,\n SubmitOrdersAsyncStatus,\n ViewOption,\n XmlCclReadyState,\n XmlCclResult,\n};\n\nexport type PowerChartReturn = {\n inPowerChart: boolean;\n};\n\n/**\n * A type which represents the object to be returned from the launchClinicalNote() function.\n * @param {string} eventString - The string version of the MPageEvent\n * @param {boolean} inPowerChart - Returns `true` if being run from inside of PowerChart and returns `false` otherwise.\n **/\nexport type MPageEventReturn = PowerChartReturn & {\n eventString: string;\n};\n\n/**\n * @param {string} eventString - string being provided as an argument to the Discern\n * native function call.\n * @param {boolean} inPowerChart - whether or not the function is being run from inside of\n * PowerChart.\n * @param {boolean} badInput - whether or not the input provided to the function is valid as\n * reported by the Discern engine.\n */\nexport type ApplinkReturn = MPageEventReturn & { badInput: boolean };\n\ndeclare global {\n /**\n * A type which ensures that only valid DiscernCOMObjects can be\n * passed to the DiscernObjectFactory constructor.\n */\n type DiscernCOMObjects =\n | 'INFOBUTTONLINK'\n | 'DISCHARGEPROCESS'\n | 'DYNDOC'\n | 'KIACROSSMAPPING'\n | 'ORDERS'\n | 'PATIENTEDUCATION'\n | 'PEXAPPLICATIONSTATUS'\n | 'PEXSCHEDULINGACTIONS'\n | 'PMLISTMAINTENANCE'\n | 'POWERFORM'\n | 'POWERNOTE'\n | 'POWERORDERS'\n | 'PREGNANCY'\n | 'PVCONTXTMPAGE'\n | 'PVFRAMEWORKLINK'\n | 'PVPATIENTFOCUS'\n | 'PVPATIENTSEARCHMPAGE'\n | 'PVVIEWERMPAGE'\n | 'TASKDOC';\n interface Window {\n readonly external: External;\n /**\n * Interface for the Cerner Discern native function which provides the function\n * responsible for opening an application, chart tab, or organization level tab.\n * Useful for development but not intended for production use.\n * @param {0 | 1 | 100} mode - The _linkmode_ parameter for the APPLINK function.The value 0\n * is used for starting a solution by application name (e.g. Powerchart.exe), the value 1\n * is used for starting a solution by solution object (e.g. DiscernAnalytics.Application),\n * and the value 100 is used for launching a link, file, or executable through a shell execute\n * (e.g. launch a URL).\n * @param {string} target - The _launchobject_ parameter for the APPLINK function. This can\n * represent an executable name, application object, file, or link to start based on the\n * _mode_ (_linkmode_) parameter. This accepts Powerchart context variables, and using\n * `$APP_AppName$` is useful in place of the executable name if you watn to open a patient\n * in the context of the current solution.\n */\n APPLINK: (mode: 0 | 1 | 100, target: string, args: string) => Promise<null>;\n }\n export type DiscernObjectFactoryReturn = {\n /**\n * Creates the MOEW handle.\n * @param dPersonId {number} - the patient ID\n * @param dEncntrId {number} - the encounter ID in which orders would be placed\n * @param dwCustomizeFlag {number} - mask used to determine options available within the MOEW\n * @param dwTabFlag {number} - the type of list being customized (2 for orders, 3 for medications).\n * @param dwTabDisplayOptionsFlag {number} - mask specifying the components to display on the list.\n * @returns a `Promise` which resolves to an integer representing a handle to the MOEW instance. 0 indicates an invalid call or call from outside PowerChart.\n */\n CreateMOEW: (\n dPersonId: number,\n dEncntrId: number,\n dwCustomizeFlag: number,\n dwTabFlag: number,\n dwTabDisplayOptionsFlag: number\n ) => Promise<number>;\n /**\n * Creates PowerPlan objects from the pathway catalog IDs. CreateMOEW() must be called first.\n * @param lMOEWHandle {number} - the handle to the MOEW\n * @param planDetailsXMLBstr {string} - XML string containing the plan/pathway catalog IDs\n * @returns a `Promise` which resolves to an integer: 1 if the plan was added successfully, and 0 otherwise.\n */\n AddPowerPlanWithDetails: (\n lMOEWHandle: number,\n planDetailsXMLBstr: string\n ) => Promise<number>;\n /**\n * Attempts to add standalone orders to the scratchpad. CreateMOEW() must be called first.\n * @param lMOEWHandle {number} - the handle to the MOEW\n * @param newOrdersXMLBstr {string} - XML string containing the order details, including synonym IDs\n * @param bSignTimeInteractionChecking {boolean} - indicates if interaction checking should be performed at order sign time.\n * @returns a `Promise` which resolves to an integer: 1 if the orders were added successfully, and 0 otherwise.\n */\n AddNewOrdersToScratchpad: (\n lMOEWHandle: number,\n newOrdersXMLBstr: string,\n bSignTimeInteractionChecking: boolean\n ) => Promise<number>;\n /**\n * Displays the modal order entry window (MOEW).\n * @param {number} lMOEWHandle - the handle to the MOEW.\n * @returns a `Promise` which resolves to an integer (0). This appears to be returned upon either a successful or unsuccessful launch.\n */\n DisplayMOEW: (lMOEWHandle: number) => Promise<number>;\n /**\n * Attempts to silently sign orders on the scratchpad. If the orders cannot be signed silently, will display the MOEW.\n * @param {number} lMOEWHandle - the handle to the MOEW.\n * @returns a `Promise` which resolves to an integer: 0 if called with invalid/improperly structured paramters, and 1 otherwise.\n */\n SignOrders: (lMOEWHandle: number) => Promise<number>;\n /**\n * Retrieves the XML representation of the order information signed during the previous MOEW invocation.\n * @param {number} lMOEWHandle - the handle to the MOEW.\n * @returns a `Promise` which resolves to a string containing prior order information. If none or invalid, the string will be empty.\n */\n GetXMLOrdersMOEW: (lMOEWHandle: number) => Promise<string>;\n /**\n * Destroys the modal order entry window (MOEW).\n * @param {number} lMOEWHandle - the handle to the MOEW.\n * @returns a `Promise` which resolves to null. This appears to be returned upon either a successful or unsuccessful destruction.\n * @throws `Error` if an unexpected error occurs.\n */\n DestroyMOEW: (lMOEWHandle: number) => Promise<null>;\n /**\n * Get valid encounter ID's for a given patient.\n * @param pid {number} - the patient ID of the patient to get encounters for.\n * @returns a `Promise` of a string representing the valid encounter ID's for the patient.\n */\n GetValidEncounters: (pid: number) => Promise<string>;\n /**\n * Provide patient context to the Discern COM object.\n * @param pid {number} - the patient ID of the patient provided for context.\n *\n * @returns a `Promise` which always returns `null`.\n */\n SetPatient(pid: number, eid: number): Promise<null>;\n /**\n * Provide patient context to the Discern COM object.\n * @param tab {0 | 1} - the tab to target upon opening. Instruction component is `0` and\n * Follow-up component is `1`.\n * @returns a `Promise` which always returns `null`.\n */\n SetDefaultTab(tab: 0 | 1): Promise<null>;\n /**\n * Open the modal for the targeted COM object.\n * @returns a `Promise` which always returns `null`.\n */\n DoModal(): Promise<null>;\n /**\n * Launches a dialog to check in the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n CheckInAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Launches a dialog to check out the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n CheckOutAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Launches a dialog to cancel the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n CancelAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Launches a dialog to put a hold on the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n HoldAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Launches a dialog to mark the specified appointment as 'no show'.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n NoShowAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Display the appointment view dialog for the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n ShowView(eventId: number): Promise<0 | 1>;\n /**\n * Display the appointment history view dialog for the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n ShowHistoryView(eventId: number): Promise<0 | 1>;\n // TODO: update return type and JSDOc\n OpenNewDocumentByReferenceTemplateId(\n pid: number,\n eid: number,\n refTemplateId: number\n ): Promise<null>;\n // TODO: update return type and JSDOc\n OpenNewDocumentByReferenceTemplateIdAndNoteType(\n pid: number,\n eid: number,\n refTemplateId: number,\n noteTypeCd: number\n ): Promise<null>;\n // TODO: update return type and JSDOc\n ModifyExistingDocumentByEventId(\n pid: number,\n eid: number,\n docEventId: number\n ): Promise<null>;\n // TODO: update return type and JSDOc\n OpenDynDocByWorkFlowId(\n pid: number,\n eid: number,\n workflowId: number\n ): Promise<null>;\n // TODO: update return type and JSDOc\n LaunchDischargeDialog(): Promise<null>;\n /**\n * A parameter to set the patient context for the Discern COM object.\n * At the time of writing this, the only discernable use for this is the\n * `DISCHARGEPROCESS` object.\n */\n person_id: number;\n /**\n * A parameter to set the encounter context for the Discern COM object.\n * At the time of writing this, the only discernable use for this is the\n * `DISCHARGEPROCESS` object.\n */\n encounter_id: number;\n /**\n * A parameter to set the user context for the Discern COM object.\n * At the time of writing this, the only discernable use for this is the\n * `DISCHARGEPROCESS` object.\n */\n user_id: number;\n };\n\n interface External {\n /**\n * A factory function which returns a Discern COM object.\n * @param comObject {DiscernCOMObjects} - a string representing the Discern\n * COM object to be created.\n * @returns the COM object the user will interact with.\n */\n DiscernObjectFactory: (\n comObject: DiscernCOMObjects\n ) => Promise<DiscernObjectFactoryReturn>;\n /**\n * Interface for the Cerner Discern native function which provides the function\n * responsible for engaging in special Cerneer _conversation events_ within the\n * web page (MPage) with the Cerner PowerChart application. Useful for development\n * but not intended for production use.\n * @param {string} type - The type of event to be triggered. Can by `'ALLERGY' | 'POWERFORM' | 'POWERNOTE' | 'ORDERS' | 'CLINICALNOTE'`\n * @param {string} args - Argument data passed to the event, specific to the event type.\n */\n MPAGES_EVENT: (\n type: 'ALLERGY' | 'POWERFORM' | 'POWERNOTE' | 'ORDERS' | 'CLINICALNOTE',\n args: string\n ) => Promise<string | number | object | void>;\n }\n}\n","/**\n * Check to see if the error reflects likely being outside of PowerChart.\n * @param e {Error} - The error to be checked.\n * @returns {boolean} - Returns `true` if the error is one of two cases that result\n * from being outside of Cerner PowerChart.\n */\nexport function outsideOfPowerChartError(e: unknown) {\n return (\n e instanceof TypeError &&\n /(MPAGES_EVENT|XMLCclRequest|APPLINK|DiscernObjectFactory) is not a function/i.test(\n e.message\n )\n );\n}\n\n/**\n * A wrapper function for the `console.warn` function which logs a warning message.\n * @param eventString {string} - The event string to be logged.\n */\nexport const warnAttemptedOrdersOutsideOfPowerChart = (\n eventString: string\n): void => {\n console.warn(`window.MPAGES_EVENT('ORDERS', '${eventString}')`);\n};\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Add an addendum to an existing document for a given patient and encounter using the\n * DYNDOC Discern COM object. Of note, Cerner PowerChart refers the \"addendum\" action\n * with the \"modify\" terminology.\n * @param {number} patientId - the patient ID to launch the document for\n * @param {number} encounterId - the encounter ID to launch the document in\n * @param {number} eventId - the event ID of the document to modify.\n * @resolves `PowerChartReturn & { success: boolean }`.\n */\n\nexport async function addAddendumToDocumentAsync(\n patientId: number,\n encounterId: number,\n eventId: number\n): Promise<PowerChartReturn & { success: boolean }> {\n let retVal: PowerChartReturn & { success: boolean } = {\n inPowerChart: true,\n success: false,\n };\n\n try {\n const dcof = await window.external.DiscernObjectFactory('DYNDOC');\n let response: 0 | 1 | null = null;\n response = await dcof.ModifyExistingDocumentByEventId(\n patientId,\n encounterId,\n eventId\n );\n retVal.success = Boolean(response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retVal.inPowerChart = false;\n return retVal;\n } else {\n throw e;\n }\n }\n\n return retVal;\n}\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n/**\n * Create a new document for a given patient and encounter using the\n * DYNDOC Discern COM object. The document can be created using either\n * a reference template ID or a reference template ID and an optional note type code,\n * depending on the chosen method of 'by workflow' or 'by reference template'.\n * @param {'by workflow' | 'by reference template'} method - the method to use to create the document.\n * @param {number} patientId - the patient ID to launch the document for.\n * @param {number} encounterId - the encounter ID to launch the document in.\n * @param {number} id - the ID of the reference template or workflow to use to create the document.\n * @param {number} noteTypeCd - (optional) the note type code to use to create the document.\n * @rejects `PowerChartReturn & { success: boolean }`\n * @throws {Error} - an error is thrown if the method provided as an argument is not supported.\n */\nexport async function createNewDocumentAsync(\n method: 'by workflow' | 'by reference template',\n patientId: number,\n encounterId: number,\n id: number,\n noteTypeCd?: number\n): Promise<PowerChartReturn & { success: boolean }> {\n let retVal: PowerChartReturn & { success: boolean } = {\n inPowerChart: true,\n success: false,\n };\n\n try {\n const dcof = await window.external.DiscernObjectFactory('DYNDOC');\n\n let response: 0 | 1 | null = null;\n\n if (method !== 'by workflow' && method !== 'by reference template') {\n throw new Error(`createNewDocumentAsync: ${method} is not supported`);\n }\n\n if (method === 'by workflow' && noteTypeCd) {\n console.warn(\n 'The noteTypeCd is not used when creating a document by workflow.'\n );\n }\n\n if (method === 'by workflow') {\n response = await dcof.OpenDynDocByWorkFlowId(patientId, encounterId, id);\n }\n\n if (method === 'by reference template' && !noteTypeCd) {\n response = await dcof.OpenNewDocumentByReferenceTemplateId(\n patientId,\n encounterId,\n id\n );\n }\n\n if (method === 'by reference template' && noteTypeCd) {\n response = await dcof.OpenNewDocumentByReferenceTemplateIdAndNoteType(\n patientId,\n encounterId,\n id,\n noteTypeCd\n );\n }\n\n retVal.success = Boolean(response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retVal.inPowerChart = false;\n } else {\n throw e;\n }\n }\n\n return retVal;\n}\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Get a list of valid encounter ID's for a given patient.\n * @param {number} personId - the patient ID to get valid encounters for\n * @resolves `PowerChartReturn & {encounterIds: Array<number>}`. If there\n * are no valid encounters, the `encounterIds` array will be empty.\n */\nexport async function getValidEncountersAsync(\n personId: number\n): Promise<PowerChartReturn & { encounterIds: Array<number> }> {\n const retData: {\n inPowerChart: boolean;\n encounterIds: Array<number>;\n } = {\n inPowerChart: true,\n encounterIds: [],\n };\n try {\n const dcof = await window.external.DiscernObjectFactory('PVCONTXTMPAGE');\n const response = await dcof.GetValidEncounters(personId);\n const eidStr = response.trim();\n if (eidStr === '') return retData;\n eidStr.split(',').forEach(e => {\n const eid = parseFloat(e);\n if (isNaN(eid)) {\n console.warn(\n `getValidEncountersAsync: encounter ID ${e} could not be parsed to a number.`\n );\n } else {\n retData.encounterIds.push(eid);\n }\n });\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { MPageEventReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Available options for the Clinical Note view.\n */\nexport type ViewOption =\n | 'menu'\n | 'buttons'\n | 'toolbar'\n | 'calculator'\n | 'view-only';\n\n/**\n * @param {string} viewName - The view name for the view-level preference of the tab to model the preferences after.\n * @param {number} viewSeq - The view sequence for the view-level preference of the tab to model the\n * preferences after. An invalid viewSeq loads the clinical note with the default preferences.\n * @param {string} compName - The component name for the component-level preference of the tab to model the\n * preferences after. An invalid compName loads the clinical note with the default preferences.\n * @param {number} compSeq - \tThe component sequence for the component-level preference of the tab to model\n * the preferences after. An invalid compSeq loads the clinical note with the default preferences.\n */\nexport type InheretanceProps = {\n viewName: string;\n viewSeq: number;\n compName: string;\n compSeq: number;\n};\n\n/**\n * @param {string} windowTitle - The text to be displayed in the first section of the title for the\n * Clinical Notes window.\n * @param {Array<ViewOption>} viewOptionFlags - (optional) View options for the Clinical Notes window.\n * If not provided, defaults to `view-only` with no other options.\n * @param {InheretanceProps} inheritanceProps - (optional) The view and component names and sequences\n * to be used for the Clinical Notes window. If not provided, uses default preferences.\n **/\nexport type ClinicalNoteOpts = {\n windowTitle?: string;\n viewOptionFlags?: Array<ViewOption>;\n inheritanceProps?: InheretanceProps;\n};\n\n/**\n * Launches a clinical note in PowerChart inheriting the preferences of the component and view described below.\n * If any of the values is invalid, it will use the default values.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param {Array<number>} eventIds - An array of `event_id`'s of the clinical note(s) to be displayed.\n * @param {ClinicalNoteOpts} opts - (optional) optional configuration parameters.\n * @returns a `Promise` returning an `MPageEventReturn` object containing the `eventString`\n * and `inPowerChart` values. Of note, we cannot provide additional information about the\n * success or failure of the invocation because this information is not provided by the\n * underlying Discern native function call's return, which awlays returns `null` no matter\n * the outcome of the call.\n **/\nexport const launchClinicalNoteAsync = async (\n patientId: number,\n encounterId: number,\n eventIds: Array<number>,\n opts?: ClinicalNoteOpts\n): Promise<MPageEventReturn> => {\n const { viewOptionFlags, inheritanceProps, windowTitle } = opts || {};\n const { viewName, viewSeq, compName, compSeq } = inheritanceProps || {};\n\n let inPowerChart = true;\n const params: Array<string> = [`${patientId}`, `${encounterId}`];\n\n const _viewOptsFlags: Array<ViewOption> =\n !viewOptionFlags || viewOptionFlags.length === 0\n ? ['view-only']\n : viewOptionFlags;\n\n params.push(`[${eventIds.join('|')}]`);\n params.push(\n `${windowTitle ||\n `Clinical Note for patient with PID ${patientId} on encounter with EID ${encounterId}`}`\n );\n params.push(`${calculateViewOptionFlag(_viewOptsFlags)}`);\n params.push(`${viewName || ''}`);\n params.push(`${viewSeq || ''}`);\n params.push(`${compName || ''}`);\n params.push(`${compSeq || ''}`);\n\n const eventString = `${params.join('|')}`;\n try {\n await window.external.MPAGES_EVENT('CLINICALNOTE', eventString);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n inPowerChart = false;\n console.warn(`window.MPAGES_EVENT('CLINICALNOTE', '${eventString}')`);\n } else {\n throw e;\n }\n }\n\n return { inPowerChart, eventString };\n};\n\nfunction calculateViewOptionFlag(viewOptionFlags: Array<ViewOption>): number {\n let total = 0;\n viewOptionFlags.forEach(flag => {\n if (flag === 'menu') total += 1;\n if (flag === 'buttons') total += 2;\n if (flag === 'toolbar') total += 4;\n if (flag === 'calculator') total += 8;\n if (flag === 'view-only') total += 16;\n });\n return total;\n}\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Launch Discharge Process dialog for a given patient and encounter.\n * @resolves `PowerChartReturn`\n */\nexport async function launchDischargeProcessAsync(\n patientId: number,\n encounterId: number,\n providerId: number\n): Promise<PowerChartReturn> {\n const retData: PowerChartReturn = {\n inPowerChart: true,\n };\n try {\n const dcof = await window.external.DiscernObjectFactory('DISCHARGEPROCESS');\n dcof.person_id = patientId;\n dcof.encounter_id = encounterId;\n dcof.user_id = providerId;\n dcof.LaunchDischargeDialog();\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Launch Patient Education for a given patient and encounter.\n * @param patientId {number} - the patient ID to get valid encounters for.\n * @param encounterId {number} - the encounter ID to get valid encounters for.\n * @param targetTab {'instruction' | 'follow-up'} - the tab to target upon opening.\n * @resolves a `PowerChartReturn`.\n */\nexport async function launchPatientEducationAsync(\n patientId: number,\n encounterId: number,\n targetTab: 'instruction' | 'follow-up'\n): Promise<PowerChartReturn> {\n const retData: PowerChartReturn = {\n inPowerChart: true,\n };\n try {\n const dcof = await window.external.DiscernObjectFactory('PATIENTEDUCATION');\n await dcof.SetPatient(patientId, encounterId);\n await dcof.SetDefaultTab(targetTab === 'instruction' ? 0 : 1);\n await dcof.DoModal();\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n return {\n inPowerChart: false,\n };\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { MPageEventReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Launch a PowerForm in Cerner's PowerChart.\n * @param {string} target - Determines whether which type of PowerForm action to take\n * upon launch. Choices are: \"new form\", \"completed form\", \"modify completed form\", or\n * \"new form search\". Cerner context variable: VIS_PowerFormTarget.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param {number} targetId - (optional) For a new form, this is the formId (pulled from DCP_FORMS_REF_ID).\n * For a completed form, this is the activityId (pulled from DCP_FORMS_ACTIVITY_ID). This parameter is\n * required for all targets except \"new form search\".\n * @resolves `MPageEventReturn`\n * @throws if there is a type mismatch between the provided option for `target` and `targetId`,\n * or if an unexpected error has occured.\n **/\nexport const launchPowerFormAsync = async (\n target: 'modify form' | 'new form' | 'new form search' | 'view form',\n patientId: number,\n encounterId: number,\n targetId?: number\n): Promise<MPageEventReturn> => {\n const requiresTargetId =\n target === 'new form' || target === 'view form' || target === 'modify form';\n\n if (requiresTargetId && !targetId) {\n throw new Error(\n \"'targetId' is required for all targets except 'new form search'.\"\n );\n }\n\n const params: Array<string> = [`${patientId}`, `${encounterId}`];\n switch (target) {\n case 'new form':\n params.push(`${targetId}`);\n params.push('0');\n break;\n case 'view form':\n case 'modify form':\n params.push('0');\n params.push(`${targetId}`);\n break;\n case 'new form search':\n params.push('0');\n params.push('0');\n break;\n }\n\n params.push(target === 'view form' ? '1' : '0');\n\n const retData: MPageEventReturn = {\n eventString: `${params.join('|')}`,\n inPowerChart: true,\n };\n\n try {\n await window.external.MPAGES_EVENT('POWERFORM', retData.eventString);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n console.warn(\n `window.MPAGES_EVENT('POWERFORM', '${retData.eventString}')`\n );\n } else {\n throw e;\n }\n }\n\n return retData;\n};\n","import { MPageEventReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Launch a PowerNote in Cerner's PowerChart.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param {string} target - Determines whether to target (open) a \"new\" PowerNote or an \"existing\" PowerNote.\n * @param {number | string} targetId - For a `new` note, this value should be a `string` representing the\n * CKI value for an encounter pathway. For an `existing` note, this value should be a `number` representing\n * the eventId of the note to be opened.\n * @resolves `MPageEventReturn`\n * @throws if there is a type mismatch between the provided option for `target` and `targetId`,\n * or if an unexpected error has occured.\n **/\nexport const launchPowerNoteAsync = async (\n target: 'new' | 'existing',\n patientId: number,\n encounterId: number,\n targetId: string | number\n): Promise<MPageEventReturn> => {\n if (target === 'new' && typeof targetId !== 'string') {\n throw new Error(\n 'targetId (for CKI) must be a string when launching a new PowerNote.'\n );\n }\n\n if (target === 'existing' && typeof targetId !== 'number') {\n throw new Error(\n 'targetId must be a number when loading an existing PowerNote.'\n );\n }\n const params: Array<string> = [\n `${patientId}`,\n `${encounterId}`,\n `${target === 'new' ? targetId : ''}`,\n `${target === 'existing' ? targetId : 0}`,\n ];\n\n const eventString = `${params.join('|')}`;\n let inPowerChart = true;\n try {\n await window.external.MPAGES_EVENT('POWERNOTE', eventString);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n inPowerChart = false;\n console.warn(`window.MPAGES_EVENT('POWERNOTE', '${eventString}')`);\n } else {\n throw e;\n }\n }\n\n return { eventString, inPowerChart };\n};\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\nexport type AppointmentAction =\n | 'check in'\n | 'check out'\n | 'cancel'\n | 'no show'\n | 'view appt dialog'\n | 'view appt history';\n\nexport type AppointmentReturn = PowerChartReturn & {\n success: boolean;\n};\n\n/**\n * Managed appointments in PowerChart. For any given appointment ID, the\n * following actions can be performed: check in, check out, cancel, no show,\n * view appointment dialog, and view appointment history. This is a wrapper function\n * for the `PEXSCHEDULINGACTIONS` Discern COM object.\n * @param action {string} - the action to perform on the appointment. The available\n * actions are: 'check in', 'check out', 'cancel', 'no show', 'view appt dialog',\n * and 'view appt history'.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves an `AppointmentReturn` object with the following properties:\n * - `success` - `true` if the action was successful, `false` otherwise.\n * - `inPowerChart` - `true` if the action was successful, `false` otherwise.\n * @throws an `Error` if the action is invalid.\n */\nexport async function manageAppointmentAsync(\n action: AppointmentAction,\n eventId: number\n): Promise<AppointmentReturn> {\n let actionSuccess: 0 | 1 = 0;\n let inPowerChart = true;\n\n try {\n const dcof = await window.external.DiscernObjectFactory(\n 'PEXSCHEDULINGACTIONS'\n );\n switch (action) {\n case 'check in':\n actionSuccess = await dcof.CheckInAppointment(eventId);\n break;\n case 'check out':\n actionSuccess = await dcof.CheckOutAppointment(eventId);\n break;\n case 'cancel':\n actionSuccess = await dcof.CancelAppointment(eventId);\n break;\n case 'no show':\n actionSuccess = await dcof.NoShowAppointment(eventId);\n break;\n case 'view appt dialog':\n actionSuccess = await dcof.ShowView(eventId);\n break;\n case 'view appt history':\n actionSuccess = await dcof.ShowHistoryView(eventId);\n break;\n default:\n throw new Error('Invalid appointment action');\n }\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n inPowerChart = false;\n } else {\n throw e;\n }\n }\n return {\n success: actionSuccess === 1,\n inPowerChart: inPowerChart,\n };\n}\n","import { ApplinkReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\nexport type OpenApplicationMode =\n | 'by solution name'\n | 'by application object'\n | 'by file'\n | 'by url'\n | 'by executable';\n\nexport type OpenApplicationArgument = {\n argument: string;\n value: string | number;\n quickOpen?: boolean;\n};\n\n/**\n * Attempts to open an application in the PowerChart application.\n * @param {OpenApplicationMode} mode - The mode in which to open the application. Valid options include:\n * - 'by solution name' - Open an application by the name of the solution.\n * - 'by application object' - Open an application by the name of the application object.\n * - 'by file' - Open an application by the name of the file.\n * - 'by url' - Open an we website in your **local** browser. This requires that your Citrix instance\n * be setup to handle server-to-client redirection.\n * - 'by executable' - Open an application by the name of the executable.\n * @param {string} target - The target of the application to open. The target can be\n * a solution name, application object name, file name, URL, or executable name.\n * @param {Array<OpenApplicationArgument>} [args] - An array of arguments to pass to the application.\n * Arguments contain the properties: `argument`, `value`, and `quickOpen`. The `argument` property is the name of the\n * argument to pass to the application. The `value` property is the value of the argument to pass to the\n * application. The `quickOpen` property is a boolean indicating whether the application should attempt to open\n * a dialog box, such as the Add Order dialog box in the Orders applet, if supported. Not all applications support\n * this feature and it will be ignored if the application does not support it. The default value is `false`.\n * @resolves `AppLinkReturn`\n * @throws If the mode is 'by solution name' or 'by application object' and the `args` parameter is undefined.\n * @throws If the mode is unsupported (invalid).\n */\nexport async function openApplicationAsync(\n mode: OpenApplicationMode,\n target: string,\n args?: Array<OpenApplicationArgument>\n): Promise<ApplinkReturn> {\n const retVal: ApplinkReturn = {\n inPowerChart: true,\n eventString: '',\n badInput: false,\n };\n\n if (mode === 'by solution name' && !args) {\n throw new Error(\n \"openApplicationAsync: 'by solution name' mode requires arguments\"\n );\n }\n if (mode === 'by application object' && !args) {\n throw new Error(\n \"openApplicationAsync: 'by application object' mode requires arguments\"\n );\n }\n const argString = generateOpenApplicationArgumentString(args || []);\n\n const modeValue = modeMap.get(mode);\n\n if (modeValue === undefined) {\n throw new Error('openApplicationAsync: invalid mode');\n }\n\n retVal.eventString = argString;\n\n try {\n const response = await window.APPLINK(modeValue, target, argString);\n\n retVal.badInput = response === null ? true : false;\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retVal.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retVal;\n}\n\n/**\n * Generates an argument string for the `APPLINK` function using structured data.\n *\n * @param args An array of arguments to pass to the application.\n *\n * @returns A string representing the arguments to pass to the `APPLINK` function.\n */\nexport function generateOpenApplicationArgumentString(\n args: Array<OpenApplicationArgument>\n) {\n return args\n .map(({ argument: arg, value, quickOpen: qo }) => {\n const isOrgLevel = /organizertab/i.test(arg);\n const isTab = /firsttab/i.test(arg) || /organizertab/i.test(arg);\n const quickOpen = qo;\n const quickOpenStr = quickOpen && isTab && !isOrgLevel ? '+' : '';\n const surroundStr = isTab ? '^' : '';\n\n return `/${arg}=${surroundStr}${value}${quickOpenStr}${surroundStr}`;\n })\n .join(' ')\n .toUpperCase();\n}\n\nconst modeMap = new Map<OpenApplicationMode, 0 | 1 | 100>();\nmodeMap.set('by solution name', 0);\nmodeMap.set('by application object', 1);\nmodeMap.set('by file', 100);\nmodeMap.set('by url', 100);\nmodeMap.set('by executable', 100);\n","import { ApplinkReturn } from '.';\n\nimport {\n OpenApplicationArgument,\n openApplicationAsync,\n} from './openApplicationAsync';\n\n/**\n * Attempts to open a tab with the name given to the `tab` variable in at the chart organizer\n * level. Uses the function from this library `openApplicationAsync`.\n * @param tab The string which represents the tab to open\n * (case insensitive). Navigation will be made to the first\n * upper-level tab in the chart that that matches the `tab` string\n * If no match is found, then sub-tab names will be searched and\n * navigation made to the first sub-tab that matches\n * the `tab` string. If no matches are found, no navigation will occur.\n * @resolves an `ApplinkReturn`\n */\nexport async function openOrganizerTabAsync(\n tab: string\n): Promise<ApplinkReturn> {\n const args: Array<OpenApplicationArgument> = [\n {\n argument: 'ORGANIZERTAB',\n value: tab,\n },\n ];\n return await openApplicationAsync('by executable', 'Powerchart.exe', args);\n}\n","import { ApplinkReturn } from '.';\nimport {\n OpenApplicationArgument,\n openApplicationAsync,\n} from './openApplicationAsync';\n\n/**\n * Attempts to open a tab with the name given to the `tab` variable in a\n * patients chart given in the context of a given encounter. Uses the function from\n * this library `openApplicationAsync`.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param tab The string which represents the tab to open\n * (case insensitive). Navigation will be made to the first\n * upper-level tab in the chart that that matches the `tab` string\n * If no match is found, then sub-tab names will be searched and\n * navigation made to the first sub-tab that matches\n * the `tab` string. If no matches are found, no navigation will occur.\n * @param quickOpen A boolean indicating whether the application should attempt to open\n * a quick add box, if supported, such as the Add Order dialog box in the Orders applet.\n * Not all applications support this feature and it will be ignored if the application does not support it.\n * The default value is `false`.\n * @resolves `ApplinkReturn`\n */\nexport async function openPatientTabAsync(\n patientId: number,\n encounterId: number,\n tab: string,\n quickOpen?: boolean\n): Promise<ApplinkReturn> {\n const args: Array<OpenApplicationArgument> = [\n {\n argument: 'PERSONID',\n value: patientId,\n },\n {\n argument: 'ENCNTRID',\n value: encounterId,\n },\n {\n argument: 'FIRSTTAB',\n value: tab,\n quickOpen,\n },\n ];\n\n return await openApplicationAsync('by executable', '$APP_APPNAME$', args);\n}\n","import { ApplinkReturn } from '.';\nimport { openApplicationAsync } from './openApplicationAsync';\n\n/**\n * Attempts to open a website in your **local** web browser. This\n * requires that your Citrix instance be setup to handle server-to-client redirection.\n * This is quite useful as a means of accesing websites that may not be accessible\n * from within the Citrix environment, e.g. those in your local network/intranet.\n * Uses the function from this library `openApplicationAsync`.\n * @param url The URL of the website to open\n * @resolves `ApplinkReturn`\n * @throws If the URL does not include 'http://' or 'https://'\n */\nexport async function openWebsiteByUrlAsync(\n url: string\n): Promise<ApplinkReturn> {\n if (\n !url.toLowerCase().includes('http://') &&\n !url.toLowerCase().includes('https://')\n ) {\n throw new Error(\n \"openWebsiteByUrlAsync: URL must include the protocol 'http://' or 'https://'\"\n );\n }\n\n return await openApplicationAsync('by url', url);\n}\n","import { XMLParser } from 'fast-xml-parser';\nimport { MPageEventReturn } from '.';\nimport {\n outsideOfPowerChartError,\n warnAttemptedOrdersOutsideOfPowerChart,\n} from './utils';\nimport { createOrderString } from './utils/createOrderString';\n\nconst launchViewMap = new Map()\n .set('search', 8)\n .set('profile', 16)\n .set('signature', 32);\n\nconst tabsMap = new Map<string, { tab: number; display: number }>()\n .set('orders', { tab: 2, display: 0 })\n .set('power orders', { tab: 2, display: 127 })\n .set('medications', { tab: 3, display: 0 })\n .set('power medications', { tab: 3, display: 127 });\n\n/**\n * @param {Array<number>} nomenclatureIds - (optional) An array of nomenclature ids for the order.\n * @param {number} orderSentenceId - (optional) The order sentence id value for the order to activate.\n * @param {number} orderId - (optional) The order id value for the order to activate.\n * @param {NewOrderOpts}newOrderOpts - (optional) The options for the new order.\n */\nexport type OrderOpts = {\n nomenclatureIds?: Array<number>;\n orderSentenceId?: number;\n interactionCheck?: 'on sign' | 'default';\n origination?: 'satellite' | 'prescription' | 'normal';\n};\n\n/**\n * A type for the options that can be passed to the makeMpageOrder function.\n * @action `activate existing` - Activates an existing order.\n * @action `cancel-discontinue` - Cancels and discontinues an existing order.\\n\n * @action `cancel-reorder` - Cancels and reorders an existing order.\n * @action `clear actions` - Clear actions of a future existing order.\n * @action `convert inpatient` - Converts a prescription order into an inpatient order.\n * @action `convert prescription` - Converts an inpatient order into a prescription.\n * @action `modify` - Modifies an existing future order.\n * @action `new order` - Creates a new order.\n * @action `renew` - Renews an existing non-prescription order.\n * @action `renew prescription` - Renews an existing prescription order.\n * @action `copy existing` - Copy an existing order.\n * @action `resume` - Resumes an existing order.\n * @action `suspend` - Suspends an existing order.\n */\nexport type OrderAction =\n | 'activate existing'\n | 'cancel-discontinue'\n | 'cancel-reorder'\n | 'clear actions'\n | 'convert inpatient'\n | 'convert prescription'\n | 'modify'\n | 'new order'\n | 'renew'\n | 'renew prescription'\n | 'copy existing'\n | 'resume'\n | 'suspend';\n\n/**\n * @action `targetTab` - (optional) Sets the tab to be displayed, with and without power orders.\n * If not provided, will default to `orders`, that is the orders tab with _PowerOrders_ disabled.\n * Any tab with the term _power_ in it will enable both _PowerOrders_ and _PowerPlans_ in _PowerChart_.\n * Also of note, enabling power plans via `power orders` or `power medications` simply means that\n * a user can _search for_ Power Plans. It does not mean that the user can _create_ Power Plans.\n * @action `launchView` - (optional) Sets the view to be displayed.If not provided,\n * will default to `search` view.\n * @action `signSilently` - (optional) Attempts to sign the orders silently. Orders are not signed silently\n * by default. If it's not possible for the system to complete a sileng sign directive,\n * the MOEW will pop up.\n * @action `dryRun` - (optional) If set to true, will not submit the order.\n * @warning Our internal testing suggests there is a _PowerChart_ bug relating to the use of power\n * orders. When making MPAGES_EVENT calls (which we do in this library through `submitOrders`)\n * in series with power orders enabled, the result was that some MPAGES_EVENT calls failed to be invoked.\n * Please keep this in mind when enabling this option. For our own use, we have disabled power orders when\n * using `submitOrders` in such a way that calls are made in series.\n */\nexport type SubmitOrderAsyncOpts = {\n targetTab?: 'orders' | 'power orders' | 'medications' | 'power medications';\n launchView?: 'search' | 'profile' | 'signature';\n signSilently?: boolean;\n dryRun?: boolean;\n};\n\nexport type SubmitOrdersAsyncStatus =\n | 'success'\n | 'cancelled'\n | 'failed'\n | 'invalid data returned'\n | 'xml parse error'\n | 'dry run';\n\nexport type SubmitOrderAsyncReturn = MPageEventReturn & {\n status: SubmitOrdersAsyncStatus;\n response: MpagesEventOrdersReturnXML | null;\n ordersPlaced: Array<{ name: string; oid: number; display: string }> | null;\n};\n\nexport type Order = {\n id: number;\n action: OrderAction;\n opts?: OrderOpts;\n};\n\n/**\n * Submit orders for a patient in a given encounter through the _Cerner PowerChart_ `MPAGES_EVENT` function.\n * By default, the seach for _PowerPlans_ are disabled (potential bug in _PowerChart_), _PowerOrders_ are disabled,\n * the target tab is set to orders, and will launch to the signature view.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param orders - The orders to be submitted. Orders are given in the form of a a series of pipe-delimited\n * parameters as specified in the `MPAGES_EVENT` documentation (below). Use the `fluent-cerner-js` library's\n * `` function to simplify building these pipe-delimited order strings.\n * @param opts - (optional) User defined options for the order submission event. The options allow for\n * changing the target tab, the view to be launched, and whether or not the orders should be signed silently.\n * @resolves `SubmitOrderAsyncReturn`\n */\nexport const submitOrdersAsync = async (\n patientId: number,\n encounterId: number,\n orders: Array<Order>,\n opts?: SubmitOrderAsyncOpts\n): Promise<SubmitOrderAsyncReturn> => {\n let { targetTab, launchView, signSilently, dryRun } = opts || {};\n if (!targetTab) targetTab = 'orders';\n if (!launchView) launchView = 'signature';\n const enablePowerPlans =\n targetTab === 'power orders' || targetTab === 'power medications';\n\n const s = orders.map(({ action, id, opts }) =>\n createOrderString(action, id, opts)\n );\n\n let params: Array<string> = [`${patientId}`, `${encounterId}`, s.join('')];\n\n params.push(enablePowerPlans ? '24' : '0');\n\n const { tab, display } = tabsMap.get(targetTab) || { tab: 2, display: 127 };\n params.push(`{${tab}|${display}}`);\n\n params.push(`${launchViewMap.get(launchView) || 32}`);\n\n params.push(`${signSilently ? '1' : '0'}`);\n\n const eventString = params.join('|');\n\n const retVal: SubmitOrderAsyncReturn = {\n eventString,\n inPowerChart: true,\n status: 'success',\n response: null,\n ordersPlaced: null,\n };\n\n if (dryRun) {\n retVal.status = 'dry run';\n return retVal;\n }\n\n try {\n const response: string = (await window.external.MPAGES_EVENT(\n 'ORDERS',\n eventString\n )) as string;\n\n // 'null' must be checked for explicitly, as it is a valid response\n // '!response' will return true for null, undefined, and empty string.\n if (response === null) {\n retVal.status = 'failed';\n return retVal;\n }\n\n if (typeof response !== 'string') {\n retVal.status = 'invalid data returned';\n return retVal;\n }\n\n switch (response.trim()) {\n case '':\n retVal.status = 'cancelled';\n break;\n default:\n retVal.status = 'success';\n const parser = new XMLParser();\n try {\n const parsed: MpagesEventOrdersReturnXML = parser.parse(response);\n retVal.response = parsed;\n if (!(parsed.Orders.Order instanceof Array)) {\n parsed.Orders.Order = [parsed.Orders.Order];\n }\n retVal.ordersPlaced = parsed.Orders.Order.map((o) => ({\n name: o.OrderedAsMnemonic,\n oid: o.OrderId,\n display: o.ClinDisplayLine,\n }));\n } catch {\n retVal.status = 'xml parse error';\n }\n\n break;\n }\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retVal.inPowerChart = false;\n retVal.status = 'invalid data returned';\n warnAttemptedOrdersOutsideOfPowerChart(eventString);\n } else {\n throw e;\n }\n }\n return retVal;\n};\n\n// TODO: investigate if we need to export this through the main index.ts file\n/**\n * When an MPAGES_EVENT:ORDER call is made asynchronously, it returns a\n * `Promise` of an XML string. This type is the parsed XML string. Several bits\n * of useful information can be extracted from here, including the order ID\n * and additional details of the newly placed order.\n */\nexport type MpagesEventOrdersReturnXML = {\n Orders: {\n OrderVersion: number;\n Order: Array<MpagesEventReturnOrderXML>;\n };\n};\n\nexport type FieldValueList = {\n ListValues: {\n FieldValue: number;\n FieldDisplayValue: number;\n FieldDtTmValue: string;\n };\n};\n\nexport type Detail = {\n FieldValueList: FieldValueList;\n OeFieldId: number;\n OeFieldMeaning: string;\n OeFieldMeaningId: number;\n ValueRequiredInd: number;\n GroupSeq: number;\n FieldSeq: number;\n ModifiedInd: number;\n DetailAlterFlag: number;\n};\n\nexport type DetailList = {\n STRENGTHDOSE: Detail;\n STRENGTHDOSEUNIT: Detail;\n RXROUTE: Detail;\n DRUGFORM: Detail;\n FREQ: Detail;\n 'SCH.PRN': Detail;\n OTHER: Detail[];\n DURATION: Detail;\n DURATIONUNIT: Detail;\n REQSTARTDTTM: Detail;\n STOPDTTM: Detail;\n STOPTYPE: Detail;\n FREQSCHEDID: Detail;\n ADHOCFREQINSTANCE: Detail;\n NEXTDOSEDTTM: Detail;\n PHARMORDERTYPE: Detail;\n DIFFINMIN: Detail;\n ICD9: Detail;\n INSTREPLACEREQUIREDDETS: Detail;\n REFERENCESTARTDTTM: Detail;\n DetailListCount: number;\n};\n\nexport type CommentList = {\n CommentValues: {\n CommentType: number;\n CommentText: string;\n };\n};\n\nexport type AdHocFreqList = {\n CurrSchedList: string;\n OrigSchedList: string;\n PrevSchedList: string;\n};\n\nexport type DiagnosisList = {\n Diagnosis: {\n DiagnosisId: number;\n NomenclatureId: number;\n SourceVocabularyCd: number;\n SourceIdentifier: string;\n DiagnosisDescription: string;\n DiagnosisRanking: number;\n SearchNomenclatureId: number;\n };\n};\n\nexport type MpagesEventReturnOrderXML = {\n OrderableType: number;\n OrderId: number;\n SynonymId: number;\n ClinCatCd: number;\n CatalogTypeCd: number;\n ActivityTypeCd: number;\n OrderSentenceId: number;\n RxMask: number;\n HnaOrderMnemonic: string;\n OrderedAsMnemonic: string;\n OrderDtTm: string;\n OrigOrderDtTm: string;\n OrderMnemonic: string;\n OrderStatusCd: number;\n OrderStatusDisp: string;\n ClinDisplayLine: string;\n SimpleDisplayLine: string;\n DeptStatusCd: number;\n NeedDoctorCosignInd: number;\n NeedPhysicianValidateInd: number;\n NeedNurseReviewInd: number;\n CommInd: number;\n IngredientInd: number;\n LastUpdtCnt: number;\n MultipleOrdSentInd: number;\n OrderActionId: number;\n TemplateOrderFlag: number;\n TemplateOrderId: number;\n CsFlag: number;\n CsOrderId: number;\n OrderStatus: number;\n SuspendInd: number;\n ResumeInd: number;\n OrderableTypeFlag: number;\n RequiredInd: number;\n ConstantInd: number;\n PrnInd: number;\n FreqTypeFlag: number;\n HybridInd: number;\n NeedRxVerifyFlag: number;\n MedTypeCd: number;\n LastActionSeq: number;\n CommentTypeMask: number;\n StopTypeCd: number;\n ProviderId: number;\n ProviderName: string;\n CommunicationTypeCd: number;\n CurrentStartDtTm: string;\n ProjectedStopDtTm: string;\n TimeZone: number;\n OrigOrdAsFlag: number;\n OrdCommentTemplateId: number;\n DisableOrdCommentInd: number;\n SuspendEffectiveDtTm: string;\n ResumeEffectiveDtTm: string;\n AdditiveCnt: number;\n ClinSigDiluentCnt: number;\n LinkNbr: number;\n LinkTypeFlag: number;\n SuperviseProviderId: number;\n SuperviseProviderName: string;\n BillingProvider: string;\n RelatedOrderObjId: number;\n ActionDtTm: string;\n OeFormatId: number;\n FmtActionCd: number;\n SignedActionCd: number;\n ActionType: number;\n EncntrId: number;\n ProcessMask: number;\n CatalogCd: number;\n ParentId: number;\n ProjectedOrderId: number;\n ProposalAcceptance: string;\n ProposalId: number;\n SignDtTm: string;\n ActionDisplay: string;\n SignedOrderStatusCd: number;\n LastActionPrsnlId: number;\n LastActionPrsnlName: string;\n LastActionDtTm: string;\n DetailList: DetailList;\n ComplianceDetailList: string;\n CommentList: CommentList;\n AdHocFreqList: AdHocFreqList;\n DiagnosisList: DiagnosisList;\n CurrSchedExceptionList: string;\n PrevSchedExceptionList: string;\n OrigSchedExceptionList: string;\n ResponsibleProviderId: number;\n ResponsibleProviderName: string;\n SuspendedDtTm: string;\n RelatedFromOrderId: number;\n OrderRelationTypeCd: number;\n OrderRelationTypeMeaning: string;\n OrderRelationTypeDisplay: string;\n ProposalRejectReasonCd: number;\n ProposalRejectReasonDisplay: string;\n ProposalFreetextRejectReason: string;\n};\n","import { OrderAction, OrderOpts } from '../submitOrdersAsync';\n\n/**\n * A type for the options that can be passed to the `makeMpageOrder` function.\n * @action `launch moew` - Launches the MOEW.\n * @action `activate existing` - Activates an existing order.\n * @action `cancel-discontinue` - Cancels and discontinues an existing order.\\n\n * @action `cancel-reorder` - Cancels and reorders an existing order.\n * @action `clear actions` - Clear actions of a future existing order.\n * @action `convert inpatient` - Converts a prescription order into an inpatient order.\n * @action `convert prescription` - Converts an inpatient order into a prescription.\n * @action `modify` - Modifies an existing future order.\n * @action `new order` - Creates a new order.\n * @action `renew` - Renews an existing non-prescription order.\n * @action `renew prescription` - Renews an existing prescription order.\n * @action `copy existing` - Copy an existing order.\n * @action `resume` - Resumes an existing order.\n * @action `suspend` - Suspends an existing order.\n *\n * @documentation [MPAGES_EVENT - ORDER](https://wiki.cerner.com/display/public/MPDEVWIKI/MPAGES_EVENT+-+ORDERS)\n */\ntype CompleteOrderAction =\n | 'launch moew'\n | 'activate existing'\n | 'cancel-discontinue'\n | 'cancel-reorder'\n | 'clear actions'\n | 'convert inpatient'\n | 'convert prescription'\n | 'modify'\n | 'new order'\n | 'renew'\n | 'renew prescription'\n | 'copy existing'\n | 'resume'\n | 'suspend';\n\nconst _createOrderString = (\n action: CompleteOrderAction,\n id?: number,\n opts?: OrderOpts\n): string => {\n const { orderSentenceId, nomenclatureIds, origination, interactionCheck } =\n opts || {};\n\n let params: Array<string> = [orderActionMap.get(action)];\n\n const nids = nomenclatureIds || [];\n\n switch (action) {\n case 'launch moew':\n params = params.concat(['0', '0', '0', '0', '0']);\n break;\n case 'new order':\n if (!id)\n throw new Error(\n `id (as synonym ID) is required for the '${action}' action`\n );\n params = params.concat([\n `${id}`,\n `${originationMap.get(origination) || 0}`,\n `${orderSentenceId || 0}`,\n nids.length > 1 ? `[${nids.join('|')}]` : `${nids[0] || 0}`,\n `${interactionMap.get(interactionCheck) || 0}`,\n ]);\n break;\n default:\n if (!id)\n throw new Error(\n `id (as the existing order ID) is required for the '${action}' action`\n );\n params = params.concat([`${id}`]);\n break;\n }\n\n return `{${params.join('|')}}`;\n};\n\nconst orderActionMap = new Map()\n .set('launch moew', 'ORDER')\n .set('activate existing', 'ACTIVATE')\n .set('cancel-discontinue', 'CANCEL DC')\n .set('cancel-reorder', 'CANCEL REORD')\n .set('clear actions', 'CLEAR')\n .set('convert inpatient', 'CONVERT_INPAT')\n .set('convert prescription', 'CONVERT_RX')\n .set('modify', 'MODIFY')\n .set('new order', 'ORDER')\n .set('renew', 'RENEW')\n .set('renew prescription', 'RENEW_RX')\n .set('copy existing', 'REPEAT')\n .set('resume', 'RESUME')\n .set('suspend', 'SUSPEND');\n\nconst originationMap = new Map()\n .set('satellite', '5')\n .set('prescription', '1')\n .set('normal', '0');\n\nconst interactionMap = new Map().set('on sign', '1').set('default', '0');\n\n/**\n * A helper function consumed by `submitOrdersAsync` function. Creates a new pipe-delimited\n * order string consumed by an `MPAGES_EVENT` call with the `ORDERS` directive.\n * @since 0.10.0-alpha.0\n * @param {OrderAction} action - The action to be performed on the order.\n * @param {number} id - The id of the order. This is the synonym id for new orders and the order id for existing orders.\n * @param {OrderOpts} opts - (optional) The options for the order.\n * @returns {string} - A pipe-delimited string which can be integrated into an MPage Event for one or more orders.\n * @throws {Error} - If the action is not a valid order action.\n * @documentation [MPAGES_EVENT - ORDER](https://wiki.cerner.com/display/public/MPDEVWIKI/MPAGES_EVENT+-+ORDERS)\n */\nexport const createOrderString = (\n action: OrderAction,\n id: number,\n opts?: OrderOpts\n) => _createOrderString(action, id, opts);\n\n/**\n * A constant string for the `launch moew` action.\n */\nexport const LAUNCH_MOEW_ORDER_STRING = _createOrderString('launch moew');\n","import { PowerOrdersMOEWFlags } from '../submitPowerOrdersAsync';\n\ntype CernerMOEWFlags =\n | 'add rx to filter'\n | 'allow only inpatient and outpatient orders'\n | 'allow power plan doc'\n | 'allow power plans'\n | 'allow regimen'\n | 'customize meds'\n | 'customize order'\n | 'disable auto search'\n | 'disallow EOL'\n | 'documented meds only'\n | 'hide demographics'\n | 'hide med rec'\n | 'read only'\n | 'show diag and probs'\n | 'show list details'\n | 'show nav tree'\n | 'show order profile'\n | 'show orders search'\n | 'show refresh and print buttons'\n | 'show related res'\n | 'show scratchpad'\n | 'sign later';\n\n/**\n * A utility function designed to calculate the bitmask for the input paramaters to be used with PowerChart's CreateMOEW() function.\n * @param {PowerOrdersMOEWOpts} inputOpts - An object containing the type of orders to be placed (medications or order) as well as an (optional)\n * array of strings defining the MOEW behavior/appearance. If not provided, the values will default to the the order setting as well as recommended\n * values for the MOEW to be configured with PowerPlan support. If any values are provided, those will be the only values used.\n * @returns The bitmask numbers (dwCustomizeFlag, dwTabFlag, and dwTabDisplayOptionsFlag) to be used with PowerChart's CreateMOEW() function.\n */\nexport const calculateMOEWBitmask = (\n targetTab: 'orders tab' | 'medications tab',\n inputFlags: Array<PowerOrdersMOEWFlags>\n): {\n dwCustomizeFlag: number;\n dwTabFlag: number;\n dwTabDisplayOptionsFlag: number;\n} => {\n // Initialize and calculate the CreateMOEW() parameters\n let dwCustomizeFlag: number = 0;\n let dwTabFlag: number = 0;\n let dwTabDisplayOptionsFlag: number = 0;\n\n // Calculate the dwTabFlag parameter\n if (targetTab === 'orders tab') {\n dwTabFlag = 2;\n }\n\n if (targetTab === 'medications tab') {\n dwTabFlag = 3;\n }\n\n // If no MOEW options are provided, use recommended default settings\n const defaultOpts: Array<PowerOrdersMOEWFlags> = [\n 'show refresh and print buttons',\n 'allow power plan doc',\n 'allow power plans',\n 'show list details',\n 'show scratchpad',\n 'show order profile',\n 'show orders search',\n 'show related res',\n 'show diag and probs',\n 'show nav tree',\n 'show demographics',\n 'show med rec',\n ];\n\n const userFlags =\n !inputFlags || inputFlags.length === 0 ? defaultOpts : inputFlags;\n\n //Go through the flags provided by the user and convert them to Cerner analogs\n //At time of last edit:\n // - absence of `show demographics` causes `hide demographics` to be added to the bitmask calculation\n // - absence of `show med rec` causes `hide med rec` to be added to the bitmask calculation\n\n const cernerFlags: Array<CernerMOEWFlags> = [];\n userFlags.forEach((flag: PowerOrdersMOEWFlags) => {\n if (flag === 'show demographics') {\n return;\n }\n if (flag === 'show med rec') {\n return;\n }\n return cernerFlags.push(flag as CernerMOEWFlags);\n });\n if (!userFlags.includes('show demographics')) {\n cernerFlags.push('hide demographics');\n }\n if (!userFlags.includes('show med rec')) {\n cernerFlags.push('hide med rec');\n }\n\n // Calculate the other two parameters (dwCustomizeFlag and dwTabDisplayOptionsFlag) that are also ultimately needed for CreateMOEW()\n cernerFlags.forEach(option => {\n switch (option) {\n // Calculate the dwCustomizeFlagParamater\n case 'sign later':\n dwCustomizeFlag += 1;\n break;\n\n case 'read only':\n dwCustomizeFlag += 4;\n break;\n\n case 'allow power plans':\n dwCustomizeFlag += 8;\n break;\n\n case 'allow power plan doc':\n dwCustomizeFlag += 16;\n break;\n\n case 'allow only inpatient and outpatient orders':\n dwCustomizeFlag += 32;\n break;\n\n case 'show refresh and print buttons':\n dwCustomizeFlag += 128;\n break;\n\n case 'documented meds only':\n dwCustomizeFlag += 256;\n break;\n\n case 'hide med rec':\n dwCustomizeFlag += 512;\n break;\n\n case 'disallow EOL':\n dwCustomizeFlag += 1024;\n break;\n\n case 'hide demographics':\n dwCustomizeFlag += 2048;\n break;\n\n case 'add rx to filter':\n dwCustomizeFlag += 4096;\n break;\n\n case 'disable auto search':\n dwCustomizeFlag += 8192;\n break;\n\n case 'allow regimen':\n dwCustomizeFlag += 16384;\n break;\n\n // Calculate the dwTabDisplayOptionsFlag parameter\n case 'show nav tree':\n dwTabDisplayOptionsFlag += 1;\n break;\n\n case 'show diag and probs':\n dwTabDisplayOptionsFlag += 2;\n break;\n\n case 'show related res':\n dwTabDisplayOptionsFlag += 4;\n break;\n\n case 'show orders search':\n dwTabDisplayOptionsFlag += 8;\n break;\n\n case 'show order profile':\n dwTabDisplayOptionsFlag += 16;\n break;\n\n case 'show scratchpad':\n dwTabDisplayOptionsFlag += 32;\n break;\n\n case 'show list details':\n dwTabDisplayOptionsFlag += 64;\n break;\n }\n });\n\n return {\n dwCustomizeFlag,\n dwTabFlag,\n dwTabDisplayOptionsFlag,\n };\n};\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\nimport { StandaloneOrder } from '../submitPowerOrdersAsync';\n\n/**\n * Attempts to add new standalone orders to the scratchpad\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW\n * @param {Array<StandaloneOrder>} standaloneOrders - An array of objects containg order synonym Ids, order origination flags and, optionally, sentence Ids, for standalone orders to be placed\n * @param {boolean} interactionChecking - A boolean value indicating whether or not order interaction checking should be performed (strongly recommended to be set to true)\n * @resolves `PowerChartReturn & { result: AddNewOrdersToScratchpadResult }`\n * @throws `Error` if the array provided is empty\n */\nexport async function addNewOrdersToScratchpadAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number,\n standaloneOrders: Array<StandaloneOrder>,\n interactionChecking: boolean\n): Promise<\n PowerChartReturn & {\n result: AddNewOrdersToScratchpadResult;\n }\n> {\n //Prepare the default return data\n let retData: PowerChartReturn & {\n result: AddNewOrdersToScratchpadResult;\n } = {\n inPowerChart: true,\n result: 'successfully added',\n };\n\n // Check for to make sure the array of orders provided is not empty\n if (standaloneOrders.length < 1) {\n throw new RangeError(\n 'There should be at least one standalone order provided.'\n );\n }\n\n // Convert the standalone orders provided into the required XML string\n let standaloneOrdersXML: string = '';\n\n standaloneOrders.forEach(standaloneOrder => {\n standaloneOrdersXML += `<Order><EOrderOriginationFlag>${\n standaloneOrder.origination === 'inpatient order' ? 0 : 1\n }</EOrderOriginationFlag><SynonymId>${standaloneOrder.synonymId}</SynonymId>\n <OrderSentenceId>${\n standaloneOrder.sentenceId ? standaloneOrder.sentenceId : ''\n }</OrderSentenceId></Order>`;\n });\n\n //Add <Orders> to beginning & end of the Standalone Order XML\n standaloneOrdersXML = '<Orders>' + standaloneOrdersXML;\n standaloneOrdersXML += '</Orders>';\n\n //Remove newlines and spaces\n standaloneOrdersXML = standaloneOrdersXML.replace(/[\\r\\n\\s]/g, '');\n\n try {\n const response = await dcof.AddNewOrdersToScratchpad(\n moewHandle,\n standaloneOrdersXML,\n interactionChecking\n );\n\n // Set the `result value` equal to a string describing the number that PowerChart returns\n switch (response) {\n case 0:\n retData.result = 'successfully added';\n break;\n\n case 1:\n retData.result = 'added and signed';\n break;\n\n case 2:\n retData.result = 'cancelled by user';\n break;\n\n case 3:\n retData.result = 'add failed';\n break;\n }\n } catch (e) {\n // If outside of PowerChart, set the output to reflect that\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.result = 'add failed';\n } else {\n // If some other error was encountered, throw that error\n throw e;\n }\n }\n\n // Return the retData object when complete\n return retData;\n}\n\nexport type AddNewOrdersToScratchpadResult =\n | 'successfully added'\n | 'added and signed'\n | 'cancelled by user'\n | 'add failed';\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\nimport { PowerPlanOrder } from '../submitPowerOrdersAsync';\n\n/**\n * Attempts to add a PowerPlan and creates PowerPlan objects from the pathway catalog Ids. CreateMOEW() must be called first.\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @param {Array<PowerPlanOrder>} powerPlanOrders - An array of objects containg catalog Ids and, optionally,\n * personalized plan Ids and diagnosis code Ids, for PowerPlan orders to be placed.\n * @resolves `PowerChartReturn & { powerPlansAdded: boolean }`\n * @throws `Error` if no orders are provided\n */\n\nexport async function addPowerPlanWithDetailsAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number,\n powerPlanOrders: Array<PowerPlanOrder>\n): Promise<\n PowerChartReturn & {\n powerPlansAdded: boolean;\n }\n> {\n //Prepare the default return data\n let retData: PowerChartReturn & {\n powerPlansAdded: boolean;\n } = {\n inPowerChart: true,\n powerPlansAdded: true,\n };\n\n // Check for to make sure the array of orders provided is not empty\n if (powerPlanOrders.length < 1) {\n throw new RangeError(\n 'There should be at least one PowerPlan order provided.'\n );\n }\n\n // Convert the PowerPlan orders provided into the required XML string\n let powerPlanOrdersXML: string = '';\n\n powerPlanOrders.forEach(\n ({\n pathwayCatalogId: cid,\n personalizedPlanId: pid,\n diagnosisIds: dids,\n }) => {\n powerPlanOrdersXML += `<Plan><PathwayCatalogId>${cid}</PathwayCatalogId><PersonalizedPlanId>${\n pid ? pid : ''\n }</PersonalizedPlanId><Diagnoses>\n ${\n dids\n ? dids.map(diagnosisSynonymID => {\n return '<DiagnosisId>' + diagnosisSynonymID + '</DiagnosisId>';\n })\n : ''\n }\n </Diagnoses></Plan>`;\n }\n );\n\n // Add <Plans> to beginning & end of PowerPlan XML\n powerPlanOrdersXML = '<Plans>' + powerPlanOrdersXML;\n powerPlanOrdersXML += '</Plans>';\n\n //Remove newlines and spaces\n powerPlanOrdersXML = powerPlanOrdersXML.replace(/[\\r\\n\\s]/g, '');\n\n try {\n const response = await dcof.AddPowerPlanWithDetails(\n moewHandle,\n powerPlanOrdersXML\n );\n\n // Set the `powerPlanAdded` boolean to be true if the orders were added, and false otherwise\n retData.powerPlansAdded = response === 0 ? false : true;\n } catch (e) {\n // If outside of PowerChart, set the output to reflect that\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.powerPlansAdded = false;\n } else {\n // If some other error was encountered, throw that error\n throw e;\n }\n }\n\n // Return the retData object when complete\n return retData;\n}\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Creates an MOEW handle.\n * @param {DiscernObjectFactoryReturn} dcof - the to reference the DisernObjectFactory object\n * @param {number} personId - the patient Id\n * @param {number} encounterId - the encounter Id in which orders would be placed\n * @param {number} dwCustomizeFlag - the bitmask that determines available MOEW options\n * @param {number} dwTabFlag - the bitmask identifying the list being customized\n * @param {number} dwTabDisplayOptionsFlag - the bitmask specificying which components display on the MOEW\n * @resolves `PowerChartReturn & { moewHandle: number | null }`\n */\n\nexport async function createMOEWAsync(\n dcof: DiscernObjectFactoryReturn,\n personId: number,\n encounterId: number,\n dwCustomizeFlag: number,\n dwTabFlag: number,\n dwTabDisplayOptionsFlag: number\n): Promise<\n PowerChartReturn & {\n moewHandle: number | null;\n }\n> {\n let retData: PowerChartReturn & {\n moewHandle: number | null;\n } = {\n inPowerChart: true,\n moewHandle: null,\n };\n\n //Use the DCOF to call CreateMOEW()\n try {\n const response = await dcof.CreateMOEW(\n personId,\n encounterId,\n dwCustomizeFlag,\n dwTabFlag,\n dwTabDisplayOptionsFlag\n );\n\n //Set the moewHandle equal to `null` if an invalid handle is returned, and set it to the actual value otherwise\n retData.moewHandle = response === 0 ? null : response;\n } catch (e) {\n //If outside of PowerChart, set the output to reflect that\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.moewHandle = null;\n } else {\n //If some other error was encountered, throw that error\n throw e;\n }\n }\n\n // Return the retData object when complete\n return retData;\n}\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Destroys the modal order entry window (MOEW).\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @description The value returned by DestroyMOEW() is not used and is not believed to\n * be meaningful, but is logged to the console for development purposes.\n * @resolves `PowerChartReturn`\n */\n\nexport async function destroyMOEWAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number\n): Promise<PowerChartReturn> {\n let retData: PowerChartReturn = {\n inPowerChart: true,\n };\n\n try {\n const response = await dcof.DestroyMOEW(moewHandle);\n\n console.log('Response from DestroyMOEW() is: ', response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Displays the modal order entry window (MOEW).\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @resolves `PowerChartReturn & { signed: boolean }`\n * @returns a `Promise` which resolves to a PowerChartReturn and an integer\n * indicating if orders were signed, 1, or 0 otherwise, converted to a Boolean.\n * @throws `Error` if an unexpected error occurs.\n */\n\nexport async function displayMOEWAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number\n): Promise<\n PowerChartReturn & {\n signed: boolean;\n }\n> {\n let retData: PowerChartReturn & {\n signed: boolean;\n } = {\n inPowerChart: true,\n signed: false,\n };\n\n try {\n const response = await dcof.DisplayMOEW(moewHandle);\n\n retData.signed = Boolean(response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { XMLParser } from 'fast-xml-parser';\nimport { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Retrieves the orders placed during the previous MOEW invocation.\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @resolves `DiscernObjectFactoryReturn` which is a complex object any any given user should\n * take the opportunity to review it before using it. Of note, the most useful properties will be\n * `inPowerChart`, which is a boolean indicating whether the user is currently in PowerChart, and\n * `ordersPlaced`, and `status`.\n */\n\nexport async function getOrdersPlacedAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number\n): Promise<GetXMLReturn> {\n let retData: GetXMLReturn = {\n inPowerChart: true,\n ordersPlaced: [],\n parsedXML: null,\n rawXML: '',\n status: 'success',\n };\n\n try {\n // Set the return object XML equal to the return XML from PowerChart\n retData.rawXML = await dcof.GetXMLOrdersMOEW(moewHandle);\n\n //Check to see if the response type was not a string (should always either be \"\" or an XML string)\n if (typeof retData.rawXML !== 'string') {\n retData.status = 'invalid data returned';\n return retData;\n }\n\n //Check to see if no orders were placed or if invalid parameters were provided\n if (retData.rawXML.trim() === '') {\n retData.status = 'cancelled, failed, or invalid parameters provided';\n return retData;\n }\n\n //Assuming we have a valid (non-empty) string at this point, attempt to parse out its XML and populate `retData.ordersPlaced`\n const parser = new XMLParser();\n try {\n const parsed: OrdersReturnXML = parser.parse(retData.rawXML);\n retData.parsedXML = parsed;\n if (!(parsed.Orders.Order instanceof Array)) {\n parsed.Orders.Order = [parsed.Orders.Order];\n }\n retData.ordersPlaced = parsed.Orders.Order.map(o => ({\n name: o.OrderedAsMnemonic,\n oid: o.OrderId,\n display: o.ClinDisplayLine,\n }));\n } catch {\n //A parsing error indicates the string isn't formatted as epxected\n retData.status = 'xml parse error';\n }\n } catch (e) {\n //If outside of PowerChart, set the output to reflect that\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.parsedXML = null;\n retData.ordersPlaced = [];\n retData.rawXML = '';\n retData.status = 'dry run';\n } else {\n // If some other error was encountered, throw that error\n throw e;\n }\n }\n\n // Return the retData object when complete\n return retData;\n}\n\nexport type SubmitPowerOrdersStatus =\n | 'success'\n | 'cancelled, failed, or invalid parameters provided'\n | 'invalid data returned'\n | 'xml parse error'\n | 'dry run';\n\nexport type GetXMLReturn = PowerChartReturn & {\n ordersPlaced: Array<{ name: string; oid: number; display: string }> | null;\n parsedXML: OrdersReturnXML | null;\n rawXML: string;\n status: SubmitPowerOrdersStatus;\n};\n\n// Return type to contain the orders placed and associated XML data\nexport type OrdersReturnXML = {\n Orders: {\n OrderVersion: number;\n Order: Array<PowerOrderReturnOrderXML>;\n };\n};\n\n// Return type of XML data\nexport type PowerOrderReturnOrderXML = {\n OrderableType: number;\n OrderId: number;\n SynonymId: number;\n ClinCatCd: number;\n CatalogTypeCd: number;\n ActivityTypeCd: number;\n OrderSentenceId: number;\n RxMask: number;\n HnaOrderMnemonic: string;\n OrderedAsMnemonic: string;\n OrderDtTm: string;\n OrigOrderDtTm: string;\n OrderMnemonic: string;\n OrderStatusCd: number;\n OrderStatusDisp: string;\n ClinDisplayLine: string;\n SimpleDisplayLine: string;\n DeptStatusCd: number;\n NeedDoctorCosignInd: number;\n NeedPhysicianValidateInd: number;\n NeedNurseReviewInd: number;\n CommInd: number;\n IngredientInd: number;\n LastUpdtCnt: number;\n MultipleOrdSentInd: number;\n OrderActionId: number;\n TemplateOrderFlag: number;\n TemplateOrderId: number;\n CsFlag: number;\n CsOrderId: number;\n OrderStatus: number;\n SuspendInd: number;\n ResumeInd: number;\n OrderableTypeFlag: number;\n RequiredInd: number;\n ConstantInd: number;\n PrnInd: number;\n FreqTypeFlag: number;\n HybridInd: number;\n NeedRxVerifyFlag: number;\n MedTypeCd: number;\n LastActionSeq: number;\n CommentTypeMask: number;\n StopTypeCd: number;\n ProviderId: number;\n ProviderName: string;\n CommunicationTypeCd: number;\n CurrentStartDtTm: string;\n ProjectedStopDtTm: string;\n TimeZone: number;\n OrigOrdAsFlag: number;\n OrdCommentTemplateId: number;\n DisableOrdCommentInd: number;\n SuspendEffectiveDtTm: string;\n ResumeEffectiveDtTm: string;\n AdditiveCnt: number;\n ClinSigDiluentCnt: number;\n LinkNbr: number;\n LinkTypeFlag: number;\n SuperviseProviderId: number;\n SuperviseProviderName: string;\n BillingProvider: string;\n RelatedOrderObjId: number;\n ActionDtTm: string;\n OeFormatId: number;\n FmtActionCd: number;\n SignedActionCd: number;\n ActionType: number;\n EncntrId: number;\n ProcessMask: number;\n CatalogCd: number;\n ParentId: number;\n ProjectedOrderId: number;\n ProposalAcceptance: string;\n ProposalId: number;\n SignDtTm: string;\n ActionDisplay: string;\n SignedOrderStatusCd: number;\n LastActionPrsnlId: number;\n LastActionPrsnlName: string;\n LastActionDtTm: string;\n DetailList: DetailList;\n ComplianceDetailList: string;\n CommentList: CommentList;\n AdHocFreqList: AdHocFreqList;\n DiagnosisList: DiagnosisList;\n CurrSchedExceptionList: string;\n PrevSchedExceptionList: string;\n OrigSchedExceptionList: string;\n ResponsibleProviderId: number;\n ResponsibleProviderName: string;\n SuspendedDtTm: string;\n RelatedFromOrderId: number;\n OrderRelationTypeCd: number;\n OrderRelationTypeMeaning: string;\n OrderRelationTypeDisplay: string;\n ProposalRejectReasonCd: number;\n ProposalRejectReasonDisplay: string;\n ProposalFreetextRejectReason: string;\n};\n\n//XML data return subtype\nexport type FieldValueList = {\n ListValues: {\n FieldValue: number;\n FieldDisplayValue: number;\n FieldDtTmValue: string;\n };\n};\n\n//XML data return subtype\nexport type Detail = {\n FieldValueList: FieldValueList;\n OeFieldId: number;\n OeFieldMeaning: string;\n OeFieldMeaningId: number;\n ValueRequiredInd: number;\n GroupSeq: number;\n FieldSeq: number;\n ModifiedInd: number;\n DetailAlterFlag: number;\n};\n\n//XML data return subtype\nexport type DetailList = {\n STRENGTHDOSE: Detail;\n STRENGTHDOSEUNIT: Detail;\n RXROUTE: Detail;\n DRUGFORM: Detail;\n FREQ: Detail;\n 'SCH.PRN': Detail;\n OTHER: Detail[];\n DURATION: Detail;\n DURATIONUNIT: Detail;\n REQSTARTDTTM: Detail;\n STOPDTTM: Detail;\n STOPTYPE: Detail;\n FREQSCHEDID: Detail;\n ADHOCFREQINSTANCE: Detail;\n NEXTDOSEDTTM: Detail;\n PHARMORDERTYPE: Detail;\n DIFFINMIN: Detail;\n ICD9: Detail;\n INSTREPLACEREQUIREDDETS: Detail;\n REFERENCESTARTDTTM: Detail;\n DetailListCount: number;\n};\n\n//XML data return subtype\nexport type CommentList = {\n CommentValues: {\n CommentType: number;\n CommentText: string;\n };\n};\n\n//XML data return subtype\nexport type AdHocFreqList = {\n CurrSchedList: string;\n OrigSchedList: string;\n PrevSchedList: string;\n};\n\n//XML data return subtype\nexport type DiagnosisList = {\n Diagnosis: {\n DiagnosisId: number;\n NomenclatureId: number;\n SourceVocabularyCd: number;\n SourceIdentifier: string;\n DiagnosisDescription: string;\n DiagnosisRanking: number;\n SearchNomenclatureId: number;\n };\n};\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Attempts to silently sign orders on the scratchpad. If the orders cannot be signed silently, will display the MOEW.\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @resolves `PowerChartReturn`\n * @description The value returned by SignOrders() is not used and is not believed to be meaningful, but is logged\n * to the console for development purposes. In our testing, a 0 is returned if an improper MOEW handle is provided, but a 1 is returned otherwise\n * (any time SignOrders() is called) but this is not yet fully confirmed. If it is confirmed,\n * the resolved object will be updated to reflect this.\n */\n\nexport async function signOrdersAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number\n): Promise<PowerChartReturn> {\n let retData: PowerChartReturn = {\n inPowerChart: true,\n };\n\n try {\n const response = await dcof.SignOrders(moewHandle);\n // TODO: Remove this console.log() statement when development is complete\n console.log('Response from SignMOEW() is: ', response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { outsideOfPowerChartError } from './utils';\nimport { calculateMOEWBitmask } from './utils/calculateMOEWBitmask';\nimport { addNewOrdersToScratchpadAsync } from './utils/addNewOrdersToScratchPadAsync';\nimport { addPowerPlanWithDetailsAsync } from './utils/addPowerPlanWithDetailsAsync';\nimport { createMOEWAsync } from './utils/createMOEWAsync';\nimport { destroyMOEWAsync } from './utils/destroyMOEWAsync';\nimport { displayMOEWAsync } from './utils/displayMOEWAsync';\nimport {\n SubmitPowerOrdersStatus,\n getOrdersPlacedAsync,\n} from './utils/getOrdersPlacedAsync';\nimport { signOrdersAsync } from './utils/signOrdersAsync';\nimport { PowerChartReturn } from '.';\n\n/**\n * PowerOrdersMOEWFlags is a type which represents an optional array of flags to customize the MOEW. If not provided, the values will default to the recommended values for the MOEW\n * with PowerPlan support. If any values are provided, those will be the only values used by submitPowerOrdersAsync().\n * @action `add rx to filter` - Turns the prescription indicator on the default filter.\n * @action `allow only inpatient and outpatient orders` - Only inpatient and ambulatory venue ordering will be allowed.\n * @action `allow power plan doc` - Enables PowerPlan documentation.\n * @action `allow power plans` - Allows PowerPlans to be used from the MOEW.\n * @action `allow regimen` - Ensures that regimens are enabled.\n * @action `disable auto search` - Disables auto search.\n * @action `disallow EOL` - This option forces edit-on-line mode (which allows multi-selection) to be disabled.\n * @action `documented meds only` - Restricts the MOEW to only perform actions on documented medications.\n * @action `show demographics` - Displays the demographics bar in the MOEW.\n * @action `show med rec` - Displays medication reconiciliation controls in the MOEW.\n * @action `read only` - The MEOW will be read only.\n * @action `show diag and probs` - Configures the MOEW such that the diagnoses/problem control menu is displayed.\n * @action `show list details` - Configures the MOEW such that the order detail control is enabled. Note that this is required if adding any orders (if parameters are provided).\n * @action `show nav tree` - Configures the MOEW such that the navigator tree control is displayed.\n * @action `show order profile` - Configures the MOEW such that the order profile is displayed.\n * @action `show orders search` - Configures the MOEW such that the order search menu is displayed. Note that this is required if adding any orders (if parameters are provided).\n * @action `show refresh and print buttons` - Will show the refresh and print buttons in the MOEW.\n * @action `show related res` - Configures the MOEW such that the related results control is displayed.\n * @action `show scratchpad` - Configures the MOEW such that the scratchpad is displayed. Note that this is required if adding any orders (if parameters are provided).\n * @action `sign later` - Sign later functionality will be allowed from the MOEW.\n **/\nexport type PowerOrdersMOEWFlags =\n | 'add rx to filter'\n | 'allow only inpatient and outpatient orders'\n | 'allow power plan doc'\n | 'allow power plans'\n | 'allow regimen'\n | 'disable auto search'\n | 'disallow EOL'\n | 'documented meds only'\n | 'read only'\n | 'show demographics' // Cerner analog: 'hide demographics'\n | 'show diag and probs'\n | 'show list details'\n | 'show med rec' // Cerner analog: 'hide med rec'\n | 'show nav tree'\n | 'show order profile'\n | 'show orders search'\n | 'show refresh and print buttons'\n | 'show related res'\n | 'show scratchpad'\n | 'sign later';\n\n/**\n * StandaloneOrder is a type which contains the items needed to place a standalone order.\n * @param {number} synonymId - The synonym Id associated with the standalone order.\n * @param {'inpatient order' | 'prescription order'} origination - The origination of the order being placed.\n * @param {number} sentenceId - An optional order sentence Id for the order being placed.\n **/\nexport type StandaloneOrder = {\n synonymId: number;\n origination: 'inpatient order' | 'prescription order';\n sentenceId?: number;\n};\n\n/**\n * PowerPlanOrder is a type which contains the items needed to place a PowerPlan order.\n * @param {number} pathwayCatalogId -The pathway catalog Id associated with the PowerPlan order.\n * @param {number} personalizedPlanId - An optional personalized plan Id.\n * @param {Array<number>} diagnosisIds - An optional array of diagnosis Ids for the PowerPlan order to be associated with\n **/\nexport type PowerPlanOrder = {\n pathwayCatalogId: number;\n personalizedPlanId?: number;\n diagnosisIds?: Array<number>;\n};\n\n/**\n * PowerOrdersOrderOpts is a type which allows the user to choose settings (silent sign and interaction checking) that impact the manner in which order(s) are placed.\n * @param {boolean} signSilently - A boolean indicating whether or not a silent sign should be attempted.\n * @param {boolean} interactionChecking - A boolean indicating whether or not interaction checking (for standalone orders only) should be performed.\n **/\nexport type SubmissionOpts = {\n signSilently: boolean;\n interactionChecking: boolean;\n};\n\n/**\n * Submits a combination of standalone orders and/or PowerPlan orders by utilizing underlying Cerner - POWERORDERS functionality.\n * @param {number} patientId - The identifier for the patient. Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this order will be placed. Cerner context variable: VIS_EncntrId.\n * @param {Array<StandaloneOrder | PowerPlanOrder>} orders - An array of `StandaloneOrder` and/or `PowerPlanOrder`\n * objects, representing orders to be placed.\n * @param {PowerOrdersOpts} opts - An *optional* object containg a flag indicating whether or not the orders should be signed\n * silently and whether interaction checking should be performed for standalone orders. Defaults to no silent signing and interaction checking if not provided.\n * @param { Array<PowerOrdersMOEWFlags>} moewFlags - An *optional* array of strings defining the MOEW behavior/appearance. If not provided,\n * the values will default to the the order setting as well as recommended\n * values for the MOEW to be configured with PowerPlan support. If any values are provided, those will be the only values used.\n * @param {'order' | 'medications'} targetTab - (optional) Determines which list to target when lauching the MOEW.\n * Either the order list or the medication list (subset). Defaults to the complete order list if not provided.\n * @returns {SubmitPowerOrdersReturn} - an object with several high value properties: a boolean flag set to notify the user if the\n * attempt was made outside of PowerChart, the `status` of the order attempt, an object\n * representing the XML response string (converted to an array of the orders placed with order `name`,\n * `oid`, and `display` available for each), and the XML/response string itself (which is attempted to be parsed).\n * @throws {Error} - If no orders are provided, an Error will be thrown.\n * @throws {SyntaxError} - If any order provided is not of type `StandaloneOrder` or `PowerPlanOrder`, a SyntaxError will be thrown.\n */\nexport const submitPowerOrdersAsync = async (\n patientId: number,\n encounterId: number,\n orders: Array<StandaloneOrder | PowerPlanOrder>,\n opts?: SubmissionOpts,\n moewFlags?: Array<PowerOrdersMOEWFlags>,\n targetTab?: 'orders tab' | 'medications tab'\n): Promise<SubmitPowerOrdersReturn> => {\n opts = !opts ? { signSilently: false, interactionChecking: true } : opts;\n\n moewFlags = !moewFlags ? [] : moewFlags;\n\n // Get required bitmask values for later use in the CreateMOEW function\n // TODO: determine if this should be moved, and maybe simply integrated directly into the CreateMOEW function\n const {\n dwCustomizeFlag,\n dwTabFlag,\n dwTabDisplayOptionsFlag,\n } = calculateMOEWBitmask(targetTab || 'orders tab', moewFlags);\n\n let retData: SubmitPowerOrdersReturn = {\n inPowerChart: true,\n status: 'success',\n ordersPlaced: null,\n };\n\n if (orders.length < 1) {\n throw new Error(\n 'At least one order to submit must be provided to this function.'\n );\n }\n\n let powerPlanOrders: Array<PowerPlanOrder> = [];\n let standaloneOrders: Array<StandaloneOrder> = [];\n\n orders.forEach(order => {\n if (isPowerPlanOrder(order)) {\n powerPlanOrders.push(order as PowerPlanOrder);\n } else if (isStandaloneOrder(order)) {\n standaloneOrders.push(order as StandaloneOrder);\n } else {\n throw new SyntaxError(\n 'Each order provided must be of either a PowerPlanOrder or StandaloneOrder type.'\n );\n }\n });\n\n try {\n let moewId: number = 0;\n\n const dcof = await window.external.DiscernObjectFactory('POWERORDERS');\n\n const createMOEW = await createMOEWAsync(\n dcof,\n patientId,\n encounterId,\n dwCustomizeFlag,\n dwTabFlag,\n dwTabDisplayOptionsFlag\n );\n\n if (createMOEW.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n\n if (createMOEW.moewHandle === null) {\n retData.inPowerChart = true;\n retData.ordersPlaced = null;\n retData.status = 'invalid data returned';\n return retData;\n }\n\n moewId = createMOEW.moewHandle;\n\n if (powerPlanOrders && powerPlanOrders.length >= 1) {\n const addPowerPlans = await addPowerPlanWithDetailsAsync(\n dcof,\n moewId,\n powerPlanOrders\n );\n\n if (addPowerPlans.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n\n if (addPowerPlans.powerPlansAdded === false) {\n retData.inPowerChart = true;\n retData.ordersPlaced = null;\n retData.status = 'cancelled, failed, or invalid parameters provided';\n return retData;\n }\n }\n\n if (standaloneOrders && standaloneOrders.length >= 1) {\n const addStandaloneOrders = await addNewOrdersToScratchpadAsync(\n dcof,\n moewId,\n standaloneOrders,\n opts.interactionChecking\n );\n\n if (addStandaloneOrders.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n\n if (\n addStandaloneOrders.result === 'add failed' ||\n addStandaloneOrders.result === 'cancelled by user'\n ) {\n retData.inPowerChart = true;\n retData.ordersPlaced = null;\n retData.status = 'cancelled, failed, or invalid parameters provided';\n return retData;\n }\n }\n\n if (opts.signSilently) {\n const signOrders = await signOrdersAsync(dcof, moewId);\n\n if (signOrders.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n } else {\n const displayMOEW = await displayMOEWAsync(dcof, moewId);\n\n if (displayMOEW.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n }\n\n const getPlacedOrders = await getOrdersPlacedAsync(dcof, moewId);\n\n if (getPlacedOrders.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n\n if (\n getPlacedOrders.ordersPlaced === null ||\n getPlacedOrders.ordersPlaced.length === 0\n ) {\n retData.inPowerChart = true;\n retData.ordersPlaced = null;\n retData.status = getPlacedOrders.status;\n return retData;\n }\n\n retData.inPowerChart = true;\n retData.ordersPlaced = getPlacedOrders.ordersPlaced;\n retData.status = getPlacedOrders.status;\n\n const destroyMOEW = await destroyMOEWAsync(dcof, moewId);\n\n if (destroyMOEW.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n } else {\n throw e;\n }\n }\n\n return retData;\n};\n\nexport type SubmitPowerOrdersReturn = PowerChartReturn & {\n status: SubmitPowerOrdersStatus;\n ordersPlaced: Array<{ name: string; oid: number; display: string }> | null;\n};\n\nconst isPowerPlanOrder = (o: PowerPlanOrder | StandaloneOrder): boolean => {\n return o.hasOwnProperty('pathwayCatalogId');\n};\n\nconst isStandaloneOrder = (o: PowerPlanOrder | StandaloneOrder): boolean => {\n return o.hasOwnProperty('synonymId') && o.hasOwnProperty('origination');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAoC;;;ACM7B,SAAS,yBAAyB,GAAY;AACnD,SACE,aAAa,aACb,+EAA+E;AAAA,IAC7E,EAAE;AAAA,EACJ;AAEJ;AAMO,IAAM,yCAAyC,CACpD,gBACS;AACT,UAAQ,KAAK,kCAAkC,WAAW,IAAI;AAChE;;;ACVA,eAAsB,2BACpB,WACA,aACA,SACkD;AAClD,MAAI,SAAkD;AAAA,IACpD,cAAc;AAAA,IACd,SAAS;AAAA,EACX;AAEA,MAAI;AACF,UAAM,OAAO,MAAM,OAAO,SAAS,qBAAqB,QAAQ;AAChE,QAAI,WAAyB;AAC7B,eAAW,MAAM,KAAK;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,WAAO,UAAU,QAAQ,QAAQ;AAAA,EACnC,SAAS,GAAG;AACV,QAAI,yBAAyB,CAAC,GAAG;AAC/B,aAAO,eAAe;AACtB,aAAO;AAAA,IACT,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AAEA,SAAO;AACT;;;AC3BA,eAAsB,uBACpB,QACA,WACA,aACA,IACA,YACkD;AAClD,MAAI,SAAkD;AAAA,IACpD,cAAc;AAAA,IACd,SAAS;AAAA,EACX;AAEA,MAAI;AACF,UAAM,OAAO,MAAM,OAAO,SAAS,qBAAqB,QAAQ;AAEhE,QAAI,WAAyB;AAE7B,QAAI,WAAW,iBAA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AAiB,OAAO;AACtC,gBAAQ,eAAe;AACvB,gBAAQ,eAAe;AACvB,gBAAQ,SAAS;AACjB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,UAAM,kBAAkB,MAAM,qBAAqB,MAAM,MAAM;AAE/D,QAAI,gBAAgB,iBAAiB,OAAO;AAC1C,cAAQ,eAAe;AACvB,cAAQ,eAAe;AACvB,cAAQ,SAAS;AACjB,aAAO;AAAA,IACT;AAEA,QACE,gBAAgB,iBAAiB,QACjC,gBAAgB,aAAa,WAAW,GACxC;AACA,cAAQ,eAAe;AACvB,cAAQ,eAAe;AACvB,cAAQ,SAAS,gBAAgB;AACjC,aAAO;AAAA,IACT;AAEA,YAAQ,eAAe;AACvB,YAAQ,eAAe,gBAAgB;AACvC,YAAQ,SAAS,gBAAgB;AAEjC,UAAM,cAAc,MAAM,iBAAiB,MAAM,MAAM;AAEvD,QAAI,YAAY,iBAAiB,OAAO;AACtC,cAAQ,eAAe;AACvB,cAAQ,eAAe;AACvB,cAAQ,SAAS;AACjB,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AACV,QAAI,yBAAyB,CAAC,GAAG;AAC/B,cAAQ,eAAe;AACvB,cAAQ,eAAe;AACvB,cAAQ,SAAS;AACjB,aAAO;AAAA,IACT,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AAEA,SAAO;AACT;AAOA,IAAM,mBAAmB,CAAC,MAAiD;AACzE,SAAO,EAAE,eAAe,kBAAkB;AAC5C;AAEA,IAAM,oBAAoB,CAAC,MAAiD;AAC1E,SAAO,EAAE,eAAe,WAAW,KAAK,EAAE,eAAe,aAAa;AACxE;","names":["opts","import_fast_xml_parser"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/index.ts","../src/addAddendumToDocumentAsync.ts","../src/createNewDocumentAsync.ts","../src/getValidEncountersAsync.ts","../src/launchClinicalNoteAsync.ts","../src/launchDischargeProcessAsync.ts","../src/launchPatientEducationAsync.ts","../src/launchPowerFormAsync.ts","../src/launchPowerNoteAsync.ts","../src/manageAppointmentAsync.ts","../src/openApplicationAsync.ts","../src/openOrganizerTabAsync.ts","../src/openPatientTabAsync.ts","../src/openWebsiteByUrlAsync.ts","../src/submitOrdersAsync.ts","../src/utils/createOrderString.ts","../src/utils/calculateMOEWBitmask.ts","../src/utils/addNewOrdersToScratchPadAsync.ts","../src/utils/addPowerPlanWithDetailsAsync.ts","../src/utils/createMOEWAsync.ts","../src/utils/destroyMOEWAsync.ts","../src/utils/displayMOEWAsync.ts","../src/utils/getOrdersPlacedAsync.ts","../src/utils/signOrdersAsync.ts","../src/submitPowerOrdersAsync.ts"],"sourcesContent":["import { makeCclRequestAsync } from 'easy-ccl-request';\nimport type {\n CclCallParam,\n CclRequestResponse,\n XmlCclResult,\n XmlCclReadyState,\n} from 'easy-ccl-request';\nimport { addAddendumToDocumentAsync } from './addAddendumToDocumentAsync';\nimport { createNewDocumentAsync } from './createNewDocumentAsync';\nimport { getValidEncountersAsync } from './getValidEncountersAsync';\nimport { launchClinicalNoteAsync } from './launchClinicalNoteAsync';\nimport type {\n ClinicalNoteOpts,\n InheretanceProps,\n ViewOption,\n} from './launchClinicalNoteAsync';\nimport { launchDischargeProcessAsync } from './launchDischargeProcessAsync';\nimport { launchPatientEducationAsync } from './launchPatientEducationAsync';\nimport { launchPowerFormAsync } from './launchPowerFormAsync';\nimport { launchPowerNoteAsync } from './launchPowerNoteAsync';\nimport { manageAppointmentAsync } from './manageAppointmentAsync';\nimport type {\n AppointmentAction,\n AppointmentReturn,\n} from './manageAppointmentAsync';\nimport { openApplicationAsync } from './openApplicationAsync';\nimport type {\n OpenApplicationArgument,\n OpenApplicationMode,\n} from './openApplicationAsync';\nimport { openOrganizerTabAsync } from './openOrganizerTabAsync';\nimport { openPatientTabAsync } from './openPatientTabAsync';\nimport { openWebsiteByUrlAsync } from './openWebsiteByUrlAsync';\nimport { submitOrdersAsync } from './submitOrdersAsync';\nimport type {\n SubmitOrderAsyncOpts,\n SubmitOrderAsyncReturn,\n SubmitOrdersAsyncStatus,\n OrderAction,\n OrderOpts,\n Order,\n} from './submitOrdersAsync';\nimport { submitPowerOrdersAsync } from './submitPowerOrdersAsync';\n\n// Export functions\nexport {\n addAddendumToDocumentAsync,\n createNewDocumentAsync,\n getValidEncountersAsync,\n launchClinicalNoteAsync,\n launchDischargeProcessAsync,\n launchPatientEducationAsync,\n launchPowerFormAsync,\n launchPowerNoteAsync,\n makeCclRequestAsync,\n manageAppointmentAsync,\n openApplicationAsync,\n openOrganizerTabAsync,\n openPatientTabAsync,\n openWebsiteByUrlAsync,\n submitOrdersAsync,\n submitPowerOrdersAsync,\n};\n\n// Export types\nexport type {\n AppointmentAction,\n AppointmentReturn,\n CclCallParam,\n CclRequestResponse,\n ClinicalNoteOpts,\n InheretanceProps,\n OpenApplicationArgument,\n OpenApplicationMode,\n Order,\n OrderAction,\n OrderOpts as OrderStrOpts,\n SubmitOrderAsyncOpts,\n SubmitOrderAsyncReturn,\n SubmitOrdersAsyncStatus,\n ViewOption,\n XmlCclReadyState,\n XmlCclResult,\n};\n\nexport type PowerChartReturn = {\n inPowerChart: boolean;\n};\n\n/**\n * A type which represents the object to be returned from the launchClinicalNote() function.\n * @param {string} eventString - The string version of the MPageEvent\n * @param {boolean} inPowerChart - Returns `true` if being run from inside of PowerChart and returns `false` otherwise.\n **/\nexport type MPageEventReturn = PowerChartReturn & {\n eventString: string;\n};\n\n/**\n * @param {string} eventString - string being provided as an argument to the Discern\n * native function call.\n * @param {boolean} inPowerChart - whether or not the function is being run from inside of\n * PowerChart.\n * @param {boolean} badInput - whether or not the input provided to the function is valid as\n * reported by the Discern engine.\n */\nexport type ApplinkReturn = MPageEventReturn & { badInput: boolean };\n\ndeclare global {\n /**\n * A type which ensures that only valid DiscernCOMObjects can be\n * passed to the DiscernObjectFactory constructor.\n */\n type DiscernCOMObjects =\n | 'INFOBUTTONLINK'\n | 'DISCHARGEPROCESS'\n | 'DYNDOC'\n | 'KIACROSSMAPPING'\n | 'ORDERS'\n | 'PATIENTEDUCATION'\n | 'PEXAPPLICATIONSTATUS'\n | 'PEXSCHEDULINGACTIONS'\n | 'PMLISTMAINTENANCE'\n | 'POWERFORM'\n | 'POWERNOTE'\n | 'POWERORDERS'\n | 'PREGNANCY'\n | 'PVCONTXTMPAGE'\n | 'PVFRAMEWORKLINK'\n | 'PVPATIENTFOCUS'\n | 'PVPATIENTSEARCHMPAGE'\n | 'PVVIEWERMPAGE'\n | 'TASKDOC';\n interface Window {\n readonly external: External;\n /**\n * Interface for the Cerner Discern native function which provides the function\n * responsible for opening an application, chart tab, or organization level tab.\n * Useful for development but not intended for production use.\n * @param {0 | 1 | 100} mode - The _linkmode_ parameter for the APPLINK function.The value 0\n * is used for starting a solution by application name (e.g. Powerchart.exe), the value 1\n * is used for starting a solution by solution object (e.g. DiscernAnalytics.Application),\n * and the value 100 is used for launching a link, file, or executable through a shell execute\n * (e.g. launch a URL).\n * @param {string} target - The _launchobject_ parameter for the APPLINK function. This can\n * represent an executable name, application object, file, or link to start based on the\n * _mode_ (_linkmode_) parameter. This accepts Powerchart context variables, and using\n * `$APP_AppName$` is useful in place of the executable name if you watn to open a patient\n * in the context of the current solution.\n */\n APPLINK: (mode: 0 | 1 | 100, target: string, args: string) => Promise<null>;\n }\n export type DiscernObjectFactoryReturn = {\n /**\n * Creates the MOEW handle.\n * @param dPersonId {number} - the patient ID\n * @param dEncntrId {number} - the encounter ID in which orders would be placed\n * @param dwCustomizeFlag {number} - mask used to determine options available within the MOEW\n * @param dwTabFlag {number} - the type of list being customized (2 for orders, 3 for medications).\n * @param dwTabDisplayOptionsFlag {number} - mask specifying the components to display on the list.\n * @returns a `Promise` which resolves to an integer representing a handle to the MOEW instance. 0 indicates an invalid call or call from outside PowerChart.\n */\n CreateMOEW: (\n dPersonId: number,\n dEncntrId: number,\n dwCustomizeFlag: number,\n dwTabFlag: number,\n dwTabDisplayOptionsFlag: number\n ) => Promise<number>;\n /**\n * Creates PowerPlan objects from the pathway catalog IDs. CreateMOEW() must be called first.\n * @param lMOEWHandle {number} - the handle to the MOEW\n * @param planDetailsXMLBstr {string} - XML string containing the plan/pathway catalog IDs\n * @returns a `Promise` which resolves to an integer: 1 if the plan was added successfully, and 0 otherwise.\n */\n AddPowerPlanWithDetails: (\n lMOEWHandle: number,\n planDetailsXMLBstr: string\n ) => Promise<number>;\n /**\n * Attempts to add standalone orders to the scratchpad. CreateMOEW() must be called first.\n * @param lMOEWHandle {number} - the handle to the MOEW\n * @param newOrdersXMLBstr {string} - XML string containing the order details, including synonym IDs\n * @param bSignTimeInteractionChecking {boolean} - indicates if interaction checking should be performed at order sign time.\n * @returns a `Promise` which resolves to an integer: 1 if the orders were added successfully, and 0 otherwise.\n */\n AddNewOrdersToScratchpad: (\n lMOEWHandle: number,\n newOrdersXMLBstr: string,\n bSignTimeInteractionChecking: boolean\n ) => Promise<number>;\n /**\n * Displays the modal order entry window (MOEW).\n * @param {number} lMOEWHandle - the handle to the MOEW.\n * @returns a `Promise` which resolves to an integer (0). This appears to be returned upon either a successful or unsuccessful launch.\n */\n DisplayMOEW: (lMOEWHandle: number) => Promise<number>;\n /**\n * Attempts to silently sign orders on the scratchpad. If the orders cannot be signed silently, will display the MOEW.\n * @param {number} lMOEWHandle - the handle to the MOEW.\n * @returns a `Promise` which resolves to an integer: 0 if called with invalid/improperly structured paramters, and 1 otherwise.\n */\n SignOrders: (lMOEWHandle: number) => Promise<number>;\n /**\n * Retrieves the XML representation of the order information signed during the previous MOEW invocation.\n * @param {number} lMOEWHandle - the handle to the MOEW.\n * @returns a `Promise` which resolves to a string containing prior order information. If none or invalid, the string will be empty.\n */\n GetXMLOrdersMOEW: (lMOEWHandle: number) => Promise<string>;\n /**\n * Destroys the modal order entry window (MOEW).\n * @param {number} lMOEWHandle - the handle to the MOEW.\n * @returns a `Promise` which resolves to null. This appears to be returned upon either a successful or unsuccessful destruction.\n * @throws `Error` if an unexpected error occurs.\n */\n DestroyMOEW: (lMOEWHandle: number) => Promise<null>;\n /**\n * Get valid encounter ID's for a given patient.\n * @param pid {number} - the patient ID of the patient to get encounters for.\n * @returns a `Promise` of a string representing the valid encounter ID's for the patient.\n */\n GetValidEncounters: (pid: number) => Promise<string>;\n /**\n * Provide patient context to the Discern COM object.\n * @param pid {number} - the patient ID of the patient provided for context.\n *\n * @returns a `Promise` which always returns `null`.\n */\n SetPatient(pid: number, eid: number): Promise<null>;\n /**\n * Provide patient context to the Discern COM object.\n * @param tab {0 | 1} - the tab to target upon opening. Instruction component is `0` and\n * Follow-up component is `1`.\n * @returns a `Promise` which always returns `null`.\n */\n SetDefaultTab(tab: 0 | 1): Promise<null>;\n /**\n * Open the modal for the targeted COM object.\n * @returns a `Promise` which always returns `null`.\n */\n DoModal(): Promise<null>;\n /**\n * Launches a dialog to check in the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n CheckInAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Launches a dialog to check out the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n CheckOutAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Launches a dialog to cancel the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n CancelAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Launches a dialog to put a hold on the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n HoldAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Launches a dialog to mark the specified appointment as 'no show'.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n NoShowAppointment(eventId: number): Promise<0 | 1>;\n /**\n * Display the appointment view dialog for the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n ShowView(eventId: number): Promise<0 | 1>;\n /**\n * Display the appointment history view dialog for the specified appointment.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves to `0` if the action was successful, `1` otherwise.\n */\n ShowHistoryView(eventId: number): Promise<0 | 1>;\n // TODO: update return type and JSDOc\n OpenNewDocumentByReferenceTemplateId(\n pid: number,\n eid: number,\n refTemplateId: number\n ): Promise<null>;\n // TODO: update return type and JSDOc\n OpenNewDocumentByReferenceTemplateIdAndNoteType(\n pid: number,\n eid: number,\n refTemplateId: number,\n noteTypeCd: number\n ): Promise<null>;\n // TODO: update return type and JSDOc\n ModifyExistingDocumentByEventId(\n pid: number,\n eid: number,\n docEventId: number\n ): Promise<null>;\n // TODO: update return type and JSDOc\n OpenDynDocByWorkFlowId(\n pid: number,\n eid: number,\n workflowId: number\n ): Promise<null>;\n // TODO: update return type and JSDOc\n LaunchDischargeDialog(): Promise<null>;\n /**\n * A parameter to set the patient context for the Discern COM object.\n * At the time of writing this, the only discernable use for this is the\n * `DISCHARGEPROCESS` object.\n */\n person_id: number;\n /**\n * A parameter to set the encounter context for the Discern COM object.\n * At the time of writing this, the only discernable use for this is the\n * `DISCHARGEPROCESS` object.\n */\n encounter_id: number;\n /**\n * A parameter to set the user context for the Discern COM object.\n * At the time of writing this, the only discernable use for this is the\n * `DISCHARGEPROCESS` object.\n */\n user_id: number;\n };\n\n interface External {\n /**\n * A factory function which returns a Discern COM object.\n * @param comObject {DiscernCOMObjects} - a string representing the Discern\n * COM object to be created.\n * @returns the COM object the user will interact with.\n */\n DiscernObjectFactory: (\n comObject: DiscernCOMObjects\n ) => Promise<DiscernObjectFactoryReturn>;\n /**\n * Interface for the Cerner Discern native function which provides the function\n * responsible for engaging in special Cerneer _conversation events_ within the\n * web page (MPage) with the Cerner PowerChart application. Useful for development\n * but not intended for production use.\n * @param {string} type - The type of event to be triggered. Can by `'ALLERGY' | 'POWERFORM' | 'POWERNOTE' | 'ORDERS' | 'CLINICALNOTE'`\n * @param {string} args - Argument data passed to the event, specific to the event type.\n */\n MPAGES_EVENT: (\n type: 'ALLERGY' | 'POWERFORM' | 'POWERNOTE' | 'ORDERS' | 'CLINICALNOTE',\n args: string\n ) => Promise<string | number | object | void>;\n }\n}\n","/**\n * Check to see if the error reflects likely being outside of PowerChart.\n * @param e {Error} - The error to be checked.\n * @returns {boolean} - Returns `true` if the error is one of two cases that result\n * from being outside of Cerner PowerChart.\n */\nexport function outsideOfPowerChartError(e: unknown) {\n return (\n e instanceof TypeError &&\n /(MPAGES_EVENT|XMLCclRequest|APPLINK|DiscernObjectFactory) is not a function/i.test(\n e.message\n )\n );\n}\n\n/**\n * A wrapper function for the `console.warn` function which logs a warning message.\n * @param eventString {string} - The event string to be logged.\n */\nexport const warnAttemptedOrdersOutsideOfPowerChart = (\n eventString: string\n): void => {\n console.warn(`window.MPAGES_EVENT('ORDERS', '${eventString}')`);\n};\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Add an addendum to an existing document for a given patient and encounter using the\n * DYNDOC Discern COM object. Of note, Cerner PowerChart refers the \"addendum\" action\n * with the \"modify\" terminology.\n * @param {number} patientId - the patient ID to launch the document for\n * @param {number} encounterId - the encounter ID to launch the document in\n * @param {number} eventId - the event ID of the document to modify.\n * @resolves `PowerChartReturn & { success: boolean }`.\n */\n\nexport async function addAddendumToDocumentAsync(\n patientId: number,\n encounterId: number,\n eventId: number\n): Promise<PowerChartReturn & { success: boolean }> {\n let retVal: PowerChartReturn & { success: boolean } = {\n inPowerChart: true,\n success: false,\n };\n\n try {\n const dcof = await window.external.DiscernObjectFactory('DYNDOC');\n let response: 0 | 1 | null = null;\n response = await dcof.ModifyExistingDocumentByEventId(\n patientId,\n encounterId,\n eventId\n );\n retVal.success = Boolean(response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retVal.inPowerChart = false;\n return retVal;\n } else {\n throw e;\n }\n }\n\n return retVal;\n}\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n/**\n * Create a new document for a given patient and encounter using the\n * DYNDOC Discern COM object. The document can be created using either\n * a reference template ID or a reference template ID and an optional note type code,\n * depending on the chosen method of 'by workflow' or 'by reference template'.\n * @param {'by workflow' | 'by reference template'} method - the method to use to create the document.\n * @param {number} patientId - the patient ID to launch the document for.\n * @param {number} encounterId - the encounter ID to launch the document in.\n * @param {number} id - the ID of the reference template or workflow to use to create the document.\n * @param {number} noteTypeCd - (optional) the note type code to use to create the document.\n * @rejects `PowerChartReturn & { success: boolean }`\n * @throws {Error} - an error is thrown if the method provided as an argument is not supported.\n */\nexport async function createNewDocumentAsync(\n method: 'by workflow' | 'by reference template',\n patientId: number,\n encounterId: number,\n id: number,\n noteTypeCd?: number\n): Promise<PowerChartReturn & { success: boolean }> {\n let retVal: PowerChartReturn & { success: boolean } = {\n inPowerChart: true,\n success: false,\n };\n\n try {\n const dcof = await window.external.DiscernObjectFactory('DYNDOC');\n\n let response: 0 | 1 | null = null;\n\n if (method !== 'by workflow' && method !== 'by reference template') {\n throw new Error(`createNewDocumentAsync: ${method} is not supported`);\n }\n\n if (method === 'by workflow' && noteTypeCd) {\n console.warn(\n 'The noteTypeCd is not used when creating a document by workflow.'\n );\n }\n\n if (method === 'by workflow') {\n response = await dcof.OpenDynDocByWorkFlowId(patientId, encounterId, id);\n }\n\n if (method === 'by reference template' && !noteTypeCd) {\n response = await dcof.OpenNewDocumentByReferenceTemplateId(\n patientId,\n encounterId,\n id\n );\n }\n\n if (method === 'by reference template' && noteTypeCd) {\n response = await dcof.OpenNewDocumentByReferenceTemplateIdAndNoteType(\n patientId,\n encounterId,\n id,\n noteTypeCd\n );\n }\n\n retVal.success = Boolean(response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retVal.inPowerChart = false;\n } else {\n throw e;\n }\n }\n\n return retVal;\n}\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Get a list of valid encounter ID's for a given patient.\n * @param {number} personId - the patient ID to get valid encounters for\n * @resolves `PowerChartReturn & {encounterIds: Array<number>}`. If there\n * are no valid encounters, the `encounterIds` array will be empty.\n */\nexport async function getValidEncountersAsync(\n personId: number\n): Promise<PowerChartReturn & { encounterIds: Array<number> }> {\n const retData: {\n inPowerChart: boolean;\n encounterIds: Array<number>;\n } = {\n inPowerChart: true,\n encounterIds: [],\n };\n try {\n const dcof = await window.external.DiscernObjectFactory('PVCONTXTMPAGE');\n const response = await dcof.GetValidEncounters(personId);\n const eidStr = response.trim();\n if (eidStr === '') return retData;\n eidStr.split(',').forEach((e) => {\n const eid = parseFloat(e);\n if (isNaN(eid)) {\n console.warn(\n `getValidEncountersAsync: encounter ID ${e} could not be parsed to a number.`\n );\n } else {\n retData.encounterIds.push(eid);\n }\n });\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { MPageEventReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Available options for the Clinical Note view.\n */\nexport type ViewOption =\n | 'menu'\n | 'buttons'\n | 'toolbar'\n | 'calculator'\n | 'view-only';\n\n/**\n * @param {string} viewName - The view name for the view-level preference of the tab to model the preferences after.\n * @param {number} viewSeq - The view sequence for the view-level preference of the tab to model the\n * preferences after. An invalid viewSeq loads the clinical note with the default preferences.\n * @param {string} compName - The component name for the component-level preference of the tab to model the\n * preferences after. An invalid compName loads the clinical note with the default preferences.\n * @param {number} compSeq - \tThe component sequence for the component-level preference of the tab to model\n * the preferences after. An invalid compSeq loads the clinical note with the default preferences.\n */\nexport type InheretanceProps = {\n viewName: string;\n viewSeq: number;\n compName: string;\n compSeq: number;\n};\n\n/**\n * @param {string} windowTitle - The text to be displayed in the first section of the title for the\n * Clinical Notes window.\n * @param {Array<ViewOption>} viewOptionFlags - (optional) View options for the Clinical Notes window.\n * If not provided, defaults to `view-only` with no other options.\n * @param {InheretanceProps} inheritanceProps - (optional) The view and component names and sequences\n * to be used for the Clinical Notes window. If not provided, uses default preferences.\n **/\nexport type ClinicalNoteOpts = {\n windowTitle?: string;\n viewOptionFlags?: Array<ViewOption>;\n inheritanceProps?: InheretanceProps;\n};\n\n/**\n * Launches a clinical note in PowerChart inheriting the preferences of the component and view described below.\n * If any of the values is invalid, it will use the default values.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param {Array<number>} eventIds - An array of `event_id`'s of the clinical note(s) to be displayed.\n * @param {ClinicalNoteOpts} opts - (optional) optional configuration parameters.\n * @returns a `Promise` returning an `MPageEventReturn` object containing the `eventString`\n * and `inPowerChart` values. Of note, we cannot provide additional information about the\n * success or failure of the invocation because this information is not provided by the\n * underlying Discern native function call's return, which awlays returns `null` no matter\n * the outcome of the call.\n **/\nexport const launchClinicalNoteAsync = async (\n patientId: number,\n encounterId: number,\n eventIds: Array<number>,\n opts?: ClinicalNoteOpts\n): Promise<MPageEventReturn> => {\n const { viewOptionFlags, inheritanceProps, windowTitle } = opts || {};\n const { viewName, viewSeq, compName, compSeq } = inheritanceProps || {};\n\n let inPowerChart = true;\n const params: Array<string> = [`${patientId}`, `${encounterId}`];\n\n const _viewOptsFlags: Array<ViewOption> =\n !viewOptionFlags || viewOptionFlags.length === 0\n ? ['view-only']\n : viewOptionFlags;\n\n params.push(`[${eventIds.join('|')}]`);\n params.push(\n `${\n windowTitle ||\n `Clinical Note for patient with PID ${patientId} on encounter with EID ${encounterId}`\n }`\n );\n params.push(`${calculateViewOptionFlag(_viewOptsFlags)}`);\n params.push(`${viewName || ''}`);\n params.push(`${viewSeq || ''}`);\n params.push(`${compName || ''}`);\n params.push(`${compSeq || ''}`);\n\n const eventString = `${params.join('|')}`;\n try {\n await window.external.MPAGES_EVENT('CLINICALNOTE', eventString);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n inPowerChart = false;\n console.warn(`window.MPAGES_EVENT('CLINICALNOTE', '${eventString}')`);\n } else {\n throw e;\n }\n }\n\n return { inPowerChart, eventString };\n};\n\nfunction calculateViewOptionFlag(viewOptionFlags: Array<ViewOption>): number {\n let total = 0;\n viewOptionFlags.forEach((flag) => {\n if (flag === 'menu') total += 1;\n if (flag === 'buttons') total += 2;\n if (flag === 'toolbar') total += 4;\n if (flag === 'calculator') total += 8;\n if (flag === 'view-only') total += 16;\n });\n return total;\n}\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Launch Discharge Process dialog for a given patient and encounter.\n * @resolves `PowerChartReturn`\n */\nexport async function launchDischargeProcessAsync(\n patientId: number,\n encounterId: number,\n providerId: number\n): Promise<PowerChartReturn> {\n const retData: PowerChartReturn = {\n inPowerChart: true,\n };\n try {\n const dcof = await window.external.DiscernObjectFactory('DISCHARGEPROCESS');\n dcof.person_id = patientId;\n dcof.encounter_id = encounterId;\n dcof.user_id = providerId;\n dcof.LaunchDischargeDialog();\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Launch Patient Education for a given patient and encounter.\n * @param patientId {number} - the patient ID to get valid encounters for.\n * @param encounterId {number} - the encounter ID to get valid encounters for.\n * @param targetTab {'instruction' | 'follow-up'} - the tab to target upon opening.\n * @resolves a `PowerChartReturn`.\n */\nexport async function launchPatientEducationAsync(\n patientId: number,\n encounterId: number,\n targetTab: 'instruction' | 'follow-up'\n): Promise<PowerChartReturn> {\n const retData: PowerChartReturn = {\n inPowerChart: true,\n };\n try {\n const dcof = await window.external.DiscernObjectFactory('PATIENTEDUCATION');\n await dcof.SetPatient(patientId, encounterId);\n await dcof.SetDefaultTab(targetTab === 'instruction' ? 0 : 1);\n await dcof.DoModal();\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n return {\n inPowerChart: false,\n };\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { MPageEventReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Launch a PowerForm in Cerner's PowerChart.\n * @param {string} target - Determines whether which type of PowerForm action to take\n * upon launch. Choices are: \"new form\", \"completed form\", \"modify completed form\", or\n * \"new form search\". Cerner context variable: VIS_PowerFormTarget.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param {number} targetId - (optional) For a new form, this is the formId (pulled from DCP_FORMS_REF_ID).\n * For a completed form, this is the activityId (pulled from DCP_FORMS_ACTIVITY_ID). This parameter is\n * required for all targets except \"new form search\".\n * @resolves `MPageEventReturn`\n * @throws if there is a type mismatch between the provided option for `target` and `targetId`,\n * or if an unexpected error has occured.\n **/\nexport const launchPowerFormAsync = async (\n target: 'modify form' | 'new form' | 'new form search' | 'view form',\n patientId: number,\n encounterId: number,\n targetId?: number\n): Promise<MPageEventReturn> => {\n const requiresTargetId =\n target === 'new form' || target === 'view form' || target === 'modify form';\n\n if (requiresTargetId && !targetId) {\n throw new Error(\n \"'targetId' is required for all targets except 'new form search'.\"\n );\n }\n\n const params: Array<string> = [`${patientId}`, `${encounterId}`];\n switch (target) {\n case 'new form':\n params.push(`${targetId}`);\n params.push('0');\n break;\n case 'view form':\n case 'modify form':\n params.push('0');\n params.push(`${targetId}`);\n break;\n case 'new form search':\n params.push('0');\n params.push('0');\n break;\n }\n\n params.push(target === 'view form' ? '1' : '0');\n\n const retData: MPageEventReturn = {\n eventString: `${params.join('|')}`,\n inPowerChart: true,\n };\n\n try {\n await window.external.MPAGES_EVENT('POWERFORM', retData.eventString);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n console.warn(\n `window.MPAGES_EVENT('POWERFORM', '${retData.eventString}')`\n );\n } else {\n throw e;\n }\n }\n\n return retData;\n};\n","import { MPageEventReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\n/**\n * Launch a PowerNote in Cerner's PowerChart.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param {string} target - Determines whether to target (open) a \"new\" PowerNote or an \"existing\" PowerNote.\n * @param {number | string} targetId - For a `new` note, this value should be a `string` representing the\n * CKI value for an encounter pathway. For an `existing` note, this value should be a `number` representing\n * the eventId of the note to be opened.\n * @resolves `MPageEventReturn`\n * @throws if there is a type mismatch between the provided option for `target` and `targetId`,\n * or if an unexpected error has occured.\n **/\nexport const launchPowerNoteAsync = async (\n target: 'new' | 'existing',\n patientId: number,\n encounterId: number,\n targetId: string | number\n): Promise<MPageEventReturn> => {\n if (target === 'new' && typeof targetId !== 'string') {\n throw new Error(\n 'targetId (for CKI) must be a string when launching a new PowerNote.'\n );\n }\n\n if (target === 'existing' && typeof targetId !== 'number') {\n throw new Error(\n 'targetId must be a number when loading an existing PowerNote.'\n );\n }\n const params: Array<string> = [\n `${patientId}`,\n `${encounterId}`,\n `${target === 'new' ? targetId : ''}`,\n `${target === 'existing' ? targetId : 0}`,\n ];\n\n const eventString = `${params.join('|')}`;\n let inPowerChart = true;\n try {\n await window.external.MPAGES_EVENT('POWERNOTE', eventString);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n inPowerChart = false;\n console.warn(`window.MPAGES_EVENT('POWERNOTE', '${eventString}')`);\n } else {\n throw e;\n }\n }\n\n return { eventString, inPowerChart };\n};\n","import { PowerChartReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\nexport type AppointmentAction =\n | 'check in'\n | 'check out'\n | 'cancel'\n | 'no show'\n | 'view appt dialog'\n | 'view appt history';\n\nexport type AppointmentReturn = PowerChartReturn & {\n success: boolean;\n};\n\n/**\n * Managed appointments in PowerChart. For any given appointment ID, the\n * following actions can be performed: check in, check out, cancel, no show,\n * view appointment dialog, and view appointment history. This is a wrapper function\n * for the `PEXSCHEDULINGACTIONS` Discern COM object.\n * @param action {string} - the action to perform on the appointment. The available\n * actions are: 'check in', 'check out', 'cancel', 'no show', 'view appt dialog',\n * and 'view appt history'.\n * @param eventId {number} - the event ID of the appointment to check in.\n * @resolves an `AppointmentReturn` object with the following properties:\n * - `success` - `true` if the action was successful, `false` otherwise.\n * - `inPowerChart` - `true` if the action was successful, `false` otherwise.\n * @throws an `Error` if the action is invalid.\n */\nexport async function manageAppointmentAsync(\n action: AppointmentAction,\n eventId: number\n): Promise<AppointmentReturn> {\n let actionSuccess: 0 | 1 = 0;\n let inPowerChart = true;\n\n try {\n const dcof = await window.external.DiscernObjectFactory(\n 'PEXSCHEDULINGACTIONS'\n );\n switch (action) {\n case 'check in':\n actionSuccess = await dcof.CheckInAppointment(eventId);\n break;\n case 'check out':\n actionSuccess = await dcof.CheckOutAppointment(eventId);\n break;\n case 'cancel':\n actionSuccess = await dcof.CancelAppointment(eventId);\n break;\n case 'no show':\n actionSuccess = await dcof.NoShowAppointment(eventId);\n break;\n case 'view appt dialog':\n actionSuccess = await dcof.ShowView(eventId);\n break;\n case 'view appt history':\n actionSuccess = await dcof.ShowHistoryView(eventId);\n break;\n default:\n throw new Error('Invalid appointment action');\n }\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n inPowerChart = false;\n } else {\n throw e;\n }\n }\n return {\n success: actionSuccess === 1,\n inPowerChart: inPowerChart,\n };\n}\n","import { ApplinkReturn } from '.';\nimport { outsideOfPowerChartError } from './utils';\n\nexport type OpenApplicationMode =\n | 'by solution name'\n | 'by application object'\n | 'by file'\n | 'by url'\n | 'by executable';\n\nexport type OpenApplicationArgument = {\n argument: string;\n value: string | number;\n quickOpen?: boolean;\n};\n\n/**\n * Attempts to open an application in the PowerChart application.\n * @param {OpenApplicationMode} mode - The mode in which to open the application. Valid options include:\n * - 'by solution name' - Open an application by the name of the solution.\n * - 'by application object' - Open an application by the name of the application object.\n * - 'by file' - Open an application by the name of the file.\n * - 'by url' - Open an we website in your **local** browser. This requires that your Citrix instance\n * be setup to handle server-to-client redirection.\n * - 'by executable' - Open an application by the name of the executable.\n * @param {string} target - The target of the application to open. The target can be\n * a solution name, application object name, file name, URL, or executable name.\n * @param {Array<OpenApplicationArgument>} [args] - An array of arguments to pass to the application.\n * Arguments contain the properties: `argument`, `value`, and `quickOpen`. The `argument` property is the name of the\n * argument to pass to the application. The `value` property is the value of the argument to pass to the\n * application. The `quickOpen` property is a boolean indicating whether the application should attempt to open\n * a dialog box, such as the Add Order dialog box in the Orders applet, if supported. Not all applications support\n * this feature and it will be ignored if the application does not support it. The default value is `false`.\n * @resolves `AppLinkReturn`\n * @throws If the mode is 'by solution name' or 'by application object' and the `args` parameter is undefined.\n * @throws If the mode is unsupported (invalid).\n */\nexport async function openApplicationAsync(\n mode: OpenApplicationMode,\n target: string,\n args?: Array<OpenApplicationArgument>\n): Promise<ApplinkReturn> {\n const retVal: ApplinkReturn = {\n inPowerChart: true,\n eventString: '',\n badInput: false,\n };\n\n if (mode === 'by solution name' && !args) {\n throw new Error(\n \"openApplicationAsync: 'by solution name' mode requires arguments\"\n );\n }\n if (mode === 'by application object' && !args) {\n throw new Error(\n \"openApplicationAsync: 'by application object' mode requires arguments\"\n );\n }\n const argString = generateOpenApplicationArgumentString(args || []);\n\n const modeValue = modeMap.get(mode);\n\n if (modeValue === undefined) {\n throw new Error('openApplicationAsync: invalid mode');\n }\n\n retVal.eventString = argString;\n\n try {\n const response = await window.APPLINK(modeValue, target, argString);\n\n retVal.badInput = response === null ? true : false;\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retVal.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retVal;\n}\n\n/**\n * Generates an argument string for the `APPLINK` function using structured data.\n *\n * @param args An array of arguments to pass to the application.\n *\n * @returns A string representing the arguments to pass to the `APPLINK` function.\n */\nexport function generateOpenApplicationArgumentString(\n args: Array<OpenApplicationArgument>\n) {\n return args\n .map(({ argument: arg, value, quickOpen: qo }) => {\n const isOrgLevel = /organizertab/i.test(arg);\n const isTab = /firsttab/i.test(arg) || /organizertab/i.test(arg);\n const quickOpen = qo;\n const quickOpenStr = quickOpen && isTab && !isOrgLevel ? '+' : '';\n const surroundStr = isTab ? '^' : '';\n\n return `/${arg.toUpperCase()}=${surroundStr}${value}${quickOpenStr}${surroundStr}`;\n })\n .join(' ');\n}\n\nconst modeMap = new Map<OpenApplicationMode, 0 | 1 | 100>();\nmodeMap.set('by solution name', 0);\nmodeMap.set('by application object', 1);\nmodeMap.set('by file', 100);\nmodeMap.set('by url', 100);\nmodeMap.set('by executable', 100);\n","import { ApplinkReturn } from '.';\n\nimport {\n OpenApplicationArgument,\n openApplicationAsync,\n} from './openApplicationAsync';\n\n/**\n * Attempts to open a tab with the name given to the `tab` variable in at the chart organizer\n * level. Uses the function from this library `openApplicationAsync`.\n * @param tab The string which represents the tab to open\n * (case insensitive). Navigation will be made to the first\n * upper-level tab in the chart that that matches the `tab` string\n * If no match is found, then sub-tab names will be searched and\n * navigation made to the first sub-tab that matches\n * the `tab` string. If no matches are found, no navigation will occur.\n * @resolves an `ApplinkReturn`\n */\nexport async function openOrganizerTabAsync(\n tab: string\n): Promise<ApplinkReturn> {\n const args: Array<OpenApplicationArgument> = [\n {\n argument: 'ORGANIZERTAB',\n value: tab,\n },\n ];\n return await openApplicationAsync('by executable', 'Powerchart.exe', args);\n}\n","import { ApplinkReturn } from '.';\nimport {\n OpenApplicationArgument,\n openApplicationAsync,\n} from './openApplicationAsync';\n\n/**\n * Attempts to open a tab with the name given to the `tab` variable in a\n * patients chart given in the context of a given encounter. Uses the function from\n * this library `openApplicationAsync`.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param tab The string which represents the tab to open\n * (case insensitive). Navigation will be made to the first\n * upper-level tab in the chart that that matches the `tab` string\n * If no match is found, then sub-tab names will be searched and\n * navigation made to the first sub-tab that matches\n * the `tab` string. If no matches are found, no navigation will occur.\n * @param quickOpen A boolean indicating whether the application should attempt to open\n * a quick add box, if supported, such as the Add Order dialog box in the Orders applet.\n * Not all applications support this feature and it will be ignored if the application does not support it.\n * The default value is `false`.\n * @resolves `ApplinkReturn`\n */\nexport async function openPatientTabAsync(\n patientId: number,\n encounterId: number,\n tab: string,\n quickOpen?: boolean\n): Promise<ApplinkReturn> {\n const args: Array<OpenApplicationArgument> = [\n {\n argument: 'PERSONID',\n value: patientId,\n },\n {\n argument: 'ENCNTRID',\n value: encounterId,\n },\n {\n argument: 'FIRSTTAB',\n value: tab,\n quickOpen,\n },\n ];\n\n return await openApplicationAsync('by executable', '$APP_APPNAME$', args);\n}\n","import { ApplinkReturn } from '.';\nimport { openApplicationAsync } from './openApplicationAsync';\n\n/**\n * Attempts to open a website in your **local** web browser. This\n * requires that your Citrix instance be setup to handle server-to-client redirection.\n * This is quite useful as a means of accesing websites that may not be accessible\n * from within the Citrix environment, e.g. those in your local network/intranet.\n * Uses the function from this library `openApplicationAsync`.\n * @param url The URL of the website to open\n * @resolves `ApplinkReturn`\n * @throws If the URL does not include 'http://' or 'https://'\n */\nexport async function openWebsiteByUrlAsync(\n url: string\n): Promise<ApplinkReturn> {\n if (\n !url.toLowerCase().includes('http://') &&\n !url.toLowerCase().includes('https://')\n ) {\n throw new Error(\n \"openWebsiteByUrlAsync: URL must include the protocol 'http://' or 'https://'\"\n );\n }\n\n return await openApplicationAsync('by url', url);\n}\n","import { XMLParser } from 'fast-xml-parser';\nimport { MPageEventReturn } from '.';\nimport {\n outsideOfPowerChartError,\n warnAttemptedOrdersOutsideOfPowerChart,\n} from './utils';\nimport { createOrderString } from './utils/createOrderString';\n\nconst launchViewMap = new Map()\n .set('search', 8)\n .set('profile', 16)\n .set('signature', 32);\n\nconst tabsMap = new Map<string, { tab: number; display: number }>()\n .set('orders', { tab: 2, display: 0 })\n .set('power orders', { tab: 2, display: 127 })\n .set('medications', { tab: 3, display: 0 })\n .set('power medications', { tab: 3, display: 127 });\n\n/**\n * @param {Array<number>} nomenclatureIds - (optional) An array of nomenclature ids for the order.\n * @param {number} orderSentenceId - (optional) The order sentence id value for the order to activate.\n * @param {number} orderId - (optional) The order id value for the order to activate.\n * @param {NewOrderOpts}newOrderOpts - (optional) The options for the new order.\n */\nexport type OrderOpts = {\n nomenclatureIds?: Array<number>;\n orderSentenceId?: number;\n interactionCheck?: 'on sign' | 'default';\n origination?: 'satellite' | 'prescription' | 'normal';\n};\n\n/**\n * A type for the options that can be passed to the makeMpageOrder function.\n * @action `activate existing` - Activates an existing order.\n * @action `cancel-discontinue` - Cancels and discontinues an existing order.\\n\n * @action `cancel-reorder` - Cancels and reorders an existing order.\n * @action `clear actions` - Clear actions of a future existing order.\n * @action `convert inpatient` - Converts a prescription order into an inpatient order.\n * @action `convert prescription` - Converts an inpatient order into a prescription.\n * @action `modify` - Modifies an existing future order.\n * @action `new order` - Creates a new order.\n * @action `renew` - Renews an existing non-prescription order.\n * @action `renew prescription` - Renews an existing prescription order.\n * @action `copy existing` - Copy an existing order.\n * @action `resume` - Resumes an existing order.\n * @action `suspend` - Suspends an existing order.\n */\nexport type OrderAction =\n | 'activate existing'\n | 'cancel-discontinue'\n | 'cancel-reorder'\n | 'clear actions'\n | 'convert inpatient'\n | 'convert prescription'\n | 'modify'\n | 'new order'\n | 'renew'\n | 'renew prescription'\n | 'copy existing'\n | 'resume'\n | 'suspend';\n\n/**\n * @action `targetTab` - (optional) Sets the tab to be displayed, with and without power orders.\n * If not provided, will default to `orders`, that is the orders tab with _PowerOrders_ disabled.\n * Any tab with the term _power_ in it will enable both _PowerOrders_ and _PowerPlans_ in _PowerChart_.\n * Also of note, enabling power plans via `power orders` or `power medications` simply means that\n * a user can _search for_ Power Plans. It does not mean that the user can _create_ Power Plans.\n * @action `launchView` - (optional) Sets the view to be displayed.If not provided,\n * will default to `search` view.\n * @action `signSilently` - (optional) Attempts to sign the orders silently. Orders are not signed silently\n * by default. If it's not possible for the system to complete a sileng sign directive,\n * the MOEW will pop up.\n * @action `dryRun` - (optional) If set to true, will not submit the order.\n * @warning Our internal testing suggests there is a _PowerChart_ bug relating to the use of power\n * orders. When making MPAGES_EVENT calls (which we do in this library through `submitOrders`)\n * in series with power orders enabled, the result was that some MPAGES_EVENT calls failed to be invoked.\n * Please keep this in mind when enabling this option. For our own use, we have disabled power orders when\n * using `submitOrders` in such a way that calls are made in series.\n */\nexport type SubmitOrderAsyncOpts = {\n targetTab?: 'orders' | 'power orders' | 'medications' | 'power medications';\n launchView?: 'search' | 'profile' | 'signature';\n signSilently?: boolean;\n dryRun?: boolean;\n};\n\nexport type SubmitOrdersAsyncStatus =\n | 'success'\n | 'cancelled'\n | 'failed'\n | 'invalid data returned'\n | 'xml parse error'\n | 'dry run';\n\nexport type SubmitOrderAsyncReturn = MPageEventReturn & {\n status: SubmitOrdersAsyncStatus;\n response: MpagesEventOrdersReturnXML | null;\n ordersPlaced: Array<{ name: string; oid: number; display: string }> | null;\n rawResponse: string | null;\n};\n\nexport type Order = {\n id: number;\n action: OrderAction;\n opts?: OrderOpts;\n};\n\n/**\n * Submit orders for a patient in a given encounter through the _Cerner PowerChart_ `MPAGES_EVENT` function.\n * By default, the seach for _PowerPlans_ are disabled (potential bug in _PowerChart_), _PowerOrders_ are disabled,\n * the target tab is set to orders, and will launch to the signature view.\n * @param {number} patientId - The identifier for the patient to whom the note belongs.\n * Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this note will be launched. Cerner context variable: VIS_EncntrId.\n * @param orders - The orders to be submitted. Orders are given in the form of a a series of pipe-delimited\n * parameters as specified in the `MPAGES_EVENT` documentation (below). Use the `fluent-cerner-js` library's\n * `` function to simplify building these pipe-delimited order strings.\n * @param opts - (optional) User defined options for the order submission event. The options allow for\n * changing the target tab, the view to be launched, and whether or not the orders should be signed silently.\n * @resolves `SubmitOrderAsyncReturn`\n */\nexport const submitOrdersAsync = async (\n patientId: number,\n encounterId: number,\n orders: Array<Order>,\n opts?: SubmitOrderAsyncOpts\n): Promise<SubmitOrderAsyncReturn> => {\n let { targetTab, launchView, signSilently, dryRun } = opts || {};\n if (!targetTab) targetTab = 'orders';\n if (!launchView) launchView = 'signature';\n const enablePowerPlans =\n targetTab === 'power orders' || targetTab === 'power medications';\n\n const s = orders.map(({ action, id, opts }) =>\n createOrderString(action, id, opts)\n );\n\n let params: Array<string> = [`${patientId}`, `${encounterId}`, s.join('')];\n\n params.push(enablePowerPlans ? '24' : '0');\n\n const { tab, display } = tabsMap.get(targetTab) || { tab: 2, display: 127 };\n params.push(`{${tab}|${display}}`);\n\n params.push(`${launchViewMap.get(launchView) || 32}`);\n\n params.push(`${signSilently ? '1' : '0'}`);\n\n const eventString = params.join('|');\n\n const retVal: SubmitOrderAsyncReturn = {\n eventString,\n inPowerChart: true,\n status: 'success',\n response: null,\n ordersPlaced: null,\n rawResponse: null,\n };\n\n if (dryRun) {\n retVal.status = 'dry run';\n return retVal;\n }\n\n try {\n const response: string = (await window.external.MPAGES_EVENT(\n 'ORDERS',\n eventString\n )) as string;\n\n // Store the raw response on the return value for debugging purposes.\n retVal.rawResponse = response;\n\n // 'null' must be checked for explicitly, as it is a valid response\n // '!response' will return true for null, undefined, and empty string.\n if (response === null) {\n retVal.status = 'failed';\n return retVal;\n }\n\n if (typeof response !== 'string') {\n retVal.status = 'invalid data returned';\n return retVal;\n }\n\n switch (response.trim()) {\n case '':\n retVal.status = 'cancelled';\n break;\n default:\n retVal.status = 'success';\n const parser = new XMLParser();\n try {\n const parsed: MpagesEventOrdersReturnXML = parser.parse(response);\n retVal.response = parsed;\n if (!(parsed.Orders.Order instanceof Array)) {\n parsed.Orders.Order = [parsed.Orders.Order];\n }\n retVal.ordersPlaced = parsed.Orders.Order.map((o) => ({\n name: o.OrderedAsMnemonic,\n oid: o.OrderId,\n display: o.ClinDisplayLine,\n }));\n } catch {\n retVal.status = 'xml parse error';\n }\n\n break;\n }\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retVal.inPowerChart = false;\n retVal.status = 'invalid data returned';\n warnAttemptedOrdersOutsideOfPowerChart(eventString);\n } else {\n throw e;\n }\n }\n return retVal;\n};\n\n// TODO: investigate if we need to export this through the main index.ts file\n/**\n * When an MPAGES_EVENT:ORDER call is made asynchronously, it returns a\n * `Promise` of an XML string. This type is the parsed XML string. Several bits\n * of useful information can be extracted from here, including the order ID\n * and additional details of the newly placed order.\n */\nexport type MpagesEventOrdersReturnXML = {\n Orders: {\n OrderVersion: number;\n Order: Array<MpagesEventReturnOrderXML>;\n };\n};\n\nexport type FieldValueList = {\n ListValues: {\n FieldValue: number;\n FieldDisplayValue: number;\n FieldDtTmValue: string;\n };\n};\n\nexport type Detail = {\n FieldValueList: FieldValueList;\n OeFieldId: number;\n OeFieldMeaning: string;\n OeFieldMeaningId: number;\n ValueRequiredInd: number;\n GroupSeq: number;\n FieldSeq: number;\n ModifiedInd: number;\n DetailAlterFlag: number;\n};\n\nexport type DetailList = {\n STRENGTHDOSE: Detail;\n STRENGTHDOSEUNIT: Detail;\n RXROUTE: Detail;\n DRUGFORM: Detail;\n FREQ: Detail;\n 'SCH.PRN': Detail;\n OTHER: Detail[];\n DURATION: Detail;\n DURATIONUNIT: Detail;\n REQSTARTDTTM: Detail;\n STOPDTTM: Detail;\n STOPTYPE: Detail;\n FREQSCHEDID: Detail;\n ADHOCFREQINSTANCE: Detail;\n NEXTDOSEDTTM: Detail;\n PHARMORDERTYPE: Detail;\n DIFFINMIN: Detail;\n ICD9: Detail;\n INSTREPLACEREQUIREDDETS: Detail;\n REFERENCESTARTDTTM: Detail;\n DetailListCount: number;\n};\n\nexport type CommentList = {\n CommentValues: {\n CommentType: number;\n CommentText: string;\n };\n};\n\nexport type AdHocFreqList = {\n CurrSchedList: string;\n OrigSchedList: string;\n PrevSchedList: string;\n};\n\nexport type DiagnosisList = {\n Diagnosis: {\n DiagnosisId: number;\n NomenclatureId: number;\n SourceVocabularyCd: number;\n SourceIdentifier: string;\n DiagnosisDescription: string;\n DiagnosisRanking: number;\n SearchNomenclatureId: number;\n };\n};\n\nexport type MpagesEventReturnOrderXML = {\n OrderableType: number;\n OrderId: number;\n SynonymId: number;\n ClinCatCd: number;\n CatalogTypeCd: number;\n ActivityTypeCd: number;\n OrderSentenceId: number;\n RxMask: number;\n HnaOrderMnemonic: string;\n OrderedAsMnemonic: string;\n OrderDtTm: string;\n OrigOrderDtTm: string;\n OrderMnemonic: string;\n OrderStatusCd: number;\n OrderStatusDisp: string;\n ClinDisplayLine: string;\n SimpleDisplayLine: string;\n DeptStatusCd: number;\n NeedDoctorCosignInd: number;\n NeedPhysicianValidateInd: number;\n NeedNurseReviewInd: number;\n CommInd: number;\n IngredientInd: number;\n LastUpdtCnt: number;\n MultipleOrdSentInd: number;\n OrderActionId: number;\n TemplateOrderFlag: number;\n TemplateOrderId: number;\n CsFlag: number;\n CsOrderId: number;\n OrderStatus: number;\n SuspendInd: number;\n ResumeInd: number;\n OrderableTypeFlag: number;\n RequiredInd: number;\n ConstantInd: number;\n PrnInd: number;\n FreqTypeFlag: number;\n HybridInd: number;\n NeedRxVerifyFlag: number;\n MedTypeCd: number;\n LastActionSeq: number;\n CommentTypeMask: number;\n StopTypeCd: number;\n ProviderId: number;\n ProviderName: string;\n CommunicationTypeCd: number;\n CurrentStartDtTm: string;\n ProjectedStopDtTm: string;\n TimeZone: number;\n OrigOrdAsFlag: number;\n OrdCommentTemplateId: number;\n DisableOrdCommentInd: number;\n SuspendEffectiveDtTm: string;\n ResumeEffectiveDtTm: string;\n AdditiveCnt: number;\n ClinSigDiluentCnt: number;\n LinkNbr: number;\n LinkTypeFlag: number;\n SuperviseProviderId: number;\n SuperviseProviderName: string;\n BillingProvider: string;\n RelatedOrderObjId: number;\n ActionDtTm: string;\n OeFormatId: number;\n FmtActionCd: number;\n SignedActionCd: number;\n ActionType: number;\n EncntrId: number;\n ProcessMask: number;\n CatalogCd: number;\n ParentId: number;\n ProjectedOrderId: number;\n ProposalAcceptance: string;\n ProposalId: number;\n SignDtTm: string;\n ActionDisplay: string;\n SignedOrderStatusCd: number;\n LastActionPrsnlId: number;\n LastActionPrsnlName: string;\n LastActionDtTm: string;\n DetailList: DetailList;\n ComplianceDetailList: string;\n CommentList: CommentList;\n AdHocFreqList: AdHocFreqList;\n DiagnosisList: DiagnosisList;\n CurrSchedExceptionList: string;\n PrevSchedExceptionList: string;\n OrigSchedExceptionList: string;\n ResponsibleProviderId: number;\n ResponsibleProviderName: string;\n SuspendedDtTm: string;\n RelatedFromOrderId: number;\n OrderRelationTypeCd: number;\n OrderRelationTypeMeaning: string;\n OrderRelationTypeDisplay: string;\n ProposalRejectReasonCd: number;\n ProposalRejectReasonDisplay: string;\n ProposalFreetextRejectReason: string;\n};\n","import { OrderAction, OrderOpts } from '../submitOrdersAsync';\n\n/**\n * A type for the options that can be passed to the `makeMpageOrder` function.\n * @action `launch moew` - Launches the MOEW.\n * @action `activate existing` - Activates an existing order.\n * @action `cancel-discontinue` - Cancels and discontinues an existing order.\\n\n * @action `cancel-reorder` - Cancels and reorders an existing order.\n * @action `clear actions` - Clear actions of a future existing order.\n * @action `convert inpatient` - Converts a prescription order into an inpatient order.\n * @action `convert prescription` - Converts an inpatient order into a prescription.\n * @action `modify` - Modifies an existing future order.\n * @action `new order` - Creates a new order.\n * @action `renew` - Renews an existing non-prescription order.\n * @action `renew prescription` - Renews an existing prescription order.\n * @action `copy existing` - Copy an existing order.\n * @action `resume` - Resumes an existing order.\n * @action `suspend` - Suspends an existing order.\n *\n * @documentation [MPAGES_EVENT - ORDER](https://wiki.cerner.com/display/public/MPDEVWIKI/MPAGES_EVENT+-+ORDERS)\n */\ntype CompleteOrderAction =\n | 'launch moew'\n | 'activate existing'\n | 'cancel-discontinue'\n | 'cancel-reorder'\n | 'clear actions'\n | 'convert inpatient'\n | 'convert prescription'\n | 'modify'\n | 'new order'\n | 'renew'\n | 'renew prescription'\n | 'copy existing'\n | 'resume'\n | 'suspend';\n\nconst _createOrderString = (\n action: CompleteOrderAction,\n id?: number,\n opts?: OrderOpts\n): string => {\n const { orderSentenceId, nomenclatureIds, origination, interactionCheck } =\n opts || {};\n\n let params: Array<string> = [orderActionMap.get(action)];\n\n const nids = nomenclatureIds || [];\n\n switch (action) {\n case 'launch moew':\n params = params.concat(['0', '0', '0', '0', '0']);\n break;\n case 'new order':\n if (!id)\n throw new Error(\n `id (as synonym ID) is required for the '${action}' action`\n );\n params = params.concat([\n `${id}`,\n `${originationMap.get(origination) || 0}`,\n `${orderSentenceId || 0}`,\n nids.length > 1 ? `[${nids.join('|')}]` : `${nids[0] || 0}`,\n `${interactionMap.get(interactionCheck) || 0}`,\n ]);\n break;\n default:\n if (!id)\n throw new Error(\n `id (as the existing order ID) is required for the '${action}' action`\n );\n params = params.concat([`${id}`]);\n break;\n }\n\n return `{${params.join('|')}}`;\n};\n\nconst orderActionMap = new Map()\n .set('launch moew', 'ORDER')\n .set('activate existing', 'ACTIVATE')\n .set('cancel-discontinue', 'CANCEL DC')\n .set('cancel-reorder', 'CANCEL REORD')\n .set('clear actions', 'CLEAR')\n .set('convert inpatient', 'CONVERT_INPAT')\n .set('convert prescription', 'CONVERT_RX')\n .set('modify', 'MODIFY')\n .set('new order', 'ORDER')\n .set('renew', 'RENEW')\n .set('renew prescription', 'RENEW_RX')\n .set('copy existing', 'REPEAT')\n .set('resume', 'RESUME')\n .set('suspend', 'SUSPEND');\n\nconst originationMap = new Map()\n .set('satellite', '5')\n .set('prescription', '1')\n .set('normal', '0');\n\nconst interactionMap = new Map().set('on sign', '1').set('default', '0');\n\n/**\n * A helper function consumed by `submitOrdersAsync` function. Creates a new pipe-delimited\n * order string consumed by an `MPAGES_EVENT` call with the `ORDERS` directive.\n * @since 0.10.0-alpha.0\n * @param {OrderAction} action - The action to be performed on the order.\n * @param {number} id - The id of the order. This is the synonym id for new orders and the order id for existing orders.\n * @param {OrderOpts} opts - (optional) The options for the order.\n * @returns {string} - A pipe-delimited string which can be integrated into an MPage Event for one or more orders.\n * @throws {Error} - If the action is not a valid order action.\n * @documentation [MPAGES_EVENT - ORDER](https://wiki.cerner.com/display/public/MPDEVWIKI/MPAGES_EVENT+-+ORDERS)\n */\nexport const createOrderString = (\n action: OrderAction,\n id: number,\n opts?: OrderOpts\n) => _createOrderString(action, id, opts);\n\n/**\n * A constant string for the `launch moew` action.\n */\nexport const LAUNCH_MOEW_ORDER_STRING = _createOrderString('launch moew');\n","import { PowerOrdersMOEWFlags } from '../submitPowerOrdersAsync';\n\ntype CernerMOEWFlags =\n | 'add rx to filter'\n | 'allow only inpatient and outpatient orders'\n | 'allow power plan doc'\n | 'allow power plans'\n | 'allow regimen'\n | 'customize meds'\n | 'customize order'\n | 'disable auto search'\n | 'disallow EOL'\n | 'documented meds only'\n | 'hide demographics'\n | 'hide med rec'\n | 'read only'\n | 'show diag and probs'\n | 'show list details'\n | 'show nav tree'\n | 'show order profile'\n | 'show orders search'\n | 'show refresh and print buttons'\n | 'show related res'\n | 'show scratchpad'\n | 'sign later';\n\n/**\n * A utility function designed to calculate the bitmask for the input paramaters to be used with PowerChart's CreateMOEW() function.\n * @param {PowerOrdersMOEWOpts} inputOpts - An object containing the type of orders to be placed (medications or order) as well as an (optional)\n * array of strings defining the MOEW behavior/appearance. If not provided, the values will default to the the order setting as well as recommended\n * values for the MOEW to be configured with PowerPlan support. If any values are provided, those will be the only values used.\n * @returns The bitmask numbers (dwCustomizeFlag, dwTabFlag, and dwTabDisplayOptionsFlag) to be used with PowerChart's CreateMOEW() function.\n */\nexport const calculateMOEWBitmask = (\n targetTab: 'orders tab' | 'medications tab',\n inputFlags: Array<PowerOrdersMOEWFlags>\n): {\n dwCustomizeFlag: number;\n dwTabFlag: number;\n dwTabDisplayOptionsFlag: number;\n} => {\n // Initialize and calculate the CreateMOEW() parameters\n let dwCustomizeFlag: number = 0;\n let dwTabFlag: number = 0;\n let dwTabDisplayOptionsFlag: number = 0;\n\n // Calculate the dwTabFlag parameter\n if (targetTab === 'orders tab') {\n dwTabFlag = 2;\n }\n\n if (targetTab === 'medications tab') {\n dwTabFlag = 3;\n }\n\n // If no MOEW options are provided, use recommended default settings\n const defaultOpts: Array<PowerOrdersMOEWFlags> = [\n 'show refresh and print buttons',\n 'allow power plan doc',\n 'allow power plans',\n 'show list details',\n 'show scratchpad',\n 'show order profile',\n 'show orders search',\n 'show related res',\n 'show diag and probs',\n 'show nav tree',\n 'show demographics',\n 'show med rec',\n ];\n\n const userFlags =\n !inputFlags || inputFlags.length === 0 ? defaultOpts : inputFlags;\n\n //Go through the flags provided by the user and convert them to Cerner analogs\n //At time of last edit:\n // - absence of `show demographics` causes `hide demographics` to be added to the bitmask calculation\n // - absence of `show med rec` causes `hide med rec` to be added to the bitmask calculation\n\n const cernerFlags: Array<CernerMOEWFlags> = [];\n userFlags.forEach((flag: PowerOrdersMOEWFlags) => {\n if (flag === 'show demographics') {\n return;\n }\n if (flag === 'show med rec') {\n return;\n }\n return cernerFlags.push(flag as CernerMOEWFlags);\n });\n if (!userFlags.includes('show demographics')) {\n cernerFlags.push('hide demographics');\n }\n if (!userFlags.includes('show med rec')) {\n cernerFlags.push('hide med rec');\n }\n\n // Calculate the other two parameters (dwCustomizeFlag and dwTabDisplayOptionsFlag) that are also ultimately needed for CreateMOEW()\n cernerFlags.forEach((option) => {\n switch (option) {\n // Calculate the dwCustomizeFlagParamater\n case 'sign later':\n dwCustomizeFlag += 1;\n break;\n\n case 'read only':\n dwCustomizeFlag += 4;\n break;\n\n case 'allow power plans':\n dwCustomizeFlag += 8;\n break;\n\n case 'allow power plan doc':\n dwCustomizeFlag += 16;\n break;\n\n case 'allow only inpatient and outpatient orders':\n dwCustomizeFlag += 32;\n break;\n\n case 'show refresh and print buttons':\n dwCustomizeFlag += 128;\n break;\n\n case 'documented meds only':\n dwCustomizeFlag += 256;\n break;\n\n case 'hide med rec':\n dwCustomizeFlag += 512;\n break;\n\n case 'disallow EOL':\n dwCustomizeFlag += 1024;\n break;\n\n case 'hide demographics':\n dwCustomizeFlag += 2048;\n break;\n\n case 'add rx to filter':\n dwCustomizeFlag += 4096;\n break;\n\n case 'disable auto search':\n dwCustomizeFlag += 8192;\n break;\n\n case 'allow regimen':\n dwCustomizeFlag += 16384;\n break;\n\n // Calculate the dwTabDisplayOptionsFlag parameter\n case 'show nav tree':\n dwTabDisplayOptionsFlag += 1;\n break;\n\n case 'show diag and probs':\n dwTabDisplayOptionsFlag += 2;\n break;\n\n case 'show related res':\n dwTabDisplayOptionsFlag += 4;\n break;\n\n case 'show orders search':\n dwTabDisplayOptionsFlag += 8;\n break;\n\n case 'show order profile':\n dwTabDisplayOptionsFlag += 16;\n break;\n\n case 'show scratchpad':\n dwTabDisplayOptionsFlag += 32;\n break;\n\n case 'show list details':\n dwTabDisplayOptionsFlag += 64;\n break;\n }\n });\n\n return {\n dwCustomizeFlag,\n dwTabFlag,\n dwTabDisplayOptionsFlag,\n };\n};\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\nimport { StandaloneOrder } from '../submitPowerOrdersAsync';\n\n/**\n * Attempts to add new standalone orders to the scratchpad\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW\n * @param {Array<StandaloneOrder>} standaloneOrders - An array of objects containg order synonym Ids, order origination flags and, optionally, sentence Ids, for standalone orders to be placed\n * @param {boolean} interactionChecking - A boolean value indicating whether or not order interaction checking should be performed (strongly recommended to be set to true)\n * @resolves `PowerChartReturn & { result: AddNewOrdersToScratchpadResult }`\n * @throws `Error` if the array provided is empty\n */\nexport async function addNewOrdersToScratchpadAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number,\n standaloneOrders: Array<StandaloneOrder>,\n interactionChecking: boolean\n): Promise<\n PowerChartReturn & {\n result: AddNewOrdersToScratchpadResult;\n }\n> {\n //Prepare the default return data\n let retData: PowerChartReturn & {\n result: AddNewOrdersToScratchpadResult;\n } = {\n inPowerChart: true,\n result: 'successfully added',\n };\n\n // Check for to make sure the array of orders provided is not empty\n if (standaloneOrders.length < 1) {\n throw new RangeError(\n 'There should be at least one standalone order provided.'\n );\n }\n\n // Convert the standalone orders provided into the required XML string\n let standaloneOrdersXML: string = '';\n\n standaloneOrders.forEach((standaloneOrder) => {\n standaloneOrdersXML += `<Order><EOrderOriginationFlag>${\n standaloneOrder.origination === 'inpatient order' ? 0 : 1\n }</EOrderOriginationFlag><SynonymId>${standaloneOrder.synonymId}</SynonymId>\n <OrderSentenceId>${\n standaloneOrder.sentenceId ? standaloneOrder.sentenceId : ''\n }</OrderSentenceId></Order>`;\n });\n\n //Add <Orders> to beginning & end of the Standalone Order XML\n standaloneOrdersXML = '<Orders>' + standaloneOrdersXML;\n standaloneOrdersXML += '</Orders>';\n\n //Remove newlines and spaces\n standaloneOrdersXML = standaloneOrdersXML.replace(/[\\r\\n\\s]/g, '');\n\n try {\n const response = await dcof.AddNewOrdersToScratchpad(\n moewHandle,\n standaloneOrdersXML,\n interactionChecking\n );\n\n // Set the `result value` equal to a string describing the number that PowerChart returns\n switch (response) {\n case 0:\n retData.result = 'successfully added';\n break;\n\n case 1:\n retData.result = 'added and signed';\n break;\n\n case 2:\n retData.result = 'cancelled by user';\n break;\n\n case 3:\n retData.result = 'add failed';\n break;\n }\n } catch (e) {\n // If outside of PowerChart, set the output to reflect that\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.result = 'add failed';\n } else {\n // If some other error was encountered, throw that error\n throw e;\n }\n }\n\n // Return the retData object when complete\n return retData;\n}\n\nexport type AddNewOrdersToScratchpadResult =\n | 'successfully added'\n | 'added and signed'\n | 'cancelled by user'\n | 'add failed';\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\nimport { PowerPlanOrder } from '../submitPowerOrdersAsync';\n\n/**\n * Attempts to add a PowerPlan and creates PowerPlan objects from the pathway catalog Ids. CreateMOEW() must be called first.\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @param {Array<PowerPlanOrder>} powerPlanOrders - An array of objects containg catalog Ids and, optionally,\n * personalized plan Ids and diagnosis code Ids, for PowerPlan orders to be placed.\n * @resolves `PowerChartReturn & { powerPlansAdded: boolean }`\n * @throws `Error` if no orders are provided\n */\n\nexport async function addPowerPlanWithDetailsAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number,\n powerPlanOrders: Array<PowerPlanOrder>\n): Promise<\n PowerChartReturn & {\n powerPlansAdded: boolean;\n }\n> {\n //Prepare the default return data\n let retData: PowerChartReturn & {\n powerPlansAdded: boolean;\n } = {\n inPowerChart: true,\n powerPlansAdded: true,\n };\n\n // Check for to make sure the array of orders provided is not empty\n if (powerPlanOrders.length < 1) {\n throw new RangeError(\n 'There should be at least one PowerPlan order provided.'\n );\n }\n\n // Convert the PowerPlan orders provided into the required XML string\n let powerPlanOrdersXML: string = '';\n\n powerPlanOrders.forEach(\n ({\n pathwayCatalogId: cid,\n personalizedPlanId: pid,\n diagnosisIds: dids,\n }) => {\n powerPlanOrdersXML += `<Plan><PathwayCatalogId>${cid}</PathwayCatalogId><PersonalizedPlanId>${\n pid ? pid : ''\n }</PersonalizedPlanId><Diagnoses>\n ${\n dids\n ? dids.map((diagnosisSynonymID) => {\n return '<DiagnosisId>' + diagnosisSynonymID + '</DiagnosisId>';\n })\n : ''\n }\n </Diagnoses></Plan>`;\n }\n );\n\n // Add <Plans> to beginning & end of PowerPlan XML\n powerPlanOrdersXML = '<Plans>' + powerPlanOrdersXML;\n powerPlanOrdersXML += '</Plans>';\n\n //Remove newlines and spaces\n powerPlanOrdersXML = powerPlanOrdersXML.replace(/[\\r\\n\\s]/g, '');\n\n try {\n const response = await dcof.AddPowerPlanWithDetails(\n moewHandle,\n powerPlanOrdersXML\n );\n\n // Set the `powerPlanAdded` boolean to be true if the orders were added, and false otherwise\n retData.powerPlansAdded = response === 0 ? false : true;\n } catch (e) {\n // If outside of PowerChart, set the output to reflect that\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.powerPlansAdded = false;\n } else {\n // If some other error was encountered, throw that error\n throw e;\n }\n }\n\n // Return the retData object when complete\n return retData;\n}\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Creates an MOEW handle.\n * @param {DiscernObjectFactoryReturn} dcof - the to reference the DisernObjectFactory object\n * @param {number} personId - the patient Id\n * @param {number} encounterId - the encounter Id in which orders would be placed\n * @param {number} dwCustomizeFlag - the bitmask that determines available MOEW options\n * @param {number} dwTabFlag - the bitmask identifying the list being customized\n * @param {number} dwTabDisplayOptionsFlag - the bitmask specificying which components display on the MOEW\n * @resolves `PowerChartReturn & { moewHandle: number | null }`\n */\n\nexport async function createMOEWAsync(\n dcof: DiscernObjectFactoryReturn,\n personId: number,\n encounterId: number,\n dwCustomizeFlag: number,\n dwTabFlag: number,\n dwTabDisplayOptionsFlag: number\n): Promise<\n PowerChartReturn & {\n moewHandle: number | null;\n }\n> {\n let retData: PowerChartReturn & {\n moewHandle: number | null;\n } = {\n inPowerChart: true,\n moewHandle: null,\n };\n\n //Use the DCOF to call CreateMOEW()\n try {\n const response = await dcof.CreateMOEW(\n personId,\n encounterId,\n dwCustomizeFlag,\n dwTabFlag,\n dwTabDisplayOptionsFlag\n );\n\n //Set the moewHandle equal to `null` if an invalid handle is returned, and set it to the actual value otherwise\n retData.moewHandle = response === 0 ? null : response;\n } catch (e) {\n //If outside of PowerChart, set the output to reflect that\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.moewHandle = null;\n } else {\n //If some other error was encountered, throw that error\n throw e;\n }\n }\n\n // Return the retData object when complete\n return retData;\n}\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Destroys the modal order entry window (MOEW).\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @description The value returned by DestroyMOEW() is not used and is not believed to\n * be meaningful, but is logged to the console for development purposes.\n * @resolves `PowerChartReturn`\n */\n\nexport async function destroyMOEWAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number\n): Promise<PowerChartReturn> {\n let retData: PowerChartReturn = {\n inPowerChart: true,\n };\n\n try {\n const response = await dcof.DestroyMOEW(moewHandle);\n\n console.log('Response from DestroyMOEW() is: ', response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Displays the modal order entry window (MOEW).\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @resolves `PowerChartReturn & { signed: boolean }`\n * @returns a `Promise` which resolves to a PowerChartReturn and an integer\n * indicating if orders were signed, 1, or 0 otherwise, converted to a Boolean.\n * @throws `Error` if an unexpected error occurs.\n */\n\nexport async function displayMOEWAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number\n): Promise<\n PowerChartReturn & {\n signed: boolean;\n }\n> {\n let retData: PowerChartReturn & {\n signed: boolean;\n } = {\n inPowerChart: true,\n signed: false,\n };\n\n try {\n const response = await dcof.DisplayMOEW(moewHandle);\n\n retData.signed = Boolean(response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { XMLParser } from 'fast-xml-parser';\nimport { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Retrieves the orders placed during the previous MOEW invocation.\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @resolves `DiscernObjectFactoryReturn` which is a complex object any any given user should\n * take the opportunity to review it before using it. Of note, the most useful properties will be\n * `inPowerChart`, which is a boolean indicating whether the user is currently in PowerChart, and\n * `ordersPlaced`, and `status`.\n */\n\nexport async function getOrdersPlacedAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number\n): Promise<GetXMLReturn> {\n let retData: GetXMLReturn = {\n inPowerChart: true,\n ordersPlaced: [],\n parsedXML: null,\n rawXML: '',\n status: 'success',\n };\n\n try {\n // Set the return object XML equal to the return XML from PowerChart\n retData.rawXML = await dcof.GetXMLOrdersMOEW(moewHandle);\n\n //Check to see if the response type was not a string (should always either be \"\" or an XML string)\n if (typeof retData.rawXML !== 'string') {\n retData.status = 'invalid data returned';\n return retData;\n }\n\n //Check to see if no orders were placed or if invalid parameters were provided\n if (retData.rawXML.trim() === '') {\n retData.status = 'cancelled, failed, or invalid parameters provided';\n return retData;\n }\n\n //Assuming we have a valid (non-empty) string at this point, attempt to parse out its XML and populate `retData.ordersPlaced`\n const parser = new XMLParser();\n try {\n const parsed: OrdersReturnXML = parser.parse(retData.rawXML);\n retData.parsedXML = parsed;\n if (!(parsed.Orders.Order instanceof Array)) {\n parsed.Orders.Order = [parsed.Orders.Order];\n }\n retData.ordersPlaced = parsed.Orders.Order.map((o) => ({\n name: o.OrderedAsMnemonic,\n oid: o.OrderId,\n display: o.ClinDisplayLine,\n }));\n } catch {\n //A parsing error indicates the string isn't formatted as epxected\n retData.status = 'xml parse error';\n }\n } catch (e) {\n //If outside of PowerChart, set the output to reflect that\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.parsedXML = null;\n retData.ordersPlaced = [];\n retData.rawXML = '';\n retData.status = 'dry run';\n } else {\n // If some other error was encountered, throw that error\n throw e;\n }\n }\n\n // Return the retData object when complete\n return retData;\n}\n\nexport type SubmitPowerOrdersStatus =\n | 'success'\n | 'cancelled, failed, or invalid parameters provided'\n | 'invalid data returned'\n | 'xml parse error'\n | 'dry run';\n\nexport type GetXMLReturn = PowerChartReturn & {\n ordersPlaced: Array<{ name: string; oid: number; display: string }> | null;\n parsedXML: OrdersReturnXML | null;\n rawXML: string;\n status: SubmitPowerOrdersStatus;\n};\n\n// Return type to contain the orders placed and associated XML data\nexport type OrdersReturnXML = {\n Orders: {\n OrderVersion: number;\n Order: Array<PowerOrderReturnOrderXML>;\n };\n};\n\n// Return type of XML data\nexport type PowerOrderReturnOrderXML = {\n OrderableType: number;\n OrderId: number;\n SynonymId: number;\n ClinCatCd: number;\n CatalogTypeCd: number;\n ActivityTypeCd: number;\n OrderSentenceId: number;\n RxMask: number;\n HnaOrderMnemonic: string;\n OrderedAsMnemonic: string;\n OrderDtTm: string;\n OrigOrderDtTm: string;\n OrderMnemonic: string;\n OrderStatusCd: number;\n OrderStatusDisp: string;\n ClinDisplayLine: string;\n SimpleDisplayLine: string;\n DeptStatusCd: number;\n NeedDoctorCosignInd: number;\n NeedPhysicianValidateInd: number;\n NeedNurseReviewInd: number;\n CommInd: number;\n IngredientInd: number;\n LastUpdtCnt: number;\n MultipleOrdSentInd: number;\n OrderActionId: number;\n TemplateOrderFlag: number;\n TemplateOrderId: number;\n CsFlag: number;\n CsOrderId: number;\n OrderStatus: number;\n SuspendInd: number;\n ResumeInd: number;\n OrderableTypeFlag: number;\n RequiredInd: number;\n ConstantInd: number;\n PrnInd: number;\n FreqTypeFlag: number;\n HybridInd: number;\n NeedRxVerifyFlag: number;\n MedTypeCd: number;\n LastActionSeq: number;\n CommentTypeMask: number;\n StopTypeCd: number;\n ProviderId: number;\n ProviderName: string;\n CommunicationTypeCd: number;\n CurrentStartDtTm: string;\n ProjectedStopDtTm: string;\n TimeZone: number;\n OrigOrdAsFlag: number;\n OrdCommentTemplateId: number;\n DisableOrdCommentInd: number;\n SuspendEffectiveDtTm: string;\n ResumeEffectiveDtTm: string;\n AdditiveCnt: number;\n ClinSigDiluentCnt: number;\n LinkNbr: number;\n LinkTypeFlag: number;\n SuperviseProviderId: number;\n SuperviseProviderName: string;\n BillingProvider: string;\n RelatedOrderObjId: number;\n ActionDtTm: string;\n OeFormatId: number;\n FmtActionCd: number;\n SignedActionCd: number;\n ActionType: number;\n EncntrId: number;\n ProcessMask: number;\n CatalogCd: number;\n ParentId: number;\n ProjectedOrderId: number;\n ProposalAcceptance: string;\n ProposalId: number;\n SignDtTm: string;\n ActionDisplay: string;\n SignedOrderStatusCd: number;\n LastActionPrsnlId: number;\n LastActionPrsnlName: string;\n LastActionDtTm: string;\n DetailList: DetailList;\n ComplianceDetailList: string;\n CommentList: CommentList;\n AdHocFreqList: AdHocFreqList;\n DiagnosisList: DiagnosisList;\n CurrSchedExceptionList: string;\n PrevSchedExceptionList: string;\n OrigSchedExceptionList: string;\n ResponsibleProviderId: number;\n ResponsibleProviderName: string;\n SuspendedDtTm: string;\n RelatedFromOrderId: number;\n OrderRelationTypeCd: number;\n OrderRelationTypeMeaning: string;\n OrderRelationTypeDisplay: string;\n ProposalRejectReasonCd: number;\n ProposalRejectReasonDisplay: string;\n ProposalFreetextRejectReason: string;\n};\n\n//XML data return subtype\nexport type FieldValueList = {\n ListValues: {\n FieldValue: number;\n FieldDisplayValue: number;\n FieldDtTmValue: string;\n };\n};\n\n//XML data return subtype\nexport type Detail = {\n FieldValueList: FieldValueList;\n OeFieldId: number;\n OeFieldMeaning: string;\n OeFieldMeaningId: number;\n ValueRequiredInd: number;\n GroupSeq: number;\n FieldSeq: number;\n ModifiedInd: number;\n DetailAlterFlag: number;\n};\n\n//XML data return subtype\nexport type DetailList = {\n STRENGTHDOSE: Detail;\n STRENGTHDOSEUNIT: Detail;\n RXROUTE: Detail;\n DRUGFORM: Detail;\n FREQ: Detail;\n 'SCH.PRN': Detail;\n OTHER: Detail[];\n DURATION: Detail;\n DURATIONUNIT: Detail;\n REQSTARTDTTM: Detail;\n STOPDTTM: Detail;\n STOPTYPE: Detail;\n FREQSCHEDID: Detail;\n ADHOCFREQINSTANCE: Detail;\n NEXTDOSEDTTM: Detail;\n PHARMORDERTYPE: Detail;\n DIFFINMIN: Detail;\n ICD9: Detail;\n INSTREPLACEREQUIREDDETS: Detail;\n REFERENCESTARTDTTM: Detail;\n DetailListCount: number;\n};\n\n//XML data return subtype\nexport type CommentList = {\n CommentValues: {\n CommentType: number;\n CommentText: string;\n };\n};\n\n//XML data return subtype\nexport type AdHocFreqList = {\n CurrSchedList: string;\n OrigSchedList: string;\n PrevSchedList: string;\n};\n\n//XML data return subtype\nexport type DiagnosisList = {\n Diagnosis: {\n DiagnosisId: number;\n NomenclatureId: number;\n SourceVocabularyCd: number;\n SourceIdentifier: string;\n DiagnosisDescription: string;\n DiagnosisRanking: number;\n SearchNomenclatureId: number;\n };\n};\n","import { PowerChartReturn } from '..';\nimport { outsideOfPowerChartError } from '.';\n\n/**\n * Attempts to silently sign orders on the scratchpad. If the orders cannot be signed silently, will display the MOEW.\n * @param {DiscernObjectFactoryReturn} dcof - the reference to the DisernObjectFactory object\n * @param {number} moewHandle - the handle to the MOEW.\n * @resolves `PowerChartReturn`\n * @description The value returned by SignOrders() is not used and is not believed to be meaningful, but is logged\n * to the console for development purposes. In our testing, a 0 is returned if an improper MOEW handle is provided, but a 1 is returned otherwise\n * (any time SignOrders() is called) but this is not yet fully confirmed. If it is confirmed,\n * the resolved object will be updated to reflect this.\n */\n\nexport async function signOrdersAsync(\n dcof: DiscernObjectFactoryReturn,\n moewHandle: number\n): Promise<PowerChartReturn> {\n let retData: PowerChartReturn = {\n inPowerChart: true,\n };\n\n try {\n const response = await dcof.SignOrders(moewHandle);\n // TODO: Remove this console.log() statement when development is complete\n console.log('Response from SignMOEW() is: ', response);\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n } else {\n throw e;\n }\n }\n return retData;\n}\n","import { outsideOfPowerChartError } from './utils';\nimport { calculateMOEWBitmask } from './utils/calculateMOEWBitmask';\nimport { addNewOrdersToScratchpadAsync } from './utils/addNewOrdersToScratchPadAsync';\nimport { addPowerPlanWithDetailsAsync } from './utils/addPowerPlanWithDetailsAsync';\nimport { createMOEWAsync } from './utils/createMOEWAsync';\nimport { destroyMOEWAsync } from './utils/destroyMOEWAsync';\nimport { displayMOEWAsync } from './utils/displayMOEWAsync';\nimport {\n SubmitPowerOrdersStatus,\n getOrdersPlacedAsync,\n} from './utils/getOrdersPlacedAsync';\nimport { signOrdersAsync } from './utils/signOrdersAsync';\nimport { PowerChartReturn } from '.';\n\n/**\n * PowerOrdersMOEWFlags is a type which represents an optional array of flags to customize the MOEW. If not provided, the values will default to the recommended values for the MOEW\n * with PowerPlan support. If any values are provided, those will be the only values used by submitPowerOrdersAsync().\n * @action `add rx to filter` - Turns the prescription indicator on the default filter.\n * @action `allow only inpatient and outpatient orders` - Only inpatient and ambulatory venue ordering will be allowed.\n * @action `allow power plan doc` - Enables PowerPlan documentation.\n * @action `allow power plans` - Allows PowerPlans to be used from the MOEW.\n * @action `allow regimen` - Ensures that regimens are enabled.\n * @action `disable auto search` - Disables auto search.\n * @action `disallow EOL` - This option forces edit-on-line mode (which allows multi-selection) to be disabled.\n * @action `documented meds only` - Restricts the MOEW to only perform actions on documented medications.\n * @action `show demographics` - Displays the demographics bar in the MOEW.\n * @action `show med rec` - Displays medication reconiciliation controls in the MOEW.\n * @action `read only` - The MEOW will be read only.\n * @action `show diag and probs` - Configures the MOEW such that the diagnoses/problem control menu is displayed.\n * @action `show list details` - Configures the MOEW such that the order detail control is enabled. Note that this is required if adding any orders (if parameters are provided).\n * @action `show nav tree` - Configures the MOEW such that the navigator tree control is displayed.\n * @action `show order profile` - Configures the MOEW such that the order profile is displayed.\n * @action `show orders search` - Configures the MOEW such that the order search menu is displayed. Note that this is required if adding any orders (if parameters are provided).\n * @action `show refresh and print buttons` - Will show the refresh and print buttons in the MOEW.\n * @action `show related res` - Configures the MOEW such that the related results control is displayed.\n * @action `show scratchpad` - Configures the MOEW such that the scratchpad is displayed. Note that this is required if adding any orders (if parameters are provided).\n * @action `sign later` - Sign later functionality will be allowed from the MOEW.\n **/\nexport type PowerOrdersMOEWFlags =\n | 'add rx to filter'\n | 'allow only inpatient and outpatient orders'\n | 'allow power plan doc'\n | 'allow power plans'\n | 'allow regimen'\n | 'disable auto search'\n | 'disallow EOL'\n | 'documented meds only'\n | 'read only'\n | 'show demographics' // Cerner analog: 'hide demographics'\n | 'show diag and probs'\n | 'show list details'\n | 'show med rec' // Cerner analog: 'hide med rec'\n | 'show nav tree'\n | 'show order profile'\n | 'show orders search'\n | 'show refresh and print buttons'\n | 'show related res'\n | 'show scratchpad'\n | 'sign later';\n\n/**\n * StandaloneOrder is a type which contains the items needed to place a standalone order.\n * @param {number} synonymId - The synonym Id associated with the standalone order.\n * @param {'inpatient order' | 'prescription order'} origination - The origination of the order being placed.\n * @param {number} sentenceId - An optional order sentence Id for the order being placed.\n **/\nexport type StandaloneOrder = {\n synonymId: number;\n origination: 'inpatient order' | 'prescription order';\n sentenceId?: number;\n};\n\n/**\n * PowerPlanOrder is a type which contains the items needed to place a PowerPlan order.\n * @param {number} pathwayCatalogId -The pathway catalog Id associated with the PowerPlan order.\n * @param {number} personalizedPlanId - An optional personalized plan Id.\n * @param {Array<number>} diagnosisIds - An optional array of diagnosis Ids for the PowerPlan order to be associated with\n **/\nexport type PowerPlanOrder = {\n pathwayCatalogId: number;\n personalizedPlanId?: number;\n diagnosisIds?: Array<number>;\n};\n\n/**\n * PowerOrdersOrderOpts is a type which allows the user to choose settings (silent sign and interaction checking) that impact the manner in which order(s) are placed.\n * @param {boolean} signSilently - A boolean indicating whether or not a silent sign should be attempted.\n * @param {boolean} interactionChecking - A boolean indicating whether or not interaction checking (for standalone orders only) should be performed.\n **/\nexport type SubmissionOpts = {\n signSilently: boolean;\n interactionChecking: boolean;\n};\n\n/**\n * Submits a combination of standalone orders and/or PowerPlan orders by utilizing underlying Cerner - POWERORDERS functionality.\n * @param {number} patientId - The identifier for the patient. Cerner context variable: PAT_PersonId.\n * @param {number} encounterId - The identifier for the encounter belonging to the patient where\n * this order will be placed. Cerner context variable: VIS_EncntrId.\n * @param {Array<StandaloneOrder | PowerPlanOrder>} orders - An array of `StandaloneOrder` and/or `PowerPlanOrder`\n * objects, representing orders to be placed.\n * @param {PowerOrdersOpts} opts - An *optional* object containg a flag indicating whether or not the orders should be signed\n * silently and whether interaction checking should be performed for standalone orders. Defaults to no silent signing and interaction checking if not provided.\n * @param { Array<PowerOrdersMOEWFlags>} moewFlags - An *optional* array of strings defining the MOEW behavior/appearance. If not provided,\n * the values will default to the the order setting as well as recommended\n * values for the MOEW to be configured with PowerPlan support. If any values are provided, those will be the only values used.\n * @param {'order' | 'medications'} targetTab - (optional) Determines which list to target when lauching the MOEW.\n * Either the order list or the medication list (subset). Defaults to the complete order list if not provided.\n * @returns {SubmitPowerOrdersReturn} - an object with several high value properties: a boolean flag set to notify the user if the\n * attempt was made outside of PowerChart, the `status` of the order attempt, an object\n * representing the XML response string (converted to an array of the orders placed with order `name`,\n * `oid`, and `display` available for each), and the XML/response string itself (which is attempted to be parsed).\n * @throws {Error} - If no orders are provided, an Error will be thrown.\n * @throws {SyntaxError} - If any order provided is not of type `StandaloneOrder` or `PowerPlanOrder`, a SyntaxError will be thrown.\n */\nexport const submitPowerOrdersAsync = async (\n patientId: number,\n encounterId: number,\n orders: Array<StandaloneOrder | PowerPlanOrder>,\n opts?: SubmissionOpts,\n moewFlags?: Array<PowerOrdersMOEWFlags>,\n targetTab?: 'orders tab' | 'medications tab'\n): Promise<SubmitPowerOrdersReturn> => {\n opts = !opts ? { signSilently: false, interactionChecking: true } : opts;\n\n moewFlags = !moewFlags ? [] : moewFlags;\n\n // Get required bitmask values for later use in the CreateMOEW function\n // TODO: determine if this should be moved, and maybe simply integrated directly into the CreateMOEW function\n const { dwCustomizeFlag, dwTabFlag, dwTabDisplayOptionsFlag } =\n calculateMOEWBitmask(targetTab || 'orders tab', moewFlags);\n\n let retData: SubmitPowerOrdersReturn = {\n inPowerChart: true,\n status: 'success',\n ordersPlaced: null,\n };\n\n if (orders.length < 1) {\n throw new Error(\n 'At least one order to submit must be provided to this function.'\n );\n }\n\n let powerPlanOrders: Array<PowerPlanOrder> = [];\n let standaloneOrders: Array<StandaloneOrder> = [];\n\n orders.forEach((order) => {\n if (isPowerPlanOrder(order)) {\n powerPlanOrders.push(order as PowerPlanOrder);\n } else if (isStandaloneOrder(order)) {\n standaloneOrders.push(order as StandaloneOrder);\n } else {\n throw new SyntaxError(\n 'Each order provided must be of either a PowerPlanOrder or StandaloneOrder type.'\n );\n }\n });\n\n try {\n let moewId: number = 0;\n\n const dcof = await window.external.DiscernObjectFactory('POWERORDERS');\n\n const createMOEW = await createMOEWAsync(\n dcof,\n patientId,\n encounterId,\n dwCustomizeFlag,\n dwTabFlag,\n dwTabDisplayOptionsFlag\n );\n\n if (createMOEW.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n\n if (createMOEW.moewHandle === null) {\n retData.inPowerChart = true;\n retData.ordersPlaced = null;\n retData.status = 'invalid data returned';\n return retData;\n }\n\n moewId = createMOEW.moewHandle;\n\n if (powerPlanOrders && powerPlanOrders.length >= 1) {\n const addPowerPlans = await addPowerPlanWithDetailsAsync(\n dcof,\n moewId,\n powerPlanOrders\n );\n\n if (addPowerPlans.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n\n if (addPowerPlans.powerPlansAdded === false) {\n retData.inPowerChart = true;\n retData.ordersPlaced = null;\n retData.status = 'cancelled, failed, or invalid parameters provided';\n return retData;\n }\n }\n\n if (standaloneOrders && standaloneOrders.length >= 1) {\n const addStandaloneOrders = await addNewOrdersToScratchpadAsync(\n dcof,\n moewId,\n standaloneOrders,\n opts.interactionChecking\n );\n\n if (addStandaloneOrders.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n\n if (\n addStandaloneOrders.result === 'add failed' ||\n addStandaloneOrders.result === 'cancelled by user'\n ) {\n retData.inPowerChart = true;\n retData.ordersPlaced = null;\n retData.status = 'cancelled, failed, or invalid parameters provided';\n return retData;\n }\n }\n\n if (opts.signSilently) {\n const signOrders = await signOrdersAsync(dcof, moewId);\n\n if (signOrders.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n } else {\n const displayMOEW = await displayMOEWAsync(dcof, moewId);\n\n if (displayMOEW.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n }\n\n const getPlacedOrders = await getOrdersPlacedAsync(dcof, moewId);\n\n if (getPlacedOrders.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n\n if (\n getPlacedOrders.ordersPlaced === null ||\n getPlacedOrders.ordersPlaced.length === 0\n ) {\n retData.inPowerChart = true;\n retData.ordersPlaced = null;\n retData.status = getPlacedOrders.status;\n return retData;\n }\n\n retData.inPowerChart = true;\n retData.ordersPlaced = getPlacedOrders.ordersPlaced;\n retData.status = getPlacedOrders.status;\n\n const destroyMOEW = await destroyMOEWAsync(dcof, moewId);\n\n if (destroyMOEW.inPowerChart === false) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n }\n } catch (e) {\n if (outsideOfPowerChartError(e)) {\n retData.inPowerChart = false;\n retData.ordersPlaced = null;\n retData.status = 'dry run';\n return retData;\n } else {\n throw e;\n }\n }\n\n return retData;\n};\n\nexport type SubmitPowerOrdersReturn = PowerChartReturn & {\n status: SubmitPowerOrdersStatus;\n ordersPlaced: Array<{ name: string; oid: number; display: string }> | null;\n};\n\nconst isPowerPlanOrder = (o: PowerPlanOrder | StandaloneOrder): boolean => {\n return o.hasOwnProperty('pathwayCatalogId');\n};\n\nconst isStandaloneOrder = (o: PowerPlanOrder | StandaloneOrder): boolean => {\n return o.hasOwnProperty('synonymId') && o.hasOwnProperty('origination');\n};\n"],"mappings":";;;;;;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AO;AAC1C,cAAQ,eAAe;AACvB,cAAQ,eAAe;AACvB,cAAQ,SAAS;AACjB,aAAO;AAAA,IACT;AAEA,QACE,gBAAgB,iBAAiB,QACjC,gBAAgB,aAAa,WAAW,GACxC;AACA,cAAQ,eAAe;AACvB,cAAQ,eAAe;AACvB,cAAQ,SAAS,gBAAgB;AACjC,aAAO;AAAA,IACT;AAEA,YAAQ,eAAe;AACvB,YAAQ,eAAe,gBAAgB;AACvC,YAAQ,SAAS,gBAAgB;AAEjC,UAAM,cAAc,MAAM,iBAAiB,MAAM,MAAM;AAEvD,QAAI,YAAY,iBAAiB,OAAO;AACtC,cAAQ,eAAe;AACvB,cAAQ,eAAe;AACvB,cAAQ,SAAS;AACjB,aAAO;AAAA,IACT;AAAA,EACF,SAAS,GAAG;AACV,QAAI,yBAAyB,CAAC,GAAG;AAC/B,cAAQ,eAAe;AACvB,cAAQ,eAAe;AACvB,cAAQ,SAAS;AACjB,aAAO;AAAA,IACT,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AAEA,SAAO;AACT;AAOA,IAAM,mBAAmB,CAAC,MAAiD;AACzE,SAAO,EAAE,eAAe,kBAAkB;AAC5C;AAEA,IAAM,oBAAoB,CAAC,MAAiD;AAC1E,SAAO,EAAE,eAAe,WAAW,KAAK,EAAE,eAAe,aAAa;AACxE;","names":["opts","import_fast_xml_parser"]}
package/dist/index.d.cts CHANGED
@@ -296,6 +296,7 @@ type SubmitOrderAsyncReturn = MPageEventReturn & {
296
296
  oid: number;
297
297
  display: string;
298
298
  }> | null;
299
+ rawResponse: string | null;
299
300
  };
300
301
  type Order = {
301
302
  id: number;