From 003513b047fcae16e2125ff7a59e6d46ad048ce4 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 16 十月 2025 18:03:36 +0800
Subject: [PATCH] 代码提交
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java | 135 ++++++++++++++++++++++++++++++++++++++------
1 files changed, 115 insertions(+), 20 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 4badfac..93ecb1c 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
@@ -13,6 +13,7 @@
import cn.lihu.jh.module.ecg.dal.mysql.appointment.AppointmentMapper;
import cn.lihu.jh.module.ecg.enums.AppointmentTypeEnum;
import cn.lihu.jh.module.ecg.enums.HisCheckCodeEnum;
+import cn.lihu.jh.module.ecg.enums.HisCheckNameEnum;
import cn.lihu.jh.module.ecg.feign.RemoteDataService;
import cn.lihu.jh.module.ecg.service.config.EcgConfigService;
import cn.lihu.jh.module.ecg.service.devrent.ApplicationTemplate;
@@ -20,6 +21,8 @@
import cn.lihu.jh.module.ecg.service.queuesequence.QueueSequenceService;
import cn.lihu.jh.module.ecg.webservice.WebServiceClient;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
@@ -29,12 +32,11 @@
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
import java.util.stream.Collectors;
import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -199,6 +201,29 @@
@Override
public PageResult<AppointmentDO> getAppointmentPage(AppointmentPageReqVO pageReqVO) {
+ //1. 鍏堟牴鎹畃atId鍘绘煡
+ PageResult<AppointmentDO> result = appointmentMapper.selectPage(pageReqVO);
+ log.info("--------------PATID result鐨勫�间负锛歿}", result);
+ if (!result.getList().isEmpty()) {
+ return result;
+ }
+
+ if (StringUtils.isNotEmpty(pageReqVO.getPatId())) {
+ // 2. 鐢� applyNo 鏌ヨ
+ pageReqVO.setApplyNo(pageReqVO.getPatId());
+ pageReqVO.setPatId(null);
+ log.info("------------------ApplyNo pageReqVO鐨勫�间负锛歿}", pageReqVO);
+ result = appointmentMapper.selectPage(pageReqVO);
+ if (!result.getList().isEmpty()) {
+ return result;
+ }
+
+ // 3. 鐢� episodeId 鏌ヨ
+ pageReqVO.setEpisodeId(pageReqVO.getApplyNo());
+ pageReqVO.setPatId(null);
+ pageReqVO.setApplyNo(null);
+ log.info("-----------EpisodeId pageReqVO鐨勫�间负锛歿}", pageReqVO);
+ }
return appointmentMapper.selectPage(pageReqVO);
}
@@ -352,6 +377,23 @@
return null;
}).ifPresent(appointment::setTolerance);
+ // 鍖荤敓寮�鍗曟椂闂�
+ 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("author")).map(author -> (Map<String, Object>) author.get("time")).map(time -> (String) time.get("value")).map(str -> {
+ try {
+ return new SimpleDateFormat("yyyyMMddHHmmss").parse(str);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }).filter(Objects::nonNull).ifPresent(appointment::setDoctorTime);
+
+ //璁剧疆寮�鍗曞尰鐢熷鍚�
+ 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("author")).map(author -> (Map<String, Object>) author.get("assignedEntity")).map(assignedEntity -> (Map<String, Object>) assignedEntity.get("assignedPerson")).map(assignedPerson -> (Map<String, Object>) assignedPerson.get("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::setDoctor);
+
+ //璁剧疆寮�鍗曞尰鐢熺紪鐮�
+ 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("author")).map(author -> (Map<String, Object>) author.get("assignedEntity")).map(assignedEntity -> (Map<String, Object>) assignedEntity.get("id")).map(id -> (Map<String, Object>) id.get("item")).map(item -> (String) item.get("extension")).ifPresent(appointment::setDoctorCode);
+
+
// 璁剧疆鎮h�呮潵婧愮被鍨�
Optional.ofNullable(encounter.get("code")).map(code -> (Map<String, Object>) code).map(code -> (String) code.get("code")).map(Integer::parseInt).ifPresent(appointment::setPatSrc);
@@ -391,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");
@@ -425,11 +452,45 @@
//璁剧疆妫�鏌ョ被鍨�
// String checkType = Optional.ofNullable(dataMap.get("controlActProcess")).map(controlActProcess -> (Map<String, Object>) controlActProcess).map(controlActProcess -> (Map<String, Object>) controlActProcess.get("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("code")).map(code -> (String) code.get("code")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL));
String checkType = 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("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("code")).map(code -> (String) code.get("code")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL));
- if (checkType != null || checkType != "")
- appointment.setBookCheckType(Integer.valueOf(HisCheckCodeEnum.getByCode(checkType.substring(1))));
+ String checkName = 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("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("code")).map(code -> (Map<String, Object>) code.get("displayName")).map(displayName -> (String) displayName.get("value")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL));
+ if (appointment.getPatSrc() != null && appointment.getPatSrc() != 4) {
+ if (checkType != null || checkType != "")
+ appointment.setBookCheckType(Integer.valueOf(HisCheckCodeEnum.getByCode(checkType.substring(1))));
+ } else if (appointment.getPatSrc() != null && appointment.getPatSrc() == 4) {
+ if (StringUtils.isNotEmpty(checkName)) {
+ checkName = checkName.replaceAll("\\s+", "");
+ appointment.setBookCheckType(Integer.valueOf(HisCheckNameEnum.getByName(checkName)));
+ }
+ }
+
+
+ // 璁剧疆绉戝鍜岀梾鍖轰俊鎭�
+ 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());
+ if (ObjectUtils.isNotEmpty(appointmentDO)) return appointmentDO.getId();
+
return createAppointment(saveReqVO);
} catch (Exception e) {
log.error("[handleAppointmentCreate][澶勭悊棰勭害鍒涘缓澶辫触 dataMap({})]", dataMap, e);
@@ -564,6 +625,9 @@
String status = 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("placerGroup")).map(placerGroup -> (Map<String, Object>) placerGroup.get("component2")).map(component2 -> (Map<String, Object>) component2.get("observationRequest")).map(observationRequest -> (Map<String, Object>) observationRequest.get("component1")).map(component1 -> (Map<String, Object>) component1.get("processStep")).map(processStep -> (Map<String, Object>) processStep.get("code")).map(code -> (String) code.get("code")).orElseThrow(() -> exception(APPOINTMENT_CREATE_FAIL));
existingAppointment.setStatus(status);
+ if ("3".equals(status)) {
+ existingAppointment.setRegisterDate(new Date());
+ }
// 灏咥ppointmentDO杞崲涓篈ppointmentSaveReqVO骞舵洿鏂�
AppointmentSaveReqVO updateReqVO = BeanUtils.toBean(existingAppointment, AppointmentSaveReqVO.class);
updateAppointment(updateReqVO);
@@ -643,6 +707,37 @@
appointmentMapper.updateById(appointment);
}
+ @Override
+ public void handleAppointmentStatusUpdate(Map<String, Object> dataMap) {
+ if (dataMap == null) {
+ throw exception(APPOINTMENT_STATUS_REGISTER_UPDATE_FAIL);
+ }
+ //鑾峰彇applyNo
+ Map<String, Object> controlActProcess = (Map<String, Object>) dataMap.get("controlActProcess");
+ Map<String, Object> subject = (Map<String, Object>) controlActProcess.get("subject");
+ Map<String, Object> placerGroup = (Map<String, Object>) subject.get("placerGroup");
+ Map<String, Object> component2 = (Map<String, Object>) placerGroup.get("component2");
+ Map<String, Object> observationRequest = (Map<String, Object>) component2.get("observationRequest");
+ Map<String, Object> id = (Map<String, Object>) observationRequest.get("id");
+ Map<String, Object> item = (Map<String, Object>) id.get("item");
+ String applyNo = (String) item.get("extension");
+
+ //鑾峰彇status
+ Map<String, Object> component1 = (Map<String, Object>) observationRequest.get("component1");
+ Map<String, Object> processStep = (Map<String, Object>) component1.get("processStep");
+ Map<String, Object> codeMap = (Map<String, Object>) processStep.get("code");
+ String status = String.valueOf(codeMap.get("code"));
+ Date date = null;
+ if (status.equals("3")) {
+ //璁板綍鐧昏鏃堕棿
+ date = new Date();
+ }
+ //鐘舵�佹洿鏂�
+ Integer i = appointmentMapper.updateStatusByApplyNo(applyNo, status, date);
+ log.info("鐢宠鍗曠櫥璁癮pplyNo:{},鐘舵�乻tatus:{},鏇存柊缁撴灉锛歿}", applyNo, status, i);
+
+ }
+
public AppointmentDO getByApplyNo(String applyNo) {
return appointmentMapper.getByApplyNo(applyNo);
}
--
Gitblit v1.9.3