|
@@ -4,316 +4,262 @@ import { UnwrapRef } from "vue";
|
|
|
import { BizException, ExceptionEnum } from "../BizException";
|
|
|
import { ElMessageBox } from "element-plus";
|
|
|
import XEUtils from "xe-utils";
|
|
|
-import useDialogToJs from "@/components/js-dialog-comp/useDialogToJs";
|
|
|
-import { magicApi } from "@/utils/database/magic-api-request";
|
|
|
-
|
|
|
-const GenerateSignature = defineAsyncComponent(() =>
|
|
|
- import("@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/components/GenerateSignature.vue"))
|
|
|
-const DialogDMT = defineAsyncComponent(() => import('@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/components/DialogMDT.vue'))
|
|
|
|
|
|
type AppContext =
|
|
|
- | any
|
|
|
- | (() => {
|
|
|
- [key: string]: any
|
|
|
-})
|
|
|
+ | any
|
|
|
+ | (() => {
|
|
|
+ [key: string]: any;
|
|
|
+ });
|
|
|
|
|
|
interface Options {
|
|
|
- appContext?: AppContext
|
|
|
- event?: {
|
|
|
- [key: string]: (...val: any[]) => void
|
|
|
- }
|
|
|
- tabletMode?: boolean,
|
|
|
+ appContext?: AppContext;
|
|
|
+ event?: {
|
|
|
+ [key: string]: (...val: any[]) => void;
|
|
|
+ };
|
|
|
+ tabletMode?: boolean;
|
|
|
}
|
|
|
|
|
|
function changeRatio() {
|
|
|
- let ratio = 0;
|
|
|
- const screen = window.screen;
|
|
|
- const ua = navigator.userAgent.toLowerCase();
|
|
|
-
|
|
|
- if (window.devicePixelRatio !== undefined) {
|
|
|
- ratio = window.devicePixelRatio;
|
|
|
- } else if (~ua.indexOf('msie')) {
|
|
|
- // @ts-ignore
|
|
|
- if (screen.deviceXDPI && screen.logicalXDPI) {
|
|
|
- // @ts-ignore
|
|
|
- ratio = screen.deviceXDPI / screen.logicalXDPI;
|
|
|
- }
|
|
|
-
|
|
|
- } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
|
|
|
- ratio = window.outerWidth / window.innerWidth;
|
|
|
+ let ratio = 0;
|
|
|
+ const screen = window.screen;
|
|
|
+ const ua = navigator.userAgent.toLowerCase();
|
|
|
+
|
|
|
+ if (window.devicePixelRatio !== undefined) {
|
|
|
+ ratio = window.devicePixelRatio;
|
|
|
+ } else if (~ua.indexOf("msie")) {
|
|
|
+ // @ts-ignore
|
|
|
+ if (screen.deviceXDPI && screen.logicalXDPI) {
|
|
|
+ // @ts-ignore
|
|
|
+ ratio = screen.deviceXDPI / screen.logicalXDPI;
|
|
|
}
|
|
|
-
|
|
|
- if (ratio) {
|
|
|
- ratio = Math.round(ratio * 100);
|
|
|
- }
|
|
|
- return ratio;
|
|
|
+ } else if (
|
|
|
+ window.outerWidth !== undefined &&
|
|
|
+ window.innerWidth !== undefined
|
|
|
+ ) {
|
|
|
+ ratio = window.outerWidth / window.innerWidth;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ratio) {
|
|
|
+ ratio = Math.round(ratio * 100);
|
|
|
+ }
|
|
|
+ return ratio;
|
|
|
}
|
|
|
|
|
|
const pageIsZoom = () => {
|
|
|
- const rate = changeRatio();
|
|
|
- if (rate !== 100) {
|
|
|
- ElMessageBox.alert("当前页面不是100%显示,请按键盘ctrl+0恢复100%显示标准,如果页面是100%缩放请检查系统缩放(可自行百度),设置=》屏幕缩放(选择100%),以防页面显示错乱,以及续打对不准!", '提示', {
|
|
|
- type: "warning"
|
|
|
- }).then(() => {
|
|
|
- }).catch(() => {
|
|
|
- })
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
+ const rate = changeRatio();
|
|
|
+ if (rate !== 100) {
|
|
|
+ ElMessageBox.alert(
|
|
|
+ "当前页面不是100%显示,请按键盘ctrl+0恢复100%显示标准,如果页面是100%缩放请检查系统缩放(可自行百度),设置=》屏幕缩放(选择100%),以防页面显示错乱,以及续打对不准!",
|
|
|
+ "提示",
|
|
|
+ {
|
|
|
+ type: "warning",
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {})
|
|
|
+ .catch(() => {});
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
export interface UseEmrInitReturn {
|
|
|
- editor: EditType
|
|
|
- runtime: Runtime
|
|
|
- iframe: HTMLIFrameElement
|
|
|
- delElementByName: (name: string) => void
|
|
|
- loadDocument: (loadParams: LoadParams) => Promise<any>
|
|
|
- loadAndSetDocument: (loadParams: LoadParams) => Promise<any>,
|
|
|
- print: (value?: 'html' | 'server') => void
|
|
|
+ editor: EditType;
|
|
|
+ runtime: Runtime;
|
|
|
+ iframe: HTMLIFrameElement;
|
|
|
+ delElementByName: (name: string) => void;
|
|
|
+ loadDocument: (loadParams: LoadParams) => Promise<any>;
|
|
|
+ loadAndSetDocument: (loadParams: LoadParams) => Promise<any>;
|
|
|
+ print: (value?: "html" | "server") => void;
|
|
|
}
|
|
|
|
|
|
export interface LoadParams {
|
|
|
- //文档id
|
|
|
- documentId: string | null
|
|
|
- // 文档类型
|
|
|
- categoryCode?: string
|
|
|
- // 患者id
|
|
|
- patientId?: string
|
|
|
- //病历类型id
|
|
|
- categoryId?: string
|
|
|
- // 文档版本号
|
|
|
- version?: string
|
|
|
+ //文档id
|
|
|
+ documentId: string | null;
|
|
|
+ // 文档类型
|
|
|
+ categoryCode?: string;
|
|
|
+ // 患者id
|
|
|
+ patientId?: string;
|
|
|
+ //病历类型id
|
|
|
+ categoryId?: string;
|
|
|
+ // 文档版本号
|
|
|
+ version?: string;
|
|
|
}
|
|
|
|
|
|
function delElementByName(this: any, name: string, editor: EditType) {
|
|
|
- editor.execute('execFn', {
|
|
|
- value: {
|
|
|
- fn: function () {
|
|
|
- const EMR = editor.getScriptRuntime().EMR
|
|
|
- const emrDoc = EMR.getDocument()
|
|
|
- const components = emrDoc.getComponentsByCode(name)
|
|
|
- components.forEach((component) => {
|
|
|
- const view = component.target
|
|
|
- const viewDom = view.el
|
|
|
- const viewParagraphDom = viewDom.parentElement
|
|
|
- viewDom.remove()
|
|
|
- if (viewParagraphDom.textContent === '') {
|
|
|
- viewParagraphDom.remove()
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- persist: true,
|
|
|
- scope: this,
|
|
|
- params: name
|
|
|
- }
|
|
|
- })
|
|
|
+ editor.execute("execFn", {
|
|
|
+ value: {
|
|
|
+ fn: function () {
|
|
|
+ const EMR = editor.getScriptRuntime().EMR;
|
|
|
+ const emrDoc = EMR.getDocument();
|
|
|
+ const components = emrDoc.getComponentsByCode(name);
|
|
|
+ components.forEach(component => {
|
|
|
+ const view = component.target;
|
|
|
+ const viewDom = view.el;
|
|
|
+ const viewParagraphDom = viewDom.parentElement;
|
|
|
+ viewDom.remove();
|
|
|
+ if (viewParagraphDom.textContent === "") {
|
|
|
+ viewParagraphDom.remove();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ persist: true,
|
|
|
+ scope: this,
|
|
|
+ params: name,
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
export function useEmrInit(
|
|
|
- div: UnwrapRef<HTMLElement | null>,
|
|
|
- options?: Options
|
|
|
+ div: UnwrapRef<HTMLElement | null>,
|
|
|
+ options?: Options
|
|
|
): Promise<UseEmrInitReturn> {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- // @ts-ignore
|
|
|
- if (div['emr']) {
|
|
|
- // @ts-ignore
|
|
|
- div.querySelector('iframe').remove()
|
|
|
- }
|
|
|
-
|
|
|
- const iframe: HTMLIFrameElement = document.createElement('iframe')
|
|
|
- let editor: EditType, runtime: Runtime
|
|
|
-
|
|
|
- iframe.style.width = '100%'
|
|
|
- iframe.style.height = '100%'
|
|
|
-
|
|
|
- let additionalParameters: string = ''
|
|
|
- if (options && options.tabletMode) {
|
|
|
- additionalParameters += '?layout=mobile-zoom'
|
|
|
- }
|
|
|
-
|
|
|
- iframe.src = '/emr/runtime/#/editor' + additionalParameters
|
|
|
- iframe.style.border = '0'
|
|
|
- iframe.style.display = 'block'
|
|
|
-
|
|
|
-
|
|
|
- function loadDocument(loadParams: LoadParams): Promise<any> {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- runtime.loadDocument(
|
|
|
- (res) => {
|
|
|
- resolve(res)
|
|
|
- },
|
|
|
- (err) => {
|
|
|
- reject(err)
|
|
|
- },
|
|
|
- loadParams
|
|
|
- )
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- function backToTop() {
|
|
|
- iframe?.contentWindow?.document?.getElementById('editorEl')?.scroll({top: 0})
|
|
|
- }
|
|
|
-
|
|
|
- function loadAndSetDocument(loadParams: LoadParams): Promise<void> {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- loadDocument(loadParams)
|
|
|
- .then((res) => {
|
|
|
- backToTop()
|
|
|
- editor.setDocument(res, true)
|
|
|
- resolve(res)
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- reject(err)
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- async function print(value: 'html' | 'server' = 'html') {
|
|
|
- const documentId = editor.documentData._id
|
|
|
- if (documentId == null) {
|
|
|
- BizException(ExceptionEnum.MESSAGE_ERROR, "请先保存病历。");
|
|
|
- }
|
|
|
- const document = await loadDocument({documentId}).catch(e => {
|
|
|
- BizException(ExceptionEnum.MESSAGE_ERROR, "网络错误无法保存。");
|
|
|
- })
|
|
|
-
|
|
|
- if (value === 'html') {
|
|
|
- pageIsZoom()
|
|
|
- }
|
|
|
- editor.execute("print", {
|
|
|
- value: {
|
|
|
- showPreview: true,
|
|
|
- document,
|
|
|
- mode: value === 'server' ? 'backend' : ''
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // @ts-ignore
|
|
|
- div['emr'] = {
|
|
|
- setEditor: (e: EditType, r: any): void => {
|
|
|
- editor = e
|
|
|
- runtime = r
|
|
|
-
|
|
|
- // @ts-ignore
|
|
|
- div['myEmr'] = {
|
|
|
- editor: e,
|
|
|
- runtime: r
|
|
|
- }
|
|
|
-
|
|
|
- if (options && options.event) {
|
|
|
- for (const key in options.event) {
|
|
|
- editor.on(key, options.event[key])
|
|
|
- }
|
|
|
- }
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ // @ts-ignore
|
|
|
+ if (div["emr"]) {
|
|
|
+ // @ts-ignore
|
|
|
+ div.querySelector("iframe").remove();
|
|
|
+ }
|
|
|
|
|
|
- resolve({
|
|
|
- editor,
|
|
|
- runtime,
|
|
|
- iframe,
|
|
|
- delElementByName: (name: string) => delElementByName(name, editor),
|
|
|
- loadDocument,
|
|
|
- loadAndSetDocument,
|
|
|
- print
|
|
|
- })
|
|
|
- },
|
|
|
- getAppContext: (): any => {
|
|
|
- if (options && options.appContext) {
|
|
|
- if (typeof options.appContext === 'function') {
|
|
|
- return options.appContext()
|
|
|
- }
|
|
|
- return options.appContext
|
|
|
- }
|
|
|
- return {}
|
|
|
- }
|
|
|
- }
|
|
|
+ const iframe: HTMLIFrameElement = document.createElement("iframe");
|
|
|
+ let editor: EditType, runtime: Runtime;
|
|
|
|
|
|
- // @ts-ignore
|
|
|
- div.appendChild(iframe)
|
|
|
- })
|
|
|
-}
|
|
|
+ iframe.style.width = "100%";
|
|
|
+ iframe.style.height = "100%";
|
|
|
|
|
|
-export function componentClick(evt, view, patientData): void {
|
|
|
- const componentType = view.componentType;
|
|
|
- const eleInfo = view.getAttribute('element')
|
|
|
- if (componentType === 'sign') {
|
|
|
- if (eleInfo.code.internal === '授权签名') {
|
|
|
- useDialogToJs(GenerateSignature, {
|
|
|
- usersign: patientData['自动签名'][0]
|
|
|
- }).then(res => {
|
|
|
- res.signature = "http://172.16.32.167:8077/doctorSignatureImage/" + res.id + '.png'
|
|
|
- view.sign([res])
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- if (eleInfo.code.business === '自动签名') {
|
|
|
- view.sign(patientData['自动签名'])
|
|
|
- }
|
|
|
+ let additionalParameters: string = "";
|
|
|
+ if (options && options.tabletMode) {
|
|
|
+ additionalParameters += "?layout=mobile-zoom";
|
|
|
}
|
|
|
|
|
|
- if (eleInfo?.code?.internal === 'MDT') {
|
|
|
- useHandleMdt(evt, view, patientData)
|
|
|
+ iframe.src = "/emr/runtime/#/editor" + additionalParameters;
|
|
|
+ iframe.style.border = "0";
|
|
|
+ iframe.style.display = "block";
|
|
|
+
|
|
|
+ function loadDocument(loadParams: LoadParams): Promise<any> {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ runtime.loadDocument(
|
|
|
+ res => {
|
|
|
+ resolve(res);
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ reject(err);
|
|
|
+ },
|
|
|
+ loadParams
|
|
|
+ );
|
|
|
+ });
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-let mdtData = []
|
|
|
|
|
|
-async function useHandleMdt(evt, view, patientData) {
|
|
|
- if (mdtData.length === 0) {
|
|
|
- mdtData = await magicApi({
|
|
|
- url: '/dataEmr/comp/mdtData',
|
|
|
- method: 'get',
|
|
|
- })
|
|
|
+ function backToTop() {
|
|
|
+ iframe?.contentWindow?.document
|
|
|
+ ?.getElementById("editorEl")
|
|
|
+ ?.scroll({ top: 0 });
|
|
|
}
|
|
|
|
|
|
- let value = view.value
|
|
|
-
|
|
|
- if (XEUtils.isArray(value)) {
|
|
|
- value = XEUtils.map(value, (item) => {
|
|
|
- return item.cascader
|
|
|
- })
|
|
|
- } else {
|
|
|
- value = []
|
|
|
+ function loadAndSetDocument(loadParams: LoadParams): Promise<void> {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ loadDocument(loadParams)
|
|
|
+ .then(res => {
|
|
|
+ backToTop();
|
|
|
+ editor.setDocument(res, true);
|
|
|
+ resolve(res);
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ reject(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- useDialogToJs(DialogDMT, {
|
|
|
- options: mdtData,
|
|
|
- value: value
|
|
|
- }).then(res => {
|
|
|
- view.setValue(res)
|
|
|
- view.value = res
|
|
|
- });
|
|
|
-}
|
|
|
+ async function print(value: "html" | "server" = "html") {
|
|
|
+ const documentId = editor.documentData._id;
|
|
|
+ if (documentId == null) {
|
|
|
+ BizException(ExceptionEnum.MESSAGE_ERROR, "请先保存病历。");
|
|
|
+ }
|
|
|
+ const document = await loadDocument({ documentId }).catch(e => {
|
|
|
+ BizException(ExceptionEnum.MESSAGE_ERROR, "网络错误无法保存。");
|
|
|
+ });
|
|
|
+
|
|
|
+ if (value === "html") {
|
|
|
+ pageIsZoom();
|
|
|
+ }
|
|
|
+ editor.execute("print", {
|
|
|
+ value: {
|
|
|
+ showPreview: true,
|
|
|
+ document,
|
|
|
+ mode: value === "server" ? "backend" : "",
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
-export function getBcjlUserInfo(value: any):
|
|
|
- {
|
|
|
- code: string, name: string
|
|
|
- } {
|
|
|
+ // @ts-ignore
|
|
|
+ div["emr"] = {
|
|
|
+ setEditor: (e: EditType, r: any): void => {
|
|
|
+ editor = e;
|
|
|
+ runtime = r;
|
|
|
|
|
|
- if (XEUtils.has(value, '编辑者')) {
|
|
|
- return {
|
|
|
- code: XEUtils.get(value, '编辑者.value[0].code', ''),
|
|
|
- name: XEUtils.get(value, '编辑者.value[0].name', '')
|
|
|
+ // @ts-ignore
|
|
|
+ div["myEmr"] = {
|
|
|
+ editor: e,
|
|
|
+ runtime: r,
|
|
|
+ };
|
|
|
+
|
|
|
+ if (options && options.event) {
|
|
|
+ for (const key in options.event) {
|
|
|
+ editor.on(key, options.event[key]);
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- return {
|
|
|
- code: XEUtils.get(value, '自动签名.value[0].code', ''),
|
|
|
- name: XEUtils.get(value, '自动签名.value[0].name', '')
|
|
|
+
|
|
|
+ resolve({
|
|
|
+ editor,
|
|
|
+ runtime,
|
|
|
+ iframe,
|
|
|
+ delElementByName: (name: string) => delElementByName(name, editor),
|
|
|
+ loadDocument,
|
|
|
+ loadAndSetDocument,
|
|
|
+ print,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getAppContext: (): any => {
|
|
|
+ if (options && options.appContext) {
|
|
|
+ if (typeof options.appContext === "function") {
|
|
|
+ return options.appContext();
|
|
|
+ }
|
|
|
+ return options.appContext;
|
|
|
}
|
|
|
- }
|
|
|
+ return {};
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ // @ts-ignore
|
|
|
+ div.appendChild(iframe);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+export function getBcjlUserInfo(value: any): {
|
|
|
+ code: string;
|
|
|
+ name: string;
|
|
|
+} {
|
|
|
+ if (XEUtils.has(value, "编辑者")) {
|
|
|
+ return {
|
|
|
+ code: XEUtils.get(value, "编辑者.value[0].code", ""),
|
|
|
+ name: XEUtils.get(value, "编辑者.value[0].name", ""),
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ code: XEUtils.get(value, "自动签名.value[0].code", ""),
|
|
|
+ name: XEUtils.get(value, "自动签名.value[0].name", ""),
|
|
|
+ };
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
export function parsingFragmentDataElements(editor: EditType | null, node) {
|
|
|
- if (editor == null || node === null) {
|
|
|
- return {}
|
|
|
- }
|
|
|
- const modelService = editor!.ModelService;
|
|
|
- const walker = modelService.createTreeWalker(node);
|
|
|
- return modelService.getElementsDataFromWalker(walker)
|
|
|
+ if (editor == null || node === null) {
|
|
|
+ return {};
|
|
|
+ }
|
|
|
+ const modelService = editor!.ModelService;
|
|
|
+ const walker = modelService.createTreeWalker(node);
|
|
|
+ return modelService.getElementsDataFromWalker(walker);
|
|
|
}
|
|
|
|
|
|
export enum RevisionShowMode {
|
|
|
- 不显示,
|
|
|
- 卡片,
|
|
|
- 嵌入
|
|
|
+ 不显示,
|
|
|
+ 卡片,
|
|
|
+ 嵌入,
|
|
|
}
|