| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | | import com.smartor.service.IPatChildArchiveService; |
| | | import com.smartor.service.IPatMaternityArchiveService; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import com.smartor.service.IServiceExternalService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private Icd10Mapper icd10Mapper; |
| | | @Autowired |
| | | private IPatMedOuthospService patMedOuthospService; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | @Autowired |
| | | private IPatMaternityArchiveService patMaternityArchiveService; |
| | | @Autowired |
| | | private IPatChildArchiveService patChildArchiveService; |
| | | @Autowired |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | @Autowired |
| | |
| | | }).collect(Collectors.toList()); |
| | | patMedInhosp1.setLeaveicd10code(hospPatientDiagnoseInfos2.get(0).getIcd10()); |
| | | patMedInhosp1.setLeavediagname(hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); |
| | | //只有诊断名称没有诊断码的数据 |
| | | if(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) |
| | | && !StringUtils.isNotEmpty(patMedInhosp1.getLeaveicd10code())){ |
| | | Icd10 icd10 = new Icd10(); |
| | | icd10.setIcdname(patMedInhosp1.getLeavediagname()); |
| | | icd10.setDelFlag("0"); |
| | | icd10.setOrgid(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); |
| | | //丽水无院区,默认值是 1 |
| | | icd10.setCampusid("1"); |
| | | //通过icdCode查询一下,是否存在 |
| | | List<Icd10> icd10s = icd10Mapper.exactQueryIcd10List(icd10); |
| | | if(CollectionUtils.isEmpty(icd10s)){ |
| | | patMedInhosp1.setLeaveicd10code(icd10s.get(0).getIcdcode()); |
| | | } |
| | | } |
| | | //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()); |
| | | } |
| | |
| | | }).collect(Collectors.toList()); |
| | | patMedInhosp1.setLeaveicd10code(hospPatientDiagnoseInfos2.get(0).getIcd10()); |
| | | patMedInhosp1.setLeavediagname(hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); |
| | | //只有诊断名称没有诊断码的数据 |
| | | if(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) |
| | | && !StringUtils.isNotEmpty(patMedInhosp1.getLeaveicd10code())){ |
| | | Icd10 icd10 = new Icd10(); |
| | | icd10.setIcdname(patMedInhosp1.getLeavediagname()); |
| | | icd10.setDelFlag("0"); |
| | | icd10.setOrgid(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); |
| | | //丽水无院区,默认值是 1 |
| | | icd10.setCampusid("1"); |
| | | //通过icdCode查询一下,是否存在 |
| | | List<Icd10> icd10s = icd10Mapper.exactQueryIcd10List(icd10); |
| | | if(CollectionUtils.isEmpty(icd10s)){ |
| | | patMedInhosp1.setLeaveicd10code(icd10s.get(0).getIcdcode()); |
| | | } |
| | | } |
| | | //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"); |
| | | String orgid = ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null; |
| | | // if(StringUtils.isNotEmpty(orgid) && orgid.equals("47246103233112211A1001")){ |
| | | // //缙云二院 住院记录不更新状态 |
| | | // }else { |
| | | // 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); |
| | | patMedInhosp1.setOrgid(orgid); |
| | | if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) { |
| | | //不需要长期任务随访 |
| | | patMedInhosp1.setFuflag("0"); |
| | |
| | | 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.setOrgid(orgid); |
| | | //丽水无院区,默认值是 1 |
| | | patMedInhosp1.setCampusid("1"); |
| | | patMedInhosp1.setPatno(ObjectUtils.isNotEmpty(BingRenXX.get("BingRenID")) ? BingRenXX.get("BingRenID").toString() : null); |
| | |
| | | }).collect(Collectors.toList()); |
| | | patMedInhosp1.setLeaveicd10code(hospPatientDiagnoseInfos2.get(0).getIcd10()); |
| | | patMedInhosp1.setLeavediagname(hospPatientDiagnoseInfos2.get(0).getZhenDuanMC()); |
| | | //只有诊断名称没有诊断码的数据 |
| | | if(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) |
| | | && !StringUtils.isNotEmpty(patMedInhosp1.getLeaveicd10code())){ |
| | | Icd10 icd10 = new Icd10(); |
| | | icd10.setIcdname(patMedInhosp1.getLeavediagname()); |
| | | icd10.setDelFlag("0"); |
| | | icd10.setOrgid(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null); |
| | | //丽水无院区,默认值是 1 |
| | | icd10.setCampusid("1"); |
| | | //通过icdCode查询一下,是否存在 |
| | | List<Icd10> icd10s = icd10Mapper.exactQueryIcd10List(icd10); |
| | | if(CollectionUtils.isEmpty(icd10s)){ |
| | | patMedInhosp1.setLeaveicd10code(icd10s.get(0).getIcdcode()); |
| | | } |
| | | } |
| | | //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()); |
| | | } |
| | |
| | | } |
| | | patMedOuthospService.dealPatMedOuthosp(patMedOuthosp, visitTimeNum); |
| | | } |
| | | |
| | | genePatSpecificArchive(patMedOuthosp, patArchive); |
| | | |
| | | if (i > 0) { |
| | | return true; |
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean cancelOperationInfo(Map dataMap) { |
| | | log.info("ServiceExternalServiceImpl---cancelOperationInfo的撤销的值为:{}", 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); |
| | | PatArchive patArchive = addPatArchive(externalInHospPatientInfo, null, null); |
| | | //手术撤销 |
| | | Map<String, Object> sscx = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ShouShuCX") : null; |
| | | ExternalOperationInfo externalOperationInfo = null; |
| | | if (ObjectUtils.isNotEmpty(sscx)) |
| | | externalOperationInfo = BeanUtil.mapToBean(sscx, ExternalOperationInfo.class, true); |
| | | PatMedOperation patMedOperation = new PatMedOperation(); |
| | | patMedOperation.setPatid(patArchive.getId()); |
| | | patMedOperation.setOrgid(patArchive.getOrgid()); |
| | | patMedOperation.setOpreqcode(externalOperationInfo.getShenQingDID()); |
| | | //查询一下,该患者是否已经有这些数据 |
| | | List<PatMedOperation> patMedOperations = patMedOperationMapper.selectPatMedOperationList(patMedOperation); |
| | | if (CollectionUtils.isNotEmpty(patMedOperations)) { |
| | | for(PatMedOperation operation : patMedOperations){ |
| | | Long id = operation.getId(); |
| | | //如果手术撤销,直接删除该条手术信息 |
| | | if (ObjectUtils.isNotEmpty(sscx)) { |
| | | operation.setId(id); |
| | | operation.setCheckFlag("1"); |
| | | operation.setDelFlag("1"); |
| | | //同时去查询,是否在subtask中生成任务,如果生成出得立马删除 |
| | | // 手术随访 |
| | | PatMedOperationItem pmoi = new PatMedOperationItem(); |
| | | //获取需要出院手术随访,未处理的数据 |
| | | pmoi.setOpid(operation.getId().toString()); |
| | | List<PatMedOperationItem> patMedOperationItems |
| | | = patMedOperationItemMapper.selectOperationItemList(pmoi); |
| | | List<Long> operationItemIds = patMedOperationItems.stream() |
| | | .map(PatMedOperationItem::getId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | |
| | | |
| | | //不需要服务了,需要通过patid和sendstate=1,2,3,5,7去查询一下,service_subtask里是否有正在执行的任务, |
| | | //有的话,立即停了 |
| | | List<Long> sendstates = Arrays.asList(1L, 2L, 3L, 5L, 7L); |
| | | List<ServiceSubtask> serviceSubtaskList = new ArrayList<>(); |
| | | ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity(); |
| | | serviceSubtaskVO.setOrgid(patArchive.getOrgid()); |
| | | serviceSubtaskVO.setPatid(patArchive.getId()); |
| | | serviceSubtaskVO.setSendstates(sendstates); |
| | | serviceSubtaskVO.setOperationItemIds(operationItemIds); |
| | | serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); |
| | | //去redis中,查询是否有subid,有的话移除cache-exist |
| | | if (CollectionUtils.isNotEmpty(serviceSubtaskList)) { |
| | | for (ServiceSubtask serviceSubtask : serviceSubtaskList) { |
| | | log.info("需要移除的subId为:{}", serviceSubtask.getId().toString()); |
| | | serviceSubtask.setSendstate(4L); |
| | | serviceSubtask.setRemark("手术撤销"); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | 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()); |
| | | } |
| | | } |
| | | operation.setUpdateTime(new Date()); |
| | | patMedOperationMapper.updatePatMedOperation(operation); |
| | | patMedOperationItemMapper.deleteSoftPatMedOperationItemByOpId(operation.getOpid()); |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | //新增患者基本信息 |
| | | private PatArchive addPatArchive(ExternalInHospPatientInfo externalInHospPatientInfo, ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo, ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo) { |
| | | Date parse = null; |
| | |
| | | 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; |
| | | Map<String, Object> JianChaBG = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JianChaBG") : 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; |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | if (ObjectUtils.isNotEmpty(JianChaBG)) { |
| | | patMedInspection.setAppliyid(ObjectUtils.isNotEmpty(JianChaBG.get("ShenQingDID")) ? JianChaBG.get("ShenQingDID").toString() : null); |
| | | } |
| | | if (CollectionUtils.isNotEmpty(JianChaBWList)) { |
| | | List<ExternalInspectionJC> externalInspectionJC = JianChaBWList.stream().map(map -> { |
| | |
| | | return true; |
| | | case "SM_SQ_CheXiao": |
| | | log.info("手术撤销入参类型为:{}", type); |
| | | cancelOperationInfo(dataMap); |
| | | return true; |
| | | case "TJ_YW_BaoGaoXX": |
| | | log.info("体检报告入参类型为:{}", type); |
| | |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //新增患者专科档案基本信息 |
| | | private void genePatSpecificArchive(PatMedOuthosp patMedOuthosp, PatArchive patArchive) { |
| | | String deptCategory = judgeDeptCategory(patMedOuthosp.getDeptcode(), patMedOuthosp.getOrgid()); |
| | | |
| | | boolean isGynecology = "1".equals(deptCategory); // 是否妇科 |
| | | boolean isPediatrics = "2".equals(deptCategory); // 是否儿科 |
| | | |
| | | if (isGynecology) { |
| | | // 走妇科档案生成逻辑 |
| | | PatMaternityArchiveDetail patMaternityArchiveDetail |
| | | = DtoConversionUtils.sourceToTarget(patMedOuthosp, PatMaternityArchiveDetail.class); |
| | | patMaternityArchiveDetail.setSourceType("1"); |
| | | patMaternityArchiveDetail.setPhone(patArchive.getTelcode()); |
| | | patMaternityArchiveDetail.setPatid(patArchive.getId()); |
| | | patMaternityArchiveDetail.setPatname(patArchive.getName()); |
| | | patMaternityArchiveDetail.setBirthdate(patArchive.getBirthdate()); |
| | | patMaternityArchiveDetail.setSex(patArchive.getSex()); |
| | | patMaternityArchiveDetail.setAddress(patArchive.getPlaceOfResidence()); |
| | | patMaternityArchiveDetail.setOuthospno(patMedOuthosp.getOuthospno()); |
| | | patMaternityArchiveDetail.setSerialnum(patMedOuthosp.getSerialnum()); |
| | | patMaternityArchiveDetail.setIcd10code(patMedOuthosp.getIcd10code()); |
| | | patMaternityArchiveDetail.setDeptcode(patMedOuthosp.getDeptcode()); |
| | | patMaternityArchiveDetail.setDeptname(patMedOuthosp.getDeptname()); |
| | | patMaternityArchiveDetail.setDoctorName(patMedOuthosp.getDrname()); |
| | | patMaternityArchiveDetail.setDoctorCode(patMedOuthosp.getDrcode()); |
| | | patMaternityArchiveDetail.setManagementDoctorName(patMedOuthosp.getDrname()); |
| | | patMaternityArchiveDetail.setManagementDoctorCode(patMedOuthosp.getDrcode()); |
| | | patMaternityArchiveDetail.setOrgid(patMedOuthosp.getOrgid()); |
| | | patMaternityArchiveDetail.setCampusid(patMedOuthosp.getCampusid()); |
| | | patMaternityArchiveService.insertOrUpdateMaternityArchive(patMaternityArchiveDetail); |
| | | } else if (isPediatrics) { |
| | | // 走儿科档案生成逻辑 |
| | | PatChildArchiveDetail patChildArchiveDetail |
| | | = DtoConversionUtils.sourceToTarget(patMedOuthosp, PatChildArchiveDetail.class); |
| | | patChildArchiveDetail.setSourceType("1"); |
| | | patChildArchiveDetail.setPhone(patArchive.getTelcode()); |
| | | patChildArchiveDetail.setPatid(patArchive.getId()); |
| | | patChildArchiveDetail.setPatname(patArchive.getName()); |
| | | patChildArchiveDetail.setBirthdate(patArchive.getBirthdate()); |
| | | patChildArchiveDetail.setSex(patArchive.getSex()); |
| | | // patChildArchiveDetail.setAddress(patArchive.getPlaceOfResidence()); |
| | | patChildArchiveDetail.setOuthospno(patMedOuthosp.getOuthospno()); |
| | | patChildArchiveDetail.setSerialnum(patMedOuthosp.getSerialnum()); |
| | | patChildArchiveDetail.setIcd10code(patMedOuthosp.getIcd10code()); |
| | | patChildArchiveDetail.setDeptcode(patMedOuthosp.getDeptcode()); |
| | | patChildArchiveDetail.setDeptname(patMedOuthosp.getDeptname()); |
| | | patChildArchiveDetail.setDoctorName(patMedOuthosp.getDrname()); |
| | | patChildArchiveDetail.setDoctorCode(patMedOuthosp.getDrcode()); |
| | | patChildArchiveDetail.setManagementDoctorName(patMedOuthosp.getDrname()); |
| | | patChildArchiveDetail.setManagementDoctorCode(patMedOuthosp.getDrcode()); |
| | | patChildArchiveDetail.setOrgid(patMedOuthosp.getOrgid()); |
| | | patChildArchiveDetail.setCampusid(patMedOuthosp.getCampusid()); |
| | | patChildArchiveService.insertOrUpdateChildArchive(patChildArchiveDetail); |
| | | } else { |
| | | // 未命中配置,不生成档案 |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断当前科室属于妇科还是儿科 |
| | | * |
| | | * @param deptCode 当前科室/病区 Code,如 "D004" |
| | | * @param orgid 医院机构ID |
| | | * @return deptCategory:1-妇科 2-儿科;null-未配置或未命中 |
| | | */ |
| | | public String judgeDeptCategory(String deptCode, String orgid) { |
| | | if (StringUtils.isEmpty(deptCode)) { |
| | | return null; |
| | | } |
| | | |
| | | // 优先取机构级配置,取不到再取全局配置 |
| | | String configValue = configService.selectConfigByKey("sys.dept.category", |
| | | orgid); |
| | | if (StringUtils.isEmpty(configValue)) { |
| | | configValue = configService.selectConfigByKey("sys.dept.category"); |
| | | } |
| | | if (StringUtils.isEmpty(configValue)) { |
| | | return null; |
| | | } |
| | | |
| | | JSONArray configs = JSON.parseArray(configValue); |
| | | if (configs == null || configs.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | for (int i = 0; i < configs.size(); i++) { |
| | | JSONObject cfg = configs.getJSONObject(i); |
| | | JSONArray deptCodes = cfg.getJSONArray("deptCodes"); |
| | | if (deptCodes != null && deptCodes.contains(deptCode)) { |
| | | return cfg.getString("deptCategory"); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |