|
|
@@ -20,9 +20,11 @@ import org.jeecg.modules.medical.entity.AfterwardsAudit;
|
|
|
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.MaterialItems;
|
|
|
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.MedicalInsuranceDrugs;
|
|
|
import org.jeecg.modules.medical.entity.MidIncidentAudit;
|
|
|
import org.jeecg.modules.medical.entity.MidIncidentAuditDiagnose;
|
|
|
import org.jeecg.modules.medical.entity.MidIncidentVisitDetailLog;
|
|
|
@@ -30,6 +32,7 @@ import org.jeecg.modules.medical.entity.MidIncidentVisitLog;
|
|
|
import org.jeecg.modules.medical.entity.MidIncidentWarningVO;
|
|
|
import org.jeecg.modules.medical.entity.RuleAttr;
|
|
|
import org.jeecg.modules.medical.entity.RuleFactorRela;
|
|
|
+import org.jeecg.modules.medical.entity.TreatmentItems;
|
|
|
import org.jeecg.modules.medical.ruleengine.dict.DictUtil;
|
|
|
import org.jeecg.modules.medical.ruleengine.plugin.InterfItemListPlugin;
|
|
|
import org.jeecg.modules.medical.service.IAdvanceWarningAuditDetailService;
|
|
|
@@ -38,15 +41,18 @@ 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.IFactorEnchanceService;
|
|
|
+import org.jeecg.modules.medical.service.IMaterialItemsService;
|
|
|
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.IMedicalInsuranceDrugsService;
|
|
|
import org.jeecg.modules.medical.service.IMidIncidentAuditDiagnoseService;
|
|
|
import org.jeecg.modules.medical.service.IMidIncidentAuditService;
|
|
|
import org.jeecg.modules.medical.service.IMidIncidentVisitDetailLogService;
|
|
|
import org.jeecg.modules.medical.service.IMidIncidentVisitLogService;
|
|
|
import org.jeecg.modules.medical.service.IRuleAttrService;
|
|
|
import org.jeecg.modules.medical.service.IRuleFactorRelaService;
|
|
|
+import org.jeecg.modules.medical.service.ITreatmentItemsService;
|
|
|
import org.jeecg.modules.message.websocket.WebSocket;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
@@ -117,12 +123,18 @@ public class RuleEngine {
|
|
|
DictUtil dictUtil;
|
|
|
@Autowired
|
|
|
WebSocket webSocket;
|
|
|
+ @Autowired
|
|
|
+ IMaterialItemsService materialItemsService;
|
|
|
+ @Autowired
|
|
|
+ ITreatmentItemsService treatmentItemsService;
|
|
|
+ @Autowired
|
|
|
+ IMedicalInsuranceDrugsService medicalInsuranceDrugsService;
|
|
|
|
|
|
public static ThreadLocal<MidIncidentWarningVO> midIncidentWarningVOThreadLocal = new ThreadLocal<>();
|
|
|
|
|
|
- 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<>();
|
|
|
+ public static Map<String, Set<Integer>> itemCodeAndRuleIdMap = new HashMap<>();
|
|
|
|
|
|
@PostConstruct
|
|
|
public void initMedicalInsRule() {
|
|
|
@@ -156,76 +168,146 @@ public class RuleEngine {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void genItemCodeAndRuleIdMap(List<MedicalInsRuleInfo> medicalInsRuleInfoList){
|
|
|
+ public void genItemCodeAndRuleIdMap(List<MedicalInsRuleInfo> medicalInsRuleInfoList) {
|
|
|
try {
|
|
|
+ Map<String, Set<Integer>> ruleItemCodeAndRuleIdMap = new HashMap<>();
|
|
|
|
|
|
- MemeryPageUtil.batchDeal(medicalInsRuleInfoList, 1000, pageDataList -> {
|
|
|
- List<Integer> ruleIdList = pageDataList.stream().map(MedicalInsRuleInfo::getId).collect(Collectors.toList());
|
|
|
- List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.lambdaQuery().in(MedicalInsRuleProject::getMedicalInsRuleInfoId, ruleIdList).list();
|
|
|
+ List<Integer> ruleIdList = medicalInsRuleInfoList.stream().map(MedicalInsRuleInfo::getId).collect(Collectors.toList());
|
|
|
+ for (Integer medicalInsInfoId : ruleIdList) {
|
|
|
+ List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.lambdaQuery().eq(MedicalInsRuleProject::getMedicalInsRuleInfoId, medicalInsInfoId).list();
|
|
|
if (CollectionUtil.isNotEmpty(medicalInsRuleProjectList)) {
|
|
|
MedicalInsRuleProject medicalInsRuleProject = null;
|
|
|
+ Set<String> consumableProjectCodeList = new HashSet<>();
|
|
|
+ Set<String> restorativesProjectCodeList = new HashSet<>();
|
|
|
+ Set<String> treatmentProjectCodeList = new HashSet<>();
|
|
|
for (int index = 0; index < medicalInsRuleProjectList.size(); index++) {
|
|
|
medicalInsRuleProject = medicalInsRuleProjectList.get(index);
|
|
|
- if (StringUtils.isNotBlank(medicalInsRuleProject.getProjectCode())) {
|
|
|
- if(medicalInsRuleProject.getProjectCode().startsWith(Constant.CONSUMABLE_START_KEY)){
|
|
|
-
|
|
|
- }else if(medicalInsRuleProject.getProjectCode().startsWith(Constant.RESTORATIVES_T_START_KEY) ||
|
|
|
- medicalInsRuleProject.getProjectCode().startsWith(Constant.RESTORATIVES_X_START_KEY) ||
|
|
|
- medicalInsRuleProject.getProjectCode().startsWith(Constant.RESTORATIVES_Z_START_KEY)){
|
|
|
-
|
|
|
+ String projectCode = medicalInsRuleProject.getProjectCode();
|
|
|
+ String correlationProjectCode = medicalInsRuleProject.getCorrelationProjectCode();
|
|
|
+ if (StringUtils.isNotBlank(projectCode)) {
|
|
|
+ if (projectCode.startsWith(Constant.CONSUMABLE_START_KEY)) {
|
|
|
+ consumableProjectCodeList.add(projectCode);
|
|
|
+ } else if (projectCode.startsWith(Constant.RESTORATIVES_T_START_KEY) ||
|
|
|
+ projectCode.startsWith(Constant.RESTORATIVES_X_START_KEY) ||
|
|
|
+ projectCode.startsWith(Constant.RESTORATIVES_Z_START_KEY)) {
|
|
|
+ restorativesProjectCodeList.add(projectCode);
|
|
|
//耗材都是字母c开头, 药品是X或Z T, 医疗服务是数字开头
|
|
|
- }else if(SPELUtil.isNumeric(medicalInsRuleProject.getProjectCode())){
|
|
|
-
|
|
|
+ } else if (SPELUtil.isNumeric(projectCode)) {
|
|
|
+ treatmentProjectCodeList.add(projectCode);
|
|
|
}
|
|
|
- if (itemCodeAndRuleIdMap.containsKey(medicalInsRuleProject.getProjectCode())) {
|
|
|
- itemCodeAndRuleIdMap.get(medicalInsRuleProject.getProjectCode()).add(medicalInsRuleProject.getMedicalInsRuleInfoId());
|
|
|
+ if (ruleItemCodeAndRuleIdMap.containsKey(projectCode)) {
|
|
|
+ ruleItemCodeAndRuleIdMap.get(projectCode).add(medicalInsRuleProject.getMedicalInsRuleInfoId());
|
|
|
} else {
|
|
|
Set<Integer> ruleIdSet = new HashSet<>();
|
|
|
ruleIdSet.add(medicalInsRuleProject.getMedicalInsRuleInfoId());
|
|
|
- itemCodeAndRuleIdMap.put(medicalInsRuleProject.getProjectCode(), ruleIdSet);
|
|
|
+ ruleItemCodeAndRuleIdMap.put(projectCode, ruleIdSet);
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(medicalInsRuleProject.getCorrelationProjectCode())) {
|
|
|
- if (itemCodeAndRuleIdMap.containsKey(medicalInsRuleProject.getCorrelationProjectCode())) {
|
|
|
- itemCodeAndRuleIdMap.get(medicalInsRuleProject.getCorrelationProjectCode()).add(medicalInsRuleProject.getMedicalInsRuleInfoId());
|
|
|
+ if (StringUtils.isNotBlank(correlationProjectCode)) {
|
|
|
+ if (correlationProjectCode.startsWith(Constant.CONSUMABLE_START_KEY)) {
|
|
|
+ consumableProjectCodeList.add(correlationProjectCode);
|
|
|
+ } else if (correlationProjectCode.startsWith(Constant.RESTORATIVES_T_START_KEY) ||
|
|
|
+ correlationProjectCode.startsWith(Constant.RESTORATIVES_X_START_KEY) ||
|
|
|
+ correlationProjectCode.startsWith(Constant.RESTORATIVES_Z_START_KEY)) {
|
|
|
+ restorativesProjectCodeList.add(correlationProjectCode);
|
|
|
+ //耗材都是字母c开头, 药品是X或Z T, 医疗服务是数字开头
|
|
|
+ } else if (SPELUtil.isNumeric(correlationProjectCode)) {
|
|
|
+ treatmentProjectCodeList.add(correlationProjectCode);
|
|
|
+ }
|
|
|
+ if (ruleItemCodeAndRuleIdMap.containsKey(correlationProjectCode)) {
|
|
|
+ ruleItemCodeAndRuleIdMap.get(correlationProjectCode).add(medicalInsRuleProject.getMedicalInsRuleInfoId());
|
|
|
} else {
|
|
|
Set<Integer> ruleIdSet = new HashSet<>();
|
|
|
ruleIdSet.add(medicalInsRuleProject.getMedicalInsRuleInfoId());
|
|
|
- itemCodeAndRuleIdMap.put(medicalInsRuleProject.getCorrelationProjectCode(), ruleIdSet);
|
|
|
+ ruleItemCodeAndRuleIdMap.put(correlationProjectCode, ruleIdSet);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
+ setCache(consumableProjectCodeList, ruleItemCodeAndRuleIdMap, Constant.PROJECT_TYPE_CONSUMABLE_METERIAL);
|
|
|
+ setCache(restorativesProjectCodeList, ruleItemCodeAndRuleIdMap, Constant.PROJECT_TYPE_MEDICINE);
|
|
|
+ setCache(treatmentProjectCodeList, ruleItemCodeAndRuleIdMap, Constant.PROJECT_TYPE_DIAGNOSIS_TREATMENT);
|
|
|
+
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- for(MedicalInsRuleInfo medicalInsRuleInfo : medicalInsRuleInfoList) {
|
|
|
- if(StringUtils.isNotBlank(medicalInsRuleInfo.getSelectedRoles())) {
|
|
|
- String[] rolesArr = medicalInsRuleInfo.getSelectedRoles().split(",");
|
|
|
- boolean medicalDiagnoseCodeFlag = Arrays.stream(rolesArr).allMatch(role -> role.equals("medicalDiagnoseCode"));
|
|
|
- boolean cMedicalDiagnoseCodeFlag = Arrays.stream(rolesArr).allMatch(role -> role.equals("correlationMedicalDiagnoseCode"));
|
|
|
- if(medicalDiagnoseCodeFlag || cMedicalDiagnoseCodeFlag) {
|
|
|
- List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId()).list();
|
|
|
- if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
|
|
|
- for (MedicalInsRuleProjectDiagnose medicalInsRuleProjectDiagnose : medicalInsRuleProjectDiagnoseList) {
|
|
|
- if (itemCodeAndRuleIdMap.containsKey(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode())) {
|
|
|
- itemCodeAndRuleIdMap.get(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode()).add(medicalInsRuleInfo.getId());
|
|
|
- } else {
|
|
|
- Set<Integer> ruleIdSet = new HashSet<>();
|
|
|
- ruleIdSet.add(medicalInsRuleInfo.getId());
|
|
|
- itemCodeAndRuleIdMap.put(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode(), ruleIdSet);
|
|
|
- }
|
|
|
+
|
|
|
+ for (MedicalInsRuleInfo medicalInsRuleInfo : medicalInsRuleInfoList) {
|
|
|
+ if (StringUtils.isNotBlank(medicalInsRuleInfo.getSelectedRoles())) {
|
|
|
+ String[] rolesArr = medicalInsRuleInfo.getSelectedRoles().split(",");
|
|
|
+ boolean medicalDiagnoseCodeFlag = Arrays.stream(rolesArr).anyMatch(role -> role.equals("medicalDiagnoseCode"));
|
|
|
+ boolean cMedicalDiagnoseCodeFlag = Arrays.stream(rolesArr).anyMatch(role -> role.equals("correlationMedicalDiagnoseCode"));
|
|
|
+ if (medicalDiagnoseCodeFlag || cMedicalDiagnoseCodeFlag) {
|
|
|
+ List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId()).list();
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
|
|
|
+ for (MedicalInsRuleProjectDiagnose medicalInsRuleProjectDiagnose : medicalInsRuleProjectDiagnoseList) {
|
|
|
+ if (itemCodeAndRuleIdMap.containsKey(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode())) {
|
|
|
+ itemCodeAndRuleIdMap.get(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode()).add(medicalInsRuleInfo.getId());
|
|
|
+ } else {
|
|
|
+ Set<Integer> ruleIdSet = new HashSet<>();
|
|
|
+ ruleIdSet.add(medicalInsRuleInfo.getId());
|
|
|
+ itemCodeAndRuleIdMap.put(medicalInsRuleProjectDiagnose.getMedicalDiagnoseCode(), ruleIdSet);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void setCache(Set<String> projectCodeList, Map<String, Set<Integer>> ruleItemCodeAndRuleIdMap, String projectType) {
|
|
|
+ if (Constant.PROJECT_TYPE_MEDICINE.equals(projectType) && CollectionUtil.isNotEmpty(ruleItemCodeAndRuleIdMap)) {
|
|
|
+ List<MedicalInsuranceDrugs> medicalInsuranceDrugsList = medicalInsuranceDrugsService.lambdaQuery().isNotNull(MedicalInsuranceDrugs::getItemIdHosp).isNotNull(MedicalInsuranceDrugs::getMedicineCode).list();
|
|
|
+ if(CollectionUtil.isNotEmpty(medicalInsuranceDrugsList)) {
|
|
|
+ for (MedicalInsuranceDrugs medicalInsuranceDrugs : medicalInsuranceDrugsList) {
|
|
|
+ for (String projectCode : projectCodeList) {
|
|
|
+ boolean startFlag = SPELUtil.startWithKey(medicalInsuranceDrugs.getMedicineCode(), projectCode);
|
|
|
+ if (startFlag) {
|
|
|
+ Set<Integer> medicalRuleInfoIdSet = ruleItemCodeAndRuleIdMap.get(projectCode);
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalRuleInfoIdSet)) {
|
|
|
+ itemCodeAndRuleIdMap.put(medicalInsuranceDrugs.getMedicineCode(), medicalRuleInfoIdSet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (Constant.PROJECT_TYPE_CONSUMABLE_METERIAL.equals(projectType) && CollectionUtil.isNotEmpty(ruleItemCodeAndRuleIdMap)) {
|
|
|
+ List<MaterialItems> materialItemsList = materialItemsService.lambdaQuery().isNotNull(MaterialItems::getItemIdHosp).isNotNull(MaterialItems::getItemId).list();
|
|
|
+ if(CollectionUtil.isNotEmpty(materialItemsList)) {
|
|
|
+ for (MaterialItems materialItems : materialItemsList) {
|
|
|
+ for (String projectCode : projectCodeList) {
|
|
|
+ boolean startFlag = SPELUtil.startWithKey(materialItems.getItemId(), projectCode);
|
|
|
+ if (startFlag) {
|
|
|
+ Set<Integer> medicalRuleInfoIdSet = ruleItemCodeAndRuleIdMap.get(projectCode);
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalRuleInfoIdSet)) {
|
|
|
+ itemCodeAndRuleIdMap.put(materialItems.getItemId(), medicalRuleInfoIdSet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (Constant.PROJECT_TYPE_DIAGNOSIS_TREATMENT.equals(projectType) && CollectionUtil.isNotEmpty(ruleItemCodeAndRuleIdMap)) {
|
|
|
+ List<TreatmentItems> treatmentItemsList = treatmentItemsService.lambdaQuery().isNotNull(TreatmentItems::getItemIdHosp).isNotNull(TreatmentItems::getItemId).list();
|
|
|
+ if(CollectionUtil.isNotEmpty(treatmentItemsList)) {
|
|
|
+ for (TreatmentItems treatmentItems : treatmentItemsList) {
|
|
|
+ for (String projectCode : projectCodeList) {
|
|
|
+ boolean startFlag = SPELUtil.startWithKey(treatmentItems.getItemId(), projectCode);
|
|
|
+ if (startFlag) {
|
|
|
+ Set<Integer> medicalRuleInfoIdSet = ruleItemCodeAndRuleIdMap.get(projectCode);
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalRuleInfoIdSet)) {
|
|
|
+ itemCodeAndRuleIdMap.put(treatmentItems.getItemId(), medicalRuleInfoIdSet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据关联的规则项目设置redis规则缓存
|
|
|
* 后续作为处方/医嘱快速匹配的索引
|
|
|
@@ -241,6 +323,7 @@ public class RuleEngine {
|
|
|
|
|
|
/**
|
|
|
* 事前提醒接口
|
|
|
+ *
|
|
|
* @param advanceWarningVO
|
|
|
* @param ipStr
|
|
|
* @return
|
|
|
@@ -253,18 +336,18 @@ public class RuleEngine {
|
|
|
JSONObject paramMap = JSON.parseObject(jsonStr);
|
|
|
|
|
|
AdvanceWarningAudit advanceWarningAudit = insertAdvanceWarning(advanceWarningVO);
|
|
|
- if(CollectionUtil.isEmpty(advanceWaringRuleIdList)){
|
|
|
+ if (CollectionUtil.isEmpty(advanceWaringRuleIdList)) {
|
|
|
log.error("事前提醒未配置对应的提醒规则");
|
|
|
return Result.ok();
|
|
|
}
|
|
|
- for(Integer medicalRuleInsInfoId : advanceWaringRuleIdList) {
|
|
|
+ for (Integer medicalRuleInsInfoId : advanceWaringRuleIdList) {
|
|
|
MedicalInsRuleInfo medicalInsRuleInfo = medicalInsRuleInfoService.getById(medicalRuleInsInfoId);
|
|
|
paramMap.put(SystemEventAttrConstant.PRE_ADVANCEWARNINGAUDIT_ID_KEY, advanceWarningAudit.getId());
|
|
|
runAdvanceWaringEngine(paramMap, medicalInsRuleInfo, advanceWarningAudit);
|
|
|
}
|
|
|
JSONObject sendJson = new JSONObject();
|
|
|
sendJson.put("id", advanceWarningAudit.getId());
|
|
|
- sendJson.put("type","during");
|
|
|
+ sendJson.put("type", "during");
|
|
|
webSocket.pushMessage(ipStr, sendJson.toJSONString());
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
@@ -314,7 +397,7 @@ public class RuleEngine {
|
|
|
if (sendFlag) {
|
|
|
JSONObject sendJson = new JSONObject();
|
|
|
sendJson.put("id", midIncidentAudit.getId());
|
|
|
- sendJson.put("type","before");
|
|
|
+ sendJson.put("type", "before");
|
|
|
webSocket.pushMessage(ipStr, sendJson.toJSONString());
|
|
|
} else {
|
|
|
log.error("无违规,事中审核无需提醒 门诊/住院号:{}", midIncidentWarningVO.getVisit_no());
|
|
|
@@ -329,9 +412,6 @@ public class RuleEngine {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 事后明细
|
|
|
*
|
|
|
@@ -597,7 +677,7 @@ public class RuleEngine {
|
|
|
*
|
|
|
* @param paramMap
|
|
|
*/
|
|
|
- public void runAdvanceWaringEngine(Map<String, Object> paramMap, MedicalInsRuleInfo medicalInsRuleInfo,Object audit) {
|
|
|
+ public void runAdvanceWaringEngine(Map<String, Object> paramMap, MedicalInsRuleInfo medicalInsRuleInfo, Object audit) {
|
|
|
if (null == medicalInsRuleInfo) {
|
|
|
log.error("未有对应的规则,接口数据:{}", paramMap);
|
|
|
return;
|
|
|
@@ -749,74 +829,74 @@ public class RuleEngine {
|
|
|
return auditFlag;
|
|
|
}
|
|
|
|
|
|
- public void getRuleProjectIntoMap(MedicalInsRuleInfo medicalInsRuleInfo, Map<String,Object> itemMap){
|
|
|
+ public void getRuleProjectIntoMap(MedicalInsRuleInfo medicalInsRuleInfo, Map<String, Object> itemMap) {
|
|
|
String selectedRoles = medicalInsRuleInfo.getSelectedRoles();
|
|
|
- if(StringUtils.isNotBlank(selectedRoles)){
|
|
|
+ if (StringUtils.isNotBlank(selectedRoles)) {
|
|
|
String[] selectedRolesArr = selectedRoles.split(",");
|
|
|
boolean diagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("medicalDiagnoseCode"));
|
|
|
boolean correlationDiagnoseFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("correlationMedicalDiagnoseCode"));
|
|
|
boolean projectCodeFlag = Arrays.stream(selectedRolesArr).anyMatch(attr -> attr.equals("projectCode"));
|
|
|
String projectCode = null;
|
|
|
- if(projectCodeFlag && null != itemMap.get(Constant.PROJECT_CODE_KEY)) {
|
|
|
+ if (projectCodeFlag && null != itemMap.get(Constant.PROJECT_CODE_KEY)) {
|
|
|
projectCode = itemMap.get(Constant.PROJECT_CODE_KEY).toString();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return;
|
|
|
}
|
|
|
List<MedicalInsRuleProject> medicalInsRuleProjectList = medicalInsRuleProjectService.lambdaQuery().eq(MedicalInsRuleProject::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
|
|
|
- .eq(projectCodeFlag, MedicalInsRuleProject::getProjectCode, projectCode).eq(MedicalInsRuleProject::getState,Constant.EFF_STATE).list();
|
|
|
- List<String> correlationProjectCodeList = new ArrayList<>();
|
|
|
- String collectionProjectCode = null;
|
|
|
- if(CollectionUtil.isNotEmpty(medicalInsRuleProjectList)){
|
|
|
- if(medicalInsRuleProjectList.size()==1) {
|
|
|
- String jsonStr = JSON.toJSONString(medicalInsRuleProjectList.get(0));
|
|
|
- collectionProjectCode = medicalInsRuleProjectList.get(0).getCorrelationProjectCode();
|
|
|
- JSONObject ruleProjectJSONObject = JSON.parseObject(jsonStr);
|
|
|
- Map<String,Object> filterMap = filterMap(ruleProjectJSONObject);
|
|
|
- itemMap.putAll(filterMap);
|
|
|
- }else{
|
|
|
- correlationProjectCodeList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getProjectCode).collect(Collectors.toList());
|
|
|
- itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONPROJECTCODELIST, correlationProjectCodeList);
|
|
|
- }
|
|
|
+ .eq(projectCodeFlag, MedicalInsRuleProject::getProjectCode, projectCode).eq(MedicalInsRuleProject::getState, Constant.EFF_STATE).list();
|
|
|
+ List<String> correlationProjectCodeList = new ArrayList<>();
|
|
|
+ String collectionProjectCode = null;
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalInsRuleProjectList)) {
|
|
|
+ if (medicalInsRuleProjectList.size() == 1) {
|
|
|
+ String jsonStr = JSON.toJSONString(medicalInsRuleProjectList.get(0));
|
|
|
+ collectionProjectCode = medicalInsRuleProjectList.get(0).getCorrelationProjectCode();
|
|
|
+ JSONObject ruleProjectJSONObject = JSON.parseObject(jsonStr);
|
|
|
+ Map<String, Object> filterMap = filterMap(ruleProjectJSONObject);
|
|
|
+ itemMap.putAll(filterMap);
|
|
|
+ } else {
|
|
|
+ correlationProjectCodeList = medicalInsRuleProjectList.stream().map(MedicalInsRuleProject::getProjectCode).collect(Collectors.toList());
|
|
|
+ itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONPROJECTCODELIST, correlationProjectCodeList);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ if (diagnoseFlag) {
|
|
|
+ List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = null;
|
|
|
+ boolean conditionFlag = false;
|
|
|
+ if (StringUtils.isNotBlank(projectCode)) {
|
|
|
+ conditionFlag = true;
|
|
|
}
|
|
|
- if(diagnoseFlag){
|
|
|
- List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = null;
|
|
|
- boolean conditionFlag = false;
|
|
|
- if(StringUtils.isNotBlank(projectCode)) {
|
|
|
- conditionFlag = true;
|
|
|
- }
|
|
|
- medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(conditionFlag, MedicalInsRuleProjectDiagnose::getMedicalInsProjectCode, projectCode).eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
|
|
|
- .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 1).list();
|
|
|
- if(CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
|
|
|
- List<String> medicalDiagnoseStrList = medicalInsRuleProjectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode).collect(Collectors.toList());
|
|
|
- itemMap.put(SystemEventAttrConstant.MEDICAL_INS_MEDICALDIAGNOSECODELIST, medicalDiagnoseStrList);
|
|
|
- }
|
|
|
+ medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(conditionFlag, MedicalInsRuleProjectDiagnose::getMedicalInsProjectCode, projectCode).eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
|
|
|
+ .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 1).list();
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
|
|
|
+ List<String> medicalDiagnoseStrList = medicalInsRuleProjectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode).collect(Collectors.toList());
|
|
|
+ itemMap.put(SystemEventAttrConstant.MEDICAL_INS_MEDICALDIAGNOSECODELIST, medicalDiagnoseStrList);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if(correlationDiagnoseFlag){
|
|
|
- List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = null;
|
|
|
- boolean conditionFlag = false;
|
|
|
- if(StringUtils.isNotBlank(collectionProjectCode)) {
|
|
|
- conditionFlag = true;
|
|
|
- }
|
|
|
- medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(conditionFlag, MedicalInsRuleProjectDiagnose::getMedicalInsProjectCode, collectionProjectCode).eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
|
|
|
- .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 2).list();
|
|
|
- if(CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
|
|
|
- List<String> medicalDiagnoseStrList = medicalInsRuleProjectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode).collect(Collectors.toList());
|
|
|
- itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, medicalDiagnoseStrList);
|
|
|
- }
|
|
|
+ if (correlationDiagnoseFlag) {
|
|
|
+ List<MedicalInsRuleProjectDiagnose> medicalInsRuleProjectDiagnoseList = null;
|
|
|
+ boolean conditionFlag = false;
|
|
|
+ if (StringUtils.isNotBlank(collectionProjectCode)) {
|
|
|
+ conditionFlag = true;
|
|
|
}
|
|
|
+ medicalInsRuleProjectDiagnoseList = medicalInsRuleProjectDiagnoseService.lambdaQuery().eq(conditionFlag, MedicalInsRuleProjectDiagnose::getMedicalInsProjectCode, collectionProjectCode).eq(MedicalInsRuleProjectDiagnose::getMedicalInsRuleInfoId, medicalInsRuleInfo.getId())
|
|
|
+ .eq(MedicalInsRuleProjectDiagnose::getProjectCodeType, 2).list();
|
|
|
+ if (CollectionUtil.isNotEmpty(medicalInsRuleProjectDiagnoseList)) {
|
|
|
+ List<String> medicalDiagnoseStrList = medicalInsRuleProjectDiagnoseList.stream().map(MedicalInsRuleProjectDiagnose::getMedicalDiagnoseCode).collect(Collectors.toList());
|
|
|
+ itemMap.put(SystemEventAttrConstant.MEDICAL_INS_CORRELATIONMEDICALDIAGNOSECODE, medicalDiagnoseStrList);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Map<String,Object> filterMap(JSONObject ruleProjectJSONObject){
|
|
|
- Map<String,Object> filterMap = new HashMap<>();
|
|
|
- if(CollectionUtil.isNotEmpty(ruleProjectJSONObject)){
|
|
|
- for(Map.Entry<String,Object> entry:ruleProjectJSONObject.entrySet()){
|
|
|
- if(null != entry.getValue()){
|
|
|
- filterMap.put(Constant.MEDICAL_INS_KEY+entry.getKey(), entry.getValue());
|
|
|
+ public Map<String, Object> filterMap(JSONObject ruleProjectJSONObject) {
|
|
|
+ Map<String, Object> filterMap = new HashMap<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(ruleProjectJSONObject)) {
|
|
|
+ for (Map.Entry<String, Object> entry : ruleProjectJSONObject.entrySet()) {
|
|
|
+ if (null != entry.getValue()) {
|
|
|
+ filterMap.put(Constant.MEDICAL_INS_KEY + entry.getKey(), entry.getValue());
|
|
|
}
|
|
|
}
|
|
|
}
|