Browse Source

事后规则引擎优化

0027005599 1 year ago
parent
commit
96e9d98b6d
14 changed files with 179 additions and 46 deletions
  1. 5 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/Constant.java
  2. 5 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/SystemEventAttrConstant.java
  3. 5 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/AfterIncidentDetailLog.java
  4. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/AfterIncidentLog.java
  5. 2 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/MasterAdmissionBill.java
  6. 3 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/MedicalInsRuleProject.java
  7. 1 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/AfterWaringLogJob.java
  8. 29 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/XCFYDatav_master_admission_billJob.java
  9. 30 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/XCFYDatav_outpatient_settle_billJob.java
  10. 17 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/FactorEnchangeFactory.java
  11. 31 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/RuleEngine.java
  12. 22 8
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/SPELUtil.java
  13. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/impl/AfterIncidentLogServiceImpl.java
  14. 27 27
      jeecg-module-system/jeecg-system-start/src/main/resources/logback-spring.xml

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

@@ -179,4 +179,9 @@ public class Constant {
      * 医疗收费项目类别字典key
      * 医疗收费项目类别字典key
      */
      */
     public static final String DICT_CATEGORIES_ITEMS_KEY = "categories_items";
     public static final String DICT_CATEGORIES_ITEMS_KEY = "categories_items";
+
+    /**
+     * 规则年龄单位为天的字典key
+     */
+    public static final String DICT_RULE_ID_AGE_DAYS_KEY = "RULE_ID_AGE_DAYS";
 }
 }

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/SystemEventAttrConstant.java

@@ -151,4 +151,9 @@ public class SystemEventAttrConstant {
      * 费用类别项目
      * 费用类别项目
      */
      */
     public static final String EXPENSE_CATEGORY = "expense_category";
     public static final String EXPENSE_CATEGORY = "expense_category";
+
+    /**
+     * HIS接口患者年龄(天数)key
+     */
+    public static final String PATIENTAGEDAYS = "patientAgeDays";
 }
 }

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

