Преглед на файлове

添加自然语言处理功能

cc12458 преди 10 месеца
родител
ревизия
deca13cfe4
променени са 3 файла, в които са добавени 80 реда и са изтрити 2 реда
  1. 20 0
      src/api/diagnosis.js
  2. 1 1
      src/utils/request.js
  3. 59 1
      src/views/diagnosis/Emr.vue

+ 20 - 0
src/api/diagnosis.js

@@ -20,6 +20,26 @@ export function getEmrShowMsg(data) {
     })
 };
 
+// 获取自然语义分析 中医电子病历回显信息
+export function getNLP_TemplateResult(text) {
+    return request({
+        url: `https://dev.hzliuzhi.com:62006/tcm_chat/json/record`,
+        method: 'post',
+        data: {
+            message: text,
+        },
+    }).then(res => {
+        if (res.code === 200) {
+            const {fourmedicine: value, ...data} = res.data;
+            return {
+                ...data,
+                echoData: value ? typeof value === 'string' ? value : JSON.stringify(value) : '{}',
+            };
+        }
+        throw new Error(res.message);
+    });
+}
+
 
 // 提交诊断页面数据
 export function addDiagnosisData(data) {

+ 1 - 1
src/utils/request.js

@@ -54,7 +54,7 @@ service.interceptors.response.use(
 
       return res
     }
-
+    if (response.config.url.startsWith(`https://dev.hzliuzhi.com`)) return res;
 
     if (response.headers['access-control-expose-headers']) {
       let str = response.headers['access-control-expose-headers'].split(';')

+ 59 - 1
src/views/diagnosis/Emr.vue

@@ -4,6 +4,7 @@
       <span>{{temItem.templateName}}</span>
       <div class="button">
         <!--<el-button type="success" size="mini" @click="handleHisMsg()">回传HIS(JS通知)</el-button>-->
+        <el-button type="primary" size="mini" @click="showAiDialog = true">自然语言处理</el-button>
         <el-button type="primary" size="mini" @click="handleHis()">回传HIS</el-button>
         <el-button type="primary" size="mini" @click="submit()">保存病历</el-button>
       </div>
@@ -44,10 +45,25 @@
         </div>
       </div>
     </el-dialog>
+
+    <el-dialog class="ai-dialog-wrapper" title="自然语言处理" :visible.sync="showAiDialog" center destroy-on-close :close-on-click-modal="false" :before-close="closeAiDialog">
+      <div style="height: 100%; overflow: auto;">
+        <el-input
+            type="textarea" :readonly="aiLoading"
+            :autosize="{ minRows: 4, maxRows: 8}"
+            placeholder="请描述患者的病情"
+            v-model="aiText">
+        </el-input>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button :disabled="aiLoading" @click="closeAiDialog()">取 消</el-button>
+        <el-button type="primary" :loading="aiLoading" @click="loadAi()">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 <script>
-import { addEMR, getEmrShowMsg, editEMR, backToHis } from "@/api/diagnosis.js";
+import { addEMR, getEmrShowMsg, editEMR, backToHis, getNLP_TemplateResult } from "@/api/diagnosis.js";
 
 import { getTemplateList, getLastTemId, saveLastTemId } from "@/api/emr";
 import { mapGetters, mapMutations } from "vuex";
@@ -63,6 +79,9 @@ export default {
   },
   data() {
     return {
+      showAiDialog: false,
+      aiLoading: false,
+      aiText: '',
       isSkip: true,
       isEdit: false, // 是否修改
       activeId: "",
@@ -143,6 +162,28 @@ export default {
     }
   },
   methods: {
+    closeAiDialog(done) {
+      if (this.aiLoading) return;
+      if (done) done();
+      this.showAiDialog = false;
+      this.aiText = '';
+    },
+    async loadAi() {
+      if (this.aiText && this.aiText.trim()) {
+        this.aiLoading = true;
+        try {
+          const result = await getNLP_TemplateResult(this.aiText.trim());
+          if (result) this.showMsgToTem(result);
+          else throw { message: `` }
+        } catch (e) {
+          if (e.message) this.$message.error(e.message);
+          this.aiLoading = false;
+          return;
+        }
+      }
+      this.aiLoading = false;
+      this.closeAiDialog();
+    },
     // 关闭预览弹窗
     handleClose() {
       this.dialogVisible = false;
@@ -1184,4 +1225,21 @@ export default {
     height: 76vh;
   }
 }
+</style>
+<style lang="scss" scoped>
+.ai-dialog-wrapper {
+  ::v-deep {
+    .el-dialog, .el-dialog__body {
+      height: auto;
+      overflow: hidden;
+    }
+    .el-dialog__body {
+      max-height: 50vh;
+    }
+  }
+  .el-textarea, ::v-deep textarea {
+    max-height: 45vh;
+  }
+}
+
 </style>