Browse Source

电子病历优化

xiao 2 years ago
parent
commit
bab4e52799

+ 51 - 31
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/EmrMain.vue

@@ -71,13 +71,15 @@ import store from "@/store";
 import {onBeforeRouteLeave} from "vue-router";
 import {getUuid} from "@/api/public-api";
 import {
-  getDrgIntelligentGrouping, getExtractDataElement,
+  deletePatientEmrByDocumentId,
+  getDrgIntelligentGrouping, insertEmrData,
   submitMedicalRecord
 } from "@/api/zhu-yuan-yi-sheng/emr-patient";
 import {useDocumentVisibility} from "@vueuse/core";
 import EmrAssistant from "@/components/zhu-yuan-yi-sheng/emr/EmrAssistant.vue";
 import XcDialogV2 from "@/components/xiao-chan/dialog/XcDialogV2.vue";
 import {getWardsApi} from "@/api/login";
+import {xcMessage} from "@/utils/xiaochan-element-plus";
 
 const props = defineProps({
   huanZheXinXi: {
@@ -106,7 +108,8 @@ let openAssistant = $ref({
   data: {},
   dialog: false
 })
-
+// 患者数据
+let patientData = {}
 // 编辑器
 let editor = null
 // 侧边栏
@@ -117,8 +120,7 @@ const emrSnippetRef = ref(null)
 let loaded = $ref(false)
 // 是否 改变了数据
 let isEditorChange = $ref(false)
-// 患者数据
-let patientData = {}
+
 // 是否开启审阅模式
 let reviewMode = $ref(false)
 // 跳转定位
@@ -154,25 +156,33 @@ const clickSaveData = async () => {
     inputErrorMessage: '长度为2 - 20 个,汉字',
     inputPattern: /^\S{2,20}$/,
     inputValue: templateName
-  }).then(({value}) => {
+  }).then(async ({value}) => {
     data.name = value
-    currentEmr.value.saveDocument(data, async () => {
+    // 检验是否必填项目
+    let validator = editor.getValidator();
+    let valid = validator.valid();
+    if (valid) {
+      BizException(ExceptionEnum.MESSAGE_ERROR, "有必填项不能为空,请仔细检查,红色输入框.")
+    }
+    let res = await insertEmrData(data)
+    currentEmr.value.saveDocument(data).then(emrRes => {
+      // 把提取到的数据放到 patientData 中.
+      Object.assign(patientData, res)
       isEditorChange = false
       emrSidebarRef.value.queryData()
-      // 跳转到空白页面
-      caseHistoryUrl = `/emr/runtime/#/editor`
       let temp = {
         documentId: data.emrDocumentId,
         categoryCode: data.emrCategoryCode,
         name: data.name,
         categoryId: data.categoryId
       }
-      await updateCaseHistoryUrl(temp)
-    }, (err) => {
-      documentId = err
-      isEditorChange = true
+      updateCaseHistoryUrl(temp)
+      xcMessage.success('保存成功')
+    }).catch(() => {
+      xcMessage.error('保存失败请重新保存')
     })
 
+
   }).catch(() => {
 
   })
@@ -235,12 +245,22 @@ const clickDelete = () => {
   whetherThereIsAMedicalRecordId()
   ElMessageBox.alert('是否要删除该模板。', '提示', {
     type: 'warning'
-  }).then(() => {
-    currentEmr.value.deleteDocument(documentId, function () {
-      emrSidebarRef.value.queryData()
-      emptyEditor()
-    });
-  }).catch(() => {
+  }).then(async () => {
+    // 本院删除
+    let res = await deletePatientEmrByDocumentId(documentId)
+    // 电子病历删除
+    await currentEmr.value.deleteDocument(documentId)
+    if (res.length > 0) {
+      console.log('删除的数据', res)
+      for (let i = 0; i < res.length; i++) {
+        let item = res[i]
+        // 删除提取到的数据源
+        delete patientData[item]
+      }
+    }
+    isEditorChange = false
+    emrSidebarRef.value.queryData()
+    emptyEditor()
 
   })
 }
@@ -342,7 +362,6 @@ const monitorPageRefresh = (event) => {
 const clickSnippet = ({content, styles}) => {
   if (!readonlyPattern()) {
     currentEmr.value.callMethod('setCursor', 'AREA_END')
-    console.log(patientData)
     currentEmr.value.insertSnippet(content, styles, patientData)
   }
 }
@@ -378,14 +397,18 @@ const emrEvent = {
 
   'contentchange': (event) => {
     if (!readonlyPattern()) {
-      // 判断内容是否改变
-      isEditorChange = true
-      emrSidebarRef.value.changeTemplateType(2)
+      // 如果是空的编辑器就不触发了
+      if (!emrRef.value.src.includes('/emr/runtime/#/editor')) {
+        // 判断内容是否改变
+        isEditorChange = true
+        emrSidebarRef.value.changeTemplateType(2)
+      }
     }
   },
-}
 
+}
 
+// 设置编辑器的模式
 const setEditorModeFun = () => {
   // 判断是不是编辑模式
   if (emrConfig.value.editor) {
@@ -478,17 +501,14 @@ const deleteDataElement = () => {
   }
 }
 
-/**
- * 重新查询患者信息
- */
+// 重新设置提取的数据, 这里是强制替换
 const reQueryPatientInformation = () => {
   // 如果是只读模式就不触发这个
   if (!readonlyPattern()) {
-    getExtractDataElement(props.huanZheXinXi.inpatientNo, props.huanZheXinXi.admissTimes).then((res) => {
-      // getExtractDataElement('005959', 23).then((res) => {
-      Object.assign(patientData, res)
-      editor.setValues(res)
-    })
+    // 如果没有文档 id 就说明是
+    if (documentId) {
+      editor.setValues(patientData)
+    }
   }
 }
 

+ 40 - 41
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-init.js

@@ -1,9 +1,10 @@
-import {ElMessage, ElMessageBox} from "element-plus";
-import {BizException, ExceptionEnum} from "@/utils/BizException";
-import {deletePatientEmrByDocumentId, insertEmrData} from "@/api/zhu-yuan-yi-sheng/emr-patient";
+import {ElMessage} from "element-plus";
 import store from '@/store'
+import {xcMessage} from "@/utils/xiaochan-element-plus";
 
+// 患者数据
 export function EMRInteractive(data, editorEvent) {
+
     this.setEditor = (editor, runtime) => {
         this.editor = editor;
         this.runtime = runtime;
@@ -78,54 +79,52 @@ export function EMRInteractive(data, editorEvent) {
                 }
             },
             data
-        };
-    };
-
-    this.saveDocument = (value, successfullySaved, failedToSave) => {
-        let document = this.editor.getDocument();
-        document.properties.categoryCode = value.emrCategoryCode
-        document.properties.patientId = value.patNo;
-        document.properties.creator = data['编辑者编码'];
-        document.properties.createTime = new Date()
-        document.properties.modifier = data['编辑者编码'];
-        document.properties.modifyTime = new Date()
-        document._id = value.emrDocumentId
-        let validator = this.editor.getValidator();
-        let valid = validator.valid();
-        if (valid) {
-            BizException(ExceptionEnum.MESSAGE_ERROR, "没有通过校验")
         }
+    };
 
-        this.runtime.saveDocument(document, (res) => {
-            insertEmrData(value).then(() => {
-                successfullySaved()
-            }).catch((e) => {
-                ElMessageBox.alert('保存失败,请重新保存,' + e, '提示', {
-                    type: "warning"
-                }).finally(() => {
-                    failedToSave(value.emrDocumentId)
-                })
-            })
-        }, (err) => {
-            ElMessage.error("emr保存失败," + err)
-        });
+    this.saveDocument = (value) => {
+        return new Promise((resolve, reject) => {
+            let document = this.editor.getDocument();
+            document.properties.categoryCode = value.emrCategoryCode
+            document.properties.patientId = value.patNo;
+            document.properties.creator = data['编辑者编码'];
+            document.properties.createTime = new Date()
+            document.properties.modifier = data['编辑者编码'];
+            document.properties.modifyTime = new Date()
+            document._id = value.emrDocumentId
+            this.runtime.saveDocument(document, (res) => {
+                    console.log(res)
+                    console.log('保存成功')
+                    resolve(res)
+                },
+                (err) => {
+                    xcMessage.error('保存失败' + err)
+                    reject(err)
+                }
+            )
+        })
 
     };
 
     this.deleteDocument = (documentId, cb) => {
-        this.runtime.delDocument(documentId, (res) => {
-            deletePatientEmrByDocumentId(documentId).then(() => {
-                cb()
-            })
-        }, (err) => {
-            ElMessage.error("删除失败" + err)
-        });
+        return new Promise((resolve, reject) => {
+            this.runtime.delDocument(documentId, (res) => {
+                resolve(res)
+                xcMessage.success('删除成功')
+            }, (err) => {
+                ElMessage.error("删除失败" + err)
+                reject(err)
+            });
+
+
+        })
+
     };
 }
 
 export const query = ref({
-    patNo: '0413224',
-    times: 1,
+    patNo: '',
+    times: 0,
     maxTimes: 1,
     state: 0
 })