| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import com.smartor.service.IServiceExternalService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | private PatMedInspectionItemMapper patMedInspectionItemMapper; |
| | | @Autowired |
| | | private Icd10Mapper icd10Mapper; |
| | | @Autowired |
| | | private IPatMedOuthospService patMedOuthospService; |
| | | @Autowired |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | @Autowired |
| | |
| | | if (CollectionUtils.isNotEmpty(sysDepts)) { |
| | | sysDept = sysDepts.get(0); |
| | | } |
| | | if(ObjectUtils.isEmpty(sysUser)){ |
| | | if (ObjectUtils.isEmpty(sysUser)) { |
| | | log.error("ServiceExternalServiceImpl---addUserDeptInfo 找不到对应的用户 username: {}", externalUserDeptInfo.getYongHuDLM()); |
| | | return false; |
| | | }else if(ObjectUtils.isEmpty(sysDept)){ |
| | | } else if (ObjectUtils.isEmpty(sysDept)) { |
| | | log.error("ServiceExternalServiceImpl---addUserDeptInfo 找不到对应的科室 hisDeptId: {}", externalUserDeptInfo.getKeShiID()); |
| | | return false; |
| | | }else { |
| | | } else { |
| | | SysUserDept sysUserDept = new SysUserDept(); |
| | | sysUserDept.setDelFlag(0L); |
| | | sysUserDept.setUserId(sysUser.getUserId()); |
| | |
| | | log.info("ServiceExternalServiceImpl---addUserDeptInfo是否修改成功03:{}", i); |
| | | } |
| | | //更新sys-user deptId |
| | | if(StringUtils.isNotEmpty(externalUserDeptInfo.getKeShiID())){ |
| | | if (StringUtils.isNotEmpty(externalUserDeptInfo.getKeShiID())) { |
| | | sysUser.setDeptId(Long.valueOf(externalUserDeptInfo.getKeShiID())); |
| | | //查询用户科室关系 |
| | | SysUserDept sysUserDeptTemp = new SysUserDept(); |
| | | sysUserDeptTemp.setUserId(sysUser.getUserId()); |
| | | sysUserDeptTemp.setOrgid(externalUserDeptInfo.getZuZhiJGID()); |
| | | List<SysUserDept> sysUserDepts = sysUserDeptMapper.selectSysUserDeptList(sysUserDeptTemp); |
| | | List<String> userDepts = sysUserDepts.stream().map(SysUserDept::getDeptCode). |
| | | distinct().collect(Collectors.toList()); |
| | | List<String> userDepts = sysUserDepts.stream().map(SysUserDept::getDeptCode).distinct().collect(Collectors.toList()); |
| | | //和queryHospUserInfoList采集的数据格式保持一致 |
| | | List<List<String>> userDeptsList = new ArrayList<>(); |
| | | if(!userDepts.isEmpty()){ |
| | | for(String userDept: userDepts){ |
| | | if (!userDepts.isEmpty()) { |
| | | for (String userDept : userDepts) { |
| | | List<String> uDept = new ArrayList<>(); |
| | | uDept.add(userDept); |
| | | userDeptsList.add(uDept); |
| | |
| | | // 4-非医嘱离院 5-死亡 9-其他 10-介入室 20-手术室 |
| | | String liYuanQxdm = ObjectUtils.isNotEmpty(JiuZhenXX.get("LiYuanQXDM")) ? JiuZhenXX.get("LiYuanQXDM").toString() : null; |
| | | //判断病人是否死亡 |
| | | if(ObjectUtils.isNotEmpty(liYuanQxdm) &&("5").equals(liYuanQxdm)){ |
| | | if (ObjectUtils.isNotEmpty(liYuanQxdm) && ("5").equals(liYuanQxdm)) { |
| | | deathFlag = true; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | patMedInhosp1.setInhospstate("1"); |
| | | if(deathFlag){ |
| | | if (deathFlag) { |
| | | //病人死亡无须随访 |
| | | patMedInhosp1.setFuflag("1"); |
| | | //更新病人 notrequiredFlag |
| | |
| | | * 第一条(急诊科室的)记录缺少“出院时间”,导致该记录在统计中始终显示为“在院”, |
| | | * 而第二条(转入科室的)记录是完整的。我们需要采集 JZ_ZY_LiQiang接口的数据, |
| | | * 里面的离抢时间来反填第一条记录的“出院时间”,从而修正第一条记录的状态。 |
| | | * |
| | | * @param dataMap |
| | | * @return |
| | | */ |
| | |
| | | List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); |
| | | PatMedInhosp patMedInhosp1 = null; |
| | | if (CollectionUtils.isNotEmpty(patMedInhospList)) patMedInhosp1 = patMedInhospList.get(0); |
| | | if(ObjectUtils.isNotEmpty(patMedInhosp1)){ |
| | | if (ObjectUtils.isNotEmpty(patMedInhosp1)) { |
| | | if (ObjectUtils.isNotEmpty(JiuZhenXX.get("LiQiangSJ"))) { |
| | | try { |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | } |
| | | } |
| | | return true; |
| | | }else { |
| | | } else { |
| | | log.error("ServiceExternalServiceImpl---editRescueFinishedOutHospInfo的没有找到对应的出院记录:{}", dataMap); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Boolean addFinshJZInfo(Map dataMap) { |
| | | log.info("ServiceExternalServiceImpl---addFinshJZInfo的新增的值为:{}", dataMap); |
| | | //先对表进行维护 |
| | | tableMaintenance(); |
| | | |
| | | Map yeWuXX = (Map) dataMap.get("YeWuXX"); |
| | | Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou"); |
| | |
| | | |
| | | PatArchive patArchive = addPatArchive(externalInHospPatientInfo, null, null); |
| | | |
| | | PatMedOuthosp patMedOuthosp = new PatMedOuthosp(); |
| | | patMedOuthosp.setOuthospno(externalInHospPatientInfo.getBingAnHao()); |
| | | patMedOuthosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp); |
| | | PatMedOuthospQueryReq patMedOuthospreq = new PatMedOuthospQueryReq(); |
| | | patMedOuthospreq.setOuthospno(externalInHospPatientInfo.getBingAnHao()); |
| | | patMedOuthospreq.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthospreq); |
| | | for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) { |
| | | PatArchive pa = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid()); |
| | | if (patArchive.getBirthdate() != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | PatMedOuthosp patMedOuthosp = DtoConversionUtils.sourceToTarget(patMedOuthospreq, PatMedOuthosp.class); |
| | | patMedOuthosp.setPatid(patArchive.getId()); |
| | | patMedOuthosp.setPatno(externalInHospPatientInfo.getBingAnHao()); |
| | | patMedOuthosp.setPatname(externalInHospPatientInfo.getXingMing()); |
| | |
| | | //不需要长期任务随访,由医生自己去随访(丽水中医院首次提出) |
| | | patMedOuthosp.setFuflag("1"); |
| | | } |
| | | i = patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp); |
| | | i = patMedOuthospService.updatePatMedOuthosp(patMedOuthosp); |
| | | } else { |
| | | patMedOuthosp.setCreateTime(new Date()); |
| | | patMedOuthosp.setUpdateTime(new Date()); |
| | |
| | | //不需要长期任务随访 |
| | | patMedOuthosp.setFuflag("1"); |
| | | } |
| | | i = patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); |
| | | } |
| | | i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp); |
| | | |
| | | // //先通过身份证和科室查询该患者是否有需要随访的(景宁提出来的) |
| | | // if (patMedOuthosp.getOrgid().equals("47255004333112711A1001") && StringUtils.isNotEmpty(patMedOuthosp.getIdcardno()) && StringUtils.isNotEmpty(patMedOuthosp.getDeptcode())) { |
| | | // ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO(); |
| | | // serviceSubtaskVO.setSfzh(patMedOuthosp.getIdcardno()); |
| | | // serviceSubtaskVO.setDeptcode(patMedOuthosp.getDeptcode()); |
| | | // serviceSubtaskVO.setSendstate(2L); |
| | | // List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | // if (CollectionUtils.isNotEmpty(serviceSubtaskList)) { |
| | | // for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | // serviceSubtask.setSendstate(6L); |
| | | // serviceSubtask.setRemark("患者已经回来复诊"); |
| | | // serviceSubtask.setUpdateTime(new Date()); |
| | | // serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | if (i > 0) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public void tableMaintenance() { |
| | | // 1. 判断表数据量 |
| | | int count = patMedOuthospMapper.countPatMedOuthosp(); |
| | | if (count > 3000000) { |
| | | // 2. 冷藏表并新建 |
| | | String timeSuffix = new SimpleDateFormat("yyyyMM").format(new Date()); |
| | | String oldName = "pat_med_outhosp"; |
| | | String newName = oldName + "_" + timeSuffix; |
| | | |
| | | // 冷藏 |
| | | patMedOuthospMapper.renameTable(oldName, newName); |
| | | |
| | | // 3. 计算所有表的最大id |
| | | List<String> tableNames = patMedOuthospMapper.getAllOuthospTableNames(); |
| | | long maxId = 0; |
| | | for (String tableName : tableNames) { |
| | | Long tableMaxId = patMedOuthospMapper.getMaxIdFromTable(tableName); |
| | | if (tableMaxId != null && tableMaxId > maxId) { |
| | | maxId = tableMaxId; |
| | | } |
| | | } |
| | | |
| | | // 4. 新建(此时只剩冷表,PatMedOuthosp没了,需要新建一个) |
| | | patMedOuthospMapper.createPatMedOuthosp(newName, oldName); |
| | | |
| | | //5.设置新表自增主键 |
| | | patMedOuthospMapper.createPatMedOuthospAutoAdd(oldName); |
| | | //6. 设置新表自增起始值 |
| | | patMedOuthospMapper.setAutoIncrement(oldName, maxId + 1); |
| | | |
| | | // 7. 更新/新建视图 |
| | | // 重新获取所有表名(包含刚新建的主表) |
| | | List<String> allTables = patMedOuthospMapper.getAllOuthospTableNames(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("CREATE OR REPLACE VIEW v_pat_med_outhosp AS "); |
| | | for (int i = 0; i < allTables.size(); i++) { |
| | | sb.append("SELECT * FROM ").append(allTables.get(i)); |
| | | if (i < allTables.size() - 1) { |
| | | sb.append(" UNION ALL "); |
| | | } |
| | | } |
| | | patMedOuthospMapper.createOrReplaceView(sb.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |