liusheng
2025-04-14 0a10b51863b939e646661394ae7e03acb0cb0039
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -254,6 +254,73 @@
    }
    @Override
    public Boolean addInDeptInfo(Map dataMap) {
        log.error("ServiceExternalServiceImpl---addInDeptInfo的新增的值为:{}", dataMap);
        Map yeWuXX = (Map) dataMap.get("YeWuXX");
        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;
        Map<String, Object> RuKeXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("RuKeXX") : 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());
        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());
        List<ExternalInHospPatientLiaisonInfo> 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());
        externalInHospPatientInfo.setExternalInHospPatientLiaisonInfos(epli2);
        List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = hospPatientDiagnoseInfos.stream().map(map -> {
            ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo();
            info.setZhenDuanID((String) map.get("ZhenDuanID"));
            info.setZhenDuanMC((String) map.get("ZhenDuanMC"));
            return info;
        }).collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(epai)) externalInHospPatientAddrInfo = epai2.get(0);
        if (CollectionUtils.isNotEmpty(epli)) externalInHospPatientLiaisonInfo = epli2.get(0);
        if (CollectionUtils.isNotEmpty(hospPatientDiagnoseInfos))
            externalInHospPatientDiagnoseInfo = hospPatientDiagnoseInfos2.get(0);
        //新增患者基本信息
        PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo);
        //新增患者入院信息
        Boolean aBoolean = addPadInhospInfo(externalInHospPatientInfo, patArchive, externalInHospPatientDiagnoseInfo);
        return aBoolean;
    }
    @Override
    public Boolean cancelInHospInfo(Map dataMap) {
        log.error("ServiceExternalServiceImpl---cancelInHospInfo的新增的值为:{}", dataMap);
        Map yeWuXX = (Map) dataMap.get("YeWuXX");
@@ -261,6 +328,7 @@
        ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
        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());
@@ -333,6 +401,7 @@
        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());
@@ -410,7 +479,7 @@
                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("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());
@@ -430,6 +499,7 @@
        ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
        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());
@@ -456,6 +526,7 @@
        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;
@@ -476,6 +547,7 @@
                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());
        }
@@ -490,8 +562,11 @@
        PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
        patMedOuthosp.setOuthospno(externalInHospPatientInfo.getBingAnHao());
        patMedOuthosp.setSerialnum(externalInHospPatientInfo.getBingAnHao());
        patMedOuthosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID());
        List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp);
        patMedOuthosp.setPatid(patArchive.getId());
        patMedOuthosp.setPatno(externalInHospPatientInfo.getBingAnHao());
        patMedOuthosp.setPatname(externalInHospPatientInfo.getXingMing());
        patMedOuthosp.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
        patMedOuthosp.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
@@ -499,6 +574,7 @@
        patMedOuthosp.setDeptcode(externalJZInfo.getJiuZhenKSID());
        patMedOuthosp.setAdmitdate(externalJZInfo.getJiuZhenRQ());
        patMedOuthosp.setOrgid(FaSongJGID);
        patMedOuthosp.setHospitalname(FaSongJGMC);
        for (ExternalDiagnosisInfo externalDiagnosisInfo : externalDiagnosisInfoList) {
            if (externalDiagnosisInfo.getZhenDuanLBMC().equals("主诊断")) {
@@ -516,7 +592,16 @@
                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());
            i = patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp);
        } else {
            patMedOuthosp.setCreateTime(new Date());
            patMedOuthosp.setUpdateTime(new Date());
            i = patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp);
        }
        if (i > 0) {
            return true;
        }
@@ -669,7 +754,7 @@
            patMedOperation.setPatno(externalInHospPatientInfo.getBingRenID());
            patMedOperation.setPatname(externalInHospPatientInfo.getXingMing());
            patMedOperation.setOrgid(externalInHospPatientInfo.getZuZhiJGID());
            patMedOperation.setSerialnum(externalInHospPatientInfo.getZhuYuanHao());
            patMedOperation.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID());
            patMedOperation.setInhospno(externalInHospPatientInfo.getBingAnHao());
            patMedOperation.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
            patMedOperation.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
@@ -705,7 +790,7 @@
                ExternalOperationDetail info = new ExternalOperationDetail();
                info.setShouShuMCID((String) map.get("ShouShuMCID"));
                info.setShouShuMC((String) map.get("ShouShuMC"));
                info.setZhuShouSBZ((String) map.get("ZhuShouSBZ"));
                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"));
@@ -760,9 +845,12 @@
            }
        }
        PatArchive patArchive = new PatArchive();
        //如果是刚出生的小孩子,是没有身份证的,怎么处理????????
        patArchive.setIdcardno(externalInHospPatientInfo.getZhengJianHM());
        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(parse);
        patArchive.setPatidHis(externalInHospPatientInfo.getBingRenID());
@@ -796,21 +884,18 @@
        }
        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.getBingAnHao());
        patArchive.setIdcardtype(externalInHospPatientInfo.getZhengJianLXMC());
        patArchive.setUpdateTime(new Date());
        if (CollectionUtils.isNotEmpty(patArchives)) {
            //如果不为空,直接将查询出来的对象返回
            PatArchive patArchive1 = patArchives.get(0);
            String orgid = patArchive1.getOrgid();
            if (StringUtils.isNotEmpty(orgid)) {
                patArchive.setUpdateTime(new Date());
                patArchive.setId(patArchive1.getId());
                patArchiveMapper.updatePatArchive(patArchive);
            }
@@ -844,10 +929,12 @@
    //新增患者入院信息
    private Boolean addPadInhospInfo(ExternalInHospPatientInfo externalInHospPatientInfo, PatArchive patArchive, ExternalInHospPatientDiagnoseInfo externalInHospPatientDiagnoseInfo) {
        PatMedInhosp patMedInhosp = new PatMedInhosp();
        List<PatMedInhosp> patMedInhospList = null;
        if (ObjectUtils.isNotEmpty(externalInHospPatientInfo)) {
            //医院那边说要用病案号,不要用住院号
            patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao());
            patMedInhosp.setSerialnum(externalInHospPatientInfo.getZhuYuanHao());
            patMedInhosp.setSerialnum(externalInHospPatientInfo.getJiuZhenYWID());
            patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp);
            patMedInhosp.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
            patMedInhosp.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
            patMedInhosp.setStarttime(externalInHospPatientInfo.getRuYuanSJ());
@@ -867,11 +954,18 @@
            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());
        }
        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.getZhenDuanID());
            patMedInhosp.setDiagname(externalInHospPatientDiagnoseInfo.getZhenDuanMC());
        }
        if (ObjectUtils.isNotEmpty(patArchive)) {
@@ -880,9 +974,17 @@
            patMedInhosp.setPatname(patArchive.getName());
            patMedInhosp.setSchemestatus(1L);
            patMedInhosp.setCreateTime(new Date());
        }
        int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp);
        int i = 1;
        if (CollectionUtils.isNotEmpty(patMedInhospList)) {
            patMedInhosp.setUpdateTime(new Date());
            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;
    }
@@ -1011,6 +1113,9 @@
            case "JG_ZZ_YiLiaoZYS":
                log.error("医疗组医生为:{}", type);
                return addMedicalTeam(dataMap);
            case "JZ_ZY_RuKe":
                log.error("入科的数据为:{}", type);
                return addInDeptInfo(dataMap);
        }
        return true;
    }