Преглед изворни кода

审方添加智能审方功能

cc12458 пре 1 година
родитељ
комит
66b9c667f4
2 измењених фајлова са 232 додато и 2 уклоњено
  1. 115 1
      src/api/prescription/prescriptionCore.js
  2. 117 1
      src/views/rescription/prescriptionCore/edit.vue

+ 115 - 1
src/api/prescription/prescriptionCore.js

@@ -60,7 +60,11 @@ export function listPrescriptionReception(query) {
   return request({
     url: '/yfc-admin/prescriptionManage/preOrderPage',
     method: 'post',
-    data: query
+    data: query,
+    params: {
+      pageNum: query.pageNum,
+      pageSize: query.pageSize,
+    },
   })
 }
 
@@ -188,6 +192,116 @@ export function getPrescriptionCore2(id) {
   });
 }
 
+export function getPrescriptionRS(id, medicines, {hidePregnant = false} = {}) {
+  const hack = request({
+    url: 'http://121.43.162.141/yf/knowlib/getYfMatInfo',
+    method: 'post',
+    data: medicines.map(item => item.matCode),
+    params: {id},
+    headers: {isToken: false},
+  }).then(res => {
+    if (res.ResultCode === 401) throw {message: res.ResultInfo};
+    if (res.code !== 0) throw res;
+    return res;
+  });
+
+  return hack.then(res => {
+    const data = Array.isArray(res.data) ? res.data : [];
+    return data.reduce((rs, item, index) => {
+      if (item && item.matid && medicines[index]) {
+        const name = medicines[index].matName || item.matname;
+        const dosage = +medicines[index].matDose;
+        const color = '#5AD8A6';
+        if (dosage && item.matdosage) {
+          const ref = {}, i = 1;
+          const child = rs[i] || (rs[i] = {title: '', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">${ref[item.matdosage]}</span>
+          </div>`);
+        }
+        if (item.matsjj) {
+          const ref = {1: '慎用', 2: '忌用', 3: '禁用'}, i = 2;
+          const child = rs[i] || (rs[i] = {title: '慎忌禁用药', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">${ref[item.matsjj]}</span>
+          </div>`);
+        }
+        if (item.matyfsjj && !hidePregnant) {
+          const color = item.matyfsjj === '3' ? 'red' : '#5AD8A6';
+          const ref = {1: '孕妇慎用', 2: '孕妇忌用', 3: '孕妇禁用'}, i = 3;
+          const child = rs[i] || (rs[i] = {title: '孕妇慎忌禁', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">${ref[item.matyfsjj]}</span>
+          </div>`);
+        }
+        if (item.matysjj) {
+          const ref = {}, i = 4;
+          const child = rs[i] || (rs[i] = {title: '服药饮食禁忌', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">${item.matysjj || '无'}</span>
+          </div>`);
+        }
+        if (item.matdxsm) {
+          const color = 'red';
+          const ref = {}, i = 5;
+          const child = rs[i] || (rs[i] = {title: '药物毒性说明', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">${item.matdxsm || '无'}</span>
+          </div>`);
+        }
+        if (item.matbzjj) {
+          const ref = {}, i = 6;
+          const child = rs[i] || (rs[i] = {title: '病证用药禁忌', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">${item.matbzjj || '无'}</span>
+          </div>`);
+        }
+        if (item.matsbf) {
+          const color = 'red';
+          const ref = {}, i = 7;
+          const child = rs[i] || (rs[i] = {title: '十八反', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">反${item.matsbf}</span>
+          </div>`);
+        }
+        if (item.matsjw) {
+          const color = 'red';
+          const ref = {}, i = 8;
+          const child = rs[i] || (rs[i] = {title: '十九畏', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">畏${item.matsjw}</span>
+          </div>`);
+        }
+        if (item.matby) {
+          const ref = {}, i = 9;
+          const child = rs[i] || (rs[i] = {title: '用药不宜', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value">不宜与${item.matby}同用</span>
+          </div>`);
+        }
+        if (dosage && (dosage < item.matmindosage || dosage > item.matmaxdosage)) {
+          const ref = {}, i = 0;
+          const child = rs[i] || (rs[i] = {title: '超剂量药品', collection: []});
+          child.collection.push(`<div>
+            <span class="met-name" style="color: ${color};">${name}</span>
+            <span class="met-value" style="color: red;">(${item.matmindosage}-${item.matmaxdosage})</span>
+          </div>`);
+        }
+      }
+      return rs;
+    }, []).filter(Boolean);
+  });
+}
+
 // 新增处方审核
 export function addPrescriptionCore(data) {
   return request({

+ 117 - 1
src/views/rescription/prescriptionCore/edit.vue

@@ -3,7 +3,13 @@ import dayjs from 'dayjs';
 import {listMedicalMechanism} from '@/api/medical/mechanism';
 import {transformFlatObjectToNested, transformNestedObjectToFlat} from '@/tools/object';
 import {bignumber, chain, multiply} from 'mathjs';
-import {addPrescriptionCore2, check, check2, getPrescriptionCore2} from '@/api/prescription/prescriptionCore';
+import {
+  addPrescriptionCore2,
+  check,
+  check2,
+  getPrescriptionCore2,
+  getPrescriptionRS,
+} from '@/api/prescription/prescriptionCore';
 import {mapGetters} from 'vuex';
 
 import regionOptions from '@/utils/options';
@@ -87,6 +93,10 @@ export default {
       saving: false,
 
       tableHeight: 0,
+
+      showRS: false,
+      rsLoading: false,
+      rs: [],
     };
   },
   computed: {
@@ -168,6 +178,23 @@ export default {
 
       if (!this.model.tackleTime) this.model.tackleTime = dayjs().startOf('minute').format('YYYY-MM-DD HH:mm:ss');
     },
+    async loadRS() {
+      const medicines = this.medicines.filter(medicine => Object.keys(medicine).length);
+      if (medicines.length === 0) return this.toggleShowRS(false);
+      this.rsLoading = true;
+      try {
+        const id = this.model.id || this.$props.id;
+        this.rs = await getPrescriptionRS(id, medicines, {hidePregnant: this.model.sex === '男' || this.model.age < 14});
+      } catch (e) {
+        if (e instanceof AggregateError) {
+          this.$message.error(e.errors.map(e=>e.message).join('; '));
+        } else {
+          this.$message.error(e.message);
+        }
+        this.toggleShowRS(false);
+      }
+      this.rsLoading = false;
+    },
     formReset() {
       const pharmacies = Array.isArray(this.pharmacyList) ? this.pharmacyList : [];
       this.model = {
@@ -326,15 +353,18 @@ export default {
         this.medicines.splice(index, 1, row);
       }
       if (this.getEmptyMedicineRowIndex === -1) this.appendMedicine({}, index + 1);
+      if (this.showRS) this.loadRS();
     },
     appendMedicine(model, index = this.medicines.length) {
       this.medicines.splice(index, 0, model || {});
     },
     deleteMedicine(row, index) {
       this.medicines.splice(index, 1);
+      if (this.showRS) this.loadRS();
     },
     updateMedicine(row, index) {
       this.medicines.splice(index, 1, {...row, subtotalMoney: this.calculationMedicinePrice(row)});
+      if (this.showRS) this.loadRS();
     },
     calculationMedicinePrice(medicine) {
       let price = chain(bignumber(medicine.matXsj || 0));
@@ -346,6 +376,11 @@ export default {
         colspan: 8,
       };
     },
+
+    toggleShowRS(show = true) {
+      this.showRS = show && !this.showRS;
+      if (this.showRS) this.loadRS();
+    },
   },
 };
 </script>
@@ -725,6 +760,25 @@ export default {
             </el-col>
           </el-row>
         </div>
+        <transition name="slide-left">
+          <div v-if="showRS" class="drawer-container">
+            <div class="header">智能审方</div>
+            <div class="main" v-loading="rsLoading">
+              <el-empty v-if="!rsLoading && rs.length === 0">
+                <el-button type="primary" @click="toggleShowRS(false)">关闭</el-button>
+              </el-empty>
+              <div v-for="block in rs" :key="block.title">
+                <div class="rs-title">{{ block.title }}</div>
+                <el-row :gutter="20">
+                  <el-col :span="24" v-for="item in block.collection" :key="item.name" style="margin-top: 8px;"
+                          v-html="item"></el-col>
+                </el-row>
+              </div>
+            </div>
+
+            <i class="el-icon-circle-close close" @click="toggleShowRS(false)"></i>
+          </div>
+        </transition>
       </el-col>
       <el-col class="col-container" :span="12">
         <div class="area" style="flex: auto;display: flex;flex-direction: column;">
@@ -827,6 +881,9 @@ export default {
             </template>
           </div>
           <div>
+            <el-button v-if="isCheck" type="primary" plain @click="toggleShowRS()"
+                       :disabled="!getEmptyMedicineRowIndex">{{ showRS ? '关闭' : '' }}智能审方
+            </el-button>
             <el-button v-if="isCheck" type="primary" @click="check('110')" :disabled="saving">审核通过</el-button>
             <el-button v-else type="primary" :loading="saving" @click="handle">保 存</el-button>
             <el-button @click="cancel">取 消</el-button>
@@ -959,6 +1016,65 @@ export default {
   display: flex;
   justify-content: space-between;
 }
+
+.col-container {
+  position: relative;
+
+  .drawer-container {
+    position: absolute;
+    top: 0;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    display: flex;
+    flex-direction: column;
+    padding: 12px 10px;
+    background-color: #fff;
+
+    .close {
+      position: absolute;
+      top: 12px + 4px;
+      right: 12px;
+      font-size: 24px;
+      cursor: pointer;
+
+      &:hover {
+        color: #5AD8A6;
+      }
+    }
+
+    > .header {
+      flex: none;
+      font-size: 20px;
+      font-weight: 700;
+      text-align: center;
+      line-height: 32px;
+    }
+
+    > .main {
+      flex: auto;
+      overflow-x: hidden;
+      overflow-y: auto;
+
+      .rs-title {
+        margin-top: 12px;
+        font-size: 18px;
+        font-weight: 700;
+      }
+    }
+  }
+
+  /* 动画效果 */
+  .slide-left-enter-active,
+  .slide-left-leave-active {
+    transition: transform 0.3s ease;
+  }
+
+  .slide-left-enter,
+  .slide-left-leave-to {
+    transform: translateX(-100%);
+  }
+}
 </style>
 <style lang="scss">
 .el-dialog {