|
@@ -1,27 +1,16 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import com.diagbot.dto.AverageStatisticsDTO;
|
|
|
-import com.diagbot.dto.NumDTO;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
-import com.diagbot.util.BeanUtil;
|
|
|
-import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.SysUserUtils;
|
|
|
import com.diagbot.vo.FilterVO;
|
|
|
-import com.diagbot.vo.HomePageFilterVO;
|
|
|
-import com.diagbot.vo.QcresultFilterVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.text.DecimalFormat;
|
|
|
-import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -31,136 +20,30 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Component
|
|
|
public class ConsoleFacade {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private QcresultInfoFacade qcresultInfoFacade;
|
|
|
@Autowired
|
|
|
- private BehospitalInfoFacade behospitalInfoFacade;
|
|
|
+ private FilterFacade filterFacade;
|
|
|
@Autowired
|
|
|
private DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * 出院人数统计
|
|
|
+ * 病历相关统计
|
|
|
*
|
|
|
* @param filterVO
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String, Object> leaveHosStatistics(FilterVO filterVO) {
|
|
|
- Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
- String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
- retMap.put("总人数", 0);
|
|
|
- retMap.put("死亡人数", 0);
|
|
|
- retMap.put("新生儿人数", 0);
|
|
|
- retMap.put("手术病人数", 0);
|
|
|
- filterVO.setHospitalId(hospitalId);
|
|
|
- filterVO.setStartDate(getStartDateStr(filterVO.getType()));
|
|
|
- filterVO.setEndDate(getEndDateStr(filterVO.getType()));
|
|
|
- HomePageFilterVO homePageFilterVO = new HomePageFilterVO();
|
|
|
- BeanUtil.copyProperties(filterVO, homePageFilterVO);
|
|
|
- Integer totleNum = behospitalInfoFacade.homePageCount(homePageFilterVO);
|
|
|
- homePageFilterVO.setDeath(1);
|
|
|
- Integer deathNum = behospitalInfoFacade.homePageCount(homePageFilterVO);
|
|
|
- homePageFilterVO.setDeath(null);
|
|
|
- homePageFilterVO.setNewBorn(1);
|
|
|
- Integer newBornNum = behospitalInfoFacade.homePageCount(homePageFilterVO);
|
|
|
- Integer operationNum = behospitalInfoFacade.homePageCountForOperation(filterVO);
|
|
|
- retMap.put("总人数", totleNum);
|
|
|
- retMap.put("死亡人数", deathNum);
|
|
|
- retMap.put("新生儿人数", newBornNum);
|
|
|
- retMap.put("手术病人数", operationNum);
|
|
|
- return retMap;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 质控病历统计
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
public Map<String, Object> mrStatistics(FilterVO filterVO) {
|
|
|
- DecimalFormat df = new DecimalFormat("#0.00");
|
|
|
- Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
- String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
- String startDate = getStartDateStr(filterVO.getType());
|
|
|
- String endDate = getEndDateStr(filterVO.getType());
|
|
|
- filterVO.setStartDate(startDate);
|
|
|
- filterVO.setEndDate(endDate);
|
|
|
- filterVO.setHospitalId(hospitalId);
|
|
|
- QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
|
|
|
- BeanUtil.copyProperties(filterVO, qcresultFilterVO);
|
|
|
-
|
|
|
- int totleNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
|
|
|
- qcresultFilterVO.setLevel("甲");
|
|
|
- int firstLevelNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
|
|
|
- qcresultFilterVO.setLevel("乙");
|
|
|
- int secondLevelNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
|
|
|
- qcresultFilterVO.setLevel("丙");
|
|
|
- int thirdLevelNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
|
|
|
- NumDTO totleNumDTO = new NumDTO();
|
|
|
- totleNumDTO.setName("累计质控病历数");
|
|
|
- totleNumDTO.setTotleNum(totleNum);
|
|
|
- totleNumDTO.setNum(totleNum);
|
|
|
- NumDTO firstLevelNumDTO = new NumDTO();
|
|
|
- firstLevelNumDTO.setName("甲级病历");
|
|
|
- firstLevelNumDTO.setNum(firstLevelNum);
|
|
|
- firstLevelNumDTO.setTotleNum(totleNum);
|
|
|
- Double firstPercent = BigDecimal.valueOf(firstLevelNum)
|
|
|
- .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
|
|
|
- .doubleValue();
|
|
|
- String firstPercentStr = df.format(BigDecimal.valueOf(firstPercent).multiply(BigDecimal.valueOf(100))) + "%";
|
|
|
- firstLevelNumDTO.setPercent(firstPercent);
|
|
|
- firstLevelNumDTO.setPercentStr(firstPercentStr);
|
|
|
- NumDTO secondLevelNumDTO = new NumDTO();
|
|
|
- secondLevelNumDTO.setName("乙级病历");
|
|
|
- secondLevelNumDTO.setNum(secondLevelNum);
|
|
|
- secondLevelNumDTO.setTotleNum(totleNum);
|
|
|
- Double secondPercent = BigDecimal.valueOf(secondLevelNum)
|
|
|
- .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
|
|
|
- .doubleValue();
|
|
|
- String secondPercentStr = df.format(BigDecimal.valueOf(secondPercent).multiply(BigDecimal.valueOf(100))) + "%";
|
|
|
- secondLevelNumDTO.setPercent(secondPercent);
|
|
|
- secondLevelNumDTO.setPercentStr(secondPercentStr);
|
|
|
- NumDTO thirdLevelNumDTO = new NumDTO();
|
|
|
- thirdLevelNumDTO.setName("丙级病历");
|
|
|
- thirdLevelNumDTO.setNum(thirdLevelNum);
|
|
|
- thirdLevelNumDTO.setTotleNum(totleNum);
|
|
|
- Double thirdPercent = BigDecimal.valueOf(1)
|
|
|
- .subtract(BigDecimal.valueOf(firstPercent))
|
|
|
- .subtract(BigDecimal.valueOf(secondPercent))
|
|
|
- .doubleValue();
|
|
|
- String thirdPercentStr = df.format(BigDecimal.valueOf(thirdPercent).multiply(BigDecimal.valueOf(100))) + "%";
|
|
|
- thirdLevelNumDTO.setPercent(thirdPercent);
|
|
|
- thirdLevelNumDTO.setPercentStr(thirdPercentStr);
|
|
|
- retMap.put("累计质控病历数", totleNumDTO);
|
|
|
- retMap.put("甲级病历", firstLevelNumDTO);
|
|
|
- retMap.put("乙级病历", secondLevelNumDTO);
|
|
|
- retMap.put("丙级病历", thirdLevelNumDTO);
|
|
|
- return retMap;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 按科室统计
|
|
|
- *
|
|
|
- * @param filterVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Map<String, Object> deptStatistics(FilterVO filterVO) {
|
|
|
Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
- retMap.put("各科室甲级病历占比", Lists.newLinkedList());
|
|
|
- retMap.put("各科室缺陷占比", Lists.newLinkedList());
|
|
|
String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
- String startDate = getStartDateStr(filterVO.getType());
|
|
|
- String endDate = getEndDateStr(filterVO.getType());
|
|
|
+ String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
|
|
|
+ String endDate = filterFacade.getEndDateStr(filterVO.getType(), null);
|
|
|
filterVO.setStartDate(startDate);
|
|
|
filterVO.setEndDate(endDate);
|
|
|
filterVO.setHospitalId(hospitalId);
|
|
|
- QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
|
|
|
- BeanUtil.copyProperties(filterVO, qcresultFilterVO);
|
|
|
try {
|
|
|
Map<String, Object> invokeParams = new HashMap<>();
|
|
|
invokeParams.put("filterVO", filterVO);
|
|
|
retMap
|
|
|
- = dataBeanAggregateQueryFacade.get("setAllDept", invokeParams, Map.class);
|
|
|
+ = dataBeanAggregateQueryFacade.get("setAllMr", invokeParams, Map.class);
|
|
|
} catch (Exception e) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
}
|
|
@@ -175,10 +58,8 @@ public class ConsoleFacade {
|
|
|
*/
|
|
|
public Map<String, Object> resultStatistics(FilterVO filterVO) {
|
|
|
Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
- retMap.put("各模块缺陷占比排行", Lists.newLinkedList());
|
|
|
- retMap.put("条目缺陷占比", Lists.newLinkedList());
|
|
|
String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
- String startDate = getStartDateStr(filterVO.getType());
|
|
|
+ String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
|
|
|
filterVO.setStartDate(startDate);
|
|
|
filterVO.setHospitalId(hospitalId);
|
|
|
try {
|
|
@@ -193,43 +74,17 @@ public class ConsoleFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 医院运营相关统计
|
|
|
+ * 平局值相关统计
|
|
|
*
|
|
|
* @param filterVO
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> averageStatistics(FilterVO filterVO) {
|
|
|
Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
- retMap.put("平均住院日", Lists.newLinkedList());
|
|
|
- retMap.put("平均住院费用", Lists.newLinkedList());
|
|
|
String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
filterVO.setHospitalId(hospitalId);
|
|
|
- String startDate = getStartDateStr(filterVO.getType());
|
|
|
+ String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
|
|
|
filterVO.setStartDate(startDate);
|
|
|
-
|
|
|
- /*
|
|
|
- List<AverageStatisticsDTO> retAverageDayNumList = Lists.newLinkedList();
|
|
|
- List<AverageStatisticsDTO> retAverageFeeList = Lists.newLinkedList();
|
|
|
- List<AverageStatisticsDTO> averageDayNumList = homePageFacade.getAverageDayNum(filterVO);
|
|
|
- List<AverageStatisticsDTO> averageFeeList = homePageFacade.getAverageFee(filterVO);
|
|
|
-
|
|
|
- if (filterVO.getLimitCount() == null || filterVO.getLimitCount().equals(0)) {
|
|
|
- filterVO.setLimitCount(10);
|
|
|
- }
|
|
|
- Integer limitCount = filterVO.getLimitCount();
|
|
|
-
|
|
|
- //平均住院日
|
|
|
- if (ListUtil.isNotEmpty(averageDayNumList)) {
|
|
|
- retAverageDayNumList = getLimitAverageList(averageDayNumList, limitCount);
|
|
|
- retMap.put("平均住院日", retAverageDayNumList);
|
|
|
- }
|
|
|
-
|
|
|
- //平均住院费用
|
|
|
- if (ListUtil.isNotEmpty(averageFeeList)) {
|
|
|
- retAverageFeeList = getLimitAverageList(averageFeeList, limitCount);
|
|
|
- retMap.put("平均住院费用", retAverageFeeList);
|
|
|
- }*/
|
|
|
-
|
|
|
try {
|
|
|
Map<String, Object> invokeParams = new HashMap<>();
|
|
|
invokeParams.put("filterVO", filterVO);
|
|
@@ -238,92 +93,6 @@ public class ConsoleFacade {
|
|
|
} catch (Exception e) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
}
|
|
|
-
|
|
|
return retMap;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 筛选起始时间
|
|
|
- *
|
|
|
- * @param type
|
|
|
- * @return
|
|
|
- */
|
|
|
- public String getStartDateStr(Integer type) {
|
|
|
- Date date = new Date();
|
|
|
- String startDate = "";
|
|
|
- String year = DateUtil.getYear(date);
|
|
|
- int month = DateUtil.getMonth(date);
|
|
|
- if (type.equals(1)) {
|
|
|
- //本月统计
|
|
|
- startDate = year + "-" + month + "-1";
|
|
|
- } else if (type.equals(2)) {
|
|
|
- //本年统计
|
|
|
- startDate = year + "-1-1";
|
|
|
- }
|
|
|
- return startDate;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 筛选截止时间
|
|
|
- *
|
|
|
- * @param type
|
|
|
- * @return
|
|
|
- */
|
|
|
- public String getEndDateStr(Integer type) {
|
|
|
- Date date = new Date();
|
|
|
- String endDate = "";
|
|
|
- String year = DateUtil.getYear(date);
|
|
|
- int month = DateUtil.getMonth(date);
|
|
|
- if (type.equals(1)) {
|
|
|
- //本月统计
|
|
|
- if (month == 12) {
|
|
|
- endDate = (Integer.valueOf(year) + 1) + "-1-1";
|
|
|
- } else {
|
|
|
- endDate = year + "-" + (month + 1) + "-1";
|
|
|
- }
|
|
|
- } else if (type.equals(2)) {
|
|
|
- //本年统计
|
|
|
- endDate = (Integer.valueOf(year) + 1) + "-1-1";
|
|
|
- }
|
|
|
- return endDate;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据限制数量重组统计结果
|
|
|
- *
|
|
|
- * @param averageList
|
|
|
- * @param limitCount
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<AverageStatisticsDTO> getLimitAverageList(List<AverageStatisticsDTO> averageList, Integer limitCount) {
|
|
|
- List<AverageStatisticsDTO> retAverageList = Lists.newLinkedList();
|
|
|
- if (averageList.size() < limitCount) {
|
|
|
- retAverageList = BeanUtil.listCopyTo(averageList, AverageStatisticsDTO.class);
|
|
|
- } else {
|
|
|
- if (averageList.size() > limitCount) {
|
|
|
- retAverageList = averageList.subList(0, limitCount - 1);
|
|
|
- List<AverageStatisticsDTO> otherList = averageList.subList(limitCount - 1, averageList.size());
|
|
|
- Double totleValue = otherList
|
|
|
- .stream()
|
|
|
- .map(i -> BigDecimal.valueOf(i.getTotleValue()))
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue();
|
|
|
- Integer num = otherList
|
|
|
- .stream()
|
|
|
- .map(AverageStatisticsDTO::getNum)
|
|
|
- .reduce(0, Integer::sum);
|
|
|
- Double averageValue = BigDecimal.valueOf(totleValue)
|
|
|
- .divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP)
|
|
|
- .doubleValue();
|
|
|
- AverageStatisticsDTO retAverageStatistics = new AverageStatisticsDTO();
|
|
|
- retAverageStatistics.setDeptName("其他");
|
|
|
- retAverageStatistics.setNum(num);
|
|
|
- retAverageStatistics.setAverageValue(averageValue);
|
|
|
- retAverageStatistics.setTotleValue(totleValue);
|
|
|
- retAverageList.add(retAverageStatistics);
|
|
|
- } else {
|
|
|
- retAverageList = averageList;
|
|
|
- }
|
|
|
- }
|
|
|
- return retAverageList;
|
|
|
- }
|
|
|
}
|