|
@@ -1,11 +1,24 @@
|
|
|
package com.diagbot.service.impl;
|
|
|
|
|
|
+
|
|
|
+import com.diagbot.dto.MedQualityControlDTO;
|
|
|
import com.diagbot.entity.MedManagementInfo;
|
|
|
import com.diagbot.mapper.MedManagementInfoMapper;
|
|
|
import com.diagbot.service.MedManagementInfoService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.entity.FilterRecordVO;
|
|
|
+
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+
|
|
|
+import java.time.Duration;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 病案管理人员表 服务实现类
|
|
@@ -16,5 +29,322 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
|
@Service
|
|
|
public class MedManagementInfoServiceImpl extends ServiceImpl<MedManagementInfoMapper, MedManagementInfo> implements MedManagementInfoService {
|
|
|
+ public MedQualityControlDTO medicalRecordIndicator(FilterRecordVO filterRecordVO, List list) {
|
|
|
+ String startDate = filterRecordVO.getStartDate();
|
|
|
+ String endDate = filterRecordVO.getEndDate();
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime sta = LocalDateTime.parse(startDate, df);
|
|
|
+ LocalDateTime end = LocalDateTime.parse(endDate, df);
|
|
|
+ MedQualityControlDTO medQualityControlDTO = new MedQualityControlDTO();
|
|
|
+ // type==1 时间为出院
|
|
|
+ filterRecordVO.setType(1);
|
|
|
+ List<Map<String, Object>> medicalRecordIndicatorStaList = baseMapper.medicalRecordIndicator(filterRecordVO,sta,end);
|
|
|
+ //时间段出院人数为
|
|
|
+ Object countNumSta = medicalRecordIndicatorStaList.get(0).get("countNum");
|
|
|
+ int totleCountSta = Integer.parseInt(countNumSta.toString());
|
|
|
+ //获取病案管理人员工作
|
|
|
+ HashMap<String, Long> longHashMap = getTimeCount(list, sta, end);
|
|
|
+ Long timeCount = longHashMap.get("病案管理");
|
|
|
+ Long codingCount = longHashMap.get("编码管理");
|
|
|
+ double monthlyDou = 0;
|
|
|
+ double monthlyCoding = 0;
|
|
|
+ try {
|
|
|
+ if(timeCount==0||totleCountSta==0){
|
|
|
+ medQualityControlDTO.setManagerMouthNum("0");
|
|
|
+ }
|
|
|
+ double timeMonth = timeCount / 30;
|
|
|
+ // 住院病案管理人员月均负担出院患者病历
|
|
|
+ monthlyDou = (totleCountSta / timeMonth);
|
|
|
+ double ceil = Math.ceil(monthlyDou);
|
|
|
+ String monthlyInt = String.valueOf(ceil);
|
|
|
+ medQualityControlDTO.setManagerMouthNum(monthlyInt);
|
|
|
+ //编码
|
|
|
+ if(codingCount==0||totleCountSta==0){
|
|
|
+ medQualityControlDTO.setCoderMouthNum("0");
|
|
|
+ }
|
|
|
+ monthlyCoding = totleCountSta / (codingCount/30);
|
|
|
+ double roundCod = Math.ceil(monthlyCoding);
|
|
|
+ String codingInt = String.valueOf(roundCod);
|
|
|
+ medQualityControlDTO.setCoderMouthNum(codingInt);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ //throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病历无关联的质控条目!");
|
|
|
+ }
|
|
|
+ //type=2 时间为住院对比
|
|
|
+ filterRecordVO.setType(2);
|
|
|
+ List<Map<String, Object>> medicalRecordIndicatorOutList = baseMapper.medicalRecordIndicator(filterRecordVO,sta,end);
|
|
|
+ // List<Map<String, Object>> medicalRecordIndicatorOutList = baseMapper.medicalRecordIndicator(filterRecordVO,sta,end);
|
|
|
+ //同期住院人数
|
|
|
+ Object countNumOut = medicalRecordIndicatorOutList.get(0).get("countNum");
|
|
|
+ int totleCountOut = Integer.parseInt(countNumOut.toString());
|
|
|
+ //type=3 住院时间缺陷情况
|
|
|
+ filterRecordVO.setType(3);
|
|
|
+ List<Map<String, Object>> blemishList = baseMapper.medicalRecordIndicator(filterRecordVO,sta,end);
|
|
|
+ if (ListUtil.isNotEmpty(blemishList)) {
|
|
|
+ for (Map<String, Object> blemishMap : blemishList) {
|
|
|
+ //入院记录未在术后24h内完成
|
|
|
+ if (("2658").equals(blemishMap.get("cases_entry_id"))) {
|
|
|
+ //未完成个数
|
|
|
+ Object obj = blemishMap.get("2658入院记录未在术后24h内完成");
|
|
|
+ double i = Double.parseDouble(obj.toString());
|
|
|
+ //完成率为
|
|
|
+ if (totleCountOut != 0) {
|
|
|
+ double admissionDou = (totleCountOut - i) / totleCountOut;
|
|
|
+ String admissionStr = Double.toString(admissionDou);
|
|
|
+ medQualityControlDTO.setAdmissionStr(admissionStr);
|
|
|
+ //完成个数
|
|
|
+ medQualityControlDTO.setAdmissionNum((totleCountOut - i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //手术记录未在术后24h内完成
|
|
|
+ if (("2170").equals(blemishMap.get("cases_entry_id"))) {
|
|
|
+ //未完成个数
|
|
|
+ Object obj = blemishMap.get("2170手术记录未在术后24h内完成");
|
|
|
+ double i = Double.parseDouble(obj.toString());
|
|
|
+ //完成率为
|
|
|
+ if (totleCountOut != 0) {
|
|
|
+ double admissionDou = (totleCountOut - i) / totleCountOut;
|
|
|
+ String admissionStr = Double.toString(admissionDou);
|
|
|
+ medQualityControlDTO.setOperationStr(admissionStr);
|
|
|
+ //完成个数
|
|
|
+ medQualityControlDTO.setOperationNum((totleCountOut - i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(medQualityControlDTO.getAdmissionStr()==null){
|
|
|
+ medQualityControlDTO.setAdmissionStr("1");
|
|
|
+ //完成个数
|
|
|
+ medQualityControlDTO.setAdmissionNum((Double.valueOf(totleCountOut)));
|
|
|
+ }
|
|
|
+ if(medQualityControlDTO.getOperationStr()==null){
|
|
|
+ medQualityControlDTO.setOperationStr("1");
|
|
|
+ //完成个数
|
|
|
+ medQualityControlDTO.setOperationNum((Double.valueOf(totleCountOut)));
|
|
|
+ }
|
|
|
+ //type=4 出院时间缺陷情况
|
|
|
+ filterRecordVO.setType(4);
|
|
|
+ List<Map<String, Object>> blemishListF = baseMapper.medicalRecordIndicator(filterRecordVO,sta,end);
|
|
|
+ if (ListUtil.isNotEmpty(blemishListF)) {
|
|
|
+ for (Map<String, Object> blemishMap : blemishListF) {
|
|
|
+ //出院记录未在术后24h内完成
|
|
|
+ if (("2635").equals(blemishMap.get("cases_entry_id"))) {
|
|
|
+ //未完成个数
|
|
|
+ Object obj = blemishMap.get("2635出院记录未在术后24h内完成");
|
|
|
+ double i = Double.parseDouble(obj.toString());
|
|
|
+ //完成率为
|
|
|
+ if (totleCountSta != 0) {
|
|
|
+ double leaveHospitalDou = (totleCountSta - i) / totleCountSta;
|
|
|
+ String leaveHospitalStr = Double.toString(leaveHospitalDou);
|
|
|
+ medQualityControlDTO.setLeaveHospitalStr(leaveHospitalStr);
|
|
|
+ //完成个数
|
|
|
+ medQualityControlDTO.setLeaveHospitalNum((totleCountOut - i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(medQualityControlDTO.getLeaveHospitalStr()==null){
|
|
|
+ medQualityControlDTO.setLeaveHospitalStr("1");
|
|
|
+ //完成个数
|
|
|
+ medQualityControlDTO.setLeaveHospitalNum((Double.valueOf(totleCountOut)));
|
|
|
+ }
|
|
|
+
|
|
|
+ //查房记录完成率
|
|
|
+ filterRecordVO.setType(0);
|
|
|
+ List<Map<String, Object>> blemishListOne = baseMapper.medicalRecordIndicator(filterRecordVO,sta,end);
|
|
|
+ int roundNum=0;
|
|
|
+ String code=null;
|
|
|
+ int record=0;
|
|
|
+ //获得住院日期所有数据未分组的缺陷
|
|
|
+ for (int i = 0; i < blemishListOne.size(); i++) {
|
|
|
+ String casesEntryId = blemishListOne.get(i).get("cases_entry_id").toString();
|
|
|
+ //只要符合其中任何一个
|
|
|
+ if(casesEntryId.equals("2655") || casesEntryId.equals("2656")|| casesEntryId.equals("2427")|| casesEntryId.equals("2654")|| casesEntryId.equals("2214")){
|
|
|
+ if(i!=0) {
|
|
|
+ code = blemishListOne.get(i).get("acode").toString();
|
|
|
+ String recordCode = blemishListOne.get(record).get("acode").toString();
|
|
|
+ if(code.equals(recordCode)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ record = i;
|
|
|
+ roundNum=roundNum+1;
|
|
|
+ //获得此次的code
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ record = i;
|
|
|
+ roundNum=roundNum+1;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //医师完整记录完成量为
|
|
|
+ if(roundNum==0){
|
|
|
+ medQualityControlDTO.setWardRoundStr("1");
|
|
|
+ //完成个数
|
|
|
+ medQualityControlDTO.setWardRoundNum((Double.valueOf(totleCountOut)));
|
|
|
+ }
|
|
|
+ medQualityControlDTO.setWardRoundNum(Double.valueOf(roundNum));
|
|
|
+ //医师完整记录完成率
|
|
|
+ Double medHomePage = (Double.valueOf(roundNum) / totleCountOut);
|
|
|
+ medQualityControlDTO.setWardRoundStr(medHomePage.toString());
|
|
|
+
|
|
|
+
|
|
|
+ return medQualityControlDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+/* //判断时间是否在一个时间段内
|
|
|
+ public static boolean belongCalendar(Date nowTime, Date beginTime, Date endTime) {
|
|
|
+ if (nowTime != null && beginTime != null && endTime != null) {
|
|
|
+ //设置当前时间
|
|
|
+ Calendar date = Calendar.getInstance();
|
|
|
+ date.setTime(nowTime);
|
|
|
+ //设置开始时间
|
|
|
+ Calendar begin = Calendar.getInstance();
|
|
|
+ begin.setTime(beginTime);
|
|
|
+ //设置结束时间
|
|
|
+ Calendar end = Calendar.getInstance();
|
|
|
+ end.setTime(endTime);
|
|
|
+ //处于开始时间之后,和结束时间之前的判断
|
|
|
+ if (date.after(begin) && date.before(end)) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public HashMap<String, Long> getTimeCount(List<MedManagementInfo> list, LocalDateTime sta, LocalDateTime end) {
|
|
|
+ HashMap<String, Long> longHashMap = new HashMap<>();
|
|
|
+ long timeCount = 0;
|
|
|
+ long codingCount = 0;
|
|
|
+ if (ListUtil.isNotEmpty(list)) {
|
|
|
+ for (MedManagementInfo managementInfo : list) {
|
|
|
+ //开始工作时间
|
|
|
+ LocalDateTime hireDate = managementInfo.getHireDate();
|
|
|
+ //辞职时间
|
|
|
+ LocalDateTime resignationTime = managementInfo.getResignationTime();
|
|
|
+ //开始工作时间和离职时间均不为空
|
|
|
+ if (hireDate != null && resignationTime != null) {
|
|
|
+ //单位时间内开始时间大于等于工作时间且小于结束时间结束时间大于等于离职时间
|
|
|
+ if ((resignationTime.isAfter(sta))&&(sta.isAfter(hireDate) || sta.equals(hireDate)) && (end.isAfter(resignationTime) || end.equals(resignationTime))) {
|
|
|
+ // 开始时间---离职时间 相差的天数
|
|
|
+ Duration duration = Duration.between(sta, resignationTime);
|
|
|
+ long days = duration.toDays();
|
|
|
+ //病案管理人员
|
|
|
+ if (1 == managementInfo.getPosition()) {
|
|
|
+ timeCount = timeCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //病案编码管理人员
|
|
|
+ if (2 == managementInfo.getPosition()) {
|
|
|
+ codingCount = codingCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //单位时间内开始时间大于等于工作时间小于结束时间且离职时间大于等于结束时间
|
|
|
+ if ((resignationTime.isAfter(sta))&&(sta.isAfter(hireDate) || sta.equals(hireDate)) && (resignationTime.isAfter(end) || end.equals(resignationTime))) {
|
|
|
+ // 开始时间---结束时间
|
|
|
+ Duration duration = Duration.between(sta, end);
|
|
|
+ long days = duration.toDays();
|
|
|
+ //病案管理人员
|
|
|
+ if (1 == managementInfo.getPosition()) {
|
|
|
+ timeCount = timeCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //病案编码管理人员
|
|
|
+ if (2 == managementInfo.getPosition()) {
|
|
|
+ codingCount = codingCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 开始时间< =工作时间 < 离职时间<=结束时间
|
|
|
+ if ((resignationTime.isAfter(sta))&&(hireDate.isAfter(sta) || sta.equals(hireDate)) && (end.isAfter(resignationTime) || end.equals(resignationTime))) {
|
|
|
+ // 结束时间 ---离职时间
|
|
|
+ Duration duration = Duration.between(hireDate, resignationTime);
|
|
|
+ long days = duration.toDays();
|
|
|
+ //病案管理人员
|
|
|
+ if (1 == managementInfo.getPosition()) {
|
|
|
+ timeCount = timeCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //病案编码管理人员
|
|
|
+ if (2 == managementInfo.getPosition()) {
|
|
|
+ codingCount = codingCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 开始时间<=工作时间 离职时间>=结束时间
|
|
|
+ if ((hireDate.isAfter(sta) || sta.equals(hireDate)) && (resignationTime.isAfter(end) || end.equals(resignationTime))) {
|
|
|
+ // 工作时间---结束时间
|
|
|
+ Duration duration = Duration.between(hireDate, end);
|
|
|
+ long days = duration.toDays();
|
|
|
+ //病案管理人员
|
|
|
+ if (1 == managementInfo.getPosition()) {
|
|
|
+ timeCount = timeCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //病案编码管理人员
|
|
|
+ if (2 == managementInfo.getPosition()) {
|
|
|
+ codingCount = codingCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //离职时间为空
|
|
|
+ if (hireDate != null && resignationTime == null) {
|
|
|
+ //开始时间<=工作时间
|
|
|
+ if (hireDate.isAfter(sta) || sta.equals(hireDate)) {
|
|
|
+ Duration duration = Duration.between(hireDate, end);
|
|
|
+ long days = duration.toDays();
|
|
|
+ //病案管理人员
|
|
|
+ if (1 == managementInfo.getPosition()) {
|
|
|
+ timeCount = timeCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //病案编码管理人员
|
|
|
+ if (2 == managementInfo.getPosition()) {
|
|
|
+ codingCount = codingCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 结束时间>开始时间>=工作时间
|
|
|
+ if ((sta.isAfter(hireDate) || sta.equals(hireDate))&&(end.isAfter(hireDate))) {
|
|
|
+ Duration duration = Duration.between(sta, end);
|
|
|
+ long days = duration.toDays();
|
|
|
+ //病案管理人员
|
|
|
+ if (1 == managementInfo.getPosition()) {
|
|
|
+ timeCount = timeCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //病案编码管理人员
|
|
|
+ if (2 == managementInfo.getPosition()) {
|
|
|
+ codingCount = codingCount + days;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //开始时间大于结束时间
|
|
|
+ if((sta.isAfter(end))){
|
|
|
+ //病案管理人员
|
|
|
+ if (1 == managementInfo.getPosition()) {
|
|
|
+ timeCount = timeCount + 0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //病案编码管理人员
|
|
|
+ if (2 == managementInfo.getPosition()) {
|
|
|
+ codingCount = codingCount + 0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ }
|
|
|
+ longHashMap.put("病案管理", timeCount);
|
|
|
+ longHashMap.put("编码管理", codingCount);
|
|
|
+ }
|
|
|
+ return longHashMap;
|
|
|
+ }
|
|
|
}
|