|
@@ -25,17 +25,18 @@ import com.diagbot.repository.LisCriticalRepository;
|
|
|
import com.diagbot.repository.PacsCriticalRepository;
|
|
|
import com.diagbot.repository.TransfusionRemindRepository;
|
|
|
import com.diagbot.service.ResultBillService;
|
|
|
+import com.diagbot.service.ResultCriticalService;
|
|
|
import com.diagbot.service.ResultInfoService;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.ExcelUtils;
|
|
|
import com.diagbot.util.FastJsonUtils;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.RespDTOUtil;
|
|
|
+import com.diagbot.vo.CriticalRuleVO;
|
|
|
import com.diagbot.vo.HospitalIdVO;
|
|
|
import com.diagbot.vo.IndicationPushVO;
|
|
|
-import com.diagbot.vo.RuleTestVO;
|
|
|
+import com.diagbot.vo.BillRuleVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
-import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -62,6 +63,9 @@ public class RuleTestFacade {
|
|
|
@Autowired
|
|
|
@Qualifier("resultInfoServiceImpl")
|
|
|
private ResultInfoService resultInfoService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("resultCriticalServiceImpl")
|
|
|
+ private ResultCriticalService resultCriticalService;
|
|
|
|
|
|
@Autowired
|
|
|
private LisConfigFacade lisConfigFacade;
|
|
@@ -97,13 +101,19 @@ public class RuleTestFacade {
|
|
|
/**
|
|
|
* 全规则测试
|
|
|
*
|
|
|
- * @param ruleTestVO
|
|
|
+ * @param hospitalIdVO
|
|
|
*/
|
|
|
- public Boolean ruleTest(RuleTestVO ruleTestVO) {
|
|
|
+ public Boolean ruleTest(HospitalIdVO hospitalIdVO) {
|
|
|
//开单合理性规则-通用
|
|
|
- billRuleTest(ruleTestVO);
|
|
|
+ BillRuleVO billRuleVO = new BillRuleVO();
|
|
|
+ billRuleVO.setHospitalId(hospitalIdVO.getHospitalId());
|
|
|
+ billRuleVO.setBillType(1);
|
|
|
+ billRuleVO.setCaseId(1l);
|
|
|
+ billRuleTest(billRuleVO);
|
|
|
//开单合理性规则-输血
|
|
|
- billTransfusionRuleTest(ruleTestVO);
|
|
|
+ billRuleVO.setBillType(2);
|
|
|
+ billRuleVO.setCaseId(2l);
|
|
|
+ billTransfusionRuleTest(billRuleVO);
|
|
|
//危急值规则-检验
|
|
|
//危急值规则-检查
|
|
|
//高危药品
|
|
@@ -114,10 +124,10 @@ public class RuleTestFacade {
|
|
|
/**
|
|
|
* 开单合理性测试
|
|
|
*
|
|
|
- * @param ruleTestVO
|
|
|
+ * @param billRuleVO
|
|
|
*/
|
|
|
- public Boolean billRuleTest(RuleTestVO ruleTestVO) {
|
|
|
- Long hospitalId = ruleTestVO.getHospitalId();
|
|
|
+ public Boolean billRuleTest(BillRuleVO billRuleVO) {
|
|
|
+ Long hospitalId = billRuleVO.getHospitalId();
|
|
|
|
|
|
List<BillItem> billRules = billManRepository.getAllRules();
|
|
|
//生成测试规则
|
|
@@ -128,17 +138,17 @@ public class RuleTestFacade {
|
|
|
//远程调用推理
|
|
|
List<ResultBill> saveList = callBill(resultList, hospitalId);
|
|
|
//保存测试结果
|
|
|
- saveResultBill(saveList, ruleTestVO, 1);
|
|
|
+ saveResultBill(saveList, billRuleVO);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 开单合理性测试-输血
|
|
|
*
|
|
|
- * @param ruleTestVO
|
|
|
+ * @param billRuleVO
|
|
|
*/
|
|
|
- public Boolean billTransfusionRuleTest(RuleTestVO ruleTestVO) {
|
|
|
- Long hospitalId = ruleTestVO.getHospitalId();
|
|
|
+ public Boolean billTransfusionRuleTest(BillRuleVO billRuleVO) {
|
|
|
+ Long hospitalId = billRuleVO.getHospitalId();
|
|
|
List<TransfusionRemind> billRules_transfusion = transfusionRemindRepository.findByStatus(StatusEnum.Enable.getKey());
|
|
|
//生成测试规则
|
|
|
List<ResultBill> resultList = ruleConvertFacade.billRuleConvert_transfusion(billRules_transfusion, hospitalId);
|
|
@@ -148,34 +158,45 @@ public class RuleTestFacade {
|
|
|
//远程调用推理
|
|
|
List<ResultBill> saveList = callBill(resultList, hospitalId);
|
|
|
//保存测试结果
|
|
|
- saveResultBill(saveList, ruleTestVO, 2);
|
|
|
+ saveResultBill(saveList, billRuleVO);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 危急值规则测试-检验
|
|
|
*
|
|
|
- * @param ruleTestVO
|
|
|
+ * @param criticalRuleVO
|
|
|
*/
|
|
|
- public void criticalLisRuleTest(RuleTestVO ruleTestVO) {
|
|
|
- Long hospitalId = ruleTestVO.getHospitalId();
|
|
|
+ public Boolean criticalLisRuleTest(CriticalRuleVO criticalRuleVO) {
|
|
|
+ Long hospitalId = criticalRuleVO.getHospitalId();
|
|
|
List<LisCritical> criticalRules_lis = lisCriticalRepository.findCustomByStatus(StatusEnum.Enable.getKey());
|
|
|
//生成测试规则
|
|
|
List<ResultCritical> resultList = ruleConvertFacade.criticalRuleConvert_lis(criticalRules_lis, hospitalId);
|
|
|
+ //远程调用推理
|
|
|
+ List<ResultCritical> saveList = callCritical(resultList, hospitalId);
|
|
|
+ //保存测试结果
|
|
|
+ saveResultCritical(saveList, criticalRuleVO);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 危急值规则测试-检查
|
|
|
*
|
|
|
- * @param ruleTestVO
|
|
|
+ * @param criticalRuleVO
|
|
|
*/
|
|
|
- public void criticalPacsRuleTest(RuleTestVO ruleTestVO) {
|
|
|
- Long hospitalId = ruleTestVO.getHospitalId();
|
|
|
+ public Boolean criticalPacsRuleTest(CriticalRuleVO criticalRuleVO) {
|
|
|
+ Long hospitalId = criticalRuleVO.getHospitalId();
|
|
|
List<PacsCritical> criticalRules_pacs = pacsCriticalRepository.findByStatus(StatusEnum.Enable.getKey());
|
|
|
//生成测试规则
|
|
|
List<ResultCritical> resultList = ruleConvertFacade.criticalRuleConvert_pacs(criticalRules_pacs, hospitalId);
|
|
|
+ //远程调用推理
|
|
|
+ List<ResultCritical> saveList = callCritical(resultList, hospitalId);
|
|
|
+ //保存测试结果
|
|
|
+ saveResultCritical(saveList, criticalRuleVO);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 数据导出
|
|
|
*
|
|
@@ -295,14 +316,68 @@ public class RuleTestFacade {
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 危急值远程调用接口
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @param hospitalId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ResultCritical> callCritical(List<ResultCritical> list, Long hospitalId) {
|
|
|
+ List<ResultCritical> retList = Lists.newLinkedList();
|
|
|
+ if (ListUtil.isEmpty(list)) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+ for (ResultCritical result : list) {
|
|
|
+ if (result.getSuccess() != null
|
|
|
+ && result.getSuccess().equals(0)) {
|
|
|
+ retList.add(result);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ IndicationPushVO indicationPushVO = searchDataFacade.creatCriticalVO(result);
|
|
|
+ indicationPushVO.setHospitalId(hospitalId);
|
|
|
+
|
|
|
+ result.setInputParams(FastJsonUtils.getBeanToJson(indicationPushVO));
|
|
|
+
|
|
|
+ RespDTO<IndicationDTO> respDTO = cdssCoreClient.indication(indicationPushVO);
|
|
|
+ if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
+ IndicationDTO data = respDTO.data;
|
|
|
+ List<BillMsg> billMsgList = data.getCriticalValList();
|
|
|
+ if (ListUtil.isEmpty(billMsgList)) {
|
|
|
+ result.setSuccess(0);
|
|
|
+ result.setMessage("未提示开单项");
|
|
|
+ retList.add(result);
|
|
|
+ } else {
|
|
|
+ for (BillMsg billMsg : billMsgList) {
|
|
|
+ ResultCritical saveResult = new ResultCritical();
|
|
|
+ BeanUtil.copyProperties(result, saveResult);
|
|
|
+ saveResult.setOutput(billMsg.getMsg());
|
|
|
+ if (saveResult.getOutput().equals(saveResult.getExpectedOutput())) {
|
|
|
+ saveResult.setSuccess(1);
|
|
|
+ } else {
|
|
|
+ saveResult.setSuccess(0);
|
|
|
+ saveResult.setMessage("提示内容与预期不符");
|
|
|
+ }
|
|
|
+ retList.add(saveResult);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.setSuccess(0);
|
|
|
+ result.setMessage("远程调用推理接口失败");
|
|
|
+ retList.add(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存开单合理性测试结果
|
|
|
+ *
|
|
|
* @param list
|
|
|
- * @param ruleTestVO
|
|
|
- * @param billType
|
|
|
+ * @param billRuleVO
|
|
|
* @return
|
|
|
*/
|
|
|
- public Boolean saveResultBill(List<ResultBill> list, RuleTestVO ruleTestVO, Integer billType) {
|
|
|
+ public Boolean saveResultBill(List<ResultBill> list, BillRuleVO billRuleVO) {
|
|
|
//保存测试结果
|
|
|
Date now = new Date();
|
|
|
Integer totleNum = list.size();
|
|
@@ -310,13 +385,13 @@ public class RuleTestFacade {
|
|
|
Integer failedNum = list.stream().filter(i -> i.getSuccess().equals(0)).collect(Collectors.toList()).size();
|
|
|
QueryWrapper<ResultInfo> resultInfoQueryWrapper = new QueryWrapper<>();
|
|
|
resultInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("hospital_id", ruleTestVO.getHospitalId())
|
|
|
- .eq("case_id", ruleTestVO.getCaseId());
|
|
|
+ .eq("hospital_id", billRuleVO.getHospitalId())
|
|
|
+ .eq("case_id", billRuleVO.getCaseId());
|
|
|
ResultInfo resultInfo = resultInfoService.getOne(resultInfoQueryWrapper, false);
|
|
|
if (resultInfo == null) {
|
|
|
resultInfo = new ResultInfo();
|
|
|
- resultInfo.setHospitalId(ruleTestVO.getHospitalId());
|
|
|
- resultInfo.setCaseId(ruleTestVO.getCaseId());
|
|
|
+ resultInfo.setHospitalId(billRuleVO.getHospitalId());
|
|
|
+ resultInfo.setCaseId(billRuleVO.getCaseId());
|
|
|
resultInfo.setGmtCreate(now);
|
|
|
}
|
|
|
resultInfo.setGmtModified(now);
|
|
@@ -330,7 +405,7 @@ public class RuleTestFacade {
|
|
|
resultBillService.remove(resultBillQueryWrapper);
|
|
|
|
|
|
for (ResultBill resultBill : list) {
|
|
|
- resultBill.setBillType(billType);
|
|
|
+ resultBill.setBillType(billRuleVO.getBillType());
|
|
|
resultBill.setGmtCreate(now);
|
|
|
resultBill.setGmtModified(now);
|
|
|
resultBill.setResultId(resultInfo.getId());
|
|
@@ -339,4 +414,49 @@ public class RuleTestFacade {
|
|
|
resultBillService.saveOrUpdateBatch(list);
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存危急值测试结果
|
|
|
+ *
|
|
|
+ * @param list
|
|
|
+ * @param criticalRuleVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean saveResultCritical(List<ResultCritical> list, CriticalRuleVO criticalRuleVO) {
|
|
|
+ //保存测试结果
|
|
|
+ Date now = new Date();
|
|
|
+ Integer totleNum = list.size();
|
|
|
+ Integer successNum = list.stream().filter(i -> i.getSuccess().equals(1)).collect(Collectors.toList()).size();
|
|
|
+ Integer failedNum = list.stream().filter(i -> i.getSuccess().equals(0)).collect(Collectors.toList()).size();
|
|
|
+ QueryWrapper<ResultInfo> resultInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ resultInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", criticalRuleVO.getHospitalId())
|
|
|
+ .eq("case_id", criticalRuleVO.getCaseId());
|
|
|
+ ResultInfo resultInfo = resultInfoService.getOne(resultInfoQueryWrapper, false);
|
|
|
+ if (resultInfo == null) {
|
|
|
+ resultInfo = new ResultInfo();
|
|
|
+ resultInfo.setHospitalId(criticalRuleVO.getHospitalId());
|
|
|
+ resultInfo.setCaseId(criticalRuleVO.getCaseId());
|
|
|
+ resultInfo.setGmtCreate(now);
|
|
|
+ }
|
|
|
+ resultInfo.setGmtModified(now);
|
|
|
+ resultInfo.setRuleNum(totleNum);
|
|
|
+ resultInfo.setRuleSuccessNum(successNum);
|
|
|
+ resultInfo.setRuleFailedNum(failedNum);
|
|
|
+ resultInfoService.saveOrUpdate(resultInfo);
|
|
|
+
|
|
|
+ QueryWrapper<ResultCritical> resultCriticalQueryWrapper = new QueryWrapper<>();
|
|
|
+ resultCriticalQueryWrapper.eq("result_id", resultInfo.getId());
|
|
|
+ resultCriticalService.remove(resultCriticalQueryWrapper);
|
|
|
+
|
|
|
+ for (ResultCritical result : list) {
|
|
|
+ result.setCriticalType(criticalRuleVO.getCriticalType());
|
|
|
+ result.setGmtCreate(now);
|
|
|
+ result.setGmtModified(now);
|
|
|
+ result.setResultId(resultInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ resultCriticalService.saveOrUpdateBatch(list);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|