From 284df1b9b053dc036004ed9dc5a941a238164efc Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 03 九月 2026 11:04:28 +0800
Subject: [PATCH] 【丽水】缙云二院 住院记录不更新状态

---
 smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java |   52 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 38 insertions(+), 14 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 343276d..e4fa9a8 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -18,6 +18,7 @@
 import com.smartor.service.IServiceExternalService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -815,10 +816,16 @@
             patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
         }
 
-        patMedInhosp1.setInhospstate("1");
+        String orgid = ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null;
+        if(StringUtils.isNotEmpty(orgid) && orgid.equals("47246103233112211A1001")){
+            //缂欎簯浜岄櫌 浣忛櫌璁板綍涓嶆洿鏂扮姸鎬�
+        }else {
+            patMedInhosp1.setInhospstate("1");
+        }
+
         if (CollectionUtils.isNotEmpty(patMedInhospList)) {
             patMedInhosp1.setUpdateTime(new Date());
-            patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null);
+            patMedInhosp1.setOrgid(orgid);
             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) {
                 //涓嶉渶瑕侀暱鏈熶换鍔¢殢璁�
                 patMedInhosp1.setFuflag("0");
@@ -831,7 +838,7 @@
                 patMedInhosp1.setHospitalcode(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null);
                 patMedInhosp1.setLeavehospitaldistrictname(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQMC")) ? BingRenXX.get("DangQianBQMC").toString() : null);
                 patMedInhosp1.setLeavehospitaldistrictcode(ObjectUtils.isNotEmpty(BingRenXX.get("DangQianBQID")) ? BingRenXX.get("DangQianBQID").toString() : null);
-                patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null);
+                patMedInhosp1.setOrgid(orgid);
                 //涓芥按鏃犻櫌鍖猴紝榛樿鍊兼槸 1
                 patMedInhosp1.setCampusid("1");
                 patMedInhosp1.setPatno(ObjectUtils.isNotEmpty(BingRenXX.get("BingRenID")) ? BingRenXX.get("BingRenID").toString() : null);
@@ -1164,7 +1171,7 @@
         List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthospreq);
         for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
             PatArchive pa = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
-            if (patArchive.getBirthdate() != null) {
+            if (ObjectUtils.isNotEmpty(patArchive) && patArchive.getBirthdate() != null) {
                 Map<String, String> map = calculateAge(pa.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now());
                 pa.setAge(ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null);
                 pa.setAgeUnit(map.get("ageUnit"));
@@ -1242,10 +1249,22 @@
             i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp);
 
         }
-        Date adminDate = externalJZInfo.getJiuZhenRQ();
+        Date adminDate = patMedOuthosp.getAdmitdate();
         //瀹屾垚鎺ヨ瘖 宸茬粡瀹屾垚浠诲姟鍐嶆闅忚
-        if(ObjectUtils.isNotEmpty(visitTimeNum) && ObjectUtils.isNotEmpty(adminDate)){
-            patMedOuthospService.followUpAgainByPatMedOuthosp(patMedOuthosp, adminDate, visitTimeNum);
+        if(ObjectUtils.isNotEmpty(visitTimeNum)
+                && ObjectUtils.isNotEmpty(adminDate)
+                && StringUtils.isNotEmpty(patMedOuthosp.getFuflag())
+                && patMedOuthosp.getFuflag().equals("1")){
+            if(visitTimeUnit.equals("澶�")){
+                visitTimeNum = visitTimeNum;
+            }else if(visitTimeUnit.equals("鍛�")){
+                visitTimeNum = visitTimeNum * 7;
+            }else if(visitTimeUnit.equals("鏈�")){
+                visitTimeNum = visitTimeNum * 30;
+            }else if(visitTimeUnit.equals("骞�")){
+                visitTimeNum = visitTimeNum * 365;
+            }
+            patMedOuthospService.dealPatMedOuthosp(patMedOuthosp, visitTimeNum);
         }
 
         if (i > 0) {
@@ -1337,7 +1356,6 @@
         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, null, null);
 
-
         //鎵嬫湳淇℃伅鏂板
         Map<String, Object> ssxx = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ShouShuSQ") : null;
         //鎵嬫湳鏇存柊
@@ -1353,12 +1371,6 @@
             externalOperationInfo = BeanUtil.mapToBean(sscx, ExternalOperationInfo.class, true);
         PatMedOperation patMedOperation = new PatMedOperation();
         patMedOperation.setPatid(patArchive.getId());
-        patMedOperation.setPatcode(externalInHospPatientInfo.getBingRenID());
-        patMedOperation.setPaname(externalInHospPatientInfo.getXingMing());
-        patMedOperation.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID());
-        patMedOperation.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC());
-        patMedOperation.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
-        patMedOperation.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
         patMedOperation.setOpreqcode(externalOperationInfo.getShenQingDID());
         //鏌ヨ涓�涓嬶紝璇ユ偅鑰呮槸鍚﹀凡缁忔湁杩欎簺鏁版嵁
         List<PatMedOperation> patMedOperations = patMedOperationMapper.selectPatMedOperationList(patMedOperation);
@@ -1413,6 +1425,13 @@
             patMedOperation.setInhospno(externalInHospPatientInfo.getBingAnHao());
             patMedOperation.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
             patMedOperation.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
+
+            patMedOperation.setPatcode(externalInHospPatientInfo.getBingRenID());
+            patMedOperation.setPaname(externalInHospPatientInfo.getXingMing());
+            patMedOperation.setLeaveldeptcode(externalInHospPatientInfo.getDangQianKSID());
+            patMedOperation.setLeaveldeptname(externalInHospPatientInfo.getDangQianKSMC());
+            patMedOperation.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
+            patMedOperation.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
         }
         patMedOperation.setHospitaldistrictcode(null);
         patMedOperation.setHospitaldistrictname(null);
@@ -1457,6 +1476,10 @@
                 return info;
             }).collect(Collectors.toList()) : null;
 
+            if(ObjectUtils.isNotEmpty(patMedOperation.getId())){
+                patMedOperationItemMapper.deleteHardPatMedOperationItemByOpId(patMedOperation.getId().toString());
+            }
+
             //addMianTableFalg鏄惁闇�瑕佸皢涓绘墜鏈殑淇℃伅鏀惧埌PatMedOperation琛ㄤ腑锛堝彧鏈夌涓�涓富鎵嬫湳淇℃伅闇�瑕佹斁锛屽悗闈㈢殑閮戒笉闇�瑕佹斁浜嗭紝涔熷氨鏄锛岀涓�涓斁瀹屽悗锛屽氨瑕佹妸杩欎釜flag鏀规垚false锛�
             Boolean addMianTableFalg = true;
             for (ExternalOperationDetail externalOperationDetail : externalOperationDetails) {
@@ -1490,6 +1513,7 @@
                     addMianTableFalg = false;
                 }
                 patMedOperationItem.setCreateTime(new Date());
+                patMedOperationItem.setUpdateTime(new Date());
                 patMedOperationItemMapper.insertPatMedOperationItem(patMedOperationItem);
             }
         }

--
Gitblit v1.9.3