Compare commits
29 Commits
f7a3f658fb
...
bug475-fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80695d90f9 | ||
|
|
deb6ade97b | ||
|
|
2d7228ca5d | ||
|
|
a447e55d43 | ||
| 1be0dc2417 | |||
| a4b4d36d93 | |||
|
|
940fad5c7d | ||
|
|
ead3733aac | ||
|
|
28bf385ec2 | ||
|
|
31f7c4f32a | ||
|
|
480663f716 | ||
|
|
cc484d5f10 | ||
|
|
30f8cdbd80 | ||
|
|
f4c6c12ef8 | ||
|
|
8cf98008ae | ||
|
|
062c8d9dee | ||
|
|
ffdfebaacf | ||
|
|
9ed52b7c48 | ||
|
|
fc1ed6c4ce | ||
|
|
818564f5ba | ||
|
|
78adbddfde | ||
|
|
861db6b0f5 | ||
|
|
b7df71fd0b | ||
|
|
5bc8a8e517 | ||
| 0264fa9d58 | |||
| cd12dd7a22 | |||
|
|
bfddf87b2c | ||
|
|
84499d4ec1 | ||
|
|
01c5b62024 |
@@ -2,9 +2,13 @@ package com.openhis.web.clinicalmanage.controller;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.core.common.core.domain.R;
|
import com.core.common.core.domain.R;
|
||||||
|
import com.openhis.common.enums.ActivityDefCategory;
|
||||||
import com.openhis.web.clinicalmanage.appservice.ISurgicalScheduleAppService;
|
import com.openhis.web.clinicalmanage.appservice.ISurgicalScheduleAppService;
|
||||||
import com.openhis.web.clinicalmanage.dto.OpCreateScheduleDto;
|
import com.openhis.web.clinicalmanage.dto.OpCreateScheduleDto;
|
||||||
import com.openhis.web.clinicalmanage.dto.OpScheduleDto;
|
import com.openhis.web.clinicalmanage.dto.OpScheduleDto;
|
||||||
|
import com.openhis.web.regdoctorstation.appservice.IRequestFormManageAppService;
|
||||||
|
import com.openhis.web.regdoctorstation.dto.RequestFormDto;
|
||||||
|
import com.openhis.web.regdoctorstation.dto.RequestFormPageDto;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -26,6 +30,7 @@ import java.util.Map;
|
|||||||
public class SurgicalScheduleController {
|
public class SurgicalScheduleController {
|
||||||
|
|
||||||
private final ISurgicalScheduleAppService surgicalScheduleAppService;
|
private final ISurgicalScheduleAppService surgicalScheduleAppService;
|
||||||
|
private final IRequestFormManageAppService requestFormManageAppService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询手术安排列表
|
* 分页查询手术安排列表
|
||||||
@@ -87,6 +92,27 @@ public class SurgicalScheduleController {
|
|||||||
return surgicalScheduleAppService.deleteSurgerySchedule(scheduleId);
|
return surgicalScheduleAppService.deleteSurgerySchedule(scheduleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询待排期手术申请列表
|
||||||
|
*
|
||||||
|
* @param requestFormDto 查询条件
|
||||||
|
* @return 手术申请列表
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/apply-list")
|
||||||
|
public R<IPage<RequestFormPageDto>> getSurgeryApplyList(@RequestBody RequestFormDto requestFormDto) {
|
||||||
|
if (requestFormDto.getPageNo() == null) {
|
||||||
|
requestFormDto.setPageNo(1);
|
||||||
|
}
|
||||||
|
if (requestFormDto.getPageSize() == null) {
|
||||||
|
requestFormDto.setPageSize(10);
|
||||||
|
}
|
||||||
|
//虽然很想这么写,但是库里的手术申请单的type_code都是直接写的SURGERY
|
||||||
|
// requestFormDto.setTypeCode(ActivityDefCategory.PROCEDURE.getCode());
|
||||||
|
//只查询手术申请单
|
||||||
|
requestFormDto.setTypeCode("SURGERY");
|
||||||
|
return R.ok(requestFormManageAppService.getRequestFormPage(requestFormDto));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出手术安排列表
|
* 导出手术安排列表
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -59,6 +59,16 @@ public interface IDoctorStationAdviceAppService {
|
|||||||
*/
|
*/
|
||||||
R<?> getRequestBaseInfo(Long encounterId);
|
R<?> getRequestBaseInfo(Long encounterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询医嘱请求数据(支持按生成来源和来源单据号过滤)
|
||||||
|
*
|
||||||
|
* @param encounterId 就诊id
|
||||||
|
* @param generateSourceEnum 生成来源(可选,如手术计费=6)
|
||||||
|
* @param sourceBillNo 来源业务单据号(可选)
|
||||||
|
* @return 医嘱请求数据
|
||||||
|
*/
|
||||||
|
R<?> getRequestBaseInfo(Long encounterId, Integer generateSourceEnum, String sourceBillNo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 门诊签退医嘱
|
* 门诊签退医嘱
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -228,8 +228,10 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
// 医嘱定义ID集合
|
// 医嘱定义ID集合
|
||||||
List<Long> adviceDefinitionIdList = adviceBaseDtoList.stream().map(AdviceBaseDto::getAdviceDefinitionId)
|
List<Long> adviceDefinitionIdList = adviceBaseDtoList.stream().map(AdviceBaseDto::getAdviceDefinitionId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// 费用定价主表ID集合
|
// 费用定价主表ID集合(过滤null值,手术项目无定价定义)
|
||||||
List<Long> chargeItemDefinitionIdList = adviceBaseDtoList.stream().map(AdviceBaseDto::getChargeItemDefinitionId)
|
List<Long> chargeItemDefinitionIdList = adviceBaseDtoList.stream()
|
||||||
|
.map(AdviceBaseDto::getChargeItemDefinitionId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 判断是否包含药品或耗材类型(只有这些类型才需要库存相关查询)
|
// 判断是否包含药品或耗材类型(只有这些类型才需要库存相关查询)
|
||||||
@@ -275,9 +277,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
medLocationConfig = Collections.emptyList();
|
medLocationConfig = Collections.emptyList();
|
||||||
allowedLocByCategory = Collections.emptyMap();
|
allowedLocByCategory = Collections.emptyMap();
|
||||||
}
|
}
|
||||||
// 费用定价子表信息 - 使用分批处理避免大量参数问题
|
// 费用定价子表信息 - 仅药品/耗材需要批次定价查询,手术/诊疗无库存概念不需要
|
||||||
List<AdvicePriceDto> childCharge = new ArrayList<>();
|
List<AdvicePriceDto> childCharge = new ArrayList<>();
|
||||||
if (chargeItemDefinitionIdList != null && !chargeItemDefinitionIdList.isEmpty()) {
|
if (hasMedOrDevice && chargeItemDefinitionIdList != null && !chargeItemDefinitionIdList.isEmpty()) {
|
||||||
// 分批处理,每批最多1000个ID,增加批次大小以减少查询次数
|
// 分批处理,每批最多1000个ID,增加批次大小以减少查询次数
|
||||||
int batchSize = 1000;
|
int batchSize = 1000;
|
||||||
for (int i = 0; i < chargeItemDefinitionIdList.size(); i += batchSize) {
|
for (int i = 0; i < chargeItemDefinitionIdList.size(); i += batchSize) {
|
||||||
@@ -957,11 +959,16 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
||||||
iMedicationRequestService.removeById(adviceSaveDto.getRequestId());
|
Long requestId = adviceSaveDto.getRequestId();
|
||||||
|
// 🔧 Bug #442: 跳过 requestId 为 null 的记录,避免删除不存在的药品请求
|
||||||
|
if (requestId == null) {
|
||||||
|
log.warn("BugFix#442: handMedication - 跳过 requestId 为 null 的删除请求");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
iMedicationRequestService.removeById(requestId);
|
||||||
// 删除已经产生的药品发放信息
|
// 删除已经产生的药品发放信息
|
||||||
iMedicationDispenseService.deleteMedicationDispense(adviceSaveDto.getRequestId());
|
iMedicationDispenseService.deleteMedicationDispense(adviceSaveDto.getRequestId());
|
||||||
// 🔧 Bug Fix #219: 删除费用项
|
// 🔧 Bug Fix #219: 删除费用项
|
||||||
Long requestId = adviceSaveDto.getRequestId();
|
|
||||||
String serviceTable = CommonConstants.TableName.MED_MEDICATION_REQUEST;
|
String serviceTable = CommonConstants.TableName.MED_MEDICATION_REQUEST;
|
||||||
// 直接删除费用项
|
// 直接删除费用项
|
||||||
iChargeItemService.deleteByServiceTableAndId(serviceTable, requestId);
|
iChargeItemService.deleteByServiceTableAndId(serviceTable, requestId);
|
||||||
@@ -1417,6 +1424,11 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
log.info("BugFix#219: handDevice - 开始删除循环, deleteList.size={}", deleteList.size());
|
log.info("BugFix#219: handDevice - 开始删除循环, deleteList.size={}", deleteList.size());
|
||||||
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
||||||
Long requestId = adviceSaveDto.getRequestId();
|
Long requestId = adviceSaveDto.getRequestId();
|
||||||
|
// 🔧 Bug #442: 跳过 requestId 为 null 的记录,避免删除不存在的耗材请求
|
||||||
|
if (requestId == null) {
|
||||||
|
log.warn("BugFix#442: handDevice - 跳过 requestId 为 null 的删除请求");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
log.info("BugFix#219: handDevice - 删除开始: requestId={}", requestId);
|
log.info("BugFix#219: handDevice - 删除开始: requestId={}", requestId);
|
||||||
|
|
||||||
// 1. 删除耗材请求
|
// 1. 删除耗材请求
|
||||||
@@ -1721,12 +1733,17 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
||||||
iServiceRequestService.removeById(adviceSaveDto.getRequestId());// 删除诊疗
|
Long requestId = adviceSaveDto.getRequestId();
|
||||||
|
// 🔧 Bug #442: 跳过 requestId 为 null 的记录,避免删除不存在的诊疗请求
|
||||||
|
if (requestId == null) {
|
||||||
|
log.warn("BugFix#442: handService - 跳过 requestId 为 null 的删除请求");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
iServiceRequestService.removeById(requestId);// 删除诊疗
|
||||||
iServiceRequestService.remove(
|
iServiceRequestService.remove(
|
||||||
new LambdaQueryWrapper<ServiceRequest>().eq(ServiceRequest::getParentId,
|
new LambdaQueryWrapper<ServiceRequest>().eq(ServiceRequest::getParentId,
|
||||||
adviceSaveDto.getRequestId()));// 删除诊疗套餐对应的子项
|
requestId));// 删除诊疗套餐对应的子项
|
||||||
// 🔧 Bug Fix #219: 删除费用项
|
// 🔧 Bug Fix #219: 删除费用项
|
||||||
Long requestId = adviceSaveDto.getRequestId();
|
|
||||||
String serviceTable = CommonConstants.TableName.WOR_SERVICE_REQUEST;
|
String serviceTable = CommonConstants.TableName.WOR_SERVICE_REQUEST;
|
||||||
// 直接删除费用项
|
// 直接删除费用项
|
||||||
iChargeItemService.deleteByServiceTableAndId(serviceTable, requestId);
|
iChargeItemService.deleteByServiceTableAndId(serviceTable, requestId);
|
||||||
@@ -1783,8 +1800,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
log.info("handService - 自动补全founderOrgId: founderOrgId={}", adviceSaveDto.getFounderOrgId());
|
log.info("handService - 自动补全founderOrgId: founderOrgId={}", adviceSaveDto.getFounderOrgId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🔧 Bug Fix #238: 诊疗项目执行科室非空校验
|
// 🔧 Bug Fix #238/#454: 诊疗项目执行科室非空校验(删除操作跳过校验)
|
||||||
if (adviceSaveDto.getAdviceType() != null && adviceSaveDto.getAdviceType() == 3) {
|
if (adviceSaveDto.getAdviceType() != null && adviceSaveDto.getAdviceType() == 3
|
||||||
|
&& !DbOpType.DELETE.getCode().equals(adviceSaveDto.getDbOpType())) {
|
||||||
Long effectiveOrgId = adviceSaveDto.getEffectiveOrgId();
|
Long effectiveOrgId = adviceSaveDto.getEffectiveOrgId();
|
||||||
if (effectiveOrgId == null) {
|
if (effectiveOrgId == null) {
|
||||||
throw new ServiceException("诊疗项目必须选择执行科室");
|
throw new ServiceException("诊疗项目必须选择执行科室");
|
||||||
@@ -1987,13 +2005,25 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public R<?> getRequestBaseInfo(Long encounterId) {
|
public R<?> getRequestBaseInfo(Long encounterId) {
|
||||||
|
return this.getRequestBaseInfo(encounterId, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<?> getRequestBaseInfo(Long encounterId, Integer generateSourceEnum, String sourceBillNo) {
|
||||||
// 当前账号的参与者id
|
// 当前账号的参与者id
|
||||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||||
|
// 未指定generateSourceEnum时,默认只查询医生开立的医嘱
|
||||||
|
int sourceEnum = (generateSourceEnum != null) ? generateSourceEnum : GenerateSource.DOCTOR_PRESCRIPTION.getValue();
|
||||||
// 医嘱请求数据
|
// 医嘱请求数据
|
||||||
List<RequestBaseDto> requestBaseInfo = doctorStationAdviceAppMapper.getRequestBaseInfo(encounterId, null,
|
List<RequestBaseDto> requestBaseInfo = doctorStationAdviceAppMapper.getRequestBaseInfo(encounterId, null,
|
||||||
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_DEVICE_REQUEST,
|
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_DEVICE_REQUEST,
|
||||||
CommonConstants.TableName.WOR_SERVICE_REQUEST, practitionerId, Whether.NO.getCode(),
|
CommonConstants.TableName.WOR_SERVICE_REQUEST, practitionerId, Whether.NO.getCode(),
|
||||||
GenerateSource.DOCTOR_PRESCRIPTION.getValue());
|
sourceEnum, sourceBillNo);
|
||||||
|
// 手术计费场景:sourceBillNo 不为空时,只保留诊疗请求(3/6),过滤掉药品(1)和耗材(2)
|
||||||
|
if (sourceBillNo != null && !sourceBillNo.isEmpty()) {
|
||||||
|
requestBaseInfo.removeIf(dto -> dto.getAdviceType() != null
|
||||||
|
&& (dto.getAdviceType() == 1 || dto.getAdviceType() == 2));
|
||||||
|
}
|
||||||
for (RequestBaseDto requestBaseDto : requestBaseInfo) {
|
for (RequestBaseDto requestBaseDto : requestBaseInfo) {
|
||||||
// 请求状态
|
// 请求状态
|
||||||
requestBaseDto
|
requestBaseDto
|
||||||
@@ -2114,7 +2144,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
|||||||
List<RequestBaseDto> requestBaseInfo = doctorStationAdviceAppMapper.getRequestBaseInfo(encounterId, patientId,
|
List<RequestBaseDto> requestBaseInfo = doctorStationAdviceAppMapper.getRequestBaseInfo(encounterId, patientId,
|
||||||
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_DEVICE_REQUEST,
|
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_DEVICE_REQUEST,
|
||||||
CommonConstants.TableName.WOR_SERVICE_REQUEST, practitionerId, Whether.YES.getCode(),
|
CommonConstants.TableName.WOR_SERVICE_REQUEST, practitionerId, Whether.YES.getCode(),
|
||||||
GenerateSource.DOCTOR_PRESCRIPTION.getValue());
|
GenerateSource.DOCTOR_PRESCRIPTION.getValue(), null);
|
||||||
for (RequestBaseDto requestBaseDto : requestBaseInfo) {
|
for (RequestBaseDto requestBaseDto : requestBaseInfo) {
|
||||||
// 请求状态
|
// 请求状态
|
||||||
requestBaseDto
|
requestBaseDto
|
||||||
|
|||||||
@@ -274,27 +274,8 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
|
|||||||
return R.fail("非就诊中患者不能完诊");
|
return R.fail("非就诊中患者不能完诊");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 获取 pool_id 和 slot_id:从 encounter → order_main → adm_schedule_slot 链路获取
|
// 2. 查找队列项(限定当天,避免复诊患者匹配到历史队列记录)
|
||||||
// 确保 div_log 中的值与排班主表一致,不依赖 triage_queue_item(队列项可能不存在或值错误)
|
|
||||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
Long divPoolId = null;
|
|
||||||
Long divSlotId = null;
|
|
||||||
if (encounter.getOrderId() != null) {
|
|
||||||
try {
|
|
||||||
Order order = iOrderService.getById(encounter.getOrderId());
|
|
||||||
if (order != null && order.getSlotId() != null) {
|
|
||||||
divSlotId = order.getSlotId();
|
|
||||||
ScheduleSlot slot = scheduleSlotMapper.selectById(divSlotId);
|
|
||||||
if (slot != null) {
|
|
||||||
divPoolId = slot.getPoolId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("获取完诊div_log的pool_id/slot_id失败,encounterId={}", encounterId, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 查找队列项(限定当天,避免复诊患者匹配到历史队列记录)
|
|
||||||
TriageQueueItem queueItem = triageQueueItemService.getOne(
|
TriageQueueItem queueItem = triageQueueItemService.getOne(
|
||||||
new LambdaQueryWrapper<TriageQueueItem>()
|
new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
@@ -319,30 +300,44 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果队列项存在,更新队列状态为已完成
|
// 3. 获取 pool_id 和 slot_id:优先使用 triage_queue_item(挂号时录入的号源信息,为权威来源)
|
||||||
// 使用 LambdaUpdateWrapper 直接更新数据库,避免 updateById 实体序列化导致的类型映射问题
|
// 队列项不存在或值缺失时,回退使用 encounter → order_main → adm_schedule_slot 链路
|
||||||
if (queueItem != null) {
|
Long divPoolId = null;
|
||||||
Integer targetStatus = TriageQueueStatus.COMPLETED.getValue();
|
Long divSlotId = null;
|
||||||
// 排除法:只要不是"已完成"就执行更新,覆盖等待、叫号中、诊中、跳过等状态
|
if (queueItem != null && queueItem.getPoolId() != null && queueItem.getSlotId() != null) {
|
||||||
if (!targetStatus.equals(queueItem.getStatus())) {
|
divPoolId = queueItem.getPoolId();
|
||||||
java.time.LocalDateTime nowLocal = java.time.LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS);
|
divSlotId = queueItem.getSlotId();
|
||||||
boolean updated = triageQueueItemService.update(
|
}
|
||||||
new LambdaUpdateWrapper<TriageQueueItem>()
|
// 队列项 poolId/slotId 缺失时,通过 encounter.orderId → order_main.slot_id → adm_schedule_slot.pool_id 回退获取
|
||||||
.eq(TriageQueueItem::getId, queueItem.getId())
|
if ((divPoolId == null || divSlotId == null) && encounter.getOrderId() != null) {
|
||||||
.set(TriageQueueItem::getStatus, targetStatus)
|
try {
|
||||||
.set(TriageQueueItem::getUpdateTime, nowLocal)
|
Order order = iOrderService.getById(encounter.getOrderId());
|
||||||
);
|
if (order != null && order.getSlotId() != null) {
|
||||||
if (updated) {
|
ScheduleSlot slot = scheduleSlotMapper.selectById(order.getSlotId());
|
||||||
log.info("完诊:更新队列状态为 COMPLETED(30) 成功,queueItemId={}, encounterId={}",
|
if (slot != null) {
|
||||||
queueItem.getId(), encounterId);
|
divSlotId = slot.getId();
|
||||||
} else {
|
divPoolId = slot.getPoolId();
|
||||||
log.error("完诊:更新队列状态为 COMPLETED(30) 失败,queueItemId={}, encounterId={}",
|
}
|
||||||
queueItem.getId(), encounterId);
|
|
||||||
}
|
}
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
log.info("完诊:队列状态已为 COMPLETED(30),无需重复更新,queueItemId={}", queueItem.getId());
|
log.warn("回退获取完诊div_log的pool_id/slot_id失败,encounterId={}", encounterId, e);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// 如果队列项存在且未完成,更新队列状态为已完成
|
||||||
|
// 使用排除法而非白名单:只要不是"已完成"就可以完诊,覆盖跳过、等待等非标准流转状态
|
||||||
|
if (queueItem != null &&
|
||||||
|
!TriageQueueStatus.COMPLETED.getValue().equals(queueItem.getStatus())) {
|
||||||
|
java.time.LocalDateTime nowLocal = java.time.LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
// 使用 LambdaUpdateWrapper 直接更新,确保 status 字段必定写入数据库
|
||||||
|
boolean queueUpdate = triageQueueItemService.update(new LambdaUpdateWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getId, queueItem.getId())
|
||||||
|
.set(TriageQueueItem::getStatus, TriageQueueStatus.COMPLETED.getValue())
|
||||||
|
.set(TriageQueueItem::getUpdateTime, nowLocal));
|
||||||
|
if (!queueUpdate) {
|
||||||
|
log.error("完诊:triage_queue_item 状态更新失败,queueItemId={}", queueItem.getId());
|
||||||
|
}
|
||||||
|
} else if (queueItem == null) {
|
||||||
log.error("完诊:未找到任何 triage_queue_item 记录,encounterId={}, tenantId={}",
|
log.error("完诊:未找到任何 triage_queue_item 记录,encounterId={}, tenantId={}",
|
||||||
encounterId, tenantId);
|
encounterId, tenantId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,11 +112,16 @@ public class DoctorStationAdviceController {
|
|||||||
* 查询医嘱请求数据
|
* 查询医嘱请求数据
|
||||||
*
|
*
|
||||||
* @param encounterId 就诊id
|
* @param encounterId 就诊id
|
||||||
|
* @param generateSourceEnum 生成来源(可选,用于按来源过滤,如手术计费=6)
|
||||||
|
* @param sourceBillNo 来源业务单据号(可选,用于按来源单据过滤)
|
||||||
* @return 医嘱请求数据
|
* @return 医嘱请求数据
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/request-base-info")
|
@GetMapping(value = "/request-base-info")
|
||||||
public R<?> getRequestBaseInfo(@RequestParam(required = false) Long encounterId) {
|
public R<?> getRequestBaseInfo(
|
||||||
return iDoctorStationAdviceAppService.getRequestBaseInfo(encounterId);
|
@RequestParam(required = false) Long encounterId,
|
||||||
|
@RequestParam(required = false) Integer generateSourceEnum,
|
||||||
|
@RequestParam(required = false) String sourceBillNo) {
|
||||||
|
return iDoctorStationAdviceAppService.getRequestBaseInfo(encounterId, generateSourceEnum, sourceBillNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ public interface DoctorStationAdviceAppMapper {
|
|||||||
@Param("MED_MEDICATION_REQUEST") String MED_MEDICATION_REQUEST,
|
@Param("MED_MEDICATION_REQUEST") String MED_MEDICATION_REQUEST,
|
||||||
@Param("WOR_DEVICE_REQUEST") String WOR_DEVICE_REQUEST,
|
@Param("WOR_DEVICE_REQUEST") String WOR_DEVICE_REQUEST,
|
||||||
@Param("WOR_SERVICE_REQUEST") String WOR_SERVICE_REQUEST, @Param("practitionerId") Long practitionerId,
|
@Param("WOR_SERVICE_REQUEST") String WOR_SERVICE_REQUEST, @Param("practitionerId") Long practitionerId,
|
||||||
@Param("historyFlag") String historyFlag, @Param("generateSourceEnum") Integer generateSourceEnum);
|
@Param("historyFlag") String historyFlag, @Param("generateSourceEnum") Integer generateSourceEnum,
|
||||||
|
@Param("sourceBillNo") String sourceBillNo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询就诊费用性质
|
* 查询就诊费用性质
|
||||||
|
|||||||
@@ -63,20 +63,4 @@ public interface IRequestFormManageAppService {
|
|||||||
* @return 申请单
|
* @return 申请单
|
||||||
*/
|
*/
|
||||||
IPage<RequestFormPageDto> getRequestFormPage(RequestFormDto requestFormDto);
|
IPage<RequestFormPageDto> getRequestFormPage(RequestFormDto requestFormDto);
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除申请单(仅待签发状态可删除)
|
|
||||||
*
|
|
||||||
* @param requestFormId 申请单ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
R<?> deleteRequestForm(Long requestFormId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤回申请单(已签发状态撤回至待签发)
|
|
||||||
*
|
|
||||||
* @param requestFormId 申请单ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
R<?> withdrawRequestForm(Long requestFormId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -75,6 +76,13 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public R<?> saveRequestForm(RequestFormSaveDto requestFormSaveDto, String typeCode) {
|
public R<?> saveRequestForm(RequestFormSaveDto requestFormSaveDto, String typeCode) {
|
||||||
|
// 诊疗执行科室配置校验(必须在任何数据库操作之前)
|
||||||
|
List<ActivityOrganizationConfigDto> activityOrganizationConfig =
|
||||||
|
requestFormManageAppMapper.getActivityOrganizationConfig(typeCode);
|
||||||
|
if (activityOrganizationConfig.isEmpty()) {
|
||||||
|
throw new ServiceException("请先配置当前时间段的执行科室");
|
||||||
|
}
|
||||||
|
|
||||||
// 诊疗处方号
|
// 诊疗处方号
|
||||||
String prescriptionNo;
|
String prescriptionNo;
|
||||||
// 申请单ID
|
// 申请单ID
|
||||||
@@ -91,8 +99,10 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
return R.fail("无待签发的医嘱,该申请单不可编辑");
|
return R.fail("无待签发的医嘱,该申请单不可编辑");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 诊疗处方号
|
// 检查申请单号:JC(检查)+ Z(住院标识)+ yyMMdd(日期)+ 5位顺序号
|
||||||
prescriptionNo = assignSeqUtil.getSeq(AssignSeqEnum.ACTIVITY_PSYCHOTROPIC_NO.getPrefix(), 8);
|
String dateStr = new java.text.SimpleDateFormat("yyMMdd").format(new Date());
|
||||||
|
int seq = assignSeqUtil.getSeqNoByDay(AssignSeqEnum.CHECK_APPLY_NO.getPrefix());
|
||||||
|
prescriptionNo = "JCZ" + dateStr + String.format("%05d", seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当前时间
|
// 当前时间
|
||||||
@@ -139,12 +149,6 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
// 诊疗集合
|
// 诊疗集合
|
||||||
List<ActivitySaveDto> activityList = requestFormSaveDto.getActivityList();
|
List<ActivitySaveDto> activityList = requestFormSaveDto.getActivityList();
|
||||||
log.info("保存申请单,typeCode={}, activityListSize={}, encounterId={}", typeCode, activityList != null ? activityList.size() : 0, encounterId);
|
log.info("保存申请单,typeCode={}, activityListSize={}, encounterId={}", typeCode, activityList != null ? activityList.size() : 0, encounterId);
|
||||||
// 诊疗执行科室配置
|
|
||||||
List<ActivityOrganizationConfigDto> activityOrganizationConfig =
|
|
||||||
requestFormManageAppMapper.getActivityOrganizationConfig(typeCode);
|
|
||||||
if (activityOrganizationConfig.isEmpty()) {
|
|
||||||
throw new ServiceException("请先配置当前时间段的执行科室");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ActivitySaveDto activitySaveDto : activityList) {
|
for (ActivitySaveDto activitySaveDto : activityList) {
|
||||||
serviceRequest = new ServiceRequest();
|
serviceRequest = new ServiceRequest();
|
||||||
@@ -471,68 +475,4 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
|||||||
return requestFormManageAppMapper.getRequestFormPage(requestFormDto, page);
|
return requestFormManageAppMapper.getRequestFormPage(requestFormDto, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除申请单(仅待签发状态可删除)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public R<?> deleteRequestForm(Long requestFormId) {
|
|
||||||
if (requestFormId == null) {
|
|
||||||
return R.fail("申请单ID不能为空");
|
|
||||||
}
|
|
||||||
RequestForm requestForm = iRequestFormService.getById(requestFormId);
|
|
||||||
if (requestForm == null) {
|
|
||||||
return R.fail("申请单不存在");
|
|
||||||
}
|
|
||||||
if (!Integer.valueOf(0).equals(requestForm.getStatus())) {
|
|
||||||
return R.fail("仅待签发状态的申请单可删除");
|
|
||||||
}
|
|
||||||
// 删除申请单
|
|
||||||
iRequestFormService.removeById(requestFormId);
|
|
||||||
// 删除关联的诊疗项目及账单
|
|
||||||
String prescriptionNo = requestForm.getPrescriptionNo();
|
|
||||||
List<Long> serviceRequestIds = iServiceRequestService
|
|
||||||
.list(new LambdaQueryWrapper<ServiceRequest>().eq(ServiceRequest::getPrescriptionNo, prescriptionNo))
|
|
||||||
.stream().map(ServiceRequest::getId).collect(Collectors.toList());
|
|
||||||
for (Long serviceRequestId : serviceRequestIds) {
|
|
||||||
iServiceRequestService.removeById(serviceRequestId);
|
|
||||||
iChargeItemService.deleteByServiceTableAndId(CommonConstants.TableName.WOR_SERVICE_REQUEST, serviceRequestId);
|
|
||||||
}
|
|
||||||
return R.ok(null, "删除成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤回申请单(已签发状态撤回至待签发)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public R<?> withdrawRequestForm(Long requestFormId) {
|
|
||||||
if (requestFormId == null) {
|
|
||||||
return R.fail("申请单ID不能为空");
|
|
||||||
}
|
|
||||||
RequestForm requestForm = iRequestFormService.getById(requestFormId);
|
|
||||||
if (requestForm == null) {
|
|
||||||
return R.fail("申请单不存在");
|
|
||||||
}
|
|
||||||
if (!Integer.valueOf(1).equals(requestForm.getStatus())) {
|
|
||||||
return R.fail("仅已签发状态的申请单可撤回");
|
|
||||||
}
|
|
||||||
// 将申请单状态回滚至待签发
|
|
||||||
RequestForm updateForm = new RequestForm();
|
|
||||||
updateForm.setId(requestFormId);
|
|
||||||
updateForm.setStatus(0);
|
|
||||||
iRequestFormService.updateById(updateForm);
|
|
||||||
// 将关联的诊疗项目状态回滚至DRAFT
|
|
||||||
String prescriptionNo = requestForm.getPrescriptionNo();
|
|
||||||
List<ServiceRequest> serviceRequests = iServiceRequestService
|
|
||||||
.list(new LambdaQueryWrapper<ServiceRequest>().eq(ServiceRequest::getPrescriptionNo, prescriptionNo));
|
|
||||||
for (ServiceRequest serviceRequest : serviceRequests) {
|
|
||||||
ServiceRequest updateService = new ServiceRequest();
|
|
||||||
updateService.setId(serviceRequest.getId());
|
|
||||||
updateService.setStatusEnum(RequestStatus.DRAFT.getValue());
|
|
||||||
iServiceRequestService.updateById(updateService);
|
|
||||||
}
|
|
||||||
return R.ok(null, "撤回成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +99,7 @@ public class RequestFormManageController {
|
|||||||
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
* @param startDate 开始日期(可选,格式:yyyy-MM-dd)
|
||||||
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
* @param endDate 结束日期(可选,格式:yyyy-MM-dd)
|
||||||
* @param status 单据状态(可选)
|
* @param status 单据状态(可选)
|
||||||
* @param keyword 关键字(可选,申请单号/检验项目名称模糊匹配)
|
* @param keyword 关键字(可选,申请单号/检验项目模糊匹配)
|
||||||
* @return 检验申请单
|
* @return 检验申请单
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/get-inspection")
|
@GetMapping(value = "/get-inspection")
|
||||||
@@ -142,6 +143,32 @@ public class RequestFormManageController {
|
|||||||
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.PROCEDURE.getCode()));
|
return R.ok(iRequestFormManageAppService.getRequestForm(encounterId, ActivityDefCategory.PROCEDURE.getCode()));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* 分页查询手术申请单(全局,不需要encounterId,用于门诊手术安排查找弹窗)
|
||||||
|
*
|
||||||
|
* @param surgeryNo 手术单号(模糊查询,可选)
|
||||||
|
* @param applyTimeStart 申请时间起始(可选)
|
||||||
|
* @param applyTimeEnd 申请时间截止(可选)
|
||||||
|
* @param mainDoctorId 主刀医生ID(可选)
|
||||||
|
* @param applyDeptId 申请科室ID(可选)
|
||||||
|
* @param pageNo 页码,默认1
|
||||||
|
* @param pageSize 每页数量,默认10
|
||||||
|
* @return 分页手术申请单列表
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/get-surgery-page")
|
||||||
|
public R<IPage<RequestFormPageDto>> getSurgeryRequestFormPage(
|
||||||
|
@RequestParam(required = false) String surgeryNo,
|
||||||
|
@RequestParam(required = false) LocalDate applyTimeStart,
|
||||||
|
@RequestParam(required = false) LocalDate applyTimeEnd,
|
||||||
|
@RequestParam(required = false) Long mainDoctorId,
|
||||||
|
@RequestParam(required = false) Long applyDeptId,
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||||
|
RequestFormDto dto = new RequestFormDto(surgeryNo, ActivityDefCategory.PROCEDURE.getCode(), applyTimeStart, applyTimeEnd,
|
||||||
|
mainDoctorId, applyDeptId, pageNo, pageSize);
|
||||||
|
return R.ok(iRequestFormManageAppService.getRequestFormPage(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* 分页查询申请单
|
* 分页查询申请单
|
||||||
* @return 申请单
|
* @return 申请单
|
||||||
*/
|
*/
|
||||||
|
|||||||