From 0b4b63dfbea2d1c4e043faee7980aba06159a63a Mon Sep 17 00:00:00 2001 From: chenqi Date: Wed, 7 Jan 2026 17:00:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(surgery):=20=E5=A2=9E=E5=8A=A0=E6=89=8B?= =?UTF-8?q?=E6=9C=AF=E5=AE=A4=E7=A1=AE=E8=AE=A4=E4=BF=A1=E6=81=AF=E5=92=8C?= =?UTF-8?q?=E6=AC=A1=E8=A6=81=E6=89=8B=E6=9C=AF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加手术室确认时间和确认人字段显示 - 实现次要手术的添加、编辑和删除功能 - 增加急诊标志和植入高值耗材开关选项 - 添加手术费用和麻醉费用计算功能 - 实现手术和麻醉项目的远程搜索功能 - 增加第一助手和第二助手选择功能 - 优化医生列表加载逻辑,支持多接口获取 - 添加按钮图标提升界面体验 - 修复encounterId为空时的接口调用问题 --- add_new_fields_to_cli_surgery.sql | 11 + .../impl/SurgeryAppServiceImpl.java | 135 ++++- .../web/clinicalmanage/dto/SurgeryDto.java | 19 +- .../mapper/clinical/SurgeryMapper.xml | 10 +- .../mapper/clinicalmanage/SurgeryMapper.xml | 12 +- .../com/openhis/common/utils/RedisKeys.java | 27 + .../com/openhis/clinical/domain/Surgery.java | 16 + .../service/impl/SurgeryServiceImpl.java | 166 +++++- .../src/views/doctorstation/components/api.js | 11 + .../inspection/inspectionApplication.vue | 17 + .../components/surgery/surgeryApplication.vue | 562 ++++++++++++++++-- .../components/tcm/tcmAdvice.vue | 19 + .../applicationShow/surgeryApplication.vue | 4 +- .../src/views/surgerymanage/index.vue | 79 ++- 手术和麻醉信息Redis缓存实现说明.md | 120 ++++ 检查surgery_indication字段.sql | 25 + .../20260105_fill_surgery_name_fields.sql | 114 ++++ .../20260106_check_and_add_surgery_indication.sql | 53 ++ 验证手术指征字段返回数据.sql | 59 ++ 19 files changed, 1368 insertions(+), 91 deletions(-) create mode 100644 add_new_fields_to_cli_surgery.sql create mode 100644 手术和麻醉信息Redis缓存实现说明.md create mode 100644 检查surgery_indication字段.sql create mode 100644 迁移记录-DB变更记录/20260105_fill_surgery_name_fields.sql create mode 100644 迁移记录-DB变更记录/20260106_check_and_add_surgery_indication.sql create mode 100644 验证手术指征字段返回数据.sql diff --git a/add_new_fields_to_cli_surgery.sql b/add_new_fields_to_cli_surgery.sql new file mode 100644 index 00000000..b96ac0ca --- /dev/null +++ b/add_new_fields_to_cli_surgery.sql @@ -0,0 +1,11 @@ +-- 添加新字段到cli_surgery表 +ALTER TABLE cli_surgery ADD COLUMN emergency_flag int2 DEFAULT 0; +ALTER TABLE cli_surgery ADD COLUMN implant_flag int2 DEFAULT 0; +ALTER TABLE cli_surgery ADD COLUMN operating_room_confirm_time timestamp; +ALTER TABLE cli_surgery ADD COLUMN operating_room_confirm_user varchar(100); + +-- 添加字段注释 +COMMENT ON COLUMN cli_surgery.emergency_flag IS '急诊标志 0-否 1-是'; +COMMENT ON COLUMN cli_surgery.implant_flag IS '植入高值耗材标志 0-否 1-是'; +COMMENT ON COLUMN cli_surgery.operating_room_confirm_time IS '手术室确认时间'; +COMMENT ON COLUMN cli_surgery.operating_room_confirm_user IS '手术室确认人'; \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgeryAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgeryAppServiceImpl.java index b8117afc..2d462e49 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgeryAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgeryAppServiceImpl.java @@ -1,5 +1,6 @@ package com.openhis.web.clinicalmanage.appservice.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -8,6 +9,8 @@ import com.core.common.core.domain.entity.SysUser; import com.core.common.utils.MessageUtils; import com.core.common.utils.SecurityUtils; import com.core.system.service.ISysUserService; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.openhis.administration.domain.ChargeItem; import com.openhis.administration.domain.Encounter; import com.openhis.administration.domain.OperatingRoom; @@ -28,6 +31,8 @@ import com.openhis.common.enums.GenerateSource; import com.openhis.common.enums.RequestStatus; import com.openhis.common.enums.TherapyTimeType; import com.openhis.common.utils.HisQueryUtils; +import com.openhis.common.utils.RedisKeys; +import com.core.common.core.redis.RedisCache; import com.openhis.document.domain.RequestForm; import com.openhis.document.service.IRequestFormService; import com.openhis.web.clinicalmanage.appservice.ISurgeryAppService; @@ -42,9 +47,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashSet; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; import static com.core.framework.datasource.DynamicDataSourceContextHolder.log; @@ -90,8 +94,10 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { @Resource private com.openhis.administration.service.IPractitionerService practitionerService; + @Resource + private RedisCache redisCache; + /** - * 分页查询手术列表 * * @param surgeryDto 查询条件 * @param pageNo 当前页 @@ -115,16 +121,52 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { /** * 根据ID查询手术详情 - * + * * @param id 手术ID * @return 手术详情 */ @Override public R getSurgeryDetail(Long id) { - SurgeryDto surgeryDto = surgeryAppMapper.getSurgeryDetail(id); + String cacheKey = RedisKeys.getSurgeryKey(id); + SurgeryDto surgeryDto = redisCache.getCacheObject(cacheKey); + + // 先从Redis缓存中获取 + if (surgeryDto != null) { + log.info("从Redis缓存中获取手术信息 - surgeryId: {}", id); + return R.ok(surgeryDto); + } + + // 缓存中没有,从数据库查询 + surgeryDto = surgeryAppMapper.getSurgeryDetail(id); if (surgeryDto == null) { return R.fail("手术信息不存在"); } + + // 从申请单中获取次要手术信息 + if (surgeryDto.getSurgeryNo() != null) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RequestForm::getPrescriptionNo, surgeryDto.getSurgeryNo()); + RequestForm requestForm = requestFormService.getOne(queryWrapper); + if (requestForm != null && requestForm.getDescJson() != null) { + try { + Map map = new ObjectMapper().readValue(requestForm.getDescJson(), Map.class); + if (map.containsKey("secondarySurgeries")) { + surgeryDto.setSecondarySurgeries((List>) map.get("secondarySurgeries")); + } + // 增加手术指征的回显兜底(从JSON中加载) + if (map.containsKey("surgeryIndication") && (surgeryDto.getSurgeryIndication() == null || surgeryDto.getSurgeryIndication().isEmpty())) { + surgeryDto.setSurgeryIndication((String) map.get("surgeryIndication")); + } + } catch (Exception e) { + log.error("解析手术申请单JSON失败", e); + } + } + } + + // 将查询结果存入Redis缓存(缓存30分钟) + redisCache.setCacheObject(cacheKey, surgeryDto, 30, java.util.concurrent.TimeUnit.MINUTES); + log.info("从数据库查询手术信息并存入Redis缓存 - surgeryId: {}", id); + return R.ok(surgeryDto); } @@ -287,6 +329,9 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { chargeItem.setTotalPrice(surgeryDto.getTotalFee() != null ? surgeryDto.getTotalFee() : new BigDecimal("0.0")); // 总价 chargeItemService.save(chargeItem); + // 清除相关缓存 + clearSurgeryAppCache(surgery); + return R.ok(surgeryId, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[]{"手术信息"})); } @@ -297,13 +342,24 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { * @return JSON字符串 */ private String buildDescJson(SurgeryDto surgeryDto) { - return String.format( - "{\"surgeryName\":\"%s\",\"surgeryLevel\":\"%s\",\"surgeryIndication\":\"%s\",\"preoperativeDiagnosis\":\"%s\"}", - surgeryDto.getSurgeryName() != null ? surgeryDto.getSurgeryName() : "", - surgeryDto.getSurgeryLevel() != null ? surgeryDto.getSurgeryLevel() : "", - surgeryDto.getSurgeryIndication() != null ? surgeryDto.getSurgeryIndication() : "", - surgeryDto.getPreoperativeDiagnosis() != null ? surgeryDto.getPreoperativeDiagnosis() : "" - ); + Map map = new HashMap<>(); + map.put("surgeryName", surgeryDto.getSurgeryName() != null ? surgeryDto.getSurgeryName() : ""); + map.put("surgeryCode", surgeryDto.getSurgeryCode() != null ? surgeryDto.getSurgeryCode() : ""); + map.put("surgeryLevel", surgeryDto.getSurgeryLevel() != null ? surgeryDto.getSurgeryLevel() : ""); + map.put("surgeryIndication", surgeryDto.getSurgeryIndication() != null ? surgeryDto.getSurgeryIndication() : ""); + map.put("preoperativeDiagnosis", surgeryDto.getPreoperativeDiagnosis() != null ? surgeryDto.getPreoperativeDiagnosis() : ""); + + // 加入次要手术信息 + if (surgeryDto.getSecondarySurgeries() != null && !surgeryDto.getSecondarySurgeries().isEmpty()) { + map.put("secondarySurgeries", surgeryDto.getSecondarySurgeries()); + } + + try { + return new ObjectMapper().writeValueAsString(map); + } catch (JsonProcessingException e) { + log.error("构建手术申请单JSON失败", e); + return "{}"; + } } /** @@ -340,6 +396,21 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { fillSurgeryNameFields(surgery); surgeryService.updateSurgery(surgery); + + // 同步更新申请单中的描述内容 + if (surgery.getSurgeryNo() != null) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RequestForm::getPrescriptionNo, surgery.getSurgeryNo()); + RequestForm requestForm = requestFormService.getOne(queryWrapper); + if (requestForm != null) { + requestForm.setDescJson(buildDescJson(surgeryDto)); + requestFormService.updateById(requestForm); + } + } + + // 清除相关缓存 + clearSurgeryAppCache(surgery); + return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[]{"手术信息"})); } @@ -363,12 +434,16 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { } surgeryService.deleteSurgery(id); + + // 清除相关缓存 + clearSurgeryAppCache(existSurgery); + return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[]{"手术信息"})); } /** * 更新手术状态 - * + * * @param id 手术ID * @param statusEnum 状态 * @return 结果 @@ -382,6 +457,10 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { } surgeryService.updateSurgeryStatus(id, statusEnum); + + // 清除相关缓存 + clearSurgeryAppCache(existSurgery); + return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[]{"手术状态"})); } @@ -504,4 +583,32 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { surgery.getPatientName(), surgery.getMainSurgeonName(), surgery.getAnesthetistName(), surgery.getAssistant1Name(), surgery.getAssistant2Name(), surgery.getScrubNurseName(), surgery.getOperatingRoomName(), surgery.getOrgName()); } + + /** + * 清除手术相关的Redis缓存 + * + * @param surgery 手术信息 + */ + private void clearSurgeryAppCache(Surgery surgery) { + // 清除单个手术缓存 + if (surgery.getId() != null) { + String surgeryKey = RedisKeys.getSurgeryKey(surgery.getId()); + redisCache.deleteObject(surgeryKey); + log.info("清除手术缓存 - surgeryId: {}", surgery.getId()); + } + + // 清除患者手术列表缓存 + if (surgery.getPatientId() != null) { + String patientKey = RedisKeys.getSurgeryListByPatientKey(surgery.getPatientId()); + redisCache.deleteObject(patientKey); + log.info("清除患者手术列表缓存 - patientId: {}", surgery.getPatientId()); + } + + // 清除就诊手术列表缓存 + if (surgery.getEncounterId() != null) { + String encounterKey = RedisKeys.getSurgeryListByEncounterKey(surgery.getEncounterId()); + redisCache.deleteObject(encounterKey); + log.info("清除就诊手术列表缓存 - encounterId: {}", surgery.getEncounterId()); + } + } } \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/SurgeryDto.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/SurgeryDto.java index f8db4228..392e8cc9 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/SurgeryDto.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/SurgeryDto.java @@ -8,6 +8,8 @@ import lombok.experimental.Accessors; import java.math.BigDecimal; import java.util.Date; +import java.util.List; +import java.util.Map; /** * 手术管理DTO @@ -196,4 +198,19 @@ public class SurgeryDto { /** 更新时间 */ private Date updateTime; -} \ No newline at end of file + + /** 急诊标志 */ + private Integer emergencyFlag; + + /** 植入高值耗材标志 */ + private Integer implantFlag; + + /** 手术室确认时间 */ + private Date operatingRoomConfirmTime; + + /** 手术室确认人 */ + private String operatingRoomConfirmUser; + + /** 次要手术列表 */ + private List> secondarySurgeries; +} diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/clinical/SurgeryMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/clinical/SurgeryMapper.xml index ee1001ab..8dddf7c2 100644 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/clinical/SurgeryMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/clinical/SurgeryMapper.xml @@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -50,6 +51,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + @@ -59,9 +64,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" main_surgeon_id, main_surgeon_name, assistant_1_id, assistant_1_name, assistant_2_id, assistant_2_name, anesthetist_id, anesthetist_name, scrub_nurse_id, scrub_nurse_name, anesthesia_type_enum, body_site, incision_level, healing_level, operating_room_id, operating_room_name, - org_id, org_name, preoperative_diagnosis, postoperative_diagnosis, surgery_description, + org_id, org_name, surgery_indication, preoperative_diagnosis, postoperative_diagnosis, surgery_description, postoperative_advice, complications, surgery_fee, anesthesia_fee, total_fee, remark, - create_by, create_time, update_by, update_time, delete_flag + create_by, create_time, update_by, update_time, delete_flag, + emergency_flag, implant_flag, operating_room_confirm_time, operating_room_confirm_user FROM cli_surgery diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/clinicalmanage/SurgeryMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/clinicalmanage/SurgeryMapper.xml index 557ea422..0212b06f 100644 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/clinicalmanage/SurgeryMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/clinicalmanage/SurgeryMapper.xml @@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -62,6 +63,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + @@ -153,6 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ro.name as operating_room_org_name, s.org_id, COALESCE(s.org_name, o.name) as org_name, + s.surgery_indication, s.preoperative_diagnosis, s.postoperative_diagnosis, s.surgery_description, @@ -163,7 +169,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" s.total_fee, s.remark, s.create_time, - s.update_time + s.update_time, + s.emergency_flag, + s.implant_flag, + s.operating_room_confirm_time, + s.operating_room_confirm_user FROM cli_surgery s LEFT JOIN adm_patient p ON s.patient_id = p.id LEFT JOIN adm_encounter e ON s.encounter_id = e.id diff --git a/openhis-server-new/openhis-common/src/main/java/com/openhis/common/utils/RedisKeys.java b/openhis-server-new/openhis-common/src/main/java/com/openhis/common/utils/RedisKeys.java index 359fe80a..3d0a341e 100644 --- a/openhis-server-new/openhis-common/src/main/java/com/openhis/common/utils/RedisKeys.java +++ b/openhis-server-new/openhis-common/src/main/java/com/openhis/common/utils/RedisKeys.java @@ -22,4 +22,31 @@ public class RedisKeys { public static String getProductsKey(String itemId){ return "products_change_price:item_" + itemId + "_key"; } + + /** + * 手术信息缓存 + * @param surgeryId 手术ID + * @return + */ + public static String getSurgeryKey(Long surgeryId){ + return "surgery:info:" + surgeryId; + } + + /** + * 手术列表缓存(按患者ID) + * @param patientId 患者ID + * @return + */ + public static String getSurgeryListByPatientKey(Long patientId){ + return "surgery:patient:" + patientId; + } + + /** + * 手术列表缓存(按就诊ID) + * @param encounterId 就诊ID + * @return + */ + public static String getSurgeryListByEncounterKey(Long encounterId){ + return "surgery:encounter:" + encounterId; + } } diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/domain/Surgery.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/domain/Surgery.java index 327c713f..562c7ec3 100644 --- a/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/domain/Surgery.java +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/domain/Surgery.java @@ -211,4 +211,20 @@ public class Surgery extends HisBaseEntity { /** 备注信息 */ @TableField("remark") private String remark; + + /** 急诊标志 */ + @TableField("emergency_flag") + private Integer emergencyFlag; + + /** 植入高值耗材标志 */ + @TableField("implant_flag") + private Integer implantFlag; + + /** 手术室确认时间 */ + @TableField("operating_room_confirm_time") + private Date operatingRoomConfirmTime; + + /** 手术室确认人 */ + @TableField("operating_room_confirm_user") + private String operatingRoomConfirmUser; } \ No newline at end of file diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/service/impl/SurgeryServiceImpl.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/service/impl/SurgeryServiceImpl.java index e34c3d78..cfd2b832 100644 --- a/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/service/impl/SurgeryServiceImpl.java +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/service/impl/SurgeryServiceImpl.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.openhis.clinical.domain.Surgery; import com.openhis.clinical.mapper.SurgeryMapper; import com.openhis.clinical.service.ISurgeryService; +import com.openhis.common.utils.RedisKeys; +import com.core.common.core.redis.RedisCache; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -14,6 +16,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Random; +import java.util.concurrent.TimeUnit; @Slf4j @Service @@ -22,8 +25,10 @@ public class SurgeryServiceImpl extends ServiceImpl impl @Resource private SurgeryMapper surgeryMapper; + @Resource + private RedisCache redisCache; + /** - * 新增手术信息 * * @param surgery 手术信息 * @return 手术ID @@ -50,6 +55,9 @@ public class SurgeryServiceImpl extends ServiceImpl impl surgeryMapper.insert(surgery); + // 清除相关缓存 + clearSurgeryCache(surgery); + // 插入后再查询一次,验证是否保存成功 Surgery inserted = surgeryMapper.selectById(surgery.getId()); log.info("插入后查询结果 - applyDoctorId: {}, applyDoctorName: {}, applyDeptId: {}, applyDeptName: {}", @@ -78,66 +86,96 @@ public class SurgeryServiceImpl extends ServiceImpl impl return "OP" + dateStr + randomStr; } - /** - * 修改手术信息 - * - * @param surgery 手术信息 - * @return 结果 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateSurgery(Surgery surgery) { - surgery.setUpdateTime(new Date()); - return surgeryMapper.updateById(surgery) > 0; - } - /** - * 删除手术信息 - * - * @param id 手术ID - * @return 结果 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean deleteSurgery(Long id) { - return surgeryMapper.deleteById(id) > 0; - } /** * 根据ID查询手术信息 - * + * * @param id 手术ID * @return 手术信息 */ @Override public Surgery getSurgeryById(Long id) { - return surgeryMapper.selectById(id); + String cacheKey = RedisKeys.getSurgeryKey(id); + + // 先从Redis缓存中获取 + Surgery surgery = redisCache.getCacheObject(cacheKey); + if (surgery != null) { + log.info("从Redis缓存中获取手术信息 - surgeryId: {}", id); + return surgery; + } + + // 缓存中没有,从数据库查询 + surgery = surgeryMapper.selectById(id); + if (surgery != null) { + // 将查询结果存入Redis缓存(缓存30分钟) + redisCache.setCacheObject(cacheKey, surgery, 30, TimeUnit.MINUTES); + log.info("从数据库查询手术信息并存入Redis缓存 - surgeryId: {}", id); + } + + return surgery; } /** * 根据患者ID查询手术列表 - * + * * @param patientId 患者ID * @return 手术列表 */ @Override public List getSurgeryListByPatientId(Long patientId) { + String cacheKey = RedisKeys.getSurgeryListByPatientKey(patientId); + + // 先从Redis缓存中获取 + List surgeryList = redisCache.getCacheObject(cacheKey); + if (surgeryList != null) { + log.info("从Redis缓存中获取患者手术列表 - patientId: {}", patientId); + return surgeryList; + } + + // 缓存中没有,从数据库查询 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(Surgery::getPatientId, patientId) .eq(Surgery::getDeleteFlag, "0") .orderByDesc(Surgery::getCreateTime); - return surgeryMapper.selectList(wrapper); + surgeryList = surgeryMapper.selectList(wrapper); + + // 将查询结果存入Redis缓存(缓存30分钟) + if (surgeryList != null && !surgeryList.isEmpty()) { + redisCache.setCacheObject(cacheKey, surgeryList, 30, TimeUnit.MINUTES); + log.info("从数据库查询患者手术列表并存入Redis缓存 - patientId: {}, count: {}", patientId, surgeryList.size()); + } + + return surgeryList; } /** * 根据就诊ID查询手术列表 - * + * * @param encounterId 就诊ID * @return 手术列表 */ @Override public List getSurgeryListByEncounterId(Long encounterId) { - return surgeryMapper.selectByEncounterId(encounterId); + String cacheKey = RedisKeys.getSurgeryListByEncounterKey(encounterId); + + // 先从Redis缓存中获取 + List surgeryList = redisCache.getCacheObject(cacheKey); + if (surgeryList != null) { + log.info("从Redis缓存中获取就诊手术列表 - encounterId: {}", encounterId); + return surgeryList; + } + + // 缓存中没有,从数据库查询 + surgeryList = surgeryMapper.selectByEncounterId(encounterId); + + // 将查询结果存入Redis缓存(缓存30分钟) + if (surgeryList != null && !surgeryList.isEmpty()) { + redisCache.setCacheObject(cacheKey, surgeryList, 30, TimeUnit.MINUTES); + log.info("从数据库查询就诊手术列表并存入Redis缓存 - encounterId: {}, count: {}", encounterId, surgeryList.size()); + } + + return surgeryList; } /** @@ -167,4 +205,72 @@ public class SurgeryServiceImpl extends ServiceImpl impl return surgeryMapper.updateById(surgery) > 0; } + + /** + * 修改手术信息 + * + * @param surgery 手术信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean updateSurgery(Surgery surgery) { + surgery.setUpdateTime(new Date()); + boolean result = surgeryMapper.updateById(surgery) > 0; + + if (result) { + // 清除相关缓存 + clearSurgeryCache(surgery); + } + + return result; + } + + /** + * 删除手术信息 + * + * @param id 手术ID + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean deleteSurgery(Long id) { + Surgery surgery = surgeryMapper.selectById(id); + boolean result = surgeryMapper.deleteById(id) > 0; + + if (result && surgery != null) { + // 清除相关缓存 + clearSurgeryCache(surgery); + } + + return result; + } + + /** + * 清除手术相关的Redis缓存 + * + * @param surgery 手术信息 + */ + private void clearSurgeryCache(Surgery surgery) { + // 清除单个手术缓存 + if (surgery.getId() != null) { + String surgeryKey = RedisKeys.getSurgeryKey(surgery.getId()); + redisCache.deleteObject(surgeryKey); + log.info("清除手术缓存 - surgeryId: {}", surgery.getId()); + } + + // 清除患者手术列表缓存 + if (surgery.getPatientId() != null) { + String patientKey = RedisKeys.getSurgeryListByPatientKey(surgery.getPatientId()); + redisCache.deleteObject(patientKey); + log.info("清除患者手术列表缓存 - patientId: {}", surgery.getPatientId()); + } + + // 清除就诊手术列表缓存 + if (surgery.getEncounterId() != null) { + String encounterKey = RedisKeys.getSurgeryListByEncounterKey(surgery.getEncounterId()); + redisCache.deleteObject(encounterKey); + log.info("清除就诊手术列表缓存 - encounterId: {}", surgery.getEncounterId()); + } + } } \ No newline at end of file diff --git a/openhis-ui-vue3/src/views/doctorstation/components/api.js b/openhis-ui-vue3/src/views/doctorstation/components/api.js index 76c45ad7..85283d85 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/api.js +++ b/openhis-ui-vue3/src/views/doctorstation/components/api.js @@ -808,6 +808,17 @@ export function getInspectionApplicationList(queryParams) { }); } +/** + * 获取诊疗项目列表 + */ +export function getDiagnosisTreatmentList(queryParams) { + return request({ + url: '/data-dictionary/diagnosis-treatment/information-page', + method: 'get', + params: queryParams, + }); +} + /** * 保存检验申请单 */ diff --git a/openhis-ui-vue3/src/views/doctorstation/components/inspection/inspectionApplication.vue b/openhis-ui-vue3/src/views/doctorstation/components/inspection/inspectionApplication.vue index 5910f625..fb0b137d 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/inspection/inspectionApplication.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/inspection/inspectionApplication.vue @@ -595,13 +595,21 @@ function initData() { // 获取检验申请单列表 function getInspectionList() { + // 如果没有encounterId,不调用接口 + if (!queryParams.encounterId) { + console.warn('【检验】encounterId为空,不调用接口') + return + } + loading.value = true // 调用真实的API,只传递 encounterId 参数 + console.log('【检验】调用API,encounterId:', queryParams.encounterId) getInspectionApplicationList({ encounterId: queryParams.encounterId }).then((res) => { if (res.code === 200) { inspectionList.value = res.data || [] total.value = res.data?.length || 0 + console.log('【检验】获取数据成功,数量:', inspectionList.value.length) } else { inspectionList.value = [] total.value = 0 @@ -977,6 +985,15 @@ watch(() => props.activeTab, (newVal) => { } }) +// 监听patientInfo变化,确保encounterId及时更新 +watch(() => props.patientInfo, (newVal) => { + console.log('【检验】patientInfo变化:', newVal) + if (newVal && newVal.encounterId) { + queryParams.encounterId = newVal.encounterId + console.log('【检验】更新encounterId:', queryParams.encounterId) + } +}, { deep: true, immediate: true }) + // 初始化 onMounted(() => { initData() diff --git a/openhis-ui-vue3/src/views/doctorstation/components/surgery/surgeryApplication.vue b/openhis-ui-vue3/src/views/doctorstation/components/surgery/surgeryApplication.vue index eb72ffca..2d6daaa8 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/surgery/surgeryApplication.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/surgery/surgeryApplication.vue @@ -50,6 +50,16 @@ + + + + + + + +