Browse Source

电子病历

DESKTOP-MINPJAU\Administrator 3 years ago
parent
commit
88bd6a8f47

+ 29 - 0
src/api/zhu-yuan-yi-sheng/emr-api.js

@@ -64,3 +64,32 @@ export async function getSnippet() {
     })
     return getTree(data, '_id', 'parent')
 }
+
+export async function getDataByDocumentId(documentId) {
+    let data = await service({
+        url: `document/docs/data/${documentId}`,
+        method: 'get'
+    })
+    let returnData = {}
+    if (data) {
+        for (let key in data) {
+            let item = data[key].element
+            console.log(item.code)
+            if (item.code) {
+                if (item.code.business) {
+                    if (item.code.business === 'ward_round_time') {
+                        console.log('查房时间', item)
+                    }
+                }
+            }
+            // if (item.code && item.code.business && item.code.business === 'ward_round_time') {
+            //     if (item.value) {
+            //         returnData['查房时间' + item.value] = item.value
+            //     }
+            // }
+            // console.log(item);
+        }
+    }
+    console.log(returnData)
+    console.log(data);
+}

+ 87 - 0
src/components/zhu-yuan-yi-sheng/emr/EmrMain.vue

@@ -0,0 +1,87 @@
+<template>
+  <div class="emr-iframe" v-loading="loaded">
+    <iframe id="emrIframe"
+            ref="emrRef"
+            :src="caseHistoryUrl"/>
+  </div>
+</template>
+
+<script setup name='EmrMain'>
+import {getEmrInpatientData} from "@/api/dictionary/emr-data-maintenance-api";
+import {huanZheXinXi} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
+import {EMRInteractive} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-init";
+import store from "@/store";
+
+let caseHistoryUrl = $ref('')
+
+let patientData = $ref({})
+let loaded = $ref(true)
+let patientId = $ref('')
+let isEditorChange = $(false)
+let times = $ref(0)
+
+const emrRef = ref(null)
+const currentEmr = ref(null)
+
+onMounted(() => {
+  nextTick(async () => {
+    patientData = await getEmrInpatientData({
+      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)
+
+  })
+})
+
+
+const monitorPageRefresh = (event) => {
+  if (isEditorChange) {
+    event.returnValue = false;
+  }
+}
+
+const editorEvents = ({name}, fragment) => {
+  if (name === 'loaded') {
+    loaded = false
+    if (times !== huanZheXinXi.value.admissTimes) {
+      // 如果住院次数不一致 那么就是历史记录 那就只能只读了
+      currentEmr.value.callMethod('setEditorMode', 'readonly')
+    } else {
+      // 设置成编辑模式
+      currentEmr.value.callMethod('setEditorMode', 'free')
+    }
+    // currentEmr.value.callMethod('setReviewMode', reviewMode)
+
+  } else if (name === 'contentchange') {
+    // 判断内容是否改变
+    isEditorChange = true
+    // emrSidebarRef.changeTemplateType(2)
+  }
+}
+
+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
+
+}
+
+</script>
+
+<style scoped>
+
+</style>

+ 19 - 2
src/components/zhu-yuan-yi-sheng/emr/EmrSidebar.vue

@@ -27,6 +27,8 @@ let returnData = $ref([])
 let filterText = $ref('')
 let treeRef = $ref('')
 
