Browse Source

药品开单合理

1178232204@qq.com 3 năm trước cách đây
mục cha
commit
36b703eabd
1 tập tin đã thay đổi với 146 bổ sung30 xóa
  1. 146 30
      src/components/knowledgeExtra/AddNewRule.vue

+ 146 - 30
src/components/knowledgeExtra/AddNewRule.vue

@@ -276,7 +276,8 @@ export default {
         klRuleByIdSub: []
       },
       rules: formRules,
-      dragDel: null
+      dragVal: null,
+      dragArr: null
     };
   },
   created() {
@@ -348,6 +349,7 @@ export default {
         } else if (item.subEqValue) {
           item.dataType = '2';
         }
+
         // disable
         if (this.form.parHasSub && this.firstPlace) {
           if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
@@ -356,6 +358,43 @@ export default {
             this.$set(item, 'disabled', true);
           }
         }
+        const dragDel =
+          localStorage
+            .getItem('zskDragDict')
+            .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
+        //药品开单合理判断
+        if (dragDel.length > 0) {
+          const obj = this.baseTypeList.find(it => it.type === 1);
+          if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
+            if (i == 2) {
+              //获取互斥项code
+              const list = obj.subMenuList.filter(it => {
+                return (
+                  it.code == arr[i - 1].subLenCode && it.remark.split('|')[0] == 3
+                );
+              });
+              const dragArr = list[0].remark.split('|')[1].split(',');
+              this.dragArr = dragArr;
+              this.dragVal = item.subLenCode;
+              //取出互斥项
+              const screenArr = obj.subMenuList.filter(item =>
+                dragArr.some(
+                  ele => ele === item.code && item.remark.split('|')[0] == 3
+                )
+              );
+              this.$set(item, 'baseTermTypeList', screenArr);
+            } else {
+              const screenArr = obj.subMenuList.filter(item => {
+                if (item.remark == '') {
+                  return item;
+                } else {
+                  return item.remark.split('|')[0] == i + 1;
+                }
+              });
+              this.$set(item, 'baseTermTypeList', screenArr);
+            }
+          }
+        }
       });
     },
     // 提交
