Browse Source

返回前台接口完善

chengyao 4 years ago
parent
commit
763780c6ba
1 changed files with 288 additions and 59 deletions
  1. 288 59
      src/main/java/com/diagbot/facade/ConsoleFacade.java

+ 288 - 59
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -520,10 +520,54 @@ public class ConsoleFacade {
                 hashMapArrayList.add(stringStringHashMap);
             }
         }
+        /**
+         * =================================返回前台-标示线========================================
+         */
+
+        Map<String, Object> baseIndex = behospitalInfoFacade.getBaseIndex(filterVO);
+        //指标一、二、三
+        if (QualityContent.FOURSTR.contains(indexName)||indexName.equals(QualityContent.QB)) {
+            hashMapArrayList = ManageIndexMethod(indexName, hashMapArrayList, baseIndex, filterVO);
+        }
+
+        //指标二十七
+        if (indexName.equals(QualityContent.JJBLL)||indexName.equals(QualityContent.QB)) {
+            hashMapArrayList = firMethod(indexName,hashMapArrayList,baseIndex);
+        }
+
+
+        //指标十七 医师查房记录
+        if (indexName.equals(QualityContent.YSCF_JL_WCL)||indexName.equals(QualityContent.QB)) {
+            hashMapArrayList = WardRoundMethod(hashMapArrayList, baseIndex, triggeringRulesMap);
+        }
+
+        //指标十八 抢救记录
+        if (indexName.equals(QualityContent.HZQJ_JLJS_WCL)||indexName.equals(QualityContent.QB)) {
+            hashMapArrayList = rescueMethod(medicalRecordIndicator,hashMapArrayList,triggeringRulesMap);
+        }
+
+        //指标十九 出院患者病历2日归档
+        if (indexName.equals(QualityContent.CCHZ_2DAY_GDL)||indexName.equals(QualityContent.QB)) {
+            hashMapArrayList = getfileSecAmount(medicalRecordIndicator,hashMapArrayList, baseIndex);
+        }
+
+
+        //指标十四 手术记录
+        if (indexName.equals(QualityContent.SS_XGJL_WCL)||indexName.equals(QualityContent.QB)) {
+            hashMapArrayList = operationMethod(medicalRecordIndicator,hashMapArrayList,triggeringRulesMap);
+        }
+
+
+        //指标十六  临床用血相关记录符合率
+        if (indexName.equals(QualityContent.LCYX_XGJL_WCL)||indexName.equals(QualityContent.QB)) {
+            filterVO.setFlagStr("1");
+            hashMapArrayList = bloodMethod(hashMapArrayList,medicalRecordIndicator,triggeringRulesMap);
+        }
         return hashMapArrayList;
     }
 
 
+
     /**
      * 病案指标数据保存
      *
@@ -540,6 +584,7 @@ public class ConsoleFacade {
         return true;
     }
 
+
     /**
      * 病案指标数据保存
      *
@@ -553,9 +598,8 @@ public class ConsoleFacade {
         //出院人数
         Long startCount = selectOperationNumMap.get(QualityContent.DISCHARGED_PATIENTS);
             Long operationFeeNum = 0L;
-            List<MedManageParamsDTO> doctorAdviceMedManageParams  = new ArrayList<>();
                 filterVO.setFlagStr("2");
-                doctorAdviceMedManageParams = behospitalInfoFacade.getMedManageParams(filterVO);
+        List<MedManageParamsDTO> doctorAdviceMedManageParams = behospitalInfoFacade.getMedManageParams(filterVO);
                 Map<String, Long> adviceNum = getAdviceNum(filterVO,doctorAdviceMedManageParams);
                 //手术人数
                 operationFeeNum = selectOperationNumMap.get("operationFee");
@@ -605,7 +649,7 @@ public class ConsoleFacade {
                     }
 
         /**
-         * =================================标示线========================================
+         * ================================保存数据-标示线========================================
          */
         Map<String, Object> baseIndex = behospitalInfoFacade.getBaseIndex(filterVO);
         //指标二十七
