Преглед изворни кода

Merge branch 'dev/20201224_2.0.0' into debug

chengyao пре 4 година
родитељ
комит
586d3be80b

Разлика између датотеке није приказан због своје велике величине
+ 279 - 11
doc/029.20201224v2.0.0/qc_initv2.0.0.sql


+ 157 - 76
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -270,48 +270,6 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         return res;
     }
 
-    /**
-     *  仅获取缺陷总揽提示信息
-     *
-     * @param analyzeRunVO
-     * @return
-     */
-    public List<MsgDTO> getMsgByBehospitalCode(AnalyzeRunVO analyzeRunVO) {
-        // 获取病历信息
-        BehospitalInfo behospitalInfo = this.getOne(new QueryWrapper<BehospitalInfo>()
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .eq("hospital_id", analyzeRunVO.getHospitalId())
-                .eq("behospital_code", analyzeRunVO.getBehospitalCode()), false
-        );
-        if (null == behospitalInfo) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该病历不存在或已删除!");
-        }
-        // 获取质控条目
-        AnalyzeVO analyzeVO = new AnalyzeVO();
-        BeanUtil.copyProperties(analyzeRunVO, analyzeVO);
-        List<QcCasesEntryDTO> qcCasesEntryDTOList = qcCasesEntryFacade.getQcCasesEntry(analyzeVO);
-        if (ListUtil.isEmpty(qcCasesEntryDTOList)) {
-            throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病历无关联的质控条目!");
-        }
-
-        List<MsgDTO> msgDTOList = getMsg(analyzeVO);
-            if (ListUtil.isNotEmpty(msgDTOList)) {
-                // 从qc_question_info的cases_entry_ids获取
-                Map<String, Object> paramMap = new HashMap<>();
-                paramMap.put("hospitalId",  analyzeRunVO.getHospitalId());
-                paramMap.put("casesEntryIds", msgDTOList.stream().map(r -> r.getCasesEntryId()).collect(Collectors.toList()));
-                Map<Long, List<QuestionEntryDTO>> quesEntryMap = qcQuestionFacade.getByCaseEntryIdsFac(paramMap);
-                for (MsgDTO msgDTO : msgDTOList) {
-                    if (quesEntryMap.get(msgDTO.getCasesEntryId()) != null) {
-                        msgDTO.setPageKeyList(quesEntryMap.get(msgDTO.getCasesEntryId())
-                                .stream().map(r -> r.getId()).collect(Collectors.toList()));
-                    }
-                }
-            }
-        return msgDTOList;
-    }
-
-
     /**
      * 处理数据(公共方法)
      *
@@ -1566,23 +1524,115 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     /**
      * 评分api
      *
-     * @param analyzeApiVO
+     * @param analyzeRunVO
      * @return
      */
-    public Map<String, Object> analyzeApi(AnalyzeApiVO analyzeApiVO) {
+    public Map<String, Object> analyzeApi(AnalyzeRunVO analyzeRunVO) {
+        Map<String, Object> resMapData = new HashMap<>(); // 返回结果
         AnalyzeVO analyzeVO = new AnalyzeVO();
-        BeanUtil.copyProperties(analyzeApiVO, analyzeVO);
-        // 评分
-        analyze(analyzeVO);
-        // 获取结果
-        GetDetailVO getDetailVO = new GetDetailVO();
-        getDetailVO.setHospitalId(analyzeApiVO.getHospitalId());
-        getDetailVO.setBehospitalCode(analyzeApiVO.getBehospitalCode());
-        getDetailVO.setNeedGroup(analyzeApiVO.getNeedGroup());
-        return getByBehospitalCodeApi(getDetailVO);
+        BeanUtil.copyProperties(analyzeRunVO, analyzeVO);
+        Long hospitalId = analyzeVO.getHospitalId();
+        // 获取病历信息
+        BehospitalInfo behospitalInfo = this.getOne(new QueryWrapper<BehospitalInfo>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", analyzeRunVO.getHospitalId())
+                .eq("behospital_code", analyzeRunVO.getBehospitalCode()), false
+        );
+        if (null == behospitalInfo) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该病历不存在或已删除!");
+        }
+        // 处理公共数据
+        QueryVo queryVo = dealCommonData(hospitalId, analyzeVO);
+        //  调用质控接口
+        Response<OutputInfo> response = qcServiceClient.extract(queryVo);
+        if (response == null || response.getData() == null) {
+            if (null == response) {
+                throw new CommonException(CommonErrorCode.RPC_ERROR, "远程质控接口没有返回数据!【" + analyzeVO.getBehospitalCode() + "】");
+            } else {
+                throw new CommonException(CommonErrorCode.RPC_ERROR,
+                        "远程质控接口没有返回数据!【" + analyzeVO.getBehospitalCode() + "】错误原因:" + response.getMsg());
+            }
+        }
+        OutputInfo outputInfo = response.getData();
+        // 质控编码列表
+        List<String> codeList = new ArrayList<>();
+        // code和info的映射map
+        Map<String, String> codeToInfoMap = new LinkedHashMap<>();
+        // 对codeList 和 codeToInfoMap进行赋值
+        setCodeData(outputInfo, codeList, codeToInfoMap);
+        AlgorithmDTO algorithmDTO = new AlgorithmDTO();
+        // 如果是1,说明已是终末质控,不再保存质控结果数据;如果是0,则保存质控结果数据
+        if ("0".equals(analyzeRunVO.getIsPlacefile())) {
+            Map<String, Object> resMap = calScoreAndSave(outputInfo, codeList, codeToInfoMap, analyzeVO, queryVo.getBehospitalInfo().getIsPlacefile());
+            algorithmDTO = (AlgorithmDTO) resMap.get("algorithmDTO");
+        }else{
+            //终末质控不保存数据
+            Map<String, Object> resMap = calScore(outputInfo, codeList, codeToInfoMap, analyzeVO, queryVo.getBehospitalInfo().getIsPlacefile());
+            algorithmDTO = (AlgorithmDTO) resMap.get("algorithmDTO");
+        }
+
+        List<MsgDTO> msgDTOList = getMsg(analyzeVO);
+        if (ListUtil.isNotEmpty(msgDTOList)) {
+            // 从qc_question_info的cases_entry_ids获取
+            Map<String, Object> paramMap = new HashMap<>();
+            paramMap.put("hospitalId",  analyzeRunVO.getHospitalId());
+            paramMap.put("casesEntryIds", msgDTOList.stream().map(r -> r.getCasesEntryId()).collect(Collectors.toList()));
+            Map<Long, List<QuestionEntryDTO>> quesEntryMap = qcQuestionFacade.getByCaseEntryIdsFac(paramMap);
+            for (MsgDTO msgDTO : msgDTOList) {
+                if (quesEntryMap.get(msgDTO.getCasesEntryId()) != null) {
+                    msgDTO.setPageKeyList(quesEntryMap.get(msgDTO.getCasesEntryId())
+                            .stream().map(r -> r.getId()).collect(Collectors.toList()));
+                }
+            }
+        }
+
+        //返回参数组装
+        BigDecimal bigDecimal = new BigDecimal(0);
+        BigDecimal res = new BigDecimal(120);
+        BigDecimal resPr = new BigDecimal(100);
+        String reNum = "0";
+        SysHospitalSet sysHospitalSet
+                = sysHospitalSetFacade.getOne(new QueryWrapper<SysHospitalSet>()
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq("hospital_id", analyzeRunVO.getHospitalId())
+                , false);
+        if (null != sysHospitalSet && sysHospitalSet.getValue().equals("1")) {
+            //百分制
+            reNum = "1";
+        }
+        QcResultApiDTO qcResultApiDTO = new QcResultApiDTO();
+        if(StringUtils.isNotEmpty(algorithmDTO.getLevel()) && algorithmDTO.getScore()!=null && msgDTOList != null){
+            if("1".equals(reNum)) {
+                bigDecimal = resPr.subtract(algorithmDTO.getScore());
+            }else if("0".equals(reNum)){
+                bigDecimal = res.subtract(algorithmDTO.getScore().multiply(new BigDecimal(120))
+                        .divide(new BigDecimal(100), 1, RoundingMode.HALF_UP));
+            }
+
+        //缺陷总数
+        Long num = msgDTOList
+                .stream()
+                .filter(Objects::nonNull)
+                .count();
+            qcResultApiDTO.setScoreRes(algorithmDTO.getScore());
+            qcResultApiDTO.setLevel(algorithmDTO.getLevel());
+            qcResultApiDTO.setNum(num);
+            qcResultApiDTO.setNumScore(bigDecimal);
+            resMapData.put("result", qcResultApiDTO);
+            List<MsgApiDTO> msgApiDTOList = BeanUtil.listCopyTo(msgDTOList, MsgApiDTO.class);
+            if (analyzeRunVO.getNeedGroup() == 0) {
+                resMapData.put("details", msgApiDTOList);
+            } else {
+                Map<String, List<MsgApiDTO>> msgMap = EntityUtil.makeEntityListMap(msgApiDTOList, "modelName");
+                resMapData.put("details", msgMap);
+            }
+        };
+        return resMapData;
     }
 
 
