Ver Fonte

完成电子病历排序和保存删除数据同步。

DESKTOP-0GD05B0\Administrator há 2 anos atrás
pai
commit
c99c366c4a

+ 1 - 0
src/components/xiao-chan/select-v3/XcSelectV3.vue

@@ -363,6 +363,7 @@ watch(() => props.data, async () => {
   await nextTick()
   enableScrollBar()
   containerRef.value.scrollTop = 0
+  if (isFocus) return
   if (!judgingCodeIsEmpty()) {
     dataFilling()
   }

+ 3 - 1
src/components/zhu-yuan-yi-sheng/yi-zhu-lu-ru/yz-edit/YzEditor.vue

@@ -862,7 +862,9 @@ const dosePrecision = () => {
 
 // 频率点击
 const pingLvRowClick = (val) => {
-  yiZhuData.value.instruction = val.name
+  if (isCydy()) {
+    yiZhuData.value.instruction = val.name;
+  }
 }
 
 let shortcutKeyRegistration = {

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

@@ -18,10 +18,12 @@
         <el-button icon="RefreshLeft" @click="clickUndo('undo')">撤销</el-button>
         <el-button icon="RefreshRight" @click="clickUndo('redo')">重做</el-button>
       </el-button-group>
-
       <el-button @click="drgIntelligentGrouping" type="primary">DRG智能分组</el-button>
-
       <emr-assistant :data="openAssistant" :to-fill-in-data="clickToFillInData"/>
+      <el-button title="根据病程记录的时间来进行排序,从小到大。"
+                 @click="diseaseCourseSequencing">
+        病程排序 ❓
+      </el-button>
       <el-switch v-model="reviewMode"
                  active-color="#ff4949"
                  active-text="关闭审阅"
@@ -146,6 +148,12 @@ const clickSaveData = async () => {
     BizException(ExceptionEnum.LOGICAL_ERROR, "无法保存病历。");
   }
   waitForLoadingToComplete()
+  // 判断是否有必填项目
+  let validator = editor.getValidator();
+  let valid = validator.valid();
+  if (valid) {
+    BizException(ExceptionEnum.MESSAGE_ERROR, "有必填项不能为空,请仔细检查,红色输入框.")
+  }
   let data = {
     // 这个是 唯一 id 调用服务的雪花算法
     emrDocumentId: documentId ? documentId : await getUuid(),
@@ -157,20 +165,14 @@ const clickSaveData = async () => {
   }
   objectValuesCannotBeNull(data)
   data.emrDataElement = editor.getDataElements('business')
-  // 检验是否必填项目
-  let validator = editor.getValidator();
-  let valid = validator.valid();
-  if (valid) {
-    BizException(ExceptionEnum.MESSAGE_ERROR, "有必填项不能为空,请仔细检查,红色输入框.")
-  }
+
   ElMessageBox.prompt('请输入保存的名称', '提示', {
     inputErrorMessage: '长度为2 - 20 个,汉字',
     inputPattern: /^\S{2,20}$/,
     inputValue: templateName
   }).then(async ({value}) => {
     data.name = value
-    let res = await insertEmrData(data)
-    currentEmr.value.saveDocument(data).then(emrRes => {
+    currentEmr.value.saveDocument(data).then(res => {
       // 把提取到的数据放到 patientData 中.
       extractData = res
       Object.assign(patientData, res)
@@ -259,10 +261,8 @@ const clickDelete = () => {
   ElMessageBox.alert('是否要删除该模板。', '提示', {
     type: 'warning'
   }).then(async () => {
-    // 本院删除
-    let res = await deletePatientEmrByDocumentId(documentId)
     // 电子病历删除
-    await currentEmr.value.deleteDocument(documentId)
+    let res = await currentEmr.value.deleteDocument(documentId)
     if (res.length > 0) {
       for (let i = 0; i < res.length; i++) {
         let item = res[i]
@@ -326,6 +326,9 @@ const nodeClick = (val, jumpOrNot, templateType) => {
 }
 
 const updateCaseHistoryUrl = async (val) => {
+  courseSegmentLocking()
+  let temp = `/emr/runtime/?documentId=${documentId}&categoryCode=${categoryCode}&categoryId=${categoryId}&patientId=${patientId}#/`
+  if (temp === caseHistoryUrl) return
   loaded = true
   isEditorChange = false
   documentId = val.documentId;
@@ -651,10 +654,63 @@ const extractFields = (val) => {
   }
 }
 
+// 是否开启审阅模式
 const isRevisionMode = () => {
   editor.setRevisionShowMode(reviewMode)
 }
 
+// 电子病历排序
+const diseaseCourseSequencing = () => {
+  if (!categoryCode.includes('shoucibingchengjilu')) {
+    return
+  }
+  editor.execute('execFn', {
+    value: {
+      scope: this,
+      params: [],
+      fn: function () {
+        const areas = [];        //区域数组
+        let walker = null;        //遍历器
+        const service = editor.ModelService; //节点工具
+        const root = editor.model.document.getRoot(); //文档跟节点
+        for (const node of root.getChildren()) { //遍历区域并把时间和区域关键放进areas
+          if (node.type === 'area') {
+            if (!walker) walker = service.createTreeWalker(node)
+            else service.setWalkerRoot(walker, node);
+            let dataElements = service.getDataElementsFromWalker(walker, '查房时间', 'business');
+            let time = dataElements['查房时间'].value;
+            areas.push({
+              time: new Date(time).getTime(),
+              t: time,
+              view: node.view
+            })
+          }
+        }
+        let item = areas[0].view.el, anchor, pos; //anchor为排序插入节点,pos为位置
+        if (item.previousElementSibling) {//如果第一个区域有前节点
+          anchor = item.previousElementSibling
+          pos = 'afterend'
+        } else if (item.nextElementSibling) {//有后节点
+          anchor = item.nextElementSibling
+          pos = 'beforebegin'
+        }
+        areas.sort((item1, item2) => {
+          return item1.time - item2.time
+        }).forEach((item) => {
+          if (!anchor) {//无前后节点之间append
+            anchor.parentElement.appendChild(item.view.el)
+          } else {
+            anchor.insertAdjacentElement(pos, item.view.el);
+            anchor = item.view.el
+            pos = 'afterend'
+          }
+        })
+      }
+    }
+  })
+}
+
+
 onMounted(() => {
   getExtractDataElement(props.huanZheXinXi.inpatientNo, props.huanZheXinXi.admissTimes).then((res) => {
     extractData = res

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

@@ -2,6 +2,7 @@ import {ElMessage} from "element-plus";
 import store from '@/store'
 import {xcMessage} from "@/utils/xiaochan-element-plus";
 import router from "@/router";
+import {deletePatientEmrByDocumentId, insertEmrData} from "@/api/zhu-yuan-yi-sheng/emr-patient";
 
 // 患者数据
 export function EMRInteractive(data, editorEvent) {
@@ -84,42 +85,22 @@ export function EMRInteractive(data, editorEvent) {
     };
 
     this.saveDocument = (value) => {
-        return new Promise((resolve, reject) => {
-            let document = this.editor.getDocument();
-            document.properties.categoryCode = value.emrCategoryCode
-            document.properties.patientId = value.patNo + "_" + value.times;
-            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)
-                    resolve(res)
-                },
-                (err) => {
-                    xcMessage.error('保存失败' + err)
-                    reject(err)
-                }
-            )
-        })
-
+        let document = this.editor.getDocument();
+        document.properties.categoryCode = value.emrCategoryCode
+        document.properties.patientId = value.patNo + "_" + value.times;
+        document.properties.creator = data['编辑者编码'];
+        document.properties.createTime = new Date()
+        document.properties.modifier = data['编辑者编码'];
+        document.properties.modifyTime = new Date()
+        document._id = value.emrDocumentId
+        value.documentData = document
+        return insertEmrData(value)
     };
 
-    this.deleteDocument = (documentId, cb) => {
-        return new Promise((resolve, reject) => {
-            this.runtime.delDocument(documentId, (res) => {
-                resolve(res)
-                xcMessage.success('删除成功')
-            }, (err) => {
-                ElMessage.error("删除失败" + err)
-                reject(err)
-            });
-
-
-        })
-
+    this.deleteDocument = (documentId) => {
+        return deletePatientEmrByDocumentId(documentId)
     };
+
 }
 
 export const query = ref({