|  |  | 
 |  |  | import cn.hutool.core.bean.BeanUtil; | 
 |  |  | import com.ruoyi.common.core.domain.entity.SysDept; | 
 |  |  | import com.ruoyi.common.core.domain.entity.SysUser; | 
 |  |  | import com.ruoyi.common.core.redis.RedisCache; | 
 |  |  | import com.ruoyi.common.exception.base.BaseException; | 
 |  |  | import com.ruoyi.common.utils.StringUtils; | 
 |  |  | import com.smartor.domain.*; | 
 |  |  | import com.smartor.mapper.*; | 
 |  |  | import com.smartor.service.IServiceExternalService; | 
 |  |  | import com.smartor.service.IServiceSubtaskService; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.apache.commons.collections4.CollectionUtils; | 
 |  |  | import org.apache.commons.lang3.ObjectUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | import java.text.ParseException; | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  | import java.time.LocalDate; | 
 |  |  | import java.time.Period; | 
 |  |  | import java.time.ZoneId; | 
 |  |  | import java.time.temporal.ChronoUnit; | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private PatArchiveMapper patArchiveMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PatArchivecontactMapper patArchivecontactMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PatMedInhospMapper patMedInhospMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PatMedOperationMapper patMedOperationMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PatMedOperationItemMapper patMedOperationItemMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PatMedInspectionMapper patMedInspectionMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PatMedInspectionItemMapper patMedInspectionItemMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private Icd10Mapper icd10Mapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PatMedOuthospMapper patMedOuthospMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private ServiceSubtaskMapper serviceSubtaskMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private RedisCache redisCache; | 
 |  |  |  | 
 |  |  |     @Value("${defaultPwd}") | 
 |  |  |     private String defaultPwd; | 
 |  |  |  | 
 |  |  |     @Value("${noLongTask}") | 
 |  |  |     private List<String> noLongTask; | 
 |  |  |  | 
 |  |  |     public Boolean generalInterface(Map dataMap) { | 
 |  |  |         Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou"); | 
 |  |  | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     @Override | 
 |  |  |     public Boolean addDeptInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addDeptInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addDeptInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> keShiXX = (Map<String, Object>) yeWuXX.get("KeShiXX"); | 
 |  |  |         ExternalDept externalDept = BeanUtil.mapToBean(keShiXX, ExternalDept.class, true); | 
 |  |  |         if (ObjectUtils.isEmpty(externalDept)) { | 
 |  |  |             throw new BaseException("externalDept是空的,没有数据!!!"); | 
 |  |  |         } | 
 |  |  |         SysDept sysDept = new SysDept(); | 
 |  |  |         sysDept.setOrgid(externalDept.getZuZhiJGID()); | 
 |  |  |         sysDept.setHisDeptId(externalDept.getKeShiID()); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         if (StringUtils.isNotEmpty(externalDept.getShiJianDM()) && externalDept.getShiJianDM().equals("1")) { | 
 |  |  |             int i = sysDeptMapper.insertDept(sysDept); | 
 |  |  |             log.error("ServiceExternalServiceImpl---addDeptInfo是否新增成功:{}", i); | 
 |  |  |             log.info("ServiceExternalServiceImpl---addDeptInfo01是否新增成功:{}", i); | 
 |  |  |         } else { | 
 |  |  |             int i = sysDeptMapper.updateDept(sysDept); | 
 |  |  |             log.error("ServiceExternalServiceImpl---addDeptInfo是否修改成功:{}", i); | 
 |  |  |             log.info("ServiceExternalServiceImpl---addDeptInfo02是否修改成功:{}", i); | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addUserInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addUserInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addUserInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> yongHuXX = (Map<String, Object>) yeWuXX.get("YongHuXX"); | 
 |  |  |         ExternalUserInfo externalUserInfo = BeanUtil.mapToBean(yongHuXX, ExternalUserInfo.class, true); | 
 |  |  |         if (ObjectUtils.isEmpty(externalUserInfo)) { | 
 |  |  |             throw new BaseException("externalUserInfo是空的,没有数据!!!"); | 
 |  |  |         } | 
 |  |  |         SysUser sysUser = new SysUser(); | 
 |  |  |         sysUser.setGuid(externalUserInfo.getZuZhiJGID()); | 
 |  |  |         sysUser.setUserName(externalUserInfo.getYongHuDLM()); | 
 |  |  |         sysUser.setOrgid(externalUserInfo.getZuZhiJGID()); | 
 |  |  |         //根据userName判断一下,是不是之前有新增 | 
 |  |  |         SysUser sysUser1 = null; | 
 |  |  |         List<SysUser> sysUserList = sysUserMapper.selectUserList(sysUser); | 
 |  |  |         if (CollectionUtils.isNotEmpty(sysUserList)) { | 
 |  |  |             sysUser1 = sysUserList.get(0); | 
 |  |  |             if (sysUserList.size() > 1) sysUser1 = getUser(sysUserList); | 
 |  |  |         } | 
 |  |  |         sysUser.setGuid(externalUserInfo.getZuZhiJGID()); | 
 |  |  |         sysUser.setNickName(externalUserInfo.getYongHuXM()); | 
 |  |  |         sysUser.setUserType(""); | 
 |  |  |         sysUser.setDeptId(null); | 
 |  |  |         sysUser.setTitle(null); | 
 |  |  |  | 
 |  |  |         BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); | 
 |  |  |         sysUser.setPassword(passwordEncoder.encode(defaultPwd)); | 
 |  |  |  | 
 |  |  |         sysUser.setHisUserId(externalUserInfo.getYongHuID()); | 
 |  |  |         sysUser.setPhonenumber(externalUserInfo.getLianXiDH()); | 
 |  |  | 
 |  |  |         sysUser.setCreateTime(externalUserInfo.getChuangJianSJ()); | 
 |  |  |         sysUser.setUpdateTime(externalUserInfo.getXiuGaiSJ()); | 
 |  |  |         sysUser.setUpdateBy(externalUserInfo.getXiuGaiRXM()); | 
 |  |  |         sysUser.setOrgid(externalUserInfo.getZuZhiJGID()); | 
 |  |  |  | 
 |  |  |         if (StringUtils.isNotEmpty(externalUserInfo.getShiJianDM()) && externalUserInfo.getShiJianDM().equals("3")) { | 
 |  |  |             sysUser.setStatus("1"); | 
 |  |  |         } | 
 |  |  |         sysUser.setBirthday(externalUserInfo.getChuShengRQ()); | 
 |  |  |         if (StringUtils.isNotEmpty(externalUserInfo.getShiJianDM()) && externalUserInfo.getShiJianDM().equals("1")) { | 
 |  |  |         if (ObjectUtils.isEmpty(sysUser1)) { | 
 |  |  |             BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); | 
 |  |  |             sysUser.setPassword(passwordEncoder.encode(defaultPwd)); | 
 |  |  |             int i = sysUserMapper.insertUser(sysUser); | 
 |  |  |             log.error("ServiceExternalServiceImpl---addDeptInfo是否新增成功:{}", i); | 
 |  |  |             log.info("ServiceExternalServiceImpl---addDeptInfo是否新增成功:{}", i); | 
 |  |  |         } else { | 
 |  |  |             sysUser.setUserId(sysUser1.getUserId()); | 
 |  |  |             int i = sysUserMapper.updateUser(sysUser); | 
 |  |  |             log.error("ServiceExternalServiceImpl---addDeptInfo是否修改成功:{}", i); | 
 |  |  |             log.info("ServiceExternalServiceImpl---addDeptInfo是否修改成功03:{}", i); | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     private SysUser getUser(List<SysUser> sysUserList) { | 
 |  |  |         SysUser sysUser = null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(sysUserList) && sysUserList.size() > 1) { | 
 |  |  |             // 按create_time降序排序,获取最新的记录 | 
 |  |  |             List<SysUser> sortedList = sysUserList.stream().sorted(Comparator.comparing(SysUser::getCreateTime).reversed()).collect(Collectors.toList()); | 
 |  |  |  | 
 |  |  |             // 第一条(最新的)赋值给sysUser1 | 
 |  |  |             sysUser = sortedList.get(0); | 
 |  |  |  | 
 |  |  |             // 获取需要删除的ID(从第二条开始) | 
 |  |  |             List<Long> idsToDelete = sortedList.stream().skip(1).map(SysUser::getUserId).collect(Collectors.toList()); | 
 |  |  |             Long[] idArray = idsToDelete.toArray(new Long[0]); | 
 |  |  |             // 批量删除其他记录 | 
 |  |  |             if (!idsToDelete.isEmpty()) { | 
 |  |  |                 sysUserMapper.deleteUserByIds(idArray); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return sysUser; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addOrganInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addOrganInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addOrganInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> ZuZhiJGXX = (Map<String, Object>) yeWuXX.get("ZuZhiJGXX"); | 
 |  |  |         ExternalOrganInfo externalOrganInfo = BeanUtil.mapToBean(ZuZhiJGXX, ExternalOrganInfo.class, true); | 
 |  |  |         if (ObjectUtils.isEmpty(externalOrganInfo)) { | 
 |  |  |             throw new BaseException("externalOrganInfo是空的,没有数据!!!"); | 
 |  |  |         } | 
 |  |  |         BaseOrganization baseOrganization = new BaseOrganization(); | 
 |  |  |         baseOrganization.setOrganizationID(externalOrganInfo.getZuZhiJGID()); | 
 |  |  |         baseOrganization.setOrganizationName(externalOrganInfo.getZuZhiJGMC()); | 
 |  |  | 
 |  |  |         baseOrganization.setOrgid(externalOrganInfo.getZuZhiJGID()); | 
 |  |  |         if (StringUtils.isNotEmpty(externalOrganInfo.getShiJianDM()) && externalOrganInfo.getShiJianDM().equals("1")) { | 
 |  |  |             int i = baseOrganizationMapper.insertBaseOrganization(baseOrganization); | 
 |  |  |             log.error("ServiceExternalServiceImpl---addOrganInfo是否新增成功:{}", i); | 
 |  |  |             log.info("ServiceExternalServiceImpl---addOrganInfo是否新增成功:{}", i); | 
 |  |  |         } else { | 
 |  |  |             int i = baseOrganizationMapper.updateBaseOrganization(baseOrganization); | 
 |  |  |             log.error("ServiceExternalServiceImpl---addOrganInfo是否修改成功:{}", i); | 
 |  |  |             log.info("ServiceExternalServiceImpl---addOrganInfo是否修改成功:{}", i); | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addCheckupReport(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addCheckupReport的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addCheckupReport的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> ZuZhiJGXX = (Map<String, Object>) yeWuXX.get("ZuZhiJGXX"); | 
 |  |  |         return false; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addInHospInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addInHospInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addInHospInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         List<HashMap<String, Object>> epai = (List<HashMap<String, Object>>) yeWuXX.get("DiZhiXXList"); | 
 |  |  |         List<HashMap<String, Object>> epli = (List<HashMap<String, Object>>) yeWuXX.get("LianXiRList"); | 
 |  |  |         List<HashMap<String, Object>> hospPatientDiagnoseInfos = (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList"); | 
 |  |  |         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX"); | 
 |  |  |         List<HashMap<String, Object>> epai = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("DiZhiXXList") : null; | 
 |  |  |         List<HashMap<String, Object>> epli = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("LianXiRList") : null; | 
 |  |  |         List<HashMap<String, Object>> hospPatientDiagnoseInfos = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList") : null; | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo = null; | 
 |  |  |         ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo = null; | 
 |  |  | 
 |  |  |             info.setGuanXiMC((String) map.get("GuanXiMC")); | 
 |  |  |             return info; | 
 |  |  |         }).collect(Collectors.toList()); | 
 |  |  |         externalInHospPatientInfo.setExternalInHospPatientLiaisonInfos(epli2); | 
 |  |  |  | 
 |  |  |         List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = hospPatientDiagnoseInfos.stream().map(map -> { | 
 |  |  |             ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo(); | 
 |  |  |             info.setZhenDuanID((String) map.get("ZhenDuanID")); | 
 |  |  |             info.setIcd10((String) map.get("Icd10")); | 
 |  |  |             info.setZhenDuanMC((String) map.get("ZhenDuanMC")); | 
 |  |  |             return info; | 
 |  |  |         }).collect(Collectors.toList()); | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean cancelInHospInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---cancelInHospInfo的新增的值为:{}", dataMap); | 
 |  |  |     public Boolean addInDeptInfo(Map dataMap) { | 
 |  |  |         log.info("ServiceExternalServiceImpl---addInDeptInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         Map<String, Object> RuKeXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("RuKeXX") : null; | 
 |  |  |  | 
 |  |  |         List<HashMap<String, Object>> epai = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) BingRenXX.get("DiZhiXXList") : null; | 
 |  |  |  | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         ExternalInDeptPatientInfo externalInDeptPatientInfo = BeanUtil.mapToBean(RuKeXX, ExternalInDeptPatientInfo.class, true); | 
 |  |  |         externalInHospPatientInfo.setZeRenHSID(externalInDeptPatientInfo.getZeRenHSID()); | 
 |  |  |         externalInHospPatientInfo.setZeRenHSXM(externalInDeptPatientInfo.getZeRenHSXM()); | 
 |  |  |         externalInHospPatientInfo.setZhuZhiYSID(externalInDeptPatientInfo.getZhuZhiYSID()); | 
 |  |  |         externalInHospPatientInfo.setZhuZhiYSXM(externalInDeptPatientInfo.getZhuZhiYSXM()); | 
 |  |  |         externalInHospPatientInfo.setRuYuanSJ(externalInDeptPatientInfo.getRuYuanSJ()); | 
 |  |  |         externalInHospPatientInfo.setJingGuanYSID(externalInDeptPatientInfo.getJingGuanYSID()); | 
 |  |  |         externalInHospPatientInfo.setJingGuanYSXM(externalInDeptPatientInfo.getJingGuanYSXM()); | 
 |  |  |         externalInHospPatientInfo.setLianXiDH(ObjectUtils.isNotEmpty(BingRenXX.get("LianXiDH")) ? BingRenXX.get("LianXiDH").toString() : null); | 
 |  |  |         externalInHospPatientInfo.setDangQianCWID(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianCWID")) ? BingRenXX.get("DangQianCWID").toString() : null); | 
 |  |  |         externalInHospPatientInfo.setDangQianCWMC(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianCWMC")) ? BingRenXX.get("DangQianCWMC").toString() : null); | 
 |  |  |  | 
 |  |  |         ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo = null; | 
 |  |  |         ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo = null; | 
 |  |  |         ExternalInHospPatientDiagnoseInfo externalInHospPatientDiagnoseInfo = null; | 
 |  |  |         List<ExternalInHospPatientAddrInfo> epai2 = epai.stream().map(map -> { | 
 |  |  |             ExternalInHospPatientAddrInfo info = new ExternalInHospPatientAddrInfo(); | 
 |  |  |             info.setDiZhiLX((String) map.get("DiZhiLX")); // 假设字段类型是 Integer | 
 |  |  |             info.setDiZhiXX((String) map.get("DiZhiXX")); | 
 |  |  |             info.setShengFenDM((String) map.get("ShengFenDM")); | 
 |  |  |             info.setShengFenMC((String) map.get("ShengFenMC")); | 
 |  |  |             info.setShiDiQDM((String) map.get("ShiDiQDM")); | 
 |  |  |             info.setShiDiQMC((String) map.get("ShiDiQMC")); | 
 |  |  |             info.setXianQuDM((String) map.get("XianQuDM")); | 
 |  |  |             info.setXianQuMC((String) map.get("XianQuMC")); | 
 |  |  |             info.setXiangZhenDM((String) map.get("XiangZhenDM")); | 
 |  |  |             info.setXiangZhenMC((String) map.get("XiangZhenMC")); | 
 |  |  |             info.setCunJiDM((String) map.get("CunJiDM")); | 
 |  |  |             info.setQiTaXX((String) map.get("QiTaXX")); | 
 |  |  |             info.setYouBian((String) map.get("YouBian")); | 
 |  |  |             return info; | 
 |  |  |         }).collect(Collectors.toList()); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         if (CollectionUtils.isNotEmpty(epai)) externalInHospPatientAddrInfo = epai2.get(0); | 
 |  |  |         //新增患者基本信息 | 
 |  |  |         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, null); | 
 |  |  |         //新增患者入院信息 | 
 |  |  |         Boolean aBoolean = addPadInhospInfo(externalInHospPatientInfo, patArchive, externalInHospPatientDiagnoseInfo); | 
 |  |  |         return aBoolean; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean cancelInHospInfo(Map dataMap) { | 
 |  |  |         log.info("ServiceExternalServiceImpl---cancelInHospInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         PatMedInhosp patMedInhosp = new PatMedInhosp(); | 
 |  |  |         patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); | 
 |  |  |         patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedInhosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); | 
 |  |  |         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); | 
 |  |  |         for (PatMedInhosp patMedInhosp1 : patMedInhospList) { | 
 |  |  |             String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid()); | 
 |  |  |             patMedInhosp1.setTagname(tagname); | 
 |  |  |         } | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) { | 
 |  |  |             Map<String, Object> JiuZhenXX = (Map<String, Object>) yeWuXX.get("JiuZhenXX"); | 
 |  |  |             Map<String, Object> JiuZhenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JiuZhenXX") : null; | 
 |  |  |             PatMedInhosp patMedInhosp1 = patMedInhospList.get(0); | 
 |  |  |             patMedInhosp1.setSchemestatus(3L); | 
 |  |  |             patMedInhosp1.setDelFlag("1"); | 
 |  |  |             patMedInhosp1.setOperator(JiuZhenXX.get("CaoZuoRXM").toString()); | 
 |  |  |             patMedInhosp1.setOperatorId(JiuZhenXX.get("CaoZuoRID").toString()); | 
 |  |  |             if (ObjectUtils.isNotEmpty(JiuZhenXX)) { | 
 |  |  |                 patMedInhosp1.setOperator(ObjectUtils.isNotEmpty(JiuZhenXX.get("CaoZuoRXM")) ? JiuZhenXX.get("CaoZuoRXM").toString() : null); | 
 |  |  |                 patMedInhosp1.setOperatorId(ObjectUtils.isNotEmpty(JiuZhenXX.get("CaoZuoRID")) ? JiuZhenXX.get("CaoZuoRID").toString() : null); | 
 |  |  |             } | 
 |  |  |             patMedInhosp1.setUpdateTime(new Date()); | 
 |  |  |             int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); | 
 |  |  |             if (i != 1) return false; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addOutHospInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addOutHospInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addOutHospInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX"); | 
 |  |  |         List<HashMap<String, Object>> epai = (List<HashMap<String, Object>>) BingRenXX.get("DiZhiXXList"); | 
 |  |  |         List<HashMap<String, Object>> epli = (List<HashMap<String, Object>>) yeWuXX.get("LianXiRList"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         Map<String, Object> ChuYuanJL = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ChuYuanJL") : null; | 
 |  |  |         List<HashMap<String, Object>> epai = ObjectUtils.isNotEmpty(BingRenXX) ? (List<HashMap<String, Object>>) BingRenXX.get("DiZhiXXList") : null; | 
 |  |  |         List<HashMap<String, Object>> epli = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("LianXiRList") : null; | 
 |  |  |         Map<String, Object> SuiFangJH = ObjectUtils.isNotEmpty(ChuYuanJL) ? (Map<String, Object>) ChuYuanJL.get("SuiFangJH") : null; | 
 |  |  |  | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo = null; | 
 |  |  |         ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo = null; | 
 |  |  |         List<ExternalInHospPatientAddrInfo> epai2 = null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(epai)) { | 
 |  |  |             epai2 = epai.stream().map(map -> { | 
 |  |  |                 ExternalInHospPatientAddrInfo info = new ExternalInHospPatientAddrInfo(); | 
 |  |  |                 info.setDiZhiLX((String) map.get("DiZhiLX")); // 假设字段类型是 Integer | 
 |  |  |                 info.setDiZhiXX((String) map.get("DiZhiXX")); | 
 |  |  |                 info.setShengFenDM((String) map.get("ShengFenDM")); | 
 |  |  |                 info.setShengFenMC((String) map.get("ShengFenMC")); | 
 |  |  |                 info.setShiDiQDM((String) map.get("ShiDiQDM")); | 
 |  |  |                 info.setShiDiQMC((String) map.get("ShiDiQMC")); | 
 |  |  |                 info.setXianQuDM((String) map.get("XianQuDM")); | 
 |  |  |                 info.setXianQuMC((String) map.get("XianQuMC")); | 
 |  |  |                 info.setXiangZhenDM((String) map.get("XiangZhenDM")); | 
 |  |  |                 info.setXiangZhenMC((String) map.get("XiangZhenMC")); | 
 |  |  |                 info.setCunJiDM((String) map.get("CunJiDM")); | 
 |  |  |                 info.setQiTaXX((String) map.get("QiTaXX")); | 
 |  |  |                 info.setYouBian((String) map.get("YouBian")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |         } | 
 |  |  |         List<ExternalInHospPatientLiaisonInfo> epli2 = null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(epli)) { | 
 |  |  |             epli2 = epli.stream().map(map -> { | 
 |  |  |                 ExternalInHospPatientLiaisonInfo info = new ExternalInHospPatientLiaisonInfo(); | 
 |  |  |                 info.setLianXiRXM((String) map.get("LianXiRXM")); | 
 |  |  |                 info.setLianXiRDH((String) map.get("LianXiRDH")); | 
 |  |  |                 info.setGuanXiDM((String) map.get("GuanXiDM")); | 
 |  |  |                 info.setGuanXiMC((String) map.get("GuanXiMC")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |         } | 
 |  |  |         if (CollectionUtils.isNotEmpty(epai)) externalInHospPatientAddrInfo = epai2.get(0); | 
 |  |  |         if (CollectionUtils.isNotEmpty(epli)) externalInHospPatientLiaisonInfo = epli2.get(0); | 
 |  |  |         //新增患者基本信息新增或修改 | 
 |  |  |         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         PatMedInhosp patMedInhosp = new PatMedInhosp(); | 
 |  |  |         patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedInhosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); | 
 |  |  |         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); | 
 |  |  |         for (PatMedInhosp patMedInhosp1 : patMedInhospList) { | 
 |  |  |             String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid()); | 
 |  |  |             patMedInhosp1.setTagname(tagname); | 
 |  |  |         } | 
 |  |  |         Map<String, Object> JiuZhenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JiuZhenXX") : null; | 
 |  |  |         PatMedInhosp patMedInhosp1 = new PatMedInhosp(); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) patMedInhosp1 = patMedInhospList.get(0); | 
 |  |  |         patMedInhosp1.setSchemestatus(2L); | 
 |  |  |         try { | 
 |  |  |             patMedInhosp1.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(JiuZhenXX.get("ChuYuanSJ").toString())); | 
 |  |  |         } catch (ParseException e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |         if (ObjectUtils.isNotEmpty(JiuZhenXX)) { | 
 |  |  |             patMedInhosp1.setOperator(ObjectUtils.isNotEmpty(JiuZhenXX.get("CaoZuoRXM")) ? JiuZhenXX.get("CaoZuoRXM").toString() : null); | 
 |  |  |             patMedInhosp1.setOperatorId(ObjectUtils.isNotEmpty(JiuZhenXX.get("CaoZuoRID")) ? JiuZhenXX.get("CaoZuoRID").toString() : null); | 
 |  |  |             patMedInhosp1.setDrname(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZhuZhiYSXM")) ? JiuZhenXX.get("ZhuZhiYSXM").toString() : null); | 
 |  |  |             patMedInhosp1.setDrcode(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZhuZhiYSID")) ? JiuZhenXX.get("ZhuZhiYSID").toString() : null); | 
 |  |  |             patMedInhosp1.setNurseName(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZeRenHSXM")) ? JiuZhenXX.get("ZeRenHSXM").toString() : null); | 
 |  |  |             patMedInhosp1.setNurseId(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZeRenHSID")) ? JiuZhenXX.get("ZeRenHSID").toString() : null); | 
 |  |  |             patMedInhosp1.setBedNo(ObjectUtils.isNotEmpty(JiuZhenXX.get("DangQianCWMC")) ? JiuZhenXX.get("DangQianCWMC").toString() : null); | 
 |  |  |         } | 
 |  |  |         patMedInhosp1.setUpdateTime(new Date()); | 
 |  |  |         patMedInhosp1.setTelcode(patArchive.getTelcode()); | 
 |  |  |         patMedInhosp1.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID()); | 
 |  |  |         patMedInhosp1.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC()); | 
 |  |  |         patMedInhosp1.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC()); | 
 |  |  |         patMedInhosp1.setDeptname(externalInHospPatientInfo.getDangQianKSMC()); | 
 |  |  |         patMedInhosp1.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID()); | 
 |  |  |         patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID()); | 
 |  |  |  | 
 |  |  |         if (ObjectUtils.isNotEmpty(SuiFangJH)) { | 
 |  |  |             patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null); | 
 |  |  |             if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) { | 
 |  |  |                 try { | 
 |  |  |                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                     patMedInhosp1.setFudate(simpleDateFormat.parse(SuiFangJH.get("SuiFangRQ").toString())); | 
 |  |  |                 } catch (ParseException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             patMedInhosp1.setFuperiod(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangZQJY")) ? SuiFangJH.get("SuiFangZQJY").toString() : null); | 
 |  |  |             patMedInhosp1.setFutypecode(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangFSDM")) ? SuiFangJH.get("SuiFangFSDM").toString() : null); | 
 |  |  |             patMedInhosp1.setFutypedesc(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangFSMC")) ? SuiFangJH.get("SuiFangFSMC").toString() : null); | 
 |  |  |             patMedInhosp1.setFuadvice(ObjectUtils.isNotEmpty(SuiFangJH.get("FuZhenZD")) ? SuiFangJH.get("FuZhenZD").toString() : null); | 
 |  |  |             patMedInhosp1.setFuspecialadvice(ObjectUtils.isNotEmpty(SuiFangJH.get("QiTaZKJBSF")) ? SuiFangJH.get("QiTaZKJBSF").toString() : null); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         List<HashMap<String, Object>> zhenDuanList = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList") : null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(zhenDuanList)) { | 
 |  |  |             List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = zhenDuanList.stream().map(map -> { | 
 |  |  |                 ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo(); | 
 |  |  |                 info.setZhenDuanID((String) map.get("ZhenDuanID")); | 
 |  |  |                 info.setZhenDuanMC((String) map.get("ZhenDuanMC")); | 
 |  |  |                 info.setIcd10((String) map.get("Icd10")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |             patMedInhosp1.setLeaveicd10code(hospPatientDiagnoseInfos2.get(0).getIcd10()); | 
 |  |  |             patMedInhosp1.setLeavediagname(hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |             //patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |             patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         patMedInhosp1.setInhospstate("1"); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) { | 
 |  |  |             patMedInhosp1.setUpdateTime(new Date()); | 
 |  |  |             patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { | 
 |  |  |                 //不需要长期任务随访 | 
 |  |  |                 patMedInhosp1.setFuflag("1"); | 
 |  |  |             } | 
 |  |  |             int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } else { | 
 |  |  |             if (ObjectUtils.isNotEmpty(BingRenXX)) { | 
 |  |  |                 patMedInhosp1.setHospitalname(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGMC")) ? BingRenXX.get("ZuZhiJGMC").toString() : null); | 
 |  |  |                 patMedInhosp1.setHospitalcode(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |                 patMedInhosp1.setLeavehospitaldistrictname(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQMC")) ? BingRenXX.get("DangQianBQMC").toString() : null); | 
 |  |  |                 patMedInhosp1.setLeavehospitaldistrictcode(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQID")) ? BingRenXX.get("DangQianBQID").toString() : null); | 
 |  |  |                 patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |                 patMedInhosp1.setPatno(ObjectUtils.isNotEmpty(BingRenXX.get("BingRenID")) ? BingRenXX.get("BingRenID").toString() : null); | 
 |  |  |                 patMedInhosp1.setInhospno(ObjectUtils.isNotEmpty(BingRenXX.get("BingAnHao")) ? BingRenXX.get("BingAnHao").toString() : null); | 
 |  |  |                 patMedInhosp1.setSerialnum(ObjectUtils.isNotEmpty(BingRenXX.get("JiuZhenYWID")) ? BingRenXX.get("JiuZhenYWID").toString() : null); | 
 |  |  |             } | 
 |  |  |             patMedInhosp1.setPatid(patArchive.getId()); | 
 |  |  |             patMedInhosp1.setPatname(patArchive.getName()); | 
 |  |  |  | 
 |  |  |             patMedInhosp1.setCreateTime(new Date()); | 
 |  |  |             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { | 
 |  |  |                 //不需要长期任务随访 | 
 |  |  |                 patMedInhosp1.setFuflag("1"); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addOutHospJLInfo(Map dataMap) { | 
 |  |  |         log.info("ServiceExternalServiceImpl---addOutHospJLInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         Map<String, Object> ChuYuanJL = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ChuYuanJL") : null; | 
 |  |  |         List<HashMap<String, Object>> epai = ObjectUtils.isNotEmpty(BingRenXX) ? (List<HashMap<String, Object>>) BingRenXX.get("DiZhiXXList") : null; | 
 |  |  |         List<HashMap<String, Object>> epli = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("LianXiRList") : null; | 
 |  |  |         Map<String, Object> SuiFangJH = ObjectUtils.isNotEmpty(ChuYuanJL) ? (Map<String, Object>) ChuYuanJL.get("SuiFangJH") : null; | 
 |  |  |  | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo = null; | 
 |  |  |         ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo = null; | 
 |  |  | 
 |  |  |         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo); | 
 |  |  |  | 
 |  |  |         PatMedInhosp patMedInhosp = new PatMedInhosp(); | 
 |  |  |         patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); | 
 |  |  |         patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedInhosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); | 
 |  |  |         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); | 
 |  |  |  | 
 |  |  |         Map<String, Object> JiuZhenXX = (Map<String, Object>) yeWuXX.get("JiuZhenXX"); | 
 |  |  |         for (PatMedInhosp patMedInhosp1 : patMedInhospList) { | 
 |  |  |             String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid()); | 
 |  |  |             patMedInhosp1.setTagname(tagname); | 
 |  |  |         } | 
 |  |  |         PatMedInhosp patMedInhosp1 = new PatMedInhosp(); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) patMedInhosp1 = patMedInhospList.get(0); | 
 |  |  |         patMedInhosp1.setSchemestatus(2L); | 
 |  |  |         try { | 
 |  |  |             patMedInhosp1.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(JiuZhenXX.get("ChuYuanSJ").toString())); | 
 |  |  |         } catch (ParseException e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |         patMedInhosp1.setOperator(JiuZhenXX.get("CaoZuoRXM").toString()); | 
 |  |  |         patMedInhosp1.setOperatorId(JiuZhenXX.get("CaoZuoRID").toString()); | 
 |  |  |         patMedInhosp1.setUpdateTime(new Date()); | 
 |  |  |         patMedInhosp1.setTelcode(patArchive.getTelcode()); | 
 |  |  |         patMedInhosp1.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID()); | 
 |  |  | 
 |  |  |         patMedInhosp1.setDeptname(externalInHospPatientInfo.getDangQianKSMC()); | 
 |  |  |         patMedInhosp1.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID()); | 
 |  |  |         patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID()); | 
 |  |  |         List<HashMap<String, Object>> zhenDuanList = (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList"); | 
 |  |  |         List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = zhenDuanList.stream().map(map -> { | 
 |  |  |             ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo(); | 
 |  |  |             info.setZhenDuanID((String) map.get("ZhenDuanID")); | 
 |  |  |             info.setZhenDuanMC((String) map.get("ZhenDuanMC")); | 
 |  |  |             return info; | 
 |  |  |         }).collect(Collectors.toList()); | 
 |  |  |         patMedInhosp1.setLeaveicd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeaveicd10code()) ? patMedInhosp1.getLeaveicd10code() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanID() : hospPatientDiagnoseInfos2.get(0).getZhenDuanID()); | 
 |  |  |         patMedInhosp1.setLeavediagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |         patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |         patMedInhosp1.setIcd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |  | 
 |  |  |         if (ObjectUtils.isNotEmpty(SuiFangJH)) { | 
 |  |  |             patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null); | 
 |  |  |             if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) { | 
 |  |  |                 try { | 
 |  |  |                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                     patMedInhosp1.setFudate(simpleDateFormat.parse(SuiFangJH.get("SuiFangRQ").toString())); | 
 |  |  |                 } catch (ParseException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             try { | 
 |  |  |                 if (!Objects.isNull(SuiFangJH.get("SuiFangRQ"))) | 
 |  |  |                     patMedInhosp1.setFudate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(SuiFangJH.get("SuiFangRQ").toString())); | 
 |  |  |             } catch (ParseException e) { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |             } | 
 |  |  |             patMedInhosp1.setFuperiod(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangZQJY")) ? SuiFangJH.get("SuiFangZQJY").toString() : null); | 
 |  |  |             patMedInhosp1.setFutypecode(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangFSDM")) ? SuiFangJH.get("SuiFangFSDM").toString() : null); | 
 |  |  |             patMedInhosp1.setFutypedesc(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangFSMC")) ? SuiFangJH.get("SuiFangFSMC").toString() : null); | 
 |  |  |             patMedInhosp1.setFuadvice(ObjectUtils.isNotEmpty(SuiFangJH.get("FuZhenZD")) ? SuiFangJH.get("FuZhenZD").toString() : null); | 
 |  |  |             patMedInhosp1.setFuspecialadvice(ObjectUtils.isNotEmpty(SuiFangJH.get("QiTaZKJBSF")) ? SuiFangJH.get("QiTaZKJBSF").toString() : null); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         List<HashMap<String, Object>> zhenDuanList = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList") : null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(zhenDuanList)) { | 
 |  |  |             List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = zhenDuanList.stream().map(map -> { | 
 |  |  |                 ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo(); | 
 |  |  |                 info.setZhenDuanID((String) map.get("ZhenDuanID")); | 
 |  |  |                 info.setZhenDuanMC((String) map.get("ZhenDuanMC")); | 
 |  |  |                 info.setIcd10((String) map.get("Icd10")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |             patMedInhosp1.setLeaveicd10code(hospPatientDiagnoseInfos2.get(0).getIcd10()); | 
 |  |  |             patMedInhosp1.setLeavediagname(hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |             //patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |             patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         patMedInhosp1.setInhospstate("1"); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) { | 
 |  |  |             patMedInhosp1.setUpdateTime(new Date()); | 
 |  |  |             patMedInhosp1.setOrgid(BingRenXX.get("ZuZhiJGID").toString()); | 
 |  |  |             patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { | 
 |  |  |                 //不需要长期任务随访 | 
 |  |  |                 patMedInhosp1.setFuflag("1"); | 
 |  |  |             } | 
 |  |  |             int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } else { | 
 |  |  |             patMedInhosp1.setHospitalname(BingRenXX.get("ZuZhiJGMC").toString()); | 
 |  |  |             patMedInhosp1.setHospitalcode(BingRenXX.get("ZuZhiJGID").toString()); | 
 |  |  |             patMedInhosp1.setLeavehospitaldistrictname(BingRenXX.get("DangQianBQMC").toString()); | 
 |  |  |             patMedInhosp1.setLeavehospitaldistrictcode(BingRenXX.get("DangQianBQID").toString()); | 
 |  |  |             if (ObjectUtils.isNotEmpty(BingRenXX)) { | 
 |  |  |                 patMedInhosp1.setHospitalname(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGMC")) ? BingRenXX.get("ZuZhiJGMC").toString() : null); | 
 |  |  |                 patMedInhosp1.setHospitalcode(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |                 patMedInhosp1.setLeavehospitaldistrictname(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQMC")) ? BingRenXX.get("DangQianBQMC").toString() : null); | 
 |  |  |                 patMedInhosp1.setLeavehospitaldistrictcode(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQID")) ? BingRenXX.get("DangQianBQID").toString() : null); | 
 |  |  |                 patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |                 patMedInhosp1.setPatno(ObjectUtils.isNotEmpty(BingRenXX.get("BingRenID")) ? BingRenXX.get("BingRenID").toString() : null); | 
 |  |  |                 patMedInhosp1.setInhospno(ObjectUtils.isNotEmpty(BingRenXX.get("BingAnHao")) ? BingRenXX.get("BingAnHao").toString() : null); | 
 |  |  |                 patMedInhosp1.setSerialnum(ObjectUtils.isNotEmpty(BingRenXX.get("JiuZhenYWID")) ? BingRenXX.get("JiuZhenYWID").toString() : null); | 
 |  |  |             } | 
 |  |  |             patMedInhosp1.setPatid(patArchive.getId()); | 
 |  |  |             patMedInhosp1.setPatname(patArchive.getName()); | 
 |  |  |             patMedInhosp1.setOrgid(BingRenXX.get("ZuZhiJGID").toString()); | 
 |  |  |             patMedInhosp1.setPatno(BingRenXX.get("BingRenID").toString()); | 
 |  |  |             patMedInhosp1.setInhospno(BingRenXX.get("ZhuYuanHao").toString()); | 
 |  |  |             patMedInhosp1.setSerialnum(BingRenXX.get("BingAnHao").toString()); | 
 |  |  |  | 
 |  |  |             patMedInhosp1.setCreateTime(new Date()); | 
 |  |  |             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { | 
 |  |  |                 //不需要长期任务随访 | 
 |  |  |                 patMedInhosp1.setFuflag("1"); | 
 |  |  |             } | 
 |  |  |             int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean cancelOutHospInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---cancelOutHospInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---cancelOutHospInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         PatMedInhosp patMedInhosp = new PatMedInhosp(); | 
 |  |  |         patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); | 
 |  |  |         patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedInhosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); | 
 |  |  |         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); | 
 |  |  |         for (PatMedInhosp patMedInhosp1 : patMedInhospList) { | 
 |  |  |             String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid()); | 
 |  |  |             patMedInhosp1.setTagname(tagname); | 
 |  |  |         } | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) { | 
 |  |  |             Map<String, Object> JiuZhenXX = (Map<String, Object>) yeWuXX.get("JiuZhenXX"); | 
 |  |  |             Map<String, Object> JiuZhenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JiuZhenXX") : null; | 
 |  |  |             PatMedInhosp patMedInhosp1 = patMedInhospList.get(0); | 
 |  |  |             patMedInhosp1.setSchemestatus(4L); | 
 |  |  |             patMedInhosp1.setOperator(JiuZhenXX.get("CaoZuoRXM").toString()); | 
 |  |  |             patMedInhosp1.setOperatorId(JiuZhenXX.get("CaoZuoRID").toString()); | 
 |  |  |             //需要将出院状态改成在院 | 
 |  |  |             patMedInhosp1.setInhospstate("0"); | 
 |  |  |             if (ObjectUtils.isNotEmpty(JiuZhenXX)) { | 
 |  |  |                 patMedInhosp1.setOperator(ObjectUtils.isNotEmpty(JiuZhenXX.get("CaoZuoRXM")) ? JiuZhenXX.get("CaoZuoRXM").toString() : null); | 
 |  |  |                 patMedInhosp1.setOperatorId(ObjectUtils.isNotEmpty(JiuZhenXX.get("CaoZuoRXM")) ? JiuZhenXX.get("CaoZuoRID").toString() : null); | 
 |  |  |             } | 
 |  |  |             patMedInhosp1.setUpdateTime(new Date()); | 
 |  |  |             int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); | 
 |  |  |  | 
 |  |  |             //取消出院,就不需要服务了,需要通过patid和sendstate=2或者sendstate=1去查询一下,service_subtask里是否有正在执行的任务,有的话,立即停了 | 
 |  |  |             ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO(); | 
 |  |  |             serviceSubtaskVO.setPatid(patMedInhosp1.getPatid()); | 
 |  |  |             serviceSubtaskVO.setSendstate(2L); | 
 |  |  |             List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); | 
 |  |  |             serviceSubtaskVO.setSendstate(1L); | 
 |  |  |             List<ServiceSubtask> serviceSubtaskList1 = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); | 
 |  |  |             if (CollectionUtils.isNotEmpty(serviceSubtaskList)) { | 
 |  |  |                 if (CollectionUtils.isNotEmpty(serviceSubtaskList1)) serviceSubtaskList.addAll(serviceSubtaskList1); | 
 |  |  |             } else { | 
 |  |  |                 if (CollectionUtils.isNotEmpty(serviceSubtaskList1)) serviceSubtaskList = serviceSubtaskList1; | 
 |  |  |             } | 
 |  |  |             //去redis中,查询是否有subid,有的话移除cache-exist | 
 |  |  |             if (CollectionUtils.isNotEmpty(serviceSubtaskList)) { | 
 |  |  |                 for (ServiceSubtask serviceSubtask : serviceSubtaskList) { | 
 |  |  |                     log.info("需要移除的subId为:{}", serviceSubtask.getId().toString()); | 
 |  |  |                     serviceSubtaskMapper.deleteServiceSubtaskById(serviceSubtask.getId()); | 
 |  |  |                     redisCache.removeElementFromList("cache-exist", serviceSubtask.getId().toString()); | 
 |  |  |                     redisCache.removeElementFromList("cache-0", serviceSubtask.getId().toString()); | 
 |  |  |                     redisCache.removeElementFromList("cache-1", serviceSubtask.getId().toString()); | 
 |  |  |                     redisCache.removeElementFromList("cache-2", serviceSubtask.getId().toString()); | 
 |  |  |                     redisCache.removeElementFromList("cache-3", serviceSubtask.getId().toString()); | 
 |  |  |                     redisCache.removeElementFromList("cache-4", serviceSubtask.getId().toString()); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addPreOutHospInfo(Map dataMap) { | 
 |  |  |         log.info("ServiceExternalServiceImpl---addPreOutHospInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         Map<String, Object> ChuYuanJL = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ChuYuanJL") : null; | 
 |  |  |         List<HashMap<String, Object>> epai = ObjectUtils.isNotEmpty(BingRenXX) ? (List<HashMap<String, Object>>) BingRenXX.get("DiZhiXXList") : null; | 
 |  |  |         List<HashMap<String, Object>> epli = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("LianXiRList") : null; | 
 |  |  |         Map<String, Object> SuiFangJH = ObjectUtils.isNotEmpty(ChuYuanJL) ? (Map<String, Object>) ChuYuanJL.get("SuiFangJH") : null; | 
 |  |  |  | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo = null; | 
 |  |  |         ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo = null; | 
 |  |  |         List<ExternalInHospPatientAddrInfo> epai2 = null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(epai)) { | 
 |  |  |             epai2 = epai.stream().map(map -> { | 
 |  |  |                 ExternalInHospPatientAddrInfo info = new ExternalInHospPatientAddrInfo(); | 
 |  |  |                 info.setDiZhiLX((String) map.get("DiZhiLX")); // 假设字段类型是 Integer | 
 |  |  |                 info.setDiZhiXX((String) map.get("DiZhiXX")); | 
 |  |  |                 info.setShengFenDM((String) map.get("ShengFenDM")); | 
 |  |  |                 info.setShengFenMC((String) map.get("ShengFenMC")); | 
 |  |  |                 info.setShiDiQDM((String) map.get("ShiDiQDM")); | 
 |  |  |                 info.setShiDiQMC((String) map.get("ShiDiQMC")); | 
 |  |  |                 info.setXianQuDM((String) map.get("XianQuDM")); | 
 |  |  |                 info.setXianQuMC((String) map.get("XianQuMC")); | 
 |  |  |                 info.setXiangZhenDM((String) map.get("XiangZhenDM")); | 
 |  |  |                 info.setXiangZhenMC((String) map.get("XiangZhenMC")); | 
 |  |  |                 info.setCunJiDM((String) map.get("CunJiDM")); | 
 |  |  |                 info.setQiTaXX((String) map.get("QiTaXX")); | 
 |  |  |                 info.setYouBian((String) map.get("YouBian")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |         } | 
 |  |  |         List<ExternalInHospPatientLiaisonInfo> epli2 = null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(epli)) { | 
 |  |  |             epli2 = epli.stream().map(map -> { | 
 |  |  |                 ExternalInHospPatientLiaisonInfo info = new ExternalInHospPatientLiaisonInfo(); | 
 |  |  |                 info.setLianXiRXM((String) map.get("LianXiRXM")); | 
 |  |  |                 info.setLianXiRDH((String) map.get("LianXiRDH")); | 
 |  |  |                 info.setGuanXiDM((String) map.get("GuanXiDM")); | 
 |  |  |                 info.setGuanXiMC((String) map.get("GuanXiMC")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |         } | 
 |  |  |         if (CollectionUtils.isNotEmpty(epai)) externalInHospPatientAddrInfo = epai2.get(0); | 
 |  |  |         if (CollectionUtils.isNotEmpty(epli)) externalInHospPatientLiaisonInfo = epli2.get(0); | 
 |  |  |         //新增患者基本信息新增或修改 | 
 |  |  |         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo); | 
 |  |  |  | 
 |  |  |         PatMedInhosp patMedInhosp = new PatMedInhosp(); | 
 |  |  |         patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedInhosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); | 
 |  |  |         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); | 
 |  |  |         for (PatMedInhosp patMedInhosp1 : patMedInhospList) { | 
 |  |  |             String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid()); | 
 |  |  |             patMedInhosp1.setTagname(tagname); | 
 |  |  |         } | 
 |  |  |         Map<String, Object> JiuZhenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JiuZhenXX") : null; | 
 |  |  |         PatMedInhosp patMedInhosp1 = new PatMedInhosp(); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) patMedInhosp1 = patMedInhospList.get(0); | 
 |  |  |         patMedInhosp1.setSchemestatus(2L); | 
 |  |  |         try { | 
 |  |  |             patMedInhosp1.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(JiuZhenXX.get("YuChuYSJ").toString())); | 
 |  |  |         } catch (ParseException e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |         if (ObjectUtils.isNotEmpty(JiuZhenXX)) { | 
 |  |  |             patMedInhosp1.setOperator(ObjectUtils.isNotEmpty(JiuZhenXX.get("CaoZuoRXM")) ? JiuZhenXX.get("CaoZuoRXM").toString() : null); | 
 |  |  |             patMedInhosp1.setOperatorId(ObjectUtils.isNotEmpty(JiuZhenXX.get("CaoZuoRID")) ? JiuZhenXX.get("CaoZuoRID").toString() : null); | 
 |  |  |             patMedInhosp1.setDrname(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZhuZhiYSXM")) ? JiuZhenXX.get("ZhuZhiYSXM").toString() : null); | 
 |  |  |             patMedInhosp1.setDrcode(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZhuZhiYSID")) ? JiuZhenXX.get("ZhuZhiYSID").toString() : null); | 
 |  |  |             patMedInhosp1.setNurseName(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZeRenHSXM")) ? JiuZhenXX.get("ZeRenHSXM").toString() : null); | 
 |  |  |             patMedInhosp1.setNurseId(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZeRenHSID")) ? JiuZhenXX.get("ZeRenHSID").toString() : null); | 
 |  |  |             patMedInhosp1.setBedNo(ObjectUtils.isNotEmpty(JiuZhenXX.get("DangQianCWMC")) ? JiuZhenXX.get("DangQianCWMC").toString() : null); | 
 |  |  |         } | 
 |  |  |         patMedInhosp1.setUpdateTime(new Date()); | 
 |  |  |         patMedInhosp1.setTelcode(patArchive.getTelcode()); | 
 |  |  |         patMedInhosp1.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID()); | 
 |  |  |         patMedInhosp1.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC()); | 
 |  |  |         patMedInhosp1.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC()); | 
 |  |  |         patMedInhosp1.setDeptname(externalInHospPatientInfo.getDangQianKSMC()); | 
 |  |  |         patMedInhosp1.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID()); | 
 |  |  |         patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID()); | 
 |  |  |  | 
 |  |  |         if (ObjectUtils.isNotEmpty(SuiFangJH)) { | 
 |  |  |             patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null); | 
 |  |  |             if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) { | 
 |  |  |                 try { | 
 |  |  |                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                     patMedInhosp1.setFudate(simpleDateFormat.parse(SuiFangJH.get("SuiFangRQ").toString())); | 
 |  |  |                 } catch (ParseException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             patMedInhosp1.setFuperiod(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangZQJY")) ? SuiFangJH.get("SuiFangZQJY").toString() : null); | 
 |  |  |             patMedInhosp1.setFutypecode(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangFSDM")) ? SuiFangJH.get("SuiFangFSDM").toString() : null); | 
 |  |  |             patMedInhosp1.setFutypedesc(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangFSMC")) ? SuiFangJH.get("SuiFangFSMC").toString() : null); | 
 |  |  |             patMedInhosp1.setFuadvice(ObjectUtils.isNotEmpty(SuiFangJH.get("FuZhenZD")) ? SuiFangJH.get("FuZhenZD").toString() : null); | 
 |  |  |             patMedInhosp1.setFuspecialadvice(ObjectUtils.isNotEmpty(SuiFangJH.get("QiTaZKJBSF")) ? SuiFangJH.get("QiTaZKJBSF").toString() : null); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         List<HashMap<String, Object>> zhenDuanList = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList") : null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(zhenDuanList)) { | 
 |  |  |             List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = zhenDuanList.stream().map(map -> { | 
 |  |  |                 ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo(); | 
 |  |  |                 info.setZhenDuanID((String) map.get("ZhenDuanID")); | 
 |  |  |                 info.setZhenDuanMC((String) map.get("ZhenDuanMC")); | 
 |  |  |                 info.setIcd10((String) map.get("Icd10")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |             patMedInhosp1.setLeaveicd10code(hospPatientDiagnoseInfos2.get(0).getIcd10()); | 
 |  |  |             patMedInhosp1.setLeavediagname(hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |             //patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |             patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         patMedInhosp1.setInhospstate("3"); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) { | 
 |  |  |             patMedInhosp1.setUpdateTime(new Date()); | 
 |  |  |             patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |             int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } else { | 
 |  |  |             if (ObjectUtils.isNotEmpty(BingRenXX)) { | 
 |  |  |                 patMedInhosp1.setHospitalname(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGMC")) ? BingRenXX.get("ZuZhiJGMC").toString() : null); | 
 |  |  |                 patMedInhosp1.setHospitalcode(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |                 patMedInhosp1.setLeavehospitaldistrictname(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQMC")) ? BingRenXX.get("DangQianBQMC").toString() : null); | 
 |  |  |                 patMedInhosp1.setLeavehospitaldistrictcode(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQID")) ? BingRenXX.get("DangQianBQID").toString() : null); | 
 |  |  |                 patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); | 
 |  |  |                 patMedInhosp1.setPatno(ObjectUtils.isNotEmpty(BingRenXX.get("BingRenID")) ? BingRenXX.get("BingRenID").toString() : null); | 
 |  |  |                 patMedInhosp1.setInhospno(ObjectUtils.isNotEmpty(BingRenXX.get("BingAnHao")) ? BingRenXX.get("BingAnHao").toString() : null); | 
 |  |  |                 patMedInhosp1.setSerialnum(ObjectUtils.isNotEmpty(BingRenXX.get("JiuZhenYWID")) ? BingRenXX.get("JiuZhenYWID").toString() : null); | 
 |  |  |             } | 
 |  |  |             patMedInhosp1.setPatid(patArchive.getId()); | 
 |  |  |             patMedInhosp1.setPatname(patArchive.getName()); | 
 |  |  |  | 
 |  |  |             patMedInhosp1.setCreateTime(new Date()); | 
 |  |  |             int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addFinshJZInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addFinshJZInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX"); | 
 |  |  |         Map<String, Object> JiuZhenXX = (Map<String, Object>) yeWuXX.get("JiuZhenXX"); | 
 |  |  |         List<HashMap<String, Object>> ZhenDuanList = (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList"); | 
 |  |  |         List<HashMap<String, Object>> externalWZInfos = (List<HashMap<String, Object>>) yeWuXX.get("WenZhenList"); | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         ExternalJZInfo externalJZInfo = BeanUtil.mapToBean(JiuZhenXX, ExternalJZInfo.class, true); | 
 |  |  |         List<ExternalDiagnosisInfo> externalDiagnosisInfoList = ZhenDuanList.stream().map(map -> { | 
 |  |  |             ExternalDiagnosisInfo info = new ExternalDiagnosisInfo(); | 
 |  |  |             info.setZhenDuanYSID((String) map.get("ZhenDuanYSID")); | 
 |  |  |             info.setZhenDuanYSXM((String) map.get("ZhenDuanYSXM")); | 
 |  |  |             info.setZhenDuanID((String) map.get("ZhenDuanID")); | 
 |  |  |             info.setZhenDuanMC((String) map.get("ZhenDuanMC")); | 
 |  |  |             info.setZhenDuanLBDM((String) map.get("ZhenDuanLBDM")); | 
 |  |  |             info.setZhenDuanLBMC((String) map.get("ZhenDuanLBMC")); | 
 |  |  |             return info; | 
 |  |  |         }).collect(Collectors.toList()); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addFinshJZInfo的新增的值为:{}", dataMap); | 
 |  |  |         //先对表进行维护 | 
 |  |  |         tableMaintenance(); | 
 |  |  |  | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou"); | 
 |  |  |         String FaSongJGID = ObjectUtils.isNotEmpty(XiaoXiTou.get("FaSongJGID")) ? XiaoXiTou.get("FaSongJGID").toString() : null; | 
 |  |  |         String FaSongJGMC = ObjectUtils.isNotEmpty(XiaoXiTou.get("FaSongJGMC")) ? XiaoXiTou.get("FaSongJGMC").toString() : null; | 
 |  |  |  | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         Map<String, Object> JiuZhenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JiuZhenXX") : null; | 
 |  |  |         List<HashMap<String, Object>> ZhenDuanList = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList") : null; | 
 |  |  |         List<HashMap<String, Object>> externalWZInfos = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("WenZhenList") : null; | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         //病人信息里没有组织机构ID | 
 |  |  |         externalInHospPatientInfo.setZuZhiJGID(FaSongJGID); | 
 |  |  |  | 
 |  |  |         ExternalJZInfo externalJZInfo = BeanUtil.mapToBean(JiuZhenXX, ExternalJZInfo.class, true); | 
 |  |  |         List<ExternalDiagnosisInfo> externalDiagnosisInfoList = null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(ZhenDuanList)) { | 
 |  |  |             externalDiagnosisInfoList = ZhenDuanList.stream().map(map -> { | 
 |  |  |                 ExternalDiagnosisInfo info = new ExternalDiagnosisInfo(); | 
 |  |  |                 info.setZhenDuanYSID((String) map.get("ZhenDuanYSID")); | 
 |  |  |                 info.setZhenDuanYSXM((String) map.get("ZhenDuanYSXM")); | 
 |  |  |                 info.setZhenDuanID((String) map.get("ZhenDuanID")); | 
 |  |  |                 info.setZhenDuanMC((String) map.get("ZhenDuanMC")); | 
 |  |  |                 info.setZhenDuanLBDM((String) map.get("ZhenDuanLBDM")); | 
 |  |  |                 info.setZhenDuanLBMC((String) map.get("ZhenDuanLBMC")); | 
 |  |  |                 info.setIcd10((String) map.get("Icd10")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |         } | 
 |  |  |         List<ExternalWZInfo> ExternalWZInfoList = externalWZInfos.stream().map(map -> { | 
 |  |  |             ExternalWZInfo info = new ExternalWZInfo(); | 
 |  |  |             info.setWenZhenLXMC((String) map.get("WenZhenLXMC")); | 
 |  |  | 
 |  |  |  | 
 |  |  |         PatMedOuthosp patMedOuthosp = new PatMedOuthosp(); | 
 |  |  |         patMedOuthosp.setOuthospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedOuthosp.setSerialnum(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedOuthosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); | 
 |  |  |         List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp); | 
 |  |  |         for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) { | 
 |  |  |             PatArchive pa = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid()); | 
 |  |  |             if (patArchive.getBirthdate() != null) { | 
 |  |  |                 Map<String, String> map = calculateAge(pa.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now()); | 
 |  |  |                 pa.setAge(ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null); | 
 |  |  |                 pa.setAgeUnit(map.get("ageUnit")); | 
 |  |  |                 pa.setAge2(ObjectUtils.isNotEmpty(map.get("age2")) ? Long.valueOf(map.get("age2")) : null); | 
 |  |  |                 pa.setAgeUnit2(map.get("ageUnit2")); | 
 |  |  |                 patMedOuthosp1.setAge(pa.getAge() + pa.getAgeUnit() + pa.getAge2() + pa.getAgeUnit2()); | 
 |  |  |                 patMedOuthosp1.setTelcode(patArchive.getTelcode()); | 
 |  |  |                 patMedOuthosp1.setIdcardno(patArchive.getIdcardno()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         patMedOuthosp.setPatid(patArchive.getId()); | 
 |  |  |         patMedOuthosp.setPatno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedOuthosp.setPatname(externalInHospPatientInfo.getXingMing()); | 
 |  |  |         patMedOuthosp.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC()); | 
 |  |  |         patMedOuthosp.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |         patMedOuthosp.setDeptname(externalJZInfo.getJiuZhenKSMC()); | 
 |  |  |         patMedOuthosp.setDeptcode(externalJZInfo.getJiuZhenKSID()); | 
 |  |  |         patMedOuthosp.setAdmitdate(externalJZInfo.getJiuZhenRQ()); | 
 |  |  |  | 
 |  |  |         Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou"); | 
 |  |  |         String FaSongJGID = XiaoXiTou.get("FaSongJGID").toString(); | 
 |  |  |         patMedOuthosp.setOrgid(FaSongJGID); | 
 |  |  |         patMedOuthosp.setHospitalname(FaSongJGMC); | 
 |  |  |         patMedOuthosp.setIdcardno(patArchive.getIdcardno()); | 
 |  |  |  | 
 |  |  |         //这个需要等HIS那边告诉取哪个字段,现在还是不对的 | 
 |  |  |         patMedOuthosp.setFudate(externalJZInfo.getSfrq()); | 
 |  |  |  | 
 |  |  |         for (ExternalDiagnosisInfo externalDiagnosisInfo : externalDiagnosisInfoList) { | 
 |  |  |             if (externalDiagnosisInfo.getZhenDuanLBMC().equals("主诊断")) { | 
 |  |  |                 patMedOuthosp.setDiagname(externalDiagnosisInfo.getZhenDuanMC()); | 
 |  |  |                 patMedOuthosp.setIcd10code(externalDiagnosisInfo.getZhenDuanID()); | 
 |  |  |                 patMedOuthosp.setDrcode(externalDiagnosisInfo.getZhenDuanYSID()); | 
 |  |  |                 patMedOuthosp.setDrname(externalDiagnosisInfo.getZhenDuanYSXM()); | 
 |  |  |                 patMedOuthosp.setIcd10code(externalDiagnosisInfo.getIcd10()); | 
 |  |  |                 patMedOuthosp.setFuflag("0"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         for (ExternalWZInfo externalWZInfo : ExternalWZInfoList) { | 
 |  |  | 
 |  |  |                 patMedOuthosp.setMainsuit(externalWZInfo.getNeiRong()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         int i = patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp); | 
 |  |  |         int i = 0; | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedOuthosps)) { | 
 |  |  |             patMedOuthosp.setId(patMedOuthosps.get(0).getId()); | 
 |  |  |             patMedOuthosp.setUpdateTime(new Date()); | 
 |  |  |             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedOuthosp.getOrgid())) { | 
 |  |  |                 //不需要长期任务随访,由医生自己去随访(丽水中医院首次提出) | 
 |  |  |                 patMedOuthosp.setFuflag("1"); | 
 |  |  |             } | 
 |  |  |             i = patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp); | 
 |  |  |         } else { | 
 |  |  |             patMedOuthosp.setCreateTime(new Date()); | 
 |  |  |             patMedOuthosp.setUpdateTime(new Date()); | 
 |  |  |             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedOuthosp.getOrgid())) { | 
 |  |  |                 //不需要长期任务随访 | 
 |  |  |                 patMedOuthosp.setFuflag("1"); | 
 |  |  |             } | 
 |  |  |             i = patMedOuthospMapper.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 | 
 |  |  |     public Boolean addDiseaseInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addDiseaseInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addDiseaseInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> JiBing = (Map<String, Object>) yeWuXX.get("JiBingMLXX"); | 
 |  |  |         Map<String, Object> JiBing = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JiBingMLXX") : null; | 
 |  |  |         ExternalDiseaseInfo externalDiseaseInfo = BeanUtil.mapToBean(JiBing, ExternalDiseaseInfo.class, true); | 
 |  |  |         Map XiaoXiTou = (Map) dataMap.get("XiaoXiTou"); | 
 |  |  |         String FaSongJGID = XiaoXiTou.get("FaSongJGID").toString(); | 
 |  |  |         String FaSongJGID = ObjectUtils.isNotEmpty(XiaoXiTou) && ObjectUtils.isNotEmpty(XiaoXiTou.get("FaSongJGID")) ? XiaoXiTou.get("FaSongJGID").toString() : null; | 
 |  |  |         Icd10 icd10 = new Icd10(); | 
 |  |  |         icd10.setIcdcode(externalDiseaseInfo.getIcD10()); | 
 |  |  |         icd10.setDelFlag("0"); | 
 |  |  | 
 |  |  |         icd10.setGuid(externalDiseaseInfo.getZuZhiJGID()); | 
 |  |  |         icd10.setLastflag(externalDiseaseInfo.getMOJIBZ()); | 
 |  |  |         icd10.setChimedflag("" + externalDiseaseInfo.getZhongYiZDBZ()); | 
 |  |  |         icd10.setUpdateTime(new Date()); | 
 |  |  |         if (CollectionUtils.isNotEmpty(icd10s)) { | 
 |  |  |             icd10.setUpdateTime(new Date()); | 
 |  |  |             icd10.setIcdid(icd10s.get(0).getIcdid()); | 
 |  |  |             icd10Mapper.updateIcd10(icd10); | 
 |  |  |         } else { | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addWardAreaInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addWardAreaInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addWardAreaInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> bqxx = (Map<String, Object>) yeWuXX.get("BingQuXX"); | 
 |  |  |         Map<String, Object> bqxx = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingQuXX") : null; | 
 |  |  |         ExternalWardArea externalWardArea = BeanUtil.mapToBean(bqxx, ExternalWardArea.class, true); | 
 |  |  |         SysDept sysDept = new SysDept(); | 
 |  |  |         sysDept.setGuid(externalWardArea.getZuZhiJGID()); | 
 |  |  |         sysDept.setOrgid(externalWardArea.getZuZhiJGID()); | 
 |  |  |         sysDept.setHisDeptId(externalWardArea.getBingQuID()); | 
 |  |  |  | 
 |  |  |         sysDept.setDeptName(externalWardArea.getBingQuMC()); | 
 |  |  | 
 |  |  |         sysDept.setDeptCode(externalWardArea.getBingQuID()); | 
 |  |  |         sysDept.setCreateBy(externalWardArea.getChuangJianRXM()); | 
 |  |  |         sysDept.setType(externalWardArea.getBingQuLXDM()); | 
 |  |  |         sysDept.setCreateTime(externalWardArea.getCreateTime()); | 
 |  |  |         sysDept.setUpdateTime(externalWardArea.getUpdateTime()); | 
 |  |  |         sysDept.setUpdateBy(externalWardArea.getUpdateBy()); | 
 |  |  |         if (StringUtils.isNotEmpty(externalWardArea.getShiJianDM()) && externalWardArea.getShiJianDM().equals("3")) { | 
 |  |  |             sysDept.setStatus("1"); | 
 |  |  |         } | 
 |  |  |         if (StringUtils.isNotEmpty(externalWardArea.getShiJianDM()) && externalWardArea.getShiJianDM().equals("1")) { | 
 |  |  |             sysDept.setCreateTime(externalWardArea.getCreateTime()); | 
 |  |  |             int i = sysDeptMapper.insertDept(sysDept); | 
 |  |  |             log.error("ServiceExternalServiceImpl---addWardAreaInfo是否新增成功:{}", i); | 
 |  |  |             log.info("ServiceExternalServiceImpl---addWardAreaInfo是否新增成功:{}", i); | 
 |  |  |         } else { | 
 |  |  |             int i = sysDeptMapper.updateDept(sysDept); | 
 |  |  |             log.error("ServiceExternalServiceImpl---addWardAreaInfo是否修改成功:{}", i); | 
 |  |  |             log.info("ServiceExternalServiceImpl---addWardAreaInfo是否修改成功:{}", i); | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addMedicalTeam(Map dataMap) { | 
 |  |  |         log.info("ServiceExternalServiceImpl---addMedicalTeam的新增的值为:{}", dataMap); | 
 |  |  |  | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Boolean addOperationInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addOperationInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addOperationInfo的新增的值为:{}", dataMap); | 
 |  |  |  | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |  | 
 |  |  |         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, null, null); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         //手术信息新增 | 
 |  |  |         Map<String, Object> ssxx = (Map<String, Object>) yeWuXX.get("ShouShuSQ"); | 
 |  |  |         Map<String, Object> ssxx = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ShouShuSQ") : null; | 
 |  |  |         //手术更新 | 
 |  |  |         Map<String, Object> ssgx = (Map<String, Object>) yeWuXX.get("ShouShuGX"); | 
 |  |  |         Map<String, Object> ssgx = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ShouShuGX") : null; | 
 |  |  |         //手术撤销 | 
 |  |  |         Map<String, Object> sscx = (Map<String, Object>) yeWuXX.get("ShouShuCX"); | 
 |  |  |         Map<String, Object> sscx = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ShouShuCX") : null; | 
 |  |  |         ExternalOperationInfo externalOperationInfo = null; | 
 |  |  |         if (ObjectUtils.isNotEmpty(ssxx)) | 
 |  |  |             externalOperationInfo = BeanUtil.mapToBean(ssxx, ExternalOperationInfo.class, true); | 
 |  |  | 
 |  |  |         patMedOperation.setPatid(patArchive.getId()); | 
 |  |  |         patMedOperation.setPatcode(externalInHospPatientInfo.getBingRenID()); | 
 |  |  |         patMedOperation.setPaname(externalInHospPatientInfo.getXingMing()); | 
 |  |  | //        patMedOperation.setOpreqid(externalOperationInfo.getShenQingDID()); | 
 |  |  |         patMedOperation.setOpreqcode(externalOperationInfo.getShenQingDID()); | 
 |  |  |         //查询一下,该患者是否已经有这些数据 | 
 |  |  |         List<PatMedOperation> patMedOperations = patMedOperationMapper.selectPatMedOperationList(patMedOperation); | 
 |  |  |  | 
 |  |  |         patMedOperation.setOpsstatus(null); | 
 |  |  |         patMedOperation.setOptypecode(externalOperationInfo.getShouShuLBDM()); | 
 |  |  |         patMedOperation.setOptypename(externalOperationInfo.getShouShuLBMC()); | 
 |  |  |         patMedOperation.setOperatortime(externalOperationInfo.getYaoQiuSJ()); | 
 |  |  |         patMedOperation.setOpreqtime(externalOperationInfo.getShenQingSJ()); | 
 |  |  |         patMedOperation.setReqdoccode(externalOperationInfo.getShenQingYSID()); | 
 |  |  |         patMedOperation.setReqdocname(externalOperationInfo.getShenQingYSXM()); | 
 |  |  |         patMedOperation.setReqdeptcode(externalOperationInfo.getShenQingKSID()); | 
 |  |  |         patMedOperation.setReqdeptname(externalOperationInfo.getShenQingKSMC()); | 
 |  |  |         patMedOperation.setReqloccode(externalOperationInfo.getShouShuKSID()); | 
 |  |  |         patMedOperation.setReqlocname(externalOperationInfo.getShouShuKSMC()); | 
 |  |  |         patMedOperation.setSurgeoncode(externalOperationInfo.getZhuDaoYSID()); | 
 |  |  |         patMedOperation.setSurgeonname(externalOperationInfo.getSanZhuYSXM()); | 
 |  |  |         patMedOperation.setFirasscode(externalOperationInfo.getYiZhuID()); | 
 |  |  |         patMedOperation.setFirassname(externalOperationInfo.getYiZhuMC()); | 
 |  |  |         patMedOperation.setSecasscode(externalOperationInfo.getErZhuYSID()); | 
 |  |  |         patMedOperation.setSecassname(externalOperationInfo.getErZhuYSXM()); | 
 |  |  |         patMedOperation.setThrasscode(externalOperationInfo.getSanZhuYSID()); | 
 |  |  |         patMedOperation.setThrassname(externalOperationInfo.getSanZhuYSXM()); | 
 |  |  |         if (ObjectUtils.isNotEmpty(externalOperationInfo)) { | 
 |  |  |             patMedOperation.setOptypecode(externalOperationInfo.getShouShuLBDM()); | 
 |  |  |             patMedOperation.setOptypename(externalOperationInfo.getShouShuLBMC()); | 
 |  |  |             patMedOperation.setOperatortime(externalOperationInfo.getYaoQiuSJ()); | 
 |  |  |             patMedOperation.setOpreqtime(externalOperationInfo.getShenQingSJ()); | 
 |  |  |             patMedOperation.setReqdoccode(externalOperationInfo.getShenQingYSID()); | 
 |  |  |             patMedOperation.setReqdocname(externalOperationInfo.getShenQingYSXM()); | 
 |  |  |             patMedOperation.setReqdeptcode(externalOperationInfo.getShenQingKSID()); | 
 |  |  |             patMedOperation.setReqdeptname(externalOperationInfo.getShenQingKSMC()); | 
 |  |  |             patMedOperation.setReqloccode(externalOperationInfo.getShouShuKSID()); | 
 |  |  |             patMedOperation.setReqlocname(externalOperationInfo.getShouShuKSMC()); | 
 |  |  |             patMedOperation.setSurgeoncode(externalOperationInfo.getZhuDaoYSID()); | 
 |  |  |             patMedOperation.setSurgeonname(externalOperationInfo.getSanZhuYSXM()); | 
 |  |  |             patMedOperation.setFirasscode(externalOperationInfo.getYiZhuID()); | 
 |  |  |             patMedOperation.setFirassname(externalOperationInfo.getYiZhuMC()); | 
 |  |  |             patMedOperation.setSecasscode(externalOperationInfo.getErZhuYSID()); | 
 |  |  |             patMedOperation.setSecassname(externalOperationInfo.getErZhuYSXM()); | 
 |  |  |             patMedOperation.setThrasscode(externalOperationInfo.getSanZhuYSID()); | 
 |  |  |             patMedOperation.setThrassname(externalOperationInfo.getSanZhuYSXM()); | 
 |  |  |             patMedOperation.setDeptid(externalOperationInfo.getShouShuKSID()); | 
 |  |  |             patMedOperation.setDeptcode(externalOperationInfo.getShouShuKSID()); | 
 |  |  |             patMedOperation.setDeptname(externalOperationInfo.getShouShuKSMC()); | 
 |  |  |             patMedOperation.setDrcode(externalOperationInfo.getZhuDaoYSID()); | 
 |  |  |             patMedOperation.setDrname(externalOperationInfo.getZhuDaoYSXM()); | 
 |  |  |         } | 
 |  |  |         patMedOperation.setCanceltime(null); | 
 |  |  |         patMedOperation.setCancelreason(null); | 
 |  |  |         patMedOperation.setCancelcode(null); | 
 |  |  | 
 |  |  |         patMedOperation.setDelFlag("0"); | 
 |  |  |         patMedOperation.setIsupload(null); | 
 |  |  |         patMedOperation.setUploadTime(null); | 
 |  |  |         patMedOperation.setOrgid(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |         patMedOperation.setInhospstate(null); | 
 |  |  |         patMedOperation.setPatno(externalInHospPatientInfo.getBingRenID()); | 
 |  |  |         patMedOperation.setPatname(externalInHospPatientInfo.getXingMing()); | 
 |  |  |         patMedOperation.setVisitid(null); | 
 |  |  |         patMedOperation.setSerialnum(externalInHospPatientInfo.getZhuYuanHao()); | 
 |  |  |         patMedOperation.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); | 
 |  |  |         patMedOperation.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC()); | 
 |  |  |         patMedOperation.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |         patMedOperation.setDeptid(externalOperationInfo.getShouShuKSID()); | 
 |  |  |         patMedOperation.setDeptcode(externalOperationInfo.getShouShuKSID()); | 
 |  |  |         patMedOperation.setDeptname(externalOperationInfo.getShouShuKSMC()); | 
 |  |  |         patMedOperation.setInhospstate(null); | 
 |  |  |         if (ObjectUtils.isNotEmpty(externalInHospPatientInfo)) { | 
 |  |  |             patMedOperation.setPatno(externalInHospPatientInfo.getBingRenID()); | 
 |  |  |             patMedOperation.setPatname(externalInHospPatientInfo.getXingMing()); | 
 |  |  |             patMedOperation.setOrgid(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |             patMedOperation.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); | 
 |  |  |             patMedOperation.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |             patMedOperation.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC()); | 
 |  |  |             patMedOperation.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |         } | 
 |  |  |         patMedOperation.setHospitaldistrictcode(null); | 
 |  |  |         patMedOperation.setHospitaldistrictname(null); | 
 |  |  |         patMedOperation.setRoomno(null); | 
 |  |  |         patMedOperation.setBedNo(null); | 
 |  |  |         patMedOperation.setDrcode(externalOperationInfo.getZhuDaoYSID()); | 
 |  |  |         patMedOperation.setDrname(externalOperationInfo.getZhuDaoYSXM()); | 
 |  |  |  | 
 |  |  |         patMedOperation.setNurseId(null); | 
 |  |  |         patMedOperation.setNurseName(null); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedOperations)) { | 
 |  |  | 
 |  |  |                 patMedOperation.setDelFlag("1"); | 
 |  |  |                 //同时去查询,是否在subtask中生成任务,如果生成出得立马删除 | 
 |  |  |             } | 
 |  |  |             patMedOperation.setUpdateTime(new Date()); | 
 |  |  |             patMedOperationMapper.updatePatMedOperation(patMedOperation); | 
 |  |  |         } else patMedOperationMapper.insertPatMedOperation(patMedOperation); | 
 |  |  |         log.error("-----patMedOperation的主键id为:{}", patMedOperation.getId()); | 
 |  |  |         } else { | 
 |  |  |             patMedOperation.setCreateTime(new Date()); | 
 |  |  |             patMedOperationMapper.insertPatMedOperation(patMedOperation); | 
 |  |  |         } | 
 |  |  |         log.info("-----patMedOperation的主键id为:{}", patMedOperation.getId()); | 
 |  |  |  | 
 |  |  |         if (ObjectUtils.isNotEmpty(ssxx)) { | 
 |  |  |             Map<String, Object> ShouShuMXList = (Map<String, Object>) ssxx.get("ShouShuMXList"); | 
 |  |  |             List<ExternalOperationDetail> externalOperationDetails = BeanUtil.mapToBean(ShouShuMXList, List.class, true); | 
 |  |  |             List<HashMap<String, Object>> ShouShuMXList = (List<HashMap<String, Object>>) ssxx.get("ShouShuMXList"); | 
 |  |  |  | 
 |  |  |             List<ExternalOperationDetail> externalOperationDetails = ObjectUtils.isNotEmpty(ShouShuMXList) ? ShouShuMXList.stream().map(map -> { | 
 |  |  |                 ExternalOperationDetail info = new ExternalOperationDetail(); | 
 |  |  |                 info.setShouShuMCID((String) map.get("ShouShuMCID")); | 
 |  |  |                 info.setShouShuMC((String) map.get("ShouShuMC")); | 
 |  |  |                 info.setZhuShouSBZ(ObjectUtils.isNotEmpty(map.get("ZhuShouSBZ")) ? map.get("ZhuShouSBZ").toString() : null); | 
 |  |  |                 info.setQieKouLBDM((String) map.get("QieKouLBDM")); | 
 |  |  |                 info.setQieKouLBMC((String) map.get("QieKouLBMC")); | 
 |  |  |                 info.setShouShuJBDM((String) map.get("ShouShuJBDM")); | 
 |  |  |                 info.setShouShuJBMC((String) map.get("ShouShuJBMC")); | 
 |  |  |                 info.setShouShuBW((String) map.get("ShouShuBW")); | 
 |  |  |                 info.setBiaoZhunBM((String) map.get("BiaoZhunBM")); | 
 |  |  |                 info.setShouShuMCQZ((String) map.get("ShouShuMCQZ")); | 
 |  |  |                 info.setShouShuMCHZ((String) map.get("ShouShuMCHZ")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()) : null; | 
 |  |  |  | 
 |  |  |             //addMianTableFalg是否需要将主手术的信息放到PatMedOperation表中(只有第一个主手术信息需要放,后面的都不需要放了,也就是说,第一个放完后,就要把这个flag改成false) | 
 |  |  |             Boolean addMianTableFalg = true; | 
 |  |  |             for (ExternalOperationDetail externalOperationDetail : externalOperationDetails) { | 
 |  |  | 
 |  |  |                     patMedOperation.setOpcode(externalOperationDetail.getShouShuMCID()); | 
 |  |  |                     patMedOperation.setOpdesc(externalOperationDetail.getShouShuMC()); | 
 |  |  | //                    patMedOperation.setOpid(externalOperationDetail.getShouShuJBDM()); | 
 |  |  |                     patMedOperation.setUpdateTime(new Date()); | 
 |  |  |                     patMedOperationMapper.updatePatMedOperation(patMedOperation); | 
 |  |  |                     addMianTableFalg = false; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 patMedOperationItem.setCreateTime(new Date()); | 
 |  |  |                 patMedOperationItemMapper.insertPatMedOperationItem(patMedOperationItem); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  | 
 |  |  |  | 
 |  |  |     //新增患者基本信息 | 
 |  |  |     private PatArchive addPatArchive(ExternalInHospPatientInfo externalInHospPatientInfo, ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo, ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo) { | 
 |  |  |         Date parse = null; | 
 |  |  |         String chuShengRQ = externalInHospPatientInfo.getChuShengRQ(); | 
 |  |  |         if (StringUtils.isNotEmpty(chuShengRQ)) { | 
 |  |  |             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | 
 |  |  |             try { | 
 |  |  |                 parse = simpleDateFormat.parse(chuShengRQ); | 
 |  |  |             } catch (ParseException e) { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         PatArchive patArchive = new PatArchive(); | 
 |  |  |         //如果是刚出生的小孩子,是没有身份证的,怎么处理???????? | 
 |  |  |         patArchive.setIdcardno(externalInHospPatientInfo.getZhengJianHM()); | 
 |  |  |         //如果身份证为空的话,就用就诊卡号代替 | 
 |  |  |         if (StringUtils.isEmpty(externalInHospPatientInfo.getZhengJianHM())) | 
 |  |  |             patArchive.setIdcardno(externalInHospPatientInfo.getJiuZhenKH()); | 
 |  |  |         patArchive.setOrgid(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |         List<PatArchive> patArchives = patArchiveMapper.selectPatArchiveList(patArchive); | 
 |  |  |         List<PatArchive> patArchives = null; | 
 |  |  |         if (ObjectUtils.isNotEmpty(patArchive.getIdcardno())) | 
 |  |  |             patArchives = patArchiveMapper.selectPatArchiveList(patArchive); | 
 |  |  |         patArchive.setPatientno(externalInHospPatientInfo.getJiuZhenKH()); | 
 |  |  |         patArchive.setBirthdate(externalInHospPatientInfo.getChuShengRQ()); | 
 |  |  |         patArchive.setBirthdate(parse); | 
 |  |  |         patArchive.setPatidHis(externalInHospPatientInfo.getBingRenID()); | 
 |  |  |         patArchive.setSourcefrom(1); | 
 |  |  |         patArchive.setPattype("2"); | 
 |  |  | 
 |  |  |             patArchive.setSex(Long.valueOf(externalInHospPatientInfo.getXingBieDM())); | 
 |  |  |         patArchive.setNation(externalInHospPatientInfo.getMinZuMC()); | 
 |  |  |         patArchive.setNativePlace(externalInHospPatientInfo.getGuoJiMC()); | 
 |  |  |         if (ObjectUtils.isNotEmpty(externalInHospPatientAddrInfo)) { | 
 |  |  |         if (ObjectUtils.isNotEmpty(externalInHospPatientInfo.getXianZhuZXX())) { | 
 |  |  |             patArchive.setPlaceOfResidence(externalInHospPatientInfo.getXianZhuZXX()); | 
 |  |  |         } else if (ObjectUtils.isNotEmpty(externalInHospPatientAddrInfo)) { | 
 |  |  |             String por = null; | 
 |  |  |             if (StringUtils.isNotEmpty(externalInHospPatientAddrInfo.getDiZhiXX())) { | 
 |  |  |                 por = externalInHospPatientAddrInfo.getDiZhiXX(); | 
 |  |  | 
 |  |  |                 por = externalInHospPatientAddrInfo.getShengFenMC() + externalInHospPatientAddrInfo.getShiDiQMC() + externalInHospPatientAddrInfo.getXianQuMC() + externalInHospPatientAddrInfo.getXiangZhenMC() + externalInHospPatientAddrInfo.getCunJiMC() + externalInHospPatientAddrInfo.getQiTaXX(); | 
 |  |  |             } | 
 |  |  |             patArchive.setPlaceOfResidence(por.replace("null", "")); | 
 |  |  |             patArchive.setBirthplace(por.replace("null", "")); | 
 |  |  | //            patArchive.setBirthplace(por.replace("null", "")); | 
 |  |  |         } | 
 |  |  |         patArchive.setBirthdate(externalInHospPatientInfo.getChuShengRQ()); | 
 |  |  |         patArchive.setAge(externalInHospPatientInfo.getNianLing()); | 
 |  |  |         patArchive.setAgeUnit(externalInHospPatientInfo.getNianLingDW()); | 
 |  |  |  | 
 |  |  |         if (ObjectUtils.isNotEmpty(parse)) { | 
 |  |  |             Map<String, String> map = calculateAge(parse.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now()); | 
 |  |  |             patArchive.setAge(ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null); | 
 |  |  |             patArchive.setAgeUnit(map.get("ageUnit")); | 
 |  |  |             patArchive.setAge2(ObjectUtils.isNotEmpty(map.get("age2")) ? Long.valueOf(map.get("age2")) : null); | 
 |  |  |             patArchive.setAgeUnit2(map.get("ageUnit2")); | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         patArchive.setTelcode(externalInHospPatientInfo.getLianXiDH()); | 
 |  |  |         if (StringUtils.isEmpty(externalInHospPatientInfo.getLianXiDH())) | 
 |  |  |         if (StringUtils.isEmpty(patArchive.getTelcode())) | 
 |  |  |             patArchive.setTelcode(externalInHospPatientInfo.getLianXiRDH()); | 
 |  |  |         patArchive.setRelativetelcode(externalInHospPatientInfo.getLianXiRDH()); | 
 |  |  |         patArchive.setGuid(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |         if (ObjectUtils.isNotEmpty(externalInHospPatientLiaisonInfo)) | 
 |  |  |             patArchive.setRelativetelcode(externalInHospPatientLiaisonInfo.getLianXiRDH()); | 
 |  |  |         patArchive.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); | 
 |  |  |         patArchive.setCreateTime(new Date()); | 
 |  |  |         patArchive.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patArchive.setIdcardtype(externalInHospPatientInfo.getZhengJianLXMC()); | 
 |  |  |         patArchive.setUpdateTime(new Date()); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patArchives)) { | 
 |  |  |             //如果不为空,直接将查询出来的对象返回 | 
 |  |  |             PatArchive patArchive1 = patArchives.get(0); | 
 |  |  | 
 |  |  |             if (StringUtils.isNotEmpty(orgid)) { | 
 |  |  |                 patArchive.setId(patArchive1.getId()); | 
 |  |  |                 patArchiveMapper.updatePatArchive(patArchive); | 
 |  |  |                 return patArchive; | 
 |  |  |             } | 
 |  |  |         } else { | 
 |  |  |             patArchive.setCreateTime(new Date()); | 
 |  |  |             patArchiveMapper.insertPatArchiveSingle(patArchive); | 
 |  |  |         } | 
 |  |  |         //新属信息 | 
 |  |  |         if (ObjectUtils.isNotEmpty(externalInHospPatientInfo.getExternalInHospPatientLiaisonInfos())) { | 
 |  |  |             for (ExternalInHospPatientLiaisonInfo external : externalInHospPatientInfo.getExternalInHospPatientLiaisonInfos()) { | 
 |  |  |                 PatArchivecontact patArchivecontact = new PatArchivecontact(); | 
 |  |  |                 patArchivecontact.setPatid(patArchive.getId()); | 
 |  |  |                 patArchivecontact.setContactname(external.getLianXiRXM()); | 
 |  |  |                 patArchivecontact.setOrgid(patArchive.getOrgid()); | 
 |  |  |                 List<PatArchivecontact> patArchivecontacts = patArchivecontactMapper.selectPatArchivecontactList(patArchivecontact); | 
 |  |  |                 patArchivecontact.setContactway(external.getLianXiRDH()); | 
 |  |  |                 patArchivecontact.setRelation(external.getGuanXiMC()); | 
 |  |  |                 if (CollectionUtils.isEmpty(patArchivecontacts)) | 
 |  |  |                     patArchivecontactMapper.insertPatArchivecontact(patArchivecontact); | 
 |  |  |                 else { | 
 |  |  |                     patArchivecontact.setId(patArchivecontacts.get(0).getId()); | 
 |  |  |                     patArchivecontactMapper.updatePatArchivecontact(patArchivecontact); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         patArchiveMapper.insertPatArchiveSingle(patArchive); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         return patArchive; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //新增患者入院信息 | 
 |  |  |     private Boolean addPadInhospInfo(ExternalInHospPatientInfo externalInHospPatientInfo, PatArchive patArchive, ExternalInHospPatientDiagnoseInfo externalInHospPatientDiagnoseInfo) { | 
 |  |  |         PatMedInhosp patMedInhosp = new PatMedInhosp(); | 
 |  |  |         List<PatMedInhosp> patMedInhospList = null; | 
 |  |  |         if (ObjectUtils.isNotEmpty(externalInHospPatientInfo)) { | 
 |  |  |             patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); | 
 |  |  |             patMedInhosp.setSerialnum(externalInHospPatientInfo.getZhuYuanHao()); | 
 |  |  |             //医院那边说要用病案号,不要用住院号 | 
 |  |  |             patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |             patMedInhosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID()); | 
 |  |  |             patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); | 
 |  |  |             patMedInhosp.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC()); | 
 |  |  |             patMedInhosp.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |             patMedInhosp.setStarttime(externalInHospPatientInfo.getRuYuanSJ()); | 
 |  |  | 
 |  |  |             patMedInhosp.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID()); | 
 |  |  |             patMedInhosp.setDeptname(externalInHospPatientInfo.getDangQianKSMC()); | 
 |  |  |             patMedInhosp.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC()); | 
 |  |  |             patMedInhosp.setBedNo(externalInHospPatientInfo.getDangQianCWID()); | 
 |  |  |             //这里是床位名称还是床位编号???? | 
 |  |  |             patMedInhosp.setBedNo(externalInHospPatientInfo.getDangQianCWMC()); | 
 |  |  |             patMedInhosp.setOrgid(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |             patMedInhosp.setHospitaldistrictid(externalInHospPatientInfo.getDangQianBQID()); | 
 |  |  |             patMedInhosp.setGuid(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  | 
 |  |  |             patMedInhosp.setHospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC()); | 
 |  |  |             patMedInhosp.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC()); | 
 |  |  |             patMedInhosp.setTelcode(patArchive.getTelcode()); | 
 |  |  |             patMedInhosp.setDrname(""); | 
 |  |  |             patMedInhosp.setDrname(externalInHospPatientInfo.getZhuZhiYSXM()); | 
 |  |  |             patMedInhosp.setDrcode(externalInHospPatientInfo.getZhuZhiYSID()); | 
 |  |  |             patMedInhosp.setNurseId(externalInHospPatientInfo.getZeRenHSID()); | 
 |  |  |             patMedInhosp.setNurseName(externalInHospPatientInfo.getZeRenHSXM()); | 
 |  |  |             patMedInhosp.setManagementDoctor(externalInHospPatientInfo.getJingGuanYSXM()); | 
 |  |  |             patMedInhosp.setManagementDoctorCode(externalInHospPatientInfo.getJingGuanYSID()); | 
 |  |  |         } | 
 |  |  |         if (ObjectUtils.isNotEmpty(externalInHospPatientDiagnoseInfo)) { | 
 |  |  |             patMedInhosp.setIcd10code(StringUtils.isNotEmpty(patMedInhosp.getIcd10code()) ? patMedInhosp.getIcd10code() + "," + externalInHospPatientDiagnoseInfo.getZhenDuanID() : externalInHospPatientDiagnoseInfo.getZhenDuanID()); | 
 |  |  |             patMedInhosp.setDiagname(StringUtils.isNotEmpty(patMedInhosp.getDiagname()) ? patMedInhosp.getDiagname() + "," + externalInHospPatientDiagnoseInfo.getZhenDuanMC() : externalInHospPatientDiagnoseInfo.getZhenDuanMC()); | 
 |  |  | //            patMedInhosp.setIcd10code(StringUtils.isNotEmpty(patMedInhosp.getIcd10code()) ? patMedInhosp.getIcd10code() + "," + externalInHospPatientDiagnoseInfo.getZhenDuanID() : externalInHospPatientDiagnoseInfo.getZhenDuanID()); | 
 |  |  | //            patMedInhosp.setDiagname(StringUtils.isNotEmpty(patMedInhosp.getDiagname()) ? patMedInhosp.getDiagname() + "," + externalInHospPatientDiagnoseInfo.getZhenDuanMC() : externalInHospPatientDiagnoseInfo.getZhenDuanMC()); | 
 |  |  |  | 
 |  |  |             patMedInhosp.setIcd10code(externalInHospPatientDiagnoseInfo.getIcd10()); | 
 |  |  |             patMedInhosp.setDiagname(externalInHospPatientDiagnoseInfo.getZhenDuanMC()); | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (ObjectUtils.isNotEmpty(patArchive)) { | 
 |  |  | 
 |  |  |             patMedInhosp.setPatname(patArchive.getName()); | 
 |  |  |  | 
 |  |  |             patMedInhosp.setSchemestatus(1L); | 
 |  |  |             patMedInhosp.setCreateTime(new Date()); | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |         int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp); | 
 |  |  |         patMedInhosp.setUpdateTime(new Date()); | 
 |  |  |         int i = 1; | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInhospList)) { | 
 |  |  |             patMedInhosp.setInhospid(patMedInhospList.get(0).getInhospid()); | 
 |  |  |             i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp); | 
 |  |  |         } else { | 
 |  |  |             patMedInhosp.setCreateTime(new Date()); | 
 |  |  |             i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp); | 
 |  |  |         } | 
 |  |  |         if (i == 1) return true; | 
 |  |  |         return false; | 
 |  |  |     } | 
 |  |  | 
 |  |  |     //新增随访任务同步 | 
 |  |  |     @Override | 
 |  |  |     public Boolean addTaskInfo(Map dataMap) { | 
 |  |  |         log.error("ServiceExternalServiceImpl---addTaskInfo的新增的值为:{}", dataMap); | 
 |  |  |         log.info("ServiceExternalServiceImpl---addTaskInfo的新增的值为:{}", dataMap); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> bqxx = (Map<String, Object>) yeWuXX.get("BingQuXX"); | 
 |  |  |  | 
 |  |  | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //检查申请服务 | 
 |  |  |     @Override | 
 |  |  |     public Boolean addInspectService(Map dataMap) { | 
 |  |  |         log.info("ServiceExternalServiceImpl---addInspectService的新增的值为:{}", dataMap); | 
 |  |  |         Map xiaoXiTou = (Map) dataMap.get("XiaoXiTou"); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         Map<String, Object> JianChaSQ = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JianChaSQ") : null; | 
 |  |  |         List<HashMap<String, Object>> JianChaBWList = ObjectUtils.isNotEmpty(JianChaSQ) ? (List<HashMap<String, Object>>) JianChaSQ.get("JianChaBWList") : null; | 
 |  |  |         List<HashMap<String, Object>> ZhenDuanList = ObjectUtils.isNotEmpty(JianChaSQ) ? (List<HashMap<String, Object>>) JianChaSQ.get("ZhenDuanList") : null; | 
 |  |  |         List<HashMap<String, Object>> epai = ObjectUtils.isNotEmpty(BingRenXX) ? (List<HashMap<String, Object>>) BingRenXX.get("DiZhiXXList") : null; | 
 |  |  |  | 
 |  |  |         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); | 
 |  |  |         externalInHospPatientInfo.setZuZhiJGID(xiaoXiTou.get("FaSongJGID").toString()); | 
 |  |  |         ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo = null; | 
 |  |  |         ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo = null; | 
 |  |  |         List<ExternalInHospPatientAddrInfo> epai2 = null; | 
 |  |  |         if (CollectionUtils.isNotEmpty(epai)) { | 
 |  |  |             epai2 = epai.stream().map(map -> { | 
 |  |  |                 ExternalInHospPatientAddrInfo info = new ExternalInHospPatientAddrInfo(); | 
 |  |  |                 info.setDiZhiLX((String) map.get("DiZhiLX")); // 假设字段类型是 Integer | 
 |  |  |                 info.setDiZhiXX((String) map.get("DiZhiXX")); | 
 |  |  |                 info.setShengFenDM((String) map.get("ShengFenDM")); | 
 |  |  |                 info.setShengFenMC((String) map.get("ShengFenMC")); | 
 |  |  |                 info.setShiDiQDM((String) map.get("ShiDiQDM")); | 
 |  |  |                 info.setShiDiQMC((String) map.get("ShiDiQMC")); | 
 |  |  |                 info.setXianQuDM((String) map.get("XianQuDM")); | 
 |  |  |                 info.setXianQuMC((String) map.get("XianQuMC")); | 
 |  |  |                 info.setXiangZhenDM((String) map.get("XiangZhenDM")); | 
 |  |  |                 info.setXiangZhenMC((String) map.get("XiangZhenMC")); | 
 |  |  |                 info.setCunJiDM((String) map.get("CunJiDM")); | 
 |  |  |                 info.setQiTaXX((String) map.get("QiTaXX")); | 
 |  |  |                 info.setYouBian((String) map.get("YouBian")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |         } | 
 |  |  |         if (CollectionUtils.isNotEmpty(epai)) externalInHospPatientAddrInfo = epai2.get(0); | 
 |  |  |         //新增患者基本信息新增或修改 | 
 |  |  |         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo); | 
 |  |  |  | 
 |  |  |         PatMedInspection patMedInspection = new PatMedInspection(); | 
 |  |  |         if (xiaoXiTou.get("XiaoXiLX").equals("JC_SQ_ShenQing") || xiaoXiTou.get("XiaoXiLX").equals("JC_SQ_XiuGai")) { | 
 |  |  |             patMedInspection.setProjecttype(1); | 
 |  |  |         } else if (xiaoXiTou.get("XiaoXiLX").equals("JY_SQ_ShenQing") || xiaoXiTou.get("XiaoXiLX").equals("JY_SQ_XiuGai")) { | 
 |  |  |             patMedInspection.setProjecttype(0); | 
 |  |  |         } | 
 |  |  |         patMedInspection.setOrgid(externalInHospPatientInfo.getZuZhiJGID()); | 
 |  |  |         patMedInspection.setInhospno(externalInHospPatientInfo.getBingAnHao()); | 
 |  |  |         patMedInspection.setPatidHis(externalInHospPatientInfo.getBingRenID()); | 
 |  |  |         patMedInspection.setPatname(externalInHospPatientInfo.getXingMing()); | 
 |  |  |         patMedInspection.setProjecttype(1); | 
 |  |  |  | 
 |  |  |         if (ObjectUtils.isNotEmpty(BingRenXX)) { | 
 |  |  |             patMedInspection.setIdcardno(ObjectUtils.isNotEmpty(BingRenXX.get("ZhengJianHM")) ? BingRenXX.get("ZhengJianHM").toString() : null); | 
 |  |  |             patMedInspection.setTelcode(ObjectUtils.isNotEmpty(BingRenXX.get("LianXiDH")) ? BingRenXX.get("LianXiDH").toString() : null); | 
 |  |  |         } | 
 |  |  |         List<PatMedInspection> patMedInspections = patMedInspectionMapper.selectPatMedInspectionList(patMedInspection); | 
 |  |  |         if (ObjectUtils.isNotEmpty(JianChaSQ)) { | 
 |  |  |             patMedInspection.setAdviceId(Long.valueOf(ObjectUtils.isNotEmpty(JianChaSQ.get("YiZhuID")) ? JianChaSQ.get("YiZhuID").toString() : null)); | 
 |  |  |             patMedInspection.setAppliyid(ObjectUtils.isNotEmpty(JianChaSQ.get("ShenQingDID")) ? JianChaSQ.get("ShenQingDID").toString() : null); | 
 |  |  |             patMedInspection.setPriority(ObjectUtils.isNotEmpty(JianChaSQ.get("YouXianJi")) ? JianChaSQ.get("YouXianJi").toString() : null); | 
 |  |  |             patMedInspection.setDrcode(ObjectUtils.isNotEmpty(JianChaSQ.get("KaiDanRID")) ? JianChaSQ.get("KaiDanRID").toString() : null); | 
 |  |  |             patMedInspection.setDrname(ObjectUtils.isNotEmpty(JianChaSQ.get("KaiDanRXM")) ? JianChaSQ.get("KaiDanRXM").toString() : null); | 
 |  |  |             patMedInspection.setDeptcode(ObjectUtils.isNotEmpty(JianChaSQ.get("KaiDanKSID")) ? JianChaSQ.get("KaiDanKSID").toString() : null); | 
 |  |  |             patMedInspection.setDeptname(ObjectUtils.isNotEmpty(JianChaSQ.get("KaiDanKSMC")) ? JianChaSQ.get("KaiDanKSMC").toString() : null); | 
 |  |  |             patMedInspection.setOperatorId(ObjectUtils.isNotEmpty(JianChaSQ.get("ShenHeRID")) ? JianChaSQ.get("ShenHeRID").toString() : null); | 
 |  |  |             patMedInspection.setOperatorName(ObjectUtils.isNotEmpty(JianChaSQ.get("ShenHeRXM")) ? JianChaSQ.get("ShenHeRXM").toString() : null); | 
 |  |  |             patMedInspection.setTypeId(ObjectUtils.isNotEmpty(JianChaSQ.get("JianChaLXID")) ? JianChaSQ.get("JianChaLXID").toString() : null); | 
 |  |  |             patMedInspection.setTypeName(ObjectUtils.isNotEmpty(JianChaSQ.get("JianChaLXMC")) ? JianChaSQ.get("JianChaLXMC").toString() : null); | 
 |  |  |             patMedInspection.setMoney(Float.valueOf(ObjectUtils.isNotEmpty(JianChaSQ.get("JinE")) ? JianChaSQ.get("JinE").toString() : null)); | 
 |  |  |             patMedInspection.setFilmFlag(Integer.valueOf(ObjectUtils.isNotEmpty(JianChaSQ.get("JiaoPianFBZ")) ? JianChaSQ.get("JiaoPianFBZ").toString() : null)); | 
 |  |  |             patMedInspection.setBedFlag(Integer.valueOf(ObjectUtils.isNotEmpty(JianChaSQ.get("ChuangBianBZ")) ? JianChaSQ.get("ChuangBianBZ").toString() : null)); | 
 |  |  |             patMedInspection.setPushFlag(Integer.valueOf(ObjectUtils.isNotEmpty(JianChaSQ.get("TuiChuangBZ")) ? JianChaSQ.get("TuiChuangBZ").toString() : null)); | 
 |  |  |             patMedInspection.setUrgentFlag(Integer.valueOf(ObjectUtils.isNotEmpty(JianChaSQ.get("JiaJiBZ")) ? JianChaSQ.get("JiaJiBZ").toString() : null)); | 
 |  |  |             patMedInspection.setNostartFlag(Integer.valueOf(ObjectUtils.isNotEmpty(JianChaSQ.get("WeiShouXZXBZ")) ? JianChaSQ.get("WeiShouXZXBZ").toString() : null)); | 
 |  |  |             if (ObjectUtils.isNotEmpty(JianChaSQ.get("KaiDanSJ"))) { | 
 |  |  |                 try { | 
 |  |  |                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                     patMedInspection.setOpendate(simpleDateFormat.parse(JianChaSQ.get("KaiDanSJ").toString())); | 
 |  |  |                 } catch (ParseException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             if (ObjectUtils.isNotEmpty(JianChaSQ.get("ShenHeSJ"))) { | 
 |  |  |                 try { | 
 |  |  |                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                     patMedInspection.setOperatorDate(simpleDateFormat.parse(JianChaSQ.get("ShenHeSJ").toString())); | 
 |  |  |                 } catch (ParseException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             if (ObjectUtils.isNotEmpty(JianChaSQ.get("ZhiXingSJ"))) { | 
 |  |  |                 try { | 
 |  |  |                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                     patMedInspection.setStartTime(simpleDateFormat.parse(JianChaSQ.get("ZhiXingSJ").toString())); | 
 |  |  |                 } catch (ParseException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if (CollectionUtils.isNotEmpty(JianChaBWList)) { | 
 |  |  |             List<ExternalInspectionJC> externalInspectionJC = JianChaBWList.stream().map(map -> { | 
 |  |  |                 ExternalInspectionJC info = new ExternalInspectionJC(); | 
 |  |  |                 info.setJianChaXMID((String) map.get("JianChaXMID")); | 
 |  |  |                 info.setJianChaXMMC((String) map.get("JianChaXMMC")); | 
 |  |  |                 info.setJianChaBWID((String) map.get("JianChaBWID")); | 
 |  |  |                 info.setJianChaBWMC((String) map.get("JianChaBWMC")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |             patMedInspection.setProjectId(externalInspectionJC.get(0).getJianChaXMID()); | 
 |  |  |             patMedInspection.setProjectName(externalInspectionJC.get(0).getJianChaXMMC()); | 
 |  |  |             patMedInspection.setPartId(externalInspectionJC.get(0).getJianChaBWID()); | 
 |  |  |             patMedInspection.setPartName(externalInspectionJC.get(0).getJianChaBWMC()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (CollectionUtils.isNotEmpty(ZhenDuanList)) { | 
 |  |  |             List<ExternalInspectionJC> externalInspectionJC = ZhenDuanList.stream().map(map -> { | 
 |  |  |                 ExternalInspectionJC info = new ExternalInspectionJC(); | 
 |  |  |                 info.setZhenDuanID((String) map.get("ZhenDuanID")); | 
 |  |  |                 info.setZhenDuanMC((String) map.get("ZhenDuanMC")); | 
 |  |  |                 return info; | 
 |  |  |             }).collect(Collectors.toList()); | 
 |  |  |             patMedInspection.setDiagid(externalInspectionJC.get(0).getZhenDuanID()); | 
 |  |  |             patMedInspection.setDiagname(externalInspectionJC.get(0).getZhenDuanMC()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInspections)) { | 
 |  |  |             patMedInspection.setUpdateDate(new Date()); | 
 |  |  |             patMedInspection.setOrgid(ObjectUtils.isNotEmpty(xiaoXiTou) && ObjectUtils.isNotEmpty(xiaoXiTou.get("FaSongJGID")) ? xiaoXiTou.get("FaSongJGID").toString() : null); | 
 |  |  |             //   更新操作 | 
 |  |  |             int i = patMedInspectionMapper.updatePatMedInspection(patMedInspection); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } else { | 
 |  |  |             patMedInspection.setDelFlag("0"); | 
 |  |  |             patMedInspection.setCreateTime(new Date()); | 
 |  |  |             int i = patMedInspectionMapper.insertPatMedInspection(patMedInspection); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //检查详情添加 | 
 |  |  |     @Override | 
 |  |  |     public Boolean addInspectBGService(Map dataMap) { | 
 |  |  |         log.info("ServiceExternalServiceImpl---addInspectBGService的新增的值为:{}", dataMap); | 
 |  |  |         Map xiaoXiTou = (Map) dataMap.get("XiaoXiTou"); | 
 |  |  |         Map yeWuXX = (Map) dataMap.get("YeWuXX"); | 
 |  |  |         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null; | 
 |  |  |         Map<String, Object> JianChaBG = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JianChaBG") : null; | 
 |  |  |         List<HashMap<String, Object>> JianChaBWList = ObjectUtils.isNotEmpty(JianChaBG) ? (List<HashMap<String, Object>>) JianChaBG.get("JianChaBWList") : null; | 
 |  |  |         PatMedInspection patMedInspection = new PatMedInspection(); | 
 |  |  |         PatMedInspectionItem patMedInspectionItem = new PatMedInspectionItem(); | 
 |  |  |         patMedInspection.setOrgid(BingRenXX.get("ZuZhiJGID").toString()); | 
 |  |  |         patMedInspection.setInhospno(BingRenXX.get("BingAnHao").toString()); | 
 |  |  |         patMedInspection.setPatidHis(BingRenXX.get("BingRenID").toString()); | 
 |  |  |         patMedInspection.setPatname(BingRenXX.get("XingMing").toString()); | 
 |  |  |         patMedInspection.setAppliyid(JianChaBG.get("ShenQingDID").toString()); | 
 |  |  |         //查找患者检查检验信息,如果无,进行新加 | 
 |  |  |         List<PatMedInspection> patMedInspections = patMedInspectionMapper.selectPatMedInspectionList(patMedInspection); | 
 |  |  |         if (CollectionUtils.isNotEmpty(patMedInspections)) { | 
 |  |  |             patMedInspectionItem.setInspectionid(patMedInspections.get(0).getId().intValue()); | 
 |  |  |         } else { | 
 |  |  |             addInspectService(dataMap); | 
 |  |  |             List<PatMedInspection> patMedInspections2 = patMedInspectionMapper.selectPatMedInspectionList(patMedInspection); | 
 |  |  |             patMedInspectionItem.setInspectionid(patMedInspections2.get(0).getId().intValue()); | 
 |  |  |         } | 
 |  |  |         //检查检验报告数据处理 | 
 |  |  |         patMedInspectionItem.setOrgid(BingRenXX.get("ZuZhiJGID").toString()); | 
 |  |  |         List<PatMedInspectionItem> patMedInspectionItems = patMedInspectionItemMapper.selectPatMedInspectionItemList(patMedInspectionItem); | 
 |  |  |         if (ObjectUtils.isNotEmpty(JianChaBG)) { | 
 |  |  |             patMedInspectionItem.setInspectionName(JianChaBG.get("JianChaHao").toString()); | 
 |  |  |             patMedInspectionItem.setReportid(JianChaBG.get("JianChaHao").toString()); | 
 |  |  |             patMedInspectionItem.setStatuscode(JianChaBG.get("DangQianZTDM").toString()); | 
 |  |  |             patMedInspectionItem.setStatusname(JianChaBG.get("DangQianZTMC").toString()); | 
 |  |  |             patMedInspectionItem.setReportid(JianChaBG.get("BaoGaoRID").toString()); | 
 |  |  |             patMedInspectionItem.setReportername(JianChaBG.get("BaoGaoRXM").toString()); | 
 |  |  |             patMedInspectionItem.setDiagimpression(JianChaBG.get("ZhenDuanYX").toString()); | 
 |  |  |             patMedInspectionItem.setDiagfindings(JianChaBG.get("ZhenDuanSJ").toString()); | 
 |  |  |             patMedInspectionItem.setDiagsuggestion(JianChaBG.get("ZhenDuanJY").toString()); | 
 |  |  |             patMedInspectionItem.setReporturl(JianChaBG.get("BaoGaoYXDZ").toString()); | 
 |  |  |             patMedInspectionItem.setCriticalFlag(Integer.valueOf(JianChaBG.get("WeiJiZBZ").toString())); | 
 |  |  |             patMedInspectionItem.setCriticalContent(JianChaBG.get("WeiJiZNR").toString()); | 
 |  |  |             patMedInspectionItem.setReportdeptid(JianChaBG.get("BaoGaoKSID").toString()); | 
 |  |  |             patMedInspectionItem.setReportdeptname(JianChaBG.get("BaoGaoKSMC").toString()); | 
 |  |  |             patMedInspectionItem.setResultcode(JianChaBG.get("JianChaJGDM").toString()); | 
 |  |  |             patMedInspectionItem.setResultname(JianChaBG.get("JianChaJGMC").toString()); | 
 |  |  |             if (ObjectUtils.isNotEmpty(JianChaBG.get("BaoGaoSJ"))) { | 
 |  |  |                 try { | 
 |  |  |                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                     patMedInspection.setOpendate(simpleDateFormat.parse(JianChaBG.get("BaoGaoSJ").toString())); | 
 |  |  |                 } catch (ParseException e) { | 
 |  |  |                     e.printStackTrace(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if (ObjectUtils.isNotEmpty(patMedInspectionItems)) { | 
 |  |  |             patMedInspectionItem.setUpdateTime(new Date()); | 
 |  |  |             int i = patMedInspectionItemMapper.updatePatMedInspectionItem(patMedInspectionItem); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } else { | 
 |  |  |             patMedInspectionItem.setDelFlag("0"); | 
 |  |  |             patMedInspectionItem.setCreateTime(new Date()); | 
 |  |  |             int i = patMedInspectionItemMapper.insertPatMedInspectionItem(patMedInspectionItem); | 
 |  |  |             if (i != 1) return false; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private Boolean getType(String type, Map dataMap) { | 
 |  |  |         switch (type) { | 
 |  |  |             case "BR_DA_DangAnJL": | 
 |  |  |                 log.error("患者档案建立入参类型为:{}", type); | 
 |  |  |                 log.info("患者档案建立入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "BR_DA_DangAnXG": | 
 |  |  |                 log.error("患者档案修改入参类型为:{}", type); | 
 |  |  |                 log.info("患者档案修改入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "JZ_MZ_ZhenDuanXXLR": | 
 |  |  |                 log.error("患者诊断信息门诊录入入参类型为:{}", type); | 
 |  |  |                 log.info("患者诊断信息门诊录入入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "JZ_ZY_ZhenDuanXXLR": | 
 |  |  |                 log.error("患者诊断信息住院录入入参类型为:{}", type); | 
 |  |  |                 log.info("患者诊断信息住院录入入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "YZ_MZ_YiZhuSQ": | 
 |  |  |                 log.error("门诊医嘱申请入参类型为:{}", type); | 
 |  |  |                 log.info("门诊医嘱申请入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "YZ_ZY_YiZhuZX": | 
 |  |  |                 log.error("住院医嘱执行入参类型为:{}", type); | 
 |  |  |                 log.info("住院医嘱执行入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "YZ_MZ_YiZhuXG": | 
 |  |  |                 log.error("门诊医嘱修改入参类型为:{}", type); | 
 |  |  |                 log.info("门诊医嘱修改入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "YZ_MZ_YiZhuCX": | 
 |  |  |                 log.error("门诊医嘱撤销入参类型为:{}", type); | 
 |  |  |                 log.info("门诊医嘱撤销入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "YZ_MZ_YiZhuCS": | 
 |  |  |                 log.error("门诊医嘱删除入参类型为:{}", type); | 
 |  |  |                 log.info("门诊医嘱删除入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "JC_SQ_ShenQing": | 
 |  |  |                 log.error("检查申请单入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |                 log.info("检查申请单入参类型为:{}", type); | 
 |  |  |                 return addInspectService(dataMap); | 
 |  |  |             case "JC_SQ_XiuGai": | 
 |  |  |                 log.error("检查申请信息更新入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |                 log.info("检查申请信息更新入参类型为:{}", type); | 
 |  |  |                 return addInspectService(dataMap); | 
 |  |  |             case "JC_SQ_CheXiao": | 
 |  |  |                 log.error("检查撤销入参类型为:{}", type); | 
 |  |  |                 log.info("检查撤销入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "JC_BG_BaoGao": | 
 |  |  |                 log.info("检查报告入参类型为:{}", type); | 
 |  |  |                 return addInspectBGService(dataMap); | 
 |  |  |             case "JY_SQ_ShenQing": | 
 |  |  |                 log.error("检验申请入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |                 log.info("检验申请入参类型为:{}", type); | 
 |  |  |                 return addInspectService(dataMap); | 
 |  |  |             case "JY_SQ_CheXiao": | 
 |  |  |                 log.error("检验撤销入参类型为:{}", type); | 
 |  |  |                 log.info("检验撤销入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "JY_SQ_XiuGai": | 
 |  |  |                 log.error("检验修改入参类型为辅:{}", type); | 
 |  |  |                 return true; | 
 |  |  |                 log.info("检验修改入参类型为辅:{}", type); | 
 |  |  |                 return addInspectService(dataMap); | 
 |  |  |             case "JY_SQ_BiaoBenCJ": | 
 |  |  |                 log.error("检验标本采集入参类型为:{}", type); | 
 |  |  |                 log.info("检验标本采集入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "JY_SQ_QuXiaoBBCJ": | 
 |  |  |                 log.error("取消检验标本采集入参类型为:{}", type); | 
 |  |  |                 log.info("取消检验标本采集入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "SM_SQ_ShenQing": | 
 |  |  |                 log.error("手术申请入参类型为:{}", type); | 
 |  |  |                 log.info("手术申请入参类型为:{}", type); | 
 |  |  |                 addOperationInfo(dataMap); | 
 |  |  |                 return true; | 
 |  |  |             case "TJ_YW_BaoGaoXX": | 
 |  |  |                 log.error("体检报告入参类型为:{}", type); | 
 |  |  |                 log.info("体检报告入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "TJ_YW_QuXiaoBG": | 
 |  |  |                 log.error("取消体检报告入参类型为:{}", type); | 
 |  |  |                 log.info("取消体检报告入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "JG_ZZ_JiGou": | 
 |  |  |                 log.error("组织机构入参类型为:{}", type); | 
 |  |  |                 log.info("组织机构入参类型为:{}", type); | 
 |  |  |                 return addOrganInfo(dataMap); | 
 |  |  |             case "JG_ZZ_KeShi": | 
 |  |  |                 log.error("科室入参类型为:{}", type); | 
 |  |  |                 log.info("科室入参类型为:{}", type); | 
 |  |  |                 return addDeptInfo(dataMap); | 
 |  |  |             case "JG_YH_JiBenXX": | 
 |  |  |                 log.error("用户信息入参类型为:{}", type); | 
 |  |  |                 log.info("用户信息入参类型为:{}", type); | 
 |  |  |                 return addUserInfo(dataMap); | 
 |  |  |             case "fu_task": | 
 |  |  |                 log.error("fu_task服务入参类型为:{}", type); | 
 |  |  |                 log.info("fu_task服务入参类型为:{}", type); | 
 |  |  |                 return addTaskInfo(dataMap); | 
 |  |  |             case "GY_ZD_JiBingML": | 
 |  |  |                 log.error("疾病入参类型为:{}", type); | 
 |  |  |                 log.info("疾病入参类型为:{}", type); | 
 |  |  |                 return addDiseaseInfo(dataMap); | 
 |  |  |             case "YP_ZD_YaoPinCDJG": | 
 |  |  |                 log.error("药品产地价格入参类型为:{}", type); | 
 |  |  |                 log.info("药品产地价格入参类型为:{}", type); | 
 |  |  |                 return true; | 
 |  |  |             case "JZ_MZ_WanChengJZ": | 
 |  |  |                 log.error("完成接诊入参类型为:{}", type); | 
 |  |  |                 log.info("(门急诊)完成接诊入参类型为:{}", type); | 
 |  |  |                 return addFinshJZInfo(dataMap); | 
 |  |  |             case "JZ_ZY_RuYuanDJ": | 
 |  |  |                 log.error("入院登记入参类型为:{}", type); | 
 |  |  |                 log.info("入院登记入参类型为:{}", type); | 
 |  |  |                 return addInHospInfo(dataMap); | 
 |  |  |             case "JZ_ZY_QuXiaoRY": | 
 |  |  |                 log.error("取消入院登记入参类型为:{}", type); | 
 |  |  |                 log.info("取消入院登记入参类型为:{}", type); | 
 |  |  |                 return cancelInHospInfo(dataMap); | 
 |  |  |             case "JZ_ZY_ChuYuan": | 
 |  |  |                 log.error("患者出院入参类型为:{}", type); | 
 |  |  |                 log.info("患者出院入参类型为:{}", type); | 
 |  |  |                 return addOutHospInfo(dataMap); | 
 |  |  |             case "BL_JL_ChuYuanJL": | 
 |  |  |                 log.info("患者出院记录入参类型为:{}", type); | 
 |  |  |                 return addOutHospJLInfo(dataMap); | 
 |  |  |             case "JZ_ZY_QuXiaoCY": | 
 |  |  |                 log.error("取消出院入参类型为:{}", type); | 
 |  |  |                 log.info("取消出院入参类型为:{}", type); | 
 |  |  |                 return cancelOutHospInfo(dataMap); | 
 |  |  |             case "JZ_ZY_YuChuYuan": | 
 |  |  |                 log.info("患者预出院入参类型为:{}", type); | 
 |  |  |                 return addPreOutHospInfo(dataMap); | 
 |  |  |             case "JG_ZZ_BingQu": | 
 |  |  |                 log.error("病区信息入参类型为辅:{}", type); | 
 |  |  |                 log.info("病区信息入参类型为:{}", type); | 
 |  |  |                 return addWardAreaInfo(dataMap); | 
 |  |  |             case "JG_ZZ_YiLiaoZYS": | 
 |  |  |                 log.info("医疗组医生为:{}", type); | 
 |  |  |                 return addMedicalTeam(dataMap); | 
 |  |  |             case "JZ_ZY_RuKe": | 
 |  |  |                 log.info("入科的数据为:{}", type); | 
 |  |  |                 return addInDeptInfo(dataMap); | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Map<String, String> calculateAge(LocalDate birthdate, LocalDate today) { | 
 |  |  |         if (birthdate == null || today.isBefore(birthdate)) { | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |         Map<String, String> ageMap = new HashMap<>(); | 
 |  |  |  | 
 |  |  |         Period period = Period.between(birthdate, today); | 
 |  |  |         long totalDays = ChronoUnit.DAYS.between(birthdate, today); | 
 |  |  |         long totalMonths = ChronoUnit.MONTHS.between(birthdate, today); | 
 |  |  |  | 
 |  |  |         int years = period.getYears(); | 
 |  |  |         int months = period.getMonths(); | 
 |  |  |         int days = period.getDays(); | 
 |  |  |  | 
 |  |  |         String ageUnit; | 
 |  |  |         Integer age; | 
 |  |  |         String ageUnit2 = null; | 
 |  |  |         Integer age2 = null; | 
 |  |  |  | 
 |  |  |         if (totalDays < 90) { | 
 |  |  |             // 小于 1 个月,按天计算 | 
 |  |  |             ageUnit = "天"; | 
 |  |  |             age = (int) totalDays; | 
 |  |  |             ageMap.put("age", age != null ? age.toString() : null); | 
 |  |  |             ageMap.put("ageUnit", ageUnit); | 
 |  |  |             ageMap.put("age2", null); | 
 |  |  |             ageMap.put("ageUnit2", null); | 
 |  |  |         } else if (totalMonths < 36) { | 
 |  |  |             // 小于 1 年,按月 + 天计算 | 
 |  |  |             ageUnit = "月"; | 
 |  |  |             age = (int) totalMonths; | 
 |  |  |             ageUnit2 = "天"; | 
 |  |  |             age2 = days; | 
 |  |  |             ageMap.put("age", age != null ? age.toString() : null); | 
 |  |  |             ageMap.put("ageUnit", ageUnit); | 
 |  |  |             ageMap.put("age2", age2 != null ? age2.toString() : null); | 
 |  |  |             ageMap.put("ageUnit2", ageUnit2); | 
 |  |  |         } else { | 
 |  |  |             // 大于 1 年,按年 + 月计算 | 
 |  |  |             ageUnit = "岁"; | 
 |  |  |             age = years; | 
 |  |  |             ageUnit2 = "月"; | 
 |  |  |             age2 = months; | 
 |  |  |             ageMap.put("age", age != null ? age.toString() : null); | 
 |  |  |             ageMap.put("ageUnit", ageUnit); | 
 |  |  |             ageMap.put("age2", age2 != null ? age2.toString() : null); | 
 |  |  |             ageMap.put("ageUnit2", ageUnit2); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return ageMap; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |