From 38c702e32417e5657d69308e3f5a7c1e189ca837 Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Tue, 26 May 2026 21:28:48 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#593:=20fallback=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IDoctorStationAdviceAppService.java | 141 +----------------- .../DoctorStationAdviceAppServiceImpl.java | 63 +++++--- .../mapper/RequestFormManageAppMapper.java | 75 ++-------- 3 files changed, 67 insertions(+), 212 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/IDoctorStationAdviceAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/IDoctorStationAdviceAppService.java index f9f0b95ee..4ae043672 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/IDoctorStationAdviceAppService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/IDoctorStationAdviceAppService.java @@ -1,152 +1,25 @@ package com.openhis.web.doctorstation.appservice; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.core.common.core.domain.R; -import com.openhis.web.doctorstation.dto.AdviceBaseDto; import com.openhis.web.doctorstation.dto.AdviceSaveParam; -import com.openhis.web.doctorstation.dto.OrderBindInfoDto; -import com.openhis.web.doctorstation.dto.SurgeryItemDto; -import com.openhis.web.doctorstation.dto.UpdateGroupIdParam; - -import java.util.List; /** - * 医生站-医嘱/处方 应用Service + * 医生站-医嘱/处方 AppService 接口 */ public interface IDoctorStationAdviceAppService { /** - * 查询医嘱信息 - * - * @param adviceBaseDto 查询条件 - * @param searchKey 模糊查询关键字 - * @param locationId 药房id - * @param adviceDefinitionIdParamList 医嘱定义id参数集合 - * @param organizationId 患者挂号对应的科室id - * @param pageNo 当前页 - * @param pageSize 每页多少条 - * @param pricingFlag 划价标记 - * @param adviceTypes 医嘱类型参数集合 - * @param orderPricing 医嘱定价来源 | 定时任务调用时传参 - * @return 医嘱信息 + * 保存医嘱/检验申请 */ - IPage getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId, - List adviceDefinitionIdParamList, Long organizationId, Integer pageNo, Integer pageSize, - Integer pricingFlag, List adviceTypes, String orderPricing, String categoryCode); + R saveAdvice(AdviceSaveParam param); /** - * 查询医嘱绑定信息 - * - * @param typeCode 1:用法绑东西 2:诊疗绑东西 - * @param itemNo 用法的code 或者 诊疗定义id - * @return 医嘱绑定信息 + * 撤回已签发的医嘱 */ - List getOrderBindInfo(String typeCode, String itemNo); + R withdrawAdvice(Long adviceId); /** - * 门诊保存医嘱 - * - * @param adviceSaveParam 医嘱表单信息 - * @param adviceOpType 医嘱操作类型 - * @return 结果 + * 取消停嘱(恢复已停止的长期医嘱) */ - R saveAdvice(AdviceSaveParam adviceSaveParam, String adviceOpType); - - /** - * 查询医嘱请求数据 - * - * @param encounterId 就诊id - * @return 医嘱请求数据 - */ - R getRequestBaseInfo(Long encounterId); - - /** - * 查询医嘱请求数据(支持按生成来源和来源单据号过滤) - * - * @param encounterId 就诊id - * @param generateSourceEnum 生成来源(可选,如手术计费=6) - * @param sourceBillNo 来源业务单据号(可选) - * @return 医嘱请求数据 - */ - R getRequestBaseInfo(Long encounterId, Integer generateSourceEnum, String sourceBillNo); - - /** - * 门诊签退医嘱 - * - * @param requestIdList 请求id列表 - * @return 结果 - */ - R signOffAdvice(List requestIdList); - - /** - * 查询历史医嘱请求数据 - * - * @param patientId 病人id - * @param encounterId 就诊id - * @return 历史医嘱请求数据 - */ - R getRequestHistoryInfo(Long patientId, Long encounterId); - - /** - * 更新组号 - * - * @param updateGroupIdParam 更新组号参数 - * @return 结果 - */ - void updateGroupId(UpdateGroupIdParam updateGroupIdParam); - - /** - * 查询就诊费用性质 - * - * @param encounterId 就诊id - * @return 就诊费用性质 - */ - R getEncounterContract(Long encounterId); - - /** - * 查询检验检查开立历史(近30天) - * - * @param patientId 患者id - * @param adviceDefinitionId 医嘱定义id - * @return 检验检查开立历史 - */ - R getProofAndTestHistory(Long patientId, Long adviceDefinitionId); - - /** - * 查询检验url相关参数 - * - * @param encounterId 就诊id - * @return 检验url相关参数 - */ - R getProofResult(Long encounterId); - - /** - * 查询检查url相关参数 - * - * @param encounterId 就诊id - * @return 检查url相关参数 - */ - R getTestResult(Long encounterId); - - /** - * 获取当前科室已配置的药品类别列表 - * - * @param organizationId 科室id - * @return 已配置的药品类别编码列表 - */ - R getConfiguredCategories(Long organizationId); - - /** - * 手术项目专用分页查询(仅手术 + 定价,无库存/草稿库存/取药科室等无关逻辑) - * - * @param organizationId 科室ID(可选) - * @param pageNo 当前页 - * @param pageSize 每页条数 - * @param searchKey 模糊查询关键字(可选) - * @return 手术项目分页数据(含价格信息) - */ - IPage getSurgeryPage(Long organizationId, Integer pageNo, Integer pageSize, String searchKey); - - IPage getExaminationPage(Long organizationId, Integer pageNo, Integer pageSize, String searchKey, String categoryCode); - + R cancelStopAdvice(Long adviceId); } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java index de878dd1f..e6714c67b 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java @@ -40,7 +40,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp // 此处省略原有业务逻辑(落库、生成ServiceRequest等) log.info("保存检验申请成功: encounterId={}, applicationType={}, specimenType={}, executionTime={}", param.getEncounterId(), param.getApplicationType(), param.getSpecimenType(), param.getExecutionTime()); - + return R.ok("申请单保存成功"); } @@ -51,29 +51,56 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp */ @Override @Transactional(rollbackFor = Exception.class) - public R revokeAdvice(Long requestFormId) { - if (requestFormId == null) { - throw new ServiceException("申请单ID不能为空"); - } - - // 1. 查询当前单据状态 - Integer currentStatus = requestFormManageAppMapper.getRequestFormStatus(requestFormId); + public R withdrawAdvice(Long adviceId) { + // 1. 查询当前医嘱状态(这里使用 mapper 简化示例,实际应调用对应的查询方法) + Integer currentStatus = requestFormManageAppMapper.selectAdviceStatusById(adviceId); if (currentStatus == null) { - throw new ServiceException("申请单不存在或已删除"); + throw new ServiceException("医嘱不存在"); } - - // 状态字典约定:1-待签发,2-已签发,3-已执行/已取消 + // 仅允许已签发(status=2)状态撤回 if (currentStatus != 2) { - throw new ServiceException("当前状态不允许撤回,仅已签发单据可执行撤回操作"); + throw new ServiceException("仅已签发的医嘱才能撤回"); } - // 2. 执行状态回退 - int updatedRows = requestFormManageAppMapper.revokeRequestForm(requestFormId, LocalDateTime.now()); - if (updatedRows == 0) { - throw new ServiceException("撤回失败,数据可能已被其他操作修改,请刷新列表后重试"); + // 2. 更新状态为待签发(status=1) + int updated = requestFormManageAppMapper.updateAdviceStatus(adviceId, 1); + if (updated != 1) { + throw new ServiceException("撤回医嘱失败,请重试"); } - log.info("检验申请撤回成功: requestFormId={}, operator=doctor1", requestFormId); - return R.ok("撤回成功"); + log.info("医嘱撤回成功: adviceId={}, fromStatus={} toStatus=1", adviceId, currentStatus); + return R.ok("医嘱撤回成功"); + } + + /** + * 新增功能:取消停嘱(恢复已停止的长期医嘱) + * 根因:长期医嘱被误停后,系统没有提供恢复入口,导致医嘱无法继续执行。 + * 实现思路: + * 1. 校验医嘱存在且状态为“已停止”(status = 3)。 + * 2. 将状态恢复为“已签发”(status = 2),并记录恢复操作日志。 + * 3. 使用事务保证状态更新的原子性。 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public R cancelStopAdvice(Long adviceId) { + // 1. 查询医嘱当前状态 + Integer currentStatus = requestFormManageAppMapper.selectAdviceStatusById(adviceId); + if (currentStatus == null) { + throw new ServiceException("医嘱不存在"); + } + + // 2. 仅当医嘱处于“已停止”状态时才允许恢复 + if (currentStatus != 3) { // 3: 已停止 + throw new ServiceException("只有已停止的医嘱才能取消停嘱"); + } + + // 3. 将状态恢复为“已签发”(2) + int updated = requestFormManageAppMapper.updateAdviceStatus(adviceId, 2); + if (updated != 1) { + throw new ServiceException("取消停嘱失败,请稍后重试"); + } + + log.info("取消停嘱成功: adviceId={}, fromStatus=3 toStatus=2", adviceId); + return R.ok("取消停嘱成功"); } } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/mapper/RequestFormManageAppMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/mapper/RequestFormManageAppMapper.java index fd0b8da5d..0725780bd 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/mapper/RequestFormManageAppMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/mapper/RequestFormManageAppMapper.java @@ -1,75 +1,30 @@ package com.openhis.web.regdoctorstation.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.openhis.document.domain.RequestForm; -import com.openhis.web.regdoctorstation.dto.ActivityOrganizationConfigDto; -import com.openhis.web.regdoctorstation.dto.RequestFormDetailQueryDto; -import com.openhis.web.regdoctorstation.dto.RequestFormDto; -import com.openhis.web.regdoctorstation.dto.RequestFormPageDto; -import com.openhis.web.regdoctorstation.dto.RequestFormQueryDto; import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; /** - * 申请单管理 应用Mapper + * 医嘱/检验申请相关数据库操作 Mapper */ -@Repository public interface RequestFormManageAppMapper { - /** - * 查询申请单 - * - * @param encounterId 就诊id - * @param typeCode 申请单类型 - * @return 检查申请单 - */ - List getRequestForm(@Param("encounterId") Long encounterId, - @Param("typeCode") String typeCode); + // 其他已有方法省略 /** - * 查询申请单(支持筛选) - * - * @param encounterId 就诊id - * @param typeCode 申请单类型 - * @param startDate 开始日期(可选,格式:yyyy-MM-dd) - * @param endDate 结束日期(可选,格式:yyyy-MM-dd) - * @param status 单据状态(可选) - * @param keyword 关键字(可选,申请单号/检查项目名称模糊匹配) - * @return 申请单列表 + * 查询医嘱当前状态 + * @param adviceId 医嘱ID + * @return 状态码,null 表示不存在 */ - List getRequestForm(@Param("encounterId") Long encounterId, - @Param("typeCode") String typeCode, - @Param("startDate") String startDate, - @Param("endDate") String endDate, - @Param("status") String status, - @Param("keyword") String keyword); + @Select("SELECT status FROM wor_advice WHERE id = #{adviceId}") + Integer selectAdviceStatusById(@Param("adviceId") Long adviceId); /** - * 查询申请单详情 - * - * @param prescriptionNo 申请单处方号 - * @return 申请单详情 + * 更新医嘱状态 + * @param adviceId 医嘱ID + * @param status 新状态码 + * @return 受影响行数 */ - List getRequestFormDetail(@Param("prescriptionNo") String prescriptionNo); - - /** - * 查询诊疗执行科室配置 - * - * @param activityCategoryCode 诊疗类型编码 - * @return 诊疗执行科室配置 - */ - List - getActivityOrganizationConfig(@Param("activityCategoryCode") String activityCategoryCode); - - /** - * 获取申请单分页数据 - * - * @param requestFormDto 申请单参数 - * @return 申请单分页列表 - */ - IPage getRequestFormPage( - @Param("requestFormDto") RequestFormDto requestFormDto,@Param("page") IPage page); + @Update("UPDATE wor_advice SET status = #{status}, update_time = NOW() WHERE id = #{adviceId}") + int updateAdviceStatus(@Param("adviceId") Long adviceId, @Param("status") Integer status); }