|
@@ -1,6 +1,8 @@
|
|
package com.diagbot.facade;
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.diagbot.dto.CheckWorkDTO;
|
|
import com.diagbot.dto.MedicalRecordDTO;
|
|
import com.diagbot.dto.MedicalRecordDTO;
|
|
import com.diagbot.entity.MedBehospitalType;
|
|
import com.diagbot.entity.MedBehospitalType;
|
|
import com.diagbot.entity.MedCheckWork;
|
|
import com.diagbot.entity.MedCheckWork;
|
|
@@ -12,15 +14,11 @@ import com.diagbot.service.impl.MedicalRecordServiceImpl;
|
|
import com.diagbot.util.DateUtil;
|
|
import com.diagbot.util.DateUtil;
|
|
import com.diagbot.util.StringUtil;
|
|
import com.diagbot.util.StringUtil;
|
|
import com.diagbot.util.SysUserUtils;
|
|
import com.diagbot.util.SysUserUtils;
|
|
-import com.diagbot.vo.MedCheckWorkAddVO;
|
|
|
|
-import com.diagbot.vo.RecordContentVO;
|
|
|
|
-import com.diagbot.vo.RecordTypeVO;
|
|
|
|
-import com.diagbot.vo.TaskVO;
|
|
|
|
|
|
+import com.diagbot.vo.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
-import java.util.Collections;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -32,15 +30,16 @@ import java.util.List;
|
|
@Component
|
|
@Component
|
|
public class MedCheckWorkFacade extends MedCheckWorkServiceImpl {
|
|
public class MedCheckWorkFacade extends MedCheckWorkServiceImpl {
|
|
@Autowired
|
|
@Autowired
|
|
- private MedCheckWorkServiceImpl medCheckWorkServiceImpl;
|
|
|
|
|
|
+ private MedCheckWorkServiceImpl medCheckWorkServiceImpl;
|
|
@Autowired
|
|
@Autowired
|
|
private MedBehospitalTypeServiceImpl medBehospitalTypeServiceImpl;
|
|
private MedBehospitalTypeServiceImpl medBehospitalTypeServiceImpl;
|
|
@Autowired
|
|
@Autowired
|
|
private MedicalRecordServiceImpl medicalRecordServiceImpl;
|
|
private MedicalRecordServiceImpl medicalRecordServiceImpl;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Author songxl
|
|
* @Author songxl
|
|
* @Description 批量插入任务
|
|
* @Description 批量插入任务
|
|
- * @Date 2021/5/11
|
|
|
|
|
|
+ * @Date 2021/5/11
|
|
* @Param [medCheckWorkVOList]
|
|
* @Param [medCheckWorkVOList]
|
|
* @Return java.lang.Boolean
|
|
* @Return java.lang.Boolean
|
|
* @MethodName addCheck
|
|
* @MethodName addCheck
|
|
@@ -50,11 +49,10 @@ public class MedCheckWorkFacade extends MedCheckWorkServiceImpl {
|
|
Long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
|
|
Long hospitalId = Long.parseLong(SysUserUtils.getCurrentHospitalID());
|
|
String create = SysUserUtils.getCurrentPrincipleID();
|
|
String create = SysUserUtils.getCurrentPrincipleID();
|
|
List<MedCheckWork> checkWorkList = new ArrayList<>();
|
|
List<MedCheckWork> checkWorkList = new ArrayList<>();
|
|
- for(MedCheckWorkAddVO medCheckWorkAddVO:medCheckWorkVOList)
|
|
|
|
- {
|
|
|
|
|
|
+ for (MedCheckWorkAddVO medCheckWorkAddVO : medCheckWorkVOList) {
|
|
//入参验证
|
|
//入参验证
|
|
if (StringUtil.isBlank(medCheckWorkAddVO.getBehospitalCode())
|
|
if (StringUtil.isBlank(medCheckWorkAddVO.getBehospitalCode())
|
|
- ||StringUtil.isBlank(medCheckWorkAddVO.getWorkType())) {
|
|
|
|
|
|
+ || StringUtil.isBlank(medCheckWorkAddVO.getWorkType())) {
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "病历id或任务类型不能为空!");
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "病历id或任务类型不能为空!");
|
|
}
|
|
}
|
|
MedCheckWork medCheckWork = new MedCheckWork();
|
|
MedCheckWork medCheckWork = new MedCheckWork();
|
|
@@ -67,12 +65,13 @@ public class MedCheckWorkFacade extends MedCheckWorkServiceImpl {
|
|
medCheckWork.setId(Long.valueOf(medCheckWorkAddVO.getBehospitalCode()));
|
|
medCheckWork.setId(Long.valueOf(medCheckWorkAddVO.getBehospitalCode()));
|
|
checkWorkList.add(medCheckWork);
|
|
checkWorkList.add(medCheckWork);
|
|
}
|
|
}
|
|
- return medCheckWorkServiceImpl.saveBatch(checkWorkList,10);
|
|
|
|
|
|
+ return medCheckWorkServiceImpl.saveBatch(checkWorkList, 10);
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Author songxl
|
|
* @Author songxl
|
|
* @Description 获取每日住院患者的类型(出院、病危、抢救。。。)
|
|
* @Description 获取每日住院患者的类型(出院、病危、抢救。。。)
|
|
- * @Date 2021/5/11
|
|
|
|
|
|
+ * @Date 2021/5/11
|
|
* @Param [param]
|
|
* @Param [param]
|
|
* @Return void
|
|
* @Return void
|
|
* @MethodName execute
|
|
* @MethodName execute
|
|
@@ -87,105 +86,134 @@ public class MedCheckWorkFacade extends MedCheckWorkServiceImpl {
|
|
|
|
|
|
|
|
|
|
//定义批量插入的集合
|
|
//定义批量插入的集合
|
|
- HashMap<String,MedBehospitalType> medBehospitalTypeMap = null;
|
|
|
|
|
|
+ HashMap<String, MedBehospitalType> medBehospitalTypeMap = null;
|
|
//1.判断患者类型表是否有记录
|
|
//1.判断患者类型表是否有记录
|
|
int count = medBehospitalTypeServiceImpl.count();
|
|
int count = medBehospitalTypeServiceImpl.count();
|
|
- if(count>0)
|
|
|
|
- {
|
|
|
|
|
|
+ if (count > 0) {
|
|
medBehospitalTypeMap = new HashMap<>();
|
|
medBehospitalTypeMap = new HashMap<>();
|
|
//2.1获取最近指定归档时间间隔的患者
|
|
//2.1获取最近指定归档时间间隔的患者
|
|
RecordTypeVO recordContentVO = new RecordTypeVO();
|
|
RecordTypeVO recordContentVO = new RecordTypeVO();
|
|
recordContentVO.setHospitalId(hospiatlId);
|
|
recordContentVO.setHospitalId(hospiatlId);
|
|
recordContentVO.setModeList(new ArrayList<String>(typeValue.keySet()));
|
|
recordContentVO.setModeList(new ArrayList<String>(typeValue.keySet()));
|
|
recordContentVO.setIsPlacefile(1l);//获取已归档的患者
|
|
recordContentVO.setIsPlacefile(1l);//获取已归档的患者
|
|
- recordContentVO.setStartTime(DateUtil.formatDateTime(DateUtil.addMinutes(DateUtil.now(),-30)));
|
|
|
|
|
|
+ recordContentVO.setStartTime(DateUtil.formatDateTime(DateUtil.addMinutes(DateUtil.now(), -30)));
|
|
recordContentVO.setEndTime(DateUtil.formatDateTime(DateUtil.now()));
|
|
recordContentVO.setEndTime(DateUtil.formatDateTime(DateUtil.now()));
|
|
getPatientRecordType(medBehospitalTypeMap,
|
|
getPatientRecordType(medBehospitalTypeMap,
|
|
- medicalRecordServiceImpl.getMedicalRecord(recordContentVO),typeValue,typeName,hospiatlId);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- //2.2添加今天之前所有患者的类型
|
|
|
|
- //2.2.1获取所有数据数量
|
|
|
|
- medBehospitalTypeMap = new HashMap<>();
|
|
|
|
- RecordTypeVO recordContentVO = new RecordTypeVO();
|
|
|
|
- recordContentVO.setHospitalId(hospiatlId);
|
|
|
|
- recordContentVO.setModeList(new ArrayList<String>(typeValue.keySet()));
|
|
|
|
- recordContentVO.setIsPlacefile(1l);//获取已归档的患者
|
|
|
|
- int num = medicalRecordServiceImpl.getRecordCount(recordContentVO);
|
|
|
|
- if(num>0)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- if(num<searchSize)
|
|
|
|
- {
|
|
|
|
|
|
+ medicalRecordServiceImpl.getMedicalRecord(recordContentVO), typeValue, typeName, hospiatlId);
|
|
|
|
+ } else {
|
|
|
|
+ //2.2添加今天之前所有患者的类型
|
|
|
|
+ //2.2.1获取所有数据数量
|
|
|
|
+ medBehospitalTypeMap = new HashMap<>();
|
|
|
|
+ RecordTypeVO recordContentVO = new RecordTypeVO();
|
|
|
|
+ recordContentVO.setHospitalId(hospiatlId);
|
|
|
|
+ recordContentVO.setModeList(new ArrayList<String>(typeValue.keySet()));
|
|
|
|
+ recordContentVO.setIsPlacefile(1l);//获取已归档的患者
|
|
|
|
+ int num = medicalRecordServiceImpl.getRecordCount(recordContentVO);
|
|
|
|
+ if (num > 0) {
|
|
|
|
+
|
|
|
|
+ if (num < searchSize) {
|
|
//执行一次
|
|
//执行一次
|
|
- recordContentVO.setStart(0L);
|
|
|
|
- recordContentVO.setEnd(num+0L);
|
|
|
|
- getPatientRecordType(medBehospitalTypeMap,
|
|
|
|
- medicalRecordServiceImpl.getMedicalRecord(recordContentVO),typeValue,typeName,hospiatlId);
|
|
|
|
- }
|
|
|
|
- int i = num/searchSize+1;
|
|
|
|
- for(int j=0;j<i;j++)
|
|
|
|
- {
|
|
|
|
- //5000个一次循环添加
|
|
|
|
- recordContentVO.setStart(j*searchSize*1L);
|
|
|
|
- recordContentVO.setEnd(searchSize*1L);
|
|
|
|
- getPatientRecordType(medBehospitalTypeMap,
|
|
|
|
- medicalRecordServiceImpl.getMedicalRecord(recordContentVO),typeValue,typeName,hospiatlId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //3.批量执行插入操作
|
|
|
|
- if(medBehospitalTypeMap.size()>0)
|
|
|
|
- {
|
|
|
|
|
|
+ recordContentVO.setStart(0L);
|
|
|
|
+ recordContentVO.setEnd(num + 0L);
|
|
|
|
+ getPatientRecordType(medBehospitalTypeMap,
|
|
|
|
+ medicalRecordServiceImpl.getMedicalRecord(recordContentVO), typeValue, typeName, hospiatlId);
|
|
|
|
+ }
|
|
|
|
+ int i = num / searchSize + 1;
|
|
|
|
+ for (int j = 0; j < i; j++) {
|
|
|
|
+ //5000个一次循环添加
|
|
|
|
+ recordContentVO.setStart(j * searchSize * 1L);
|
|
|
|
+ recordContentVO.setEnd(searchSize * 1L);
|
|
|
|
+ getPatientRecordType(medBehospitalTypeMap,
|
|
|
|
+ medicalRecordServiceImpl.getMedicalRecord(recordContentVO), typeValue, typeName, hospiatlId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //3.批量执行插入操作
|
|
|
|
+ if (medBehospitalTypeMap.size() > 0) {
|
|
List<MedBehospitalType> medBehospitalTypeList = new ArrayList<>(medBehospitalTypeMap.values());
|
|
List<MedBehospitalType> medBehospitalTypeList = new ArrayList<>(medBehospitalTypeMap.values());
|
|
- medBehospitalTypeServiceImpl.saveBatch(medBehospitalTypeList,batchSize);
|
|
|
|
|
|
+ medBehospitalTypeServiceImpl.saveBatch(medBehospitalTypeList, batchSize);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Author songxl
|
|
* @Author songxl
|
|
* @Description 获取患者类型存入批量插入map
|
|
* @Description 获取患者类型存入批量插入map
|
|
- * @Date 2021/5/11
|
|
|
|
|
|
+ * @Date 2021/5/11
|
|
* @Param [medBehospitalTypeMap, medicalRecordList, typeValue, typeName, hospiatlId]
|
|
* @Param [medBehospitalTypeMap, medicalRecordList, typeValue, typeName, hospiatlId]
|
|
* @Return void
|
|
* @Return void
|
|
* @MethodName getPatientRecordType
|
|
* @MethodName getPatientRecordType
|
|
*/
|
|
*/
|
|
- private void getPatientRecordType(HashMap<String,MedBehospitalType> medBehospitalTypeMap,
|
|
|
|
|
|
+ private void getPatientRecordType(HashMap<String, MedBehospitalType> medBehospitalTypeMap,
|
|
List<MedicalRecordDTO> medicalRecordList,
|
|
List<MedicalRecordDTO> medicalRecordList,
|
|
JSONObject typeValue,
|
|
JSONObject typeValue,
|
|
- JSONObject typeName,Long hospiatlId) {
|
|
|
|
|
|
+ JSONObject typeName, Long hospiatlId) {
|
|
|
|
|
|
- if(medicalRecordList==null || medicalRecordList.isEmpty()){return;}
|
|
|
|
|
|
+ if (medicalRecordList == null || medicalRecordList.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
//1.遍历查询出来的结果
|
|
//1.遍历查询出来的结果
|
|
- for(MedicalRecordDTO medicalRecordDTO:medicalRecordList)
|
|
|
|
- {
|
|
|
|
|
|
+ for (MedicalRecordDTO medicalRecordDTO : medicalRecordList) {
|
|
//2.判断批量插入map中有没有这个患者
|
|
//2.判断批量插入map中有没有这个患者
|
|
- if(medBehospitalTypeMap.containsKey(medicalRecordDTO.getBehospitalCode()))
|
|
|
|
- {
|
|
|
|
|
|
+ if (medBehospitalTypeMap.containsKey(medicalRecordDTO.getBehospitalCode())) {
|
|
//3.比较这两次的分值大小
|
|
//3.比较这两次的分值大小
|
|
int lval = medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).getValue();
|
|
int lval = medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).getValue();
|
|
- int nval = typeValue.getInteger(medicalRecordDTO.getModeId()+"");
|
|
|
|
- if(nval>lval)
|
|
|
|
- {
|
|
|
|
|
|
+ int nval = typeValue.getInteger(medicalRecordDTO.getModeId() + "");
|
|
|
|
+ if (nval > lval) {
|
|
medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).setValue(nval);
|
|
medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).setValue(nval);
|
|
medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode())
|
|
medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode())
|
|
- .setBehospitalType(typeName.getString(medicalRecordDTO.getModeId()+""));
|
|
|
|
|
|
+ .setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
//4.获取分值记录这个患者
|
|
//4.获取分值记录这个患者
|
|
MedBehospitalType medBehospitalType = new MedBehospitalType();
|
|
MedBehospitalType medBehospitalType = new MedBehospitalType();
|
|
medBehospitalType.setBehospitalCode(medicalRecordDTO.getBehospitalCode());
|
|
medBehospitalType.setBehospitalCode(medicalRecordDTO.getBehospitalCode());
|
|
- medBehospitalType.setBehospitalType(typeName.getString(medicalRecordDTO.getModeId()+""));
|
|
|
|
- medBehospitalType.setValue(typeValue.getInteger(medicalRecordDTO.getModeId()+""));
|
|
|
|
|
|
+ medBehospitalType.setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
|
|
|
|
+ medBehospitalType.setValue(typeValue.getInteger(medicalRecordDTO.getModeId() + ""));
|
|
medBehospitalType.setCreateTime(DateUtil.now());
|
|
medBehospitalType.setCreateTime(DateUtil.now());
|
|
medBehospitalType.setHospitalId(hospiatlId);
|
|
medBehospitalType.setHospitalId(hospiatlId);
|
|
- medBehospitalTypeMap.put(medicalRecordDTO.getBehospitalCode(),medBehospitalType);
|
|
|
|
|
|
+ medBehospitalTypeMap.put(medicalRecordDTO.getBehospitalCode(), medBehospitalType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页
|
|
|
|
+ *
|
|
|
|
+ * @param checkWorkPageVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public IPage<CheckWorkDTO> pageFac(CheckWorkPageVO checkWorkPageVO) {
|
|
|
|
+ checkWorkPageSet(checkWorkPageVO);
|
|
|
|
+ IPage<CheckWorkDTO> res = getCheckWorkPage(checkWorkPageVO);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void checkWorkPageSet(CheckWorkPageVO checkWorkPageVO) {
|
|
|
|
+ //入参验证
|
|
|
|
+ //出院时间
|
|
|
|
+ if (null != checkWorkPageVO && null != checkWorkPageVO.getStartDate()) {
|
|
|
|
+ checkWorkPageVO.setStartDate(DateUtil.getFirstTimeOfDay(checkWorkPageVO.getStartDate()));
|
|
|
|
+ }
|
|
|
|
+ if (null != checkWorkPageVO && null != checkWorkPageVO.getEndDate()) {
|
|
|
|
+ checkWorkPageVO.setEndDate(DateUtil.getFirstTimeOfDay(DateUtil.addDay(checkWorkPageVO.getEndDate(), 1)));
|
|
|
|
+ }
|
|
|
|
+ if (null != checkWorkPageVO && null != checkWorkPageVO.getStartDate() && null != checkWorkPageVO.getEndDate()) {
|
|
|
|
+ if (DateUtil.after(checkWorkPageVO.getStartDate(), checkWorkPageVO.getEndDate())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "出院时间的开始时间必须小于结束时间!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //住院天数
|
|
|
|
+ if (null != checkWorkPageVO && null != checkWorkPageVO.getSDay() && null != checkWorkPageVO.getLDay()) {
|
|
|
|
+ if (checkWorkPageVO.getSDay() > checkWorkPageVO.getLDay()) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "住院天数区间有误!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ checkWorkPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|