|
@@ -2,13 +2,16 @@ package com.diagbot.facade;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.dto.BasDeptInfoDTO;
|
|
|
import com.diagbot.dto.BehospitalInfoAgeDTO;
|
|
|
import com.diagbot.dto.CheckWorkDTO;
|
|
|
import com.diagbot.dto.MedicalRecordDTO;
|
|
|
+import com.diagbot.entity.BehospitalInfo;
|
|
|
import com.diagbot.entity.MedBehospitalType;
|
|
|
import com.diagbot.entity.MedCheckInfo;
|
|
|
+import com.diagbot.entity.MedicalRecord;
|
|
|
import com.diagbot.entity.SysTaskCron;
|
|
|
import com.diagbot.entity.SysUser;
|
|
|
import com.diagbot.enums.CheckJobTypeEnum;
|
|
@@ -18,6 +21,7 @@ import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.MedBehospitalTypeServiceImpl;
|
|
|
import com.diagbot.service.impl.MedCheckInfoServiceImpl;
|
|
|
import com.diagbot.service.impl.MedicalRecordServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
@@ -180,6 +184,56 @@ public class MedCheckWorkFacade {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 获取每日住院患者的类型(出院、病危、抢救。。。)
|
|
|
+ * @Date 2021/5/11
|
|
|
+ * @Param [param]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName execute
|
|
|
+ */
|
|
|
+ public void execute(String param, String behospitalCode) {
|
|
|
+ if (StringUtil.isBlank(behospitalCode) || StringUtil.isBlank(param)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject paramJson = JSONObject.parseObject(param);
|
|
|
+ JSONObject typeValue = paramJson.getJSONObject("typeVal");
|
|
|
+ JSONObject typeName = paramJson.getJSONObject("typeName");
|
|
|
+ int searchSize = paramJson.getInteger("searchSize");
|
|
|
+ int batchSize = paramJson.getInteger("batchSize");
|
|
|
+
|
|
|
+
|
|
|
+ //定义批量插入的集合
|
|
|
+ HashMap<String, MedBehospitalType> medBehospitalTypeMap = new HashMap<>();
|
|
|
+ //1.获取有指定文书、没有患者类型的患者数据
|
|
|
+ RecordTypeVO recordContentVO = new RecordTypeVO();
|
|
|
+ recordContentVO.setModeList(new ArrayList<>(typeValue.keySet()));
|
|
|
+ List<MedicalRecord> medicalRecords = medicalRecordServiceImpl.list(new QueryWrapper<MedicalRecord>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq(SysUserUtils.getCurrentHospitalID() != null, "hospital_id", SysUserUtils.getCurrentHospitalID())
|
|
|
+ .eq("behospital_code", behospitalCode));
|
|
|
+ List<MedicalRecordDTO> medicalRecordList = BeanUtil.listCopyTo(medicalRecords, MedicalRecordDTO.class);
|
|
|
+ if (medicalRecordList != null && !medicalRecordList.isEmpty()) {
|
|
|
+ getPatientRecordType(medBehospitalTypeMap, medicalRecordList, typeValue, typeName);
|
|
|
+ }
|
|
|
+ //2.批量执行插入操作
|
|
|
+ try {
|
|
|
+ if (medBehospitalTypeMap != null && medBehospitalTypeMap.size() > 0) {
|
|
|
+ //删除原来的插入新的
|
|
|
+ medBehospitalTypeServiceImpl.remove(new UpdateWrapper<MedBehospitalType>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq(SysUserUtils.getCurrentHospitalID() != null, "hospital_id", SysUserUtils.getCurrentHospitalID())
|
|
|
+ .in("behospital_code", medBehospitalTypeMap.keySet()));
|
|
|
+
|
|
|
+ List<MedBehospitalType> medBehospitalTypeList = new ArrayList<>(medBehospitalTypeMap.values());
|
|
|
+ medBehospitalTypeServiceImpl.saveOrUpdateBatch(medBehospitalTypeList, batchSize);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Author songxl
|
|
|
* @Description 获取患者类型存入批量插入map
|
|
@@ -200,23 +254,27 @@ public class MedCheckWorkFacade {
|
|
|
for (MedicalRecordDTO medicalRecordDTO : medicalRecordList) {
|
|
|
//2.判断批量插入map中有没有这个患者
|
|
|
if (medBehospitalTypeMap.containsKey(medicalRecordDTO.getBehospitalCode())) {
|
|
|
- //3.比较这两次的分值大小
|
|
|
- int lval = medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).getValue();
|
|
|
- int nval = typeValue.getInteger(medicalRecordDTO.getModeId() + "");
|
|
|
- if (nval > lval) {
|
|
|
- medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).setValue(nval);
|
|
|
- medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode())
|
|
|
- .setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
|
|
|
+ if (typeName.containsKey(medicalRecordDTO.getModeId() + "")) {
|
|
|
+ //3.比较这两次的分值大小
|
|
|
+ int lval = medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).getValue();
|
|
|
+ int nval = typeValue.getInteger(medicalRecordDTO.getModeId() + "");
|
|
|
+ if (nval > lval) {
|
|
|
+ medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).setValue(nval);
|
|
|
+ medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode())
|
|
|
+ .setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
//4.获取分值记录这个患者
|
|
|
- MedBehospitalType medBehospitalType = new MedBehospitalType();
|
|
|
- medBehospitalType.setBehospitalCode(medicalRecordDTO.getBehospitalCode());
|
|
|
- medBehospitalType.setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
|
|
|
- medBehospitalType.setValue(typeValue.getInteger(medicalRecordDTO.getModeId() + ""));
|
|
|
- medBehospitalType.setCreateTime(DateUtil.now());
|
|
|
- medBehospitalType.setHospitalId(medicalRecordDTO.getHospitalId());
|
|
|
- medBehospitalTypeMap.put(medicalRecordDTO.getBehospitalCode(), medBehospitalType);
|
|
|
+ if (typeName.containsKey(medicalRecordDTO.getModeId() + "")) {
|
|
|
+ MedBehospitalType medBehospitalType = new MedBehospitalType();
|
|
|
+ medBehospitalType.setBehospitalCode(medicalRecordDTO.getBehospitalCode());
|
|
|
+ medBehospitalType.setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
|
|
|
+ medBehospitalType.setValue(typeValue.getInteger(medicalRecordDTO.getModeId() + ""));
|
|
|
+ medBehospitalType.setCreateTime(DateUtil.now());
|
|
|
+ medBehospitalType.setHospitalId(medicalRecordDTO.getHospitalId());
|
|
|
+ medBehospitalTypeMap.put(medicalRecordDTO.getBehospitalCode(), medBehospitalType);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|