@@ -123,6 +123,11 @@ public class AfterIncidentDetailLog implements Serializable {
     @JsonProperty("patient_age")
     @JsonProperty("patient_age")
     @JSONField(name = "patient_age")
     @JSONField(name = "patient_age")
     private java.lang.String patientAge;
     private java.lang.String patientAge;
+
+    /**患者年龄;*/
+    @Excel(name = "患者年龄(天数);", width = 15)
+    @ApiModelProperty(value = "患者年龄(天数);")
+    private java.lang.Double patientAgeDays;
 	/**住院号/门诊号*/
 	/**住院号/门诊号*/
 	@Excel(name = "住院号/门诊号", width = 15)
 	@Excel(name = "住院号/门诊号", width = 15)
     @ApiModelProperty(value = "住院号/门诊号")
     @ApiModelProperty(value = "住院号/门诊号")

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

@@ -89,7 +89,7 @@ public class AfterIncidentLog implements Serializable {
     private Integer zyts;
     private Integer zyts;
     @Excel(name = "患者年龄(天)", width = 15)
     @Excel(name = "患者年龄(天)", width = 15)
     @ApiModelProperty(value = "患者年龄(天)")
     @ApiModelProperty(value = "患者年龄(天)")
-    private Integer patientAgeDays;
+    private Double patientAgeDays;
     @Excel(name = "是否医保", width = 15)
     @Excel(name = "是否医保", width = 15)
     @ApiModelProperty(value = "是否医保,1=是,0=否")
     @ApiModelProperty(value = "是否医保,1=是,0=否")
     private Integer medicalInsurance;
     private Integer medicalInsurance;

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

@@ -165,6 +165,8 @@ public class MasterAdmissionBill implements Serializable {
     @ApiModelProperty(value = "患者年龄;如有患者年龄,则不需要患者出生日期。患者年龄或出生日期有一个字段即可")
     @ApiModelProperty(value = "患者年龄;如有患者年龄,则不需要患者出生日期。患者年龄或出生日期有一个字段即可")
     private java.lang.String patientAge;
     private java.lang.String patientAge;
 
 
+    private Double patientAgeDays;
+
     @Excel(name = "就诊日期", width = 15, format =  "yyyy-MM-dd HH:mm:ss")
     @Excel(name = "就诊日期", width = 15, format =  "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8",pattern =  "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8",pattern =  "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern= "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern= "yyyy-MM-dd HH:mm:ss")

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

@@ -263,5 +263,8 @@ public class MedicalInsRuleProject implements Serializable {
     @TableField(exist = false)
     @TableField(exist = false)
     private List<String> code;
     private List<String> code;
 
 
+    @TableField(exist = false)
+    private Double ageDays;
+
 
 
 }
 }

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

@@ -117,6 +117,7 @@ public class AfterWaringLogJob implements Job {
             afterIncidentDetailLog.setPatientId(masterAdmissionBill.getPatientId());
             afterIncidentDetailLog.setPatientId(masterAdmissionBill.getPatientId());
             afterIncidentDetailLog.setPatientName(masterAdmissionBill.getPatientName());
             afterIncidentDetailLog.setPatientName(masterAdmissionBill.getPatientName());
             afterIncidentDetailLog.setPatientAge(masterAdmissionBill.getPatientAge());
             afterIncidentDetailLog.setPatientAge(masterAdmissionBill.getPatientAge());
+            afterIncidentDetailLog.setPatientAgeDays(masterAdmissionBill.getPatientAgeDays());
             afterIncidentDetailLog.setDischargeStatus(masterAdmissionBill.getDischargeStatus());
             afterIncidentDetailLog.setDischargeStatus(masterAdmissionBill.getDischargeStatus());
 //            afterIncidentDetailLog.setSingle_dose_number();
 //            afterIncidentDetailLog.setSingle_dose_number();
 //            afterIncidentDetailLog.setSingle_dose_unit();
 //            afterIncidentDetailLog.setSingle_dose_unit();

+ 29 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/XCFYDatav_master_admission_billJob.java

@@ -1,10 +1,13 @@
 package org.jeecg.modules.medical.job;
 package org.jeecg.modules.medical.job;
 
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.system.vo.DictModel;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.Constant;
+import org.jeecg.modules.medical.SystemEventAttrConstant;
 import org.jeecg.modules.medical.afterwaring.XCFYDataTransferService;
 import org.jeecg.modules.medical.afterwaring.XCFYDataTransferService;
 import org.jeecg.modules.medical.common.CommonUtil;
 import org.jeecg.modules.medical.common.CommonUtil;
 import org.jeecg.modules.medical.entity.MasterAdmissionBill;
 import org.jeecg.modules.medical.entity.MasterAdmissionBill;
@@ -72,6 +75,32 @@ public class XCFYDatav_master_admission_billJob implements Job {
                             dataMap.put("YB_DISCHARGE_DISEASE_NAME_MAIN", ybDiagCode[1]);
                             dataMap.put("YB_DISCHARGE_DISEASE_NAME_MAIN", ybDiagCode[1]);
                         }
                         }
                     }
                     }
+                    Object patientAge = dataMap.get("PATIENT_AGE");
+                    Object visitTime = dataMap.get("VISIT_TIME");
+                    Object patientBirthday = dataMap.get("PATIENT_BIRTHDAY");
+                    Long ageDays = 0l;
+                    if(null != patientBirthday){
+                        Date patientBirthDayDate = (Date) patientBirthday;
+
+                        if(null != visitTime){
+                            Date visitTimeDate = (Date) visitTime;
+                            ageDays = DateUtil.betweenDay(patientBirthDayDate, visitTimeDate, false);
+                        }else{
+                            ageDays = DateUtil.betweenDay(patientBirthDayDate, new Date(), false);
+                        }
+                        dataMap.put("PATIENT_AGE_DAYS", ageDays.doubleValue());
+                    }else{
+                        if(null != patientAge){
+                            try {
+                                Double patientAgeDouble = Double.parseDouble(patientAge.toString());
+                                Double patientAgeDays = patientAgeDouble * 365;
+                                dataMap.put("PATIENT_AGE_DAYS", patientAgeDays);
+                            }catch (Exception e){
+                                log.error(e.getMessage(), e);
+                            }
+                        }
+                    }
+
                     dataMap.put("CREATE_BY", "auto");
                     dataMap.put("CREATE_BY", "auto");
                     dataMap.put("CREATE_TIME", new Date());
                     dataMap.put("CREATE_TIME", new Date());
                 }
                 }

+ 30 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/XCFYDatav_outpatient_settle_billJob.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.medical.job;
 package org.jeecg.modules.medical.job;
 
 
