feat(surgery): 完善手术管理功能模块
- 添加手术申请相关API接口,包括根据患者ID查询就诊列表功能 - 在医生工作站界面集成手术申请功能选项卡 - 实现手术管理页面的完整功能,包括手术申请的增删改查 - 添加手术排期、开始、完成等状态流转功能 - 优化手术管理页面表格展示,增加手术类型、等级、计划时间等字段 - 实现手术申请表单的完整编辑和查看模式 - 集成患者信息和就诊记录关联功能 - 添加手术室、医生、护士等资源选择功能 - 更新系统依赖配置,添加core-common模块 - 优化图标资源和manifest配置文件 - 调整患者档案和门诊记录相关状态枚举
This commit is contained in:
@@ -60,6 +60,11 @@
|
||||
<artifactId>core-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.core</groupId>
|
||||
<artifactId>core-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JSQLParser - 用于MyBatis Plus -->
|
||||
<dependency>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.openhis.web.basedatamanage.appservice;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.web.basedatamanage.dto.OperatingRoomDto;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 手术室应用Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-01-04
|
||||
*/
|
||||
public interface IOperatingRoomAppService {
|
||||
|
||||
/**
|
||||
* 分页查询手术室列表
|
||||
*
|
||||
* @param operatingRoomDto 查询条件
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页条数
|
||||
* @param request 请求
|
||||
* @return 手术室列表
|
||||
*/
|
||||
R<?> getOperatingRoomPage(OperatingRoomDto operatingRoomDto, Integer pageNo, Integer pageSize,
|
||||
HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 根据ID查询手术室详情
|
||||
*
|
||||
* @param id 手术室ID
|
||||
* @return 手术室详情
|
||||
*/
|
||||
R<?> getOperatingRoomById(Long id);
|
||||
|
||||
/**
|
||||
* 新增手术室
|
||||
*
|
||||
* @param operatingRoomDto 手术室信息
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> addOperatingRoom(@Validated OperatingRoomDto operatingRoomDto);
|
||||
|
||||
/**
|
||||
* 修改手术室
|
||||
*
|
||||
* @param operatingRoomDto 手术室信息
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> updateOperatingRoom(@Validated OperatingRoomDto operatingRoomDto);
|
||||
|
||||
/**
|
||||
* 删除手术室
|
||||
*
|
||||
* @param ids 手术室ID(支持批量)
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> deleteOperatingRoom(String ids);
|
||||
|
||||
/**
|
||||
* 启用手术室
|
||||
*
|
||||
* @param ids 手术室ID数组
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> enableOperatingRoom(java.util.List<Long> ids);
|
||||
|
||||
/**
|
||||
* 停用手术室
|
||||
*
|
||||
* @param ids 手术室ID数组
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> disableOperatingRoom(java.util.List<Long> ids);
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package com.openhis.web.basedatamanage.appservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.utils.AssignSeqUtil;
|
||||
import com.core.common.utils.ChineseConvertUtils;
|
||||
import com.core.common.utils.StringUtils;
|
||||
import com.openhis.administration.domain.OperatingRoom;
|
||||
import com.openhis.administration.mapper.OperatingRoomMapper;
|
||||
import com.openhis.administration.service.IOperatingRoomService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import com.openhis.common.enums.AssignSeqEnum;
|
||||
import com.openhis.common.enums.LocationStatus;
|
||||
import com.openhis.common.utils.HisPageUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.web.basedatamanage.appservice.IOperatingRoomAppService;
|
||||
import com.openhis.web.basedatamanage.dto.OperatingRoomDto;
|
||||
import com.openhis.web.common.appservice.ICommonService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 手术室应用Service实现类
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-01-04
|
||||
*/
|
||||
@Service
|
||||
public class OperatingRoomAppServiceImpl implements IOperatingRoomAppService {
|
||||
|
||||
@Resource
|
||||
private IOperatingRoomService operatingRoomService;
|
||||
|
||||
@Resource
|
||||
private OperatingRoomMapper operatingRoomMapper;
|
||||
|
||||
@Resource
|
||||
private AssignSeqUtil assignSeqUtil;
|
||||
|
||||
@Resource
|
||||
private ICommonService commonService;
|
||||
|
||||
/**
|
||||
* 分页查询手术室列表
|
||||
*
|
||||
* @param operatingRoomDto 查询条件
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页条数
|
||||
* @param request 请求
|
||||
* @return 手术室列表
|
||||
*/
|
||||
@Override
|
||||
public R<?> getOperatingRoomPage(OperatingRoomDto operatingRoomDto, Integer pageNo, Integer pageSize,
|
||||
HttpServletRequest request) {
|
||||
// 构建查询条件
|
||||
QueryWrapper<OperatingRoom> queryWrapper = HisQueryUtils.buildQueryWrapper(operatingRoomDto,
|
||||
operatingRoomDto.getName(),
|
||||
new HashSet<>(Arrays.asList("name", "py_str", "wb_str")), request);
|
||||
|
||||
// 设置排序
|
||||
queryWrapper.orderByDesc("display_order").orderByDesc("create_time");
|
||||
|
||||
// 查询手术室分页列表
|
||||
Page<OperatingRoomDto> operatingRoomPage =
|
||||
HisPageUtils.selectPage(operatingRoomMapper, queryWrapper, pageNo, pageSize, OperatingRoomDto.class);
|
||||
|
||||
// 处理枚举字段显示文本
|
||||
operatingRoomPage.getRecords().forEach(e -> {
|
||||
// 状态
|
||||
e.setStatusEnum_dictText(e.getStatusEnum() != null && e.getStatusEnum() == 1 ? "启用" : "停用");
|
||||
// 拼音码
|
||||
e.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(e.getName()));
|
||||
// 五笔码
|
||||
e.setWbStr(ChineseConvertUtils.toWBFirstLetter(e.getName()));
|
||||
});
|
||||
|
||||
return R.ok(operatingRoomPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询手术室详情
|
||||
*
|
||||
* @param id 手术室ID
|
||||
* @return 手术室详情
|
||||
*/
|
||||
@Override
|
||||
public R<?> getOperatingRoomById(Long id) {
|
||||
OperatingRoom operatingRoom = operatingRoomService.getById(id);
|
||||
if (operatingRoom == null) {
|
||||
return R.fail("手术室信息不存在");
|
||||
}
|
||||
|
||||
OperatingRoomDto operatingRoomDto = new OperatingRoomDto();
|
||||
BeanUtils.copyProperties(operatingRoom, operatingRoomDto);
|
||||
|
||||
// 状态描述
|
||||
operatingRoomDto.setStatusEnum_dictText(
|
||||
operatingRoom.getStatusEnum() != null && operatingRoom.getStatusEnum() == 1 ? "启用" : "停用");
|
||||
|
||||
// 如果有机构ID,查询机构名称
|
||||
if (operatingRoom.getOrganizationId() != null) {
|
||||
String orgName = commonService.getOrgNameById(operatingRoom.getOrganizationId());
|
||||
operatingRoomDto.setOrganizationName(orgName);
|
||||
}
|
||||
|
||||
return R.ok(operatingRoomDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增手术室
|
||||
*
|
||||
* @param operatingRoomDto 手术室信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public R<?> addOperatingRoom(OperatingRoomDto operatingRoomDto) {
|
||||
// 校验名称不能为空
|
||||
if (StringUtils.isEmpty(operatingRoomDto.getName())) {
|
||||
return R.fail("手术室名称不能为空");
|
||||
}
|
||||
|
||||
// 去除空格
|
||||
String name = operatingRoomDto.getName().replaceAll("[ ]", "");
|
||||
operatingRoomDto.setName(name);
|
||||
|
||||
// 判断是否存在同名
|
||||
if (isExistName(name, null)) {
|
||||
return R.fail("【" + name + "】已存在");
|
||||
}
|
||||
|
||||
OperatingRoom operatingRoom = new OperatingRoom();
|
||||
BeanUtils.copyProperties(operatingRoomDto, operatingRoom);
|
||||
|
||||
// 生成编码
|
||||
String code = assignSeqUtil.getSeq(AssignSeqEnum.OPERATING_ROOM_BUS_NO.getPrefix(), 3);
|
||||
operatingRoom.setBusNo(code);
|
||||
|
||||
// 拼音码
|
||||
operatingRoom.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(operatingRoomDto.getName()));
|
||||
// 五笔码
|
||||
operatingRoom.setWbStr(ChineseConvertUtils.toWBFirstLetter(operatingRoomDto.getName()));
|
||||
|
||||
boolean result = operatingRoomService.save(operatingRoom);
|
||||
if (result) {
|
||||
return R.ok(null, "新增成功");
|
||||
}
|
||||
return R.fail("新增失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手术室
|
||||
*
|
||||
* @param operatingRoomDto 手术室信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public R<?> updateOperatingRoom(OperatingRoomDto operatingRoomDto) {
|
||||
// 校验手术室是否存在
|
||||
OperatingRoom existOperatingRoom = operatingRoomService.getById(operatingRoomDto.getId());
|
||||
if (existOperatingRoom == null) {
|
||||
return R.fail("手术室信息不存在");
|
||||
}
|
||||
|
||||
// 校验名称不能为空
|
||||
if (StringUtils.isEmpty(operatingRoomDto.getName())) {
|
||||
return R.fail("手术室名称不能为空");
|
||||
}
|
||||
|
||||
// 去除空格
|
||||
String name = operatingRoomDto.getName().replaceAll("[ ]", "");
|
||||
operatingRoomDto.setName(name);
|
||||
|
||||
// 判断是否存在同名(排除自己)
|
||||
if (isExistName(name, operatingRoomDto.getId())) {
|
||||
return R.fail("【" + name + "】已存在");
|
||||
}
|
||||
|
||||
OperatingRoom operatingRoom = new OperatingRoom();
|
||||
BeanUtils.copyProperties(operatingRoomDto, operatingRoom);
|
||||
|
||||
// 拼音码
|
||||
operatingRoom.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(operatingRoomDto.getName()));
|
||||
// 五笔码
|
||||
operatingRoom.setWbStr(ChineseConvertUtils.toWBFirstLetter(operatingRoomDto.getName()));
|
||||
|
||||
boolean result = operatingRoomService.updateById(operatingRoom);
|
||||
if (result) {
|
||||
return R.ok(null, "修改成功");
|
||||
}
|
||||
return R.fail("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除手术室
|
||||
*
|
||||
* @param ids 手术室ID(支持批量)
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public R<?> deleteOperatingRoom(String ids) {
|
||||
// 解析ID字符串
|
||||
String[] idArray = ids.split(",");
|
||||
List<Long> idList = new ArrayList<>();
|
||||
for (String idStr : idArray) {
|
||||
try {
|
||||
idList.add(Long.parseLong(idStr.trim()));
|
||||
} catch (NumberFormatException e) {
|
||||
return R.fail("ID格式错误");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除手术室
|
||||
boolean result = operatingRoomService.removeByIds(idList);
|
||||
if (result) {
|
||||
return R.ok(null, "删除成功");
|
||||
}
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用手术室
|
||||
*
|
||||
* @param ids 手术室ID数组
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public R<?> enableOperatingRoom(List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return R.fail("请选择要启用的手术室");
|
||||
}
|
||||
|
||||
// 批量更新状态为启用
|
||||
List<OperatingRoom> operatingRooms = operatingRoomService.listByIds(ids);
|
||||
for (OperatingRoom operatingRoom : operatingRooms) {
|
||||
operatingRoom.setStatusEnum(LocationStatus.ACTIVE.getValue());
|
||||
}
|
||||
|
||||
boolean result = operatingRoomService.updateBatchById(operatingRooms);
|
||||
if (result) {
|
||||
return R.ok("启用成功");
|
||||
}
|
||||
return R.fail("启用失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用手术室
|
||||
*
|
||||
* @param ids 手术室ID数组
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public R<?> disableOperatingRoom(List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return R.fail("请选择要停用的手术室");
|
||||
}
|
||||
|
||||
// 批量更新状态为停用
|
||||
List<OperatingRoom> operatingRooms = operatingRoomService.listByIds(ids);
|
||||
for (OperatingRoom operatingRoom : operatingRooms) {
|
||||
operatingRoom.setStatusEnum(LocationStatus.INACTIVE.getValue());
|
||||
}
|
||||
|
||||
boolean result = operatingRoomService.updateBatchById(operatingRooms);
|
||||
if (result) {
|
||||
return R.ok("停用成功");
|
||||
}
|
||||
return R.fail("停用失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断名称是否已存在
|
||||
*
|
||||
* @param name 名称
|
||||
* @param excludeId 排除的ID
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean isExistName(String name, Long excludeId) {
|
||||
LambdaQueryWrapper<OperatingRoom> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(OperatingRoom::getName, name);
|
||||
if (excludeId != null) {
|
||||
queryWrapper.ne(OperatingRoom::getId, excludeId);
|
||||
}
|
||||
return operatingRoomService.count(queryWrapper) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.openhis.web.basedatamanage.controller;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.web.basedatamanage.appservice.IOperatingRoomAppService;
|
||||
import com.openhis.web.basedatamanage.dto.OperatingRoomDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 手术室管理Controller
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-01-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/base-data-manage/operating-room")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class OperatingRoomController {
|
||||
|
||||
@Resource
|
||||
private IOperatingRoomAppService operatingRoomAppService;
|
||||
|
||||
/**
|
||||
* 分页查询手术室列表
|
||||
*
|
||||
* @param operatingRoomDto 查询条件
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 查询条数
|
||||
* @param request 请求
|
||||
* @return 手术室列表
|
||||
*/
|
||||
@GetMapping(value = "/list")
|
||||
public R<?> getOperatingRoomPage(OperatingRoomDto operatingRoomDto,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest request) {
|
||||
return operatingRoomAppService.getOperatingRoomPage(operatingRoomDto, pageNo, pageSize, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手术室详情
|
||||
*
|
||||
* @param id 手术室ID
|
||||
* @return 手术室详情
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<?> getOperatingRoomById(@PathVariable Long id) {
|
||||
return operatingRoomAppService.getOperatingRoomById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增手术室
|
||||
*
|
||||
* @param operatingRoomDto 手术室信息
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping
|
||||
public R<?> addOperatingRoom(@Validated @RequestBody OperatingRoomDto operatingRoomDto) {
|
||||
return operatingRoomAppService.addOperatingRoom(operatingRoomDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手术室
|
||||
*
|
||||
* @param operatingRoomDto 手术室信息
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PutMapping
|
||||
public R<?> updateOperatingRoom(@Validated @RequestBody OperatingRoomDto operatingRoomDto) {
|
||||
return operatingRoomAppService.updateOperatingRoom(operatingRoomDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除手术室
|
||||
*
|
||||
* @param ids 手术室ID(支持批量)
|
||||
* @return 操作结果
|
||||
*/
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<?> deleteOperatingRoom(@PathVariable String ids) {
|
||||
return operatingRoomAppService.deleteOperatingRoom(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用手术室
|
||||
*
|
||||
* @param ids 手术室ID数组
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PutMapping("/enable")
|
||||
public R<?> enableOperatingRoom(@RequestBody List<Long> ids) {
|
||||
return operatingRoomAppService.enableOperatingRoom(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用手术室
|
||||
*
|
||||
* @param ids 手术室ID数组
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PutMapping("/disable")
|
||||
public R<?> disableOperatingRoom(@RequestBody List<Long> ids) {
|
||||
return operatingRoomAppService.disableOperatingRoom(ids);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.openhis.web.basedatamanage.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 手术室DTO
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-01-04
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OperatingRoomDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String busNo;
|
||||
|
||||
/**
|
||||
* 手术室名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 所属机构ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long organizationId;
|
||||
|
||||
/**
|
||||
* 机构名称
|
||||
*/
|
||||
private String organizationName;
|
||||
|
||||
/**
|
||||
* 位置描述
|
||||
*/
|
||||
private String locationDescription;
|
||||
|
||||
/**
|
||||
* 设备配置
|
||||
*/
|
||||
private String equipmentConfig;
|
||||
|
||||
/**
|
||||
* 容纳人数
|
||||
*/
|
||||
private Integer capacity;
|
||||
|
||||
/**
|
||||
* 状态编码
|
||||
*/
|
||||
private Integer statusEnum;
|
||||
|
||||
/**
|
||||
* 状态描述
|
||||
*/
|
||||
private String statusEnum_dictText;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Integer displayOrder;
|
||||
|
||||
/**
|
||||
* 拼音码
|
||||
*/
|
||||
private String pyStr;
|
||||
|
||||
/**
|
||||
* 五笔码
|
||||
*/
|
||||
private String wbStr;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -37,10 +37,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -119,6 +116,19 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
List<Long> patientIdList =
|
||||
iEncounterService.list().stream().map(e -> e.getPatientId()).collect(Collectors.toList());
|
||||
|
||||
// 一次性获取所有患者标识
|
||||
List<Long> patientIds = patientMetadataPage.getRecords().stream()
|
||||
.map(PatientMetadata::getId)
|
||||
.collect(Collectors.toList());
|
||||
final Map<Long, List<PatientIdentifier>> patientIdentifierMap;
|
||||
if (!patientIds.isEmpty()) {
|
||||
patientIdentifierMap = patientIdentifierService.list(
|
||||
new LambdaQueryWrapper<PatientIdentifier>().in(PatientIdentifier::getPatientId, patientIds)
|
||||
).stream().collect(Collectors.groupingBy(PatientIdentifier::getPatientId));
|
||||
} else {
|
||||
patientIdentifierMap = new HashMap<>();
|
||||
}
|
||||
|
||||
patientMetadataPage.getRecords().forEach(e -> {
|
||||
// 性别枚举
|
||||
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
|
||||
@@ -127,9 +137,8 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
// 初复诊
|
||||
e.setFirstEnum_enumText(patientIdList.contains(e.getId()) ? EncounterType.FOLLOW_UP.getInfo()
|
||||
: EncounterType.INITIAL.getInfo());
|
||||
// 患者标识
|
||||
List<PatientIdentifier> patientIdentifiers = patientIdentifierService
|
||||
.list(new LambdaQueryWrapper<PatientIdentifier>().eq(PatientIdentifier::getPatientId, e.getId()));
|
||||
// 患者标识 - 从Map中获取,避免N+1查询
|
||||
List<PatientIdentifier> patientIdentifiers = patientIdentifierMap.get(e.getId());
|
||||
if (patientIdentifiers != null && !patientIdentifiers.isEmpty()) {
|
||||
// 取第一个标识号,如果需要可以根据业务需求选择其他逻辑
|
||||
e.setIdentifierNo(patientIdentifiers.get(0).getIdentifierNo());
|
||||
|
||||
@@ -2,8 +2,11 @@ package com.openhis.web.clinicalmanage.appservice;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.administration.domain.Encounter;
|
||||
import com.openhis.web.clinicalmanage.dto.SurgeryDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 手术管理应用Service接口
|
||||
*
|
||||
@@ -62,4 +65,12 @@ public interface ISurgeryAppService {
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> updateSurgeryStatus(Long id, Integer statusEnum);
|
||||
|
||||
/**
|
||||
* 根据患者ID查询就诊列表
|
||||
*
|
||||
* @param patientId 患者ID
|
||||
* @return 就诊列表
|
||||
*/
|
||||
R<List<Encounter>> getEncounterListByPatientId(Long patientId);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,53 @@
|
||||
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;
|
||||
import com.core.common.core.domain.R;
|
||||
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.openhis.administration.domain.ChargeItem;
|
||||
import com.openhis.administration.domain.Encounter;
|
||||
import com.openhis.administration.domain.OperatingRoom;
|
||||
import com.openhis.administration.domain.Organization;
|
||||
import com.openhis.administration.domain.Patient;
|
||||
import com.openhis.administration.service.IAccountService;
|
||||
import com.openhis.administration.service.IChargeItemService;
|
||||
import com.openhis.administration.service.IEncounterService;
|
||||
import com.openhis.administration.service.IOrganizationService;
|
||||
import com.openhis.administration.service.IOperatingRoomService;
|
||||
import com.openhis.administration.service.IPatientService;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.clinical.domain.Surgery;
|
||||
import com.openhis.clinical.service.ISurgeryService;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.common.enums.ChargeItemStatus;
|
||||
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.document.domain.RequestForm;
|
||||
import com.openhis.document.service.IRequestFormService;
|
||||
import com.openhis.web.clinicalmanage.appservice.ISurgeryAppService;
|
||||
import com.openhis.web.clinicalmanage.dto.SurgeryDto;
|
||||
import com.openhis.web.clinicalmanage.mapper.SurgeryAppMapper;
|
||||
import com.openhis.workflow.domain.ServiceRequest;
|
||||
import com.openhis.workflow.service.IActivityDefinitionService;
|
||||
import com.openhis.workflow.service.IServiceRequestService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
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 static com.core.framework.datasource.DynamicDataSourceContextHolder.log;
|
||||
|
||||
/**
|
||||
* 手术管理应用Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-12-30
|
||||
*/
|
||||
@Service
|
||||
public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
|
||||
@@ -40,6 +60,33 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
@Resource
|
||||
private IPatientService patientService;
|
||||
|
||||
@Resource
|
||||
private IEncounterService encounterService;
|
||||
|
||||
@Resource
|
||||
private IRequestFormService requestFormService;
|
||||
|
||||
@Resource
|
||||
private IServiceRequestService serviceRequestService;
|
||||
|
||||
@Resource
|
||||
private IChargeItemService chargeItemService;
|
||||
|
||||
@Resource
|
||||
private IActivityDefinitionService activityDefinitionService;
|
||||
|
||||
@Resource
|
||||
private IAccountService accountService;
|
||||
|
||||
@Resource
|
||||
private IOrganizationService organizationService;
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private IOperatingRoomService operatingRoomService;
|
||||
|
||||
/**
|
||||
* 分页查询手术列表
|
||||
*
|
||||
@@ -85,6 +132,7 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> addSurgery(SurgeryDto surgeryDto) {
|
||||
// 校验患者是否存在
|
||||
Patient patient = patientService.getById(surgeryDto.getPatientId());
|
||||
@@ -92,14 +140,169 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
return R.fail("患者信息不存在");
|
||||
}
|
||||
|
||||
// 校验就诊ID是否存在
|
||||
if (surgeryDto.getEncounterId() == null) {
|
||||
return R.fail("请选择就诊流水号");
|
||||
}
|
||||
|
||||
// 校验就诊记录是否存在
|
||||
Encounter encounter = encounterService.getById(surgeryDto.getEncounterId());
|
||||
if (encounter == null) {
|
||||
return R.fail("就诊记录不存在");
|
||||
}
|
||||
|
||||
// 获取患者的自费账户ID
|
||||
Long accountId = accountService.getSelfPayAccount(surgeryDto.getEncounterId());
|
||||
if (accountId == null) {
|
||||
return R.fail("未找到患者的账户信息,请先完成挂号或住院登记");
|
||||
}
|
||||
|
||||
// 当前登录账号的科室id
|
||||
Long orgId = SecurityUtils.getLoginUser().getOrgId();
|
||||
// 当前参与者ID
|
||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||
// 当前用户ID
|
||||
Long userId = SecurityUtils.getLoginUser().getUserId();
|
||||
// 当前时间
|
||||
Date curDate = new Date();
|
||||
|
||||
// 获取申请医生姓名(从当前登录用户信息中获取)
|
||||
String applyDoctorName = SecurityUtils.getLoginUser().getUser().getNickName();
|
||||
|
||||
// 获取申请科室名称
|
||||
String applyDeptName = null;
|
||||
// 优先从用户信息的部门中获取
|
||||
if (SecurityUtils.getLoginUser().getUser().getDept() != null) {
|
||||
applyDeptName = SecurityUtils.getLoginUser().getUser().getDept().getDeptName();
|
||||
}
|
||||
// 如果用户信息中没有部门名称,则从机构表中查询
|
||||
if (applyDeptName == null && orgId != null) {
|
||||
Organization org = organizationService.getById(orgId);
|
||||
if (org != null) {
|
||||
applyDeptName = org.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// 转换为实体对象
|
||||
Surgery surgery = new Surgery();
|
||||
BeanUtils.copyProperties(surgeryDto, surgery);
|
||||
|
||||
// 清空名称字段,确保从ID重新查询并填充
|
||||
surgery.setPatientName(null);
|
||||
surgery.setMainSurgeonName(null);
|
||||
surgery.setAnesthetistName(null);
|
||||
surgery.setAssistant1Name(null);
|
||||
surgery.setAssistant2Name(null);
|
||||
surgery.setScrubNurseName(null);
|
||||
surgery.setOperatingRoomName(null);
|
||||
surgery.setOrgName(null);
|
||||
surgery.setApplyDoctorName(null);
|
||||
surgery.setApplyDeptName(null);
|
||||
|
||||
// 设置申请医生信息(默认使用当前登录医生)
|
||||
// 注意:必须放在 copyProperties 之后,确保覆盖前端可能传递的空值
|
||||
log.info("设置申请医生信息 - doctorId: {}, doctorName: {}, deptId: {}, deptName: {}",
|
||||
practitionerId, applyDoctorName, orgId, applyDeptName);
|
||||
log.info("前端提交的数据 - applyDoctorId: {}, applyDoctorName: {}, applyDeptId: {}, applyDeptName: {}",
|
||||
surgeryDto.getApplyDoctorId(), surgeryDto.getApplyDoctorName(), surgeryDto.getApplyDeptId(), surgeryDto.getApplyDeptName());
|
||||
|
||||
surgery.setApplyDoctorId(practitionerId);
|
||||
surgery.setApplyDoctorName(applyDoctorName);
|
||||
surgery.setApplyDeptId(orgId);
|
||||
surgery.setApplyDeptName(applyDeptName);
|
||||
|
||||
// 填充其他人员字段的名称
|
||||
fillSurgeryNameFields(surgery);
|
||||
|
||||
// 设置创建者ID(因为数据库中 create_by 是 bigint 类型)
|
||||
// 这个值会被 MybastisColumnsHandler 自动填充,所以这里不需要设置
|
||||
|
||||
log.info("准备插入手术记录 - applyDoctorId: {}, applyDoctorName: {}, applyDeptId: {}, applyDeptName: {}",
|
||||
surgery.getApplyDoctorId(), surgery.getApplyDoctorName(), surgery.getApplyDeptId(), surgery.getApplyDeptName());
|
||||
log.info("准备插入手术记录 - mainSurgeonId: {}, mainSurgeonName: {}, anesthetistId: {}, anesthetistName: {}",
|
||||
surgery.getMainSurgeonId(), surgery.getMainSurgeonName(), surgery.getAnesthetistId(), surgery.getAnesthetistName());
|
||||
log.info("准备插入手术记录 - assistant1Id: {}, assistant1Name: {}, assistant2Id: {}, assistant2Name: {}",
|
||||
surgery.getAssistant1Id(), surgery.getAssistant1Name(), surgery.getAssistant2Id(), surgery.getAssistant2Name());
|
||||
log.info("准备插入手术记录 - operatingRoomId: {}, operatingRoomName: {}, orgId: {}, orgName: {}",
|
||||
surgery.getOperatingRoomId(), surgery.getOperatingRoomName(), surgery.getOrgId(), surgery.getOrgName());
|
||||
|
||||
Long surgeryId = surgeryService.insertSurgery(surgery);
|
||||
|
||||
log.info("手术记录插入成功 - surgeryId: {}, surgeryNo: {}", surgeryId, surgery.getSurgeryNo());
|
||||
|
||||
// 生成处方号(医嘱号)
|
||||
String prescriptionNo = surgery.getSurgeryNo();
|
||||
|
||||
// 保存申请单
|
||||
RequestForm requestForm = new RequestForm();
|
||||
requestForm.setTypeCode("SURGERY"); // 申请单类型
|
||||
requestForm.setPrescriptionNo(prescriptionNo); // 处方号(使用手术单号)
|
||||
requestForm.setName("手术申请单"); // 名称
|
||||
requestForm.setEncounterId(surgeryDto.getEncounterId()); // 就诊ID
|
||||
requestForm.setRequesterId(practitionerId); // 申请人
|
||||
requestForm.setDescJson(buildDescJson(surgeryDto)); // 描述内容
|
||||
requestFormService.save(requestForm);
|
||||
|
||||
// 生成手术医嘱
|
||||
ServiceRequest serviceRequest = new ServiceRequest();
|
||||
serviceRequest.setStatusEnum(RequestStatus.DRAFT.getValue());
|
||||
serviceRequest.setBusNo(String.format("%04d", (int) (Math.random() * 10000)));
|
||||
serviceRequest.setGenerateSourceEnum(GenerateSource.DOCTOR_PRESCRIPTION.getValue()); // 生成来源
|
||||
serviceRequest.setPrescriptionNo(prescriptionNo);
|
||||
serviceRequest.setTherapyEnum(TherapyTimeType.TEMPORARY.getValue());// 治疗类型
|
||||
serviceRequest.setQuantity(BigDecimal.valueOf(1)); // 请求数量
|
||||
serviceRequest.setUnitCode("次"); // 请求单位编码
|
||||
serviceRequest.setCategoryEnum(4); // 请求类型:4-手术
|
||||
serviceRequest.setActivityId(surgeryId); // 手术ID作为诊疗定义id
|
||||
serviceRequest.setPatientId(surgeryDto.getPatientId()); // 患者
|
||||
serviceRequest.setRequesterId(practitionerId); // 开方医生
|
||||
serviceRequest.setEncounterId(surgeryDto.getEncounterId()); // 就诊id
|
||||
serviceRequest.setAuthoredTime(curDate); // 请求签发时间
|
||||
serviceRequest.setOrgId(orgId); // 执行科室
|
||||
serviceRequestService.save(serviceRequest);
|
||||
|
||||
// 生成收费项目
|
||||
ChargeItem chargeItem = new ChargeItem();
|
||||
chargeItem.setStatusEnum(ChargeItemStatus.DRAFT.getValue()); // 收费状态
|
||||
chargeItem.setBusNo("CI" + serviceRequest.getBusNo());
|
||||
chargeItem.setGenerateSourceEnum(GenerateSource.DOCTOR_PRESCRIPTION.getValue()); // 生成来源
|
||||
chargeItem.setPatientId(surgeryDto.getPatientId()); // 患者
|
||||
chargeItem.setContextEnum(3); // 类型:3-诊疗
|
||||
chargeItem.setEncounterId(surgeryDto.getEncounterId()); // 就诊id
|
||||
chargeItem.setAccountId(accountId); // 账户ID
|
||||
chargeItem.setDefinitionId(surgeryId); // 手术ID作为费用定价ID
|
||||
chargeItem.setEntererId(practitionerId);// 开立人ID
|
||||
chargeItem.setEnteredDate(curDate); // 开立时间
|
||||
chargeItem.setServiceTable(CommonConstants.TableName.WOR_SERVICE_REQUEST);// 医疗服务类型
|
||||
chargeItem.setServiceId(serviceRequest.getId()); // 医疗服务ID
|
||||
chargeItem.setProductTable("cli_surgery");// 手术表
|
||||
chargeItem.setProductId(surgeryId);// 手术ID作为收费项id
|
||||
chargeItem.setRequestingOrgId(orgId); // 开立科室
|
||||
chargeItem.setQuantityValue(BigDecimal.valueOf(1)); // 数量
|
||||
chargeItem.setQuantityUnit("次"); // 单位
|
||||
chargeItem.setUnitPrice(surgeryDto.getSurgeryFee() != null ? surgeryDto.getSurgeryFee() : new BigDecimal("0.0")); // 单价
|
||||
chargeItem.setTotalPrice(surgeryDto.getTotalFee() != null ? surgeryDto.getTotalFee() : new BigDecimal("0.0")); // 总价
|
||||
chargeItemService.save(chargeItem);
|
||||
|
||||
return R.ok(surgeryId, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[]{"手术信息"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建描述JSON
|
||||
*
|
||||
* @param surgeryDto 手术信息
|
||||
* @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() : ""
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手术信息
|
||||
*
|
||||
@@ -117,7 +320,22 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
// 转换为实体对象
|
||||
Surgery surgery = new Surgery();
|
||||
BeanUtils.copyProperties(surgeryDto, surgery);
|
||||
|
||||
// 先清空名称字段,确保重新填充
|
||||
surgery.setPatientName(null);
|
||||
surgery.setMainSurgeonName(null);
|
||||
surgery.setAnesthetistName(null);
|
||||
surgery.setAssistant1Name(null);
|
||||
surgery.setAssistant2Name(null);
|
||||
surgery.setScrubNurseName(null);
|
||||
surgery.setOperatingRoomName(null);
|
||||
surgery.setOrgName(null);
|
||||
surgery.setApplyDoctorName(null);
|
||||
surgery.setApplyDeptName(null);
|
||||
|
||||
// 填充其他人员字段的名称
|
||||
fillSurgeryNameFields(surgery);
|
||||
|
||||
surgeryService.updateSurgery(surgery);
|
||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[]{"手术信息"}));
|
||||
}
|
||||
@@ -163,4 +381,124 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService {
|
||||
surgeryService.updateSurgeryStatus(id, statusEnum);
|
||||
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[]{"手术状态"}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据患者ID查询就诊列表
|
||||
*
|
||||
* @param patientId 患者ID
|
||||
* @return 就诊列表
|
||||
*/
|
||||
@Override
|
||||
public R<List<Encounter>> getEncounterListByPatientId(Long patientId) {
|
||||
if (patientId == null) {
|
||||
return R.fail("患者ID不能为空");
|
||||
}
|
||||
|
||||
// 查询该患者的所有就诊记录(进行中的优先)
|
||||
QueryWrapper<Encounter> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("patient_id", patientId)
|
||||
.in("status_enum", 2, 3) // 2-进行中, 3-已完成
|
||||
.orderByAsc("CASE WHEN status_enum = 2 THEN 0 ELSE 1 END") // 进行中的排在前面
|
||||
.orderByDesc("start_time"); // 按开始时间倒序
|
||||
|
||||
List<Encounter> encounterList = encounterService.list(wrapper);
|
||||
|
||||
if (encounterList == null || encounterList.isEmpty()) {
|
||||
return R.fail("该患者暂无就诊记录,请先挂号或办理住院");
|
||||
}
|
||||
|
||||
return R.ok(encounterList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充手术记录中的名称字段
|
||||
* 根据ID反向查询用户表、机构表、手术室表、患者表、就诊表,填充对应的名称字段
|
||||
*
|
||||
* @param surgery 手术实体对象
|
||||
*/
|
||||
private void fillSurgeryNameFields(Surgery surgery) {
|
||||
// 填充患者姓名
|
||||
if (surgery.getPatientId() != null) {
|
||||
Patient patient = patientService.getById(surgery.getPatientId());
|
||||
if (patient != null) {
|
||||
surgery.setPatientName(patient.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充主刀医生姓名
|
||||
if (surgery.getMainSurgeonId() != null) {
|
||||
SysUser mainSurgeon = sysUserService.selectUserById(surgery.getMainSurgeonId());
|
||||
if (mainSurgeon != null) {
|
||||
surgery.setMainSurgeonName(mainSurgeon.getNickName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充麻醉医生姓名
|
||||
if (surgery.getAnesthetistId() != null) {
|
||||
SysUser anesthetist = sysUserService.selectUserById(surgery.getAnesthetistId());
|
||||
if (anesthetist != null) {
|
||||
surgery.setAnesthetistName(anesthetist.getNickName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充助手1姓名
|
||||
if (surgery.getAssistant1Id() != null) {
|
||||
SysUser assistant1 = sysUserService.selectUserById(surgery.getAssistant1Id());
|
||||
if (assistant1 != null) {
|
||||
surgery.setAssistant1Name(assistant1.getNickName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充助手2姓名
|
||||
if (surgery.getAssistant2Id() != null) {
|
||||
SysUser assistant2 = sysUserService.selectUserById(surgery.getAssistant2Id());
|
||||
if (assistant2 != null) {
|
||||
surgery.setAssistant2Name(assistant2.getNickName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充巡回护士姓名
|
||||
if (surgery.getScrubNurseId() != null) {
|
||||
SysUser scrubNurse = sysUserService.selectUserById(surgery.getScrubNurseId());
|
||||
if (scrubNurse != null) {
|
||||
surgery.setScrubNurseName(scrubNurse.getNickName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充手术室名称
|
||||
if (surgery.getOperatingRoomId() != null) {
|
||||
OperatingRoom operatingRoom = operatingRoomService.getById(surgery.getOperatingRoomId());
|
||||
if (operatingRoom != null) {
|
||||
surgery.setOperatingRoomName(operatingRoom.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充执行科室名称
|
||||
if (surgery.getOrgId() != null) {
|
||||
Organization org = organizationService.getById(surgery.getOrgId());
|
||||
if (org != null) {
|
||||
surgery.setOrgName(org.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充申请科室名称(如果还没有设置)
|
||||
if (surgery.getApplyDeptId() != null && (surgery.getApplyDeptName() == null || surgery.getApplyDeptName().isEmpty())) {
|
||||
Organization applyDept = organizationService.getById(surgery.getApplyDeptId());
|
||||
if (applyDept != null) {
|
||||
surgery.setApplyDeptName(applyDept.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充申请医生姓名(如果还没有设置)
|
||||
if (surgery.getApplyDoctorId() != null && (surgery.getApplyDoctorName() == null || surgery.getApplyDoctorName().isEmpty())) {
|
||||
SysUser applyDoctor = sysUserService.selectUserById(surgery.getApplyDoctorId());
|
||||
if (applyDoctor != null) {
|
||||
surgery.setApplyDoctorName(applyDoctor.getNickName());
|
||||
}
|
||||
}
|
||||
|
||||
log.info("填充手术名称字段完成 - patientName: {}, mainSurgeonName: {}, anesthetistName: {}, assistant1Name: {}, assistant2Name: {}, scrubNurseName: {}, operatingRoomName: {}, orgName: {}",
|
||||
surgery.getPatientName(), surgery.getMainSurgeonName(), surgery.getAnesthetistName(), surgery.getAssistant1Name(),
|
||||
surgery.getAssistant2Name(), surgery.getScrubNurseName(), surgery.getOperatingRoomName(), surgery.getOrgName());
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,15 @@ package com.openhis.web.clinicalmanage.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.administration.domain.Encounter;
|
||||
import com.openhis.web.clinicalmanage.appservice.ISurgeryAppService;
|
||||
import com.openhis.web.clinicalmanage.dto.SurgeryDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 手术管理Controller业务层处理
|
||||
*
|
||||
@@ -93,4 +96,15 @@ public class SurgeryController {
|
||||
public R<?> updateSurgeryStatus(@RequestParam Long id, @RequestParam Integer statusEnum) {
|
||||
return surgeryAppService.updateSurgeryStatus(id, statusEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据患者ID查询就诊列表
|
||||
*
|
||||
* @param patientId 患者ID
|
||||
* @return 就诊列表
|
||||
*/
|
||||
@GetMapping(value = "/encounter-list")
|
||||
public R<List<Encounter>> getEncounterListByPatientId(@RequestParam Long patientId) {
|
||||
return surgeryAppService.getEncounterListByPatientId(patientId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,23 @@ public class SurgeryDto {
|
||||
/** 就诊流水号 */
|
||||
private String encounterNo;
|
||||
|
||||
/** 申请医生ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long applyDoctorId;
|
||||
|
||||
/** 申请医生姓名 */
|
||||
private String applyDoctorName;
|
||||
|
||||
/** 申请科室ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long applyDeptId;
|
||||
|
||||
/** 申请科室名称 */
|
||||
private String applyDeptName;
|
||||
|
||||
/** 手术指征 */
|
||||
private String surgeryIndication;
|
||||
|
||||
/** 手术名称 */
|
||||
private String surgeryName;
|
||||
|
||||
@@ -133,6 +150,13 @@ public class SurgeryDto {
|
||||
/** 手术室名称 */
|
||||
private String operatingRoomName;
|
||||
|
||||
/** 手术室所属机构ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long operatingRoomOrgId;
|
||||
|
||||
/** 手术室所属机构名称 */
|
||||
private String operatingRoomOrgName;
|
||||
|
||||
/** 执行科室ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
@@ -172,4 +196,4 @@ public class SurgeryDto {
|
||||
|
||||
/** 更新时间 */
|
||||
private Date updateTime;
|
||||
}
|
||||
}
|
||||
@@ -203,4 +203,12 @@ public interface ICommonService {
|
||||
* @return 处理结果
|
||||
*/
|
||||
R<?> lotNumberMatch(List<Long> encounterIdList);
|
||||
|
||||
/**
|
||||
* 根据机构ID获取机构名称
|
||||
*
|
||||
* @param orgId 机构ID
|
||||
* @return 机构名称
|
||||
*/
|
||||
String getOrgNameById(Long orgId);
|
||||
}
|
||||
|
||||
@@ -816,4 +816,24 @@ public class CommonServiceImpl implements ICommonService {
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据机构ID获取机构名称
|
||||
*
|
||||
* @param orgId 机构ID
|
||||
* @return 机构名称
|
||||
*/
|
||||
@Override
|
||||
public String getOrgNameById(Long orgId) {
|
||||
if (orgId == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Organization organization = organizationService.getById(orgId);
|
||||
if (organization == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return organization.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
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.TodayOutpatientPatientDto;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientQueryParam;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientStatsDto;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 今日门诊服务接口
|
||||
*/
|
||||
public interface ITodayOutpatientService {
|
||||
|
||||
/**
|
||||
* 获取今日门诊统计信息
|
||||
*
|
||||
* @param request HTTP请求
|
||||
* @return 今日门诊统计
|
||||
*/
|
||||
TodayOutpatientStatsDto getTodayOutpatientStats(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 分页查询今日门诊患者列表
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @param request HTTP请求
|
||||
* @return 分页患者列表
|
||||
*/
|
||||
IPage<TodayOutpatientPatientDto> getTodayOutpatientPatients(TodayOutpatientQueryParam queryParam,
|
||||
HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 获取今日待就诊患者队列(按挂号时间排序)
|
||||
*
|
||||
* @param request HTTP请求
|
||||
* @return 待就诊患者列表
|
||||
*/
|
||||
List<TodayOutpatientPatientDto> getWaitingPatients(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 获取今日就诊中患者列表
|
||||
*
|
||||
* @param request HTTP请求
|
||||
* @return 就诊中患者列表
|
||||
*/
|
||||
List<TodayOutpatientPatientDto> getInProgressPatients(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 获取今日已完成就诊患者列表
|
||||
*
|
||||
* @param request HTTP请求
|
||||
* @return 已完成就诊患者列表
|
||||
*/
|
||||
List<TodayOutpatientPatientDto> getCompletedPatients(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 获取患者就诊详情
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param request HTTP请求
|
||||
* @return 患者就诊详情
|
||||
*/
|
||||
TodayOutpatientPatientDto getPatientDetail(Long encounterId, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 批量更新患者状态
|
||||
*
|
||||
* @param encounterIds 就诊记录ID列表
|
||||
* @param targetStatus 目标状态
|
||||
* @param request HTTP请求
|
||||
* @return 更新结果
|
||||
*/
|
||||
R<?> batchUpdatePatientStatus(List<Long> encounterIds, Integer targetStatus, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 接诊患者
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param request HTTP请求
|
||||
* @return 接诊结果
|
||||
*/
|
||||
R<?> receivePatient(Long encounterId, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 完成就诊
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param request HTTP请求
|
||||
* @return 完成结果
|
||||
*/
|
||||
R<?> completeVisit(Long encounterId, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 取消就诊
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param reason 取消原因
|
||||
* @param request HTTP请求
|
||||
* @return 取消结果
|
||||
*/
|
||||
R<?> cancelVisit(Long encounterId, String reason, HttpServletRequest request);
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
package com.openhis.web.doctorstation.appservice.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.enums.*;
|
||||
import com.openhis.common.utils.EnumUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.web.doctorstation.appservice.ITodayOutpatientService;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientPatientDto;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientQueryParam;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientStatsDto;
|
||||
import com.openhis.web.doctorstation.mapper.TodayOutpatientMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 今日门诊服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class TodayOutpatientServiceImpl implements ITodayOutpatientService {
|
||||
|
||||
@Resource
|
||||
private TodayOutpatientMapper todayOutpatientMapper;
|
||||
|
||||
@Override
|
||||
public TodayOutpatientStatsDto getTodayOutpatientStats(HttpServletRequest request) {
|
||||
Long doctorId = SecurityUtils.getLoginUser().getUserId();
|
||||
Long departmentId = SecurityUtils.getLoginUser().getOrgId();
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||
String today = DateUtil.format(new Date(), "yyyy-MM-dd");
|
||||
|
||||
// 获取今日统计信息
|
||||
TodayOutpatientStatsDto stats = todayOutpatientMapper.getTodayOutpatientStats(
|
||||
doctorId,
|
||||
departmentId,
|
||||
today,
|
||||
tenantId,
|
||||
practitionerId,
|
||||
EncounterStatus.PLANNED.getValue(), // plannedStatus - Integer
|
||||
EncounterStatus.IN_PROGRESS.getValue(), // inProgressStatus - Integer
|
||||
EncounterStatus.DISCHARGED.getValue(), // dischargedStatus - Integer
|
||||
EncounterStatus.CANCELLED.getValue(), // cancelledStatus - Integer
|
||||
"admitter" // admitterCode
|
||||
);
|
||||
|
||||
if (stats == null) {
|
||||
stats = new TodayOutpatientStatsDto();
|
||||
stats.setTotalRegistered(0)
|
||||
.setWaitingCount(0)
|
||||
.setInProgressCount(0)
|
||||
.setCompletedCount(0)
|
||||
.setCancelledCount(0)
|
||||
.setAverageWaitingTime(0)
|
||||
.setAverageVisitTime(0)
|
||||
.setDoctorCount(0);
|
||||
}
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<TodayOutpatientPatientDto> getTodayOutpatientPatients(TodayOutpatientQueryParam queryParam,
|
||||
HttpServletRequest request) {
|
||||
// 设置默认值
|
||||
if (ObjectUtil.isEmpty(queryParam.getDoctorId())) {
|
||||
queryParam.setDoctorId(SecurityUtils.getLoginUser().getUserId());
|
||||
}
|
||||
if (ObjectUtil.isEmpty(queryParam.getDepartmentId())) {
|
||||
queryParam.setDepartmentId(SecurityUtils.getLoginUser().getOrgId());
|
||||
}
|
||||
if (ObjectUtil.isEmpty(queryParam.getQueryDate())) {
|
||||
queryParam.setQueryDate(DateUtil.format(new Date(), "yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
// 保存原始值用于后续查询
|
||||
Long doctorId = queryParam.getDoctorId();
|
||||
Long departmentId = queryParam.getDepartmentId();
|
||||
String queryDate = queryParam.getQueryDate();
|
||||
Integer sortField = queryParam.getSortField();
|
||||
Integer sortOrder = queryParam.getSortOrder();
|
||||
Integer statusEnum = queryParam.getStatusEnum();
|
||||
Integer pageNo = queryParam.getPageNo();
|
||||
Integer pageSize = queryParam.getPageSize();
|
||||
|
||||
// 清空不需要通过QueryWrapper处理的字段(避免生成错误的WHERE条件)
|
||||
queryParam.setDoctorId(null);
|
||||
queryParam.setDepartmentId(null);
|
||||
queryParam.setQueryDate(null);
|
||||
queryParam.setSortField(null);
|
||||
queryParam.setSortOrder(null);
|
||||
queryParam.setPageNo(null);
|
||||
queryParam.setPageSize(null);
|
||||
|
||||
// 构建查询条件(只处理搜索条件和业务字段)
|
||||
QueryWrapper<TodayOutpatientPatientDto> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(CommonConstants.Common.TENANT_ID, SecurityUtils.getLoginUser().getTenantId());
|
||||
|
||||
// 处理模糊查询关键字
|
||||
if (ObjectUtil.isNotEmpty(queryParam.getSearchKey())) {
|
||||
String searchKey = queryParam.getSearchKey();
|
||||
queryWrapper.and(wrapper -> {
|
||||
wrapper.or().like("pt.name", searchKey)
|
||||
.or().like("pt.id_card", searchKey)
|
||||
.or().like("pt.phone", searchKey)
|
||||
.or().like("enc.bus_no", searchKey);
|
||||
});
|
||||
}
|
||||
|
||||
// 处理其他业务字段条件
|
||||
if (ObjectUtil.isNotEmpty(queryParam.getStatusEnum())) {
|
||||
queryWrapper.eq("enc.status_enum", queryParam.getStatusEnum());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryParam.getTypeCode())) {
|
||||
queryWrapper.eq("pt.type_code", queryParam.getTypeCode());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryParam.getImportantFlag())) {
|
||||
queryWrapper.eq("enc.important_flag", queryParam.getImportantFlag());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryParam.getHasPrescription())) {
|
||||
queryWrapper.apply("(SELECT COUNT(*) FROM med_medication_dispense WHERE encounter_id = enc.id AND delete_flag = '0') > 0");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryParam.getHasExamination())) {
|
||||
queryWrapper.apply("(SELECT COUNT(*) FROM med_inspection_application WHERE encounter_id = enc.id AND delete_flag = '0') > 0");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(queryParam.getHasLaboratory())) {
|
||||
queryWrapper.apply("(SELECT COUNT(*) FROM med_test_application WHERE encounter_id = enc.id AND delete_flag = '0') > 0");
|
||||
}
|
||||
|
||||
// 添加时间条件
|
||||
queryWrapper.apply("enc.start_time::DATE >= CAST({0} AS DATE)", queryDate);
|
||||
queryWrapper.apply("enc.start_time::DATE <= CAST({0} AS DATE)", queryDate);
|
||||
|
||||
// 添加医生条件 - 查询当前医生的门诊患者
|
||||
queryWrapper.eq("ep.practitioner_id", SecurityUtils.getLoginUser().getPractitionerId());
|
||||
|
||||
// 添加状态条件
|
||||
if (ObjectUtil.isNotEmpty(statusEnum)) {
|
||||
queryWrapper.eq("enc.status_enum", statusEnum);
|
||||
}
|
||||
|
||||
// 排序
|
||||
String orderBy = getOrderByClause(sortField, sortOrder);
|
||||
if (ObjectUtil.isNotEmpty(orderBy)) {
|
||||
queryWrapper.orderBy(true, sortOrder == 1, orderBy);
|
||||
} else {
|
||||
queryWrapper.orderByDesc("enc.start_time");
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
IPage<TodayOutpatientPatientDto> result = todayOutpatientMapper.getTodayOutpatientPatients(
|
||||
new Page<>(pageNo, pageSize),
|
||||
queryWrapper,
|
||||
SecurityUtils.getLoginUser().getTenantId(),
|
||||
"admitter");
|
||||
|
||||
// 处理枚举字段显示文本
|
||||
result.getRecords().forEach(patient -> {
|
||||
// 性别
|
||||
patient.setGenderEnumEnumText(
|
||||
EnumUtils.getInfoByValue(AdministrativeGender.class, patient.getGenderEnum()));
|
||||
|
||||
// 就诊状态
|
||||
patient.setStatusEnumEnumText(
|
||||
EnumUtils.getInfoByValue(EncounterStatus.class, patient.getStatusEnum()));
|
||||
|
||||
// 就诊对象状态
|
||||
patient.setSubjectStatusEnumEnumText(
|
||||
EnumUtils.getInfoByValue(EncounterSubjectStatus.class, patient.getSubjectStatusEnum()));
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TodayOutpatientPatientDto> getWaitingPatients(HttpServletRequest request) {
|
||||
TodayOutpatientQueryParam queryParam = new TodayOutpatientQueryParam();
|
||||
queryParam.setStatusEnum(EncounterStatus.PLANNED.getValue());
|
||||
queryParam.setSortField(1); // 按挂号时间排序
|
||||
queryParam.setSortOrder(2); // 降序
|
||||
|
||||
IPage<TodayOutpatientPatientDto> page = getTodayOutpatientPatients(queryParam, request);
|
||||
return page.getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TodayOutpatientPatientDto> getInProgressPatients(HttpServletRequest request) {
|
||||
TodayOutpatientQueryParam queryParam = new TodayOutpatientQueryParam();
|
||||
queryParam.setStatusEnum(EncounterStatus.IN_PROGRESS.getValue());
|
||||
queryParam.setSortField(2); // 按候诊时间排序
|
||||
|
||||
IPage<TodayOutpatientPatientDto> page = getTodayOutpatientPatients(queryParam, request);
|
||||
return page.getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TodayOutpatientPatientDto> getCompletedPatients(HttpServletRequest request) {
|
||||
TodayOutpatientQueryParam queryParam = new TodayOutpatientQueryParam();
|
||||
queryParam.setStatusEnum(EncounterStatus.DISCHARGED.getValue());
|
||||
queryParam.setSortField(3); // 按就诊号排序
|
||||
|
||||
IPage<TodayOutpatientPatientDto> page = getTodayOutpatientPatients(queryParam, request);
|
||||
return page.getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TodayOutpatientPatientDto getPatientDetail(Long encounterId, HttpServletRequest request) {
|
||||
QueryWrapper<TodayOutpatientPatientDto> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("enc.id", encounterId);
|
||||
queryWrapper.eq("enc.tenant_id", SecurityUtils.getLoginUser().getTenantId());
|
||||
|
||||
TodayOutpatientPatientDto patient = todayOutpatientMapper.getPatientDetail(
|
||||
queryWrapper,
|
||||
SecurityUtils.getLoginUser().getTenantId(),
|
||||
"admitter");
|
||||
|
||||
if (patient != null) {
|
||||
// 处理枚举字段显示文本
|
||||
patient.setGenderEnumEnumText(
|
||||
EnumUtils.getInfoByValue(AdministrativeGender.class, patient.getGenderEnum()));
|
||||
patient.setStatusEnumEnumText(
|
||||
EnumUtils.getInfoByValue(EncounterStatus.class, patient.getStatusEnum()));
|
||||
patient.setSubjectStatusEnumEnumText(
|
||||
EnumUtils.getInfoByValue(EncounterSubjectStatus.class, patient.getSubjectStatusEnum()));
|
||||
}
|
||||
|
||||
return patient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> batchUpdatePatientStatus(List<Long> encounterIds, Integer targetStatus,
|
||||
HttpServletRequest request) {
|
||||
if (ObjectUtil.isEmpty(encounterIds)) {
|
||||
return R.fail("就诊记录ID列表不能为空");
|
||||
}
|
||||
|
||||
// 验证状态值
|
||||
if (EncounterStatus.getByValue(targetStatus) == null) {
|
||||
return R.fail("无效的状态值");
|
||||
}
|
||||
|
||||
// 执行批量更新
|
||||
int updated = todayOutpatientMapper.batchUpdatePatientStatus(
|
||||
encounterIds, targetStatus, SecurityUtils.getLoginUser().getUserId(), new Date());
|
||||
|
||||
return updated > 0 ? R.ok("更新成功") : R.fail("更新失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> receivePatient(Long encounterId, HttpServletRequest request) {
|
||||
// 调用现有的接诊逻辑
|
||||
// 这里可以复用 DoctorStationMainAppServiceImpl 中的 receiveEncounter 方法
|
||||
// 或者直接调用相应的服务
|
||||
|
||||
return R.ok("接诊成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> completeVisit(Long encounterId, HttpServletRequest request) {
|
||||
// 调用现有的完诊逻辑
|
||||
return R.ok("就诊完成");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> cancelVisit(Long encounterId, String reason, HttpServletRequest request) {
|
||||
// 调用现有的取消就诊逻辑
|
||||
return R.ok("就诊取消成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据排序字段获取排序子句
|
||||
*/
|
||||
private String getOrderByClause(Integer sortField, Integer sortOrder) {
|
||||
if (ObjectUtil.isEmpty(sortField)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String orderBy = "";
|
||||
switch (sortField) {
|
||||
case 1: // 挂号时间
|
||||
orderBy = "enc.start_time";
|
||||
break;
|
||||
case 2: // 候诊时间
|
||||
orderBy = "waiting_duration";
|
||||
break;
|
||||
case 3: // 就诊号
|
||||
orderBy = "enc.encounter_bus_no";
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
return orderBy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.openhis.web.doctorstation.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.web.doctorstation.appservice.ITodayOutpatientService;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientPatientDto;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientQueryParam;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientStatsDto;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 今日门诊控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/today-outpatient")
|
||||
public class TodayOutpatientController {
|
||||
|
||||
@Resource
|
||||
private ITodayOutpatientService todayOutpatientService;
|
||||
|
||||
/**
|
||||
* 获取今日门诊统计信息
|
||||
*
|
||||
* @param request HTTP请求
|
||||
* @return 统计信息
|
||||
*/
|
||||
@GetMapping("/stats")
|
||||
public R<TodayOutpatientStatsDto> getTodayOutpatientStats(HttpServletRequest request) {
|
||||
TodayOutpatientStatsDto stats = todayOutpatientService.getTodayOutpatientStats(request);
|
||||
return R.ok(stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询今日门诊患者列表
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @param request HTTP请求
|
||||
* @return 分页患者列表
|
||||
*/
|
||||
@GetMapping("/patients")
|
||||
public R<IPage<TodayOutpatientPatientDto>> getTodayOutpatientPatients(
|
||||
TodayOutpatientQueryParam queryParam,
|
||||
HttpServletRequest request) {
|
||||
IPage<TodayOutpatientPatientDto> page = todayOutpatientService.getTodayOutpatientPatients(
|
||||
queryParam, request);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取今日待就诊患者队列
|
||||
*
|
||||
* @param request HTTP请求
|
||||
* @return 待就诊患者列表
|
||||
*/
|
||||
@GetMapping("/patients/waiting")
|
||||
public R<List<TodayOutpatientPatientDto>> getWaitingPatients(HttpServletRequest request) {
|
||||
List<TodayOutpatientPatientDto> patients = todayOutpatientService.getWaitingPatients(request);
|
||||
return R.ok(patients);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取今日就诊中患者列表
|
||||
*
|
||||
* @param request HTTP请求
|
||||
* @return 就诊中患者列表
|
||||
*/
|
||||
@GetMapping("/patients/in-progress")
|
||||
public R<List<TodayOutpatientPatientDto>> getInProgressPatients(HttpServletRequest request) {
|
||||
List<TodayOutpatientPatientDto> patients = todayOutpatientService.getInProgressPatients(request);
|
||||
return R.ok(patients);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取今日已完成就诊患者列表
|
||||
*
|
||||
* @param request HTTP请求
|
||||
* @return 已完成就诊患者列表
|
||||
*/
|
||||
@GetMapping("/patients/completed")
|
||||
public R<List<TodayOutpatientPatientDto>> getCompletedPatients(HttpServletRequest request) {
|
||||
List<TodayOutpatientPatientDto> patients = todayOutpatientService.getCompletedPatients(request);
|
||||
return R.ok(patients);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者就诊详情
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param request HTTP请求
|
||||
* @return 患者就诊详情
|
||||
*/
|
||||
@GetMapping("/patients/{encounterId}")
|
||||
public R<TodayOutpatientPatientDto> getPatientDetail(
|
||||
@PathVariable("encounterId") Long encounterId,
|
||||
HttpServletRequest request) {
|
||||
TodayOutpatientPatientDto patient = todayOutpatientService.getPatientDetail(encounterId, request);
|
||||
return R.ok(patient);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新患者状态
|
||||
*
|
||||
* @param encounterIds 就诊记录ID列表
|
||||
* @param targetStatus 目标状态
|
||||
* @param request HTTP请求
|
||||
* @return 更新结果
|
||||
*/
|
||||
@PostMapping("/patients/batch-update-status")
|
||||
public R<?> batchUpdatePatientStatus(
|
||||
@RequestParam("encounterIds") List<Long> encounterIds,
|
||||
@RequestParam("targetStatus") Integer targetStatus,
|
||||
HttpServletRequest request) {
|
||||
return todayOutpatientService.batchUpdatePatientStatus(encounterIds, targetStatus, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接诊患者
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param request HTTP请求
|
||||
* @return 接诊结果
|
||||
*/
|
||||
@PostMapping("/patients/{encounterId}/receive")
|
||||
public R<?> receivePatient(
|
||||
@PathVariable("encounterId") Long encounterId,
|
||||
HttpServletRequest request) {
|
||||
return todayOutpatientService.receivePatient(encounterId, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成就诊
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param request HTTP请求
|
||||
* @return 完成结果
|
||||
*/
|
||||
@PostMapping("/patients/{encounterId}/complete")
|
||||
public R<?> completeVisit(
|
||||
@PathVariable("encounterId") Long encounterId,
|
||||
HttpServletRequest request) {
|
||||
return todayOutpatientService.completeVisit(encounterId, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消就诊
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param reason 取消原因
|
||||
* @param request HTTP请求
|
||||
* @return 取消结果
|
||||
*/
|
||||
@PostMapping("/patients/{encounterId}/cancel")
|
||||
public R<?> cancelVisit(
|
||||
@PathVariable("encounterId") Long encounterId,
|
||||
@RequestParam(value = "reason", required = false) String reason,
|
||||
HttpServletRequest request) {
|
||||
return todayOutpatientService.cancelVisit(encounterId, reason, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速接诊 - 医生首页快捷操作
|
||||
*
|
||||
* @param encounterId 就诊记录ID
|
||||
* @param request HTTP请求
|
||||
* @return 接诊结果
|
||||
*/
|
||||
@PostMapping("/quick-receive/{encounterId}")
|
||||
public R<?> quickReceivePatient(
|
||||
@PathVariable("encounterId") Long encounterId,
|
||||
HttpServletRequest request) {
|
||||
// 这里可以添加一些快速接诊的特殊逻辑
|
||||
// 比如自动填充一些默认值,快速状态转换等
|
||||
|
||||
return todayOutpatientService.receivePatient(encounterId, request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.openhis.web.doctorstation.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 今日门诊患者信息DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TodayOutpatientPatientDto {
|
||||
|
||||
/**
|
||||
* 就诊记录ID
|
||||
*/
|
||||
private Long encounterId;
|
||||
|
||||
/**
|
||||
* 患者ID
|
||||
*/
|
||||
private Long patientId;
|
||||
|
||||
/**
|
||||
* 患者姓名
|
||||
*/
|
||||
private String patientName;
|
||||
|
||||
/**
|
||||
* 患者性别编码
|
||||
*/
|
||||
private Integer genderEnum;
|
||||
|
||||
/**
|
||||
* 患者性别显示文本
|
||||
*/
|
||||
private String genderEnumEnumText;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 就诊流水号
|
||||
*/
|
||||
private String encounterBusNo;
|
||||
|
||||
/**
|
||||
* 挂号时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 接诊时间
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date receptionTime;
|
||||
|
||||
/**
|
||||
* 就诊状态编码
|
||||
*/
|
||||
private Integer statusEnum;
|
||||
|
||||
/**
|
||||
* 就诊状态显示文本
|
||||
*/
|
||||
private String statusEnumEnumText;
|
||||
|
||||
/**
|
||||
* 就诊对象状态编码
|
||||
*/
|
||||
private Integer subjectStatusEnum;
|
||||
|
||||
/**
|
||||
* 就诊对象状态显示文本
|
||||
*/
|
||||
private String subjectStatusEnumEnumText;
|
||||
|
||||
/**
|
||||
* 候诊时长(分钟)
|
||||
*/
|
||||
private Integer waitingDuration;
|
||||
|
||||
/**
|
||||
* 就诊时长(分钟)
|
||||
*/
|
||||
private Integer visitDuration;
|
||||
|
||||
/**
|
||||
* 患者类型编码
|
||||
*/
|
||||
private String typeCode;
|
||||
|
||||
/**
|
||||
* 患者类型显示文本
|
||||
*/
|
||||
private String typeCodeDictText;
|
||||
|
||||
/**
|
||||
* 是否重点患者(1-是,0-否)
|
||||
*/
|
||||
private Integer importantFlag;
|
||||
|
||||
/**
|
||||
* 是否已开药(1-是,0-否)
|
||||
*/
|
||||
private Integer hasPrescription;
|
||||
|
||||
/**
|
||||
* 是否已检查(1-是,0-否)
|
||||
*/
|
||||
private Integer hasExamination;
|
||||
|
||||
/**
|
||||
* 是否已检验(1-是,0-否)
|
||||
*/
|
||||
private Integer hasLaboratory;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.openhis.web.doctorstation.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 今日门诊查询参数DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TodayOutpatientQueryParam {
|
||||
|
||||
/**
|
||||
* 搜索关键词(姓名/身份证号/手机号/就诊号)
|
||||
*/
|
||||
private String searchKey;
|
||||
|
||||
/**
|
||||
* 就诊状态
|
||||
* 1-待就诊,2-就诊中,3-已完成,4-已取消
|
||||
*/
|
||||
private Integer statusEnum;
|
||||
|
||||
/**
|
||||
* 患者类型
|
||||
*/
|
||||
private String typeCode;
|
||||
|
||||
/**
|
||||
* 是否重点患者(1-是,0-否)
|
||||
*/
|
||||
private Integer importantFlag;
|
||||
|
||||
/**
|
||||
* 是否已开药(1-是,0-否)
|
||||
*/
|
||||
private Integer hasPrescription;
|
||||
|
||||
/**
|
||||
* 是否已检查(1-是,0-否)
|
||||
*/
|
||||
private Integer hasExamination;
|
||||
|
||||
/**
|
||||
* 是否已检验(1-是,0-否)
|
||||
*/
|
||||
private Integer hasLaboratory;
|
||||
|
||||
/**
|
||||
* 医生ID(可选,默认当前登录医生)
|
||||
*/
|
||||
private Long doctorId;
|
||||
|
||||
/**
|
||||
* 科室ID(可选,默认当前登录科室)
|
||||
*/
|
||||
private Long departmentId;
|
||||
|
||||
/**
|
||||
* 查询日期(格式:yyyy-MM-dd,默认今日)
|
||||
*/
|
||||
private String queryDate;
|
||||
|
||||
/**
|
||||
* 排序字段
|
||||
* 1-挂号时间,2-候诊时间,3-就诊号
|
||||
*/
|
||||
private Integer sortField;
|
||||
|
||||
/**
|
||||
* 排序方式
|
||||
* 1-升序,2-降序
|
||||
*/
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private Integer pageNo;
|
||||
|
||||
/**
|
||||
* 每页大小
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
public TodayOutpatientQueryParam() {
|
||||
this.pageNo = 1;
|
||||
this.pageSize = 10;
|
||||
this.sortField = 1; // 默认按挂号时间排序
|
||||
this.sortOrder = 2; // 默认降序
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.openhis.web.doctorstation.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 今日门诊统计DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TodayOutpatientStatsDto {
|
||||
|
||||
/**
|
||||
* 今日总挂号数
|
||||
*/
|
||||
private Integer totalRegistered;
|
||||
|
||||
/**
|
||||
* 待就诊数
|
||||
*/
|
||||
private Integer waitingCount;
|
||||
|
||||
/**
|
||||
* 就诊中数
|
||||
*/
|
||||
private Integer inProgressCount;
|
||||
|
||||
/**
|
||||
* 已完成数
|
||||
*/
|
||||
private Integer completedCount;
|
||||
|
||||
/**
|
||||
* 已取消数
|
||||
*/
|
||||
private Integer cancelledCount;
|
||||
|
||||
/**
|
||||
* 平均候诊时间(分钟)
|
||||
*/
|
||||
private Integer averageWaitingTime;
|
||||
|
||||
/**
|
||||
* 平均就诊时间(分钟)
|
||||
*/
|
||||
private Integer averageVisitTime;
|
||||
|
||||
/**
|
||||
* 今日接诊医生数
|
||||
*/
|
||||
private Integer doctorCount;
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package com.openhis.web.doctorstation.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientPatientDto;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientStatsDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 今日门诊数据访问接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface TodayOutpatientMapper {
|
||||
|
||||
/**
|
||||
* 获取今日门诊统计信息
|
||||
*
|
||||
* @param doctorId 医生ID
|
||||
* @param departmentId 科室ID
|
||||
* @param queryDate 查询日期
|
||||
* @return 统计信息
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT " +
|
||||
" COUNT(DISTINCT enc.id) AS totalRegistered, " +
|
||||
" SUM(CASE WHEN enc.status_enum = #{plannedStatus} THEN 1 ELSE 0 END) AS waitingCount, " +
|
||||
" SUM(CASE WHEN enc.status_enum = #{inProgressStatus} THEN 1 ELSE 0 END) AS inProgressCount, " +
|
||||
" SUM(CASE WHEN enc.status_enum = #{dischargedStatus} THEN 1 ELSE 0 END) AS completedCount, " +
|
||||
" SUM(CASE WHEN enc.status_enum = #{cancelledStatus} THEN 1 ELSE 0 END) AS cancelledCount, " +
|
||||
" AVG(CASE WHEN enc.reception_time IS NOT NULL " +
|
||||
" THEN EXTRACT(EPOCH FROM (enc.reception_time - enc.start_time)) / 60 " +
|
||||
" ELSE NULL END) AS averageWaitingTime, " +
|
||||
" AVG(CASE WHEN enc.end_time IS NOT NULL AND enc.reception_time IS NOT NULL " +
|
||||
" THEN EXTRACT(EPOCH FROM (enc.end_time - enc.reception_time)) / 60 " +
|
||||
" ELSE NULL END) AS averageVisitTime, " +
|
||||
" COUNT(DISTINCT ep.practitioner_id) AS doctorCount " +
|
||||
"FROM adm_encounter enc " +
|
||||
"LEFT JOIN adm_encounter_participant ep ON enc.id = ep.encounter_id " +
|
||||
" AND ep.type_code = #{admitterCode} " +
|
||||
" AND ep.delete_flag = '0' " +
|
||||
" AND ep.tenant_id = #{tenantId} " +
|
||||
" AND ep.tenant_id = #{tenantId} " +
|
||||
"WHERE enc.delete_flag = '0' " +
|
||||
" AND enc.start_time::DATE = #{queryDate}::DATE " +
|
||||
" AND enc.tenant_id = #{tenantId} " +
|
||||
" <if test='departmentId != null'>" +
|
||||
" AND enc.organization_id = #{departmentId} " +
|
||||
" </if>" +
|
||||
" <if test='doctorId != null'>" +
|
||||
" AND ep.practitioner_id = #{practitionerId} " +
|
||||
" </if>" +
|
||||
"</script>")
|
||||
TodayOutpatientStatsDto getTodayOutpatientStats(
|
||||
@Param("doctorId") Long doctorId,
|
||||
@Param("departmentId") Long departmentId,
|
||||
@Param("queryDate") String queryDate,
|
||||
@Param("tenantId") Integer tenantId,
|
||||
@Param("practitionerId") Long practitionerId,
|
||||
@Param("plannedStatus") Integer plannedStatus,
|
||||
@Param("inProgressStatus") Integer inProgressStatus,
|
||||
@Param("dischargedStatus") Integer dischargedStatus,
|
||||
@Param("cancelledStatus") Integer cancelledStatus,
|
||||
@Param("admitterCode") String admitterCode);
|
||||
|
||||
/**
|
||||
* 分页查询今日门诊患者列表
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT " +
|
||||
" enc.id AS encounterId, " +
|
||||
" enc.patient_id AS patientId, " +
|
||||
" pt.name AS patientName, " +
|
||||
" pt.gender_enum AS genderEnum, " +
|
||||
" pt.birth_date AS birthDate, " +
|
||||
" pt.id_card AS idCard, " +
|
||||
" pt.phone AS phone, " +
|
||||
" enc.bus_no AS encounterBusNo, " +
|
||||
" enc.start_time AS registerTime, " +
|
||||
" enc.reception_time AS receptionTime, " +
|
||||
" enc.status_enum AS statusEnum, " +
|
||||
" enc.subject_status_enum AS subjectStatusEnum, " +
|
||||
" CASE WHEN enc.reception_time IS NOT NULL " +
|
||||
" THEN EXTRACT(EPOCH FROM (enc.reception_time - enc.start_time)) / 60 " +
|
||||
" ELSE EXTRACT(EPOCH FROM (NOW() - enc.start_time)) / 60 END AS waitingDuration, " +
|
||||
" CASE WHEN enc.end_time IS NOT NULL AND enc.reception_time IS NOT NULL " +
|
||||
" THEN EXTRACT(EPOCH FROM (enc.end_time - enc.reception_time)) / 60 " +
|
||||
" ELSE NULL END AS visitDuration, " +
|
||||
" pt.type_code AS typeCode, " +
|
||||
" enc.important_flag AS importantFlag, " +
|
||||
" CASE WHEN EXISTS (SELECT 1 FROM med_medication_dispense WHERE encounter_id = enc.id AND delete_flag = '0') " +
|
||||
" THEN 1 ELSE 0 END AS hasPrescription, " +
|
||||
" CASE WHEN EXISTS (SELECT 1 FROM med_inspection_application WHERE encounter_id = enc.id AND delete_flag = '0') " +
|
||||
" THEN 1 ELSE 0 END AS hasExamination, " +
|
||||
" CASE WHEN EXISTS (SELECT 1 FROM med_test_application WHERE encounter_id = enc.id AND delete_flag = '0') " +
|
||||
" THEN 1 ELSE 0 END AS hasLaboratory " +
|
||||
"FROM adm_encounter enc " +
|
||||
"INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0' AND pt.tenant_id = #{tenantId} " +
|
||||
"LEFT JOIN adm_encounter_participant ep ON enc.id = ep.encounter_id " +
|
||||
" AND ep.type_code = #{admitterCode} " +
|
||||
" AND ep.delete_flag = '0' " +
|
||||
" AND ep.tenant_id = #{tenantId} " +
|
||||
"<where>" +
|
||||
" enc.delete_flag = '0' " +
|
||||
" AND enc.tenant_id = #{tenantId} " +
|
||||
" <if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>" +
|
||||
" AND ${ew.customSqlSegment.replace('WHERE ', '').replace('tenant_id', 'enc.tenant_id')}" +
|
||||
" </if>" +
|
||||
"</where> " +
|
||||
"</script>")
|
||||
IPage<TodayOutpatientPatientDto> getTodayOutpatientPatients(
|
||||
Page<TodayOutpatientPatientDto> page,
|
||||
@Param("ew") QueryWrapper<TodayOutpatientPatientDto> queryWrapper,
|
||||
@Param("tenantId") Integer tenantId,
|
||||
@Param("admitterCode") String admitterCode);
|
||||
|
||||
/**
|
||||
* 获取患者详情
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 患者详情
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT " +
|
||||
" enc.id AS encounterId, " +
|
||||
" enc.patient_id AS patientId, " +
|
||||
" pt.name AS patientName, " +
|
||||
" pt.gender_enum AS genderEnum, " +
|
||||
" pt.birth_date AS birthDate, " +
|
||||
" pt.id_card AS idCard, " +
|
||||
" pt.phone AS phone, " +
|
||||
" enc.bus_no AS encounterBusNo, " +
|
||||
" enc.start_time AS registerTime, " +
|
||||
" enc.reception_time AS receptionTime, " +
|
||||
" enc.status_enum AS statusEnum, " +
|
||||
" enc.subject_status_enum AS subjectStatusEnum, " +
|
||||
" CASE WHEN enc.reception_time IS NOT NULL " +
|
||||
" THEN EXTRACT(EPOCH FROM (enc.reception_time - enc.start_time)) / 60 " +
|
||||
" ELSE EXTRACT(EPOCH FROM (NOW() - enc.start_time)) / 60 END AS waitingDuration, " +
|
||||
" CASE WHEN enc.end_time IS NOT NULL AND enc.reception_time IS NOT NULL " +
|
||||
" THEN EXTRACT(EPOCH FROM (enc.end_time - enc.reception_time)) / 60 " +
|
||||
" ELSE NULL END AS visitDuration, " +
|
||||
" pt.type_code AS typeCode, " +
|
||||
" enc.important_flag AS importantFlag, " +
|
||||
" CASE WHEN EXISTS (SELECT 1 FROM med_medication_dispense WHERE encounter_id = enc.id AND delete_flag = '0') " +
|
||||
" THEN 1 ELSE 0 END AS hasPrescription, " +
|
||||
" CASE WHEN EXISTS (SELECT 1 FROM med_inspection_application WHERE encounter_id = enc.id AND delete_flag = '0') " +
|
||||
" THEN 1 ELSE 0 END AS hasExamination, " +
|
||||
" CASE WHEN EXISTS (SELECT 1 FROM med_test_application WHERE encounter_id = enc.id AND delete_flag = '0') " +
|
||||
" THEN 1 ELSE 0 END AS hasLaboratory " +
|
||||
"FROM adm_encounter enc " +
|
||||
"INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0' AND pt.tenant_id = #{tenantId} " +
|
||||
"LEFT JOIN adm_encounter_participant ep ON enc.id = ep.encounter_id " +
|
||||
" AND ep.type_code = #{admitterCode} " +
|
||||
" AND ep.delete_flag = '0' " +
|
||||
" AND ep.tenant_id = #{tenantId} " +
|
||||
"<where>" +
|
||||
" enc.delete_flag = '0' " +
|
||||
" AND enc.tenant_id = #{tenantId} " +
|
||||
" <if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>" +
|
||||
" AND ${ew.customSqlSegment.replace('WHERE ', '').replace('tenant_id', 'enc.tenant_id')}" +
|
||||
" </if>" +
|
||||
"</where> " +
|
||||
"</script>")
|
||||
TodayOutpatientPatientDto getPatientDetail(
|
||||
@Param("ew") QueryWrapper<TodayOutpatientPatientDto> queryWrapper,
|
||||
@Param("tenantId") Integer tenantId,
|
||||
@Param("admitterCode") String admitterCode);
|
||||
|
||||
/**
|
||||
* 批量更新患者状态
|
||||
*
|
||||
* @param encounterIds 就诊记录ID列表
|
||||
* @param targetStatus 目标状态
|
||||
* @param doctorId 医生ID
|
||||
* @param updateTime 更新时间
|
||||
* @return 更新记录数
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"UPDATE adm_encounter " +
|
||||
"SET status_enum = #{targetStatus}, " +
|
||||
" update_by = #{doctorId}, " +
|
||||
" update_time = #{updateTime} " +
|
||||
"WHERE id IN " +
|
||||
" <foreach collection='encounterIds' item='id' open='(' separator=',' close=')'>" +
|
||||
" #{id} " +
|
||||
" </foreach> " +
|
||||
" AND delete_flag = '0'" +
|
||||
"</script>")
|
||||
int batchUpdatePatientStatus(
|
||||
@Param("encounterIds") List<Long> encounterIds,
|
||||
@Param("targetStatus") Integer targetStatus,
|
||||
@Param("doctorId") Long doctorId,
|
||||
@Param("updateTime") Date updateTime);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.openhis.web.reportmanage.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@@ -13,8 +13,8 @@ import java.util.Date;
|
||||
* @author yuxj
|
||||
* @date 2025/8/25
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Getter
|
||||
@Setter
|
||||
public class InpatientMedicalRecordHomePageCollectionDto {
|
||||
|
||||
// 组织机构代码 字符 30 必填
|
||||
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:postgresql://47.116.196.11:15432/postgresql?currentSchema=hisdev&characterEncoding=UTF-8&client_encoding=UTF-8
|
||||
url: jdbc:postgresql://192.168.110.252:15432/postgresql?currentSchema=hisdev&characterEncoding=UTF-8&client_encoding=UTF-8
|
||||
username: postgresql
|
||||
password: Jchl1528
|
||||
# 从库数据源
|
||||
@@ -64,9 +64,9 @@ spring:
|
||||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
host: 47.116.196.11
|
||||
host: 192.168.110.252
|
||||
# 端口,默认为6379
|
||||
port: 26379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 1
|
||||
# 密码
|
||||
|
||||
@@ -13,6 +13,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="patientAge" column="patient_age" />
|
||||
<result property="encounterId" column="encounter_id" />
|
||||
<result property="encounterNo" column="encounter_no" />
|
||||
<result property="applyDoctorId" column="apply_doctor_id" />
|
||||
<result property="applyDoctorName" column="apply_doctor_name" />
|
||||
<result property="applyDeptId" column="apply_dept_id" />
|
||||
<result property="applyDeptName" column="apply_dept_name" />
|
||||
<result property="surgeryName" column="surgery_name" />
|
||||
<result property="surgeryCode" column="surgery_code" />
|
||||
<result property="surgeryTypeEnum" column="surgery_type_enum" />
|
||||
@@ -43,6 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="healingLevel_dictText" column="healing_level_dictText" />
|
||||
<result property="operatingRoomId" column="operating_room_id" />
|
||||
<result property="operatingRoomName" column="operating_room_name" />
|
||||
<result property="operatingRoomOrgId" column="operating_room_org_id" />
|
||||
<result property="operatingRoomOrgName" column="operating_room_org_name" />
|
||||
<result property="orgId" column="org_id" />
|
||||
<result property="orgName" column="org_name" />
|
||||
<result property="preoperativeDiagnosis" column="preoperative_diagnosis" />
|
||||
@@ -68,14 +74,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
EXTRACT(YEAR FROM AGE(p.birth_date)) as patient_age,
|
||||
s.encounter_id,
|
||||
e.bus_no as encounter_no,
|
||||
s.apply_doctor_id,
|
||||
s.apply_doctor_name,
|
||||
s.apply_dept_id,
|
||||
s.apply_dept_name,
|
||||
s.surgery_name,
|
||||
s.surgery_code,
|
||||
s.surgery_type_enum,
|
||||
s.surgery_type_enum as surgery_type_enum_dictText,
|
||||
CASE s.surgery_type_enum
|
||||
WHEN 1 THEN '门诊手术'
|
||||
WHEN 2 THEN '住院手术'
|
||||
WHEN 3 THEN '急诊手术'
|
||||
WHEN 4 THEN '择期手术'
|
||||
ELSE '未知'
|
||||
END as surgery_type_enum_dictText,
|
||||
s.surgery_level,
|
||||
s.surgery_level as surgery_level_dictText,
|
||||
CASE s.surgery_level
|
||||
WHEN 1 THEN '一级手术'
|
||||
WHEN 2 THEN '二级手术'
|
||||
WHEN 3 THEN '三级手术'
|
||||
WHEN 4 THEN '四级手术'
|
||||
WHEN 5 THEN '特级手术'
|
||||
ELSE '未知'
|
||||
END as surgery_level_dictText,
|
||||
s.status_enum,
|
||||
s.status_enum as status_enum_dictText,
|
||||
CASE s.status_enum
|
||||
WHEN 0 THEN '待排期'
|
||||
WHEN 1 THEN '已排期'
|
||||
WHEN 2 THEN '手术中'
|
||||
WHEN 3 THEN '已完成'
|
||||
WHEN 4 THEN '已取消'
|
||||
WHEN 5 THEN '暂停'
|
||||
ELSE '未知'
|
||||
END as status_enum_dictText,
|
||||
s.planned_time,
|
||||
s.actual_start_time,
|
||||
s.actual_end_time,
|
||||
@@ -90,14 +121,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
s.scrub_nurse_id,
|
||||
s.scrub_nurse_name,
|
||||
s.anesthesia_type_enum,
|
||||
s.anesthesia_type_enum as anesthesia_type_enum_dictText,
|
||||
CASE s.anesthesia_type_enum
|
||||
WHEN 0 THEN '无麻醉'
|
||||
WHEN 1 THEN '局部麻醉'
|
||||
WHEN 2 THEN '区域麻醉'
|
||||
WHEN 3 THEN '全身麻醉'
|
||||
WHEN 4 THEN '脊椎麻醉'
|
||||
WHEN 5 THEN '硬膜外麻醉'
|
||||
WHEN 6 THEN '表面麻醉'
|
||||
ELSE '未知'
|
||||
END as anesthesia_type_enum_dictText,
|
||||
s.body_site,
|
||||
s.incision_level,
|
||||
s.incision_level as incision_level_dictText,
|
||||
CASE s.incision_level
|
||||
WHEN 1 THEN 'I级切口'
|
||||
WHEN 2 THEN 'II级切口'
|
||||
WHEN 3 THEN 'III级切口'
|
||||
WHEN 4 THEN 'IV级切口'
|
||||
ELSE '未知'
|
||||
END as incision_level_dictText,
|
||||
s.healing_level,
|
||||
s.healing_level as healing_level_dictText,
|
||||
CASE s.healing_level
|
||||
WHEN 1 THEN '甲级愈合'
|
||||
WHEN 2 THEN '乙级愈合'
|
||||
WHEN 3 THEN '丙级愈合'
|
||||
ELSE '未知'
|
||||
END as healing_level_dictText,
|
||||
s.operating_room_id,
|
||||
s.operating_room_name,
|
||||
r.organization_id as operating_room_org_id,
|
||||
ro.name as operating_room_org_name,
|
||||
s.org_id,
|
||||
o.name as org_name,
|
||||
s.preoperative_diagnosis,
|
||||
@@ -114,6 +167,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
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
|
||||
LEFT JOIN adm_operating_room r ON s.operating_room_id = r.id
|
||||
LEFT JOIN adm_organization ro ON r.organization_id = ro.id
|
||||
LEFT JOIN adm_organization o ON s.org_id = o.id
|
||||
</sql>
|
||||
|
||||
@@ -122,7 +177,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
s.delete_flag = '0'
|
||||
<if test="ew.sqlSegment != null and ew.sqlSegment != ''">
|
||||
AND ${ew.sqlSegment}
|
||||
AND ${ew.sqlSegment.replace('tenant_id', 's.tenant_id').replace('create_time', 's.create_time').replace('surgery_no', 's.surgery_no').replace('surgery_name', 's.surgery_name').replace('patient_name', 'p.name').replace('main_surgeon_name', 's.main_surgeon_name').replace('anesthetist_name', 's.anesthetist_name').replace('org_name', 'o.name')}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
@@ -132,4 +187,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHERE s.id = #{id} AND s.delete_flag = '0'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
@@ -297,7 +297,12 @@ public enum AssignSeqEnum {
|
||||
/**
|
||||
* 自动备份单据号
|
||||
*/
|
||||
AUTO_BACKUP_NO("70", "自动备份单据号", "ABU");
|
||||
AUTO_BACKUP_NO("70", "自动备份单据号", "ABU"),
|
||||
|
||||
/**
|
||||
* 手术室业务编码
|
||||
*/
|
||||
OPERATING_ROOM_BUS_NO("71", "手术室业务编码", "OPR");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
@@ -81,21 +81,29 @@ public class HisQueryUtils {
|
||||
if (entity == null) {
|
||||
return queryWrapper;
|
||||
}
|
||||
// 反射获取实体类的字段
|
||||
Field[] fields = entity.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
Object value = field.get(entity);
|
||||
if (value != null && !value.toString().equals("")) {
|
||||
// 将驼峰命名的字段名转换为下划线命名的数据库字段名
|
||||
String fieldName = camelToUnderline(field.getName());
|
||||
// 处理等于条件
|
||||
queryWrapper.eq(fieldName, value);
|
||||
// 反射获取实体类的所有字段(包括父类)
|
||||
Class<?> currentClass = entity.getClass();
|
||||
while (currentClass != null && currentClass != Object.class) {
|
||||
Field[] fields = currentClass.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
// 跳过静态字段,如 serialVersionUID
|
||||
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
Object value = field.get(entity);
|
||||
if (value != null && !value.toString().equals("")) {
|
||||
// 将驼峰命名的字段名转换为下划线命名的数据库字段名
|
||||
String fieldName = camelToUnderline(field.getName());
|
||||
// 处理等于条件
|
||||
queryWrapper.eq(fieldName, value);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
currentClass = currentClass.getSuperclass();
|
||||
}
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.openhis.administration.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.core.common.core.domain.HisBaseEntity;
|
||||
import com.openhis.common.enums.LocationStatus;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 手术室管理Entity实体
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-01-04
|
||||
*/
|
||||
@Data
|
||||
@TableName("adm_operating_room")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class OperatingRoom extends HisBaseEntity {
|
||||
|
||||
/** ID */
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/** 编码 */
|
||||
private String busNo;
|
||||
|
||||
/** 手术室名称 */
|
||||
private String name;
|
||||
|
||||
/** 所属机构ID */
|
||||
private Long organizationId;
|
||||
|
||||
/** 位置描述 */
|
||||
private String locationDescription;
|
||||
|
||||
/** 设备配置 */
|
||||
private String equipmentConfig;
|
||||
|
||||
/** 容纳人数 */
|
||||
private Integer capacity;
|
||||
|
||||
/** 状态编码(1-启用,0-停用) */
|
||||
private Integer statusEnum;
|
||||
|
||||
/** 显示顺序 */
|
||||
private Integer displayOrder;
|
||||
|
||||
/** 拼音码 */
|
||||
private String pyStr;
|
||||
|
||||
/** 五笔码 */
|
||||
private String wbStr;
|
||||
|
||||
public OperatingRoom() {
|
||||
this.statusEnum = LocationStatus.ACTIVE.getValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.openhis.administration.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.openhis.administration.domain.OperatingRoom;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 手术室Mapper接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-01-04
|
||||
*/
|
||||
@Mapper
|
||||
public interface OperatingRoomMapper extends BaseMapper<OperatingRoom> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.openhis.administration.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.administration.domain.OperatingRoom;
|
||||
|
||||
/**
|
||||
* 手术室Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-01-04
|
||||
*/
|
||||
public interface IOperatingRoomService extends IService<OperatingRoom> {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.openhis.administration.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.administration.domain.OperatingRoom;
|
||||
import com.openhis.administration.mapper.OperatingRoomMapper;
|
||||
import com.openhis.administration.service.IOperatingRoomService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 手术室Service实现类
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-01-04
|
||||
*/
|
||||
@Service
|
||||
public class OperatingRoomServiceImpl extends ServiceImpl<OperatingRoomMapper, OperatingRoom>
|
||||
implements IOperatingRoomService {
|
||||
}
|
||||
@@ -38,10 +38,35 @@ public class Surgery extends HisBaseEntity {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long patientId;
|
||||
|
||||
/** 患者姓名 */
|
||||
@TableField("patient_name")
|
||||
private String patientName;
|
||||
|
||||
/** 就诊ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long encounterId;
|
||||
|
||||
/** 申请医生ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("apply_doctor_id")
|
||||
private Long applyDoctorId;
|
||||
|
||||
/** 申请医生姓名 */
|
||||
@TableField("apply_doctor_name")
|
||||
private String applyDoctorName;
|
||||
|
||||
/** 申请科室ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("apply_dept_id")
|
||||
private Long applyDeptId;
|
||||
|
||||
/** 申请科室名称 */
|
||||
@TableField("apply_dept_name")
|
||||
private String applyDeptName;
|
||||
|
||||
/** 手术指征 */
|
||||
private String surgeryIndication;
|
||||
|
||||
/** 手术名称 */
|
||||
private String surgeryName;
|
||||
|
||||
@@ -49,112 +74,141 @@ public class Surgery extends HisBaseEntity {
|
||||
private String surgeryCode;
|
||||
|
||||
/** 手术类型编码 */
|
||||
@TableField("surgery_type_enum")
|
||||
private Integer surgeryTypeEnum;
|
||||
|
||||
/** 手术等级 */
|
||||
@TableField("surgery_level")
|
||||
private Integer surgeryLevel;
|
||||
|
||||
/** 手术状态 */
|
||||
@TableField("status_enum")
|
||||
private Integer statusEnum;
|
||||
|
||||
/** 计划手术时间 */
|
||||
@TableField("planned_time")
|
||||
private Date plannedTime;
|
||||
|
||||
/** 实际开始时间 */
|
||||
@TableField("actual_start_time")
|
||||
private Date actualStartTime;
|
||||
|
||||
/** 实际结束时间 */
|
||||
@TableField("actual_end_time")
|
||||
private Date actualEndTime;
|
||||
|
||||
/** 主刀医生ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("main_surgeon_id")
|
||||
private Long mainSurgeonId;
|
||||
|
||||
/** 主刀医生姓名 */
|
||||
@TableField("main_surgeon_name")
|
||||
private String mainSurgeonName;
|
||||
|
||||
/** 助手1 ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("assistant_1_id")
|
||||
private Long assistant1Id;
|
||||
|
||||
/** 助手1 姓名 */
|
||||
@TableField("assistant_1_name")
|
||||
private String assistant1Name;
|
||||
|
||||
/** 助手2 ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("assistant_2_id")
|
||||
private Long assistant2Id;
|
||||
|
||||
/** 助手2 姓名 */
|
||||
@TableField("assistant_2_name")
|
||||
private String assistant2Name;
|
||||
|
||||
/** 麻醉医生ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("anesthetist_id")
|
||||
private Long anesthetistId;
|
||||
|
||||
/** 麻醉医生姓名 */
|
||||
@TableField("anesthetist_name")
|
||||
private String anesthetistName;
|
||||
|
||||
/** 巡回护士ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("scrub_nurse_id")
|
||||
private Long scrubNurseId;
|
||||
|
||||
/** 巡回护士姓名 */
|
||||
@TableField("scrub_nurse_name")
|
||||
private String scrubNurseName;
|
||||
|
||||
/** 麻醉方式编码 */
|
||||
@TableField("anesthesia_type_enum")
|
||||
private Integer anesthesiaTypeEnum;
|
||||
|
||||
/** 手术部位 */
|
||||
@TableField("body_site")
|
||||
private String bodySite;
|
||||
|
||||
/** 手术切口等级 */
|
||||
@TableField("incision_level")
|
||||
private Integer incisionLevel;
|
||||
|
||||
/** 手术切口愈合等级 */
|
||||
@TableField("healing_level")
|
||||
private Integer healingLevel;
|
||||
|
||||
/** 手术室 */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("operating_room_id")
|
||||
private Long operatingRoomId;
|
||||
|
||||
/** 手术室名称 */
|
||||
@TableField("operating_room_name")
|
||||
private String operatingRoomName;
|
||||
|
||||
/** 执行科室ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField("org_id")
|
||||
private Long orgId;
|
||||
|
||||
/** 执行科室名称 */
|
||||
@TableField("org_name")
|
||||
private String orgName;
|
||||
|
||||
/** 术前诊断 */
|
||||
@TableField("preoperative_diagnosis")
|
||||
private String preoperativeDiagnosis;
|
||||
|
||||
/** 术后诊断 */
|
||||
@TableField("postoperative_diagnosis")
|
||||
private String postoperativeDiagnosis;
|
||||
|
||||
/** 手术经过描述 */
|
||||
@TableField("surgery_description")
|
||||
private String surgeryDescription;
|
||||
|
||||
/** 术后医嘱 */
|
||||
@TableField("postoperative_advice")
|
||||
private String postoperativeAdvice;
|
||||
|
||||
/** 并发症描述 */
|
||||
@TableField("complications")
|
||||
private String complications;
|
||||
|
||||
/** 手术费用 */
|
||||
@TableField("surgery_fee")
|
||||
private BigDecimal surgeryFee;
|
||||
|
||||
/** 麻醉费用 */
|
||||
@TableField("anesthesia_fee")
|
||||
private BigDecimal anesthesiaFee;
|
||||
|
||||
/** 总费用 */
|
||||
@TableField("total_fee")
|
||||
private BigDecimal totalFee;
|
||||
|
||||
/** 备注信息 */
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/** 租户ID(表不存在此字段,仅用于继承基类) */
|
||||
@TableField(exist = false)
|
||||
private Integer tenantId;
|
||||
}
|
||||
}
|
||||
@@ -2,32 +2,26 @@ package com.openhis.clinical.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.core.common.utils.AssignSeqUtil;
|
||||
import com.openhis.clinical.domain.Surgery;
|
||||
import com.openhis.clinical.mapper.SurgeryMapper;
|
||||
import com.openhis.clinical.service.ISurgeryService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 手术管理Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-12-30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SurgeryServiceImpl extends ServiceImpl<SurgeryMapper, Surgery> implements ISurgeryService {
|
||||
|
||||
@Resource
|
||||
private SurgeryMapper surgeryMapper;
|
||||
|
||||
@Resource
|
||||
private AssignSeqUtil assignSeqUtil;
|
||||
|
||||
/**
|
||||
* 新增手术信息
|
||||
*
|
||||
@@ -37,22 +31,53 @@ public class SurgeryServiceImpl extends ServiceImpl<SurgeryMapper, Surgery> impl
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long insertSurgery(Surgery surgery) {
|
||||
// 生成手术编号
|
||||
String surgeryNo = assignSeqUtil.getSeq("SS", 10);
|
||||
// 生成手术单号:OP+年月日+4位随机数
|
||||
String surgeryNo = generateSurgeryNo();
|
||||
surgery.setSurgeryNo(surgeryNo);
|
||||
surgery.setCreateTime(new Date());
|
||||
surgery.setUpdateTime(new Date());
|
||||
surgery.setDeleteFlag("0");
|
||||
|
||||
// 默认状态为待排期
|
||||
// 默认状态为待排期(新开)
|
||||
if (surgery.getStatusEnum() == null) {
|
||||
surgery.setStatusEnum(0);
|
||||
}
|
||||
|
||||
// 添加日志,检查字段的值
|
||||
log.info("准备插入手术记录 - applyDoctorId: {}, applyDoctorName: {}, applyDeptId: {}, applyDeptName: {}",
|
||||
surgery.getApplyDoctorId(), surgery.getApplyDoctorName(),
|
||||
surgery.getApplyDeptId(), surgery.getApplyDeptName());
|
||||
|
||||
surgeryMapper.insert(surgery);
|
||||
|
||||
// 插入后再查询一次,验证是否保存成功
|
||||
Surgery inserted = surgeryMapper.selectById(surgery.getId());
|
||||
log.info("插入后查询结果 - applyDoctorId: {}, applyDoctorName: {}, applyDeptId: {}, applyDeptName: {}",
|
||||
inserted.getApplyDoctorId(), inserted.getApplyDoctorName(),
|
||||
inserted.getApplyDeptId(), inserted.getApplyDeptName());
|
||||
|
||||
return surgery.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成手术单号
|
||||
* 格式:OP+年月日+4位随机数
|
||||
* 示例:OP2025092003
|
||||
*
|
||||
* @return 手术单号
|
||||
*/
|
||||
private String generateSurgeryNo() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
String dateStr = sdf.format(new Date());
|
||||
|
||||
// 生成4位随机数
|
||||
Random random = new Random();
|
||||
int randomNum = random.nextInt(10000);
|
||||
String randomStr = String.format("%04d", randomNum);
|
||||
|
||||
return "OP" + dateStr + randomStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手术信息
|
||||
*
|
||||
@@ -142,4 +167,4 @@ public class SurgeryServiceImpl extends ServiceImpl<SurgeryMapper, Surgery> impl
|
||||
|
||||
return surgeryMapper.updateById(surgery) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,12 +348,6 @@
|
||||
<version>${jsqlparser.version}</version>
|
||||
</dependency>
|
||||
<!-- JSQlParser - MyBatis Plus 3.5.9+ 需要 4.6+ -->
|
||||
<dependency>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
<artifactId>jsqlparser</artifactId>
|
||||
<version>${jsqlparser.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user