Browse Source

病历可以恢复到上一个病历

DESKTOP-0GD05B0\Administrator 2 years ago
parent
commit
a483c04c4d

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

@@ -184,5 +184,13 @@ export function isDisReqEdit(patNo) {
     })
 }
 
+export function getHistory(documentId) {
+    return request({
+        url: url + 'getHistory',
+        method: 'get',
+        params: {documentId}
+    })
+}
+
 
 

+ 2 - 1
src/components/xiao-chan/dialog/XcDialogV2.vue

@@ -1,6 +1,7 @@
 <template>
   <div class="xc-dialog-v2" ref="dialogRef">
-    <el-dialog v-model="dialog" :title="props.title"
+    <el-dialog v-model="dialog"
+               :title="props.title"
                :show-close="false"
                draggable
                :width="props.width"

+ 110 - 0
src/components/zhu-yuan-yi-sheng/emr/HistoricalEmr.vue

@@ -0,0 +1,110 @@
+<template>
+  <xc-dialog-v2 v-model="dialog"
+                :maximize="true"
+                title="还原病历"
+                @closed="emit('closed')">
+    <div class="historical__main">
+      <div class="historical__left">
+        <el-table :data="historicalData"
+                  highlight-current-row
+                  @row-click="rowClick">
+          <el-table-column fixed="left" label="操作">
+            <template #default="{row}">
+              <el-button @click.stop="restoreData(row)">还原</el-button>
+            </template>
+          </el-table-column>
+          <el-table-column label="创建人" prop="properties.creator"/>
+          <el-table-column label="创建时间" prop="properties.createTime">
+            <template #default="{row}">
+              {{ getFormatDatetime(row.properties.createTime) }}
+            </template>
+          </el-table-column>
+          <el-table-column label="修改人" prop="properties.modifier"/>
+          <el-table-column label="修改时间" prop="properties.modifyTime">
+            <template #default="{row}">
+              {{ getFormatDatetime(row.properties.modifyTime) }}
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <div class="historical__iframe">
+        <iframe
+            ref="emrRef"
+            width="100%"
+            height="700px"
+            src="/emr/runtime/#/editor"/>
+      </div>
+    </div>
+
+  </xc-dialog-v2>
+</template>
+
+<script setup name='HistoricalEmr' lang="ts">
+import XcDialogV2 from "@/components/xiao-chan/dialog/XcDialogV2.vue";
+import {nextTick, onMounted, ref} from "vue";
+import {EMRInteractive} from '@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-init'
+import {getHistory} from '@/api/zhu-yuan-yi-sheng/emr-patient'
+import {getFormatDatetime} from '@/utils/date'
+import {ElMessageBox} from "element-plus";
+
+const props = defineProps({
+  docunentId: {
+    type: String
+  }
+})
+const emit = defineEmits(['closed', 'restoreData'])
+
+const dialog = ref(true)
+const emrRef = ref(null)
+const currentEmr = ref(null)
+const historicalData = ref([])
+
+let editor = null
+
+const emrEvent = {
+  'ready': (event) => {
+    editor = currentEmr.value.getEditor()
+  }
+}
+
+const rowClick = (row) => {
+  editor.setDocument(row)
+}
+
+const restoreData = (row) => {
+  ElMessageBox.confirm('是否要还原到此节点。', '提示', {
+    type: 'warning'
+  }).then(() => {
+    delete row.documentId
+    delete row.reversion
+    emit('restoreData', row)
+  }).catch(() => {
+
+  })
+
+}
+
+onMounted(async () => {
+  await nextTick()
+  currentEmr.value = new EMRInteractive(null, emrEvent);
+  emrRef.value.parentElement.emr = currentEmr.value
+  getHistory(props.docunentId).then((res) => {
+    historicalData.value = res as Array<any>;
+  })
+})
+</script>
+
+<style scoped lang="scss">
+.historical__main {
+  display: flex;
+
+  .historical__left {
+    width: 220px;
+    height: 100%;
+  }
+
+  .historical__iframe {
+    flex: 1;
+  }
+}
+</style>

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

@@ -19,7 +19,15 @@
                    @click="clickDelete">
           删除
         </el-button>
+        <el-button @click="recoveryDialog = true">
+          恢复
+        </el-button>
       </el-button-group>
+      <!--   恢复到上一次保存的状态   -->
+      <historical-emr v-if="recoveryDialog"
+                      @closed="recoveryDialog = false"
+                      :docunent-id="documentId"
+                      @restore-data="restoreData"/>
       <el-divider direction="vertical"/>
       <el-button-group>
         <el-button type="primary" icon="Printer" @click="frontEndPrinting"
@@ -45,6 +53,7 @@
           DRG分组
         </el-button>
       </el-button-group>
+      <!--   手术数据填充   -->
       <emr-assistant :data="openAssistant" :to-fill-in-data="clickToFillInData"/>
       <el-divider direction="vertical"/>
       <el-select v-model="reviewMode"