+import cn.hutool.core.date.DateUtil;
+import javafx.beans.binding.ObjectExpression;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.system.vo.DictModel;
@@ -41,14 +43,14 @@ public class XCFYDatav_outpatient_settle_billJob implements Job {
             "admission_disease_id, admission_disease_name,yb_admission_disease_id, yb_admission_disease_name, medfee_sumamt, fulamt_ownpay_amt, " +
             "admission_disease_id, admission_disease_name,yb_admission_disease_id, yb_admission_disease_name, medfee_sumamt, fulamt_ownpay_amt, " +
             "overlmt_selfpay, preselfpay_amt, inscp_scp_amt, act_pay_dedc, hifp_pay, pool_prop_selfpay, " +
             "overlmt_selfpay, preselfpay_amt, inscp_scp_amt, act_pay_dedc, hifp_pay, pool_prop_selfpay, " +
             "cvlserv_pay, hifes_pay, hifmi_pay, hifob_pay, maf_pay, oth_pay, fund_pay_sumamt, " +
             "cvlserv_pay, hifes_pay, hifmi_pay, hifob_pay, maf_pay, oth_pay, fund_pay_sumamt, " +
-            "create_time, create_by) VALUES (:ID,:HISID,:VISIT_NO,:RECIPE_NO,:PAY_METHOD,:BMI_AREA_ID," +
+            "create_time, create_by, patient_age_days) VALUES (:ID,:HISID,:VISIT_NO,:RECIPE_NO,:PAY_METHOD,:BMI_AREA_ID," +
             ":BMI_AREA_NAME,:HOSPITAL_ID,:HOSPITAL_NAME,:P_LEVEL_YY,:BENEFIT_TYPE,:ADMISSION_DEPT_ID," +
             ":BMI_AREA_NAME,:HOSPITAL_ID,:HOSPITAL_NAME,:P_LEVEL_YY,:BENEFIT_TYPE,:ADMISSION_DEPT_ID," +
             ":ADMISSION_DEPT_NAME,:DOCTOR_ID,:DOCTOR_NAME,:REFUND_FALGE,:FEE_OCUR_TIME,:BILL_DATE," +
             ":ADMISSION_DEPT_NAME,:DOCTOR_ID,:DOCTOR_NAME,:REFUND_FALGE,:FEE_OCUR_TIME,:BILL_DATE," +
             ":REFUND_DATE,:PATIENT_ID,:PATIENT_NAME,:PATIENT_GENDER,:PATIENT_BIRTHDAY,:PATIENT_AGE," +
             ":REFUND_DATE,:PATIENT_ID,:PATIENT_NAME,:PATIENT_GENDER,:PATIENT_BIRTHDAY,:PATIENT_AGE," +
             ":VISIT_TIME,:BENEFIT_GROUP_ID,:CLAIM_TYPE,:IF_LOCAL_FLAG,:ADMISSION_DISEASE_ID," +
             ":VISIT_TIME,:BENEFIT_GROUP_ID,:CLAIM_TYPE,:IF_LOCAL_FLAG,:ADMISSION_DISEASE_ID," +
             ":ADMISSION_DISEASE_NAME,:YB_ADMISSION_DISEASE_ID,:YB_ADMISSION_DISEASE_NAME:MEDFEE_SUMAMT,:FULAMT_OWNPAY_AMT,:OVERLMT_SELFPAY,:PRESELFPAY_AMT," +
             ":ADMISSION_DISEASE_NAME,:YB_ADMISSION_DISEASE_ID,:YB_ADMISSION_DISEASE_NAME:MEDFEE_SUMAMT,:FULAMT_OWNPAY_AMT,:OVERLMT_SELFPAY,:PRESELFPAY_AMT," +
             ":INSCP_SCP_AMT,:ACT_PAY_DEDC,:HIFP_PAY,:POOL_PROP_SELFPAY,:CVLSERV_PAY,:HIFES_PAY,:HIFMI_PAY," +
             ":INSCP_SCP_AMT,:ACT_PAY_DEDC,:HIFP_PAY,:POOL_PROP_SELFPAY,:CVLSERV_PAY,:HIFES_PAY,:HIFMI_PAY," +
-            ":HIFOB_PAY,:MAF_PAY,:OTH_PAY,:FUND_PAY_SUMAMT,:CREATE_TIME,:CREATE_BY)";
+            ":HIFOB_PAY,:MAF_PAY,:OTH_PAY,:FUND_PAY_SUMAMT,:CREATE_TIME,:CREATE_BY,:PATIENT_AGE_DAYS)";
 
 
 
 
     String insertDetailSql = "INSERT INTO outpatient_settlement_details (id, hisid, visit_no, patient_id, hospital_id, " +
     String insertDetailSql = "INSERT INTO outpatient_settlement_details (id, hisid, visit_no, patient_id, hospital_id, " +
@@ -89,8 +91,32 @@ public class XCFYDatav_outpatient_settle_billJob implements Job {
                             dataMap.put("YB_ADMISSION_DISEASE_NAME", ybDiagCode[1]);
                             dataMap.put("YB_ADMISSION_DISEASE_NAME", ybDiagCode[1]);
                         }
                         }
                     }
                     }
