|
|
@@ -11,6 +11,8 @@ import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.medical.Constant;
|
|
|
import org.jeecg.modules.medical.SystemEventAttrConstant;
|
|
|
+import org.jeecg.modules.medical.entity.AdvanceWarningAudit;
|
|
|
+import org.jeecg.modules.medical.entity.AdvanceWarningVO;
|
|
|
import org.jeecg.modules.medical.entity.AdviceDetailsVO;
|
|
|
import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
|
|
|
import org.jeecg.modules.medical.entity.AfterIncidentLog;
|
|
|
@@ -30,6 +32,8 @@ import org.jeecg.modules.medical.entity.RuleAttr;
|
|
|
import org.jeecg.modules.medical.entity.RuleFactorRela;
|
|
|
import org.jeecg.modules.medical.ruleengine.dict.DictUtil;
|
|
|
import org.jeecg.modules.medical.ruleengine.plugin.InterfItemListPlugin;
|
|
|
+import org.jeecg.modules.medical.service.IAdvanceWarningAuditDetailService;
|
|
|
+import org.jeecg.modules.medical.service.IAdvanceWarningAuditService;
|
|
|
import org.jeecg.modules.medical.service.IAfterwardsAuditDetailService;
|
|
|
import org.jeecg.modules.medical.service.IAfterwardsAuditService;
|
|
|
import org.jeecg.modules.medical.service.IAfterwardsIncidentAuditDiagnoseService;
|
|
|
@@ -106,6 +110,10 @@ public class RuleEngine {
|
|
|
@Autowired
|
|
|
IMedicalInsRuleProjectDiagnoseService medicalInsRuleProjectDiagnoseService;
|
|
|
@Autowired
|
|
|
+ IAdvanceWarningAuditService advanceWarningAuditService;
|
|
|
+ @Autowired
|
|
|
+ IAdvanceWarningAuditDetailService advanceWarningAuditDetailService;
|
|
|
+ @Autowired
|
|
|
DictUtil dictUtil;
|
|
|
@Autowired
|
|
|
WebSocket webSocket;
|
|
|
@@ -114,7 +122,7 @@ public class RuleEngine {
|
|
|
|
|
|
public static Map<String, Set<Integer>> itemCodeAndRuleIdMap = new HashMap<>();
|
|
|
public static Map<String, List<RuleAttr>> interfRuleAttrList = new HashMap<>();
|
|
|
-
|
|
|
+ public static List<Integer> advanceWaringRuleIdList = new ArrayList<>();
|
|
|
|
|
|
@PostConstruct
|
|
|
public void initMedicalInsRule() {
|
|
|
@@ -129,11 +137,13 @@ public class RuleEngine {
|
|
|
*/
|
|
|
List<Integer> medicalInsRuleInfoIdList = new ArrayList<>();
|
|
|
Map<Integer, MedicalInsRuleInfo> medicalMap = new HashMap<>();
|
|
|
+// redisTemplate.delete(Constant.MEDICAL_RULE_CACHE_KEY + "_" + Constant.TREATMEN_TYPE_ADVANCE_WARNING);
|
|
|
for (MedicalInsRuleInfo medicalInsRuleInfo : medicalInsRuleInfoList) {
|
|
|
medicalMap.put(medicalInsRuleInfo.getId(), medicalInsRuleInfo);
|
|
|
if (Constant.TREATMEN_TYPE_ADVANCE_WARNING.equals(medicalInsRuleInfo.getCallScenario())) {
|
|
|
- redisTemplate.opsForHash().put(Constant.MEDICAL_RULE_CACHE_KEY + "_" + Constant.TREATMEN_TYPE_ADVANCE_WARNING,
|
|
|
- medicalInsRuleInfo.getId(), medicalInsRuleInfo.getDegreeSuspicion());
|
|
|
+// redisTemplate.opsForHash().put(Constant.MEDICAL_RULE_CACHE_KEY + "_" + Constant.TREATMEN_TYPE_ADVANCE_WARNING,
|
|
|
+// medicalInsRuleInfo.getId(), medicalInsRuleInfo.getDegreeSuspicion());
|
|
|
+ advanceWaringRuleIdList.add(medicalInsRuleInfo.getId());
|
|
|
} else if (Constant.TREATMEN_TYPE_MID_INCIDENT_WARNING.equals(medicalInsRuleInfo.getCallScenario())
|
|
|
|| Constant.TREATMEN_TYPE_MID_EX_POST_SUPERVISION.equals(medicalInsRuleInfo.getCallScenario())) {
|
|
|
medicalInsRuleInfoIdList.add(medicalInsRuleInfo.getId());
|
|
|
@@ -202,6 +212,34 @@ public class RuleEngine {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 事前提醒接口
|
|
|
+ * @param advanceWarningVO
|
|
|
+ * @param ipStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Result dealPreInterfaceEngin(AdvanceWarningVO advanceWarningVO, String ipStr) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ String jsonStr = JSON.toJSONString(advanceWarningVO);
|
|
|
+ log.info("事中提醒接收报文:{}", jsonStr);
|
|
|
+ JSONObject paramMap = JSON.parseObject(jsonStr);
|
|
|
+
|
|
|
+ AdvanceWarningAudit advanceWarningAudit = insertAdvanceWarning(advanceWarningVO);
|
|
|
+ for(Integer medicalRuleInsInfoId : advanceWaringRuleIdList) {
|
|
|
+ MedicalInsRuleInfo medicalInsRuleInfo = medicalInsRuleInfoService.getById(medicalRuleInsInfoId);
|
|
|
+ runAdvanceWaringEngine(paramMap, medicalInsRuleInfo, advanceWarningAudit);
|
|
|
+ }
|
|
|
+
|
|
|
+ webSocket.pushMessage(ipStr, JSON.toJSONString(advanceWarningAudit));
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public Result dealMidInterfaceEngin(String intefName, MidIncidentWarningVO midIncidentWarningVO, String ipStr) {
|
|
|
midIncidentWarningVOThreadLocal.set(midIncidentWarningVO);
|
|
|
@@ -363,6 +401,25 @@ public class RuleEngine {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public AdvanceWarningAudit insertAdvanceWarning(AdvanceWarningVO advanceWarningVO) {
|
|
|
+ AdvanceWarningAudit advanceWarningAudit = new AdvanceWarningAudit();
|
|
|
+ Date date = new Date(System.currentTimeMillis());
|
|
|
+ advanceWarningAudit.setCreateTime(date);
|
|
|
+ advanceWarningAudit.setDoctorId(advanceWarningVO.getDoctor_code());
|
|
|
+ advanceWarningAudit.setDoctorName(advanceWarningVO.getDoctor_name());
|
|
|
+ advanceWarningAudit.setMedicalDeptCode(advanceWarningVO.getMedical_dept_code());
|
|
|
+ advanceWarningAudit.setMedicalDeptName(advanceWarningVO.getMedical_dept_name());
|
|
|
+ advanceWarningAudit.setPatientId(advanceWarningVO.getPatient_id());
|
|
|
+ advanceWarningAudit.setPatientName(advanceWarningVO.getPatient_name());
|
|
|
+ advanceWarningAudit.setNoticeType("事前提醒");
|
|
|
+ advanceWarningAudit.setTreatmentType(advanceWarningVO.getVisit_type());
|
|
|
+
|
|
|
+ advanceWarningAuditService.save(advanceWarningAudit);
|
|
|
+
|
|
|
+
|
|
|
+ return advanceWarningAudit;
|
|
|
+ }
|
|
|
+
|
|
|
public MidIncidentAudit insertMidWarning(MidIncidentWarningVO midIncidentWarningVO) {
|
|
|
MidIncidentAudit midIncidentAudit = new MidIncidentAudit();
|
|
|
midIncidentAudit.setMedicalDeptCode(midIncidentWarningVO.getMedical_dept_code());
|
|
|
@@ -457,6 +514,37 @@ public class RuleEngine {
|
|
|
return afterwardsAudit;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 事前提醒引擎
|
|
|
+ *
|
|
|
+ * @param paramMap
|
|
|
+ */
|
|
|
+ public void runAdvanceWaringEngine(Map<String, Object> paramMap, MedicalInsRuleInfo medicalInsRuleInfo,Object audit) {
|
|
|
+ if (null == medicalInsRuleInfo) {
|
|
|
+ log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<RuleFactorRela> query = new LambdaQueryWrapper<RuleFactorRela>();
|
|
|
+ query.eq(RuleFactorRela::getDelFlag, CommonConstant.DEL_FLAG_0);
|
|
|
+ query.eq(RuleFactorRela::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId());
|
|
|
+ query.orderByAsc(RuleFactorRela::getSeqNum);
|
|
|
+ List<RuleFactorRela> ruleFactorRelaList = ruleFactorRelaService.list(query);
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(ruleFactorRelaList)) {
|
|
|
+ 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));
|
|
|
+ for (Integer medicalRuleInsInfoId : enchanceTypeMap.keySet()) {
|
|
|
+
|
|
|
+ List<FactorEnchance> factorEnchanceListTemp = enchanceTypeMap.get(medicalRuleInsInfoId);
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_ID, medicalRuleInsInfoId);
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_CODE, medicalInsRuleInfo.getRuleCode());
|
|
|
+ paramMap.put(SystemEventAttrConstant.MEDICAL_INS_RULE_INFO_NAME, medicalInsRuleInfo.getRuleName());
|
|
|
+ factorEnchangeFactory.runFactorEnchange(medicalRuleInsInfoId, medicalInsRuleInfo, audit, paramMap, ruleFactorRelaList, factorEnchanceListTemp, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 事后跑统计类规则引擎
|
|
|
*
|