|
@@ -1,23 +1,14 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-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.Map;
|
|
@@ -29,126 +20,25 @@ 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(), null));
|
|
|
- filterVO.setEndDate(getEndDateStr(filterVO.getType(), null));
|
|
|
- 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(), null);
|
|
|
- String endDate = getEndDateStr(filterVO.getType(), null);
|
|
|
- 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("出院人数统计", new LinkedHashMap<>());
|
|
|
retMap.put("各科室甲级病历占比", Lists.newLinkedList());
|
|
|
- retMap.put("各科室缺陷占比", Lists.newLinkedList());
|
|
|
String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
- String startDate = getStartDateStr(filterVO.getType(), null);
|
|
|
- String endDate = getEndDateStr(filterVO.getType(), null);
|
|
|
+ String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
|
|
|
+ String endDate = filterFacade.getEndDateStr(filterVO.getType(), null);
|
|
|
filterVO.setStartDate(startDate);
|
|
|
filterVO.setEndDate(endDate);
|
|
|
filterVO.setHospitalId(hospitalId);
|
|
@@ -156,7 +46,7 @@ public class ConsoleFacade {
|
|
|
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);
|
|
|
}
|
|
@@ -171,10 +61,11 @@ public class ConsoleFacade {
|
|
|
*/
|
|
|
public Map<String, Object> resultStatistics(FilterVO filterVO) {
|
|
|
Map<String, Object> retMap = new LinkedHashMap<>();
|
|
|
+ retMap.put("各科室缺陷占比", Lists.newLinkedList());
|
|
|
retMap.put("各模块缺陷占比排行", Lists.newLinkedList());
|
|
|
retMap.put("条目缺陷占比", Lists.newLinkedList());
|
|
|
String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
- String startDate = getStartDateStr(filterVO.getType(), null);
|
|
|
+ String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
|
|
|
filterVO.setStartDate(startDate);
|
|
|
filterVO.setHospitalId(hospitalId);
|
|
|
try {
|
|
@@ -201,7 +92,7 @@ public class ConsoleFacade {
|
|
|
retMap.put("各科室质控平均分", Lists.newLinkedList());
|
|
|
String hospitalId = SysUserUtils.getCurrentHospitalID();
|
|
|
filterVO.setHospitalId(hospitalId);
|
|
|
- String startDate = getStartDateStr(filterVO.getType(), null);
|
|
|
+ String startDate = filterFacade.getStartDateStr(filterVO.getType(), null);
|
|
|
filterVO.setStartDate(startDate);
|
|
|
try {
|
|
|
Map<String, Object> invokeParams = new HashMap<>();
|
|
@@ -211,88 +102,6 @@ public class ConsoleFacade {
|
|
|
} catch (Exception e) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
}
|
|
|
-
|
|
|
return retMap;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 筛选起始时间
|
|
|
- *
|
|
|
- * @param type
|
|
|
- * @return
|
|
|
- */
|
|
|
- public String getStartDateStr(Integer type, Integer optYear) {
|
|
|
- Date date = new Date();
|
|
|
- String startDate = "";
|
|
|
- String year = optYear == null ? DateUtil.getYear(date) : optYear.toString();
|
|
|
- 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, Integer optYear) {
|
|
|
- Date date = new Date();
|
|
|
- String endDate = "";
|
|
|
- String year = optYear == null ? DateUtil.getYear(date) : optYear.toString();
|
|
|
- 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 type
|
|
|
- * @return
|
|
|
- */
|
|
|
- public String getLastStartDateStr(Integer type) {
|
|
|
- Date date = new Date();
|
|
|
- String dateStr = "";
|
|
|
- String year = DateUtil.getYear(date);
|
|
|
- int month = DateUtil.getMonth(date);
|
|
|
- if (type.equals(1)) {
|
|
|
- if (month == 1) {
|
|
|
- dateStr = (Integer.valueOf(year) - 1) + "-12-1";
|
|
|
- } else {
|
|
|
- dateStr = year + "-" + (month - 1) + "-1";
|
|
|
- }
|
|
|
- } else if (type.equals(2)) {
|
|
|
- dateStr = (Integer.valueOf(year) - 1) + "-1-1";
|
|
|
- }
|
|
|
- return dateStr;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取上一统计周期(上月/去年)的起始时间
|
|
|
- *
|
|
|
- * @param type
|
|
|
- * @return
|
|
|
- */
|
|
|
- public String getLastEndDateStr(Integer type) {
|
|
|
- //上一统计周期的截止时间等于本周期的起始时间
|
|
|
- return getStartDateStr(type, null);
|
|
|
- }
|
|
|
-
|
|
|
}
|