liusheng
5 天以前 4bb2588c5579d43ae5d343c7343a425a80b02d6c
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -3,6 +3,7 @@
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.*;
@@ -55,9 +56,17 @@
    @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;
@@ -238,6 +247,7 @@
        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());
@@ -254,6 +264,56 @@
    }
    @Override
    public Boolean addInDeptInfo(Map dataMap) {
        log.error("ServiceExternalServiceImpl---addInDeptInfo的新增的值为:{}", dataMap);
        Map yeWuXX = (Map) dataMap.get("YeWuXX");
        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.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.error("ServiceExternalServiceImpl---cancelInHospInfo的新增的值为:{}", dataMap);
        Map yeWuXX = (Map) dataMap.get("YeWuXX");
@@ -261,6 +321,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 +394,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());
@@ -388,11 +450,13 @@
                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(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.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");
@@ -410,7 +474,140 @@
                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());
            patMedInhosp1.setCreateTime(new Date());
            int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1);
            if (i != 1) return false;
        }
        return true;
    }
    @Override
    public Boolean addOutHospJLInfo(Map dataMap) {
        log.error("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;
        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);
        }
        PatMedInhosp patMedInhosp1 = new PatMedInhosp();
        if (CollectionUtils.isNotEmpty(patMedInhospList)) patMedInhosp1 = patMedInhospList.get(0);
        patMedInhosp1.setSchemestatus(2L);
        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();
                }
            }
            try {
                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(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());
@@ -430,6 +627,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());
@@ -439,12 +637,183 @@
            Map<String, Object> JiuZhenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JiuZhenXX") : null;
            PatMedInhosp patMedInhosp1 = patMedInhospList.get(0);
            patMedInhosp1.setSchemestatus(4L);
            //需要将出院状态改成在院
            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.error("需要移除的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.error("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;
@@ -456,6 +825,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 +846,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 +861,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 +873,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 +891,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;
        }
@@ -543,8 +927,8 @@
        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 {
@@ -561,7 +945,7 @@
        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());
@@ -571,19 +955,26 @@
        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);
        } else {
            int i = sysDeptMapper.updateDept(sysDept);
            log.error("ServiceExternalServiceImpl---addWardAreaInfo是否修改成功:{}", i);
        }
        return true;
    }
    @Override
    public Boolean addMedicalTeam(Map dataMap) {
        log.error("ServiceExternalServiceImpl---addMedicalTeam的新增的值为:{}", dataMap);
        return true;
    }
@@ -662,7 +1053,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());
@@ -698,7 +1089,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"));
@@ -753,9 +1144,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());
@@ -789,15 +1183,13 @@
        }
        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.setCreateTime(new Date());
        patArchive.setIdcardtype(externalInHospPatientInfo.getZhengJianLXMC());
        patArchive.setUpdateTime(new Date());
        if (CollectionUtils.isNotEmpty(patArchives)) {
            //如果不为空,直接将查询出来的对象返回
            PatArchive patArchive1 = patArchives.get(0);
@@ -807,6 +1199,7 @@
                patArchiveMapper.updatePatArchive(patArchive);
            }
        } else {
            patArchive.setCreateTime(new Date());
            patArchiveMapper.insertPatArchiveSingle(patArchive);
        }
        //新属信息
@@ -835,10 +1228,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());
@@ -846,7 +1241,8 @@
            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());
@@ -858,11 +1254,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.getIcd10());
            patMedInhosp.setDiagname(externalInHospPatientDiagnoseInfo.getZhenDuanMC());
        }
        if (ObjectUtils.isNotEmpty(patArchive)) {
@@ -871,9 +1274,17 @@
            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;
    }
@@ -897,6 +1308,216 @@
//            int i = iServiceSubtaskService.insertServiceSubtask(serviceSubtask);
//            log.error("ServiceExternalServiceImpl---addWardAreaInfo是否修改成功:{}", i);
//        }
        return true;
    }
    //检查申请服务
    @Override
    public Boolean addInspectService(Map dataMap) {
        log.error("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.error("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;
    }
@@ -931,22 +1552,25 @@
                return true;
            case "JC_SQ_ShenQing":
                log.error("检查申请单入参类型为:{}", type);
                return true;
                return addInspectService(dataMap);
            case "JC_SQ_XiuGai":
                log.error("检查申请信息更新入参类型为:{}", type);
                return true;
                return addInspectService(dataMap);
            case "JC_SQ_CheXiao":
                log.error("检查撤销入参类型为:{}", type);
                return true;
            case "JC_BG_BaoGao":
                log.error("检查报告入参类型为:{}", type);
                return addInspectBGService(dataMap);
            case "JY_SQ_ShenQing":
                log.error("检验申请入参类型为:{}", type);
                return true;
                return addInspectService(dataMap);
            case "JY_SQ_CheXiao":
                log.error("检验撤销入参类型为:{}", type);
                return true;
            case "JY_SQ_XiuGai":
                log.error("检验修改入参类型为辅:{}", type);
                return true;
                return addInspectService(dataMap);
            case "JY_SQ_BiaoBenCJ":
                log.error("检验标本采集入参类型为:{}", type);
                return true;
@@ -993,12 +1617,24 @@
            case "JZ_ZY_ChuYuan":
                log.error("患者出院入参类型为:{}", type);
                return addOutHospInfo(dataMap);
            case "BL_JL_ChuYuanJL":
                log.error("患者出院记录入参类型为:{}", type);
                return addOutHospJLInfo(dataMap);
            case "JZ_ZY_QuXiaoCY":
                log.error("取消出院入参类型为:{}", type);
                return cancelOutHospInfo(dataMap);
            case "JZ_ZY_YuChuYuan":
                log.error("患者预出院入参类型为:{}", type);
                return addPreOutHospInfo(dataMap);
            case "JG_ZZ_BingQu":
                log.error("病区信息入参类型为辅:{}", type);
                log.error("病区信息入参类型为:{}", type);
                return addWardAreaInfo(dataMap);
            case "JG_ZZ_YiLiaoZYS":
                log.error("医疗组医生为:{}", type);
                return addMedicalTeam(dataMap);
            case "JZ_ZY_RuKe":
                log.error("入科的数据为:{}", type);
                return addInDeptInfo(dataMap);
        }
        return true;
    }