-                    String hisId = dataMap.get("HISID").toString();
-                    getDetailByHisId(hisId);
+                    Object patientAge = dataMap.get("PATIENT_AGE");
+                    Object visitTime = dataMap.get("VISIT_TIME");
+                    Object patientBirthday = dataMap.get("PATIENT_BIRTHDAY");
+                    Long ageDays = 0l;
+                    if(null != patientBirthday){
+                        Date patientBirthDayDate = (Date) patientBirthday;
+
+                        if(null != visitTime){
+                            Date visitTimeDate = (Date) visitTime;
+                            ageDays = DateUtil.betweenDay(patientBirthDayDate, visitTimeDate, false);
+                        }else{
+                            ageDays = DateUtil.betweenDay(patientBirthDayDate, new Date(), false);
+                        }
+                        dataMap.put("PATIENT_AGE_DAYS", ageDays.doubleValue());
+                    }else{
+                        if(null != patientAge){
+                            try {
+                                Double patientAgeDouble = Double.parseDouble(patientAge.toString());
+                                Double patientAgeDays = patientAgeDouble * 365;
+                                dataMap.put("PATIENT_AGE_DAYS", patientAgeDays);
+                            }catch (Exception e){
+                                log.error(e.getMessage(), e);
+                            }
+                        }
+                    }
+
                 }
                 }
             });
             });
             if (count <= 0) {
             if (count <= 0) {

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

@@ -43,8 +43,10 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
@@ -433,7 +435,15 @@ public class FactorEnchangeFactory {
      */
      */
     public boolean setLogicalExpressionResultByFactorEnchance(Map<String, Object> localMap, FactorEnchance factorEnchance) throws Exception {
     public boolean setLogicalExpressionResultByFactorEnchance(Map<String, Object> localMap, FactorEnchance factorEnchance) throws Exception {
         if (StringUtils.isNotBlank(factorEnchance.getEnhanceValue())) {
         if (StringUtils.isNotBlank(factorEnchance.getEnhanceValue())) {
-            Boolean resultTemp = (Boolean) spelUtil.runSpelExpression(localMap, factorEnchance.getEnhanceValue());
+            List<FactorCondRela> factorCondRelaList = factorCondRelaMap.get(factorEnchance.getId());
+            Set<String> condStrParamName = new HashSet<>();
+            for (FactorCondRela factorCondRela : factorCondRelaList){
+                condStrParamName.add(enchanceAttrMap.get(factorCondRela.getEventAttrId()).getEnName());
+                if(2 == factorCondRela.getRefAttrType()){
+                    condStrParamName.add(enchanceAttrMap.get(factorCondRela.getRefEventAttrId()).getEnName());
+                }
+            }
+            Boolean resultTemp = (Boolean) spelUtil.runSpelExpression(localMap, factorEnchance.getEnhanceValue(), condStrParamName);
             return resultTemp;
             return resultTemp;
         } else {
         } else {
             List<FactorCondRela> factorCondRelaList = factorCondRelaMap.get(factorEnchance.getId());
             List<FactorCondRela> factorCondRelaList = factorCondRelaMap.get(factorEnchance.getId());
@@ -445,12 +455,17 @@ public class FactorEnchangeFactory {
                     result = false;
                     result = false;
                 }
                 }
                 for (FactorCondRela factorCondRela : factorCondRelaList) {
                 for (FactorCondRela factorCondRela : factorCondRelaList) {
+                    Set<String> condStrParamName = new HashSet<>();
+                    condStrParamName.add(enchanceAttrMap.get(factorCondRela.getEventAttrId()).getEnName());
+                    if(2 == factorCondRela.getRefAttrType()){
+                        condStrParamName.add(enchanceAttrMap.get(factorCondRela.getRefEventAttrId()).getEnName());
+                    }
                     if (!StringUtils.isNotBlank(factorCondRela.getCondStr())) {
                     if (!StringUtils.isNotBlank(factorCondRela.getCondStr())) {
                         log.error("未正常生成表达式,逻辑表达式:{}", factorCondRela);
                         log.error("未正常生成表达式,逻辑表达式:{}", factorCondRela);
                         String condStr = spelUtil.getSPELString(factorCondRela, enchanceAttrMap);
                         String condStr = spelUtil.getSPELString(factorCondRela, enchanceAttrMap);
                         factorCondRela.setCondStr(condStr);
                         factorCondRela.setCondStr(condStr);
                     }
                     }
-                    Boolean resultTemp = (Boolean) spelUtil.runSpelExpression(localMap, factorCondRela.getCondStr());
+                    Boolean resultTemp = (Boolean) spelUtil.runSpelExpression(localMap, factorCondRela.getCondStr(), condStrParamName);
                     if (Constant.AND.equals(factorEnchance.getExtAttr1())) {
                     if (Constant.AND.equals(factorEnchance.getExtAttr1())) {
                         result = resultTemp && result;
                         result = resultTemp && result;
                     } else {
                     } else {

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

@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.SystemEventAttrConstant;
 import org.jeecg.modules.medical.SystemEventAttrConstant;
@@ -57,6 +58,7 @@ import org.jeecg.modules.medical.service.IRuleAttrService;
 import org.jeecg.modules.medical.service.IRuleFactorRelaService;
 import org.jeecg.modules.medical.service.IRuleFactorRelaService;
 import org.jeecg.modules.medical.service.ITreatmentItemsService;
 import org.jeecg.modules.medical.service.ITreatmentItemsService;
 import org.jeecg.modules.message.websocket.WebSocket;
 import org.jeecg.modules.message.websocket.WebSocket;
+import org.jeecg.modules.system.service.ISysDictService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -134,6 +136,8 @@ public class RuleEngine {
     IMedicalInsuranceDrugsService medicalInsuranceDrugsService;
     IMedicalInsuranceDrugsService medicalInsuranceDrugsService;
     @Autowired
     @Autowired
     IDiagnoseItemsService diagnoseItemsService;
     IDiagnoseItemsService diagnoseItemsService;
+    @Autowired
+    ISysDictService sysDictService;
 
 
     @Value("${cache.auto:false}")
     @Value("${cache.auto:false}")
     private Boolean cacheAutoInit;
     private Boolean cacheAutoInit;
@@ -147,6 +151,8 @@ public class RuleEngine {
     public static Map<Integer, List<FactorEnchance>> allEnchanceTypeMap = new HashMap<>();
     public static Map<Integer, List<FactorEnchance>> allEnchanceTypeMap = new HashMap<>();
     public static Map<Integer, MedicalInsRuleInfo> allMedicalMap = new HashMap<>();
     public static Map<Integer, MedicalInsRuleInfo> allMedicalMap = new HashMap<>();
 
 
+    public static Set<Integer> daysRuleIdSet = new HashSet<>();
+
     public void initMedicalInsRule() {
     public void initMedicalInsRule() {
         log.info("进入初始化RuleEngine");
         log.info("进入初始化RuleEngine");
         List<MedicalInsRuleInfo> medicalInsRuleInfoList = medicalInsRuleInfoService.lambdaQuery().eq(MedicalInsRuleInfo::getState, Constant.EFF_STATE).list();
         List<MedicalInsRuleInfo> medicalInsRuleInfoList = medicalInsRuleInfoService.lambdaQuery().eq(MedicalInsRuleInfo::getState, Constant.EFF_STATE).list();
@@ -172,6 +178,7 @@ public class RuleEngine {
         List<RuleAttr> ruleAttrList = ruleAttrService.list();
         List<RuleAttr> ruleAttrList = ruleAttrService.list();
         interfRuleAttrList = ruleAttrList.stream().collect(Collectors.groupingBy(RuleAttr::getInterfName));
         interfRuleAttrList = ruleAttrList.stream().collect(Collectors.groupingBy(RuleAttr::getInterfName));
         initFactor();
         initFactor();
+        initRuleDaysSet();
 
 
     }
     }
 
 
@@ -182,6 +189,15 @@ public class RuleEngine {
         }
         }
     }
     }
 
 
+    public void initRuleDaysSet(){
+        List<DictModel> ruleList = sysDictService.getDictItems(Constant.DICT_RULE_ID_AGE_DAYS_KEY);
+        if(CollectionUtil.isNotEmpty(ruleList)){
+            for(DictModel dictModel : ruleList){
+                daysRuleIdSet.add(Integer.parseInt(dictModel.getValue()));
+            }
+        }
+    }
+
     public void initFactor(){
     public void initFactor(){
         LambdaQueryWrapper<RuleFactorRela> query = new LambdaQueryWrapper<RuleFactorRela>();
         LambdaQueryWrapper<RuleFactorRela> query = new LambdaQueryWrapper<RuleFactorRela>();
         query.eq(RuleFactorRela::getDelFlag, CommonConstant.DEL_FLAG_0);
         query.eq(RuleFactorRela::getDelFlag, CommonConstant.DEL_FLAG_0);
@@ -577,7 +593,8 @@ public class RuleEngine {
                             if (StringUtils.isNotBlank(selectedRoles)) {
                             if (StringUtils.isNotBlank(selectedRoles)) {
                                 String[] selectedRolesArr = selectedRoles.split(",");
                                 String[] selectedRolesArr = selectedRoles.split(",");
                                 boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
                                 boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
-                                if(diagnoseFlag){
+                                boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
+                                if(diagnoseFlag && !projectCodeFlag){
                                     medicalInsRuleProjectList.add(medicalInsRuleProject);
                                     medicalInsRuleProjectList.add(medicalInsRuleProject);
                                 }
                                 }
                             }
                             }
@@ -677,7 +694,8 @@ public class RuleEngine {
                             if (StringUtils.isNotBlank(selectedRoles)) {
                             if (StringUtils.isNotBlank(selectedRoles)) {
                                 String[] selectedRolesArr = selectedRoles.split(",");
                                 String[] selectedRolesArr = selectedRoles.split(",");
                                 boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
                                 boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
-                                if(diagnoseFlag){
+                                boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
+                                if(diagnoseFlag && !projectCodeFlag){
                                     medicalInsRuleProjectList.add(medicalInsRuleProject);
                                     medicalInsRuleProjectList.add(medicalInsRuleProject);
                                 }
                                 }
                             }
                             }
@@ -775,7 +793,8 @@ public class RuleEngine {
                         if (StringUtils.isNotBlank(selectedRoles)) {
                         if (StringUtils.isNotBlank(selectedRoles)) {
                             String[] selectedRolesArr = selectedRoles.split(",");
                             String[] selectedRolesArr = selectedRoles.split(",");
                             boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
                             boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
-                            if(diagnoseFlag){
+                            boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
+                            if(diagnoseFlag && !projectCodeFlag){
                                 medicalInsRuleProjectList.add(medicalInsRuleProject);
                                 medicalInsRuleProjectList.add(medicalInsRuleProject);
                             }
                             }
                         }
                         }
@@ -824,6 +843,15 @@ public class RuleEngine {
      * @param medicalInsRuleProject
      * @param medicalInsRuleProject
      */
      */
     public void setProjectToLocalMap(Map<String,Object> itemMap, MedicalInsRuleProject medicalInsRuleProject){
     public void setProjectToLocalMap(Map<String,Object> itemMap, MedicalInsRuleProject medicalInsRuleProject){
+        if(null != medicalInsRuleProject.getAge()){
+            if(daysRuleIdSet.contains(medicalInsRuleProject.getMedicalInsRuleInfoId())){
+                medicalInsRuleProject.setAgeDays(Double.valueOf(medicalInsRuleProject.getAge()));
+            }else{
+                if(null != medicalInsRuleProject.getAge()){
+                    medicalInsRuleProject.setAgeDays(Double.valueOf(medicalInsRuleProject.getAge() * 365));
+                }
+            }
+        }
         String jsonStr = JSON.toJSONString(medicalInsRuleProject);
         String jsonStr = JSON.toJSONString(medicalInsRuleProject);
         JSONObject jsonObject = JSONObject.parseObject(jsonStr);
         JSONObject jsonObject = JSONObject.parseObject(jsonStr);
         Map<String,Object> transferMedicalMap = filterMap(jsonObject);
         Map<String,Object> transferMedicalMap = filterMap(jsonObject);

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

@@ -18,8 +18,10 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 
 
@@ -120,12 +122,10 @@ public class SPELUtil {
     }
     }
 
 
 
 
-    public Object runSpelExpression(Map<String, Object> contentMap, String condStr) throws Exception {
-
+    public Object runSpelExpression(Map<String, Object> contentMap, String condStr, Set<String> condStrParamName) throws Exception {
         StandardEvaluationContext ctx = new StandardEvaluationContext();
         StandardEvaluationContext ctx = new StandardEvaluationContext();
         Method[] methods = this.getClass().getMethods();
         Method[] methods = this.getClass().getMethods();
         for (Method method : methods) {
         for (Method method : methods) {
-//            log.info("methodName:{} method:{}", method.getName(), method);
             if (!"runSpelExpression".equals(method.getName()) && method.getName().startsWith("is")) {
             if (!"runSpelExpression".equals(method.getName()) && method.getName().startsWith("is")) {
                 ctx.registerFunction(method.getName(), method);
                 ctx.registerFunction(method.getName(), method);
             }
             }
@@ -140,13 +140,24 @@ public class SPELUtil {
             log.error(e.getMessage(), e);
             log.error(e.getMessage(), e);
             throw new Exception("执行失败el表达式:"+ condStr);
             throw new Exception("执行失败el表达式:"+ condStr);
         }
         }
-
         log.info("执行语句:{} 执行结果:{}  ", condStr, defResult);
         log.info("执行语句:{} 执行结果:{}  ", condStr, defResult);
-//        Object defResult = expression.getValue(ctx, Object.class);
+        log.info("执行语句:{} 执行结果:{} ", getCondStrAndParam(condStr, condStrParamName, contentMap), defResult);
 
 
         return defResult;
         return defResult;
     }
     }
 
 
+    public static String getCondStrAndParam(String condStr, Set<String> condStrParamName,Map<String,Object> itemMap){
+
+        for(String condStrParam : condStrParamName){
+            Object replaceValue = itemMap.get(condStrParam);
+            if(null == replaceValue){
+                replaceValue = "[未找到该属性]";
+            }
+            condStr = condStr.replace(condStrParam, replaceValue.toString());
+        }
+        return condStr;
+    }
+
 
 
     public static Boolean isMemberLeftString(String inValue, List<String> memberList) {
     public static Boolean isMemberLeftString(String inValue, List<String> memberList) {
         if (StringUtils.isNotBlank(inValue) && CollectionUtil.isNotEmpty(memberList)) {
         if (StringUtils.isNotBlank(inValue) && CollectionUtil.isNotEmpty(memberList)) {
@@ -364,15 +375,18 @@ public class SPELUtil {
 //        lList.add(1L);
 //        lList.add(1L);
 //        lList.add(2L);
 //        lList.add(2L);
 //        System.out.println(spelUtil.isMemberLeftLong(3L, lList));
 //        System.out.println(spelUtil.isMemberLeftLong(3L, lList));
-////        String condStr = "isMemberLeftObject(#medical_diagnose_code,#medical_ins_medicalDiagnoseCodeList) && #change_class<>#medical_ins_changeClass";
+////        String condStr = "#isMemberLeftObject(#medical_diagnose_code,#medical_ins_medicalDiagnoseCodeList) && #change_class<>#medical_ins_changeClass";
 //        String condStr = "#isMemberListAndList(#medical_diagnose_code,#medical_ins_medicalDiagnoseCodeList) ";
 //        String condStr = "#isMemberListAndList(#medical_diagnose_code,#medical_ins_medicalDiagnoseCodeList) ";
 
 
         Map<String, Object> itemMap1 = new HashMap<>();
         Map<String, Object> itemMap1 = new HashMap<>();
         itemMap1.put("medical_diagnose_code", Arrays.asList("1", "2", "3"));
         itemMap1.put("medical_diagnose_code", Arrays.asList("1", "2", "3"));
         itemMap1.put("medical_ins_medicalDiagnoseCodeList", Arrays.asList("3", "5", "6"));
         itemMap1.put("medical_ins_medicalDiagnoseCodeList", Arrays.asList("3", "5", "6"));
-        String condStr = "'1' != 1";
+        Set<String> nameSet = new HashSet<>();
+        nameSet.add("medical_diagnose_code");
+        nameSet.add("medical_ins_medicalDiagnoseCodeList");
+        String condStr = "#isMemberListAndList(#medical_diagnose_code,#medical_ins_medicalDiagnoseCodeList)";
         try {
         try {
-            System.out.println(spelUtil.runSpelExpression(itemMap1, condStr));
+            System.out.println(spelUtil.runSpelExpression(itemMap1, condStr, nameSet));
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             log.error(e.getMessage(), e);
             log.error(e.getMessage(), e);

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

@@ -38,7 +38,7 @@ public class AfterIncidentLogServiceImpl extends ServiceImpl<AfterIncidentLogMap
         afterIncidentLog.setOutHospDate(masterAdmissionBill.getDischargeDate());
         afterIncidentLog.setOutHospDate(masterAdmissionBill.getDischargeDate());
         afterIncidentLog.setZyts(masterAdmissionBill.getZyts());
         afterIncidentLog.setZyts(masterAdmissionBill.getZyts());
         afterIncidentLog.setDiagnoses(masterAdmissionBill.getDischargeDiseaseIdMain());
         afterIncidentLog.setDiagnoses(masterAdmissionBill.getDischargeDiseaseIdMain());
-//TODO        afterIncidentLog.setPatientAgeDays();
+        afterIncidentLog.setPatientAgeDays(masterAdmissionBill.getPatientAgeDays());
 
 
         afterIncidentLog.setState(Constant.WATING);
         afterIncidentLog.setState(Constant.WATING);
         Integer medicalINsurance = 0;
         Integer medicalINsurance = 0;

+ 27 - 27
jeecg-module-system/jeecg-system-start/src/main/resources/logback-spring.xml

@@ -29,33 +29,33 @@
 			<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
 			<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
 		</encoder>
 		</encoder>
 	</appender>
 	</appender>
-	<!-- 按照每天生成日志文件 -->
-	<appender name="businessLogFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
-		<file>${LOG_HOME}/spel.log</file>
-		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-			<!--日志文件输出的文件名-->
-			<FileNamePattern>${LOG_HOME}/spel.%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>
-			<TimeBasedFileNamingAndTriggeringPolicy
-					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
-				<MaxFileSize>10MB</MaxFileSize>
-			</TimeBasedFileNamingAndTriggeringPolicy>
-			<!--日志文件保留天数-->
-			<MaxHistory>30</MaxHistory>
-		</rollingPolicy>
-		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
-			<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
-			<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}.%M\(%line\) - %msg%n</pattern>
-			<charset>UTF-8</charset>
-		</encoder>
-		<!--日志文件最大的大小-->
-		<!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">-->
-		<!--<MaxFileSize>1024MB</MaxFileSize>-->
-		<!--</triggeringPolicy>-->
-	</appender>
+<!--	&lt;!&ndash; 按照每天生成日志文件 &ndash;&gt;-->
+<!--	<appender name="businessLogFile" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
+<!--		<file>${LOG_HOME}/spel.log</file>-->
+<!--		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
+<!--			&lt;!&ndash;日志文件输出的文件名&ndash;&gt;-->
+<!--			<FileNamePattern>${LOG_HOME}/spel.%d{yyyy-MM-dd_HH}-%i.log</FileNamePattern>-->
+<!--			<TimeBasedFileNamingAndTriggeringPolicy-->
+<!--					class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">-->
+<!--				<MaxFileSize>10MB</MaxFileSize>-->
+<!--			</TimeBasedFileNamingAndTriggeringPolicy>-->
+<!--			&lt;!&ndash;日志文件保留天数&ndash;&gt;-->
+<!--			<MaxHistory>30</MaxHistory>-->
+<!--		</rollingPolicy>-->
+<!--		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">-->
+<!--			&lt;!&ndash;格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符&ndash;&gt;-->
+<!--			<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}.%M\(%line\) - %msg%n</pattern>-->
+<!--			<charset>UTF-8</charset>-->
+<!--		</encoder>-->
+<!--		&lt;!&ndash;日志文件最大的大小&ndash;&gt;-->
+<!--		&lt;!&ndash;<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">&ndash;&gt;-->
+<!--		&lt;!&ndash;<MaxFileSize>1024MB</MaxFileSize>&ndash;&gt;-->
+<!--		&lt;!&ndash;</triggeringPolicy>&ndash;&gt;-->
+<!--	</appender>-->
 
 
-	<logger name="org.jeecg.modules.medical.ruleengine.SPELUtil" additivity="true" level="info">
-		<appender-ref ref="businessLogFile"/>
-	</logger>
+<!--	<logger name="org.jeecg.modules.medical.ruleengine.SPELUtil" additivity="true" level="info">-->
+<!--		<appender-ref ref="businessLogFile"/>-->
+<!--	</logger>-->
 
 
 
 
 
 
@@ -70,7 +70,7 @@
 	<root level="INFO">
 	<root level="INFO">
 		<appender-ref ref="STDOUT" />
 		<appender-ref ref="STDOUT" />
 		<appender-ref ref="FILE" />
 		<appender-ref ref="FILE" />
-		<appender-ref ref="businessLogFile" />
+<!--		<appender-ref ref="businessLogFile" />-->
 	</root>
 	</root>
 
 
 </configuration>
 </configuration>