Browse Source

电子病历中可以查看全员的患者但是只有自己科室才能修改

DESKTOP-0GD05B0\Administrator 2 years ago
parent
commit
8071d2df8e

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

@@ -23,8 +23,9 @@
 
       <emr-assistant :data="openAssistant" :to-fill-in-data="clickToFillInData"/>
       <el-switch v-model="reviewMode" active-color="#ff4949" active-text="关闭审阅" :active-value="false"
-                 inactive-color="#13ce66" inactive-text="开启审阅" :inactive-value="true">
-      </el-switch>
+                 inactive-color="#13ce66" inactive-text="开启审阅" :inactive-value="true"/>
+      <span style="color: red;margin-left: 10px">{{ currentMode() }}</span>
+
     </el-header>
 
     <el-container>
@@ -90,6 +91,9 @@ const props = defineProps({
   editor: {
     type: Boolean,
     default: true
+  },
+  visitor: {
+    type: Boolean
   }
 })
 
@@ -110,9 +114,7 @@ let openAssistant = $ref({
 })
 
 // 编辑器
-let editor = null
-// 患者历史记录
-let tempTimes = $ref(props.huanZheXinXi.admissTimes)
+let editor = $ref(null)
 // 侧边栏
 const emrSidebarRef = ref(null)
 // 片段预览
