From 30b4fe30d36b48a103b281aff631fc45af849636 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 18 三月 2025 16:58:59 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java |  153 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 111 insertions(+), 42 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
index c20ac7b..1557d47 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -265,40 +265,100 @@
         log.error("ServiceExternalServiceImpl---addOutHospInfo鐨勬柊澧炵殑鍊间负锛歿}", dataMap);
         Map yeWuXX = (Map) dataMap.get("YeWuXX");
         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX");
+        List<HashMap<String, Object>> epai = (List<HashMap<String, Object>>) BingRenXX.get("DiZhiXXList");
+        List<HashMap<String, Object>> epli = (List<HashMap<String, Object>>) yeWuXX.get("LianXiRList");
         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);
+        //鏂板鎮h�呭熀鏈俊鎭柊澧炴垨淇敼
+        PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo);
 
         PatMedInhosp patMedInhosp = new PatMedInhosp();
         patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp);
-        if (CollectionUtils.isNotEmpty(patMedInhospList)) {
-            Map<String, Object> JiuZhenXX = (Map<String, Object>) yeWuXX.get("JiuZhenXX");
-            PatMedInhosp patMedInhosp1 = patMedInhospList.get(0);
-            patMedInhosp1.setSchemestatus(2L);
-            try {
-                patMedInhosp1.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(JiuZhenXX.get("ChuYuanSJ").toString()));
-            } catch (ParseException e) {
-                e.printStackTrace();
-            }
-            patMedInhosp1.setOperator(JiuZhenXX.get("CaoZuoRXM").toString());
-            patMedInhosp1.setOperatorId(JiuZhenXX.get("CaoZuoRID").toString());
-            patMedInhosp1.setUpdateTime(new Date());
-            patMedInhosp1.setUpdateTime(new Date());
 
-            patMedInhosp1.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
-            patMedInhosp1.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
-            patMedInhosp1.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC());
-            patMedInhosp1.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID());
-            List<HashMap<String, Object>> zhenDuanList = (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList");
-            List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = zhenDuanList.stream().map(map -> {
-                ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo();
-                info.setZhenDuanID((String) map.get("ZhenDuanID"));
-                info.setZhenDuanMC((String) map.get("ZhenDuanMC"));
-                return info;
-            }).collect(Collectors.toList());
-            patMedInhosp1.setLeaveicd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeaveicd10code()) ? patMedInhosp1.getLeaveicd10code() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanID() : hospPatientDiagnoseInfos2.get(0).getZhenDuanID());
-            patMedInhosp1.setLeavediagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
-            patMedInhosp1.setInhospstate("1");
+        Map<String, Object> JiuZhenXX = (Map<String, Object>) yeWuXX.get("JiuZhenXX");
+        PatMedInhosp patMedInhosp1 = new PatMedInhosp();
+        if (CollectionUtils.isNotEmpty(patMedInhospList)) patMedInhosp1 = patMedInhospList.get(0);
+        patMedInhosp1.setSchemestatus(2L);
+        try {
+            patMedInhosp1.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(JiuZhenXX.get("ChuYuanSJ").toString()));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        patMedInhosp1.setOperator(JiuZhenXX.get("CaoZuoRXM").toString());
+        patMedInhosp1.setOperatorId(JiuZhenXX.get("CaoZuoRID").toString());
+        patMedInhosp1.setUpdateTime(new Date());
+        patMedInhosp1.setTelcode(patArchive.getTelcode());
+        patMedInhosp1.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
+        patMedInhosp1.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
+        patMedInhosp1.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC());
+        patMedInhosp1.setDeptname(externalInHospPatientInfo.getDangQianKSMC());
+        patMedInhosp1.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID());
+        patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID());
+        List<HashMap<String, Object>> zhenDuanList = (List<HashMap<String, Object>>) yeWuXX.get("ZhenDuanList");
+        List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = zhenDuanList.stream().map(map -> {
+            ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo();
+            info.setZhenDuanID((String) map.get("ZhenDuanID"));
+            info.setZhenDuanMC((String) map.get("ZhenDuanMC"));
+            return info;
+        }).collect(Collectors.toList());
+        patMedInhosp1.setLeaveicd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeaveicd10code()) ? patMedInhosp1.getLeaveicd10code() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanID() : hospPatientDiagnoseInfos2.get(0).getZhenDuanID());
+        patMedInhosp1.setLeavediagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
+        patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
+        patMedInhosp1.setIcd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
+        patMedInhosp1.setInhospstate("1");
+        if (CollectionUtils.isNotEmpty(patMedInhospList)) {
+            patMedInhosp1.setUpdateTime(new Date());
+            patMedInhosp1.setOrgid(BingRenXX.get("ZuZhiJGID").toString());
             int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
+            if (i != 1) return false;
+        } else {
+            patMedInhosp1.setHospitalname(BingRenXX.get("ZuZhiJGMC").toString());
+            patMedInhosp1.setHospitalcode(BingRenXX.get("ZuZhiJGID").toString());
+            patMedInhosp1.setLeavehospitaldistrictname(BingRenXX.get("DangQianBQMC").toString());
+            patMedInhosp1.setLeavehospitaldistrictcode(BingRenXX.get("DangQianBQID").toString());
+            patMedInhosp1.setPatid(patArchive.getId());
+            patMedInhosp1.setPatname(patArchive.getName());
+            patMedInhosp1.setOrgid(BingRenXX.get("ZuZhiJGID").toString());
+            patMedInhosp1.setPatno(BingRenXX.get("BingRenID").toString());
+            patMedInhosp1.setInhospno(BingRenXX.get("ZhuYuanHao").toString());
+            patMedInhosp1.setSerialnum(BingRenXX.get("BingAnHao").toString());
+            patMedInhosp1.setCreateTime(new Date());
+            int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1);
             if (i != 1) return false;
         }
         return true;