@@ -290,6 +299,8 @@ import XcDialogV2 from "@/components/xiao-chan/dialog/XcDialogV2.vue";
 import {getWardsApi} from "@/api/login";
 import {xcMessage} from "@/utils/xiaochan-element-plus";
 import EmrUnorderedList from "@/components/zhu-yuan-yi-sheng/emr/EmrUnorderedList.vue";
+import HistoricalEmr from "@/components/zhu-yuan-yi-sheng/emr/HistoricalEmr.vue";
+import {stringIsBlank} from "@/utils/blank-utils";
 
 const props = defineProps({
   huanZheXinXi: {
@@ -309,7 +320,7 @@ const props = defineProps({
 const currentEmr = ref(null)
 const emrRef = ref(null)
 
-
+let recoveryDialog = $ref(false)
 let categoryCode = $ref('')
 // 文档 id 唯一值
 let documentId = $ref('')
@@ -440,7 +451,7 @@ const emrEvent = {
 const clickSaveData = async () => {
   // 只读模式无法保存数据
   if (readonlyPattern()) {
-    BizException(ExceptionEnum.LOGICAL_ERROR, "无法保存病历。");
+    BizException(ExceptionEnum.LOGICAL_ERROR, "当前为只读模式,无法保存病历。");
   }
   waitForLoadingToComplete()
   // 判断是否有必填项目
@@ -449,9 +460,9 @@ const clickSaveData = async () => {
   if (valid) {
     BizException(ExceptionEnum.MESSAGE_ERROR, "有必填项不能为空,请仔细检查,红色输入框.")
   }
+  await analysisIframeSrcSearch()
   let data = {
-    // 这个是 唯一 id 调用服务的雪花算法
-    emrDocumentId: documentId ? documentId : await getUuid(),
+    emrDocumentId: documentId,
     emrCategoryCode: categoryCode,
     patNo: props.huanZheXinXi.inpatientNo,
     times: props.huanZheXinXi.admissTimes,
@@ -460,12 +471,11 @@ const clickSaveData = async () => {
   }
   objectValuesCannotBeNull(data)
   data.emrDataElement = editor.getDataElements('business')
-
   ElMessageBox.prompt('请输入保存的名称', '提示', {
     inputErrorMessage: '长度为2 - 20 个,汉字',
     inputPattern: /^\S{2,20}$/,
     inputValue: templateName
-  }).then(async ({value}) => {
+  }).then(({value}) => {
     data.name = value
     currentEmr.value.saveDocument(data).then(res => {
       // 把提取到的数据放到 patientData 中.
@@ -625,7 +635,7 @@ const updateCaseHistoryUrl = async (val) => {
   if (temp === caseHistoryUrl) return
   loaded = true
   isEditorChange = false
-  documentId = val.documentId;
+  documentId = val.documentId
   categoryCode = val.categoryCode
   templateName = val.name
   categoryId = val.categoryId
@@ -731,8 +741,9 @@ const setEditorModeFun = () => {
     currentEmr.value.callMethod('setEditorMode', 'free')
     // 如果不是首次病程记录就需要执行下面的代码
     if (!categoryCode.includes('shoucibingchengjilu')) {
+      // 如果创建人是空的就说明是第一次创建
       if (createId === null) {
-        return currentEmr.value.callMethod('setEditorMode', 'readonly');
+        return currentEmr.value.callMethod('setEditorMode', 'free');
       }
       // 创建人不是自己就只能看
       if (doctorLevel === 1 && createId !== userData.code) {
@@ -1114,6 +1125,29 @@ const buttonClass = (val, activation = true) => {
 }
 
 
+/**
+ * 解析 iframe 上面的参数保证一致
+ */
+const analysisIframeSrcSearch = async () => {
+  // 先一步转成 url 不然 URLSearchParams 不会解析第一个参数
+  const url = new URL('http://localhost' + caseHistoryUrl);
+  const args = new URLSearchParams(url.search);
+  documentId = args.get('documentId')
+  // 如果没有的话就去服务器要一个
+  if (documentId === null || documentId === 'null') {
+    // 这个是 唯一 id 调用服务的雪花算法
+    documentId = await getUuid()
+  }
+}
+
+// 恢复历史数据
+const restoreData = (data) => {
+  editor.setDocument(data)
+  xcMessage.success('恢复成功,请点击保存。')
+  recoveryDialog = false
+}
+
+
 onMounted(() => {
   getExtractDataElement(props.huanZheXinXi.inpatientNo, props.huanZheXinXi.admissTimes).then((res) => {
     extractData = res

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

@@ -86,14 +86,21 @@ export function EMRInteractive(data, editorEvent) {
 
     this.saveDocument = (value) => {
         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
+
+        if (document.properties.creator) {
+            document.properties.modifier = data['编辑者姓名'];
+            document.properties.modifierId = data['编辑者编码'];
+            document.properties.modifyTime = new Date()
+        } else {
+            document.properties.creator = data['编辑者姓名'];
+            document.properties.creatorId = data['编辑者编码'];
+            document.properties.createTime = new Date()
+        }
         return insertEmrData(value)
     };