@@ -134,8 +136,18 @@ let jumpPositioning = {
 // 创建人 id
 let createId = null
 
+const currentMode = () => {
+  return editor?.getEditorMode() === 'readonly' ? '只读' : '编辑'
+}
+
 
+// 点击保存病历
 const clickSaveData = async () => {
+  // 只读模式无法保存数据
+  if (editor !== null && editor.getEditorMode() === 'readonly') {
+    BizException(ExceptionEnum.LOGICAL_ERROR, "无法保存病历。");
+  }
+
   waitForLoadingToComplete()
   let data = {
     // 这个是 唯一 id 调用服务的雪花算法
@@ -226,12 +238,11 @@ const servicePrint = () => {
  * 点击删除数据
  */
 const clickDelete = () => {
+  if (editor !== null && editor.getEditorMode() === 'readonly') {
+    BizException(ExceptionEnum.LOGICAL_ERROR, "无法删除病历。");
+  }
   waitForLoadingToComplete()
   whetherThereIsAMedicalRecordId()
-  // deletePatientEmrByDocumentId(documentId).then(() => {
-  //
-  // })
-  // return
   ElMessageBox.alert('是否要删除该模板。', '提示', {
     type: 'warning'
   }).then(() => {
@@ -273,6 +284,9 @@ const checkEmrChange = (cb) => {
 
 const nodeClick = (val, jumpOrNot, templateType) => {
   createId = val.createId ? val.createId : null
+  if (props.huanZheXinXi.smallDept !== userData.deptCode && createId === null) {
+    BizException(ExceptionEnum.LOGICAL_ERROR, "无法创建病历,患者不属于您的科室")
+  }
   if (jumpOrNot) {
     if (val.documentId === documentId) {
       positioningTime(val.value, val.code)
@@ -339,8 +353,10 @@ const monitorPageRefresh = (event) => {
  * @param styles
  */
 const clickSnippet = ({content, styles}) => {
-  currentEmr.value.callMethod('setCursor', 'AREA_END')
-  currentEmr.value.insertSnippet(content, styles, patientData)
+  if (editor !== null && editor.getEditorMode() !== 'readonly') {
+    currentEmr.value.callMethod('setCursor', 'AREA_END')
+    currentEmr.value.insertSnippet(content, styles, patientData)
+  }
 }
 
 // 用户信息
@@ -357,6 +373,7 @@ const getCurrentPersonnelInformation = (data) => {
   patientData['编辑者科室'] = [{code: userData.deptCode, name: userData.deptName}]
   patientData['编辑者科室编码'] = userData.deptCode
   patientData['编辑者科室名称'] = userData.deptName
+
   patientData.user_token = userData.token
 }
 
@@ -378,10 +395,6 @@ const emrEvent = {
       emrSidebarRef.value.changeTemplateType(2)
     }
   },
-
-  'insertFragment': (evt, view, nodes, fragment, defaultData) => {
-    // 片段插入就会执行这个方法
-  }
 }
 
 
@@ -390,14 +403,16 @@ const setEditorModeFun = () => {
   if (props.editor) {
     // 设置成编辑模式
     currentEmr.value.callMethod('setEditorMode', 'free')
-    // 创建人不是自己就只能看
-    if (createId !== null && createId !== userData.code) {
+    if (categoryCode.includes('shoucibingchengjilu')) {
+      // 如果是病程记录就不用锁住,因为要根据片段锁住
+      currentEmr.value.callMethod('setEditorMode', 'free')
+    } else if (createId !== null && createId !== userData.code) {
+      // 创建人不是自己就只能看
       currentEmr.value.callMethod('setEditorMode', 'readonly')
     }
   } else {
     currentEmr.value.callMethod('setEditorMode', 'readonly')
   }
-
 }
 
 /**
@@ -489,12 +504,7 @@ const reQueryPatientInformation = () => {
  *  撤销或者重做
  */
 const clickUndo = (val) => {
-  try {
-    editor.execute(val)
-  } catch (e) {
-
-  }
-
+  editor.execute(val)
 }
 
 /**

+ 46 - 4
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/Home.vue

@@ -4,7 +4,7 @@
   次数 ({{ maxTimes }}) :
   <el-input-number v-model="times" @keydown.enter="disPatients"/>
   <el-button @click="disPatients">出院患者</el-button>
-  <el-button>转科患者</el-button>
+  <el-button @click="allPatientsInTheHospital">全院患者</el-button>
   出院天数:{{ dischargeDays }}
   <span style="color: red">出院七天后就无法编辑患者病历</span>
   <div v-if="show">
@@ -30,15 +30,24 @@ import {subtractTime} from "@/utils/date";
 
 const divRef = ref(null)
 
+// 最大高度
 let maxHeight = $ref()
+// 编辑模式
 let editor = $ref(false)
+// 是否显示页面
 let show = $ref(false)
+// 获取患者信息
 let patientInfo = $ref()
-let patNo = $ref('0413224')
-let times = $ref(1)
+// 住院号
+let patNo = $ref('') // 0413224
+// 住院次数
+let times = $ref(1) // 1
+// 最大住院次数
 let maxTimes = $ref(0)
+// 距离今天的出院天数
 let dischargeDays = $ref(0)
 
+// 获取最大住院次数
 const getMaxTimes = () => {
   getDischargeTimes(patNo).then((res) => {
     times = res
@@ -46,6 +55,7 @@ const getMaxTimes = () => {
   })
 }
 
+// 点击查询出院患者
 const disPatients = async () => {
   if (times === 0 || !patNo) {
     BizException(ExceptionEnum.MESSAGE_ERROR, '请输入住院号,住院次数不能为 0 ')
@@ -66,16 +76,20 @@ const disPatients = async () => {
   location.reload()
 }
 
+// 解析路由数据
 const routerFunc = async () => {
   if (router.currentRoute.value.query.pat) {
     let temp = JSON.parse(window.atob(router.currentRoute.value.query.pat))
     patNo = temp.patNo
     times = temp.times
+    console.log(temp)
     if (temp.state === 1) {
       await queryActPatient()
-    } else {
+    } else if (temp.state === 2) {
       maxTimes = temp.maxTimes
       await queryDisPatient()
+    } else if (temp.state === 3) {
+      await queryAllPatients()
     }
     await nextTick()
     maxHeight = window.innerHeight - divRef.value?.clientHeight
@@ -99,6 +113,34 @@ const queryDisPatient = async () => {
   show = true
 }
 
+// 点击全员患者数据
+const allPatientsInTheHospital = async () => {
+  if (!patNo) {
+    BizException(ExceptionEnum.MESSAGE_ERROR, '请输入住院号。 ')
+  }
+  let query = {
+    patNo: patNo,
+    times: times,
+    maxTimes: maxTimes,
+    state: 3
+  }
+  let te = JSON.stringify(query)
+  await router.push({
+    name: 'emrEditor',
+    query: {
+      pat: window.btoa(te)
+    }
+  })
+  location.reload()
+}
+
+
+const queryAllPatients = async () => {
+  patientInfo = await getPatientInfo(patNo)
+  show = true
+  editor = true
+}
+
 onActivated(async () => {
   await routerFunc()
 })