| | |
| | | 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.time.LocalDate; |
| | | import java.time.Period; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | private BaseOrganizationMapper baseOrganizationMapper; |
| | | @Autowired |
| | | private PatArchiveMapper patArchiveMapper; |
| | | @Autowired |
| | | private PatArchivecontactMapper patArchivecontactMapper; |
| | | @Autowired |
| | | private PatMedInhospMapper patMedInhospMapper; |
| | | @Autowired |
| | |
| | | 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(); |
| | |
| | | Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX"); |
| | | ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); |
| | | patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); |
| | | 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"); |
| | | PatMedInhosp patMedInhosp1 = patMedInhospList.get(0); |
| | |
| | | PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo); |
| | | |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); |
| | | patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); |
| | | List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); |
| | | |
| | | for (PatMedInhosp patMedInhosp1 : patMedInhospList) { |
| | | String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid()); |
| | | patMedInhosp1.setTagname(tagname); |
| | | } |
| | | Map<String, Object> JiuZhenXX = (Map<String, Object>) yeWuXX.get("JiuZhenXX"); |
| | | PatMedInhosp patMedInhosp1 = new PatMedInhosp(); |
| | | if (CollectionUtils.isNotEmpty(patMedInhospList)) patMedInhosp1 = patMedInhospList.get(0); |
| | |
| | | patMedInhosp1.setOperator(JiuZhenXX.get("CaoZuoRXM").toString()); |
| | | patMedInhosp1.setOperatorId(JiuZhenXX.get("CaoZuoRID").toString()); |
| | | patMedInhosp1.setUpdateTime(new Date()); |
| | | 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.setTelcode(patArchive.getTelcode()); |
| | | patMedInhosp1.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID()); |
| | | patMedInhosp1.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC()); |
| | |
| | | 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()); |
| | | // patMedInhosp1.setIcd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); |
| | | patMedInhosp1.setInhospstate("1"); |
| | | if (CollectionUtils.isNotEmpty(patMedInhospList)) { |
| | | patMedInhosp1.setUpdateTime(new Date()); |
| | |
| | | patMedInhosp1.setPatname(patArchive.getName()); |
| | | patMedInhosp1.setOrgid(BingRenXX.get("ZuZhiJGID").toString()); |
| | | patMedInhosp1.setPatno(BingRenXX.get("BingRenID").toString()); |
| | | patMedInhosp1.setInhospno(BingRenXX.get("ZhuYuanHao").toString()); |
| | | patMedInhosp1.setInhospno(BingRenXX.get("BingAnHao").toString()); |
| | | patMedInhosp1.setSerialnum(BingRenXX.get("BingAnHao").toString()); |
| | | patMedInhosp1.setCreateTime(new Date()); |
| | | int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1); |
| | |
| | | Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX"); |
| | | ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true); |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); |
| | | patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); |
| | | 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"); |
| | | PatMedInhosp patMedInhosp1 = patMedInhospList.get(0); |
| | |
| | | patMedOperation.setPatname(externalInHospPatientInfo.getXingMing()); |
| | | patMedOperation.setVisitid(null); |
| | | patMedOperation.setSerialnum(externalInHospPatientInfo.getZhuYuanHao()); |
| | | patMedOperation.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); |
| | | patMedOperation.setInhospno(externalInHospPatientInfo.getBingAnHao()); |
| | | patMedOperation.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC()); |
| | | patMedOperation.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID()); |
| | | patMedOperation.setDeptid(externalOperationInfo.getShouShuKSID()); |
| | |
| | | patMedOperation.setDelFlag("1"); |
| | | //同时去查询,是否在subtask中生成任务,如果生成出得立马删除 |
| | | } |
| | | patMedOperation.setUpdateTime(new Date()); |
| | | patMedOperationMapper.updatePatMedOperation(patMedOperation); |
| | | } else patMedOperationMapper.insertPatMedOperation(patMedOperation); |
| | | } else { |
| | | patMedOperation.setCreateTime(new Date()); |
| | | patMedOperationMapper.insertPatMedOperation(patMedOperation); |
| | | } |
| | | log.error("-----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 = ShouShuMXList.stream().map(map -> { |
| | | ExternalOperationDetail info = new ExternalOperationDetail(); |
| | | info.setShouShuMCID((String) map.get("ShouShuMCID")); |
| | | info.setShouShuMC((String) map.get("ShouShuMC")); |
| | | info.setZhuShouSBZ((String) map.get("ZhuShouSBZ")); |
| | | 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()); |
| | | |
| | | //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()); |
| | | patArchive.setOrgid(externalInHospPatientInfo.getZuZhiJGID()); |
| | | List<PatArchive> 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.setPlaceOfResidence(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())) |
| | | patArchive.setTelcode(externalInHospPatientInfo.getLianXiRDH()); |
| | |
| | | patArchive.setGuid(externalInHospPatientInfo.getZuZhiJGID()); |
| | | if (ObjectUtils.isNotEmpty(externalInHospPatientLiaisonInfo)) |
| | | patArchive.setRelativetelcode(externalInHospPatientLiaisonInfo.getLianXiRDH()); |
| | | patArchive.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); |
| | | patArchive.setInhospno(externalInHospPatientInfo.getBingAnHao()); |
| | | patArchive.setCreateTime(new Date()); |
| | | patArchive.setIdcardtype(externalInHospPatientInfo.getZhengJianLXMC()); |
| | | if (CollectionUtils.isNotEmpty(patArchives)) { |
| | |
| | | } |
| | | } |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return patArchive; |
| | | } |
| | | |
| | |
| | | private Boolean addPadInhospInfo(ExternalInHospPatientInfo externalInHospPatientInfo, PatArchive patArchive, ExternalInHospPatientDiagnoseInfo externalInHospPatientDiagnoseInfo) { |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | if (ObjectUtils.isNotEmpty(externalInHospPatientInfo)) { |
| | | patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao()); |
| | | //医院那边说要用病案号,不要用住院号 |
| | | patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao()); |
| | | patMedInhosp.setSerialnum(externalInHospPatientInfo.getZhuYuanHao()); |
| | | patMedInhosp.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC()); |
| | | patMedInhosp.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID()); |
| | |
| | | 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 < 30) { |
| | | // 小于 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 < 12) { |
| | | // 小于 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; |
| | | } |
| | | |
| | | } |