+
+
     /**
      * 获取明细api
      *
@@ -1668,31 +1718,62 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
      * @return
      */
     public AnalyzeRunDTO analyzeRun(AnalyzeRunVO analyzeRunVO) {
-        List<MsgDTO> msgDTOList = this.getMsgByBehospitalCode(analyzeRunVO);
+        Long modeId = analyzeRunVO.getModeId();
+        analyzeRunVO.setModeId(null);
+        AnalyzeVO analyzeVO = new AnalyzeVO();
+        BeanUtil.copyProperties(analyzeRunVO, analyzeVO);
+        Long hospitalId = analyzeVO.getHospitalId();
+
+        // 处理公共数据
+            QueryVo queryVo = dealCommonData(hospitalId, analyzeVO);
+        //  调用质控接口
+        Response<OutputInfo> response = qcServiceClient.extract(queryVo);
+        if (response == null || response.getData() == null) {
+            if (null == response) {
+                throw new CommonException(CommonErrorCode.RPC_ERROR, "远程质控接口没有返回数据!【" + analyzeVO.getBehospitalCode() + "】");
+            } else {
+                throw new CommonException(CommonErrorCode.RPC_ERROR,
+                        "远程质控接口没有返回数据!【" + analyzeVO.getBehospitalCode() + "】错误原因:" + response.getMsg());
+            }
+        }
+        OutputInfo outputInfo = response.getData();
+        // 质控编码列表
+        List<String> codeList = new ArrayList<>();
+        // code和info的映射map
+        Map<String, String> codeToInfoMap = new LinkedHashMap<>();
+        // 对codeList 和 codeToInfoMap进行赋值
+        setCodeData(outputInfo, codeList, codeToInfoMap);
+
+        // 如果是1,说明已是终末质控,不再保存质控结果数据;如果是0,则保存质控结果数据
+        if ("0".equals(analyzeRunVO.getIsPlacefile())) {
+            // 计算分值并保存结果至数据库
+            Map<String, Object> resMap = calScoreAndSave(outputInfo, codeList, codeToInfoMap, analyzeVO, queryVo.getBehospitalInfo().getIsPlacefile());
+        }
+
+        // 返回缺陷提示信息
+        List<MsgDTO> msgDTOList = new ArrayList<>();
+        if (ListUtil.isNotEmpty(codeList)) {
+            AnalyzeCodeVO analyzeCodeVO = new AnalyzeCodeVO();
+            analyzeCodeVO.setCodeList(codeList);
+            analyzeCodeVO.setHospitalId(hospitalId);
+            analyzeCodeVO.setModeId(modeId);
+            // 获取缺陷条目信息
+            msgDTOList = getMsgByEntryCode(analyzeCodeVO);
+            // 设置info信息
+            if (codeToInfoMap != null && !codeToInfoMap.isEmpty()) {
+                for (MsgDTO msgDTO : msgDTOList) {
+                    String info = codeToInfoMap.get(msgDTO.getCode());
+                    if (StringUtil.isNotBlank(info)) {
+                        msgDTO.setInfo(info);
+                    }
+                }
+            }
+        }
+
         //返回参数组装
         AnalyzeRunDTO analyzeRunDTO = new AnalyzeRunDTO();
-        //缺陷总扣分
-        BigDecimal numScore = msgDTOList
-                .stream()
-                .map(MsgDTO::getScore)
-                .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
-        //缺陷总数
-        Long num = msgDTOList
-                .stream()
-                .filter(Objects::nonNull)
-                .count();
-        analyzeRunDTO.setNum(num);
-        analyzeRunDTO.setNumScore(numScore);
-        QcresultInfo qcresultInfo = qcresultInfoFacade.getOne(new QueryWrapper<QcresultInfo>()
-                .eq("behospital_code", analyzeRunVO.getBehospitalCode())
-                .eq("hospital_id", analyzeRunVO.getHospitalId())
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .select("behospital_code", "level", "score_res"));
-        BigDecimal bigDecimal = new BigDecimal(0);
-        if(null != qcresultInfo){
-            analyzeRunDTO.setLevel(qcresultInfo.getLevel()==null?"":qcresultInfo.getLevel());
-            analyzeRunDTO.setScoreRes(qcresultInfo.getScoreRes() ==null ? bigDecimal : qcresultInfo.getScoreRes());
-        }
+        // analyzeRunDTO.setScoreRes(algorithmDTO.getScore());
+        // analyzeRunDTO.setLevel(algorithmDTO.getLevel());
         analyzeRunDTO.setMsgDTOList(msgDTOList);
         return analyzeRunDTO;
     }