+let key = ''
+
 const defaultProps = {
   children: 'children',
   label: 'name',
@@ -35,7 +37,11 @@ const defaultProps = {
 let templateType = $ref(0)
 
 const handleNodeClick = (val) => {
-  emit('nodeClick', val, templateType)
+  let str = JSON.stringify(val)
+  if (key !== str) {
+    key = str
+    emit('nodeClick', val, templateType);
+  }
 }
 
 const typeChange = (val) => {
@@ -70,13 +76,24 @@ const changeTemplateType = (val) => {
   typeChange(val)
 }
 
-defineExpose({queryHistory, changeTemplateType})
+const deleteTheSpecifiedNode = (id) => {
+  for (let i = 0, len = returnData.patientTree.length; i < len; i++) {
+    let item = returnData.patientTree[i]
+    if (item.emrDocumentId === id) {
+      returnData.patientTree.splice(i, 1)
+      return
+    }
+  }
+}
+
+defineExpose({queryHistory, changeTemplateType, deleteTheSpecifiedNode})
 
 onMounted(() => {
   nextTick(() => {
     getEmrTree(huanZheXinXi.value.inpatientNo, huanZheXinXi.value.admissTimes).then((res) => {
       treeData = res.emrTree
       returnData = res
+      console.log(res)
     })
   })
 })

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

@@ -18,7 +18,7 @@ export function EMRInteractive(data, endiorEvent) {
     };
 
     this.callMethod = (name, ...value) => {
-        this.editor[name](...value)
+        return this.editor[name](...value)
     }
 
     this.insertSnippet = (content, styles) => {

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

@@ -5,7 +5,7 @@
       <el-button icon="ArrowLeft" style="font-size: 14px" text @click="clickBack">返回</el-button>
       住院次数:
       <el-input-number :min="1" :max="huanZheXinXi.admissTimes" v-model="times"/>
-      <el-button @click="queryHistoricalInformation">历史记录</el-button>
+      <el-button @click="resetData">历史记录</el-button>
 
       <div v-if="times === huanZheXinXi.admissTimes">
         <el-button type="success" icon="CircleCheck" @click="clickSaveData">保存数据</el-button>
@@ -30,12 +30,11 @@
         <el-row>
 
           <el-col :span="20">
-            <div class="emr-iframe" name="emr">
-
+            <!--            <emr-main/>-->
+            <div class="emr-iframe">
               <iframe id="emrIframe"
                       ref="emrRef"
                       :src="caseHistoryUrl"/>
-
             </div>
           </el-col>
 
@@ -63,7 +62,6 @@ import {uuid} from "@/utils/getUuid";
 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'])
@@ -92,9 +90,6 @@ let reviewMode = $ref(false)
 
 const updateCaseHistoryUrl = (val) => {
   let valCode = val.code ? val.code : val.emrCategoryCode;
-  if (documentId === val.emrDocumentId && categoryCode === valCode) {
-    return
-  }
   loaded = true
   isEditorChange = false
   documentId = val.emrDocumentId;
@@ -110,17 +105,6 @@ const refreshPage = () => {
   })
 }
 
-const clearData = async () => {
-  loaded = true
-  documentId = ''
-  categoryCode = ''
-  templateName = ''
-  patientId = ''
-  categroyId = ''
-  await sleep(500)
-  loaded = false
-}
-
 const clickSaveData = () => {
 
   waitForLoadingToComplete()
@@ -182,7 +166,8 @@ const clickDelete = () => {
     type: 'warning'
   }).then(() => {
     currentEmr.value.deleteDocument(documentId, function () {
-      refreshPage()
+      emrSidebarRef.deleteTheSpecifiedNode(documentId)
+      nodeClick({}, 2)
     });
   }).catch(() => {
 
@@ -192,11 +177,11 @@ const clickDelete = () => {
 
 const whetherThereIsAMedicalRecordId = () => {
   if (!documentId) {
-    BizException(ExceptionEnum.MESSAGE_ERROR, "请先选择电子病历的模板。")
+    BizException(ExceptionEnum.MESSAGE_ERROR, "请先选择患者的病历。")
   }
 }
 
-const queryHistoricalInformation = () => {
+const resetData = () => {
   checkEmrChange(() => {
     nodeClick({}, 0)
     emrSidebarRef.queryHistory(times);
@@ -243,7 +228,10 @@ const editorEvents = ({name}, fragment) => {
       // 设置成编辑模式
       currentEmr.value.callMethod('setEditorMode', 'free')
     }
-    // currentEmr.value.callMethod('setReviewMode', reviewMode)
+    if (categoryCode === "bingchengjiluzhuanyong" && documentId) {
+      console.log(currentEmr.value.callMethod('getElementsData'));
+      console.log("这个是病程记录")
+    }
 
   } else if (name === 'contentchange') {
     // 判断内容是否改变
@@ -307,7 +295,6 @@ onMounted(() => {
 })
 
 onDeactivated(() => {
-  console.log(123)
   window.removeEventListener('beforeunload', monitorPageRefresh)
 })