@@ -613,15 +657,15 @@ public class ConsoleFacade {
         //指标十七 医师查房记录
 
         //指标十八 抢救记录
-        rescueMethod(doctorAdviceMedManageParams,medIndexResult);
+        rescueMethods(doctorAdviceMedManageParams,medIndexResult);
         //指标十九 出院患者病历2日归档
-        getfileSecAmount(filterVO,baseIndex,medIndexResult);
+        getfileSecAmounts(filterVO,baseIndex,medIndexResult);
         //指标十四 手术记录
         medIndexResult.setOperationCompleteResult(Double.parseDouble(operationFeeNum+""));
         //指标十六  临床用血相关记录符合率
         filterVO.setFlagStr("1");
         List<MedManageParamsDTO> medManageParams = behospitalInfoFacade.getMedManageParams(filterVO);
-        bloodMethod(doctorAdviceMedManageParams, medManageParams,medIndexResult);
+        bloodMethods(doctorAdviceMedManageParams, medManageParams,medIndexResult);
         medIndexResult.setHospitalId(filterVO.getHospitalId());
         medIndexResult.setStartDate(filterVO.getStartDate());
         medIndexResult.setEndDate(filterVO.getEndDate());
@@ -2721,9 +2765,200 @@ public class ConsoleFacade {
         return behospitalInfoFacade.hmImproveMRPage(qcResultShortPageVO);
     }
 
+    //指标十八 抢救记录
+    private  List<Map<String, String>> rescueMethod( Map<String, Double> medManageParams, List<Map<String, String>> retList,Map<String, Long> triggeringRulesMap){
+        //接受抢救的质控病历总数
+        double count = medManageParams.get("rescue_result");
+        String num = null;
+        if(StringUtils.isNotEmpty(String.valueOf(count)) &&  count != 0d){
+            double rescueDo = currencyCal(count, triggeringRulesMap.get("rescueNum"));
+            num = String.valueOf(rescueDo);
+        };
+        LinkedHashMap<String, String> firMap = new LinkedHashMap<>();
+        firMap.put("name","患者抢救记录及时完成率");
+        firMap.put("notCopiedStr",StringUtils.isEmpty(num)? null:(num+"%"));
+        firMap.put("num",num);
+        retList.add(firMap);
+        return retList;
+    };
+
+    //指标十七 医师查房记录
+    private List<Map<String, String>> WardRoundMethod( List<Map<String, String>> retList, Map<String, Object> baseIndex, Map<String, Long> triggeringRulesMap){
+        String num = null;
+        if( triggeringRulesMap.containsKey("WardRoundNum") && baseIndex.containsKey("forWorkNum") && !baseIndex.get("forWorkNum").toString().equals("0")){
+            double wardRoundDo = currencyCal(baseIndex.get("forWorkNum"), triggeringRulesMap.get("WardRoundNum"));
+            num = String.valueOf(wardRoundDo);
+        };
+        LinkedHashMap<String, String> firMap = new LinkedHashMap<>();
+        firMap.put("name","医师查房记录完成率");
+        firMap.put("notCopiedStr",StringUtils.isEmpty(num)? null:(num+"%"));
+        firMap.put("num",num);
+        retList.add(firMap);
+        return retList;
+    }
+
+    //指标十四 手术记录
+    private  List<Map<String, String>> operationMethod(Map<String, Double> medManageParams, List<Map<String, String>>retList, Map<String, Long> triggeringRulesMap){
+        String operationFeeNum = medManageParams.get("operation_result")+"";
+        String num = null;
+        if( triggeringRulesMap.containsKey("operationRecordNum") && StringUtils.isNotEmpty(operationFeeNum) && ! operationFeeNum.equals("0")){
+            double operationRecordDo = currencyCal(operationFeeNum, triggeringRulesMap.get("operationRecordNum"));
+            num = String.valueOf(operationRecordDo);
+        };
+        LinkedHashMap<String, String> firMap = new LinkedHashMap<>();
+        firMap.put("name","手术相关记录完成率");
+        firMap.put("notCopiedStr",StringUtils.isEmpty(num)? null:(num+"%"));
+        firMap.put("num",num);
+        retList.add(firMap);
+        return retList;
+    }
+
+    //指标十六  临床用血相关记录符合率
+    private  List<Map<String, String>> bloodMethod( List<Map<String, String>>retList,Map<String, Double> bloodRes,Map<String, Long> triggeringRulesMap){
+
+        double count = bloodRes.get("blood_result");
+        String num = null;
+        if(StringUtils.isNotEmpty(String.valueOf(count)) &&  count != 0d){
+            //指标十七
+            double rescueDo = currencyCal(count, triggeringRulesMap.get("bloodNum"));
+            num = String.valueOf(rescueDo);
+        }
+        LinkedHashMap<String, String> firMap = new LinkedHashMap<>();
+        firMap.put("name","临床用血相关记录符合率");
+        firMap.put("notCopiedStr",StringUtils.isEmpty(num)? null:(num+"%"));
+        firMap.put("num",num);
+        retList.add(firMap);
+        return retList;
+    }
+
+    private double currencyCal(Object objFir,Object objSec){
+        DecimalFormat df = new DecimalFormat("#0.00");
+        double firDouble = Double.parseDouble(objFir.toString()) - Double.parseDouble(objSec.toString());
+        double thrWorkNum = Double.parseDouble(objFir.toString());
+        double retData = Double.parseDouble(df.format(firDouble * 100 / thrWorkNum));
+        return retData;
+    };
+
+    //指标十九 出院患者病历2日归档
+    private List<Map<String, String>> getfileSecAmount(Map<String, Double> medManageParams, List<Map<String, String>>retList, Map<String, Object> baseIndex){
+        DecimalFormat df = new DecimalFormat("#0.00");
+        double count = medManageParams.get("sec_file_result");
+        String num = null;
+        if(StringUtils.isNotEmpty( baseIndex.get("firWorkNum").toString()) && ! baseIndex.get("firWorkNum").toString().equals("0") ){
+            double retNum =count* 100/Double.parseDouble(baseIndex.get("firWorkNum").toString());
+            double firGradeStr = Double.parseDouble(df.format(retNum));
+            num = String.valueOf(firGradeStr);
+        }
+        LinkedHashMap<String, String> firMap = new LinkedHashMap<>();
+        firMap.put("name","出院患者病历2日归档率");
+        firMap.put("notCopiedStr",StringUtils.isEmpty(num)? null:(num+"%"));
+        firMap.put("num",num);
+        retList.add(firMap);
+        return retList;
+    };
+
+
+    private List<Map<String, String>> ManageIndexMethod(String indexName,List<Map<String, String>> retList, Map<String, Object> baseIndex,FilterVO filterVO){
+        FilterVO timeVo = new FilterVO();
+        BeanUtils.copyProperties(filterVO,timeVo);
+        QueryWrapper<MedManagementInfo> query = new QueryWrapper<>();
+        timeTrans(timeVo);
+        query.eq("hospital_id", filterVO.getHospitalId())
+                .eq("is_deleted", IsDeleteEnum.N)
+                .isNotNull("start_date")
+                .isNotNull("end_date")
+                .ge("start_date",timeVo.getStartDate())
+                .le("end_date",timeVo.getEndDate())
+                .select("position_id","work_person");
+        List<MedManagementInfo> list = medManagementInfoService.list(query);
+        //单位时间同期门诊病案管理人员实际工作总月数
+        if(indexName.equals(QualityContent.MZBA_CYHZ)||indexName.equals(QualityContent.QB)) {
+            Optional<Double> firOp = list.stream().filter(obj -> obj.getPositionId().equals("3")).map(MedManagementInfo::getWorkPerson).reduce(Double::sum);
+            Double firMouth = 0d;
+            if(firOp.isPresent()){
+                firMouth = firOp.get();
+            }
+            String num3= null;
+            if(firMouth != 0d && firMouth != null  && StringUtils.isNotEmpty( baseIndex.get("secWorkNum").toString())){
+                //指标二
+                num3 = String.valueOf(Math.ceil(Double.parseDouble(baseIndex.get("secWorkNum").toString())/firMouth));
+            }
+            LinkedHashMap<String, String> thrMap = new LinkedHashMap<>();
+            thrMap.put("name","门诊病案管理人员月均负担门诊患者病历数");
+            thrMap.put("num",num3);
+            retList.add(thrMap);
+        }
+
+        //单位时间同期住院病案管理人员实际工作总月数
+        if(indexName.equals(QualityContent.ZYBA_CYHZ)||indexName.equals(QualityContent.QB)) {
+            Optional<Double> secOp = list.stream().filter(obj->obj.getPositionId().equals("1")).map(MedManagementInfo::getWorkPerson).reduce(Double::sum);
+            Double secMouth = 0d;
+            if(secOp.isPresent()){
+                secMouth = secOp.get();
+            }
+            //指标一
+            String num1 = null;
+            if(secMouth != 0d && secMouth != null && StringUtils.isNotEmpty( baseIndex.get("firWorkNum").toString())){
+                num1 = String.valueOf(Math.ceil(Double.parseDouble(baseIndex.get("firWorkNum").toString()) / secMouth));
+            }
+            LinkedHashMap<String, String> firMap = new LinkedHashMap<>();
+            firMap.put("name","住院病案管理人员月均负担出院患者病历数");
+            firMap.put("num",num1);
+            retList.add(firMap);
+        }
+
+        //单位时间同期病案编码管理人员实际工作总月数
+        if(indexName.equals(QualityContent.BABM_CYHZ)||indexName.equals(QualityContent.QB)) {
+            Optional<Double> thrOp = list.stream().filter(obj->obj.getPositionId().equals("2")).map(MedManagementInfo::getWorkPerson).reduce(Double::sum);
+            Double thrMouth = 0d;
+            if(thrOp.isPresent()){
+                thrMouth = thrOp.get();
+            }
+
+            //指标三
+            String num2 = null;
+            if(thrMouth != 0d && thrMouth != null && StringUtils.isNotEmpty( baseIndex.get("firWorkNum").toString())){
+                num2 = String.valueOf(Math.ceil(Double.parseDouble(baseIndex.get("firWorkNum").toString())/thrMouth));
+
+            }
+            LinkedHashMap<String, String> secMap = new LinkedHashMap<>();
+            secMap.put("name","病案编码人员月均负担出院患者病历数");
+            secMap.put("num",num2);
+            retList.add(secMap);
+        }
+        return retList;
+    };
+
+
+    private List<Map<String, String>> firMethod(String indexName,List<Map<String, String>> retList, Map<String, Object> baseIndex){
+        DecimalFormat df = new DecimalFormat("0.00");
+        if(indexName.equals(QualityContent.JJBLL)||indexName.equals(QualityContent.QB)) {
+            //指标二十七 -甲级病历率
+            Double firRecord = 0d;
+            String num4= null;
+            if(StringUtils.isNotEmpty( baseIndex.get("forWorkNum").toString())){
+                firRecord =Double.parseDouble(baseIndex.get("forWorkNum").toString());
+            }
+            if( firRecord != 0d && StringUtils.isNotEmpty( baseIndex.get("sixWorkNum").toString()) ){
+                double retNum = Double.parseDouble(baseIndex.get("sixWorkNum").toString()) * 100 / firRecord;
+                double firGradeStr = Double.parseDouble(df.format(retNum));
+                num4 = String.valueOf(Math.ceil(firGradeStr));
+            }
+            LinkedHashMap<String, String> fouMap = new LinkedHashMap<>();
+            fouMap.put("name","甲级病历率");
+            fouMap.put("notCopiedStr",StringUtils.isEmpty(num4)? null:(num4+"%"));
+            fouMap.put("num",num4);
+            retList.add(fouMap);
+        }
+        return retList;
+    };
+
 
+    /**
+     * ==============================后台维护===============================
+     */
     //指标十八 抢救记录
-    private  void rescueMethod(List<MedManageParamsDTO> medManageParams,MedIndexResult medIndexResult){
+    private  void rescueMethods(List<MedManageParamsDTO> medManageParams,MedIndexResult medIndexResult){
         List<MedManageParamsDTO> manageList= new ArrayList<>();
         List<String> rescueDrugList = QualityContent.RESCUEDRUGLIST;
         for (int i = 0; i < medManageParams.size(); i++) {
@@ -2745,7 +2980,7 @@ public class ConsoleFacade {
     }
 
     //指标十六  临床用血相关记录符合率
-    private void bloodMethod(List<MedManageParamsDTO> doctorAdviceList, List<MedManageParamsDTO> medManageParams,MedIndexResult medIndexResult){
+    private void bloodMethods(List<MedManageParamsDTO> doctorAdviceList, List<MedManageParamsDTO> medManageParams,MedIndexResult medIndexResult){
         Set<String> manageList= new CopyOnWriteArraySet<>();
         List<String> blood_list = QualityContent.BLOODLIST;
         //lis项目存在用血住院病历号
@@ -2758,34 +2993,27 @@ public class ConsoleFacade {
         System.out.println("lis项目存在用血住院病历号 = " + (xx2-xx1));
         //advice体现lis项目存在用血的住院病历号
         doctorAdviceList.parallelStream()
-              .filter(obj -> beCode.contains(obj.getBehospitalCode()) && obj.getDoctorAdviceType()
-                      .equals(QualityContent.STAT_ORDER) && blood_list.contains(obj.getDaItemName()) &&
-                      (StringUtils.isEmpty(obj.getDaStatus())) || (StringUtils.isNotEmpty(obj.getDaStatus()) && ! obj.getDaStatus()
-                      .equals(QualityContent.CANCELLATION_ORDER)))
+                .filter(obj -> beCode.contains(obj.getBehospitalCode()) && obj.getDoctorAdviceType()
+                        .equals(QualityContent.STAT_ORDER) && blood_list.contains(obj.getDaItemName()) &&
+                        (StringUtils.isEmpty(obj.getDaStatus())) || (StringUtils.isNotEmpty(obj.getDaStatus()) && ! obj.getDaStatus()
+                        .equals(QualityContent.CANCELLATION_ORDER)))
                 .distinct()
-              .map(obj -> manageList.add(obj.getBehospitalCode()))
-              .collect(Collectors.toList());
+                .map(obj -> manageList.add(obj.getBehospitalCode()))
+                .collect(Collectors.toList());
         long xx3= System.currentTimeMillis();
         System.out.println("advice体现lis项目存在用血的住院病历号 = " + (xx3-xx2));
 
-            //临床用血的质控病历总数
-            double count = manageList.size();
-            if(StringUtils.isNotEmpty(String.valueOf(count)) &&  count != 0d){
-                //指标十七
-                medIndexResult.setBloodResult(count);
-            }
+        //临床用血的质控病历总数
+        double count = manageList.size();
+        if(StringUtils.isNotEmpty(String.valueOf(count)) &&  count != 0d){
+            //指标十七
+            medIndexResult.setBloodResult(count);
+        }
     }
 
-    private double currencyCal(Object objFir,Object objSec){
-        DecimalFormat df = new DecimalFormat("#0.00");
-        double firDouble = Double.parseDouble(objFir.toString()) - Double.parseDouble(objSec.toString());
-        double thrWorkNum = Double.parseDouble(objFir.toString());
-        double retData = Double.parseDouble(df.format(firDouble * 100 / thrWorkNum));
-        return retData;
-    };
 
     //指标十九 出院患者病历2日归档
-    private void getfileSecAmount(FilterVO filterVO,Map<String, Object> baseIndex,MedIndexResult medIndexResult){
+    private void getfileSecAmounts(FilterVO filterVO,Map<String, Object> baseIndex,MedIndexResult medIndexResult){
         QueryWrapper<BehospitalInfo> query = new QueryWrapper<>();
         DecimalFormat df = new DecimalFormat("#0.00");
         query.eq("hospital_id", filterVO.getHospitalId())
@@ -2848,40 +3076,41 @@ public class ConsoleFacade {
         return false;
     }
 
-    private void firMethod(String indexName, Map<String, Object> baseIndex, MedIndexResult medIndexResult){
+    private void firMethods(String indexName, Map<String, Object> baseIndex, MedIndexResult medIndexResult){
         DecimalFormat df = new DecimalFormat("0.00");
-          //指标二十七 -甲级病历率
-            Double firRecord = 0d;
-            if(StringUtils.isNotEmpty( baseIndex.get("forWorkNum").toString())){
-                firRecord =Double.parseDouble(baseIndex.get("forWorkNum").toString());
-            }
-            if( firRecord != 0d && StringUtils.isNotEmpty( baseIndex.get("sixWorkNum").toString()) ){
-                double retNum = Double.parseDouble(baseIndex.get("sixWorkNum").toString()) * 100 / firRecord;
-                double firGradeStr = Double.parseDouble(df.format(retNum));
-                medIndexResult.setFirRecordResult(firGradeStr);
-            }
+        //指标二十七 -甲级病历率
+        Double firRecord = 0d;
+        if(StringUtils.isNotEmpty( baseIndex.get("forWorkNum").toString())){
+            firRecord =Double.parseDouble(baseIndex.get("forWorkNum").toString());
+        }
+        if( firRecord != 0d && StringUtils.isNotEmpty( baseIndex.get("sixWorkNum").toString()) ){
+            double retNum = Double.parseDouble(baseIndex.get("sixWorkNum").toString()) * 100 / firRecord;
+            double firGradeStr = Double.parseDouble(df.format(retNum));
+            medIndexResult.setFirRecordResult(firGradeStr);
+        }
+    };
+
+    private void timeTrans(FilterVO filterVO){
+        SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar cal1 = Calendar.getInstance();
+        Calendar cal2 = Calendar.getInstance();
+        try {
+            cal1.setTime(myFormatter.parse(filterVO.getStartDate()));
+            cal2.setTime(myFormatter.parse(filterVO.getEndDate()));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+
+        cal1.set(Calendar.DAY_OF_MONTH, 1);//当月的第一天
+        cal2.set(Calendar.DAY_OF_MONTH, 1);
+        cal2.set(Calendar.DATE, 1);//设为当前月的1号
+        cal2.roll(Calendar.DATE, -1);
+        String startTime = myFormatter.format(cal1.getTime())+" 00:00:00";
+        String endTime = myFormatter.format(cal2.getTime())+" 23:59:59";
+        filterVO.setStartDate(startTime);
+        filterVO.setEndDate(endTime);
     };
 
-   private void timeTrans(FilterVO filterVO){
-       SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
-       Calendar cal1 = Calendar.getInstance();
-       Calendar cal2 = Calendar.getInstance();
-       try {
-           cal1.setTime(myFormatter.parse(filterVO.getStartDate()));
-           cal2.setTime(myFormatter.parse(filterVO.getEndDate()));
-       } catch (ParseException e) {
-           e.printStackTrace();
-       }
-
-       cal1.set(Calendar.DAY_OF_MONTH, 1);//当月的第一天
-       cal2.set(Calendar.DAY_OF_MONTH, 1);
-       cal2.set(Calendar.DATE, 1);//设为当前月的1号
-       cal2.roll(Calendar.DATE, -1);
-       String startTime = myFormatter.format(cal1.getTime())+" 00:00:00";
-       String endTime = myFormatter.format(cal2.getTime())+" 23:59:59";
-       filterVO.setStartDate(startTime);
-       filterVO.setEndDate(endTime);
-   };
 
 
     /**