Explorar el Código

事前提醒引擎和接口

0027005599 hace 2 años
padre
commit
b9e973269f

+ 5 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/controller/HisController.java

@@ -84,8 +84,10 @@ public class HisController extends JeecgController<Audit, IAuditService> {
    @AutoLog(value = "事前提醒")
    @ApiOperation(value="事前提醒接口", notes="事前提醒接口调用")
    @PostMapping(value = "/advanceWarning")
-   public Result<String> advanceWarning(@RequestBody AdvanceWarningVO advanceWarningVO) {
-
+   public Result<String> advanceWarning(@RequestBody AdvanceWarningVO advanceWarningVO,HttpServletRequest httpServletRequest) {
+       String ipStr = HttpUtils.getIPAddress(httpServletRequest);
+       log.info("事前远端请求的服务ip地址:{}", ipStr);
+       ruleEngine.dealPreInterfaceEngin(advanceWarningVO, ipStr);
        return Result.OK("添加成功!");
    }
 
@@ -102,7 +104,7 @@ public class HisController extends JeecgController<Audit, IAuditService> {
     public Result<String> midIncidentWarning(@RequestBody MidIncidentWarningVO midIncidentWarningVO,HttpServletRequest httpServletRequest) {
 
         String ipStr = HttpUtils.getIPAddress(httpServletRequest);
-        log.info("远端请求的服务ip地址:{}", ipStr);
+        log.info("事中远端请求的服务ip地址:{}", ipStr);
         ruleEngine.dealMidInterfaceEngin("midIncidentWarning", midIncidentWarningVO, ipStr);
         return Result.OK("添加成功!");
     }

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

@@ -69,34 +69,7 @@ public class AdvanceWarningAudit implements Serializable {
 	@Excel(name = "患者姓名", width = 15)
     @ApiModelProperty(value = "患者姓名")
     private java.lang.String patientName;
-	/**住院号/门诊号*/
-	@Excel(name = "住院号/门诊号", width = 15)
-    @ApiModelProperty(value = "住院号/门诊号")
-    private java.lang.String outpatientNumber;
-	/**医嘱号/处方号*/
-	@Excel(name = "医嘱号/处方号", width = 15)
-    @ApiModelProperty(value = "医嘱号/处方号")
-    private java.lang.String prescriptionNumber;
-	/**反馈结果*/
-	@Excel(name = "反馈结果", width = 15)
-    @ApiModelProperty(value = "反馈结果")
-    private java.lang.String feedbackResult;
-	/**反馈编码*/
-	@Excel(name = "反馈编码", width = 15)
-    @ApiModelProperty(value = "反馈编码")
-    private java.lang.String feedbackCode;
-	/**上个审核人员*/
-	@Excel(name = "上个审核人员", width = 15)
-    @ApiModelProperty(value = "上个审核人员")
-    private java.lang.String preCheckBy;
-	/**审核人*/
-	@Excel(name = "审核人", width = 15)
-    @ApiModelProperty(value = "审核人")
-    private java.lang.String checkBy;
-	/**审核状态*/
-	@Excel(name = "审核状态", width = 15)
-    @ApiModelProperty(value = "审核状态")
-    private java.lang.String checkState;
+
 	/**创建人*/
     @ApiModelProperty(value = "创建人")
     private java.lang.String createBy;

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

@@ -36,6 +36,10 @@ public class AdvanceWarningAuditDetail implements Serializable {
 	@TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键ID")
     private java.lang.Integer id;
+    /**事前提醒工单表ID*/
+    @Excel(name = "事前提醒工单表ID", width = 15)
+    @ApiModelProperty(value = "事前提醒工单表ID")
+    private java.lang.Integer advanceWarningAuditId;
 	/**医保规则ID*/
 	@Excel(name = "医保规则ID", width = 15)
     @ApiModelProperty(value = "医保规则ID")

+ 9 - 10
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/AdvanceWarningVO.java

@@ -10,19 +10,18 @@ import lombok.Data;
 @Data
 @ApiModel(value="事前提醒接口参数类", description="advanceWarning")
 public class AdvanceWarningVO {
-//    病人ID
-
+    //    病人ID
     private String patient_id;
-
-//    科室编码
-
+    //病人姓名
+    private String patient_name;
+    //就诊类型(1住院、2门诊)
+    private String visit_type;
+    //    科室编码
     private String medical_dept_code;
-//    科室名称
-
+    //    科室名称
     private String medical_dept_name;
-//    医师编号
-
+    //    医师编号
     private String doctor_code;
-//    医师姓名
+    //    医师姓名
     private String doctor_name;
 }

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

@@ -32,7 +32,7 @@ import lombok.experimental.Accessors;
 public class TreatmentItems implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    @TableId(type = IdType.ASSIGN_ID)
+    @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键")
     private String id;
 

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

@@ -9,6 +9,8 @@ import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.util.SpringContextUtils;
 import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.EnchanceTypeEnum;
+import org.jeecg.modules.medical.entity.AdvanceWarningAudit;
+import org.jeecg.modules.medical.entity.AdvanceWarningAuditDetail;
 import org.jeecg.modules.medical.entity.AfterwardsAudit;
 import org.jeecg.modules.medical.entity.AfterwardsAuditDetail;
 import org.jeecg.modules.medical.entity.EventAttr;
@@ -21,6 +23,7 @@ import org.jeecg.modules.medical.entity.MidIncidentAuditDetail;
 import org.jeecg.modules.medical.entity.MidIncidentWarningVO;
 import org.jeecg.modules.medical.entity.RuleFactorRela;
 import org.jeecg.modules.medical.ruleengine.dict.DictUtil;
+import org.jeecg.modules.medical.service.IAdvanceWarningAuditDetailService;
 import org.jeecg.modules.medical.service.IAfterwardsAuditDetailService;
 import org.jeecg.modules.medical.service.IAfterwardsAuditService;
 import org.jeecg.modules.medical.service.IEventAttrService;
@@ -68,6 +71,8 @@ public class FactorEnchangeFactory {
     @Autowired
     IAfterwardsAuditDetailService afterwardsAuditDetailService;
     @Autowired
+    IAdvanceWarningAuditDetailService advanceWarningAuditDetailService;
+    @Autowired
     SqlUtil sqlUtil;
 
     public static Map<Integer, EventAttr> enchanceAttrMap = new HashMap<>();
@@ -152,10 +157,13 @@ public class FactorEnchangeFactory {
     }
 
     public void insertWarningDetail(Map<String, Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, Object audit, List<Map<String, Object>> itemList) {
-        if(null == audit || CollectionUtil.isEmpty(itemList)){
+        if (null == audit || CollectionUtil.isEmpty(itemList)) {
             return;
         }
-        if (audit instanceof MidIncidentAudit) {
+        if (audit instanceof AdvanceWarningAudit) {
+            AdvanceWarningAudit advanceWarningAudit = (AdvanceWarningAudit) audit;
+            insertAdvanceWaringDetail(itemMap, medicalInsRuleInfo, advanceWarningAudit);
+        } else if (audit instanceof MidIncidentAudit) {
             MidIncidentAudit midIncidentAudit = (MidIncidentAudit) audit;
             insertMidWarningDetail(itemMap, medicalInsRuleInfo, midIncidentAudit, itemList);
         } else {
@@ -164,6 +172,25 @@ public class FactorEnchangeFactory {
         }
     }
 
+    public void insertAdvanceWaringDetail(Map<String,Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo, AdvanceWarningAudit advanceWarningAudit){
+        AdvanceWarningAuditDetail advanceWarningAuditDetail = new AdvanceWarningAuditDetail();
+        advanceWarningAuditDetail.setAdvanceWarningAuditId(advanceWarningAudit.getId());
+        advanceWarningAuditDetail.setDoctorId(advanceWarningAudit.getDoctorId());
+        advanceWarningAuditDetail.setDoctorName(advanceWarningAudit.getDoctorName());
+        advanceWarningAuditDetail.setCreateTime(new Date(System.currentTimeMillis()));
+        advanceWarningAuditDetail.setMedicalDeptCode(advanceWarningAudit.getMedicalDeptCode());
+        advanceWarningAuditDetail.setMedicalDeptName(advanceWarningAudit.getMedicalDeptName());
+        advanceWarningAuditDetail.setPatientId(advanceWarningAudit.getPatientId());
+        advanceWarningAuditDetail.setPatientName(advanceWarningAudit.getPatientName());
+        advanceWarningAuditDetail.setNoticeType("事前提醒");
+        advanceWarningAuditDetail.setMedicalInsRuleInfoCode(medicalInsRuleInfo.getRuleCode());
+        advanceWarningAuditDetail.setMedicalInsRuleInfoName(medicalInsRuleInfo.getRuleName());
+        advanceWarningAuditDetail.setTreatmentType(advanceWarningAudit.getTreatmentType());
+        advanceWarningAuditDetail.setNoticeType(advanceWarningAudit.getNoticeType());
+        advanceWarningAuditDetail.setDescription(medicalInsRuleInfo.getDescription());
+        advanceWarningAuditDetailService.save(advanceWarningAuditDetail);
+    }
+
     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())) {

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

@@ -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);
+            }
+        }
+    }
+
     /**
      * 事后跑统计类规则引擎
      *