Răsfoiți Sursa

事后稽核引擎

0027005599 2 ani în urmă
părinte
comite
db5301e045

+ 9 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/Constant.java

@@ -89,4 +89,13 @@ public class Constant {
     public static final String VALIDATION_HANDER_METHOD_CONTINUE = "CONTINUE";
 
     public static final String SPLIT_STR = ",";
+    /**
+     * 住院
+     */
+    public static final String TREAMENT_TYPE_HOSP = "1";
+
+    /**
+     * 门诊
+     */
+    public static final String TREAMENT_TYPE_OUTPATIENT = "2";
 }

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/HospitalizatioSettleDetail.java

@@ -33,7 +33,7 @@ public class HospitalizatioSettleDetail implements Serializable {
     private static final long serialVersionUID = 1L;
 
 	/**主键*/
-	@TableId(type = IdType.ASSIGN_ID)
+	@TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键")
     private java.lang.Integer id;
 	/**结算单据号;单据唯一识别码,也称交易码(HISID),和住院主单关联条件 */

+ 8 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/MasterAdmissionBill.java

@@ -44,6 +44,10 @@ public class MasterAdmissionBill implements Serializable {
 	@Excel(name = "住院号;病人在医院的住院号", width = 15)
     @ApiModelProperty(value = "住院号;病人在医院的住院号")
     private java.lang.String zyh;
+    /**处方号or医嘱号*/
+    @Excel(name = "处方号or医嘱号", width = 15)
+    @ApiModelProperty(value = "处方号or医嘱号")
+    private String recipeNo;
 	/**支付方式;自费、医保等*/
 	@Excel(name = "支付方式;费用类型 0 自费 1市医保 2省医保 3 国家医保", width = 15)
     @ApiModelProperty(value = "支付方式;费用类型 0 自费 1市医保 2省医保 3 国家医保")
@@ -280,6 +284,10 @@ public class MasterAdmissionBill implements Serializable {
 	@Excel(name = "基金支付总额;基金支付总额 = 基本医保统筹基金支出(含职工基本医疗保险、居民基本医疗保险)+ 补充医疗保险基金支出 (含覆盖全体参保人的居民大病保险和大额医疗费用补助、覆盖部分参保人的企业职工大额医疗费用补助和公务员医疗补助等)+ 医疗救助基金支出 + 其他支出(如伤残人员医疗保障基金支出)", width = 15)
     @ApiModelProperty(value = "基金支付总额;基金支付总额 = 基本医保统筹基金支出(含职工基本医疗保险、居民基本医疗保险)+ 补充医疗保险基金支出 (含覆盖全体参保人的居民大病保险和大额医疗费用补助、覆盖部分参保人的企业职工大额医疗费用补助和公务员医疗补助等)+ 医疗救助基金支出 + 其他支出(如伤残人员医疗保障基金支出)")
     private java.math.BigDecimal fundPaySumamt;
+
+    /**事后监管状态;*/
+    @ApiModelProperty(value = "事后监管状态; WAITING,DEALING,FINISH")
+    private String state;
 	/**创建时间;*/
 	@JsonFormat(timezone = "GMT+8",pattern =  "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern= "yyyy-MM-dd HH:mm:ss")

+ 9 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/AfterWaringJob.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.medical.job;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
@@ -14,7 +15,10 @@ import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 事后触发监管
@@ -48,8 +52,12 @@ public class AfterWaringJob implements Job {
         AfterwardsAudit afterwardsAudit = ruleEngine.insertAfterWarning(afterIncidentLog);
         afterIncidentLogService.lambdaUpdate().set(AfterIncidentLog::getState, Constant.DEALING).eq(AfterIncidentLog::getId, afterIncidentLog.getId()).update();
         List<AfterIncidentDetailLog> afterIncidentDetailLogList = afterIncidentDetailLogService.lambdaQuery().eq(AfterIncidentDetailLog::getAfterIncidentLogId, afterIncidentLog.getId()).list();
+        String jsonStr = JSON.toJSONString(afterIncidentDetailLogList);
+        List<Map> itemList = JSON.parseArray(jsonStr, Map.class);
+        List<Map<String,Object>> realItemList = new ArrayList<>();
+        realItemList.addAll((Collection<? extends Map<String, Object>>) itemList);
         for (AfterIncidentDetailLog afterIncidentDetailLog : afterIncidentDetailLogList) {
-            ruleEngine.dealAfterInterfaceEngin(afterwardsAudit, afterIncidentDetailLog);
+            ruleEngine.dealAfterInterfaceEngin(afterwardsAudit, afterIncidentDetailLog, realItemList);
         }
         afterIncidentLogService.lambdaUpdate().set(AfterIncidentLog::getState, Constant.SUCCESS).eq(AfterIncidentLog::getId, afterIncidentLog.getId()).update();
     }

+ 48 - 5
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/AfterWaringLogJob.java

@@ -1,19 +1,31 @@
 package org.jeecg.modules.medical.job;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.apache.commons.lang.StringUtils;
 import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
 import org.jeecg.modules.medical.entity.AfterIncidentLog;
 import org.jeecg.modules.medical.entity.AfterwardsAudit;
+import org.jeecg.modules.medical.entity.HospitalizatioSettleDetail;
+import org.jeecg.modules.medical.entity.MasterAdmissionBill;
 import org.jeecg.modules.medical.ruleengine.RuleEngine;
 import org.jeecg.modules.medical.service.IAfterIncidentDetailLogService;
 import org.jeecg.modules.medical.service.IAfterIncidentLogService;
+import org.jeecg.modules.medical.service.IHospitalizatioSettleDetailService;
+import org.jeecg.modules.medical.service.IMasterAdmissionBillService;
+import org.jeecg.modules.medical.service.IMaterialItemsService;
+import org.jeecg.modules.medical.service.IOutpatientSettleBillService;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysUserService;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -26,17 +38,48 @@ public class AfterWaringLogJob implements Job {
     IAfterIncidentDetailLogService afterIncidentDetailLogService;
     @Autowired
     RuleEngine ruleEngine;
-
-
+    @Autowired
+    IMasterAdmissionBillService masterAdmissionBillService;
+    @Autowired
+    IHospitalizatioSettleDetailService hospitalizatioSettleDetailService;
+    @Autowired
+    IOutpatientSettleBillService outpatientSettleBillService;
+    @Autowired
+    ISysUserService sysUserService;
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-
+        List<MasterAdmissionBill> masterAdmissionBillList = masterAdmissionBillService.lambdaQuery().isNull(MasterAdmissionBill::getState).last(" limit 1000").list();
+        for(MasterAdmissionBill masterAdmissionBill : masterAdmissionBillList){
+            dealAftertask(masterAdmissionBill);
+        }
     }
 
 
     @Async("commonTaskAsyncPool")
-    public void dealAftertask(AfterIncidentLog afterIncidentLog) {
-
+    public void dealAftertask(MasterAdmissionBill masterAdmissionBill) {
+        AfterIncidentLog afterIncidentLog = afterIncidentLogService.addAfterIncidentLog(masterAdmissionBill);
+        List<HospitalizatioSettleDetail> hospitalizatioSettleDetails = hospitalizatioSettleDetailService.lambdaQuery().eq(HospitalizatioSettleDetail::getHisid, masterAdmissionBill.getHisid()).list();
+        List<AfterIncidentDetailLog> afterIncidentDetailLogList = new ArrayList<>();
+        AfterIncidentDetailLog afterIncidentDetailLog = null;
+        for(HospitalizatioSettleDetail hospitalizatioSettleDetail : hospitalizatioSettleDetails){
+            afterIncidentDetailLog = new AfterIncidentDetailLog();
+            afterIncidentDetailLog.setAfterIncidentLogId(afterIncidentLog.getId());
+            afterIncidentDetailLog.setMedical_diagnose_name_str(masterAdmissionBill.getDischargeDiseaseNameMain());
+            afterIncidentDetailLog.setMedical_diagnose_code_str(masterAdmissionBill.getDischargeDiseaseIdMain());
+            afterIncidentDetailLog.setAmount(hospitalizatioSettleDetail.getCost());
+            afterIncidentDetailLog.setMedical_project_code(hospitalizatioSettleDetail.getItemId());
+            afterIncidentDetailLog.setMedical_project_name(hospitalizatioSettleDetail.getItemName());
+            afterIncidentDetailLog.setProject_name(hospitalizatioSettleDetail.getItemNameHosp());
+            afterIncidentDetailLog.setProject_code(hospitalizatioSettleDetail.getItemIdHosp());
+            afterIncidentDetailLog.setCreateTime(afterIncidentLog.getCreateTime());
+            afterIncidentDetailLog.setDoctorId(afterIncidentLog.getDoctorId());
+            afterIncidentDetailLog.setDoctorName(afterIncidentLog.getDoctorName());
+//            sysUserService.lambdaQuery().eq("")
+//            afterIncidentDetailLog.setDoctorLevel();
+        }
     }
+
+
+
 }

+ 111 - 28
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/FactorEnchangeFactory.java

@@ -3,8 +3,10 @@ package org.jeecg.modules.medical.ruleengine;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.formula.functions.Even;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.util.SpringContextUtils;
 import org.jeecg.common.util.dynamic.db.DynamicDBUtil;
@@ -87,7 +89,7 @@ public class FactorEnchangeFactory {
     }
 
 
-    public boolean runFactorEnchange(Integer medicalInfoRuleInfoId, MedicalInsRuleInfo medicalInsRuleInfo, Object audit, Map<String, Object> localMap, List<RuleFactorRela> ruleFactorRelaList, List<FactorEnchance> factorEnchanceList) {
+    public boolean runFactorEnchange(Integer medicalInfoRuleInfoId, MedicalInsRuleInfo medicalInsRuleInfo, Object audit, Map<String, Object> localMap, List<RuleFactorRela> ruleFactorRelaList, List<FactorEnchance> factorEnchanceList,List<Map<String,Object>> itemList) {
         Map<Integer, FactorEnchance> factorEnchanceMap = factorEnchanceList.stream().collect(Collectors.toMap(FactorEnchance::getId, v -> v, (v1, v2) -> v1));
         boolean result = false;
         for (RuleFactorRela ruleFactorRela : ruleFactorRelaList) {
@@ -122,7 +124,7 @@ public class FactorEnchangeFactory {
                     result = setLogicalExpressionResultByFactorEnchance(localMap, factorEnchance);
                     if (Constant.WARING_EVENT_ATTR_ID == factorEnchance.getEventAttrId()) {
                         if (result) {
-                            insertWarningDetail(localMap, medicalInsRuleInfo, audit);
+                            insertWarningDetail(localMap, medicalInsRuleInfo, audit, itemList);
                         }
                     } else {
                         localMap.put(getParamName(factorEnchance.getEventAttrId()), result);
@@ -156,23 +158,68 @@ public class FactorEnchangeFactory {
         return ioTypeMap;
     }
 
-    public void insertWarningDetail(Map<String, Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, Object audit){
+    public void insertWarningDetail(Map<String, Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, Object audit,List<Map<String,Object>> itemList){
         if(audit instanceof MidIncidentAudit) {
             MidIncidentAudit midIncidentAudit = (MidIncidentAudit) audit;
-            insertMidWarningDetail(itemMap, medicalInsRuleInfo, midIncidentAudit);
+            insertMidWarningDetail(itemMap, medicalInsRuleInfo, midIncidentAudit, itemList);
         }else{
             AfterwardsAudit afterwardsAudit = (AfterwardsAudit) audit;
-            insertAfterWarningDetail(itemMap, medicalInsRuleInfo, afterwardsAudit);
+            insertAfterWarningDetail(itemMap, medicalInsRuleInfo, afterwardsAudit, itemList);
         }
     }
 
-    public void insertAfterWarningDetail(Map<String, Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, AfterwardsAudit afterwardsAudit) {
-        Double amount = (Double) itemMap.get(Constant.AMOUNT_KEY);
+    public void insertAfterWarningDetail(Map<String, Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, AfterwardsAudit afterwardsAudit, List<Map<String,Object>> itemList) {
+
         if(Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod())) {
             afterwardsAuditService.lambdaUpdate().set(AfterwardsAudit::getAmount, afterwardsAudit.getAmount()).eq(AfterwardsAudit::getId, afterwardsAudit.getId()).update();
+            List<AfterwardsAuditDetail> afterwardsAuditDetailList = new ArrayList<>();
+            QueryWrapper queryWrapper = new QueryWrapper();
+            queryWrapper.eq("afterwards_audit_id", afterwardsAudit.getId());
+            afterwardsAuditDetailService.remove(queryWrapper);
+            Date date = new Date(System.currentTimeMillis());
+            for(Map<String,Object> otherMap : itemList){
+                AfterwardsAuditDetail afterwardsAuditDetail = new AfterwardsAuditDetail();
+                Double amount = (Double) otherMap.getOrDefault(Constant.AMOUNT_KEY, 0);
+                afterwardsAuditDetail.setAmount(new BigDecimal(amount));
+                afterwardsAuditDetail.setProejctCode(otherMap.get(Constant.PROJECT_CODE_KEY).toString());
+                afterwardsAuditDetail.setProejctName(otherMap.get(Constant.PROJECT_NAME_KEY).toString());
+                afterwardsAuditDetail.setMedicalProjectCode(otherMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
+                afterwardsAuditDetail.setMedicalProjectName(otherMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
+                afterwardsAuditDetail.setProjectType(otherMap.getOrDefault(Constant.PROJECT_TYPE_KEY, "default").toString());
+                afterwardsAuditDetail.setMedicalDeptCode(afterwardsAudit.getMedicalDeptCode());
+                afterwardsAuditDetail.setMedicalDeptName(afterwardsAudit.getMedicalDeptName());
+
+                afterwardsAuditDetail.setCreateTime(date);
+                afterwardsAuditDetail.setDoctorName(afterwardsAudit.getDoctorName());
+                afterwardsAuditDetail.setDoctorId(afterwardsAudit.getDoctorId());
+                afterwardsAuditDetail.setPatientId(afterwardsAudit.getPatientId());
+                afterwardsAuditDetail.setPatientName(afterwardsAudit.getPatientName());
+                afterwardsAuditDetail.setTreatmentType(medicalInsRuleInfo.getTreatmentType());
+                afterwardsAuditDetail.setNoticeType("事后预警");
+                afterwardsAuditDetail.setMedicalInsRuleInfoCode(medicalInsRuleInfo.getRuleCode());
+                afterwardsAuditDetail.setMedicalInsRuleInfoId(medicalInsRuleInfo.getId());
+                afterwardsAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
+                afterwardsAuditDetail.setDescription(medicalInsRuleInfo.getDescription());
+                afterwardsAuditDetail.setOutpatientNumber(afterwardsAudit.getOutpatientNumber());
+                afterwardsAuditDetail.setPrescriptionNumber(afterwardsAudit.getPrescriptionNumber());
+
+                afterwardsAuditDetail.setViolationLevel(medicalInsRuleInfo.getViolationLevel());
+                afterwardsAuditDetail.setTreatmentType(medicalInsRuleInfo.getTreatmentType());
+                afterwardsAuditDetail.setAfterwardsAuditId(afterwardsAudit.getId());
+                afterwardsAuditDetailList.add(afterwardsAuditDetail);
+
+            }
+            afterwardsAuditDetailService.saveBatch(afterwardsAuditDetailList);
         }else {
-//            MidIncidentWarningVO midIncidentWarningVO = RuleEngine.midIncidentWarningVOThreadLocal.get();
+            Double amount = (Double) itemMap.getOrDefault(Constant.AMOUNT_KEY, 0);
             AfterwardsAuditDetail afterwardsAuditDetail = new AfterwardsAuditDetail();
+            afterwardsAuditDetail.setProejctCode(itemMap.get(Constant.PROJECT_CODE_KEY).toString());
+            afterwardsAuditDetail.setProejctName(itemMap.get(Constant.PROJECT_NAME_KEY).toString());
+            afterwardsAuditDetail.setMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
+            afterwardsAuditDetail.setMedicalProjectName(itemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
+            afterwardsAuditDetail.setProjectType(itemMap.getOrDefault(Constant.PROJECT_TYPE_KEY, "default").toString());
+            afterwardsAuditDetail.setAmount(new BigDecimal(amount));
+
             afterwardsAuditDetail.setMedicalDeptCode(afterwardsAudit.getMedicalDeptCode());
             afterwardsAuditDetail.setMedicalDeptName(afterwardsAudit.getMedicalDeptName());
             Date date = new Date(System.currentTimeMillis());
@@ -187,32 +234,65 @@ public class FactorEnchangeFactory {
             afterwardsAuditDetail.setMedicalInsRuleInfoId(medicalInsRuleInfo.getId());
             afterwardsAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
             afterwardsAuditDetail.setDescription(medicalInsRuleInfo.getDescription());
-            afterwardsAuditDetail.setProejctCode(itemMap.get(Constant.PROJECT_CODE_KEY).toString());
-            afterwardsAuditDetail.setProejctName(itemMap.get(Constant.PROJECT_NAME_KEY).toString());
-            afterwardsAuditDetail.setMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
-            afterwardsAuditDetail.setMedicalProjectName(itemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
             afterwardsAuditDetail.setOutpatientNumber(afterwardsAudit.getOutpatientNumber());
             afterwardsAuditDetail.setPrescriptionNumber(afterwardsAudit.getPrescriptionNumber());
-            afterwardsAuditDetail.setProjectType(itemMap.getOrDefault(Constant.PROJECT_TYPE_KEY, "default").toString());
+
             afterwardsAuditDetail.setViolationLevel(medicalInsRuleInfo.getViolationLevel());
             afterwardsAuditDetail.setTreatmentType(medicalInsRuleInfo.getTreatmentType());
             afterwardsAuditDetail.setAfterwardsAuditId(afterwardsAudit.getId());
-            afterwardsAuditDetail.setAmount(new BigDecimal(amount));
+
             afterwardsAuditService.lambdaUpdate().setSql("amount +"+amount).eq(AfterwardsAudit::getId, afterwardsAudit.getId()).update();
             afterwardsAuditDetailService.save(afterwardsAuditDetail);
         }
 
 
+
     }
 
-    public void insertMidWarningDetail(Map<String, Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, MidIncidentAudit midIncidentAudit) {
+    public void insertMidWarningDetail(Map<String, Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, MidIncidentAudit midIncidentAudit,List<Map<String,Object>> itemList) {
+        MidIncidentWarningVO midIncidentWarningVO = RuleEngine.midIncidentWarningVOThreadLocal.get();
 
-        Double amount = (Double) itemMap.get(Constant.AMOUNT_KEY);
         if(Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod())) {
             midIncidentAuditService.lambdaUpdate().set(MidIncidentAudit::getAmount, midIncidentAudit.getAmount()).eq(MidIncidentAudit::getId, midIncidentAudit.getId()).update();
+            QueryWrapper<MidIncidentAuditDetail> queryWrapper = new QueryWrapper();
+            queryWrapper.eq("mid_incident_audit_id", midIncidentAudit.getId());
+            midIncidentAuditDetailService.remove(queryWrapper);
+            List<MidIncidentAuditDetail> otherList = new ArrayList();
+            for(Map<String,Object> otherItemMap : itemList){
+                MidIncidentAuditDetail midIncidentAuditDetail = new MidIncidentAuditDetail();
+                midIncidentAuditDetail.setMedicalDeptCode(midIncidentWarningVO.getMedical_dept_code());
+                midIncidentAuditDetail.setMedicalDeptName(midIncidentWarningVO.getMedical_dept_name());
+                Date date = new Date(System.currentTimeMillis());
+                midIncidentAuditDetail.setCreateTime(date);
+                midIncidentAuditDetail.setDoctorName(midIncidentWarningVO.getDoctor_name());
+                midIncidentAuditDetail.setDoctorId(midIncidentWarningVO.getDoctor_code());
+                midIncidentAuditDetail.setPatientId(midIncidentWarningVO.getPatient_id());
+                midIncidentAuditDetail.setPatientName(midIncidentWarningVO.getPatient_name());
+                midIncidentAuditDetail.setTreatmentType(medicalInsRuleInfo.getTreatmentType());
+                midIncidentAuditDetail.setNoticeType("事中预警");
+                midIncidentAuditDetail.setMedicalInsRuleInfoCode(medicalInsRuleInfo.getRuleCode());
+                midIncidentAuditDetail.setMedicalInsRuleInfoId(medicalInsRuleInfo.getId());
+                midIncidentAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
+                midIncidentAuditDetail.setDescription(medicalInsRuleInfo.getDescription());
+                midIncidentAuditDetail.setOutpatientNumber(midIncidentAudit.getOutpatientNumber());
+                midIncidentAuditDetail.setPrescriptionNumber(midIncidentAudit.getPrescriptionNumber());
+                midIncidentAuditDetail.setViolationLevel(medicalInsRuleInfo.getViolationLevel());
+                midIncidentAuditDetail.setTreatmentType(medicalInsRuleInfo.getTreatmentType());
+                midIncidentAuditDetail.setMidIncidentAuditId(midIncidentAudit.getId());
+                midIncidentAuditDetail.setProejctCode(otherItemMap.get(Constant.PROJECT_CODE_KEY).toString());
+                midIncidentAuditDetail.setProejctName(otherItemMap.get(Constant.PROJECT_NAME_KEY).toString());
+                midIncidentAuditDetail.setMedicalProjectCode(otherItemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
+                midIncidentAuditDetail.setMedicalProjectName(otherItemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
+                Double otherAmount = (Double) otherItemMap.getOrDefault(Constant.AMOUNT_KEY, 0);
+                midIncidentAuditDetail.setAmount(otherAmount);
+                midIncidentAuditDetail.setProjectType(otherItemMap.getOrDefault(Constant.PROJECT_TYPE_KEY, "default").toString());
+                otherList.add(midIncidentAuditDetail);
+            }
+            midIncidentAuditDetailService.saveBatch(otherList);
         }else {
-            MidIncidentWarningVO midIncidentWarningVO = RuleEngine.midIncidentWarningVOThreadLocal.get();
             MidIncidentAuditDetail midIncidentAuditDetail = new MidIncidentAuditDetail();
+            midIncidentAuditDetail.setAmount(midIncidentAudit.getAmount());
+            Double amount = (Double) itemMap.getOrDefault(Constant.AMOUNT_KEY, 0);
             midIncidentAuditDetail.setMedicalDeptCode(midIncidentWarningVO.getMedical_dept_code());
             midIncidentAuditDetail.setMedicalDeptName(midIncidentWarningVO.getMedical_dept_name());
             Date date = new Date(System.currentTimeMillis());
@@ -227,18 +307,19 @@ public class FactorEnchangeFactory {
             midIncidentAuditDetail.setMedicalInsRuleInfoId(medicalInsRuleInfo.getId());
             midIncidentAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
             midIncidentAuditDetail.setDescription(medicalInsRuleInfo.getDescription());
-            midIncidentAuditDetail.setProejctCode(itemMap.get(Constant.PROJECT_CODE_KEY).toString());
-            midIncidentAuditDetail.setProejctName(itemMap.get(Constant.PROJECT_NAME_KEY).toString());
-            midIncidentAuditDetail.setMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
-            midIncidentAuditDetail.setMedicalProjectName(itemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
             midIncidentAuditDetail.setOutpatientNumber(midIncidentAudit.getOutpatientNumber());
             midIncidentAuditDetail.setPrescriptionNumber(midIncidentAudit.getPrescriptionNumber());
-            midIncidentAuditDetail.setProjectType(itemMap.getOrDefault(Constant.PROJECT_TYPE_KEY, "default").toString());
             midIncidentAuditDetail.setViolationLevel(medicalInsRuleInfo.getViolationLevel());
             midIncidentAuditDetail.setTreatmentType(medicalInsRuleInfo.getTreatmentType());
             midIncidentAuditDetail.setMidIncidentAuditId(midIncidentAudit.getId());
-            midIncidentAuditDetail.setAmount(amount);
+            midIncidentAuditDetail.setProejctCode(itemMap.get(Constant.PROJECT_CODE_KEY).toString());
+            midIncidentAuditDetail.setProejctName(itemMap.get(Constant.PROJECT_NAME_KEY).toString());
+            midIncidentAuditDetail.setMedicalProjectCode(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY).toString());
+            midIncidentAuditDetail.setMedicalProjectName(itemMap.get(Constant.MEDICAL_PROJECT_NAME_KEY).toString());
+
+            midIncidentAuditDetail.setProjectType(itemMap.getOrDefault(Constant.PROJECT_TYPE_KEY, "default").toString());
             midIncidentAuditService.lambdaUpdate().setSql("amount +"+amount).eq(MidIncidentAudit::getId, midIncidentAudit.getId()).update();
+
             midIncidentAuditDetailService.save(midIncidentAuditDetail);
         }
 
@@ -314,11 +395,12 @@ public class FactorEnchangeFactory {
         List<FactorAttrRela> factorAttrRelaOutList = ioTypeMap.get(Constant.OUTPUT);
         if (CollectionUtil.isNotEmpty(factorAttrRelaOutList)) {
             if (factorAttrRelaOutList.size() == 1 && checkEventAttrArr(factorAttrRelaOutList.get(0).getEventAttrId())) {
-                List<Map<String, Object>> dataList = jdbcTemplate.queryForList(sql, new Object[]{});
-                localMap.put(factorAttrRelaOutList.get(0).getEventAttrId().toString(), dataList);
+                List<Object> dataList = jdbcTemplate.queryForList(sql,Object.class);
+//                    jdbcTemplate.queryForList()
+                localMap.put(getParamName(factorAttrRelaOutList.get(0).getEventAttrId()), dataList);
             } else if (factorAttrRelaOutList.size() == 1 && checkEventAttrMap(factorAttrRelaOutList.get(0).getEventAttrId())) {
                 Map<String, Object> dataMap = jdbcTemplate.queryForMap(sql);
-                localMap.put(factorAttrRelaOutList.get(0).getEventAttrId().toString(), dataMap);
+                localMap.put(getParamName(factorAttrRelaOutList.get(0).getEventAttrId()), dataMap);
             } else {
                 SqlRowSet rs = jdbcTemplate.queryForRowSet(sql);
                 if (rs.first()) {
@@ -335,7 +417,8 @@ public class FactorEnchangeFactory {
     }
 
     public boolean checkEventAttrArr(Integer eventAttrId) {
-        Integer dispType = enchanceAttrMap.get(eventAttrId).getDispType();
+        EventAttr eventAttr = enchanceAttrMap.get(eventAttrId);
+        Integer dispType = eventAttr.getDispType();
         if (ColumnTypeEnum.getType(dispType) == ColumnTypeEnum.ARRAY) {
             return true;
         }
@@ -381,7 +464,7 @@ public class FactorEnchangeFactory {
                         whereColumn = DateUtil.formatDate(paramDate);
                         break;
                     default:
-                        log.error("数据类型超出范围");
+                        log.error("数据类型超出范围,当作字符串处理,{} value:{}", type, paramObject);
                         whereColumn = paramObject.toString();
                         return whereColumn;
                 }

+ 9 - 8
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/RuleEngine.java

@@ -242,8 +242,9 @@ public class RuleEngine {
                         }
                     }
                 }
-                runMidEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, midIncidentAudit, ipStr);
+                runMidEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, midIncidentAudit, itemList);
             }
+            webSocket.pushMessage(ipStr, JSON.toJSONString(midIncidentAudit));
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         } finally {
@@ -260,7 +261,7 @@ public class RuleEngine {
      * @param afterwardsAudit
      * @param afterIncidentDetailLog
      */
-    public void dealAfterInterfaceEngin(AfterwardsAudit afterwardsAudit, AfterIncidentDetailLog afterIncidentDetailLog) {
+    public void dealAfterInterfaceEngin(AfterwardsAudit afterwardsAudit, AfterIncidentDetailLog afterIncidentDetailLog,List<Map<String,Object>> itemList) {
 
         try {
 //            List<RuleAttr> ruleAttrList = interfRuleAttrList.get(intefName);
@@ -291,7 +292,7 @@ public class RuleEngine {
                     medicalInsRuleInfoIdList.addAll(diagnoseMedicalInsRuleInfoIdList);
                 }
             }
-            runAfterEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, afterwardsAudit);
+            runAfterEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, afterwardsAudit, itemList);
 //            }
         } catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -473,7 +474,7 @@ public class RuleEngine {
      *
      * @param paramMap
      */
-    public void runAfterEngine(Set<String> auditDetailSet, Map<String, Object> paramMap, Set<Integer> medicalInsRuleInfoIdList, AfterwardsAudit afterIncidentAudit) {
+    public void runAfterEngine(Set<String> auditDetailSet, Map<String, Object> paramMap, Set<Integer> medicalInsRuleInfoIdList, AfterwardsAudit afterIncidentAudit,List<Map<String,Object>> itemList) {
         if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
             log.error("未有对应的规则,接口数据:{}", paramMap);
             return;
@@ -501,7 +502,7 @@ public class RuleEngine {
                 paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
                 List<RuleFactorRela> ruleFactorRelaSortList = ruleIdAndFatorEnchanceIdMap.get(medicalRuleInsInfoId);
 
-                boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, afterIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp);
+                boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, afterIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp, itemList);
                 if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
                     log.error("事后提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
                     return;
@@ -515,7 +516,7 @@ public class RuleEngine {
      *
      * @param paramMap
      */
-    public void runMidEngine(Set<String> auditDetailSet, Map<String, Object> paramMap, Set<Integer> medicalInsRuleInfoIdList, MidIncidentAudit midIncidentAudit, String ipStr) {
+    public void runMidEngine(Set<String> auditDetailSet, Map<String, Object> paramMap, Set<Integer> medicalInsRuleInfoIdList, MidIncidentAudit midIncidentAudit, List<Map<String,Object>> itemList) {
         if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
             log.error("未有对应的规则,接口数据:{}", paramMap);
             return;
@@ -545,14 +546,14 @@ public class RuleEngine {
                 List<RuleFactorRela> ruleFactorRelaSortList = ruleIdAndFatorEnchanceIdMap.get(medicalRuleInsInfoId);
 
 //                factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp);
-                boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp);
+                boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp, itemList);
                 if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
                     log.error("事中提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
                     return;
                 }
             }
         }
-        webSocket.pushMessage(ipStr, JSON.toJSONString(midIncidentAudit));
+
     }
 
 

+ 5 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/IAfterIncidentLogService.java

@@ -1,7 +1,11 @@
 package org.jeecg.modules.medical.service;
 
+import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.entity.AfterIncidentLog;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.medical.entity.MasterAdmissionBill;
+
+import java.util.Date;
 
 /**
  * @Description: after_incident_log
@@ -10,5 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @Version: V1.0
  */
 public interface IAfterIncidentLogService extends IService<AfterIncidentLog> {
-
+    public AfterIncidentLog addAfterIncidentLog(MasterAdmissionBill masterAdmissionBill);
 }

+ 22 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/impl/AfterIncidentLogServiceImpl.java

@@ -1,12 +1,16 @@
 package org.jeecg.modules.medical.service.impl;
 
+import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.entity.AfterIncidentLog;
+import org.jeecg.modules.medical.entity.MasterAdmissionBill;
 import org.jeecg.modules.medical.mapper.AfterIncidentLogMapper;
 import org.jeecg.modules.medical.service.IAfterIncidentLogService;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.util.Date;
+
 /**
  * @Description: after_incident_log
  * @Author: jeecg-boot
@@ -16,4 +20,22 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class AfterIncidentLogServiceImpl extends ServiceImpl<AfterIncidentLogMapper, AfterIncidentLog> implements IAfterIncidentLogService {
 
+    @Override
+    public AfterIncidentLog addAfterIncidentLog(MasterAdmissionBill masterAdmissionBill){
+        Date date = new Date(System.currentTimeMillis());
+        AfterIncidentLog afterIncidentLog = new AfterIncidentLog();
+        afterIncidentLog.setVisitNo(masterAdmissionBill.getZyh());
+        afterIncidentLog.setDoctorId(masterAdmissionBill.getDoctorId());
+        afterIncidentLog.setDoctorName(masterAdmissionBill.getDoctorName());
+        afterIncidentLog.setCreateTime(date);
+        afterIncidentLog.setMedicalDeptCode(masterAdmissionBill.getAdmissionDeptId());
+        afterIncidentLog.setMedicalDeptName(masterAdmissionBill.getAdmissionDeptName());
+        afterIncidentLog.setPatientId(masterAdmissionBill.getPatientId());
+        afterIncidentLog.setPatientName(masterAdmissionBill.getPatientName());
+        afterIncidentLog.setDoctorAdviceNo(masterAdmissionBill.getRecipeNo());
+        afterIncidentLog.setVisitType(Constant.TREAMENT_TYPE_HOSP);
+        afterIncidentLog.setInHospDate(masterAdmissionBill.getAdmissionDate());
+        this.save(afterIncidentLog);
+        return afterIncidentLog;
+    }
 }