@@ -377,6 +437,7 @@
                 patMedOuthosp.setIcd10code(externalDiagnosisInfo.getZhenDuanID());
                 patMedOuthosp.setDrcode(externalDiagnosisInfo.getZhenDuanYSID());
                 patMedOuthosp.setDrname(externalDiagnosisInfo.getZhenDuanYSXM());
+                patMedOuthosp.setIcd10code(externalDiagnosisInfo.getIcd10());
             }
         }
         for (ExternalWZInfo externalWZInfo : ExternalWZInfoList) {
@@ -405,19 +466,23 @@
         String FaSongJGID = XiaoXiTou.get("FaSongJGID").toString();
         Icd10 icd10 = new Icd10();
         icd10.setIcdcode(externalDiseaseInfo.getIcD10());
+        icd10.setDelFlag("0");
+        icd10.setOrgid(FaSongJGID);
+        //閫氳繃icdCode鏌ヨ涓�涓嬶紝鏄惁瀛樺湪
+        List<Icd10> icd10s = icd10Mapper.selectIcd10List(icd10);
         icd10.setHisIcdid(externalDiseaseInfo.getJiBingID());
         icd10.setIcdname(externalDiseaseInfo.getJiBingMC());
         icd10.setGuid(externalDiseaseInfo.getZuZhiJGID());
         icd10.setLastflag(externalDiseaseInfo.getMOJIBZ());
         icd10.setChimedflag("" + externalDiseaseInfo.getZhongYiZDBZ());
-        icd10.setOrgid(FaSongJGID);
-//        icd10Association.setIcd10AssortName(externalDiseaseInfo.getJiBingFLMC());
-//        icd10Association.setChineseMedicineDiagnoseSign(externalDiseaseInfo.getZhongYiZDBZ());
-//        icd10Association.setChineseMedicineDiagnoseAssortCode(externalDiseaseInfo.getZhongYiZDFLDM());
-//        icd10Association.setChineseMedicineDiagnoseAssortName(externalDiseaseInfo.getZhongYiZDFLMC());
-//        icd10Association.setOutpatientUseAssort(externalDiseaseInfo.getMenZhenSYBZ());
-//        icd10Association.setInpatientUseAssort(externalDiseaseInfo.getZhuYuanSYBZ());
-        icd10Mapper.insertIcd10(icd10);
+        if (CollectionUtils.isNotEmpty(icd10s)) {
+            icd10.setUpdateTime(new Date());
+            icd10.setIcdid(icd10s.get(0).getIcdid());
+            icd10Mapper.updateIcd10(icd10);
+        } else {
+            icd10.setCreateTime(new Date());
+            icd10Mapper.insertIcd10(icd10);
+        }
         return true;
     }
 
