Browse Source

抽离电子病历工具类

xiaochan 1 month ago
parent
commit
ce896e8896

+ 35 - 0
src/utils/emr/emrUtils.ts

@@ -0,0 +1,35 @@
+import { DataElementItem, EditType } from "@/utils/emr/edit";
+import XEUtils from "xe-utils";
+import { stringNotBlank } from "@/utils/blank-utils";
+
+// 根据编码获取组件
+export function getInternalByCode(
+  editor: EditType,
+  name: string,
+  code: "internal" | "business" = "internal",
+  removeNotNull = true
+): DataElementItem[] {
+  const signatureControl = editor.getDataElements(code, false, true);
+  let data = signatureControl[name] as DataElementItem[];
+  if (!data) {
+    return [];
+  }
+  if (!XEUtils.isArray(data)) {
+    data = [data];
+  }
+  if (removeNotNull) {
+    // 移出不为空的数据
+    XEUtils.remove(data, item => {
+      return stringNotBlank(item.value);
+    });
+  }
+  return data;
+}
+
+export function getViewById(editor: EditType, id: string) {
+  const find = editor.view.container.find(`#${id}`);
+  if (XEUtils.isEmpty(find)) {
+    return;
+  }
+  return find[0];
+}

+ 3 - 6
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/plugins/ca/EmrCAComp.vue

@@ -3,12 +3,8 @@ import {
   emrRootContextKey,
   EmrStore,
 } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/useEmrStore";
-import {
-  authorizedSignatureDataElement,
-  getInternalByCode,
-  selectData,
-  SignComp,
-} from "./emr-ca";
+import { authorizedSignatureDataElement, selectData, SignComp } from "./emr-ca";
+
 import XEUtils from "xe-utils";
 import { BizException, ExceptionEnum } from "@/utils/BizException";
 import {
@@ -24,6 +20,7 @@ import XcElOption from "@/components/xiao-chan/xc-el-option/XcElOption.vue";
 import { useUserStore } from "@/pinia/user-store";
 import { patientInfo } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
 import { stringIsBlank } from "@/utils/blank-utils";
+import { getInternalByCode } from "@/utils/emr/emrUtils";
 
 const SignIdCard = defineAsyncComponent(() => import("./SignIdCard.vue"));
 

+ 1 - 32
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/plugins/ca/emr-ca.tsx

@@ -17,12 +17,12 @@ import {
   isCourse,
   patientInfo,
 } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
-import { stringNotBlank } from "@/utils/blank-utils";
 import { ElMessageBox } from "element-plus";
 import { parsingFragmentDataElements } from "@/utils/emr/emr-init-v2";
 import { Install } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/plugins";
 import { defineAsyncComponent } from "vue";
 import env from "@/utils/setting";
+import { getInternalByCode, getViewById } from "@/utils/emr/emrUtils";
 
 const GenerateSignature = defineAsyncComponent(
   () =>
@@ -185,37 +185,6 @@ const GenerateSignatureDialog = defineComponent({
 
 const us = useUserStore().userInfo;
 
-export function getInternalByCode(
-  editor: EditType,
-  name: string,
-  code: "internal" | "business" = "internal",
-  removeNotNull = true
-): DataElementItem[] {
-  const signatureControl = editor.getDataElements(code, false, true);
-  let data = signatureControl[name] as DataElementItem[];
-  if (!data) {
-    return [];
-  }
-  if (!XEUtils.isArray(data)) {
-    data = [data];
-  }
-  if (removeNotNull) {
-    // 移出不为空的数据
-    XEUtils.remove(data, item => {
-      return stringNotBlank(item.value);
-    });
-  }
-  return data;
-}
-
-function getViewById(editor: EditType, id: string) {
-  const find = editor.view.container.find(`#${id}`);
-  if (XEUtils.isEmpty(find)) {
-    return;
-  }
-  return find[0];
-}
-
 function dialog() {
   let tmpClose = (_value: CloseValue, _data) => {};
   let value: DialogState;