From 9ad12f4a3cbf1fc5bb2ef5a76a371064afac62fc Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 24 十月 2025 11:48:37 +0800
Subject: [PATCH] 新增日志

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java |   48 +++++++++++++++++++++++++++---------------------
 1 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java
index cdd312e..745b77d 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java
@@ -433,21 +433,6 @@
                 Optional.ofNullable(patientPerson.get("id")).map(id -> (Map<String, Object>) id).map(id -> (List<?>) id.get("item")).filter(items -> !items.isEmpty()).map(items -> (Map<String, Object>) items.get(1)).map(item -> (String) item.get("extension")).ifPresent(appointment::setMedicalCard);
             });
 
-            // 璁剧疆绉戝鍜岀梾鍖轰俊鎭�
-            Optional.ofNullable(encounter.get("location")).map(location -> (Map<String, Object>) location).map(location -> (Map<String, Object>) location.get("serviceDeliveryLocation")).map(location -> (Map<String, Object>) location.get("serviceProviderOrganization")).ifPresent(org -> {
-                // 璁剧疆绉戝浠g爜鍜屽悕绉�
-                Optional.ofNullable(org.get("id")).map(id -> (Map<String, Object>) id).map(id -> (Map<String, Object>) id.get("item")).map(item -> (String) item.get("extension")).ifPresent(appointment::setPatDeptCode);
-
-                Optional.ofNullable(org.get("name")).map(name -> (Map<String, Object>) name).map(name -> (Map<String, Object>) name.get("item")).map(item -> (Map<String, Object>) item.get("part")).map(part -> (String) part.get("value")).ifPresent(appointment::setPatDeptDesc);
-
-                // 璁剧疆鐥呭尯浠g爜鍜屽悕绉�
-                Optional.ofNullable(org.get("asOrganizationPartOf")).map(wardOrg -> (Map<String, Object>) wardOrg).map(wardOrg -> (Map<String, Object>) wardOrg.get("wholeOrganization")).ifPresent(wardOrg -> {
-                    Optional.ofNullable(wardOrg.get("id")).map(id -> (Map<String, Object>) id).map(id -> (Map<String, Object>) id.get("item")).map(item -> (String) item.get("extension")).ifPresent(appointment::setPatWardCode);
-
-                    Optional.ofNullable(wardOrg.get("name")).map(name -> (Map<String, Object>) name).map(name -> (Map<String, Object>) name.get("item")).map(item -> (Map<String, Object>) item.get("part")).map(part -> (String) part.get("value")).ifPresent(appointment::setPatWardDesc);
-                });
-            });
-
             // 璁剧疆鏀粯鐘舵��
             Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("zdy")).map(zdy -> {
                 Object payStatus = zdy.get("PayStatus");
@@ -479,8 +464,34 @@
             }
 
 
+            // 璁剧疆绉戝鍜岀梾鍖轰俊鎭�
+            Optional.ofNullable(encounter.get("location")).map(location -> (Map<String, Object>) location).map(location -> (Map<String, Object>) location.get("serviceDeliveryLocation")).map(location -> (Map<String, Object>) location.get("serviceProviderOrganization")).ifPresent(org -> {
+                // 璁剧疆绉戝浠g爜鍜屽悕绉�
+                Optional.ofNullable(org.get("id")).map(id -> (Map<String, Object>) id).map(id -> (Map<String, Object>) id.get("item")).map(item -> (String) item.get("extension")).ifPresent(appointment::setPatDeptCode);
+
+                Optional.ofNullable(org.get("name")).map(name -> (Map<String, Object>) name).map(name -> (Map<String, Object>) name.get("item")).map(item -> (Map<String, Object>) item.get("part")).map(part -> (String) part.get("value")).ifPresent(appointment::setPatDeptDesc);
+
+                // 璁剧疆鐥呭尯浠g爜鍜屽悕绉�
+                Optional.ofNullable(org.get("asOrganizationPartOf")).map(wardOrg -> (Map<String, Object>) wardOrg).map(wardOrg -> (Map<String, Object>) wardOrg.get("wholeOrganization")).ifPresent(wardOrg -> {
+                    Optional.ofNullable(wardOrg.get("id")).map(id -> (Map<String, Object>) id).map(id -> (Map<String, Object>) id.get("item")).map(item -> (String) item.get("extension")).ifPresent(appointment::setPatWardCode);
+                    if (appointment.getPatSrc() != null && appointment.getPatSrc() == 4) {
+                        //浣撴灏辫繖涓�涓瀹�
+                        appointment.setPatDeptDesc("鍋ュ悍绠$悊涓績");
+                    } else {
+                        Optional.ofNullable(wardOrg.get("name")).map(name -> (Map<String, Object>) name).map(name -> (Map<String, Object>) name.get("item")).map(item -> (Map<String, Object>) item.get("part")).map(part -> (String) part.get("value")).ifPresent(appointment::setPatWardDesc);
+                    }
+                });
+            });
+
+
             // 灏咥ppointmentDO杞崲涓篈ppointmentSaveReqVO骞朵繚瀛�
             AppointmentSaveReqVO saveReqVO = BeanUtils.toBean(appointment, AppointmentSaveReqVO.class);
+
+            //鏍规嵁鐢宠缂栧彿鍏堟煡璇竴涓嬫槸鍚﹀瓨鍦紝濡傛灉瀛樺湪锛屽氨涓嶆柊澧炰簡
+            AppointmentDO appointmentDO = appointmentMapper.getByApplyNo(saveReqVO.getApplyNo());
+            log.info("=======鏄惁鏂板杩囦簡锛歿}", ObjectUtils.isNotEmpty(appointmentDO) ? appointmentDO.getId() : null);
+            if (ObjectUtils.isNotEmpty(appointmentDO)) return appointmentDO.getId();
+
             return createAppointment(saveReqVO);
         } catch (Exception e) {
             log.error("[handleAppointmentCreate][澶勭悊棰勭害鍒涘缓澶辫触 dataMap({})]", dataMap, e);
@@ -628,12 +639,7 @@
      * 浠巇ataMap涓彁鍙杄ncounter鏁版嵁
      */
     private Map<String, Object> extractEncounter(Map<String, Object> dataMap) {
-        return Optional.ofNullable(dataMap.get("controlActProcess"))
-                .map(controlActProcess -> (Map<String, Object>) controlActProcess)
-                .map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject"))
-                .map(subject -> (Map<String, Object>) subject.get("observationRequest"))
-                .map(observationRequest -> (Map<String, Object>) observationRequest.get("componentOf1"))
-                .map(componentOf1 -> (Map<String, Object>) componentOf1.get("encounter")).orElse(null);
+        return Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("subject")).map(subject -> (Map<String, Object>) subject.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("componentOf1")).map(componentOf1 -> (Map<String, Object>) componentOf1.get("encounter")).orElse(null);
     }
 
     @Override

--
Gitblit v1.9.3