|
|
@@ -15,12 +15,12 @@ import org.jeecg.modules.medical.entity.AdviceDetailsVO;
|
|
|
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.AfterwardsAuditDetail;
|
|
|
import org.jeecg.modules.medical.entity.AfterwardsIncidentAuditDiagnose;
|
|
|
import org.jeecg.modules.medical.entity.DiagnosesVO;
|
|
|
import org.jeecg.modules.medical.entity.FactorEnchance;
|
|
|
import org.jeecg.modules.medical.entity.MedicalInsRuleInfo;
|
|
|
import org.jeecg.modules.medical.entity.MedicalInsRuleProject;
|
|
|
+import org.jeecg.modules.medical.entity.MedicalInsRuleProjectDiagnose;
|
|
|
import org.jeecg.modules.medical.entity.MidIncidentAudit;
|
|
|
import org.jeecg.modules.medical.entity.MidIncidentAuditDiagnose;
|
|
|
import org.jeecg.modules.medical.entity.MidIncidentVisitDetailLog;
|
|
|
@@ -33,11 +33,9 @@ import org.jeecg.modules.medical.ruleengine.plugin.InterfItemListPlugin;
|
|
|
import org.jeecg.modules.medical.service.IAfterwardsAuditDetailService;
|
|
|
import org.jeecg.modules.medical.service.IAfterwardsAuditService;
|
|
|
import org.jeecg.modules.medical.service.IAfterwardsIncidentAuditDiagnoseService;
|
|
|
-import org.jeecg.modules.medical.service.IEventAttrService;
|
|
|
-import org.jeecg.modules.medical.service.IFactorAttrRelaService;
|
|
|
-import org.jeecg.modules.medical.service.IFactorCondRelaService;
|
|
|
import org.jeecg.modules.medical.service.IFactorEnchanceService;
|
|
|
import org.jeecg.modules.medical.service.IMedicalInsRuleInfoService;
|
|
|
+import org.jeecg.modules.medical.service.IMedicalInsRuleProjectDiagnoseService;
|
|
|
import org.jeecg.modules.medical.service.IMedicalInsRuleProjectService;
|
|
|
import org.jeecg.modules.medical.service.IMidIncidentAuditDiagnoseService;
|
|
|
import org.jeecg.modules.medical.service.IMidIncidentAuditService;
|
|
|
@@ -72,7 +70,7 @@ public class RuleEngine {
|
|
|
private IMedicalInsRuleInfoService medicalInsRuleInfoService;
|
|
|
@Autowired
|
|
|
private IFactorEnchanceService factorEnchanceService;
|
|
|
-// @Autowired
|
|
|
+ // @Autowired
|
|
|
// private IEventAttrService eventAttrService;
|
|
|
// @Autowired
|
|
|
// private IFactorAttrRelaService factorAttrRelaService;
|
|
|
@@ -106,6 +104,8 @@ public class RuleEngine {
|
|
|
@Autowired
|
|
|
IAfterwardsIncidentAuditDiagnoseService afterwardsIncidentAuditDiagnoseService;
|
|
|
@Autowired
|
|
|
+ IMedicalInsRuleProjectDiagnoseService medicalInsRuleProjectDiagnoseService;
|
|
|
+ @Autowired
|
|
|
DictUtil dictUtil;
|
|
|
@Autowired
|
|
|
WebSocket webSocket;
|
|
|
@@ -167,10 +167,18 @@ public class RuleEngine {
|
|
|
itemCodeAndRuleIdMap.put(medicalInsRuleProject.getCorrelationProjectCode(), ruleIdSet);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-// if(StringUtils.isNotBlank(medicalInsRuleProject.get)){
|
|
|
-//
|
|
|
-// }
|
|
|
+ List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleProjectId, medicalInsRuleProject.getMedicineInsRuleInfoId()).list();
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
|
|
|
+ for (MedicalInsRuleProjectDiagnose medicalInsRuleProjectDiagnose : medicalInsRuleProjectDiagnoseList) {
|
|
|
+ if (itemCodeAndRuleIdMap.containsKey(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode())) {
|
|
|
+ itemCodeAndRuleIdMap.get(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode()).add(medicalInsRuleProject.getMedicineInsRuleInfoId());
|
|
|
+ } else {
|
|
|
+ Set<Integer> ruleIdSet = new HashSet<>();
|
|
|
+ ruleIdSet.add(medicalInsRuleProject.getMedicineInsRuleInfoId());
|
|
|
+ itemCodeAndRuleIdMap.put(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode(), ruleIdSet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// setMIDProjectCodeToRedis(medicalInsRuleProject);
|
|
|
}
|
|
|
}
|
|
|
@@ -200,14 +208,6 @@ public class RuleEngine {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Integer getMIDMedicalId(String itemCode) {
|
|
|
- Object medicineInsRuleId = redisTemplate.opsForHash().get(Constant.MEDICAL_RULE_CACHE_KEY, itemCode);
|
|
|
-// redisTemplate.opsForSet().add(Constant.MEDICAL_RULE_CACHE_KEY)
|
|
|
- if (null != medicineInsRuleId) {
|
|
|
- return (Integer) medicineInsRuleId;
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
public Result dealMidInterfaceEngin(String intefName, MidIncidentWarningVO midIncidentWarningVO, String ipStr) {
|
|
|
midIncidentWarningVOThreadLocal.set(midIncidentWarningVO);
|
|
|
@@ -233,10 +233,13 @@ public class RuleEngine {
|
|
|
}
|
|
|
Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
|
|
|
if (null != diagnose) {
|
|
|
+ List<Object> diagnoseList = (List<Object>) diagnose;
|
|
|
//获取诊断编码配置的规则ID,加入需要执行的规则
|
|
|
- Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
|
|
|
- if (CollectionUtil.isNotEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
- medicalInsRuleInfoIdList.addAll(diagnoseMedicalInsRuleInfoIdList);
|
|
|
+ for (Object diagnoseObject : diagnoseList) {
|
|
|
+ Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnoseObject.toString());
|
|
|
+ if (CollectionUtil.isNotEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
+ medicalInsRuleInfoIdList.addAll(diagnoseMedicalInsRuleInfoIdList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
runMidEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, midIncidentAudit, ipStr);
|
|
|
@@ -251,43 +254,51 @@ public class RuleEngine {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Result dealAfterInterfaceEngin(String intefName, AfterIncidentLog afterIncidentLog, AfterIncidentDetailLog afterIncidentDetailLog) {
|
|
|
+ /**
|
|
|
+ * 事后明细
|
|
|
+ *
|
|
|
+ * @param intefName
|
|
|
+ * @param afterwardsAudit
|
|
|
+ * @param afterIncidentDetailLog
|
|
|
+ */
|
|
|
+ public void dealAfterInterfaceEngin(String intefName, AfterwardsAudit afterwardsAudit, AfterIncidentDetailLog afterIncidentDetailLog) {
|
|
|
|
|
|
try {
|
|
|
- List<RuleAttr> ruleAttrList = interfRuleAttrList.get(intefName);
|
|
|
- if (null == ruleAttrList) {
|
|
|
- return Result.error("接口:" + intefName + " 未配置 对应的规则属性");
|
|
|
- }
|
|
|
+// List<RuleAttr> ruleAttrList = interfRuleAttrList.get(intefName);
|
|
|
+// if (null == ruleAttrList) {
|
|
|
+//
|
|
|
+// return Result.error("接口:" + intefName + " 未配置 对应的规则属性");
|
|
|
+// }
|
|
|
dictUtil.transferAfterIncidentWarning(afterIncidentDetailLog);
|
|
|
String jsonStr = JSON.toJSONString(afterIncidentDetailLog);
|
|
|
log.info("事后处理日志:{}", jsonStr);
|
|
|
- JSONObject paramMap = JSON.parseObject(jsonStr);
|
|
|
- List<Map<String, Object>> itemList = interfItemListPlugin.findProIntersection(paramMap, ruleAttrList);
|
|
|
- AfterwardsAudit afterwardsAudit = insertAfterWarning(afterIncidentLog);
|
|
|
+ JSONObject itemMap = JSON.parseObject(jsonStr);
|
|
|
+// List<Map<String, Object>> itemList = interfItemListPlugin.findProIntersection(paramMap, ruleAttrList);
|
|
|
+
|
|
|
// insertAfterWarning(afterwardsAudit);
|
|
|
// midIncidentAudit.setInterfName(intefName);
|
|
|
Set<String> auditDetailSet = new HashSet<>();
|
|
|
- for (Map<String, Object> itemMap : itemList) {
|
|
|
- Set<Integer> medicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
- if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
|
|
|
- log.error("项目编码未匹配到对应的医保规则:{}", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
- continue;
|
|
|
- }
|
|
|
- Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
|
|
|
- if (null != diagnose) {
|
|
|
- //获取诊断编码配置的规则ID,加入需要执行的规则
|
|
|
- Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
|
|
|
- if (CollectionUtil.isNotEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
- medicalInsRuleInfoIdList.addAll(diagnoseMedicalInsRuleInfoIdList);
|
|
|
- }
|
|
|
+// for (Map<String, Object> itemMap : itemList) {
|
|
|
+ Set<Integer> medicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
|
|
|
+ log.error("项目编码未匹配到对应的医保规则:{}", itemMap.get(Constant.MEDICAL_PROJECT_CODE_KEY));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Object diagnose = itemMap.get(Constant.MEDICAL_DIAGNOSE_CODE_KEY);
|
|
|
+ if (null != diagnose) {
|
|
|
+ //获取诊断编码配置的规则ID,加入需要执行的规则
|
|
|
+ Set<Integer> diagnoseMedicalInsRuleInfoIdList = itemCodeAndRuleIdMap.get(diagnose.toString());
|
|
|
+ if (CollectionUtil.isNotEmpty(diagnoseMedicalInsRuleInfoIdList)) {
|
|
|
+ medicalInsRuleInfoIdList.addAll(diagnoseMedicalInsRuleInfoIdList);
|
|
|
}
|
|
|
-// runAfterEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, midIncidentAudit, ipStr);
|
|
|
}
|
|
|
+ runAfterEngine(auditDetailSet, itemMap, medicalInsRuleInfoIdList, afterwardsAudit);
|
|
|
+// }
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
|
|
|
|
- return Result.ok();
|
|
|
+// return Result.ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -298,6 +309,11 @@ public class RuleEngine {
|
|
|
midIncidentVisitLog.setVisitNo(midIncidentWarningVO.getVisit_no());
|
|
|
midIncidentVisitLog.setPatientId(midIncidentWarningVO.getPatient_id());
|
|
|
midIncidentVisitLog.setPatientName(midIncidentWarningVO.getPatient_name());
|
|
|
+ midIncidentVisitLog.setDoctorLevel(midIncidentWarningVO.getDoctor_level());
|
|
|
+ midIncidentVisitLog.setPatientAge(midIncidentWarningVO.getPatient_age());
|
|
|
+ midIncidentVisitLog.setPatientGender(midIncidentWarningVO.getPatient_gender());
|
|
|
+ midIncidentVisitLog.setDischargeStatus(midIncidentWarningVO.getDischarge_status());
|
|
|
+ midIncidentVisitLog.setTotoalAmount(midIncidentWarningVO.getTotoal_amount());
|
|
|
if (CollectionUtil.isNotEmpty(midIncidentWarningVO.getDiagnoses())) {
|
|
|
midIncidentVisitLog.setDiagnoses(JSON.toJSONString(midIncidentWarningVO.getDiagnoses()));
|
|
|
}
|
|
|
@@ -353,6 +369,7 @@ public class RuleEngine {
|
|
|
midIncidentVisitDetailLog.setProejctName(adviceDetailsVO.getProject_name());
|
|
|
midIncidentVisitDetailLog.setPatientId(midIncidentWarningVO.getPatient_id());
|
|
|
midIncidentVisitDetailLog.setPatientId(midIncidentWarningVO.getPatient_name());
|
|
|
+ midIncidentVisitDetailLog.setAmount(new BigDecimal(adviceDetailsVO.getAmount()));
|
|
|
midIncidentVisitDetailLogList.add(midIncidentVisitDetailLog);
|
|
|
}
|
|
|
midIncidentVisitDetailLogService.saveBatch(midIncidentVisitDetailLogList);
|
|
|
@@ -372,7 +389,19 @@ public class RuleEngine {
|
|
|
midIncidentAudit.setTreatmentType(midIncidentWarningVO.getVisit_type());
|
|
|
midIncidentAudit.setPrescriptionNumber(midIncidentWarningVO.getDoctor_advice_no());
|
|
|
midIncidentAudit.setNoticeType("事中预警");
|
|
|
+
|
|
|
midIncidentAuditService.save(midIncidentAudit);
|
|
|
+ double allAmount = 0;
|
|
|
+ if (null != midIncidentWarningVO.getTotoal_amount() && midIncidentWarningVO.getTotoal_amount() > 0) {
|
|
|
+ allAmount = midIncidentWarningVO.getTotoal_amount();
|
|
|
+ } else {
|
|
|
+ if (CollectionUtil.isNotEmpty(midIncidentWarningVO.getAdvice_details())) {
|
|
|
+ for (AdviceDetailsVO adviceDetailsVO : midIncidentWarningVO.getAdvice_details()) {
|
|
|
+ allAmount = allAmount + adviceDetailsVO.getAmount();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ midIncidentAudit.setAmount(allAmount);
|
|
|
if (CollectionUtil.isNotEmpty(midIncidentWarningVO.getDiagnoses())) {
|
|
|
List<MidIncidentAuditDiagnose> midIncidentAuditDiagnoseList = new ArrayList<>();
|
|
|
for (DiagnosesVO diagnosesVO : midIncidentWarningVO.getDiagnoses()) {
|
|
|
@@ -440,63 +469,13 @@ public class RuleEngine {
|
|
|
return afterwardsAudit;
|
|
|
}
|
|
|
|
|
|
- public List<Integer> getMedicalInsRuleInfoIdByIntef(String intefName, Map<String, Object> paramMap, List<RuleAttr> ruleAttrList) {
|
|
|
-
|
|
|
- List<Integer> medicalIdList = new ArrayList<>();
|
|
|
- Map<String, List<Integer>> itemCodeAndRuleIdMap = new HashMap<>();
|
|
|
- for (RuleAttr ruleAttr : ruleAttrList) {
|
|
|
- String itemCode = null;
|
|
|
- if (StringUtils.isNotBlank(ruleAttr.getAttrPath())) {
|
|
|
- Object value = paramMap.get(ruleAttr.getAttrPath());
|
|
|
- if (null == value) {
|
|
|
- log.error("接口调用:{} 不存在 属性路径:{}", intefName, ruleAttr.getAttrPath());
|
|
|
- break;
|
|
|
- }
|
|
|
- String attrName = ruleAttr.getRuleAttr();
|
|
|
- if (value instanceof List) {
|
|
|
- List<Map<String, Object>> pathValueList = (List<Map<String, Object>>) value;
|
|
|
- for (Map<String, Object> itemMap : pathValueList) {
|
|
|
- Object itemCodeTemp = itemMap.get(attrName);
|
|
|
- if (null != itemCodeTemp) {
|
|
|
- itemCode = (String) itemCodeTemp;
|
|
|
- Integer medicineInsRuleId = getMIDMedicalId(itemCode);
|
|
|
- if (null != medicineInsRuleId) {
|
|
|
- medicalIdList.add(medicineInsRuleId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (value instanceof Map) {
|
|
|
- Map<String, Object> pathValueMap = (Map) value;
|
|
|
- Object itemCodeTemp = pathValueMap.get(attrName);
|
|
|
- if (null != itemCodeTemp) {
|
|
|
- itemCode = (String) itemCodeTemp;
|
|
|
- Integer medicineInsRuleId = getMIDMedicalId(itemCode);
|
|
|
- if (null != medicineInsRuleId) {
|
|
|
- medicalIdList.add(medicineInsRuleId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- Object itemCodeObject = paramMap.get(ruleAttr.getRuleAttr());
|
|
|
- if (null != itemCodeObject) {
|
|
|
- Integer medicineInsRuleId = getMIDMedicalId(itemCodeObject.toString());
|
|
|
- if (null != medicineInsRuleId) {
|
|
|
- medicalIdList.add(medicineInsRuleId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-// paramMap.put("itemList", itemList);
|
|
|
- return medicalIdList;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 事中跑批规则引擎
|
|
|
*
|
|
|
* @param paramMap
|
|
|
*/
|
|
|
- public void runAfterEngine(Set<String> auditDetailSet, Map<String, Object> paramMap, Set<Integer> medicalInsRuleInfoIdList, MidIncidentAudit midIncidentAudit, String ipStr) {
|
|
|
+ public void runAfterEngine(Set<String> auditDetailSet, Map<String, Object> paramMap, Set<Integer> medicalInsRuleInfoIdList, AfterwardsAudit afterIncidentAudit) {
|
|
|
if (CollectionUtil.isEmpty(medicalInsRuleInfoIdList)) {
|
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
|
return;
|
|
|
@@ -509,7 +488,6 @@ public class RuleEngine {
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(ruleFactorRelaList)) {
|
|
|
Map<Integer, List<RuleFactorRela>> ruleIdAndFatorEnchanceIdMap = ruleFactorRelaList.stream().collect(Collectors.groupingBy(RuleFactorRela::getMedicalInsRuleInfoId));
|
|
|
-// Map<Integer, RuleFactorRela> factorEnchanceRuleIdMap = ruleFactorRelaList.stream().collect(Collectors.toMap(RuleFactorRela::getFactorEnhanceId, v -> v, (v1, v2) -> v1));
|
|
|
Set<Integer> factorEnchangeIdList = ruleFactorRelaList.stream().map(RuleFactorRela::getFactorEnhanceId).collect(Collectors.toSet());
|
|
|
List<FactorEnchance> factorEnchanceList = factorEnchanceService.listByIds(factorEnchangeIdList);
|
|
|
Map<Integer, List<FactorEnchance>> enchanceTypeMap = factorEnchanceList.stream().collect(Collectors.groupingBy(FactorEnchance::getFactorCatalog));
|
|
|
@@ -525,10 +503,13 @@ public class RuleEngine {
|
|
|
paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
List<RuleFactorRela> ruleFactorRelaSortList = ruleIdAndFatorEnchanceIdMap.get(medicalRuleInsInfoId);
|
|
|
|
|
|
- factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp);
|
|
|
+ boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, afterIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp);
|
|
|
+ if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
|
|
|
+ log.error("事后提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- webSocket.pushMessage(ipStr, JSON.toJSONString(midIncidentAudit));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -565,7 +546,12 @@ public class RuleEngine {
|
|
|
paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
List<RuleFactorRela> ruleFactorRelaSortList = ruleIdAndFatorEnchanceIdMap.get(medicalRuleInsInfoId);
|
|
|
|
|
|
- factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp);
|
|
|
+// factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp);
|
|
|
+ boolean auditFlag = factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, midIncidentAudit, paramMap, ruleFactorRelaSortList, factorEnchanceListTemp);
|
|
|
+ if (Constant.VALIDATION_HANDER_METHOD_RETURN.equals(medicalInsRuleInfo.getViolationHandingMethod()) && auditFlag) {
|
|
|
+ log.error("事中提醒数据:{} 规则名:{} 触发诊断类规则,直接全金额,后续规则无需再跑", paramMap, medicalInsRuleInfo);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
webSocket.pushMessage(ipStr, JSON.toJSONString(midIncidentAudit));
|