@@ -586,8 +651,10 @@
     private PatArchive addPatArchive(ExternalInHospPatientInfo externalInHospPatientInfo, ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo, ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo) {
         PatArchive patArchive = new PatArchive();
         patArchive.setIdcardno(externalInHospPatientInfo.getZhengJianHM());
+        patArchive.setOrgid(externalInHospPatientInfo.getZuZhiJGID());
         List<PatArchive> patArchives = patArchiveMapper.selectPatArchiveList(patArchive);
         patArchive.setPatientno(externalInHospPatientInfo.getJiuZhenKH());
+        patArchive.setBirthdate(externalInHospPatientInfo.getChuShengRQ());
         patArchive.setPatidHis(externalInHospPatientInfo.getBingRenID());
         patArchive.setSourcefrom(1);
         patArchive.setPattype("2");
@@ -597,10 +664,14 @@
         patArchive.setNation(externalInHospPatientInfo.getMinZuMC());
         patArchive.setNativePlace(externalInHospPatientInfo.getGuoJiMC());
         if (ObjectUtils.isNotEmpty(externalInHospPatientAddrInfo)) {
-            String por = externalInHospPatientAddrInfo.getShengFenMC() + externalInHospPatientAddrInfo.getShiDiQMC() + externalInHospPatientAddrInfo.getXianQuMC() + externalInHospPatientAddrInfo.getXiangZhenMC() + externalInHospPatientAddrInfo.getCunJiMC() + externalInHospPatientAddrInfo.getQiTaXX();
-            patArchive.setPlaceOfResidence(por.replace(null, ""));
-            String bp = externalInHospPatientAddrInfo.getShengFenMC() + externalInHospPatientAddrInfo.getShiDiQMC() + externalInHospPatientAddrInfo.getXianQuMC() + externalInHospPatientAddrInfo.getXiangZhenMC() + externalInHospPatientAddrInfo.getCunJiMC() + externalInHospPatientAddrInfo.getQiTaXX();
-            patArchive.setBirthplace(bp.replace(null, ""));
+            String por = null;
+            if (StringUtils.isNotEmpty(externalInHospPatientAddrInfo.getDiZhiXX())) {
+                por = externalInHospPatientAddrInfo.getDiZhiXX();
+            } else {
+                por = externalInHospPatientAddrInfo.getShengFenMC() + externalInHospPatientAddrInfo.getShiDiQMC() + externalInHospPatientAddrInfo.getXianQuMC() + externalInHospPatientAddrInfo.getXiangZhenMC() + externalInHospPatientAddrInfo.getCunJiMC() + externalInHospPatientAddrInfo.getQiTaXX();
+            }
+            patArchive.setPlaceOfResidence(por.replace("null", ""));
+            patArchive.setBirthplace(por.replace("null", ""));
         }
         patArchive.setBirthdate(externalInHospPatientInfo.getChuShengRQ());
         patArchive.setAge(externalInHospPatientInfo.getNianLing());
@@ -610,18 +681,16 @@
             patArchive.setTelcode(externalInHospPatientInfo.getLianXiRDH());
         patArchive.setRelativetelcode(externalInHospPatientInfo.getLianXiRDH());
         patArchive.setGuid(externalInHospPatientInfo.getZuZhiJGID());
-        patArchive.setOrgid(externalInHospPatientInfo.getZuZhiJGID());
         if (ObjectUtils.isNotEmpty(externalInHospPatientLiaisonInfo))
             patArchive.setRelativetelcode(externalInHospPatientLiaisonInfo.getLianXiRDH());
         patArchive.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
         patArchive.setCreateTime(new Date());
+        patArchive.setIdcardtype(externalInHospPatientInfo.getZhengJianLXMC());
         if (CollectionUtils.isNotEmpty(patArchives)) {
             //濡傛灉涓嶄负绌猴紝鐩存帴灏嗘煡璇㈠嚭鏉ョ殑瀵硅薄杩斿洖
             PatArchive patArchive1 = patArchives.get(0);
             String orgid = patArchive1.getOrgid();
             if (StringUtils.isNotEmpty(orgid)) {
-                orgid = orgid + "," + externalInHospPatientInfo.getZuZhiJGID();
-                patArchive.setOrgid(orgid);
                 patArchive.setId(patArchive1.getId());
                 patArchiveMapper.updatePatArchive(patArchive);
                 return patArchive;

--
Gitblit v1.9.3