+ 2 - 2
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -122,8 +122,8 @@ public class BehospitalInfoController {
     @SysLogger("analyze_api")
     @Transactional
     //    @ApiIgnore
-    public RespDTO<Map<String, Object>> analyzeApi(@RequestBody AnalyzeApiVO analyzeApiVO) {
-        return RespDTO.onSuc(behospitalInfoFacade.analyzeApi(analyzeApiVO));
+    public RespDTO<Map<String, Object> > analyzeApi(@RequestBody AnalyzeRunVO analyzeRunVO) {
+        return RespDTO.onSuc(behospitalInfoFacade.analyzeApi(analyzeRunVO));
     }
 
 

+ 8 - 8
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -7926,8 +7926,8 @@
             AND t1.hospital_id = t2.hospital_id
             AND t1.behospital_code = t2.behospital_code
             AND (
-            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
-            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
+            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
+            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
             )
         </if>
         <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
@@ -8154,8 +8154,8 @@
             AND t1.hospital_id = t2.hospital_id
             AND t1.behospital_code = t2.behospital_code
             AND (
-            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
-            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
+            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
+            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
             )
         </if>
         <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
@@ -8443,8 +8443,8 @@
             AND t1.hospital_id = t2.hospital_id
             AND t1.behospital_code = t2.behospital_code
             AND (
-            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
-            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
+            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
+            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
             )
         </if>
         <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
@@ -8680,8 +8680,8 @@
             AND t1.hospital_id = t2.hospital_id
             AND t1.behospital_code = t2.behospital_code
             AND (
-            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' )
-            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' )
+            ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
+            OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
             )
         </if>
         <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">