@@ -520,13 +559,28 @@ export default {
       if (dragDel.length > 0) {
         dragType = true;
         const types = dragDel[0].split('-');
-        screenArr = obj.subMenuList.filter(item => {
-          if (item.remark == '') {
-            return item;
-          } else {
-            return item.remark.split('|')[0] == index + 1;
-          }
-        });
+        if (this.dragArr && index > 0) {
+          //获取互斥项code
+          const list = obj.subMenuList.filter(it => {
+            return it.code == this.dragVal && it.remark.split('|')[0] == 3;
+          });
+          const dragArr = list[0].remark.split('|')[1].split(',');
+          this.dragArr = dragArr;
+          //取出互斥项
+          screenArr = obj.subMenuList.filter(item =>
+            dragArr.some(
+              ele => ele === item.code && item.remark.split('|')[0] == 3
+            )
+          );
+        } else {
+          screenArr = obj.subMenuList.filter(item => {
+            if (item.remark == '') {
+              return item;
+            } else {
+              return item.remark.split('|')[0] == index + 1;
+            }
+          });
+        }
       }
       //危急值实验室子项目已选医学标准术语判断
       if (this.form.parHasSub && this.firstPlace) {
@@ -551,12 +605,6 @@ export default {
         'baseTermTypeList',
         (isDel && val == 2) || dragType ? screenArr : obj.subMenuList
       );
-      // this.$set(
-      //   this.form.klRuleByIdSub[index],
-      //   'baseTermTypeList',
-      //   dragType ? subMenuList : obj.subMenuList
-      // );
-
       this.$set(this.form.klRuleByIdSub[index], 'subLenCode', '');
       this.$set(this.form.klRuleByIdSub[index], 'dataType', '');
 
@@ -766,7 +814,6 @@ export default {
     },
     childClearNumText(index) {
       let obj = JSON.parse(JSON.stringify(this.form.klRuleByIdSub));
-
       obj[index].subMaxOperator = '';
       obj[index].subMaxValue = '';
       obj[index].subMaxUnit = '';
@@ -801,22 +848,84 @@ export default {
         localStorage
           .getItem('zskDragDict')
           .match(new RegExp(this.ruleTermCodeStrs, 'g')) || [];
-          console.log(val);
-          
-      if (dragDel.length > 0 && index == 1 && this.form.klRuleByIdSub.length == 3 && this.form.klRuleByIdSub[index+1].subType == 1) {
-        const klRuleByIdSub = this.form.klRuleByIdSub[index+1]
-        klRuleByIdSub.baseTermTypeList.filter(it=>{
-          const drag = it.remark.split('|')[1].split(',')
-          const arr = drag.filter(item=>{
-            console.log(item);
-            
-            return item = val
-          })
-          console.log(arr);
-        })
+      const inx = index == 1 ? index + 1 : index == 2 ? index - 1 : index;
+      const subobj = this.baseTypeList.find(it => it.type == 1);
+      let obj = this.form.klRuleByIdSub;
+      const mutex = obj.some((item, i, arr) => {
+        return item.subLenCode == '';
+      });
+      //判断药品合理性总条数是否大于1条,是否存在第二条或第三条类型为1,存在触发互斥
+      if (
+        //判断3条规则是否都已选中
+        dragDel.length > 0 &&
+        index > 0 &&
+        this.form.klRuleByIdSub.length > 1 &&
+        this.form.klRuleByIdSub[inx].subType == 1 &&
+        this.form.klRuleByIdSub[index].subType == 1
+      ) {
+        if (!mutex) {
+          //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
+          if (this.dragArr.indexOf(this.dragVal) > -1) {
+            //剂型给药途径互斥判断
+            this.$set(this.form.klRuleByIdSub, inx, {
+              groupId: this.form.klRuleByIdSub[inx].groupId,
+              groupChildId: 'child' + new Date().valueOf(),
+              baseTypes: this.baseTypeList,
+              baseTermTypeList: [],
+              conceptList: [],
+              subDescription: '',
+              parRuleType: '',
+              subConceptId: '',
+              subType: '',
+              subMaxOperator: '',
+              subMaxUnit: '',
+              subMaxValue: '',
+              subMinOperator: '',
+              subMinUnit: '',
+              subMinValue: '',
+              subEqValue: '',
+              subLenCode: '',
+              dataType: ''
+            });
+          }
+        } else {
+          //
+          const list = subobj.subMenuList.filter(it => {
+            return it.code == val && it.remark.split('|')[0] == 3;
+          });
+          //获取互斥项code
+          const dragArr = list[0].remark.split('|')[1].split(',');
+          this.dragArr = dragArr;
+          //获取互斥项
+          const screenArr = subobj.subMenuList.filter(item =>
+            dragArr.some(
+              ele => ele === item.code && item.remark.split('|')[0] == 3
+            )
+          );
+          this.$set(
+            this.form.klRuleByIdSub[inx],
+            'baseTermTypeList',
+            screenArr
+          );
+        }
+        this.dragVal = val;
       }
-      if (dragDel.length > 0 && index == 1) {
-        this.dragDel = val;
+
+      //判断药品合理性总条数是否大于1条,并当前规则类型为1,
+      if (
+        dragDel.length > 0 &&
+        index > 0 &&
+        this.form.klRuleByIdSub.length > 1 &&
+        this.form.klRuleByIdSub[index].subType == 1 &&
+        mutex
+      ) {
+        //获取互斥项code
+        const list = subobj.subMenuList.filter(it => {
+          return it.code == val && it.remark.split('|')[0] == 3;
+        });
+        const dragArr = list[0].remark.split('|')[1].split(',');
+        this.dragArr = dragArr;
+        this.dragVal = val;
       }
       if ((numTypes + ',').indexOf(val + ',') > -1) {
         this.$set(this.form.klRuleByIdSub[index], 'dataType', '1');
@@ -825,6 +934,13 @@ export default {
       }
       this.childClearConcept(index);
       this.childClearNumText(index);
+    },
+    // 去重
+    unique(arr, obj) {
+      return arr.reduce((cur, next) => {
+        obj[next] ? '' : (obj[next] = true && cur.push(next));
+        return cur;
+      }, []);
     }
   },
   watch: {