DESKTOP-MINPJAU\Administrator 3 years ago
parent
commit
0011287ad5

+ 20 - 8
src/components/zhu-yuan-yi-sheng/emr/EmrSnippet.vue

@@ -25,14 +25,22 @@ import {getSnippet} from "@/api/zhu-yuan-yi-sheng/emr-api";
 import {getWindowSize} from "@/utils/window-size";
 import {EMRInteractive} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-init";
 
+const props = defineProps({
+  patientData: {
+    type: Object
+  }
+})
+
 const emit = defineEmits(['nodeClick'])
 
 let snippetData = $ref([])
 let dialog = $ref(false)
-let selectedData = $ref({})
+let selectedData = {}
 let filterText = $ref('')
 let treeRef = $ref('')
 
+let executeLoad = true
+
 const defaultProps = {
   children: 'children',
   label: 'name',
@@ -57,23 +65,27 @@ const handleNodeClick = (node, object, event) => {
 }
 
 const fragmentPreview = (event, data, node) => {
-  console.log(event, data, node)
+  // console.log(event, data, node)
   selectedData = data
   dialog = true
-  if (!currentEmr.value) {
+  if (currentEmr.value) {
+    currentEmr.value.callMethod('setDocument', selectedData, true, true)
+  } else {
     nextTick(() => {
-      currentEmr.value = new EMRInteractive(null, editorEvents);
+      currentEmr.value = new EMRInteractive(props.patientData, editorEvents);
       emrRef.value.parentElement.emr = currentEmr.value
     });
-  } else {
-    currentEmr.value.setDocument(selectedData, true, true)
   }
 }
 
 const editorEvents = ({name}) => {
-  if (name === 'loaded') {
-    currentEmr.value.setDocument(selectedData, true, true)
+  if (executeLoad) {
+    if (name === 'loaded') {
+      executeLoad = false
+      currentEmr.value.callMethod('setDocument', selectedData, true, true)
+    }
   }
+
 }
 
 onMounted(() => {

+ 0 - 10
src/router/modules/dashboard.js

@@ -466,16 +466,6 @@ const route = [
                             activeMenu: '/inpatient/zhuYuanYiSheng/yiZhuLuRu',
                         },
                     },
-                    {
-                        path: 'electronicMedicalRecord',
-                        component: createNameComponent(() => import('../../views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/index.vue')),
-                        meta: {
-                            title: '电子病历',
-                            hideTabs: true,
-                            passRule: true,
-                            activeMenu: '/inpatient/zhuYuanYiSheng/yiZhuLuRu',
-                        },
-                    },
                 ],
             },
         ],

+ 0 - 255
src/views/hospitalization/EmrEditor.vue

@@ -1,255 +0,0 @@
-<template>
-  <el-row style="height: 100%;padding: 0" v-loading="isLoading">
-
-    <el-col :span="4" style="background-color: white">
-      <el-col>
-        <emr-sidebar @nodeClick="handleNodeClick" @typeChange="typeChange"/>
-      </el-col>
-
-    </el-col>
-
-    <el-col :span="20">
-      <el-col>
-        <div style="height: 40px">
-          <emr-selection style="width: 120px" v-model="editorModify.editorTitle"
-                         execute="defaultStyleId"
-                         @change="selectionChange"
-                         :data="editorTitle" styles="styles"/>
-          <emr-selection v-model="editorModify.availableFonts" :data="editorData.availableFonts"
-                         @change="selectionChange"
-                         code="font"
-                         execute="fontFamily"
-                         styles="styles"
-                         name="text"/>
-          <emr-selection style="width: 120px"
-                         v-model="editorModify.fontSizes"
-                         execute="fontSize"
-                         @change="selectionChange" :data="editorData.fontSizes"/>
-        </div>
-      </el-col>
-
-      <el-col style="width: 100%;height: calc(100% - 50px);overflow-y: clip">
-        <el-row style="height: 100%">
-          <el-col :span="2">
-            as范德贝克哈设计好的呢
-          </el-col>
-
-          <el-col :span="17">
-            <iframe style="width: 100%;height: 100%" :src="iframeSrc" ref="iframeRef"/>
-          </el-col>
-
-          <el-col :span="5">
-            这里是存放数据源的
-          </el-col>
-        </el-row>
-
-
-      </el-col>
-
-    </el-col>
-  </el-row>
-</template>
-
-<script>
-import {getTemplate} from "@/api/zhu-yuan-yi-sheng/emr-api";
-import store from "@/store";
-import {huanZheXinXi} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
-import {ref} from 'vue'
-import EmrSidebar from "@/components/zhu-yuan-yi-sheng/emr/EmrSidebar.vue";
-import EmrSelection from "@/components/zhu-yuan-yi-sheng/emr/EmrSelection.vue";
-
-export default {
-  name: 'EmrEditor',
-  components: {EmrSelection, EmrSidebar},
-  setup() {
-    const iframeSrc = '/emr/runtime/#/editor'
-    const templateType = ref(0)
-
-    let emrInit = null
-    const iframeRef = ref(null)
-    const isLoading = ref(true)
-    const editorData = ref({})
-    const editorTitle = [
-      {
-        code: "global_style_text",
-        name: "正文",
-        styles: "font-family: &quot;Microsoft YaHei&quot;; font-size: 12pt; font-weight: normal;"
-      },
-      {
-        code: "global_style_title",
-        name: "标题",
-        styles: "font-family: &quot;Microsoft YaHei&quot;; font-size: 22pt; font-weight: normal;"
-      },
-      {
-        code: "global_style_subtitle",
-        name: "副标题",
-        styles: "font-family: &quot;Microsoft YaHei&quot;; font-size: 20pt; font-weight: normal;"
-      },
-      {
-        code: "global_style_title_1",
-        name: "标题1",
-        styles: "font-family: &quot;Microsoft YaHei&quot;; font-size: 18pt; font-weight: normal;"
-      },
-      {
-        code: "global_style_title_2",
-        name: "标题2",
-        styles: "font-family: &quot;Microsoft YaHei&quot;; font-size: 16pt; font-weight: normal;"
-      },
-      {
-        code: "global_style_title_3",
-        name: "标题3",
-        styles: "font-family: &quot;Microsoft YaHei&quot; font-size: 14pt; font-weight: normal;"
-      },
-      {
-        code: "global_style_title_4",
-        name: "标题4",
-        styles: "font-family: &quot;Microsoft YaHei&quot;; font-size: 12pt; font-weight: normal;"
-      },
-      {
-        code: "global_style_title_5",
-        name: "标题5",
-        styles: "font-family: &quot;Microsoft YaHei&quot;; font-size: 11pt; font-weight: normal;"
-      }
-    ]
-    const editorModify = ref({
-      editorTitle: 'global_style_text',
-      availableFonts: 'SimSun',
-      fontSizes: '12pt'
-    })
-
-    const typeChange = (val) => {
-      console.log(val)
-    }
-
-    const handleNodeClick = (val) => {
-      getTemplate(val.code).then((res) => {
-        emrInit.editor.setDocument(res, true, true)
-      })
-    }
-
-
-    const getEditorData = () => {
-      let availableFonts = emrInit.editor.getAvailableFonts()
-      for (let i = 0, len = availableFonts.length; i < len; i++) {
-        availableFonts[i]['styles'] = `font-family:${availableFonts[i]['font']}`
-      }
-      dataAssignment('availableFonts', availableFonts)
-      dataAssignment('fontSizes', emrInit.editor.getFontSizes(), 'code')
-      console.log(editorData.value);
-    }
-
-    const dataAssignment = (name, data, code) => {
-      if (code) {
-        let keys = {}
-        let deduplication = []
-        for (let i = 0, len = data.length; i < len; i++) {
-          let item = data[i]
-          if (!keys[item[code]]) {
-            deduplication.push(item)
-            keys[item[code]] = item
-          }
-        }
-        editorData.value[name] = deduplication;
-      } else {
-        editorData.value[name] = data;
-      }
-    }
-
-    const selectionChange = (name, val, data) => {
-      console.log(name, val, data)
-      emrInit.editor.execute(name, {value: val})
-    }
-
-    onMounted(() => {
-      nextTick(() => {
-        emrInit = new EMRInteractive()
-        iframeRef.value.parentElement.emr = emrInit
-      })
-
-    })
-
-    return {
-      iframeSrc,
-      templateType,
-      handleNodeClick,
-      iframeRef,
-      isLoading,
-      editorModify,
-      typeChange,
-      editorData,
-      editorTitle,
-      selectionChange
-    }
-
-    function EMRInteractive(data) {
-      this.setEditor = (editor, runtime) => {
-        this.editor = editor;
-        this.runtime = runtime;
-
-        editor.on('loaded', function (event) {
-          getEditorData()
-          isLoading.value = false
-        })
-
-      };
-
-      this.getAppContext = () => {
-        return {
-          endpoints: {
-            app: "/bdp/dataservice/api",
-          },
-          input: {
-            user: store.state.user.info.code,
-            name: store.state.user.info.name
-          },
-          login: {
-            token: store.state.user.info.token
-          },
-          data
-        };
-      };
-
-      this.loadDocument = (result) => {
-        this.runtime.loadDocument(
-            result => {
-              console.log(result)
-            }
-        )
-      }
-
-      this.saveDocument = (cb) => {
-        let data = this.editor.getDocument();
-        data.properties.patientId = huanZheXinXi.value.inpatientNo;
-        data.properties.creator = store.state.user.info.code;
-        data.properties.createTime = new Date()
-        data.properties.modifier = store.state.user.info.code;
-        data.properties.modifyTime = new Date()
-        this.runtime.saveDocument(
-            data,
-            (res) => {
-              console.log("emr保存成功", res);
-            },
-            (err) => {
-              console.log("emr保存失败", err);
-            }
-        );
-      };
-      this.deleteDocument = (cb) => {
-        this.runtime.delDocument(documentId, (res) => {
-          console.log(res)
-        });
-      };
-      this.printDocument = (showPreview, docs = null) => {
-        console.log(showPreview, docs)
-        console.log('print document.')
-      };
-    }
-  }
-}
-
-
-</script>
-
-<style scoped>
-
-</style>

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

@@ -1,43 +1,39 @@
-import store from "@/store";
-import {ElMessage} from "element-plus";
+import {ElMessage, ElMessageBox} from "element-plus";
 import {BizException, ExceptionEnum} from "@/utils/BizException";
 import {deletePatientEmrByDocumentId, insertEmrData} from "@/api/zhu-yuan-yi-sheng/emr-patient";
-import {clone} from "@/utils/clone";
 
-export function EMRInteractive(data, loaded) {
+export function EMRInteractive(data, endiorEvent) {
     this.setEditor = (editor, runtime) => {
         this.editor = editor;
         this.runtime = runtime;
 
         editor.on('loaded', function (event) {
-            loaded(event)
+            endiorEvent(event)
         })
 
         editor.on('contentchange', function (event) {
-            loaded(event)
+            endiorEvent(event)
         })
 
     };
 
-    this.setDocument = (data, isRender, clearUndoStack) => {
-        this.editor.setDocument(data, isRender, clearUndoStack)
+    this.callMethod = (name, ...value) => {
+        this.editor[name](...value)
     }
 
-    this.setEditorMode = (value) => {
-        this.editor.setEditorMode(value)
-    }
-
-    this.insertSnippet = (content, styles, patientData) => {
+    this.insertSnippet = (content, styles) => {
         //病历片段相关参数
         let insertContent = {
             // 内容
             value: content,
             // 样式
             styles: styles,
-            // 默认值
-            data: patientData,
             isFragment: true,
+            // 默认值
+            defaultData: data
         }
+        console.log(data)
+
         this.editor.execute("insertContents", insertContent);
     }
 
@@ -46,20 +42,20 @@ export function EMRInteractive(data, loaded) {
             endpoints: {
                 app: "/bdp/dataservice/api",
             }, input: {
-                user: store.state.user.info.code, name: store.state.user.info.name
+                user: data.user_code, name: data.name
             }, login: {
-                token: store.state.user.info.token
+                token: data.user_token
             }, data
         };
     };
 
-    this.saveDocument = (value) => {
+    this.saveDocument = (value, successfullySaved, failedToSave) => {
         let data = this.editor.getDocument();
         data.properties.categoryCode = value.emrCategoryCode
         data.properties.patientId = value.patNo;
-        data.properties.creator = store.state.user.info.code;
+        data.properties.creator = data.user_code;
         data.properties.createTime = new Date()
-        data.properties.modifier = store.state.user.info.code;
+        data.properties.modifier = data.user_code;
         data.properties.modifyTime = new Date()
         data._id = value.emrDocumentId
         let validator = this.editor.getValidator();
@@ -70,9 +66,14 @@ export function EMRInteractive(data, loaded) {
         }
 
         this.runtime.saveDocument(data, (res) => {
-
-            insertEmrData(value)
-
+            insertEmrData(value).then(() => {
+                successfullySaved()
+            }).catch(async (e) => {
+                await ElMessageBox.alert('保存失败,请重新保存,' + e, '提示', {
+                    type: "warning"
+                })
+                failedToSave(value.emrDocumentId)
+            })
         }, (err) => {
 
             ElMessage.error("emr保存失败," + err)
@@ -102,3 +103,4 @@ export function EMRInteractive(data, loaded) {
         })
     };
 }
+

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

@@ -13,6 +13,10 @@
       </div>
       <el-button style="margin-left: 5px" type="primary" icon="Printer" @click="testPrint">打印电子病历</el-button>
       <el-button icon="RefreshLeft" @click="refreshPage">刷新页面</el-button>
+
+      <el-switch v-model="reviewMode" active-color="#ff4949" active-text="关闭审阅" :active-value="false"
+                 inactive-color="#13ce66" inactive-text="开启审阅" :inactive-value="true">
+      </el-switch>
     </el-header>
 
     <el-container>
@@ -36,7 +40,7 @@
           </el-col>
 
           <el-col :span="4" style="background-color: white">
-            <emr-snippet @node-click="clickSnippet"/>
+            <emr-snippet @node-click="clickSnippet" :patientData="patientData"/>
           </el-col>
 
         </el-row>
@@ -60,6 +64,7 @@ import {BizException, ExceptionEnum} from "@/utils/BizException";
 import router from '@/router'
 import EmrSnippet from "@/components/zhu-yuan-yi-sheng/emr/EmrSnippet.vue";
 import sleep from "@/utils/sleep";
+import store from "@/store";
 
 const emit = defineEmits(['refreshPage'])
 
@@ -82,6 +87,8 @@ let loaded = $ref(false)
 let isEditorChange = $ref(false)
 // 患者数据
 let patientData = $ref({})
+// 是否开启审阅模式
+let reviewMode = $ref(false)
 
 const updateCaseHistoryUrl = (val) => {
   let valCode = val.code ? val.code : val.emrCategoryCode;
@@ -98,7 +105,9 @@ const updateCaseHistoryUrl = (val) => {
 
 
 const refreshPage = () => {
-  emit('refreshPage', '电子病历')
+  checkEmrChange(() => {
+    emit('refreshPage', '电子病历')
+  })
 }
 
 const clearData = async () => {
@@ -114,6 +123,8 @@ const clearData = async () => {
 
 const clickSaveData = () => {
 
+  waitForLoadingToComplete()
+
   let data = {
     emrDocumentId: documentId ? documentId : uuid(31, 62),
     emrCategoryCode: categoryCode,
@@ -124,20 +135,29 @@ const clickSaveData = () => {
 
   objectValuesCannotBeNull(data)
 
-  ElMessageBox.prompt('请输入保存的名称,自动带上日期', '提示', {
+  ElMessageBox.prompt('请输入保存的名称', '提示', {
     inputErrorMessage: '长度为2 - 20 个,汉字',
     inputPattern: /^\S{2,20}$/,
     inputValue: templateName
   }).then(async ({value}) => {
     data.name = value
-    await currentEmr.value.saveDocument(data)
-    isEditorChange = false
-    // clearData()
+    await currentEmr.value.saveDocument(data, () => {
+      isEditorChange = false
+    }, (err) => {
+      documentId = err
+      isEditorChange = true
+    })
   }).catch(() => {
 
   })
 }
 
+const waitForLoadingToComplete = () => {
+  if (loaded) {
+    BizException(ExceptionEnum.MESSAGE_ERROR, "请等待加载成功。")
+  }
+}
+
 const objectValuesCannotBeNull = (object) => {
   if (!object.emrCategoryCode) {
     BizException(ExceptionEnum.LOGICAL_ERROR, "请先选择模板")
@@ -151,10 +171,12 @@ const objectValuesCannotBeNull = (object) => {
 }
 
 const testPrint = () => {
+  waitForLoadingToComplete()
   currentEmr.value.printDocument(true, null);
 }
 
 const clickDelete = () => {
+  waitForLoadingToComplete()
   whetherThereIsAMedicalRecordId()
   ElMessageBox.alert('是否要删除该模板。', '提示', {
     type: 'warning'
@@ -211,16 +233,18 @@ const nodeClick = (val, templateType) => {
 }
 
 
-const editorEvents = ({name}) => {
+const editorEvents = ({name}, fragment) => {
   if (name === 'loaded') {
     loaded = false
     if (times !== huanZheXinXi.value.admissTimes) {
       // 如果住院次数不一致 那么就是历史记录 那就只能只读了
-      currentEmr.value.setEditorMode('readonly');
+      currentEmr.value.callMethod('setEditorMode', 'readonly')
     } else {
       // 设置成编辑模式
-      currentEmr.value.setEditorMode('free');
+      currentEmr.value.callMethod('setEditorMode', 'free')
     }
+    // currentEmr.value.callMethod('setReviewMode', reviewMode)
+
   } else if (name === 'contentchange') {
     // 判断内容是否改变
     isEditorChange = true
@@ -244,8 +268,20 @@ const clickSnippet = ({content, styles}) => {
   currentEmr.value.insertSnippet(content, styles, patientData)
 }
 
-const fillInUserInformation = () => {
-  console.log(patientData)
+const getCurrentPersonnelInformation = (data) => {
+  let userData = store.state.user.info
+
+  patientData.user_selection = [{code: userData.code, name: userData.name}]
+  patientData.user_code = userData.code
+  patientData.user_name = userData.name
+
+  patientData.user_dept_selection = [{code: userData.deptCode, name: userData.deptName}]
+  patientData.user_dept_code = userData.deptCode
+  patientData.user_dept_name = userData.deptName
+
+  patientData.user_token = userData.token
+
+  console.log(data)
 }
 
 onMounted(() => {
@@ -256,12 +292,16 @@ onMounted(() => {
       patNo: huanZheXinXi.value.inpatientNo,
       times: huanZheXinXi.value.admissTimes
     })
+
+    getCurrentPersonnelInformation(patientData)
+
     patientId = huanZheXinXi.value.inpatientNo
     currentEmr.value = new EMRInteractive(patientData, editorEvents);
     emrRef.value.parentElement.emr = currentEmr.value
 
     window.addEventListener('beforeunload', monitorPageRefresh)
 
+
   })
 
 })