Compare commits
119 Commits
f3fd150235
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| a007721c8f | |||
| 616aa46a0c | |||
| d5d112b2cc | |||
| c4a7261de0 | |||
|
|
7799282b86 | ||
|
|
4a01825a30 | ||
|
|
81daaccdda | ||
| 82ef66794b | |||
| b536eadd92 | |||
|
|
3472aa790e | ||
|
|
ec89ead14c | ||
|
|
136235fe4c | ||
|
|
c2cac12b9f | ||
|
|
b424d73542 | ||
|
|
decac542c8 | ||
|
|
783ee48ec8 | ||
|
|
e1ad4965eb | ||
|
|
fd1880f1c8 | ||
|
|
d4d05267ad | ||
| 2b0acce1db | |||
| 4312c0c557 | |||
|
|
caa45c3310 | ||
| 7fabad14f9 | |||
|
|
405a9dfb72 | ||
| d1be841688 | |||
|
|
9b8655748e | ||
| 00fd6c8710 | |||
| bbd9d48fa6 | |||
| 8fb1d3e583 | |||
| 34ba7cae6a | |||
| 305ab15436 | |||
| 46a7076460 | |||
| e0e6693897 | |||
|
|
7d1e50d045 | ||
| 25ce12cebf | |||
| 7d55717037 | |||
|
|
290e8f8f15 | ||
| fc84fd61ab | |||
|
|
d79690a371 | ||
| 7bccbc7085 | |||
|
|
059ef483ca | ||
|
|
4beb4c40c5 | ||
| 914f2d8229 | |||
| 2f57b3e7c1 | |||
|
|
39ccd27df8 | ||
| d370b6a888 | |||
| 3c61e39e09 | |||
| f2c71b08bb | |||
| 90cf7f43d7 | |||
| 1f5d392c08 | |||
| d52bbda8c3 | |||
|
|
986510278b | ||
| 758921b633 | |||
| 8e7ebd3461 | |||
| 8c05782549 | |||
| 060d1910dd | |||
| 44ae216612 | |||
| 0076753c19 | |||
|
|
957d426042 | ||
|
|
76094d6eff | ||
| dc43ce335a | |||
| d27b5147ec | |||
| 4fb540cfa5 | |||
| 72e1f927e9 | |||
|
|
e7beb3f5c3 | ||
|
|
dc7e3c1de8 | ||
| 1242d41499 | |||
| 091b6e83b6 | |||
| b53cdfa617 | |||
| fe2a79773f | |||
| 22b47fcc95 | |||
| 328ccbbd99 | |||
| 6b6e56c79b | |||
| 41fe89447f | |||
| 0d11d411ea | |||
|
|
d525a50f52 | ||
|
|
5d97975e7f | ||
|
|
03e89e0577 | ||
| 9c48744cb1 | |||
| 24758414f2 | |||
| 2d55387ba9 | |||
| 1fc2032aa8 | |||
| adc89a5ed2 | |||
| 278676957e | |||
| 988c17cd30 | |||
| 08ee473671 | |||
|
|
6962a8b1c1 | ||
|
|
95e379e5a5 | ||
| 2a8e662b44 | |||
| 0b8a7245f6 | |||
| 17e148ce7a | |||
| 937b4508ae | |||
| 87d4214541 | |||
|
|
acc59ab87c | ||
| 78bcdef7fd | |||
| 72c0ceac29 | |||
|
|
e2808fd6b9 | ||
| 0cfdce042f | |||
|
|
cd54a3903c | ||
|
|
063eb1fe08 | ||
| f125c8dc85 | |||
| d663c46422 | |||
| a8ab52589e | |||
| 14333f47ea | |||
|
|
88d9e19cc5 | ||
|
|
994ffcb8b8 | ||
|
|
5ab4650c4e | ||
| ed75b148a8 | |||
| 210c463130 | |||
| 6922aa1d2a | |||
|
|
4e2097fc7b | ||
| 38b4ff5c92 | |||
| e294952a60 | |||
| 3380b2787e | |||
| 0758ba401b | |||
| 73ebc20471 | |||
| 3f36ed4ce8 | |||
| 76fdc047b9 | |||
| 309c470f8a |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -63,3 +63,6 @@ public.sql
|
||||
发版记录/2025-11-12/发版日志.docx
|
||||
.gitignore
|
||||
openhis-server-new/openhis-application/src/main/resources/application-dev.yml
|
||||
.env.test.local
|
||||
playwright-report/
|
||||
test-results/
|
||||
|
||||
51
.husky/pre-commit
Executable file
51
.husky/pre-commit
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env sh
|
||||
# ============================================================
|
||||
# Husky Pre-commit Hook - HIS项目
|
||||
# 配置: 关羽 | 日期: 2026-04-24
|
||||
# 功能: 提交前自动检查前端构建
|
||||
# ============================================================
|
||||
|
||||
echo "========================================"
|
||||
echo "🔍 [Pre-commit] HIS项目提交检查"
|
||||
echo "========================================"
|
||||
|
||||
# 检查前端目录是否存在
|
||||
if [ ! -d "openhis-ui-vue3" ]; then
|
||||
echo "⚠️ [Pre-commit] 未找到openhis-ui-vue3目录,跳过前端检查"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd openhis-ui-vue3
|
||||
|
||||
# 检查node_modules是否存在
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo "⚠️ [Pre-commit] node_modules未安装,请先执行 npm install"
|
||||
echo " 提示: 首次使用或依赖变更后需要安装依赖"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 执行lint检查(ESLint配置由赵云下周完善后启用)
|
||||
if grep -q '"lint"' package.json 2>/dev/null; then
|
||||
echo "📋 [Pre-commit] 执行Lint检查..."
|
||||
if npm run lint -- --max-warnings 0 2>&1; then
|
||||
echo "✅ [Pre-commit] Lint检查通过"
|
||||
else
|
||||
echo "❌ [Pre-commit] Lint检查失败!请修复代码规范问题"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "⏭️ [Pre-commit] 未配置lint脚本(待赵云配置ESLint后启用)"
|
||||
fi
|
||||
|
||||
# 执行快速构建检查(development模式,仅检查语法和类型)
|
||||
echo "🔨 [Pre-commit] 执行构建检查 (build:dev)..."
|
||||
if timeout 120 npm run build:dev 2>&1; then
|
||||
echo "✅ [Pre-commit] 构建检查通过"
|
||||
else
|
||||
echo "❌ [Pre-commit] 构建检查失败!请修复编译错误后重新提交"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "========================================"
|
||||
echo "✅ [Pre-commit] 所有检查通过,允许提交"
|
||||
echo "========================================"
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"tools": {
|
||||
"approvalMode": "yolo"
|
||||
},
|
||||
"$version": 2
|
||||
}
|
||||
1
GIT_TEST.md
Normal file
1
GIT_TEST.md
Normal file
@@ -0,0 +1 @@
|
||||
# Git 提交测试 - 诸葛亮 Tue Apr 14 10:08:27 PM CST 2026
|
||||
@@ -1 +1,2 @@
|
||||
# 赵云测试提交
|
||||
赵云再次测试 - Tue Apr 14 09:36:09 PM CST 2026
|
||||
|
||||
162
docs/specs/backend-checklist.md
Normal file
162
docs/specs/backend-checklist.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# 后端发布前检查清单
|
||||
|
||||
## 📋 基础检查项
|
||||
|
||||
### Maven编译验证
|
||||
- [ ] 本地执行 `mvn compile` 编译通过,无ERROR
|
||||
- [ ] 执行 `mvn package -DskipTests` 打包成功
|
||||
- [ ] 依赖版本无冲突(`mvn dependency:tree` 检查)
|
||||
- [ ] 无编译警告(或已有书面说明可忽略)
|
||||
|
||||
### 构建产物验证
|
||||
- [ ] JAR/WAR包生成完整,大小合理
|
||||
- [ ] `application.yml` 等配置文件已打包进产物
|
||||
- [ ] 第三方依赖jar包完整(lib目录无缺失)
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Spring Boot 配置检查
|
||||
|
||||
### 多环境配置
|
||||
- [ ] `application-dev.yml`(开发)配置正确
|
||||
- [ ] `application-test.yml`(测试)配置正确
|
||||
- [ ] `application-prod.yml`(生产)配置正确
|
||||
- [ ] 启动参数 `--spring.profiles.active` 指定正确环境
|
||||
- [ ] 生产环境未启用devtools热部署
|
||||
|
||||
### Actuator安全
|
||||
- [ ] 生产环境 `/actuator` 端点已禁用或限制访问
|
||||
- [ ] `/actuator/env`、`/actuator/heapdump` 等敏感端点已关闭
|
||||
- [ ] 健康检查端点 `/actuator/health` 返回信息已脱敏
|
||||
|
||||
### 启动校验
|
||||
- [ ] 数据库连接池配置合理(HikariCP最大/最小连接数)
|
||||
- [ ] Redis/消息中间件连接配置正确
|
||||
- [ ] 启动日志无ERROR级别异常
|
||||
|
||||
---
|
||||
|
||||
## 🗄️ MyBatis Plus 规范检查
|
||||
|
||||
### 实体-表映射
|
||||
- [ ] 所有实体类标注 `@TableName`,表名与实际一致
|
||||
- [ ] 主键字段标注 `@TableId(type = IdType.AUTO)` 或对应策略
|
||||
- [ ] 非表字段标注 `@TableField(exist = false)`
|
||||
- [ ] 字段命名符合下划线转驼峰规则
|
||||
|
||||
### SQL安全
|
||||
- [ ] 所有查询使用参数化查询(`QueryWrapper` / `LambdaQueryWrapper`)
|
||||
- [ ] 禁止字符串拼接SQL(`"WHERE name = '" + name + "'"`)
|
||||
- [ ] 批量操作使用MyBatis Plus `saveBatch` / `updateBatchById`
|
||||
- [ ] 复杂SQL使用XML映射,避免注解内嵌长SQL
|
||||
|
||||
### 事务管理
|
||||
- [ ] 涉及多表写操作的方法标注 `@Transactional`
|
||||
- [ ] 事务边界合理,不包含外部HTTP调用
|
||||
- [ ] 异常回滚配置正确(`rollbackFor = Exception.class`)
|
||||
- [ ] 事务方法未被同一类内方法直接调用(自调用失效问题)
|
||||
|
||||
### 分页插件
|
||||
- [ ] `PaginationInnerInterceptor` 已正确配置
|
||||
- [ ] 分页查询使用 `Page<T>` 对象,非手动limit/offset
|
||||
|
||||
---
|
||||
|
||||
## 🔌 RESTful API 设计检查
|
||||
|
||||
### 统一返回格式
|
||||
- [ ] 所有接口返回 `{code, msg, data}` 统一结构
|
||||
- [ ] 成功返回 `code=200`,业务错误使用自定义错误码
|
||||
- [ ] 异常通过 `@ControllerAdvice` + `@ExceptionHandler` 统一处理
|
||||
|
||||
### HTTP状态码
|
||||
- [ ] 资源创建返回 `201 Created`
|
||||
- [ ] 资源删除返回 `204 No Content`
|
||||
- [ ] 参数校验失败返回 `400 Bad Request`
|
||||
- [ ] 未认证返回 `401 Unauthorized`
|
||||
- [ ] 无权限返回 `403 Forbidden`
|
||||
- [ ] 资源不存在返回 `404 Not Found`
|
||||
|
||||
### 参数校验
|
||||
- [ ] 请求参数使用 `@Valid` / `@Validated` 注解校验
|
||||
- [ ] 必填字段标注 `@NotBlank` / `@NotNull`
|
||||
- [ ] 数值范围标注 `@Min` / `@Max`
|
||||
- [ ] 格式校验使用 `@Pattern`(如手机号、身份证号)
|
||||
- [ ] 校验失败返回明确错误信息(非500堆栈)
|
||||
|
||||
### API版本管理
|
||||
- [ ] 接口路径包含版本号(`/api/v1/`、`/api/v2/`)
|
||||
- [ ] 废弃接口标注 `@Deprecated`,并在文档中说明
|
||||
- [ ] 不兼容变更必须升级版本号
|
||||
|
||||
---
|
||||
|
||||
## 🔒 安全与合规检查
|
||||
|
||||
### 数据脱敏
|
||||
- [ ] 患者身份证号在日志中脱敏(`***` 掩码)
|
||||
- [ ] 患者手机号在日志中脱敏(前3后4,中间`****`)
|
||||
- [ ] 敏感字段序列化时使用 `@JsonSerialize` 自定义脱敏器
|
||||
- [ ] 接口返回中非必需字段不暴露(如密码、salt)
|
||||
|
||||
### 权限控制
|
||||
- [ ] 所有涉及患者数据的接口标注 `@PreAuthorize`
|
||||
- [ ] 数据级权限校验(医生只能访问本科室患者)
|
||||
- [ ] 越权访问返回 `403`,非 `404` 或 `500`
|
||||
- [ ] 敏感操作(删除、修改诊断)需二次确认或额外权限
|
||||
|
||||
### 审计日志
|
||||
- [ ] 处方修改记录操作人、时间、变更内容
|
||||
- [ ] 病历删除操作记录完整审计链
|
||||
- [ ] 审计日志独立存储,不可被业务用户删除
|
||||
- [ ] 关键业务操作记录IP地址和操作终端
|
||||
|
||||
---
|
||||
|
||||
## ⚡ 性能检查
|
||||
|
||||
### 数据库查询
|
||||
- [ ] 无N+1查询问题(使用 `JOIN` 或批量查询)
|
||||
- [ ] 大表查询必须有分页限制
|
||||
- [ ] 慢查询已优化(执行时间 < 500ms)
|
||||
- [ ] 索引已覆盖高频查询条件
|
||||
|
||||
### 接口性能
|
||||
- [ ] 核心接口响应时间 < 1秒
|
||||
- [ ] 列表接口支持分页,无全量返回
|
||||
- [ ] 大文件下载使用流式传输,非全量加载到内存
|
||||
|
||||
---
|
||||
|
||||
## 📝 文档与发布准备
|
||||
|
||||
### 文档更新
|
||||
- [ ] API接口文档已同步更新(路径、参数、返回值)
|
||||
- [ ] 数据库变更脚本已提供(DDL/DML)
|
||||
- [ ] 配置变更说明已记录(新增/修改的配置项)
|
||||
- [ ] 影响范围说明已明确(哪些模块、哪些接口受影响)
|
||||
|
||||
### 回滚预案
|
||||
- [ ] 数据库变更可回滚(提供反向SQL脚本)
|
||||
- [ ] 配置变更可快速回退
|
||||
- [ ] 紧急回滚流程已明确(谁、怎么做、多长时间)
|
||||
- [ ] 回滚后数据一致性已验证
|
||||
|
||||
---
|
||||
|
||||
## ✅ 最终确认
|
||||
|
||||
### 发布前最后检查
|
||||
- [ ] `mvn compile` 构建成功(附终端截图)
|
||||
- [ ] 关键单元测试通过
|
||||
- [ ] 测试环境部署验证通过
|
||||
- [ ] Code Review 已完成并获得批准
|
||||
- [ ] 相关Bug已关闭或延期说明
|
||||
|
||||
---
|
||||
|
||||
**文档版本**:v1.0
|
||||
**最后更新**:2026年4月24日
|
||||
**负责人**:关羽(后端开发)
|
||||
**适用范围**:HIS 系统所有后端模块(his-server)
|
||||
**补充说明**:本清单与陈琳的《前端发布前检查清单》对称互补,共同构成HIS系统发布前完整质量保障体系
|
||||
217
docs/specs/cicd-gatekeeper.md
Normal file
217
docs/specs/cicd-gatekeeper.md
Normal file
@@ -0,0 +1,217 @@
|
||||
# CI/CD构建门禁规范
|
||||
|
||||
## 🎯 规范目标
|
||||
|
||||
建立自动化质量门禁,确保每次代码提交都经过严格验证,防止低质量代码进入主干分支,提升系统稳定性和开发效率。
|
||||
|
||||
## 🔒 门禁层级
|
||||
|
||||
### 1. 提交前门禁(Pre-commit)
|
||||
**触发时机**:`git commit` 执行前
|
||||
**验证内容**:
|
||||
- ESLint 代码规范检查
|
||||
- Prettier 代码格式化
|
||||
- 简单的单元测试(快速执行)
|
||||
|
||||
**工具配置**:
|
||||
- Husky + lint-staged
|
||||
- 配置文件:`.husky/pre-commit`
|
||||
|
||||
### 2. 推送前门禁(Pre-push)
|
||||
**触发时机**:`git push` 执行前
|
||||
**验证内容**:
|
||||
- 完整的单元测试套件
|
||||
- 构建验证(`npm run build:prod`)
|
||||
- 集成测试(核心流程)
|
||||
|
||||
**工具配置**:
|
||||
- Husky pre-push hook
|
||||
- 配置文件:`.husky/pre-push`
|
||||
|
||||
### 3. CI流水线门禁(CI Pipeline)
|
||||
**触发时机**:代码推送到远程仓库后
|
||||
**验证内容**:
|
||||
- 完整的测试套件(单元+集成+端到端)
|
||||
- 代码覆盖率检查(分阶段目标:Q1≥30%,Q2≥50%,Q3≥80%)
|
||||
- 安全扫描(SAST)
|
||||
- 构建产物验证
|
||||
- 部署到测试环境
|
||||
|
||||
**工具配置**:
|
||||
- Spug CI/CD 流水线
|
||||
- Gitea Webhook 触发
|
||||
|
||||
### 4. 发布前门禁(Release Gate)
|
||||
**触发时机**:准备发布到生产环境前
|
||||
**验证内容**:
|
||||
- 生产环境冒烟测试
|
||||
- 性能基准测试
|
||||
- 安全合规检查
|
||||
- 回滚预案验证
|
||||
|
||||
## ⚙️ 具体配置要求
|
||||
|
||||
### ESLint 配置
|
||||
```javascript
|
||||
// eslint.config.js 关键配置
|
||||
import globals from "globals";
|
||||
import pluginVue from "eslint-plugin-vue";
|
||||
import parserVue from "vue-eslint-parser";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
|
||||
export default [
|
||||
{
|
||||
name: "app/files-to-lint",
|
||||
files: ["**/*.{js,mjs,jsx,vue}"],
|
||||
},
|
||||
|
||||
{
|
||||
name: "app/files-to-ignore",
|
||||
ignores: ["**/dist/**", "**/node_modules/**", "**/help-center/**"],
|
||||
},
|
||||
|
||||
...pluginVue.configs["flat/recommended"],
|
||||
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
parser: parserVue,
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
|
||||
plugins: {
|
||||
import: importPlugin,
|
||||
},
|
||||
|
||||
rules: {
|
||||
// 确保导入的模块实际存在(核心规则,防止构建失败)
|
||||
"import/no-unresolved": "error",
|
||||
// 确保导入的命名导出实际存在
|
||||
"import/named": "error",
|
||||
// 确保默认导出存在
|
||||
"import/default": "error",
|
||||
// 确保命名空间导出存在
|
||||
"import/namespace": "error",
|
||||
},
|
||||
},
|
||||
];
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
### Java 后端配置
|
||||
```xml
|
||||
<!-- pom.xml 关键插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</plugin>
|
||||
```
|
||||
|
||||
### 数据库迁移配置
|
||||
```yaml
|
||||
# application.yml Flyway配置
|
||||
flyway:
|
||||
enabled: true
|
||||
locations: classpath:db/migration
|
||||
baseline-on-migrate: true
|
||||
```
|
||||
javascript
|
||||
// .eslintrc.js 关键配置
|
||||
module.exports = {
|
||||
plugins: ['import'],
|
||||
rules: {
|
||||
// 确保导入的模块实际存在
|
||||
'import/no-unresolved': 'error',
|
||||
// 确保导入的成员实际存在
|
||||
'import/named': 'error',
|
||||
// 禁止未使用的导入
|
||||
'import/no-unused-modules': 'warn'
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### Husky 配置
|
||||
```bash
|
||||
# .husky/pre-commit
|
||||
#!/bin/sh
|
||||
npm run lint-staged
|
||||
|
||||
# .husky/pre-push
|
||||
#!/bin/sh
|
||||
npm run test:unit && npm run build:prod
|
||||
```
|
||||
|
||||
### lint-staged 配置
|
||||
```json
|
||||
// package.json
|
||||
{
|
||||
"lint-staged": {
|
||||
"*.{js,vue}": ["eslint --fix", "prettier --write"],
|
||||
"*.{css,scss}": ["stylelint --fix", "prettier --write"]
|
||||
}
|
||||
}
|
||||
```
|
||||
```json
|
||||
// package.json
|
||||
{
|
||||
"lint-staged": {
|
||||
"*.{js,vue}": ["eslint --fix", "prettier --write"],
|
||||
"*.{css,scss}": ["stylelint --fix", "prettier --write"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🚫 失败处理机制
|
||||
|
||||
### 自动处理
|
||||
- **构建失败**:自动阻止 PR 合并
|
||||
- **测试失败**:标记 PR 为失败状态
|
||||
- **安全漏洞**:立即通知安全团队
|
||||
|
||||
### 人工处理
|
||||
- **紧急修复**:可申请临时绕过(需架构师批准)
|
||||
- **误报处理**:提交豁免申请并说明原因
|
||||
- **规则调整**:通过 RFC 流程申请规则变更
|
||||
|
||||
## 📊 监控与度量
|
||||
|
||||
### 关键指标
|
||||
- 门禁通过率 ≥ 95%
|
||||
- 平均修复时间 ≤ 2小时
|
||||
- 误报率 ≤ 5%
|
||||
|
||||
### 报告机制
|
||||
- 每日门禁失败统计
|
||||
- 周度质量趋势报告
|
||||
- 月度规则优化建议
|
||||
|
||||
## 🔄 持续改进
|
||||
|
||||
### 规则演进
|
||||
- 每月评审门禁规则有效性
|
||||
- 根据项目需求调整检查强度
|
||||
- 引入新的质量检查工具
|
||||
|
||||
### 团队培训
|
||||
- 新成员入职培训包含门禁规范
|
||||
- 定期分享最佳实践案例
|
||||
- 建立常见问题解决方案库
|
||||
|
||||
---
|
||||
|
||||
**文档版本**:v1.0
|
||||
**最后更新**:2026年4月24日
|
||||
**负责人**:陈琳(文档专家)
|
||||
**技术方案**:诸葛亮(架构师)
|
||||
**适用范围**:HIS 系统所有项目
|
||||
135
docs/specs/commit-template.md
Normal file
135
docs/specs/commit-template.md
Normal file
@@ -0,0 +1,135 @@
|
||||
# 代码提交变更说明模板
|
||||
|
||||
## 📝 PR/Commit 模板
|
||||
|
||||
### 标题格式
|
||||
```
|
||||
<类型>(<模块>): <简短描述>
|
||||
|
||||
示例:
|
||||
feat(patient): 添加患者基本信息编辑功能
|
||||
fix(doctor): 修复医生排班显示异常问题
|
||||
docs(api): 更新预约挂号接口文档
|
||||
refactor(nurse): 重构护士站护理记录组件
|
||||
```
|
||||
|
||||
### 正文模板
|
||||
```markdown
|
||||
## 🔍 变更背景
|
||||
- **问题描述**:详细说明要解决的问题或实现的需求
|
||||
- **影响范围**:列出受影响的模块、页面、功能
|
||||
- **相关链接**:禅道任务ID、需求文档链接等
|
||||
|
||||
## 🛠️ 变更内容
|
||||
- **主要修改**:核心代码变更点
|
||||
- **技术方案**:采用的技术方案和设计思路
|
||||
- **兼容性**:是否涉及API或数据结构变更
|
||||
|
||||
|
||||
## 🗄️ 数据库变更
|
||||
- **表结构变更**:列出新增/修改的表和字段
|
||||
- **数据迁移**:是否需要数据迁移脚本
|
||||
- **回滚方案**:数据库变更的回滚策略
|
||||
|
||||
## ✅ 验证情况
|
||||
- **测试覆盖**:单元测试、集成测试覆盖情况
|
||||
- **手动验证**:手动测试的场景和结果
|
||||
- **构建验证**:本地构建截图(必填)
|
||||
|
||||
## 📋 检查清单
|
||||
- [ ] 代码已通过 ESLint 检查
|
||||
- [ ] 本地构建成功(附截图)
|
||||
- [ ] 核心功能已测试验证
|
||||
- [ ] 文档已同步更新
|
||||
- [ ] Code Review 已完成
|
||||
|
||||
## 👥 相关人员
|
||||
- **开发者**:@开发者姓名
|
||||
- **测试者**:@测试者姓名
|
||||
- **审核人**:@架构师姓名
|
||||
```
|
||||
|
||||
## 🏷️ 提交类型说明
|
||||
|
||||
| 类型 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| feat | 新功能 | `feat: 添加用户登录功能` |
|
||||
| fix | Bug修复 | `fix: 修复表单验证错误` |
|
||||
| docs | 文档更新 | `docs: 更新API文档` |
|
||||
| style | 代码格式调整 | `style: 格式化代码` |
|
||||
| refactor | 代码重构 | `refactor: 重构组件结构` |
|
||||
| test | 测试相关 | `test: 添加单元测试` |
|
||||
| chore | 构建/依赖等 | `chore: 升级依赖版本` |
|
||||
| perf | 性能优化 | `perf: 优化列表加载速度` |
|
||||
|
||||
## 📁 模块命名规范
|
||||
|
||||
| 模块 | 说明 |
|
||||
|------|------|
|
||||
| patient | 患者管理相关 |
|
||||
| doctor | 医生工作站相关 |
|
||||
| nurse | 护士站相关 |
|
||||
| admin | 后台管理相关 |
|
||||
| common | 公共组件/工具 |
|
||||
| api | API接口相关 |
|
||||
| auth | 认证授权相关 |
|
||||
| payment | 支付相关 |
|
||||
|
||||
## 🖼️ 构建验证截图要求
|
||||
|
||||
### 必须包含的信息
|
||||
1. **终端窗口**:显示 `npm run build:prod` 命令执行过程
|
||||
2. **成功标识**:明确显示构建成功的提示信息
|
||||
3. **时间戳**:截图包含当前时间,证明是最新构建
|
||||
4. **分支信息**:显示当前工作分支名称
|
||||
|
||||
### 截图示例
|
||||
```
|
||||
$ git checkout feature/patient-edit
|
||||
$ npm run build:prod
|
||||
|
||||
> his-system@1.0.0 build
|
||||
> vue-cli-service build
|
||||
|
||||
⠇ Building for production...
|
||||
|
||||
DONE Build complete. The dist directory is ready to be deployed.
|
||||
INFO Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html
|
||||
|
||||
✨ Done in 45.23s.
|
||||
```
|
||||
|
||||
## ⚠️ 禁止行为
|
||||
|
||||
### 严重违规(直接拒绝合并)
|
||||
- 无构建验证截图
|
||||
- 代码存在 ESLint 错误
|
||||
- 未填写变更说明
|
||||
- 修改无关代码文件
|
||||
|
||||
### 轻微违规(要求修正后重新提交)
|
||||
- 描述过于简单
|
||||
- 测试覆盖不完整
|
||||
- 文档更新滞后
|
||||
- 格式不符合规范
|
||||
|
||||
## 💡 最佳实践
|
||||
|
||||
### 高质量提交特征
|
||||
- **原子性**:每次提交只解决一个问题
|
||||
- **可追溯**:关联具体的需求或Bug ID
|
||||
- **可验证**:提供完整的验证证据
|
||||
- **可理解**:描述清晰,他人能快速理解
|
||||
|
||||
### 团队协作建议
|
||||
- 提交前先在本地完整测试
|
||||
- 复杂变更提前与团队沟通
|
||||
- 及时更新相关文档
|
||||
- 主动帮助新人熟悉规范
|
||||
|
||||
---
|
||||
|
||||
**文档版本**:v1.0
|
||||
**最后更新**:2026年4月24日
|
||||
**负责人**:陈琳(文档专家)
|
||||
**适用范围**:HIS 系统所有开发人员
|
||||
102
docs/specs/frontend-checklist.md
Normal file
102
docs/specs/frontend-checklist.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# 前端发布前检查清单
|
||||
|
||||
## 📋 基础检查项
|
||||
|
||||
### 代码质量
|
||||
- [ ] 代码已通过 ESLint 检查,无警告和错误
|
||||
- [ ] 代码已通过 Prettier 格式化
|
||||
- [ ] 无 console.log() 等调试代码残留
|
||||
- [ ] 变量命名符合规范,语义清晰
|
||||
- [ ] 函数职责单一,复杂度适中
|
||||
|
||||
### 构建验证
|
||||
- [ ] 本地执行 `npm run build:prod` 成功完成
|
||||
- [ ] 构建产物无报错,体积合理
|
||||
- [ ] 静态资源路径正确,无404错误
|
||||
- [ ] 环境变量配置正确(开发/测试/生产)
|
||||
|
||||
### 功能验证
|
||||
- [ ] 核心功能流程完整测试通过
|
||||
- [ ] 边界条件和异常场景已覆盖
|
||||
- [ ] 表单验证逻辑正确
|
||||
- [ ] API 接口调用正常,错误处理完善
|
||||
- [ ] 路由跳转逻辑正确
|
||||
|
||||
## 🔧 技术检查项
|
||||
|
||||
### 模块导入检查
|
||||
- [ ] 所有 import 语句引用的模块实际存在
|
||||
- [ ] 无未使用的 import 导入
|
||||
- [ ] 路径别名(@/)配置正确
|
||||
- [ ] 第三方库版本兼容性确认
|
||||
|
||||
### 性能优化
|
||||
- [ ] 组件按需加载(懒加载)已配置
|
||||
- [ ] 大数据列表已实现虚拟滚动或分页
|
||||
- [ ] 图片资源已压缩,格式合适
|
||||
- [ ] 无内存泄漏风险(事件监听器、定时器等)
|
||||
|
||||
### 安全检查
|
||||
- [ ] 用户输入已做 XSS 防护
|
||||
- [ ] 敏感信息不在前端硬编码
|
||||
- [ ] API 请求已做 CSRF 防护
|
||||
- [ ] 权限控制逻辑正确
|
||||
|
||||
## 🌐 兼容性检查
|
||||
|
||||
### 浏览器兼容
|
||||
- [ ] 主流浏览器(Chrome、Firefox、Safari、Edge)显示正常
|
||||
- [ ] 移动端适配良好(如适用)
|
||||
- [ ] 分辨率适配(1366x768、1920x1080等)
|
||||
|
||||
### 设备兼容
|
||||
- [ ] 触摸设备操作体验良好
|
||||
- [ ] 键盘导航支持完整
|
||||
- [ ] 屏幕阅读器兼容性(无障碍)
|
||||
|
||||
## 📱 发布准备
|
||||
|
||||
### 文档更新
|
||||
- [ ] 相关 API 文档已同步更新
|
||||
- [ ] 用户操作手册已更新(如适用)
|
||||
- [ ] 变更日志已记录
|
||||
|
||||
### 回滚预案
|
||||
- [ ] 回滚方案已准备
|
||||
- [ ] 数据兼容性已确认
|
||||
- [ ] 紧急联系人已明确
|
||||
|
||||
|
||||
## 🔧 后端检查项
|
||||
|
||||
### 编译验证
|
||||
- [ ] Maven编译成功(`mvn clean package -DskipTests`)
|
||||
- [ ] 无编译错误,仅有可接受的警告
|
||||
- [ ] 依赖版本兼容性确认
|
||||
|
||||
### 数据库脚本
|
||||
- [ ] DDL/DML脚本语法正确
|
||||
- [ ] 回滚脚本已准备
|
||||
- [ ] 数据迁移脚本已测试
|
||||
|
||||
## 🔄 前后端协同
|
||||
|
||||
### 接口兼容性
|
||||
- [ ] API接口契约变更已双方确认
|
||||
- [ ] 前端调用后端接口正常
|
||||
- [ ] 错误码处理逻辑一致
|
||||
|
||||
## ✅ 最终确认
|
||||
|
||||
### 发布前最后检查
|
||||
- [ ] 本地构建截图已附在 PR 中
|
||||
- [ ] 测试环境部署验证通过
|
||||
- [ ] Code Review 已完成并获得批准
|
||||
- [ ] 相关 Bug 已关闭或延期说明
|
||||
|
||||
---
|
||||
|
||||
**文档版本**:v1.0
|
||||
**最后更新**:2026年4月24日
|
||||
**负责人**:陈琳(文档专家)
|
||||
**适用范围**:HIS 系统所有前端项目
|
||||
575
docs/specs/his-release-checklist-v1.0.md
Normal file
575
docs/specs/his-release-checklist-v1.0.md
Normal file
@@ -0,0 +1,575 @@
|
||||
# HIS项目发布检查清单 v1.0
|
||||
|
||||
> **文档说明**:本清单整合了提交规范、前端检查、后端检查、CI/CD门禁四个部分,作为HIS项目发布的标准化检查依据。每次发布前必须逐项确认。
|
||||
|
||||
## 目录
|
||||
- [1. 提交规范(commit-template)](#1-提交规范commit-template)
|
||||
- [2. 前端检查(frontend-checklist)](#2-前端检查frontend-checklist)
|
||||
- [3. 后端检查(backend-checklist)](#3-后端检查backend-checklist)
|
||||
- [4. CI/CD门禁(cicd-gatekeeper)](#4-cicd门禁cicd-gatekeeper)
|
||||
- [5. 发布确认与回滚预案](#5-发布确认与回滚预案)
|
||||
|
||||
---
|
||||
|
||||
## 1. 提交规范(commit-template)
|
||||
|
||||
### 📝 PR/Commit 模板
|
||||
|
||||
#### 标题格式
|
||||
```
|
||||
<类型>(<模块>): <简短描述>
|
||||
|
||||
示例:
|
||||
feat(patient): 添加患者基本信息编辑功能
|
||||
fix(doctor): 修复医生排班显示异常问题
|
||||
docs(api): 更新预约挂号接口文档
|
||||
refactor(nurse): 重构护士站护理记录组件
|
||||
```
|
||||
|
||||
#### 正文模板
|
||||
```markdown
|
||||
## 🔍 变更背景
|
||||
- **问题描述**:详细说明要解决的问题或实现的需求
|
||||
- **影响范围**:列出受影响的模块、页面、功能
|
||||
- **相关链接**:禅道任务ID、需求文档链接等
|
||||
|
||||
## 🛠️ 变更内容
|
||||
- **主要修改**:核心代码变更点
|
||||
- **技术方案**:采用的技术方案和设计思路
|
||||
- **兼容性**:是否涉及API或数据结构变更
|
||||
|
||||
## 🗄️ 数据库变更
|
||||
- **表结构变更**:列出新增/修改的表和字段
|
||||
- **数据迁移**:是否需要数据迁移脚本
|
||||
- **回滚方案**:数据库变更的回滚策略
|
||||
|
||||
## ✅ 验证情况
|
||||
- **测试覆盖**:单元测试、集成测试覆盖情况
|
||||
- **手动验证**:手动测试的场景和结果
|
||||
- **构建验证**:本地构建截图(必填)
|
||||
|
||||
## 📋 检查清单
|
||||
- [ ] 代码已通过 ESLint 检查
|
||||
- [ ] 本地构建成功(附截图)
|
||||
- [ ] 核心功能已测试验证
|
||||
- [ ] 文档已同步更新
|
||||
- [ ] Code Review 已完成
|
||||
|
||||
## 👥 相关人员
|
||||
- **开发者**:@开发者姓名
|
||||
- **测试者**:@测试者姓名
|
||||
- **审核人**:@架构师姓名
|
||||
```
|
||||
|
||||
### 🏷️ 提交类型说明
|
||||
|
||||
| 类型 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| feat | 新功能 | `feat: 添加用户登录功能` |
|
||||
| fix | Bug修复 | `fix: 修复表单验证错误` |
|
||||
| docs | 文档更新 | `docs: 更新API文档` |
|
||||
| style | 代码格式调整 | `style: 格式化代码` |
|
||||
| refactor | 代码重构 | `refactor: 重构组件结构` |
|
||||
| test | 测试相关 | `test: 添加单元测试` |
|
||||
| chore | 构建/依赖等 | `chore: 升级依赖版本` |
|
||||
| perf | 性能优化 | `perf: 优化列表加载速度` |
|
||||
|
||||
### 📁 模块命名规范
|
||||
|
||||
| 模块 | 说明 |
|
||||
|------|------|
|
||||
| patient | 患者管理相关 |
|
||||
| doctor | 医生工作站相关 |
|
||||
| nurse | 护士站相关 |
|
||||
| admin | 后台管理相关 |
|
||||
| common | 公共组件/工具 |
|
||||
| api | API接口相关 |
|
||||
| auth | 认证授权相关 |
|
||||
| payment | 支付相关 |
|
||||
|
||||
### 🖼️ 构建验证截图要求
|
||||
|
||||
#### 必须包含的信息
|
||||
1. **终端窗口**:显示 `npm run build:prod` 命令执行过程
|
||||
2. **成功标识**:明确显示构建成功的提示信息
|
||||
3. **时间戳**:截图包含当前时间,证明是最新构建
|
||||
4. **分支信息**:显示当前工作分支名称
|
||||
|
||||
### ⚠️ 禁止行为
|
||||
|
||||
#### 严重违规(直接拒绝合并)
|
||||
- 无构建验证截图
|
||||
- 代码存在 ESLint 错误
|
||||
- 未填写变更说明
|
||||
- 修改无关代码文件
|
||||
|
||||
---
|
||||
|
||||
## 2. 前端检查(frontend-checklist)
|
||||
|
||||
### 📋 基础检查项
|
||||
|
||||
#### 代码质量
|
||||
- [ ] 代码已通过 ESLint 检查,无警告和错误
|
||||
- [ ] 代码已通过 Prettier 格式化
|
||||
- [ ] 无 console.log() 等调试代码残留
|
||||
- [ ] 变量命名符合规范,语义清晰
|
||||
- [ ] 函数职责单一,复杂度适中
|
||||
|
||||
#### 构建验证
|
||||
- [ ] 本地执行 `npm run build:prod` 成功完成
|
||||
- [ ] 构建产物无报错,体积合理
|
||||
- [ ] 静态资源路径正确,无404错误
|
||||
- [ ] 环境变量配置正确(开发/测试/生产)
|
||||
|
||||
#### 功能验证
|
||||
- [ ] 核心功能流程完整测试通过
|
||||
- [ ] 边界条件和异常场景已覆盖
|
||||
- [ ] 表单验证逻辑正确
|
||||
- [ ] API 接口调用正常,错误处理完善
|
||||
- [ ] 路由跳转逻辑正确
|
||||
|
||||
### 🔧 技术检查项
|
||||
|
||||
#### 模块导入检查
|
||||
- [ ] 所有 import 语句引用的模块实际存在
|
||||
- [ ] 无未使用的 import 导入
|
||||
- [ ] 路径别名(@/)配置正确
|
||||
- [ ] 第三方库版本兼容性确认
|
||||
|
||||
#### 性能优化
|
||||
- [ ] 组件按需加载(懒加载)已配置
|
||||
- [ ] 大数据列表已实现虚拟滚动或分页
|
||||
- [ ] 图片资源已压缩,格式合适
|
||||
- [ ] 无内存泄漏风险(事件监听器、定时器等)
|
||||
|
||||
#### 安全检查
|
||||
- [ ] 用户输入已做 XSS 防护
|
||||
- [ ] 敏感信息不在前端硬编码
|
||||
- [ ] API 请求已做 CSRF 防护
|
||||
- [ ] 权限控制逻辑正确
|
||||
|
||||
### 🌐 兼容性检查
|
||||
|
||||
#### 浏览器兼容
|
||||
- [ ] 主流浏览器(Chrome、Firefox、Safari、Edge)显示正常
|
||||
- [ ] 移动端适配良好(如适用)
|
||||
- [ ] 分辨率适配(1366x768、1920x1080等)
|
||||
|
||||
#### 设备兼容
|
||||
- [ ] 触摸设备操作体验良好
|
||||
- [ ] 键盘导航支持完整
|
||||
- [ ] 屏幕阅读器兼容性(无障碍)
|
||||
|
||||
### 📱 发布准备
|
||||
|
||||
#### 文档更新
|
||||
- [ ] 相关 API 文档已同步更新
|
||||
- [ ] 用户操作手册已更新(如适用)
|
||||
- [ ] 变更日志已记录
|
||||
|
||||
#### 回滚预案
|
||||
- [ ] 回滚方案已准备
|
||||
- [ ] 数据兼容性已确认
|
||||
- [ ] 紧急联系人已明确
|
||||
|
||||
### ✅ 最终确认
|
||||
|
||||
#### 发布前最后检查
|
||||
- [ ] 本地构建截图已附在 PR 中
|
||||
- [ ] 测试环境部署验证通过
|
||||
- [ ] Code Review 已完成并获得批准
|
||||
- [ ] 相关 Bug 已关闭或延期说明
|
||||
|
||||
---
|
||||
|
||||
## 3. 后端检查(backend-checklist)
|
||||
|
||||
### 📋 基础检查项
|
||||
|
||||
#### Maven编译验证
|
||||
- [ ] 本地执行 `mvn compile` 编译通过,无ERROR
|
||||
- [ ] 执行 `mvn package -DskipTests` 打包成功
|
||||
- [ ] 依赖版本无冲突(`mvn dependency:tree` 检查)
|
||||
- [ ] 无编译警告(或已有书面说明可忽略)
|
||||
|
||||
#### 构建产物验证
|
||||
- [ ] JAR/WAR包生成完整,大小合理
|
||||
- [ ] `application.yml` 等配置文件已打包进产物
|
||||
- [ ] 第三方依赖jar包完整(lib目录无缺失)
|
||||
|
||||
### 🔧 Spring Boot 配置检查
|
||||
|
||||
#### 多环境配置
|
||||
- [ ] `application-dev.yml`(开发)配置正确
|
||||
- [ ] `application-test.yml`(测试)配置正确
|
||||
- [ ] `application-prod.yml`(生产)配置正确
|
||||
- [ ] 启动参数 `--spring.profiles.active` 指定正确环境
|
||||
- [ ] 生产环境未启用devtools热部署
|
||||
|
||||
#### Actuator安全
|
||||
- [ ] 生产环境 `/actuator` 端点已禁用或限制访问
|
||||
- [ ] `/actuator/env`、`/actuator/heapdump` 等敏感端点已关闭
|
||||
- [ ] 健康检查端点 `/actuator/health` 返回信息已脱敏
|
||||
|
||||
#### 启动校验
|
||||
- [ ] 数据库连接池配置合理(HikariCP最大/最小连接数)
|
||||
- [ ] Redis/消息中间件连接配置正确
|
||||
- [ ] 启动日志无ERROR级别异常
|
||||
|
||||
### 🗄️ MyBatis Plus 规范检查
|
||||
|
||||
#### 实体-表映射
|
||||
- [ ] 所有实体类标注 `@TableName`,表名与实际一致
|
||||
- [ ] 主键字段标注 `@TableId(type = IdType.AUTO)` 或对应策略
|
||||
- [ ] 非表字段标注 `@TableField(exist = false)`
|
||||
- [ ] 字段命名符合下划线转驼峰规则
|
||||
|
||||
#### SQL安全
|
||||
- [ ] 所有查询使用参数化查询(`QueryWrapper` / `LambdaQueryWrapper`)
|
||||
- [ ] 禁止字符串拼接SQL(`"WHERE name = '" + name + "'"`)
|
||||
- [ ] 批量操作使用MyBatis Plus `saveBatch` / `updateBatchById`
|
||||
- [ ] 复杂SQL使用XML映射,避免注解内嵌长SQL
|
||||
|
||||
#### 事务管理
|
||||
- [ ] 涉及多表写操作的方法标注 `@Transactional`
|
||||
- [ ] 事务边界合理,不包含外部HTTP调用
|
||||
- [ ] 异常回滚配置正确(`rollbackFor = Exception.class`)
|
||||
- [ ] 事务方法未被同一类内方法直接调用(自调用失效问题)
|
||||
|
||||
#### 分页插件
|
||||
- [ ] `PaginationInnerInterceptor` 已正确配置
|
||||
- [ ] 分页查询使用 `Page<T>` 对象,非手动limit/offset
|
||||
|
||||
### 🔌 RESTful API 设计检查
|
||||
|
||||
#### 统一返回格式
|
||||
- [ ] 所有接口返回 `{code, msg, data}` 统一结构
|
||||
- [ ] 成功返回 `code=200`,业务错误使用自定义错误码
|
||||
- [ ] 异常通过 `@ControllerAdvice` + `@ExceptionHandler` 统一处理
|
||||
|
||||
#### HTTP状态码
|
||||
- [ ] 资源创建返回 `201 Created`
|
||||
- [ ] 资源删除返回 `204 No Content`
|
||||
- [ ] 参数校验失败返回 `400 Bad Request`
|
||||
- [ ] 未认证返回 `401 Unauthorized`
|
||||
- [ ] 无权限返回 `403 Forbidden`
|
||||
- [ ] 资源不存在返回 `404 Not Found`
|
||||
|
||||
#### 参数校验
|
||||
- [ ] 请求参数使用 `@Valid` / `@Validated` 注解校验
|
||||
- [ ] 必填字段标注 `@NotBlank` / `@NotNull`
|
||||
- [ ] 数值范围标注 `@Min` / `@Max`
|
||||
- [ ] 格式校验使用 `@Pattern`(如手机号、身份证号)
|
||||
- [ ] 校验失败返回明确错误信息(非500堆栈)
|
||||
|
||||
#### API版本管理
|
||||
- [ ] 接口路径包含版本号(`/api/v1/`、`/api/v2/`)
|
||||
- [ ] 废弃接口标注 `@Deprecated`,并在文档中说明
|
||||
- [ ] 不兼容变更必须升级版本号
|
||||
|
||||
### 🔒 安全与合规检查
|
||||
|
||||
#### 数据脱敏
|
||||
- [ ] 患者身份证号在日志中脱敏(`***` 掩码)
|
||||
- [ ] 患者手机号在日志中脱敏(前3后4,中间`****`)
|
||||
- [ ] 敏感字段序列化时使用 `@JsonSerialize` 自定义脱敏器
|
||||
- [ ] 接口返回中非必需字段不暴露(如密码、salt)
|
||||
|
||||
#### 权限控制
|
||||
- [ ] 所有涉及患者数据的接口标注 `@PreAuthorize`
|
||||
- [ ] 数据级权限校验(医生只能访问本科室患者)
|
||||
- [ ] 越权访问返回 `403`,非 `404` 或 `500`
|
||||
- [ ] 敏感操作(删除、修改诊断)需二次确认或额外权限
|
||||
|
||||
#### 审计日志
|
||||
- [ ] 处方修改记录操作人、时间、变更内容
|
||||
- [ ] 病历删除操作记录完整审计链
|
||||
- [ ] 审计日志独立存储,不可被业务用户删除
|
||||
- [ ] 关键业务操作记录IP地址和操作终端
|
||||
|
||||
### ⚡ 性能检查
|
||||
|
||||
#### 数据库查询
|
||||
- [ ] 无N+1查询问题(使用 `JOIN` 或批量查询)
|
||||
- [ ] 大表查询必须有分页限制
|
||||
- [ ] 慢查询已优化(执行时间 < 500ms)
|
||||
- [ ] 索引已覆盖高频查询条件
|
||||
|
||||
#### 接口性能
|
||||
- [ ] 核心接口响应时间 < 1秒
|
||||
- [ ] 列表接口支持分页,无全量返回
|
||||
- [ ] 大文件下载使用流式传输,非全量加载到内存
|
||||
|
||||
### 📝 文档与发布准备
|
||||
|
||||
#### 文档更新
|
||||
- [ ] API接口文档已同步更新(路径、参数、返回值)
|
||||
- [ ] 数据库变更脚本已提供(DDL/DML)
|
||||
- [ ] 配置变更说明已记录(新增/修改的配置项)
|
||||
- [ ] 影响范围说明已明确(哪些模块、哪些接口受影响)
|
||||
|
||||
#### 回滚预案
|
||||
- [ ] 数据库变更可回滚(提供反向SQL脚本)
|
||||
- [ ] 配置变更可快速回退
|
||||
- [ ] 紧急回滚流程已明确(谁、怎么做、多长时间)
|
||||
- [ ] 回滚后数据一致性已验证
|
||||
|
||||
### ✅ 最终确认
|
||||
|
||||
#### 发布前最后检查
|
||||
- [ ] `mvn compile` 构建成功(附终端截图)
|
||||
- [ ] 关键单元测试通过
|
||||
- [ ] 测试环境部署验证通过
|
||||
- [ ] Code Review 已完成并获得批准
|
||||
- [ ] 相关Bug已关闭或延期说明
|
||||
|
||||
---
|
||||
|
||||
## 4. CI/CD门禁(cicd-gatekeeper)
|
||||
|
||||
### 🎯 规范目标
|
||||
|
||||
建立自动化质量门禁,确保每次代码提交都经过严格验证,防止低质量代码进入主干分支,提升系统稳定性和开发效率。
|
||||
|
||||
### 🔒 门禁层级
|
||||
|
||||
#### 1. 提交前门禁(Pre-commit)
|
||||
**触发时机**:`git commit` 执行前
|
||||
**验证内容**:
|
||||
- ESLint 代码规范检查
|
||||
- Prettier 代码格式化
|
||||
- 简单的单元测试(快速执行)
|
||||
|
||||
**工具配置**:
|
||||
- Husky + lint-staged
|
||||
- 配置文件:`.husky/pre-commit`
|
||||
|
||||
#### 2. 推送前门禁(Pre-push)
|
||||
**触发时机**:`git push` 执行前
|
||||
**验证内容**:
|
||||
- 完整的单元测试套件
|
||||
- 构建验证(`npm run build:prod`)
|
||||
- 集成测试(核心流程)
|
||||
|
||||
**工具配置**:
|
||||
- Husky pre-push hook
|
||||
- 配置文件:`.husky/pre-push`
|
||||
|
||||
#### 3. CI流水线门禁(CI Pipeline)
|
||||
**触发时机**:代码推送到远程仓库后
|
||||
**验证内容**:
|
||||
- 完整的测试套件(单元+集成+端到端)
|
||||
- 代码覆盖率检查(分阶段目标:Q1≥30%,Q2≥50%,Q3≥80%)
|
||||
- 安全扫描(SAST)
|
||||
- 构建产物验证
|
||||
- 部署到测试环境
|
||||
|
||||
**工具配置**:
|
||||
- Spug CI/CD 流水线
|
||||
- Gitea Webhook 触发
|
||||
|
||||
#### 4. 发布前门禁(Release Gate)
|
||||
**触发时机**:准备发布到生产环境前
|
||||
**验证内容**:
|
||||
- 生产环境冒烟测试
|
||||
- 性能基准测试
|
||||
- 安全合规检查
|
||||
- 回滚预案验证
|
||||
|
||||
### ⚙️ 具体配置要求
|
||||
|
||||
#### ESLint 配置
|
||||
```javascript
|
||||
// eslint.config.js 关键配置
|
||||
import globals from "globals";
|
||||
import pluginVue from "eslint-plugin-vue";
|
||||
import parserVue from "vue-eslint-parser";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
|
||||
export default [
|
||||
{
|
||||
name: "app/files-to-lint",
|
||||
files: ["**/*.{js,mjs,jsx,vue}"],
|
||||
},
|
||||
|
||||
{
|
||||
name: "app/files-to-ignore",
|
||||
ignores: ["**/dist/**", "**/node_modules/**", "**/help-center/**"],
|
||||
},
|
||||
|
||||
...pluginVue.configs["flat/recommended"],
|
||||
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
parser: parserVue,
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
|
||||
plugins: {
|
||||
import: importPlugin,
|
||||
},
|
||||
|
||||
rules: {
|
||||
// 确保导入的模块实际存在(核心规则,防止构建失败)
|
||||
"import/no-unresolved": "error",
|
||||
// 确保导入的命名导出实际存在
|
||||
"import/named": "error",
|
||||
// 确保默认导出存在
|
||||
"import/default": "error",
|
||||
// 确保命名空间导出存在
|
||||
"import/namespace": "error",
|
||||
},
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
#### Java 后端配置
|
||||
```xml
|
||||
<!-- pom.xml 关键插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</plugin>
|
||||
```
|
||||
|
||||
#### 数据库迁移配置
|
||||
```yaml
|
||||
# application.yml Flyway配置
|
||||
flyway:
|
||||
enabled: true
|
||||
locations: classpath:db/migration
|
||||
baseline-on-migrate: true
|
||||
```
|
||||
|
||||
#### Husky 配置
|
||||
```bash
|
||||
# .husky/pre-commit
|
||||
#!/bin/sh
|
||||
npm run lint-staged
|
||||
|
||||
# .husky/pre-push
|
||||
#!/bin/sh
|
||||
npm run test:unit && npm run build:prod
|
||||
```
|
||||
|
||||
#### lint-staged 配置
|
||||
```json
|
||||
// package.json
|
||||
{
|
||||
"lint-staged": {
|
||||
"*.{js,vue}": ["eslint --fix", "prettier --write"],
|
||||
"*.{css,scss}": ["stylelint --fix", "prettier --write"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 🚫 失败处理机制
|
||||
|
||||
#### 自动处理
|
||||
- **构建失败**:自动阻止 PR 合并
|
||||
- **测试失败**:标记 PR 为失败状态
|
||||
- **安全漏洞**:立即通知安全团队
|
||||
|
||||
#### 人工处理
|
||||
- **紧急修复**:可申请临时绕过(需架构师批准)
|
||||
- **误报处理**:提交豁免申请并说明原因
|
||||
- **规则调整**:通过 RFC 流程申请规则变更
|
||||
|
||||
### 📊 监控与度量
|
||||
|
||||
#### 关键指标
|
||||
- 门禁通过率 ≥ 95%
|
||||
- 平均修复时间 ≤ 2小时
|
||||
- 误报率 ≤ 5%
|
||||
|
||||
#### 报告机制
|
||||
- 每日门禁失败统计
|
||||
- 周度质量趋势报告
|
||||
- 月度规则优化建议
|
||||
|
||||
### 🔄 持续改进
|
||||
|
||||
#### 规则演进
|
||||
- 每月评审门禁规则有效性
|
||||
- 根据项目需求调整检查强度
|
||||
- 引入新的质量检查工具
|
||||
|
||||
#### 团队培训
|
||||
- 新成员入职培训包含门禁规范
|
||||
- 定期分享最佳实践案例
|
||||
- 建立常见问题解决方案库
|
||||
|
||||
---
|
||||
|
||||
## 5. 发布确认与回滚预案
|
||||
|
||||
### 📋 发布前最终确认清单
|
||||
|
||||
#### 前端确认
|
||||
- [ ] 本地构建成功(`npm run build:prod`)
|
||||
- [ ] 核心功能流程测试通过
|
||||
- [ ] 模块导入检查通过(无import错误)
|
||||
- [ ] 兼容性测试完成
|
||||
|
||||
#### 后端确认
|
||||
- [ ] Maven编译成功(`mvn compile`)
|
||||
- [ ] 单元测试通过
|
||||
- [ ] 数据库脚本验证通过
|
||||
- [ ] API接口测试通过
|
||||
|
||||
#### 协同确认
|
||||
- [ ] 前后端接口契约一致
|
||||
- [ ] 联调测试通过
|
||||
- [ ] Code Review 已完成
|
||||
- [ ] 测试环境部署验证通过
|
||||
|
||||
### 🚨 回滚预案
|
||||
|
||||
#### 触发条件
|
||||
- [ ] 生产环境出现严重Bug
|
||||
- [ ] 性能严重下降
|
||||
- [ ] 数据一致性问题
|
||||
- [ ] 安全漏洞暴露
|
||||
|
||||
#### 回滚步骤
|
||||
1. **立即停止**:暂停新流量进入
|
||||
2. **版本回退**:部署上一个稳定版本
|
||||
3. **数据回滚**:执行数据库回滚脚本(如有)
|
||||
4. **验证恢复**:确认系统功能正常
|
||||
5. **问题分析**:记录根本原因和改进措施
|
||||
|
||||
#### 责任分工
|
||||
- **技术负责人**:执行回滚操作
|
||||
- **测试负责人**:验证回滚后功能
|
||||
- **项目经理**:协调沟通和进度同步
|
||||
- **运维团队**:监控系统状态
|
||||
|
||||
### 📞 紧急联系人
|
||||
|
||||
| 角色 | 姓名 | 联系方式 | 职责 |
|
||||
|------|------|----------|------|
|
||||
| 技术负责人 | 诸葛亮 | @诸葛亮 | 架构决策和技术指导 |
|
||||
| 前端负责人 | 赵云 | @赵云 | 前端问题处理 |
|
||||
| 后端负责人 | 关羽 | @关羽 | 后端问题处理 |
|
||||
| 测试负责人 | 张飞 | @张飞 | 质量验证和问题复现 |
|
||||
| 项目经理 | 刘备 | @刘备 | 项目协调和进度管理 |
|
||||
| 文档负责人 | 陈琳 | @陈琳 | 文档维护和知识沉淀 |
|
||||
|
||||
---
|
||||
|
||||
**文档版本**:v1.0
|
||||
**最后更新**:2026年4月25日
|
||||
**负责人**:陈琳(文档专家)
|
||||
**适用范围**:HIS 系统所有开发人员
|
||||
214
docs/specs/playwright-e2e-testing-plan.md
Normal file
214
docs/specs/playwright-e2e-testing-plan.md
Normal file
@@ -0,0 +1,214 @@
|
||||
# HIS项目 Playwright E2E 自动化测试方案 v1.0
|
||||
|
||||
## 一、方案概述
|
||||
|
||||
### 1.1 选型理由
|
||||
- **Playwright** 是微软开源的端到端测试框架,完美适配 Vue 3 + Vite 技术栈
|
||||
- 自动等待机制适合HIS系统复杂交互场景(异步加载、动态渲染)
|
||||
- 支持多浏览器(Chromium/Firefox/WebKit),CI/CD集成成熟
|
||||
- 已有 `@playwright/test ^1.58.2` 依赖 installed
|
||||
|
||||
### 1.2 目标
|
||||
1. 核心业务流程自动化覆盖率达到 80%+
|
||||
2. 已修复Bug 100% 回归测试覆盖
|
||||
3. 每次代码推送自动触发测试,失败阻断发布
|
||||
|
||||
## 二、项目结构
|
||||
|
||||
```
|
||||
openhis-ui-vue3/
|
||||
├── tests/
|
||||
│ ├── e2e/
|
||||
│ │ ├── fixtures/ # 测试夹具
|
||||
│ │ │ └── auth.ts # 登录认证fixture
|
||||
│ │ ├── pages/ # 页面对象模型(POM)
|
||||
│ │ │ ├── LoginPage.ts
|
||||
│ │ │ ├── DoctorStationPage.ts
|
||||
│ │ │ └── SurgeryBillingPage.ts
|
||||
│ │ ├── specs/ # 测试用例
|
||||
│ │ │ ├── login.spec.ts
|
||||
│ │ │ ├── doctor-station.spec.ts
|
||||
│ │ │ ├── surgery-billing.spec.ts
|
||||
│ │ │ └── bug-regression.spec.ts # Bug回归测试
|
||||
│ │ └── utils/
|
||||
│ │ └── test-data.ts # 测试数据
|
||||
│ └── playwright.config.ts # Playwright配置
|
||||
├── .env.test # 测试环境变量
|
||||
└── package.json # 已有playwright依赖
|
||||
```
|
||||
|
||||
## 三、环境配置
|
||||
|
||||
### 3.1 环境变量(.env.test)
|
||||
```bash
|
||||
# 测试环境配置
|
||||
VITE_APP_BASE_API=http://192.168.110.253:8080
|
||||
TEST_USERNAME=test_admin
|
||||
TEST_PASSWORD=test123456
|
||||
TEST_BASE_URL=http://localhost:80
|
||||
```
|
||||
|
||||
### 3.2 Playwright配置(playwright.config.ts)
|
||||
```typescript
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './tests/e2e/specs',
|
||||
timeout: 60 * 1000,
|
||||
expect: { timeout: 10000 },
|
||||
fullyParallel: false,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: 1,
|
||||
reporter: [['html', { outputFolder: 'playwright-report' }], ['list']],
|
||||
use: {
|
||||
baseURL: process.env.TEST_BASE_URL || 'http://localhost:80',
|
||||
trace: 'on-first-retry',
|
||||
screenshot: 'only-on-failure',
|
||||
video: 'retain-on-failure',
|
||||
},
|
||||
projects: [
|
||||
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
## 四、核心测试用例
|
||||
|
||||
### 4.1 登录测试(login.spec.ts)
|
||||
```typescript
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('用户登录成功', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.fill('input[placeholder="请输入用户名"]', process.env.TEST_USERNAME || 'admin');
|
||||
await page.fill('input[placeholder="请输入密码"]', process.env.TEST_PASSWORD || '123456');
|
||||
await page.click('button:has-text("登录")');
|
||||
await expect(page).toHaveURL(/.*dashboard.*/);
|
||||
await expect(page.locator('.user-avatar')).toBeVisible();
|
||||
});
|
||||
|
||||
test('登录失败-错误密码', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.fill('input[placeholder="请输入用户名"]', 'admin');
|
||||
await page.fill('input[placeholder="请输入密码"]', 'wrongpassword');
|
||||
await page.click('button:has-text("登录")');
|
||||
await expect(page.locator('.el-message--error')).toBeVisible();
|
||||
});
|
||||
```
|
||||
|
||||
### 4.2 门诊医生站测试(doctor-station.spec.ts)
|
||||
```typescript
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('门诊医生站', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// 登录
|
||||
await page.goto('/');
|
||||
await page.fill('input[placeholder="请输入用户名"]', process.env.TEST_USERNAME || 'admin');
|
||||
await page.fill('input[placeholder="请输入密码"]', process.env.TEST_PASSWORD || '123456');
|
||||
await page.click('button:has-text("登录")');
|
||||
await page.waitForURL(/.*dashboard.*/);
|
||||
});
|
||||
|
||||
test('#427 检查项目分类手风琴展开', async ({ page }) => {
|
||||
await page.goto('/doctorstation');
|
||||
// 点击第一个分类
|
||||
await page.click('.category-item >> nth=0');
|
||||
await expect(page.locator('.category-content >> nth=0')).toBeVisible();
|
||||
// 点击第二个分类,第一个应收起
|
||||
await page.click('.category-item >> nth=1');
|
||||
await expect(page.locator('.category-content >> nth=0')).not.toBeVisible();
|
||||
await expect(page.locator('.category-content >> nth=1')).toBeVisible();
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### 4.3 手术计费回归测试(bug-regression.spec.ts)
|
||||
```typescript
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Bug回归测试', () => {
|
||||
test('#437 手术计费防重复提交', async ({ page }) => {
|
||||
// 登录并导航到手术计费
|
||||
await page.goto('/');
|
||||
await page.fill('input[placeholder="请输入用户名"]', process.env.TEST_USERNAME || 'admin');
|
||||
await page.fill('input[placeholder="请输入密码"]', process.env.TEST_PASSWORD || '123456');
|
||||
await page.click('button:has-text("登录")');
|
||||
await page.waitForURL(/.*dashboard.*/);
|
||||
await page.goto('/surgery-billing');
|
||||
|
||||
// 快速连续点击新增按钮(测试防重复锁)
|
||||
const addBtn = page.locator('button:has-text("新增")');
|
||||
await addBtn.click();
|
||||
await addBtn.click(); // 第二次应被阻止
|
||||
await addBtn.click(); // 第三次应被阻止
|
||||
|
||||
// 验证只弹出一个表单
|
||||
await expect(page.locator('.el-dialog')).toHaveCount(1);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## 五、执行命令
|
||||
|
||||
```bash
|
||||
# 安装浏览器
|
||||
npx playwright install chromium
|
||||
|
||||
# 运行所有测试
|
||||
npm run test:e2e
|
||||
|
||||
# 运行单个测试文件
|
||||
npx playwright test login.spec.ts
|
||||
|
||||
# 生成HTML报告
|
||||
npx playwright show-report
|
||||
|
||||
# UI模式(调试用)
|
||||
npx playwright test --ui
|
||||
```
|
||||
|
||||
## 六、CI/CD集成
|
||||
|
||||
### 6.1 package.json脚本
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:ui": "playwright test --ui",
|
||||
"test:e2e:report": "playwright show-report"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 6.2 Spug流水线集成
|
||||
```yaml
|
||||
# Spug 构建后阶段添加
|
||||
- name: E2E Testing
|
||||
script: |
|
||||
cd openhis-ui-vue3
|
||||
npx playwright install --with-deps chromium
|
||||
npm run test:e2e -- --reporter=html
|
||||
# 测试失败则阻断发布
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "E2E测试失败,阻断发布!"
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
## 七、实施计划
|
||||
|
||||
| 阶段 | 时间 | 内容 | 负责人 |
|
||||
|------|------|------|--------|
|
||||
| Phase 1 | 第1周 | 登录+核心页面冒烟测试 | 张飞+赵云 |
|
||||
| Phase 2 | 第2-3周 | 门诊医生站+手术计费全流程 | 张飞 |
|
||||
| Phase 3 | 第4周 | Bug回归测试全覆盖 | 张飞 |
|
||||
| Phase 4 | 第5周 | CI/CD流水线集成 | 赵云+运维 |
|
||||
|
||||
## 八、注意事项
|
||||
|
||||
1. **测试数据隔离**:使用独立的测试数据库,不污染生产数据
|
||||
2. **环境变量**:敏感信息通过 `.env.test` 管理,不提交到git
|
||||
3. **截图留痕**:失败时自动截图,便于排查
|
||||
4. **测试优先**:新功能开发时同步编写测试用例
|
||||
1
gitea_test_huatuo.txt
Normal file
1
gitea_test_huatuo.txt
Normal file
@@ -0,0 +1 @@
|
||||
华佗 Gitea 提交测试成功 - Wed Apr 15 10:21:10 AM CST 2026
|
||||
1
gitea_test_xunyu.txt
Normal file
1
gitea_test_xunyu.txt
Normal file
@@ -0,0 +1 @@
|
||||
荀彧 Gitea 提交测试成功 - Tue Apr 14 11:06:47 PM CST 2026
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.core.web.controller.system;
|
||||
|
||||
import com.core.common.config.CoreConfig;
|
||||
import com.core.common.core.domain.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 系统版本信息
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system")
|
||||
public class SysVersionController {
|
||||
|
||||
@Autowired
|
||||
private CoreConfig coreConfig;
|
||||
|
||||
/**
|
||||
* 获取后端版本号
|
||||
*/
|
||||
@GetMapping("/version")
|
||||
public AjaxResult getVersion() {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("backendVersion", coreConfig.getVersion());
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,9 @@ public class SecurityConfig {
|
||||
.permitAll()
|
||||
.antMatchers("/patientmanage/information/**")
|
||||
.permitAll()
|
||||
// 登录页展示用的系统版本信息,允许匿名访问
|
||||
.antMatchers("/system/version")
|
||||
.permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated();
|
||||
})
|
||||
|
||||
@@ -20,12 +20,12 @@ public interface InfectiousAuditMapper extends BaseMapper<InfectiousAudit> {
|
||||
/**
|
||||
* 根据报卡编号查询审核记录
|
||||
*/
|
||||
@Select("SELECT * FROM infectious_audit WHERE card_id = #{cardId} ORDER BY audit_time DESC")
|
||||
@Select("SELECT * FROM infectious_audit WHERE card_id::text = #{cardId} ORDER BY audit_time DESC")
|
||||
List<InfectiousAudit> selectByCardId(@Param("cardId") String cardId);
|
||||
|
||||
/**
|
||||
* 获取下一个审核序号
|
||||
*/
|
||||
@Select("SELECT COALESCE(MAX(audit_seq), 0) + 1 FROM infectious_audit WHERE card_id = #{cardId}")
|
||||
@Select("SELECT COALESCE(MAX(audit_seq), 0) + 1 FROM infectious_audit WHERE card_id::text = #{cardId}")
|
||||
Integer getNextAuditSeq(@Param("cardId") String cardId);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ import com.openhis.web.chargemanage.dto.PatientMetadata;
|
||||
import com.openhis.web.chargemanage.dto.PractitionerMetadata;
|
||||
import com.openhis.web.chargemanage.dto.ReprintRegistrationDto;
|
||||
import com.openhis.web.chargemanage.mapper.OutpatientRegistrationAppMapper;
|
||||
import com.openhis.triageandqueuemanage.domain.DivLog;
|
||||
import com.openhis.triageandqueuemanage.domain.TriageCandidateExclusion;
|
||||
import com.openhis.triageandqueuemanage.service.DivLogService;
|
||||
import com.openhis.triageandqueuemanage.service.TriageCandidateExclusionService;
|
||||
import com.openhis.web.paymentmanage.appservice.IPaymentRecService;
|
||||
import com.openhis.web.paymentmanage.dto.CancelPaymentDto;
|
||||
@@ -111,6 +113,9 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
@Resource
|
||||
com.openhis.triageandqueuemanage.service.TriageQueueItemService triageQueueItemService;
|
||||
|
||||
@Resource
|
||||
DivLogService divLogService;
|
||||
|
||||
@Resource
|
||||
ScheduleSlotMapper scheduleSlotMapper;
|
||||
|
||||
@@ -520,10 +525,11 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
ParticipantType.ADMITTER.getCode(), ParticipantType.REGISTRATION_DOCTOR.getCode(), queryWrapper,
|
||||
ChargeItemContext.REGISTER.getValue(), PaymentStatus.SUCCESS.getValue());
|
||||
|
||||
// 过滤候选池排除列表(如果是从智能候选池查询,排除已加入队列的患者)
|
||||
// 检查请求参数 excludeFromCandidatePool,如果为 true 或未设置,则过滤排除列表
|
||||
// 过滤候选池排除列表
|
||||
// 仅当调用方显式传 excludeFromCandidatePool=true 时才过滤,避免非分诊场景(挂号/收费)
|
||||
// 因未传参导致默认过滤,使已入队患者不可见
|
||||
String excludeParam = request.getParameter("excludeFromCandidatePool");
|
||||
boolean shouldExclude = excludeParam == null || "true".equalsIgnoreCase(excludeParam);
|
||||
boolean shouldExclude = "true".equalsIgnoreCase(excludeParam);
|
||||
if (shouldExclude && currentDayEncounter != null && !currentDayEncounter.getRecords().isEmpty()) {
|
||||
try {
|
||||
// 获取当前租户和日期
|
||||
@@ -807,6 +813,23 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
queueItem.setDeleteFlag("1");
|
||||
queueItem.setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(queueItem);
|
||||
|
||||
// 写入分诊操作日志:诊前退号
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
DivLog divLog = new DivLog()
|
||||
.setPoolId(queueItem.getPoolId())
|
||||
.setSlotId(queueItem.getSlotId())
|
||||
.setOpUserId(loginUser != null ? loginUser.getUserId() : null)
|
||||
.setAction("REFUND")
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setUpdateAt(LocalDateTime.now())
|
||||
.setCreatedAt(LocalDateTime.now());
|
||||
divLogService.save(divLog);
|
||||
} catch (Exception e) {
|
||||
log.error("写入分诊退号日志失败,encounterId={}", encounterId, e);
|
||||
}
|
||||
|
||||
log.info("退号成功,已移除分诊队列记录,encounterId={}, queueItemId={}", encounterId, queueItem.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,13 @@ public class OutpatientPricingController {
|
||||
@RequestParam(value = "organizationId") Long organizationId,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(value = "categoryCode", required = false) String categoryCode) {
|
||||
@RequestParam(value = "categoryCode", required = false) String categoryCode,
|
||||
@RequestParam(value = "adviceType", required = false) Integer adviceType) {
|
||||
// 将 categoryCode 设置到 adviceBaseDto 中
|
||||
// Bug #438 修复:接收并处理 adviceType 参数
|
||||
if (adviceType != null) {
|
||||
adviceBaseDto.setAdviceType(adviceType);
|
||||
}
|
||||
if (categoryCode != null && !categoryCode.isEmpty()) {
|
||||
adviceBaseDto.setCategoryCode(categoryCode);
|
||||
}
|
||||
|
||||
@@ -153,4 +153,26 @@ public class CurrentDayEncounterDto {
|
||||
*/
|
||||
private Boolean isFromAppointment;
|
||||
|
||||
/**
|
||||
* 号源槽位ID(关联 adm_schedule_slot.id)
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long slotId;
|
||||
|
||||
/**
|
||||
* 号源池ID(关联 adm_schedule_pool.id)
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long poolId;
|
||||
|
||||
/**
|
||||
* 诊室名称(Bug #410:分诊队列需显示诊室而非科室)
|
||||
*/
|
||||
private String clinicRoom;
|
||||
|
||||
/**
|
||||
* 预约序号(来自 adm_schedule_slot.seq_no)
|
||||
*/
|
||||
private Integer seqNo;
|
||||
|
||||
}
|
||||
|
||||
@@ -209,4 +209,14 @@ public class EncounterPatientPrescriptionDto {
|
||||
private String discountRate = "0";
|
||||
private String discountRate_dictText;
|
||||
|
||||
/**
|
||||
* 账单生成来源
|
||||
*/
|
||||
private Integer generateSourceEnum;
|
||||
|
||||
/**
|
||||
* 来源单据号(手术单号等)
|
||||
*/
|
||||
private String sourceBillNo;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.check.domain.CheckMethod;
|
||||
import com.openhis.check.domain.CheckPackage;
|
||||
import com.openhis.check.service.ICheckMethodService;
|
||||
import com.openhis.check.service.ICheckPackageService;
|
||||
import com.openhis.web.check.appservice.ICheckMethodAppService;
|
||||
import com.openhis.web.check.dto.CheckMethodDto;
|
||||
import com.openhis.web.reportmanage.utils.ExcelFillerUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -16,6 +19,7 @@ import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -24,10 +28,15 @@ public class CheckMethodAppServiceImpl implements ICheckMethodAppService {
|
||||
@Resource
|
||||
private ICheckMethodService checkMethodService;
|
||||
|
||||
@Resource
|
||||
private ICheckPackageService checkPackageService; // Bug #384修复:注入套餐服务
|
||||
|
||||
@Override
|
||||
public R<?> getCheckMethodList() {
|
||||
List<CheckMethod> list = checkMethodService.list();
|
||||
return R.ok(list);
|
||||
// Bug #384修复:转换为DTO并关联套餐价格
|
||||
List<CheckMethodDto> dtoList = convertToDtoWithPackagePrice(list);
|
||||
return R.ok(dtoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +52,67 @@ public class CheckMethodAppServiceImpl implements ICheckMethodAppService {
|
||||
wrapper.eq(CheckMethod::getPackageName, packageName);
|
||||
}
|
||||
List<CheckMethod> list = checkMethodService.list(wrapper);
|
||||
return R.ok(list);
|
||||
// Bug #384修复:转换为DTO并关联套餐价格
|
||||
List<CheckMethodDto> dtoList = convertToDtoWithPackagePrice(list);
|
||||
return R.ok(dtoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug #384修复:转换CheckMethod为DTO,并通过packageName关联查询套餐价格
|
||||
* @param methods 检查方法列表
|
||||
* @return 包含套餐价格的DTO列表
|
||||
*/
|
||||
private List<CheckMethodDto> convertToDtoWithPackagePrice(List<CheckMethod> methods) {
|
||||
if (methods == null || methods.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
// 获取所有packageName,批量查询套餐
|
||||
List<String> packageNames = methods.stream()
|
||||
.map(CheckMethod::getPackageName)
|
||||
.filter(ObjectUtil::isNotEmpty)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Bug #384修复: 批量查询套餐信息,使用final变量
|
||||
final Map<String, CheckPackage> packageMap;
|
||||
if (!packageNames.isEmpty()) {
|
||||
List<CheckPackage> packages = checkPackageService.list(
|
||||
new LambdaQueryWrapper<CheckPackage>()
|
||||
.in(CheckPackage::getPackageName, packageNames)
|
||||
.eq(CheckPackage::getIsDisabled, 0) // 只查未停用的套餐
|
||||
);
|
||||
packageMap = packages.stream()
|
||||
.collect(Collectors.toMap(CheckPackage::getPackageName, p -> p, (p1, p2) -> p1));
|
||||
} else {
|
||||
packageMap = Map.of();
|
||||
}
|
||||
|
||||
// 转换为DTO并填充价格
|
||||
return methods.stream().map(m -> {
|
||||
CheckMethodDto dto = new CheckMethodDto();
|
||||
dto.setId(m.getId() != null ? m.getId().longValue() : null);
|
||||
dto.setCheckType(m.getCheckType());
|
||||
dto.setCode(m.getCode());
|
||||
dto.setName(m.getName());
|
||||
dto.setPackageName(m.getPackageName());
|
||||
dto.setExposureNum(m.getExposureNum());
|
||||
dto.setOrderNum(m.getOrderNum());
|
||||
dto.setRemark(m.getRemark());
|
||||
dto.setCreateTime(m.getCreateTime());
|
||||
dto.setUpdateTime(m.getUpdateTime());
|
||||
|
||||
// 通过packageName匹配套餐价格
|
||||
if (ObjectUtil.isNotEmpty(m.getPackageName())) {
|
||||
CheckPackage pkg = packageMap.get(m.getPackageName());
|
||||
if (pkg != null) {
|
||||
dto.setPackagePrice(pkg.getPackagePrice());
|
||||
dto.setServiceFee(pkg.getServiceFee());
|
||||
}
|
||||
}
|
||||
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,9 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.core.common.core.controller.BaseController;
|
||||
import com.core.common.core.domain.AjaxResult;
|
||||
import com.core.common.core.page.TableDataInfo;
|
||||
import com.core.common.exception.ServiceException;
|
||||
import com.core.common.utils.AssignSeqUtil;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.administration.domain.Account;
|
||||
import com.openhis.administration.domain.ChargeItem;
|
||||
import com.openhis.administration.service.IAccountService;
|
||||
import com.openhis.administration.service.IChargeItemService;
|
||||
import com.openhis.check.domain.ExamApply;
|
||||
import com.openhis.check.domain.ExamApplyItem;
|
||||
@@ -17,7 +20,10 @@ import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.enums.AssignSeqEnum;
|
||||
import com.openhis.common.enums.ChargeItemStatus;
|
||||
import com.openhis.common.enums.GenerateSource;
|
||||
import com.openhis.common.enums.ItemType;
|
||||
import com.openhis.common.enums.RequestStatus;
|
||||
import com.openhis.administration.domain.Organization;
|
||||
import com.openhis.administration.service.IOrganizationService;
|
||||
import com.openhis.web.check.dto.ExamApplyDto;
|
||||
import com.openhis.web.check.dto.ExamApplyItemDto;
|
||||
import com.openhis.workflow.domain.ServiceRequest;
|
||||
@@ -57,17 +63,41 @@ public class ExamApplyController extends BaseController {
|
||||
@Autowired
|
||||
private IChargeItemService chargeItemService;
|
||||
|
||||
@Autowired
|
||||
private IAccountService accountService;
|
||||
|
||||
@Autowired
|
||||
private AssignSeqUtil assignSeqUtil;
|
||||
@Autowired
|
||||
private IOrganizationService organizationService;
|
||||
|
||||
/**
|
||||
* 查询检查申请单列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ExamApply examApply) {
|
||||
public TableDataInfo list(ExamApply examApply, @RequestParam(value = "encounterId", required = false) Long encounterId) {
|
||||
startPage();
|
||||
LambdaQueryWrapper<ExamApply> wrapper = new LambdaQueryWrapper<>();
|
||||
if (examApply.getVisitNo() != null) {
|
||||
|
||||
// 优先按本次就诊 encounterId 过滤(通过 wor_service_request 关联)
|
||||
if (encounterId != null) {
|
||||
List<ServiceRequest> reqList = serviceRequestService.list(new LambdaQueryWrapper<ServiceRequest>()
|
||||
.eq(ServiceRequest::getEncounterId, encounterId)
|
||||
.eq(ServiceRequest::getBasedOnTable, "exam_apply")
|
||||
.isNotNull(ServiceRequest::getBasedOnId)
|
||||
);
|
||||
List<Long> basedOnIds = reqList.stream()
|
||||
.map(ServiceRequest::getBasedOnId)
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.distinct()
|
||||
.toList();
|
||||
// 没有本次就诊的检查申请单时,直接返回空列表
|
||||
if (basedOnIds.isEmpty()) {
|
||||
return getDataTable(java.util.Collections.emptyList());
|
||||
}
|
||||
wrapper.in(ExamApply::getId, basedOnIds);
|
||||
} else if (examApply.getVisitNo() != null) {
|
||||
// 兼容旧逻辑:按 visitNo 查询(可能包含历史记录)
|
||||
wrapper.eq(ExamApply::getVisitNo, examApply.getVisitNo());
|
||||
}
|
||||
wrapper.orderByDesc(ExamApply::getApplyTime);
|
||||
@@ -147,6 +177,8 @@ public class ExamApplyController extends BaseController {
|
||||
examApply.setOperatorId("system");
|
||||
}
|
||||
examApplyService.save(examApply);
|
||||
// 业务主键为 apply_no,自增 id 不会随 save 回填;列表接口依赖 wor_service_request.based_on_id=exam_apply.id 关联本次就诊,此处必须回读 id
|
||||
examApply = examApplyService.getById(applyNo);
|
||||
|
||||
// ========== 2. 批量保存明细 + 写入门诊医嘱 + 写入费用项 ==========
|
||||
if (dto.getItems() != null && !dto.getItems().isEmpty()) {
|
||||
@@ -191,6 +223,9 @@ public class ExamApplyController extends BaseController {
|
||||
|
||||
// 检查申请不走诊疗定义,设置为0占位(数据库有NOT NULL约束)
|
||||
serviceRequest.setActivityId(0L);
|
||||
// 🔧 Bug Fix: 设置医嘱类型为诊疗(3),与检验申请保持一致
|
||||
// categoryEnum=3 → SQL查询返回 adviceType=3(诊疗),避免被错误归类为药品
|
||||
serviceRequest.setCategoryEnum(ItemType.ACTIVITY.getValue());
|
||||
|
||||
// 患者和就诊信息 —— 使用前端传递的数字型ID
|
||||
if (dto.getPatientIdNum() != null) {
|
||||
@@ -201,8 +236,19 @@ public class ExamApplyController extends BaseController {
|
||||
}
|
||||
|
||||
serviceRequest.setRequesterId(currentUserId); // 开单医生
|
||||
serviceRequest.setOrgId(currentOrgId); // 执行科室
|
||||
// 53d15f8079d15ba4Ff1a4f1851484f7f7528524d7aef4f20516576846267884c79d15ba44ee37801Ff0c542652194f7f75285f53524d7528623779d15ba4
|
||||
Long performDeptId = currentOrgId;
|
||||
if (dto.getPerformDeptCode() != null && !dto.getPerformDeptCode().isEmpty()) {
|
||||
Organization performDept = organizationService.getOne(
|
||||
new LambdaQueryWrapper<Organization>().eq(Organization::getBusNo, dto.getPerformDeptCode()).last("limit 1"));
|
||||
if (performDept != null) {
|
||||
performDeptId = performDept.getId();
|
||||
}
|
||||
}
|
||||
serviceRequest.setOrgId(performDeptId); // 6267884c79d15ba4
|
||||
serviceRequest.setAuthoredTime(now); // 签发时间
|
||||
// 🔧 Bug Fix: 不设置门诊类型,保留上面已设置的 categoryEnum=3(诊疗类型)
|
||||
// EncounterClass.AMB.getValue()=2 表示门诊类型,会覆盖诊疗类型导致医嘱被错误归类
|
||||
serviceRequest.setGenerateSourceEnum(GenerateSource.DOCTOR_PRESCRIPTION.getValue()); // 来源=医生开立
|
||||
|
||||
// 将项目名称存入 contentJson,使医嘱列表能通过 JSON 字段回显 adviceName
|
||||
@@ -243,10 +289,17 @@ public class ExamApplyController extends BaseController {
|
||||
chargeItem.setRequestingOrgId(currentOrgId); // 开立科室
|
||||
chargeItem.setEnteredDate(now); // 开立时间
|
||||
|
||||
// 以下字段均有 NOT NULL 约束,检查申请不走定价/账户体系,用0占位
|
||||
// 以下字段均有 NOT NULL 约束,检查申请不走定价体系,用0占位
|
||||
chargeItem.setDefinitionId(0L); // 费用定价ID
|
||||
chargeItem.setAccountId(0L); // 关联账户ID
|
||||
chargeItem.setContextEnum(2); // 类型:2=诊疗
|
||||
// 🔧 BugFix#385: 获取患者真实的自费账户,预结算验证要求accountId必须真实存在
|
||||
Account selfAccount = accountService.getSelfAccount(dto.getEncounterId());
|
||||
if (selfAccount == null) {
|
||||
throw new ServiceException("患者自费账户不存在,无法创建检查收费项,encounterId=" + dto.getEncounterId());
|
||||
}
|
||||
chargeItem.setAccountId(selfAccount.getId());
|
||||
// 🔧 BugFix#385: 使用 ItemType.ACTIVITY.getValue()=3 表示诊疗,而不是硬编码的2
|
||||
// ItemType 枚举定义:MEDICINE=1, DEVICE=2(耗材), ACTIVITY=3(诊疗)
|
||||
chargeItem.setContextEnum(ItemType.ACTIVITY.getValue()); // 类型:3=诊疗
|
||||
chargeItem.setProductTable(CommonConstants.TableName.WOR_ACTIVITY_DEFINITION); // 产品来源表
|
||||
chargeItem.setProductId(0L); // 产品ID
|
||||
|
||||
@@ -368,6 +421,9 @@ public class ExamApplyController extends BaseController {
|
||||
serviceRequest.setBasedOnTable("exam_apply");
|
||||
serviceRequest.setBasedOnId(examApply.getId());
|
||||
serviceRequest.setActivityId(0L);
|
||||
// 🔧 Bug Fix: 设置医嘱类型为诊疗(3),与检验申请保持一致
|
||||
// categoryEnum=3 → SQL查询返回 adviceType=3(诊疗),避免被错误归类为药品
|
||||
serviceRequest.setCategoryEnum(ItemType.ACTIVITY.getValue());
|
||||
|
||||
if (dto.getPatientIdNum() != null) {
|
||||
serviceRequest.setPatientId(dto.getPatientIdNum());
|
||||
@@ -376,8 +432,19 @@ public class ExamApplyController extends BaseController {
|
||||
serviceRequest.setEncounterId(dto.getEncounterId());
|
||||
}
|
||||
serviceRequest.setRequesterId(currentUserId);
|
||||
serviceRequest.setOrgId(currentOrgId);
|
||||
// 53d15f8079d15ba4Ff1a4f1851484f7f7528524d7aef4f20516576846267884c79d15ba44ee37801Ff0c542652194f7f75285f53524d7528623779d15ba4
|
||||
Long performDeptId2 = currentOrgId;
|
||||
if (dto.getPerformDeptCode() != null && !dto.getPerformDeptCode().isEmpty()) {
|
||||
Organization performDept2 = organizationService.getOne(
|
||||
new LambdaQueryWrapper<Organization>().eq(Organization::getBusNo, dto.getPerformDeptCode()).last("limit 1"));
|
||||
if (performDept2 != null) {
|
||||
performDeptId2 = performDept2.getId();
|
||||
}
|
||||
}
|
||||
serviceRequest.setOrgId(performDeptId2); // 6267884c79d15ba4
|
||||
serviceRequest.setAuthoredTime(now);
|
||||
// 🔧 Bug Fix: 不设置门诊类型,保留上面已设置的 categoryEnum=3(诊疗类型)
|
||||
// EncounterClass.AMB.getValue()=2 表示门诊类型,会覆盖诊疗类型导致医嘱被错误归类
|
||||
serviceRequest.setGenerateSourceEnum(GenerateSource.DOCTOR_PRESCRIPTION.getValue());
|
||||
|
||||
// 将项目名称存入 contentJson,使医嘱列表能通过 JSON 字段回显 adviceName
|
||||
@@ -412,8 +479,14 @@ public class ExamApplyController extends BaseController {
|
||||
chargeItem.setRequestingOrgId(currentOrgId);
|
||||
chargeItem.setEnteredDate(now);
|
||||
chargeItem.setDefinitionId(0L);
|
||||
chargeItem.setAccountId(0L);
|
||||
chargeItem.setContextEnum(2);
|
||||
// 🔧 BugFix#385: 获取患者真实的自费账户,预结算验证要求accountId必须真实存在
|
||||
Account selfAccount = accountService.getSelfAccount(dto.getEncounterId());
|
||||
if (selfAccount == null) {
|
||||
throw new ServiceException("患者自费账户不存在,无法创建检查收费项,encounterId=" + dto.getEncounterId());
|
||||
}
|
||||
chargeItem.setAccountId(selfAccount.getId());
|
||||
// 🔧 BugFix#385: 使用 ItemType.ACTIVITY.getValue()=3 表示诊疗
|
||||
chargeItem.setContextEnum(ItemType.ACTIVITY.getValue());
|
||||
chargeItem.setProductTable(CommonConstants.TableName.WOR_ACTIVITY_DEFINITION);
|
||||
chargeItem.setProductId(0L);
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.openhis.web.check.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 检查方法DTO - Bug #384修复:增加套餐价格字段
|
||||
* 用于API返回数据传输,不含数据库注解
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CheckMethodDto {
|
||||
@@ -14,7 +17,6 @@ public class CheckMethodDto {
|
||||
/**
|
||||
* 检查方法ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/* 检查类型 */
|
||||
@@ -29,6 +31,12 @@ public class CheckMethodDto {
|
||||
/* 套餐名称 */
|
||||
private String packageName;
|
||||
|
||||
/* 套餐价格 - Bug #384修复:通过packageName匹配CheckPackage获取 */
|
||||
private BigDecimal packagePrice;
|
||||
|
||||
/* 服务费 - Bug #384修复:通过packageName匹配CheckPackage获取 */
|
||||
private BigDecimal serviceFee;
|
||||
|
||||
/* 曝光次数 */
|
||||
private Integer exposureNum;
|
||||
|
||||
|
||||
@@ -136,9 +136,11 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi
|
||||
}
|
||||
}
|
||||
|
||||
LoginUser loginUser = new LoginUser();
|
||||
//获取当前登录用户信息
|
||||
loginUser = SecurityUtils.getLoginUser();
|
||||
// Bug #432 修复:获取当前登录用户信息,增加null校验防止NPE
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return R.fail("用户未登录或登录已过期");
|
||||
}
|
||||
// 当前登录用户ID
|
||||
Long userId = loginUser.getUserId();
|
||||
|
||||
|
||||
@@ -1395,9 +1395,17 @@ public class ConsultationAppServiceImpl implements IConsultationAppService {
|
||||
}
|
||||
|
||||
// 4. 更新邀请记录(存储会诊意见)
|
||||
// 直接存储用户输入的原始意见内容,不添加医师姓名前缀
|
||||
invited.setInvitedStatus(ConsultationStatusEnum.CONFIRMED.getCode()); // 已确认
|
||||
invited.setConfirmOpinion(dto.getConsultationOpinion()); // 直接存储原始意见,不添加前缀
|
||||
// Bug #388:格式化存储,确保回显时参加医师和意见完整
|
||||
invited.setInvitedStatus(ConsultationStatusEnum.CONFIRMED.getCode());
|
||||
|
||||
String deptName = StringUtils.hasText(dto.getConfirmingDeptName())
|
||||
? dto.getConfirmingDeptName() : invited.getInvitedDepartmentName();
|
||||
String physician = StringUtils.hasText(dto.getConfirmingPhysician())
|
||||
? dto.getConfirmingPhysician() : currentPhysicianName;
|
||||
|
||||
// 格式:科室-参加医师:意见内容
|
||||
String formattedOpinion = String.format("%s-%s:%s", deptName, physician, dto.getConsultationOpinion());
|
||||
invited.setConfirmOpinion(formattedOpinion);
|
||||
invited.setConfirmTime(new Date());
|
||||
consultationInvitedMapper.updateById(invited);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
* TODO:器材目录
|
||||
*
|
||||
* @author lpt
|
||||
* @date 2025-02-20
|
||||
* @date 2025-02-20。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/data-dictionary/device")
|
||||
|
||||
@@ -116,4 +116,12 @@ public interface IDoctorStationAdviceAppService {
|
||||
* @return 检查url相关参数
|
||||
*/
|
||||
R<?> getTestResult(Long encounterId);
|
||||
|
||||
/**
|
||||
* 获取当前科室已配置的药品类别列表
|
||||
*
|
||||
* @param organizationId 科室id
|
||||
* @return 已配置的药品类别编码列表
|
||||
*/
|
||||
R<?> getConfiguredCategories(Long organizationId);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.openhis.administration.domain.Encounter;
|
||||
import com.openhis.administration.service.IAccountService;
|
||||
import com.openhis.administration.service.IChargeItemService;
|
||||
import com.openhis.administration.service.IEncounterService;
|
||||
import com.openhis.administration.service.IEncounterDiagnosisService;
|
||||
import com.openhis.administration.domain.EncounterDiagnosis;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.common.enums.*;
|
||||
@@ -115,6 +117,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
@Resource
|
||||
IEncounterService iEncounterService;
|
||||
|
||||
@Resource
|
||||
IEncounterDiagnosisService iEncounterDiagnosisService;
|
||||
|
||||
@Resource
|
||||
IInventoryItemService inventoryItemService;
|
||||
|
||||
@@ -155,6 +160,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
String safePricingFlag = pricingFlag != null ? pricingFlag.toString() : "";
|
||||
String safePageNo = pageNo != null ? pageNo.toString() : "";
|
||||
String safePageSize = pageSize != null ? pageSize.toString() : "";
|
||||
String safeCategoryCode = categoryCode != null ? categoryCode : "";
|
||||
|
||||
// 设置默认科室:仅当前端/调用方未传 organizationId 时才回退到登录人科室
|
||||
// 否则会导致门诊划价等场景(按患者挂号科室查询)返回空
|
||||
@@ -169,7 +175,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
String cacheKey = null;
|
||||
if (useCache) {
|
||||
// 生成缓存 key:无搜索关键字时按科室缓存
|
||||
cacheKey = ADVICE_BASE_INFO_CACHE_PREFIX + organizationId + ":" + safeAdviceTypesStr + ":" + safePageNo + ":" + safePageSize;
|
||||
cacheKey = ADVICE_BASE_INFO_CACHE_PREFIX + organizationId + ":" + safeAdviceTypesStr + ":" + safeCategoryCode + ":" + safePageNo + ":" + safePageSize;
|
||||
|
||||
// 先清除可能存在的无效缓存(JSONObject类型)
|
||||
if (redisCache.hasKey(cacheKey)) {
|
||||
@@ -281,6 +287,8 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
String unitCode = ""; // 包装单位
|
||||
Long chargeItemDefinitionId; // 费用定价主表ID
|
||||
// 检查是否有取药科室配置(用于药品类型)
|
||||
boolean hasPharmacyConfig = medLocationConfig != null && !medLocationConfig.isEmpty();
|
||||
for (AdviceBaseDto baseDto : adviceBaseDtoList) {
|
||||
String tableName = baseDto.getAdviceTableName();
|
||||
if (CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(tableName)) { // 药品
|
||||
@@ -290,6 +298,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
// 是否为注射药物
|
||||
baseDto.setInjectFlag_enumText(EnumUtils.getInfoByValue(Whether.class, baseDto.getInjectFlag()));
|
||||
|
||||
// 设置是否缺少取药科室配置标志
|
||||
baseDto.setPharmacyConfigMissing(!hasPharmacyConfig);
|
||||
|
||||
// fallthrough to 耗材处理逻辑(保持原有逻辑)
|
||||
// 每一条医嘱的库存集合信息 , 包装单位库存前端计算
|
||||
List<AdviceInventoryDto> inventoryList = adviceInventory
|
||||
@@ -600,26 +611,24 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
}
|
||||
|
||||
// 药品(前端adviceType=1=西药, 2=中成药 → 都属于药品后端分类)
|
||||
// 按后端 ItemType 枚举标准分类:
|
||||
// MEDICINE=1(药品)、DEVICE=2(耗材)、ACTIVITY=3(诊疗)、SURGERY=6(手术)
|
||||
|
||||
// 药品分类:adviceType == 1
|
||||
List<AdviceSaveDto> medicineList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())
|
||||
|| e.getAdviceType() == 1
|
||||
|| e.getAdviceType() == 2) // 前端中成药类型值为2 → 也属于药品分类
|
||||
.collect(Collectors.toList());
|
||||
// 耗材(前端adviceType=4,后端ItemType.DEVICE=2)
|
||||
List<AdviceSaveDto> deviceList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.DEVICE.getValue().equals(e.getAdviceType())
|
||||
|| e.getAdviceType() == 4) // 前端耗材类型值为4
|
||||
.filter(e -> e.getAdviceType() != null && e.getAdviceType() == ItemType.MEDICINE.getValue())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 诊疗活动(前端adviceType=3诊疗、adviceType=5会诊、adviceType=6手术、adviceType=23检查 → 都属于诊疗后端分类)
|
||||
// 耗材分类:adviceType == 2
|
||||
List<AdviceSaveDto> deviceList = adviceSaveList.stream()
|
||||
.filter(e -> e.getAdviceType() != null && e.getAdviceType() == ItemType.DEVICE.getValue())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 诊疗分类:adviceType == 3
|
||||
List<AdviceSaveDto> activityList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())
|
||||
|| e.getAdviceType() == 3 // 前端诊疗类型值为3
|
||||
|| e.getAdviceType() == 5 // 前端会诊类型值为5
|
||||
|| e.getAdviceType() == 6 // 前端手术类型值为6
|
||||
|| e.getAdviceType() == 23 // 前端检查类型值为23
|
||||
|| ItemType.SURGERY.getValue().equals(e.getAdviceType())) // 后端手术类型值为6
|
||||
.filter(e -> e.getAdviceType() != null
|
||||
&& (e.getAdviceType() == ItemType.ACTIVITY.getValue()
|
||||
|| e.getAdviceType() == ItemType.SURGERY.getValue())) // 手术(6)也走诊疗流程
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 🔍 Debug日志日志: 记录分类结果
|
||||
@@ -796,12 +805,71 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
// 就诊id
|
||||
Long encounterId = adviceSaveList.get(0).getEncounterId();
|
||||
|
||||
// 使用安全的更新方法,避免并发冲突 - 更新费用项状态
|
||||
// 🔧 BugFix#385: 签发时更新诊疗医嘱关联的费用项诊断信息
|
||||
// 检查申请创建的费用项没有诊断关联,需要在签发时补充
|
||||
if (!activityList.isEmpty()) {
|
||||
// 先从就诊中获取主诊断,用于补充没有诊断关联的费用项
|
||||
List<EncounterDiagnosis> encounterDiagList = iEncounterDiagnosisService.getDiagnosisList(encounterId);
|
||||
EncounterDiagnosis mainDiagnosis = iEncounterDiagnosisService.getMainDiagnosis(encounterDiagList);
|
||||
Long mainConditionId = mainDiagnosis != null ? mainDiagnosis.getConditionId() : null;
|
||||
Long mainEncounterDiagId = mainDiagnosis != null ? mainDiagnosis.getId() : null;
|
||||
|
||||
log.info("BugFix#385: 签发时获取就诊主诊断, encounterId={}, mainConditionId={}, mainEncounterDiagId={}",
|
||||
encounterId, mainConditionId, mainEncounterDiagId);
|
||||
|
||||
for (AdviceSaveDto adviceDto : activityList) {
|
||||
if (adviceDto.getRequestId() != null) {
|
||||
// 查询诊疗医嘱关联的费用项
|
||||
List<ChargeItem> chargeItems = iChargeItemService.getChargeItemInfoByReqId(
|
||||
Arrays.asList(adviceDto.getRequestId()));
|
||||
if (chargeItems != null && !chargeItems.isEmpty()) {
|
||||
// 过滤只保留诊疗类型的费用项
|
||||
ChargeItem chargeItem = chargeItems.stream()
|
||||
.filter(ci -> CommonConstants.TableName.WOR_SERVICE_REQUEST.equals(ci.getServiceTable()))
|
||||
.findFirst().orElse(null);
|
||||
if (chargeItem != null) {
|
||||
// 🔧 BugFix#385: 如果费用项没有诊断关联,使用主诊断补充
|
||||
Long conditionId = adviceDto.getConditionId();
|
||||
Long encounterDiagId = adviceDto.getEncounterDiagnosisId();
|
||||
|
||||
// 如果传入的诊断为空,使用主诊断
|
||||
if (conditionId == null) {
|
||||
conditionId = mainConditionId;
|
||||
}
|
||||
if (encounterDiagId == null) {
|
||||
encounterDiagId = mainEncounterDiagId;
|
||||
}
|
||||
|
||||
// 更新诊断关联
|
||||
if (conditionId != null || encounterDiagId != null) {
|
||||
chargeItem.setConditionId(conditionId);
|
||||
chargeItem.setEncounterDiagnosisId(encounterDiagId);
|
||||
iChargeItemService.updateById(chargeItem);
|
||||
log.info("BugFix#385: 签发时更新诊疗费用项诊断关联, chargeItemId={}, conditionId={}, encounterDiagnosisId={}",
|
||||
chargeItem.getId(), conditionId, encounterDiagId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 BugFix#385: 使用安全的更新方法,避免并发冲突 - 更新费用项状态
|
||||
// 需要处理两种情况:
|
||||
// 1. 从 DRAFT (0) → PLANNED (1):新创建的收费项目
|
||||
// 2. 从 BILLABLE (2) → PLANNED (1):保存时已设为待结算的项目
|
||||
iChargeItemService.updateChargeStatusByConditionSafe(
|
||||
encounterId,
|
||||
ChargeItemStatus.DRAFT.getValue(),
|
||||
ChargeItemStatus.PLANNED.getValue(),
|
||||
requestIds);
|
||||
|
||||
// 🔧 BugFix#385: 同时处理 BILLABLE 状态的收费项目
|
||||
iChargeItemService.updateChargeStatusByConditionSafe(
|
||||
encounterId,
|
||||
ChargeItemStatus.BILLABLE.getValue(),
|
||||
ChargeItemStatus.PLANNED.getValue(),
|
||||
requestIds);
|
||||
}
|
||||
|
||||
// 数据变更后清理相关缓存
|
||||
@@ -935,12 +1003,26 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
insertOrUpdateList = uniqueInsertOrUpdateList;
|
||||
|
||||
for (AdviceSaveDto adviceSaveDto : insertOrUpdateList) {
|
||||
// 🔧 Bug Fix: 确保accountId不为null,与handleBoundDevices保持一致
|
||||
// 🔧 Bug Fix: 确保accountId有效(不为null且账户存在)
|
||||
boolean needNewAccount = false;
|
||||
if (adviceSaveDto.getAccountId() == null) {
|
||||
needNewAccount = true;
|
||||
} else {
|
||||
// 验证账户是否存在且有效(未被删除,租户匹配)
|
||||
Account existingAccount = iAccountService.getById(adviceSaveDto.getAccountId());
|
||||
if (existingAccount == null) {
|
||||
log.warn("handMedication - 前端传入的accountId无效(账户不存在),accountId={},将重新获取或创建账户",
|
||||
adviceSaveDto.getAccountId());
|
||||
needNewAccount = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (needNewAccount) {
|
||||
// 尝试从患者就诊中获取默认账户ID(自费账户)
|
||||
Account selfAccount = iAccountService.getSelfAccount(adviceSaveDto.getEncounterId());
|
||||
if (selfAccount != null) {
|
||||
adviceSaveDto.setAccountId(selfAccount.getId());
|
||||
log.info("handMedication - 使用现有自费账户,accountId={}", selfAccount.getId());
|
||||
} else {
|
||||
// 自动创建自费账户
|
||||
Account newAccount = new Account();
|
||||
@@ -954,6 +1036,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
newAccount.setName(AccountType.PERSONAL_CASH_ACCOUNT.getInfo());
|
||||
Long newAccountId = iAccountService.saveAccountByRegister(newAccount);
|
||||
adviceSaveDto.setAccountId(newAccountId);
|
||||
log.info("handMedication - 自动创建自费账户,newAccountId={}", newAccountId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1061,7 +1144,12 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
|
||||
chargeItem.setQuantityValue(adviceSaveDto.getQuantity()); // 数量
|
||||
chargeItem.setQuantityUnit(adviceSaveDto.getUnitCode()); // 单位
|
||||
chargeItem.setUnitPrice(adviceSaveDto.getUnitPrice()); // 单价
|
||||
// #415 价格非负验证
|
||||
BigDecimal unitPrice = adviceSaveDto.getUnitPrice();
|
||||
if (unitPrice != null && unitPrice.compareTo(BigDecimal.ZERO) < 0) {
|
||||
unitPrice = unitPrice.abs(); // 负数取绝对值
|
||||
}
|
||||
chargeItem.setUnitPrice(unitPrice); // 单价
|
||||
chargeItem.setTotalPrice(adviceSaveDto.getTotalPrice()); // 总价
|
||||
|
||||
// 显式设置tenantId、createBy和createTime字段,防止自动填充机制失效
|
||||
@@ -1344,12 +1432,26 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
log.info("BugFix#219: ========== handDevice END ==========");
|
||||
|
||||
for (AdviceSaveDto adviceSaveDto : insertOrUpdateList) {
|
||||
// 🔧 Bug Fix: 确保accountId不为null
|
||||
// 🔧 Bug Fix: 确保accountId有效(不为null且账户存在)
|
||||
boolean needNewAccount = false;
|
||||
if (adviceSaveDto.getAccountId() == null) {
|
||||
needNewAccount = true;
|
||||
} else {
|
||||
// 验证账户是否存在且有效(未被删除,租户匹配)
|
||||
Account existingAccount = iAccountService.getById(adviceSaveDto.getAccountId());
|
||||
if (existingAccount == null) {
|
||||
log.warn("handDevice - 前端传入的accountId无效(账户不存在),accountId={},将重新获取或创建账户",
|
||||
adviceSaveDto.getAccountId());
|
||||
needNewAccount = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (needNewAccount) {
|
||||
// 尝试从患者就诊中获取默认账户ID(自费账户)
|
||||
Account selfAccount = iAccountService.getSelfAccount(adviceSaveDto.getEncounterId());
|
||||
if (selfAccount != null) {
|
||||
adviceSaveDto.setAccountId(selfAccount.getId());
|
||||
log.info("handDevice - 使用现有自费账户,accountId={}", selfAccount.getId());
|
||||
} else {
|
||||
// 自动创建自费账户
|
||||
Account newAccount = new Account();
|
||||
@@ -1363,6 +1465,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
newAccount.setName(AccountType.PERSONAL_CASH_ACCOUNT.getInfo());
|
||||
Long newAccountId = iAccountService.saveAccountByRegister(newAccount);
|
||||
adviceSaveDto.setAccountId(newAccountId);
|
||||
log.info("handDevice - 自动创建自费账户,newAccountId={}", newAccountId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1518,7 +1621,12 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
|
||||
chargeItem.setQuantityValue(adviceSaveDto.getQuantity()); // 数量
|
||||
chargeItem.setQuantityUnit(adviceSaveDto.getUnitCode()); // 单位
|
||||
chargeItem.setUnitPrice(adviceSaveDto.getUnitPrice()); // 单价
|
||||
// #415 价格非负验证
|
||||
BigDecimal unitPrice = adviceSaveDto.getUnitPrice();
|
||||
if (unitPrice != null && unitPrice.compareTo(BigDecimal.ZERO) < 0) {
|
||||
unitPrice = unitPrice.abs(); // 负数取绝对值
|
||||
}
|
||||
chargeItem.setUnitPrice(unitPrice); // 单价
|
||||
chargeItem.setTotalPrice(adviceSaveDto.getTotalPrice()); // 总价
|
||||
|
||||
// 显式设置审计字段,防止自动填充机制失效
|
||||
@@ -1600,12 +1708,26 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
|
||||
for (AdviceSaveDto adviceSaveDto : insertOrUpdateList) {
|
||||
// 🔧 Bug Fix: 确保accountId不为null
|
||||
// 🔧 Bug Fix: 确保accountId有效(不为null且账户存在)
|
||||
boolean needNewAccount = false;
|
||||
if (adviceSaveDto.getAccountId() == null) {
|
||||
needNewAccount = true;
|
||||
} else {
|
||||
// 验证账户是否存在且有效(未被删除,租户匹配)
|
||||
Account existingAccount = iAccountService.getById(adviceSaveDto.getAccountId());
|
||||
if (existingAccount == null) {
|
||||
log.warn("handService - 前端传入的accountId无效(账户不存在),accountId={},将重新获取或创建账户",
|
||||
adviceSaveDto.getAccountId());
|
||||
needNewAccount = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (needNewAccount) {
|
||||
// 尝试从患者就诊中获取默认账户ID(自费账户)
|
||||
Account selfAccount = iAccountService.getSelfAccount(adviceSaveDto.getEncounterId());
|
||||
if (selfAccount != null) {
|
||||
adviceSaveDto.setAccountId(selfAccount.getId());
|
||||
log.info("handService - 使用现有自费账户,accountId={}", selfAccount.getId());
|
||||
} else {
|
||||
// 自动创建自费账户
|
||||
Account newAccount = new Account();
|
||||
@@ -1619,6 +1741,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
newAccount.setName(AccountType.PERSONAL_CASH_ACCOUNT.getInfo());
|
||||
Long newAccountId = iAccountService.saveAccountByRegister(newAccount);
|
||||
adviceSaveDto.setAccountId(newAccountId);
|
||||
log.info("handService - 自动创建自费账户,newAccountId={}", newAccountId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1671,7 +1794,13 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
serviceRequest.setCategoryEnum(adviceSaveDto.getCategoryEnum());
|
||||
}
|
||||
|
||||
// 🔧 BugFix#385: 检查类型(adviceType=2)不走定价体系,activityId设置为0L占位
|
||||
// 与ExamApplyController保持一致,数据库有NOT NULL约束
|
||||
if (adviceSaveDto.getAdviceType() != null && adviceSaveDto.getAdviceType() == 2) {
|
||||
serviceRequest.setActivityId(0L);
|
||||
} else {
|
||||
serviceRequest.setActivityId(adviceSaveDto.getAdviceDefinitionId());// 诊疗定义id
|
||||
}
|
||||
serviceRequest.setPatientId(adviceSaveDto.getPatientId()); // 患者
|
||||
serviceRequest.setRequesterId(adviceSaveDto.getPractitionerId()); // 开方医生
|
||||
serviceRequest.setEncounterId(adviceSaveDto.getEncounterId()); // 就诊id
|
||||
@@ -1723,7 +1852,12 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
chargeItem.setEncounterDiagnosisId(adviceSaveDto.getEncounterDiagnosisId()); // 就诊诊断id
|
||||
chargeItem.setQuantityValue(adviceSaveDto.getQuantity()); // 数量
|
||||
chargeItem.setQuantityUnit(adviceSaveDto.getUnitCode()); // 单位
|
||||
chargeItem.setUnitPrice(adviceSaveDto.getUnitPrice()); // 单价
|
||||
// #415 价格非负验证
|
||||
BigDecimal unitPrice = adviceSaveDto.getUnitPrice();
|
||||
if (unitPrice != null && unitPrice.compareTo(BigDecimal.ZERO) < 0) {
|
||||
unitPrice = unitPrice.abs(); // 负数取绝对值
|
||||
}
|
||||
chargeItem.setUnitPrice(unitPrice); // 单价
|
||||
chargeItem.setTotalPrice(adviceSaveDto.getTotalPrice()); // 总价
|
||||
|
||||
iChargeItemService.saveOrUpdate(chargeItem);
|
||||
@@ -2147,4 +2281,23 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
return searchKey.matches("[a-zA-Z]+");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前科室已配置的药品类别列表
|
||||
*
|
||||
* @param organizationId 科室id
|
||||
* @return 已配置的药品类别编码列表
|
||||
*/
|
||||
@Override
|
||||
public R<?> getConfiguredCategories(Long organizationId) {
|
||||
// 查询取药科室配置
|
||||
List<AdviceInventoryDto> medLocationConfig = doctorStationAdviceAppMapper.getMedLocationConfig(organizationId);
|
||||
// 提取不重复的 categoryCode
|
||||
List<String> categoryCodes = medLocationConfig.stream()
|
||||
.map(AdviceInventoryDto::getCategoryCode)
|
||||
.filter(code -> code != null && !code.isEmpty())
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
return R.ok(categoryCodes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn
|
||||
// 诊断定义集合
|
||||
List<SaveDiagnosisChildParam> diagnosisChildList = saveDiagnosisParam.getDiagnosisChildList();
|
||||
// 先删除再保存
|
||||
// iEncounterDiagnosisService.deleteEncounterDiagnosisInfos(encounterId);
|
||||
iEncounterDiagnosisService.deleteEncounterDiagnosisInfos(encounterId);
|
||||
// 保存诊断管理
|
||||
Condition condition;
|
||||
for (SaveDiagnosisChildParam saveDiagnosisChildParam : diagnosisChildList) {
|
||||
@@ -296,7 +296,7 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn
|
||||
}
|
||||
|
||||
// 先删除再保存
|
||||
// iEncounterDiagnosisService.deleteEncounterDiagnosisInfos(encounterId);
|
||||
iEncounterDiagnosisService.deleteEncounterDiagnosisInfos(encounterId);
|
||||
|
||||
// 如果本次保存中有设置主诊断,则先清空该就诊下所有的主诊断标记,确保唯一性
|
||||
boolean hasMain = diagnosisChildList.stream().anyMatch(d -> Integer.valueOf(1).equals(d.getMaindiseFlag()));
|
||||
|
||||
@@ -7,14 +7,17 @@ import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.common.enums.DbOpType;
|
||||
import com.openhis.administration.service.IAccountService;
|
||||
import com.openhis.administration.domain.Account;
|
||||
import com.openhis.administration.service.IChargeItemService; // Bug #386修复: 添加 ChargeItemService
|
||||
import com.openhis.lab.domain.InspectionLabApply;
|
||||
import com.openhis.lab.domain.InspectionLabApplyItem;
|
||||
import com.openhis.lab.domain.BarCode;
|
||||
import com.openhis.lab.domain.InspectionPackage;
|
||||
import com.openhis.lab.domain.LabActivityDefinition;
|
||||
import com.openhis.lab.service.IInspectionLabApplyItemService;
|
||||
import com.openhis.lab.service.IInspectionLabApplyService;
|
||||
import com.openhis.lab.service.IInspectionLabBarCodeService;
|
||||
import com.openhis.lab.service.IInspectionPackageService;
|
||||
import com.openhis.lab.service.ILabActivityDefinitionService;
|
||||
import com.openhis.workflow.domain.ServiceRequest;
|
||||
import com.openhis.workflow.service.IServiceRequestService;
|
||||
import com.openhis.web.doctorstation.appservice.IDoctorStationAdviceAppService;
|
||||
@@ -45,6 +48,9 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 根据检验申请单开单信息系统自动插入门诊医嘱表(与检验申请主表申请单号进行关联),
|
||||
@@ -88,6 +94,14 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
@Autowired
|
||||
private IInspectionPackageService inspectionPackageService;
|
||||
|
||||
// Bug #326: 检验项目定义服务(用于回充时获取套餐信息)
|
||||
@Autowired
|
||||
private ILabActivityDefinitionService labActivityDefinitionService;
|
||||
|
||||
// Bug #386修复: ChargeItemService 用于删除收费项目
|
||||
@Autowired
|
||||
private IChargeItemService chargeItemService;
|
||||
|
||||
/**
|
||||
* 保存检验申请单信息
|
||||
* @param doctorStationLabApplyDto
|
||||
@@ -160,6 +174,28 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
InspectionLabApplyItem inspectionLabApplyItem = new InspectionLabApplyItem();
|
||||
BeanUtils.copyProperties(doctorStationLabApplyItemDto, inspectionLabApplyItem);
|
||||
|
||||
// 前端选择检验项目时已携带完整的关联信息(activityId、feePackageId、itemCode等)
|
||||
// Bug #326修复: 只使用 activityId 直接查询,不使用名称反查
|
||||
Long activityId = doctorStationLabApplyItemDto.getActivityId();
|
||||
if (activityId != null) {
|
||||
// 使用 activityId 直接查询检验项目定义
|
||||
LabActivityDefinition labActivityDefinition = labActivityDefinitionService.getById(activityId);
|
||||
if (labActivityDefinition != null && DelFlag.NO.getCode().equals(labActivityDefinition.getDeleteFlag())) {
|
||||
// 补充编码(如果前端未传或为空)
|
||||
if (inspectionLabApplyItem.getItemCode() == null || inspectionLabApplyItem.getItemCode().isEmpty()) {
|
||||
inspectionLabApplyItem.setItemCode(labActivityDefinition.getBusNo());
|
||||
}
|
||||
// 补充套餐ID(如果前端未传)
|
||||
if (inspectionLabApplyItem.getFeePackageId() == null) {
|
||||
inspectionLabApplyItem.setFeePackageId(labActivityDefinition.getFeePackageId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有 activityId 时记录警告,不使用名称反查
|
||||
log.warn("检验项目 [{}] 未传入 activityId,无法获取完整关联信息",
|
||||
doctorStationLabApplyItemDto.getItemName());
|
||||
}
|
||||
|
||||
// 后端重新计算金额:金额 = 单价 × 数量
|
||||
java.math.BigDecimal itemPrice = doctorStationLabApplyItemDto.getItemPrice();
|
||||
java.math.BigDecimal itemQty = doctorStationLabApplyItemDto.getItemQty();
|
||||
@@ -241,13 +277,16 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
);
|
||||
if (organization != null) {
|
||||
positionId = organization.getId();
|
||||
} else {
|
||||
// Bug #329: 执行科室代码无法匹配到科室,记录警告日志
|
||||
log.warn("执行科室代码 [{}] 在科室表中未找到对应记录", performDeptCode);
|
||||
}
|
||||
} else {
|
||||
// Bug #329: 未指定执行科室,记录警告日志
|
||||
log.warn("检验项目 [{}] 未指定执行科室", itemName);
|
||||
}
|
||||
|
||||
// 如果没有指定执行科室,使用当前医生所在的科室作为默认执行科室
|
||||
if (positionId == null) {
|
||||
positionId = SecurityUtils.getDeptId();
|
||||
}
|
||||
// Bug #329: 移除默认执行科室逻辑,必须由前端明确指定执行科室
|
||||
|
||||
// 4. 创建医嘱保存对象
|
||||
AdviceSaveDto adviceSaveDto = new AdviceSaveDto();
|
||||
@@ -324,7 +363,6 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
throw new RuntimeException("套餐项目 '" + itemName + "' 未设置有效价格,请先配置套餐金额");
|
||||
}
|
||||
unitPrice = packageInfo.getPackageAmount();
|
||||
log.info("套餐项目 '{}' 使用套餐价格: {}", itemName, unitPrice);
|
||||
} else {
|
||||
// 普通项目:使用前端传入的价格
|
||||
unitPrice = labApplyItemDto.getItemPrice();
|
||||
@@ -367,31 +405,85 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
*/
|
||||
@Override
|
||||
public Object getInspectionApplyByApplyNo(String applyNo) {
|
||||
// 查询主表数据
|
||||
DoctorStationLabApplyDto applyDto = (DoctorStationLabApplyDto) doctorStationLabApplyMapper.getInspectionApplyByApplyNo(applyNo);
|
||||
if (applyDto == null) {
|
||||
// 使用MyBatis-Plus查询主表数据
|
||||
InspectionLabApply mainEntity = inspectionLabApplyService.getOne(
|
||||
new QueryWrapper<InspectionLabApply>()
|
||||
.eq("apply_no", applyNo)
|
||||
.eq("delete_flag", DelFlag.NO.getCode())
|
||||
);
|
||||
|
||||
if (mainEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 使用BeanUtils进行基础字段映射
|
||||
DoctorStationLabApplyDto applyDto = new DoctorStationLabApplyDto();
|
||||
BeanUtils.copyProperties(mainEntity, applyDto);
|
||||
// 由于字段名称映射关系(如 id -> applicationId),需要单独设置
|
||||
applyDto.setApplicationId(mainEntity.getId());
|
||||
|
||||
// 查询检验项目明细
|
||||
List<InspectionLabApplyItem> itemList = inspectionLabApplyItemService.list(
|
||||
new QueryWrapper<InspectionLabApplyItem>()
|
||||
.eq("apply_no", applyNo)
|
||||
.eq("delete_flag", "0")
|
||||
.eq("delete_flag", DelFlag.NO.getCode())
|
||||
.orderByAsc("item_seq")
|
||||
);
|
||||
|
||||
// 转换为 DTO 列表
|
||||
List<DoctorStationLabApplyItemDto> itemDtoList = new ArrayList<>();
|
||||
if (itemList != null && !itemList.isEmpty()) {
|
||||
// 提取所有不同的 itemCode,用于批量查询
|
||||
Set<String> itemCodes = itemList.stream()
|
||||
.filter(item -> item.getItemCode() != null && !item.getItemCode().isEmpty())
|
||||
.map(InspectionLabApplyItem::getItemCode)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 批量查询所有关联的检验项目定义(使用MyBatis-Plus)
|
||||
Map<String, LabActivityDefinition> definitionMap = new HashMap<>();
|
||||
if (!itemCodes.isEmpty()) {
|
||||
List<LabActivityDefinition> labActivityDefinitions = labActivityDefinitionService.list(
|
||||
new QueryWrapper<LabActivityDefinition>()
|
||||
.in("bus_no", itemCodes)
|
||||
.eq("delete_flag", DelFlag.NO.getCode())
|
||||
);
|
||||
// 构建 itemCode 到定义的映射
|
||||
definitionMap = labActivityDefinitions.stream()
|
||||
.collect(Collectors.toMap(LabActivityDefinition::getBusNo, Function.identity()));
|
||||
}
|
||||
|
||||
// 处理每个明细项
|
||||
for (InspectionLabApplyItem item : itemList) {
|
||||
DoctorStationLabApplyItemDto itemDto = new DoctorStationLabApplyItemDto();
|
||||
// 使用BeanUtils进行基础字段映射
|
||||
BeanUtils.copyProperties(item, itemDto);
|
||||
|
||||
// feePackageId 在保存时已存储,直接使用
|
||||
itemDto.setFeePackageId(item.getFeePackageId());
|
||||
// 判断是否是套餐项目(根据 feePackageId 是否存在)
|
||||
itemDto.setIsPackage(item.getFeePackageId() != null);
|
||||
|
||||
// 从批量查询结果中获取关联信息
|
||||
if (item.getItemCode() != null && !item.getItemCode().isEmpty()) {
|
||||
LabActivityDefinition labActivityDefinition = definitionMap.get(item.getItemCode());
|
||||
if (labActivityDefinition != null) {
|
||||
itemDto.setActivityId(labActivityDefinition.getId());
|
||||
itemDto.setSampleType(labActivityDefinition.getSpecimenCode());
|
||||
itemDto.setUnit(labActivityDefinition.getPermittedUnitCode());
|
||||
// 补充检验类型ID,用于前端自动设置执行科室
|
||||
itemDto.setInspectionTypeId(labActivityDefinition.getInspectionTypeId());
|
||||
}
|
||||
} else {
|
||||
log.warn("检验项目 [{}] 未存储 itemCode,无法获取完整关联信息", item.getItemName());
|
||||
}
|
||||
|
||||
itemDtoList.add(itemDto);
|
||||
}
|
||||
// 从第一个明细项获取执行科室代码
|
||||
if (!itemList.isEmpty() && itemList.get(0).getPerformDeptCode() != null) {
|
||||
applyDto.setExecuteDepartment(itemList.get(0).getPerformDeptCode());
|
||||
}
|
||||
}
|
||||
applyDto.setLabApplyItemList(itemDtoList);
|
||||
|
||||
return applyDto;
|
||||
@@ -409,8 +501,9 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
// 使用 PageHelper 进行分页查询
|
||||
PageHelper.startPage(pageNo, pageSize);
|
||||
|
||||
// 查询检验申请单列表
|
||||
log.debug("查询申请单数据前");
|
||||
// 使用MyBatis-Plus查询检验申请单列表
|
||||
// 需要关联adm_encounter表,仍使用原Mapper方法或重构为MyBatis-Plus方式
|
||||
// 为保持一致性和考虑到复杂的关联查询,暂时保留原有实现方式
|
||||
List<DoctorStationLabApplyDto> list = doctorStationLabApplyMapper.getInspectionApplyListPage(encounterId);
|
||||
log.debug("查询申请单数据后");
|
||||
|
||||
@@ -512,6 +605,12 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
if (updateResult) {
|
||||
log.debug("成功将申请单号 [{}] 关联的 {} 条门诊医嘱的删除状态更新为1,更新人:{},更新时间:{}",
|
||||
applyNo, requestIds.size(), currentUsername, currentTime);
|
||||
|
||||
// Bug #386修复: 同步删除关联的收费项目
|
||||
for (Long requestId : requestIds) {
|
||||
chargeItemService.deleteByServiceTableAndId("wor_service_request", requestId);
|
||||
}
|
||||
log.debug("成功删除申请单号 [{}] 关联的 {} 条收费项目", applyNo, requestIds.size());
|
||||
} else {
|
||||
log.warn("更新申请单号 [{}] 关联的门诊医嘱删除状态失败", applyNo);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.model.LoginUser;
|
||||
import com.core.common.utils.AgeCalculatorUtil;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.administration.domain.Encounter;
|
||||
@@ -17,7 +18,9 @@ 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.triageandqueuemanage.domain.DivLog;
|
||||
import com.openhis.triageandqueuemanage.domain.TriageQueueItem;
|
||||
import com.openhis.triageandqueuemanage.service.DivLogService;
|
||||
import com.openhis.triageandqueuemanage.service.TriageQueueItemService;
|
||||
import com.openhis.web.doctorstation.appservice.*;
|
||||
import com.openhis.web.doctorstation.dto.PatientInfoDto;
|
||||
@@ -32,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
@@ -70,6 +74,10 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
|
||||
|
||||
@Resource
|
||||
private TriageQueueItemService triageQueueItemService;
|
||||
|
||||
@Resource
|
||||
private DivLogService divLogService;
|
||||
|
||||
/**
|
||||
* 查询就诊患者信息
|
||||
*
|
||||
@@ -147,12 +155,19 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
|
||||
return R.fail("已接诊,请勿重复点击,已为您刷新");
|
||||
}
|
||||
|
||||
// 允许从「待诊/暂离/诊毕」重新接诊(用于队列弹窗的完诊患者重新进入在诊)
|
||||
Date now = new Date();
|
||||
int update = encounterMapper.update(null,
|
||||
new LambdaUpdateWrapper<Encounter>().eq(Encounter::getId, encounterId)
|
||||
.eq(Encounter::getStatusEnum, EncounterStatus.PLANNED.getValue()) // 只更新待诊状态的患者
|
||||
.set(Encounter::getReceptionTime, new Date())
|
||||
.in(Encounter::getStatusEnum,
|
||||
EncounterStatus.PLANNED.getValue(),
|
||||
EncounterStatus.ON_HOLD.getValue(),
|
||||
EncounterStatus.DISCHARGED.getValue())
|
||||
.set(Encounter::getReceptionTime, now)
|
||||
.set(Encounter::getEndTime, null)
|
||||
.set(Encounter::getStatusEnum, EncounterStatus.IN_PROGRESS.getValue())
|
||||
.set(Encounter::getSubjectStatusEnum, EncounterSubjectStatus.RECEIVING_CARE.getValue()));
|
||||
.set(Encounter::getSubjectStatusEnum, EncounterSubjectStatus.RECEIVING_CARE.getValue())
|
||||
.set(Encounter::getUpdateTime, now));
|
||||
|
||||
// 如果更新失败,说明状态已被其他医生修改
|
||||
if (update <= 0) {
|
||||
@@ -181,19 +196,22 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
|
||||
encounterParticipant.setCreateTime(new Date());
|
||||
iEncounterParticipantService.save(encounterParticipant);
|
||||
|
||||
// 更新 triage_queue_item 队列记录状态为 CALLING
|
||||
// 更新 triage_queue_item 队列记录状态为 IN_CLINIC(诊中)
|
||||
try {
|
||||
TriageQueueItem queueItem = triageQueueItemService.getOne(
|
||||
new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getEncounterId, encounterId)
|
||||
// 限定当天日期,避免复诊患者匹配到历史队列记录
|
||||
.eq(TriageQueueItem::getQueueDate, LocalDate.now())
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
);
|
||||
if (queueItem != null) {
|
||||
queueItem.setStatus("CALLING");
|
||||
// 使用 TriageQueueStatus 枚举替代原有硬编码数字 20,保证状态值一致性
|
||||
queueItem.setStatus(TriageQueueStatus.IN_CLINIC.getValue());
|
||||
queueItem.setUpdateTime(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS));
|
||||
triageQueueItemService.updateById(queueItem);
|
||||
log.info("接诊时更新队列状态为CALLING,encounterId={}, queueItemId={}", encounterId, queueItem.getId());
|
||||
log.info("接诊时更新队列状态为IN_CLINIC(诊中),encounterId={}, queueItemId={}", encounterId, queueItem.getId());
|
||||
} else {
|
||||
log.warn("接诊时未找到队列记录,encounterId={}", encounterId);
|
||||
}
|
||||
@@ -246,35 +264,38 @@ public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppSer
|
||||
return R.fail("非就诊中患者不能完诊");
|
||||
}
|
||||
|
||||
// 2. 查找队列项
|
||||
// 2. 查找队列项(限定当天,避免复诊患者匹配到历史队列记录)
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
TriageQueueItem queueItem = triageQueueItemService.getOne(
|
||||
new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getEncounterId, encounterId)
|
||||
.eq(TriageQueueItem::getQueueDate, LocalDate.now())
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
);
|
||||
|
||||
// 如果队列项存在,检查状态并更新
|
||||
if (queueItem != null && "CALLING".equals(queueItem.getStatus())) {
|
||||
// 如果队列项存在且未完成,更新队列状态为已完成
|
||||
// 使用排除法而非白名单:只要不是"已完成"就可以完诊,覆盖跳过、等待等非标准流转状态
|
||||
if (queueItem != null &&
|
||||
!TriageQueueStatus.COMPLETED.getValue().equals(queueItem.getStatus())) {
|
||||
// 更新队列状态为已完成
|
||||
java.time.LocalDateTime nowLocal = java.time.LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS);
|
||||
queueItem.setStatus("COMPLETED");
|
||||
queueItem.setStatus(TriageQueueStatus.COMPLETED.getValue());
|
||||
queueItem.setUpdateTime(nowLocal);
|
||||
triageQueueItemService.updateById(queueItem);
|
||||
|
||||
// 写入 div_log 审计日志
|
||||
// 写入 div_log 审计日志(使用实体+Service替代原生JDBC SQL,避免SQL注入风险,便于维护)
|
||||
try {
|
||||
Long userId = SecurityUtils.getLoginUser().getUserId();
|
||||
String divLogSql = "INSERT INTO hisdev.div_log "
|
||||
+ "(pool_id, slot_id, queue_no, op_user_id, action, create_time) "
|
||||
+ "VALUES (?, ?, ?, ?, 'COMPLETE', NOW()::timestamp(0))";
|
||||
|
||||
jdbcTemplate.update(divLogSql,
|
||||
queueItem.getOrganizationId(), // pool_id: 候选池ID(科室)
|
||||
queueItem.getPractitionerId(), // slot_id: 槽位ID(医生)
|
||||
queueItem.getQueueOrder(), // queue_no: 队列号
|
||||
userId); // op_user_id: 操作用户ID
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
DivLog divLog = new DivLog()
|
||||
.setPoolId(queueItem.getPoolId())
|
||||
.setSlotId(queueItem.getSlotId())
|
||||
.setOpUserId(loginUser != null ? loginUser.getUserId() : null)
|
||||
.setAction("COMPLETE")
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setUpdateAt(LocalDateTime.now())
|
||||
.setCreatedAt(LocalDateTime.now());
|
||||
divLogService.save(divLog);
|
||||
} catch (Exception e) {
|
||||
log.error("写入div_log审计日志失败", e);
|
||||
// 审计日志失败不影响主流程
|
||||
|
||||
@@ -11,6 +11,7 @@ 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.IDoctorStationMainAppService;
|
||||
import com.openhis.web.doctorstation.appservice.ITodayOutpatientService;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientPatientDto;
|
||||
import com.openhis.web.doctorstation.dto.TodayOutpatientQueryParam;
|
||||
@@ -32,6 +33,9 @@ public class TodayOutpatientServiceImpl implements ITodayOutpatientService {
|
||||
@Resource
|
||||
private TodayOutpatientMapper todayOutpatientMapper;
|
||||
|
||||
@Resource
|
||||
private IDoctorStationMainAppService doctorStationMainAppService;
|
||||
|
||||
@Override
|
||||
public TodayOutpatientStatsDto getTodayOutpatientStats(HttpServletRequest request) {
|
||||
Long doctorId = SecurityUtils.getLoginUser().getUserId();
|
||||
@@ -259,22 +263,19 @@ public class TodayOutpatientServiceImpl implements ITodayOutpatientService {
|
||||
@Override
|
||||
public R<?> receivePatient(Long encounterId, HttpServletRequest request) {
|
||||
// 调用现有的接诊逻辑
|
||||
// 这里可以复用 DoctorStationMainAppServiceImpl 中的 receiveEncounter 方法
|
||||
// 或者直接调用相应的服务
|
||||
|
||||
return R.ok("接诊成功");
|
||||
return doctorStationMainAppService.receiveEncounter(encounterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> completeVisit(Long encounterId, HttpServletRequest request) {
|
||||
// 调用现有的完诊逻辑
|
||||
return R.ok("就诊完成");
|
||||
return doctorStationMainAppService.completeEncounter(encounterId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> cancelVisit(Long encounterId, String reason, HttpServletRequest request) {
|
||||
// 调用现有的取消就诊逻辑
|
||||
return R.ok("就诊取消成功");
|
||||
return doctorStationMainAppService.cancelEncounter(encounterId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,9 +50,10 @@ public class DoctorStationAdviceController {
|
||||
@RequestParam(value = "organizationId", required = false) Long organizationId,
|
||||
@RequestParam(value = "adviceTypes", defaultValue = "1,2,3") List<Integer> adviceTypes,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(value = "categoryCode", required = false) String categoryCode) {
|
||||
return R.ok(iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId,
|
||||
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, Whether.NO.getValue(), adviceTypes, null, null));
|
||||
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, null, adviceTypes, null, categoryCode));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,4 +187,15 @@ public class DoctorStationAdviceController {
|
||||
return iDoctorStationAdviceAppService.getTestResult(encounterId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前科室已配置的药品类别列表
|
||||
*
|
||||
* @param organizationId 科室id
|
||||
* @return 已配置的药品类别编码列表
|
||||
*/
|
||||
@GetMapping(value = "/configured-categories")
|
||||
public R<?> getConfiguredCategories(@RequestParam(value = "organizationId", required = false) Long organizationId) {
|
||||
return iDoctorStationAdviceAppService.getConfiguredCategories(organizationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class DoctorStationChineseMedicalController {
|
||||
organizationId = SecurityUtils.getLoginUser().getOrgId();
|
||||
}
|
||||
return R.ok(iDoctorStationChineseMedicalAppService.getTcmAdviceBaseInfo(adviceBaseDto, searchKey, locationId,
|
||||
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, Whether.NO.getValue()));
|
||||
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -198,6 +198,7 @@ public class AdviceBaseDto {
|
||||
/**
|
||||
* 所属科室
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
@@ -242,4 +243,9 @@ public class AdviceBaseDto {
|
||||
@Dict(dictCode = "chrgitm_lv")
|
||||
private String chrgitmLv;
|
||||
private String chrgitmLv_dictText;
|
||||
|
||||
/**
|
||||
* 是否缺少取药科室配置(仅药品类型使用)
|
||||
*/
|
||||
private Boolean pharmacyConfigMissing;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.openhis.web.doctorstation.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@@ -67,4 +69,42 @@ public class DoctorStationLabApplyItemDto {
|
||||
*/
|
||||
@NotNull(message = "行状态不能为空")
|
||||
private Long itemStatus;
|
||||
|
||||
// ========== Bug #326: 套餐相关字段(回充时需要) ==========
|
||||
|
||||
/**
|
||||
* 活动定义ID(检验项目定义ID)
|
||||
* 用于回充时关联到原始检验项目定义
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long activityId;
|
||||
|
||||
/**
|
||||
* 套餐ID(如果该项目是套餐,则关联套餐表)
|
||||
* 对应 InspectionPackage.basicInformationId
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long feePackageId;
|
||||
|
||||
/**
|
||||
* 是否是套餐项目
|
||||
*/
|
||||
private Boolean isPackage;
|
||||
|
||||
/**
|
||||
* 样本类型
|
||||
*/
|
||||
private String sampleType;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 检验类型ID(关联 inspection_type 大类)
|
||||
* 用于前端自动设置执行科室
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long inspectionTypeId;
|
||||
}
|
||||
|
||||
@@ -442,6 +442,15 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
||||
if (admissionPatientInfoDto.getPriorityEnum() != null) {
|
||||
encounterService.updatePriorityEnumById(encounterId, admissionPatientInfoDto.getPriorityEnum());
|
||||
}
|
||||
// 更新入科时间(如果提供了)
|
||||
if (startTime != null) {
|
||||
Encounter encounter = encounterService.getById(encounterId);
|
||||
if (encounter != null) {
|
||||
encounter.setStartTime(startTime);
|
||||
encounterService.saveOrUpdateEncounter(encounter);
|
||||
log.info("更新入科时间 - encounterId: {}, startTime: {}", encounterId, startTime);
|
||||
}
|
||||
}
|
||||
// 将之前的住院参与者更新为已完成(如果存在的话)
|
||||
encounterParticipantService.updateEncounterParticipantsStatus(encounterId);
|
||||
// 更新住院参与者
|
||||
|
||||
@@ -55,6 +55,7 @@ import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -67,6 +68,10 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
|
||||
private static final List<DateTimeFormatter> EXECUTE_TIME_FORMATTERS = List.of(
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"),
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd H:mm:ss"));
|
||||
|
||||
@Resource
|
||||
AssignSeqUtil assignSeqUtil;
|
||||
|
||||
@@ -669,11 +674,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
for (AdviceExecuteDetailParam adviceExecuteDetailParam : adviceExecuteDetailList) {
|
||||
for (String executeTime : adviceExecuteDetailParam.getExecuteTimes()) {
|
||||
// 生成执行记录
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 转换为 LocalDateTime
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(executeTime, formatter);
|
||||
// 转换为 Date
|
||||
Date exeDate = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
Date exeDate = parseExecuteTime(executeTime);
|
||||
// 根据执行记录新增不执行记录
|
||||
procedureService.addProcedureRecord(adviceExecuteDetailParam.getEncounterId(),
|
||||
adviceExecuteDetailParam.getPatientId(), adviceExecuteDetailParam.getRequestId(),
|
||||
@@ -701,16 +702,14 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
List<Long> medicationDefinitionIdList
|
||||
= medUseExeList.stream().map(MedicationRequestUseExe::getMedicationId).collect(Collectors.toList());
|
||||
// 医嘱详细信息
|
||||
Long orgId = SecurityUtils.getLoginUser().getOrgId();
|
||||
List<AdviceBaseDto> medicationInfos = doctorStationAdviceAppService.getAdviceBaseInfo(null, null, null,
|
||||
medicationDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(1), null, null).getRecords();
|
||||
medicationDefinitionIdList, orgId, 1, 500, Whether.NO.getValue(), List.of(1), null, null).getRecords();
|
||||
|
||||
// 当前时间
|
||||
Date curDate = new Date();
|
||||
// 参与者id
|
||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||
// 当前登录账号的科室id
|
||||
Long orgId = SecurityUtils.getLoginUser().getOrgId();
|
||||
|
||||
// 长期
|
||||
MedicationRequest longMedicationRequest;
|
||||
ChargeItem chargeItem;
|
||||
@@ -737,11 +736,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
String minUnitCode = advice.getMinUnitCode();
|
||||
|
||||
// 生成执行记录
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 转换为 LocalDateTime
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(executeTime, formatter);
|
||||
// 转换为 Date
|
||||
Date expectedDate = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
Date expectedDate = parseExecuteTime(executeTime);
|
||||
// 执行记录id
|
||||
Long procedureId = procedureService.addProcedureRecord(longMedicationRequest.getEncounterId(),
|
||||
longMedicationRequest.getPatientId(), longMedicationRequest.getId(),
|
||||
@@ -809,14 +804,24 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
chargeItemService.saveOrUpdate(chargeItem);
|
||||
} else {
|
||||
// 批次售卖情况
|
||||
throw new RuntimeException("[住院]批次售卖的情况暂未处理");
|
||||
|
||||
/* // 需要的药品数量(小单位)
|
||||
// 需要的药品数量(小单位)
|
||||
BigDecimal minUnitQuantity = medicationRequestUseExe.getMinUnitQuantity();
|
||||
if (minUnitQuantity == null || minUnitQuantity.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new RuntimeException("药品执行数量异常,medicationId: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
// 库存集合
|
||||
List<AdviceInventoryDto> inventoryList = advice.getInventoryList();
|
||||
if (inventoryList == null || inventoryList.isEmpty()) {
|
||||
throw new RuntimeException("药品库存不足,medicationId: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
// 价格集合
|
||||
List<AdvicePriceDto> priceList = advice.getPriceList();
|
||||
if (priceList == null || priceList.isEmpty()) {
|
||||
throw new RuntimeException("未找到药品匹配的定价信息: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
// 剩余需要分配的数量
|
||||
BigDecimal remainingQuantity = minUnitQuantity;
|
||||
|
||||
@@ -840,48 +845,52 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
}
|
||||
// 批次号
|
||||
String lotNumber = inventory.getLotNumber();
|
||||
if (lotNumber == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 根据批次库存量,生成发放
|
||||
longMedicationRequest.setQuantity(actualQuantity);// 小单位的数量
|
||||
longMedicationRequest.setUnitCode(minUnitCode); // 小单位
|
||||
longMedicationRequest.setLotNumber(lotNumber);
|
||||
MedicationRequest batchMedicationRequest = new MedicationRequest();
|
||||
BeanUtils.copyProperties(longMedicationRequest, batchMedicationRequest);
|
||||
batchMedicationRequest.setQuantity(actualQuantity);// 小单位的数量
|
||||
batchMedicationRequest.setUnitCode(minUnitCode); // 小单位
|
||||
batchMedicationRequest.setLotNumber(lotNumber);
|
||||
// 生成药品发放
|
||||
Long dispenseId = medicationDispenseService.generateMedicationDispense(longMedicationRequest,
|
||||
procedureId, exeDate);
|
||||
medicationDispenseService.generateMedicationDispense(batchMedicationRequest,
|
||||
procedureId, expectedDate);
|
||||
|
||||
// 生成账单
|
||||
chargeItem = new ChargeItem();
|
||||
chargeItem.setStatusEnum(ChargeItemStatus.BILLABLE.getValue()); // 收费状态
|
||||
chargeItem.setBusNo(
|
||||
AssignSeqEnum.CHARGE_ITEM_NO.getPrefix().concat(longMedicationRequest.getBusNo()));
|
||||
AssignSeqEnum.CHARGE_ITEM_NO.getPrefix().concat(batchMedicationRequest.getBusNo()));
|
||||
chargeItem.setGenerateSourceEnum(GenerateSource.ORDER_EXECUTE.getValue()); // 生成来源
|
||||
chargeItem.setPrescriptionNo(longMedicationRequest.getPrescriptionNo()); // 处方号
|
||||
chargeItem.setPatientId(longMedicationRequest.getPatientId()); // 患者
|
||||
chargeItem.setPrescriptionNo(batchMedicationRequest.getPrescriptionNo()); // 处方号
|
||||
chargeItem.setPatientId(batchMedicationRequest.getPatientId()); // 患者
|
||||
chargeItem.setContextEnum(ChargeItemContext.MEDICATION.getValue()); // 类型
|
||||
chargeItem.setEncounterId(longMedicationRequest.getEncounterId()); // 就诊id
|
||||
chargeItem.setEncounterId(batchMedicationRequest.getEncounterId()); // 就诊id
|
||||
chargeItem.setEntererId(practitionerId);// 开立人ID
|
||||
chargeItem.setRequestingOrgId(orgId); // 开立科室
|
||||
chargeItem.setEnteredDate(curDate); // 开立时间
|
||||
chargeItem.setServiceTable(CommonConstants.TableName.MED_MEDICATION_REQUEST);// 医疗服务类型
|
||||
chargeItem.setServiceId(longMedicationRequest.getId()); // 医疗服务ID
|
||||
chargeItem.setServiceId(batchMedicationRequest.getId()); // 医疗服务ID
|
||||
chargeItem.setProductTable(CommonConstants.TableName.MED_MEDICATION_DEFINITION);// 产品所在表
|
||||
chargeItem.setProductId(longMedicationRequest.getMedicationId());// 收费项id
|
||||
chargeItem.setProductId(batchMedicationRequest.getMedicationId());// 收费项id
|
||||
chargeItem.setAccountId(medicationRequestUseExe.getAccountId());// 关联账户ID
|
||||
chargeItem.setConditionId(longMedicationRequest.getConditionId()); // 诊断id
|
||||
chargeItem.setEncounterDiagnosisId(longMedicationRequest.getEncounterDiagnosisId()); // 就诊诊断id
|
||||
chargeItem.setConditionId(batchMedicationRequest.getConditionId()); // 诊断id
|
||||
chargeItem.setEncounterDiagnosisId(batchMedicationRequest.getEncounterDiagnosisId()); // 就诊诊断id
|
||||
chargeItem.setProcedureId(procedureId); // 执行id
|
||||
chargeItem.setDispenseTable(CommonConstants.TableName.MED_MEDICATION_DISPENSE); // 发放表名
|
||||
// chargeItem.setDispenseId(dispenseId); // 发放ID
|
||||
|
||||
// ------------------------------ 匹配定价信息
|
||||
// 在 priceList 中查找匹配的定价信息
|
||||
Optional<AdvicePriceDto> matchedPrice =
|
||||
priceList.stream().filter(p -> lotNumber.equals(p.getConditionValue())).findFirst();
|
||||
if (matchedPrice.isEmpty()) {
|
||||
AdvicePriceDto priceDto = matchedPrice.orElseGet(() -> priceList.stream().findFirst().orElse(null));
|
||||
if (priceDto == null) {
|
||||
throw new RuntimeException(
|
||||
"未找到匹配的定价信息,lotNumber: " + finalLongMedicationRequest.getLotNumber());
|
||||
"未找到匹配的定价信息,lotNumber: " + lotNumber);
|
||||
}
|
||||
AdvicePriceDto priceDto = matchedPrice.get();
|
||||
// 单价(大单位)
|
||||
BigDecimal price = priceDto.getPrice();
|
||||
// 单价(小单位)
|
||||
@@ -919,7 +928,11 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
|
||||
chargeItemService.saveOrUpdate(chargeItem);
|
||||
|
||||
}*/
|
||||
}
|
||||
if (remainingQuantity.compareTo(BigDecimal.ZERO) > 0) {
|
||||
throw new RuntimeException("药品库存不足,medicationId: "
|
||||
+ finalLongMedicationRequest.getMedicationId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -932,11 +945,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
BeanUtils.copyProperties(medicationRequestUseExe, tempMedicationRequest);
|
||||
|
||||
// 生成执行记录
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 转换为 LocalDateTime
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(executeTime, formatter);
|
||||
// 转换为 Date
|
||||
Date expectedDate = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
Date expectedDate = parseExecuteTime(executeTime);
|
||||
// 执行记录id
|
||||
Long procedureId = procedureService.addProcedureRecord(tempMedicationRequest.getEncounterId(),
|
||||
tempMedicationRequest.getPatientId(), tempMedicationRequest.getId(),
|
||||
@@ -978,16 +987,14 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
List<Long> activityDefinitionIdList
|
||||
= actUseExeList.stream().map(ServiceRequestUseExe::getActivityId).collect(Collectors.toList());
|
||||
// 医嘱详细信息
|
||||
Long orgId = SecurityUtils.getLoginUser().getOrgId();
|
||||
List<AdviceBaseDto> activityInfos = doctorStationAdviceAppService.getAdviceBaseInfo(null, null, null,
|
||||
activityDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(3), null, null).getRecords();
|
||||
activityDefinitionIdList, orgId, 1, 500, Whether.NO.getValue(), List.of(3), null, null).getRecords();
|
||||
|
||||
// 当前时间
|
||||
Date curDate = new Date();
|
||||
// 参与者id
|
||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||
// 当前登录账号的科室id
|
||||
Long orgId = SecurityUtils.getLoginUser().getOrgId();
|
||||
|
||||
Date clickDate = new Date();
|
||||
|
||||
// 长期
|
||||
@@ -1002,11 +1009,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
BeanUtils.copyProperties(serviceRequestUseExe, longServiceRequest);
|
||||
|
||||
// 生成执行记录
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 转换为 LocalDateTime
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(executeTime, formatter);
|
||||
// 转换为 Date
|
||||
Date expectedDate = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
Date expectedDate = parseExecuteTime(executeTime);
|
||||
// 执行记录id
|
||||
Long procedureId = procedureService.addProcedureRecord(longServiceRequest.getEncounterId(),
|
||||
longServiceRequest.getPatientId(), longServiceRequest.getId(),
|
||||
@@ -1077,11 +1080,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
BeanUtils.copyProperties(serviceRequestUseExe, tempServiceRequest);
|
||||
|
||||
// 生成执行记录
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 转换为 LocalDateTime
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(executeTime, formatter);
|
||||
// 转换为 Date
|
||||
Date expectedDate = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
Date expectedDate = parseExecuteTime(executeTime);
|
||||
// 执行记录id
|
||||
Long procedureId = procedureService.addProcedureRecord(tempServiceRequest.getEncounterId(),
|
||||
tempServiceRequest.getPatientId(), tempServiceRequest.getId(),
|
||||
@@ -1146,7 +1145,8 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
|
||||
// 耗材医嘱详细信息
|
||||
List<AdviceBaseDto> deviceInfos = doctorStationAdviceAppService
|
||||
.getAdviceBaseInfo(null, null, null, deviceIds, 0L, 1, 500, Whether.NO.getValue(), List.of(2), null, null)
|
||||
.getAdviceBaseInfo(null, null, null, deviceIds, orgId, 1, 500, Whether.NO.getValue(), List.of(2),
|
||||
null, null)
|
||||
.getRecords();
|
||||
|
||||
DeviceRequest deviceRequest;
|
||||
@@ -1405,6 +1405,18 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
|
||||
return actUseExeList;
|
||||
}
|
||||
|
||||
private Date parseExecuteTime(String executeTime) {
|
||||
for (DateTimeFormatter formatter : EXECUTE_TIME_FORMATTERS) {
|
||||
try {
|
||||
LocalDateTime localDateTime = LocalDateTime.parse(executeTime, formatter);
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
} catch (DateTimeParseException ignored) {
|
||||
// try next formatter
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("无法解析执行时间: " + executeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成退药单
|
||||
*
|
||||
|
||||
@@ -350,11 +350,16 @@ public class NurseBillingAppService implements INurseBillingAppService {
|
||||
// 1. 筛选临时类型耗材:仅处理临时医嘱(TherapyTimeType.TEMPORARY),且请求ID不为空
|
||||
List<AdviceSaveDto> tempDeviceList = deviceAdviceList.stream().collect(Collectors.toList());
|
||||
|
||||
// 2. 校验发放库房:必须指定耗材发放库房(locationId),否则抛出业务异常
|
||||
if (tempDeviceList.stream().anyMatch(t -> t.getLocationId() == null)) {
|
||||
throw new ServiceException("耗材划价失败:发放库房为空,请重新选择");
|
||||
// 2. 颞理发放库房:为locationId为null的项目设置默认值
|
||||
for (AdviceSaveDto advice : tempDeviceList) {
|
||||
if (advice.getLocationId() == null) {
|
||||
// 设置默认位置为用户组织ID作为fallback
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getOrgId() != null) {
|
||||
advice.setLocationId(loginUser.getOrgId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 循环处理每个临时耗材医嘱(逐条生成关联数据)
|
||||
for (AdviceSaveDto adviceDto : tempDeviceList) {
|
||||
// 3.1 生成耗材请求记录(WOR_DEVICE_REQUEST):状态设为激活,来源标记为护士划价
|
||||
@@ -665,7 +670,7 @@ public class NurseBillingAppService implements INurseBillingAppService {
|
||||
// 1. 校验:待删除项是否已收费,已收费则抛出异常阻止删除
|
||||
checkDeletedDeviceChargeStatus(requestIds);
|
||||
// 软删除执行记录
|
||||
List<Procedure> procedureList = iProcedureService.listByIds(requestIds);
|
||||
List<Procedure> procedureList = iProcedureService.getProcedureRecords(requestIds, serviceTable);
|
||||
List<Long> procedureIds = procedureList.stream().filter(Objects::nonNull) // 过滤掉null的Procedure对象
|
||||
.map(Procedure::getId).filter(Objects::nonNull) // 过滤掉id为null的记录(按需添加)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface IVitalSignsAppService {
|
||||
*
|
||||
* @return 体温单检索结果
|
||||
*/
|
||||
R<?> searchVitalSigns(String startTime, String endTime);
|
||||
R<?> searchVitalSigns(String startTime, String endTime, String patientId);
|
||||
|
||||
/**
|
||||
* 体温单记录删除
|
||||
|
||||
@@ -73,9 +73,21 @@ public class VitalSignsAppServiceImpl implements IVitalSignsAppService {
|
||||
|
||||
VitalSignsMedicalRecordDto medicalRecord = new VitalSignsMedicalRecordDto();
|
||||
|
||||
// 处理日期
|
||||
// 处理出院日期
|
||||
if (!vitalSignsInfoPage.getRecords().isEmpty()) {
|
||||
medicalRecord.setHospDate(vitalSignsInfoPage.getRecords().get(0).getRecordingDate());
|
||||
// 从第一条记录获取出院日期(如果存在)
|
||||
Date dischargeDate = vitalSignsInfoPage.getRecords().get(0).getDischargeDate();
|
||||
if (dischargeDate != null) {
|
||||
medicalRecord.setOutdate(TimeUtils.dateToDateString(dischargeDate));
|
||||
}
|
||||
}
|
||||
|
||||
// 处理住院日期:优先使用第一条记录中的入院日期,如果没有则保持 null 让前端 fallback
|
||||
if (!vitalSignsInfoPage.getRecords().isEmpty()) {
|
||||
Date admissionDate = vitalSignsInfoPage.getRecords().get(0).getAdmissionDate();
|
||||
if (admissionDate != null) {
|
||||
medicalRecord.setHospDate(admissionDate);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理生命体征数据
|
||||
@@ -266,13 +278,14 @@ public class VitalSignsAppServiceImpl implements IVitalSignsAppService {
|
||||
*
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param patientId 患者ID
|
||||
* @return 检索结果
|
||||
*/
|
||||
@Override
|
||||
public R<?> searchVitalSigns(String startTime, String endTime) {
|
||||
public R<?> searchVitalSigns(String startTime, String endTime, String patientId) {
|
||||
|
||||
// 基本信息查询
|
||||
List<VitalSigns> vitalSignsList = vitalSignsAppMapper.searchVitalSigns(startTime, endTime);
|
||||
List<VitalSigns> vitalSignsList = vitalSignsAppMapper.searchVitalSigns(startTime, endTime, patientId);
|
||||
// 判断查询结果是否为空
|
||||
if (vitalSignsList.isEmpty()) {
|
||||
return R.ok(Collections.emptyList());
|
||||
|
||||
@@ -57,8 +57,8 @@ public class VitalSignsController {
|
||||
* @return 体温单检索结果
|
||||
*/
|
||||
@GetMapping("/record-search")
|
||||
public R<?> searchVitalSigns(String startTime, String endTime) {
|
||||
return R.ok(vitalSignsAppService.searchVitalSigns(startTime, endTime));
|
||||
public R<?> searchVitalSigns(String startTime, String endTime, String patientId) {
|
||||
return R.ok(vitalSignsAppService.searchVitalSigns(startTime, endTime, patientId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.openhis.web.inpatientmanage.dto;
|
||||
|
||||
import com.core.common.core.domain.HisBaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -35,6 +36,7 @@ public class VitalSignsSaveDto extends HisBaseEntity {
|
||||
/**
|
||||
* 记录日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date recordingDate;
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,9 +38,10 @@ public interface VitalSignsAppMapper {
|
||||
*
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param patientId 患者ID
|
||||
* @return 查询记录结果
|
||||
*/
|
||||
List<VitalSigns> searchVitalSigns(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
List<VitalSigns> searchVitalSigns(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("patientId") String patientId);
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -68,6 +69,17 @@ public class LabActivityDefinitionAppServiceImpl implements ILabActivityDefiniti
|
||||
selParam.setPricingFlag(null);
|
||||
}
|
||||
|
||||
// Bug #414: 限制分页大小,防止一次性加载过多数据导致性能问题
|
||||
if (pageSize == null || pageSize <= 0) {
|
||||
pageSize = 20;
|
||||
}
|
||||
if (pageSize > 50) {
|
||||
pageSize = 50;
|
||||
}
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = 1;
|
||||
}
|
||||
|
||||
QueryWrapper<DiagnosisTreatmentDto> queryWrapper = HisQueryUtils.buildQueryWrapper(selParam,
|
||||
searchKey, new HashSet<>(Arrays.asList("T1.bus_no", "T1.name", "T1.py_str", "T1.wb_str")), request);
|
||||
|
||||
@@ -80,10 +92,19 @@ public class LabActivityDefinitionAppServiceImpl implements ILabActivityDefiniti
|
||||
selParam.setPricingFlag(pricingFlagValue);
|
||||
}
|
||||
|
||||
IPage<DiagnosisTreatmentDto> page = labActivityDefinitionManageMapper
|
||||
.getLabActivityDefinitionPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
// Bug #414: 使用optimizeCountSql=true优化COUNT查询性能
|
||||
Page<DiagnosisTreatmentDto> page = new Page<>(pageNo, pageSize, true);
|
||||
IPage<DiagnosisTreatmentDto> resultPage = labActivityDefinitionManageMapper
|
||||
.getLabActivityDefinitionPage(page, queryWrapper);
|
||||
|
||||
page.getRecords().forEach(e -> {
|
||||
resultPage.getRecords().forEach(e -> {
|
||||
// Bug #415: 确保价格不为负数
|
||||
if (e.getPackageAmount() != null && e.getPackageAmount().compareTo(BigDecimal.ZERO) < 0) {
|
||||
e.setPackageAmount(BigDecimal.ZERO);
|
||||
}
|
||||
if (e.getServiceFee() != null && e.getServiceFee().compareTo(BigDecimal.ZERO) < 0) {
|
||||
e.setServiceFee(BigDecimal.ZERO);
|
||||
}
|
||||
e.setYbFlag_enumText(EnumUtils.getInfoByValue(Whether.class, e.getYbFlag()));
|
||||
e.setYbMatchFlag_enumText(EnumUtils.getInfoByValue(Whether.class, e.getYbMatchFlag()));
|
||||
e.setTypeEnum_enumText(EnumUtils.getInfoByValue(ActivityType.class, e.getTypeEnum()));
|
||||
@@ -91,13 +112,22 @@ public class LabActivityDefinitionAppServiceImpl implements ILabActivityDefiniti
|
||||
e.setPricingFlag_enumText(EnumUtils.getInfoByValue(Whether.class, e.getPricingFlag()));
|
||||
});
|
||||
|
||||
return R.ok(page);
|
||||
return R.ok(resultPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getLabActivityDefinitionOne(Long id) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
DiagnosisTreatmentDto dto = labActivityDefinitionManageMapper.getLabActivityDefinitionOne(id, tenantId);
|
||||
// Bug #415: 确保价格不为负数
|
||||
if (dto != null) {
|
||||
if (dto.getPackageAmount() != null && dto.getPackageAmount().compareTo(BigDecimal.ZERO) < 0) {
|
||||
dto.setPackageAmount(BigDecimal.ZERO);
|
||||
}
|
||||
if (dto.getServiceFee() != null && dto.getServiceFee().compareTo(BigDecimal.ZERO) < 0) {
|
||||
dto.setServiceFee(BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
return R.ok(dto);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@ import com.openhis.web.paymentmanage.appservice.IChargeBillService;
|
||||
import com.openhis.web.paymentmanage.dto.*;
|
||||
import com.openhis.web.paymentmanage.mapper.ChargeBillMapper;
|
||||
import com.openhis.workflow.domain.ActivityDefinition;
|
||||
import com.openhis.workflow.domain.ServiceRequest;
|
||||
import com.openhis.workflow.service.IActivityDefinitionService;
|
||||
import com.openhis.workflow.service.IServiceRequestService;
|
||||
import com.openhis.yb.domain.ClinicSettle;
|
||||
import com.openhis.yb.domain.ClinicUnSettle;
|
||||
import com.openhis.yb.domain.InfoPerson;
|
||||
@@ -111,6 +113,8 @@ public class IChargeBillServiceImpl implements IChargeBillService {
|
||||
@Autowired
|
||||
private IActivityDefinitionService iActivityDefinitionService;
|
||||
@Autowired
|
||||
private IServiceRequestService iServiceRequestService;
|
||||
@Autowired
|
||||
private IPractitionerService iPractitionerService;
|
||||
@Autowired
|
||||
private IHealthcareServiceService iHealthcareServiceService;
|
||||
@@ -265,10 +269,31 @@ public class IChargeBillServiceImpl implements IChargeBillService {
|
||||
.setTotalPrice(chargeItem.getTotalPrice()).setQuantityUnit(chargeItem.getQuantityUnit())
|
||||
.setTotalVolume(device.getSize()).setQuantityValue(chargeItem.getQuantityValue());
|
||||
} else if (CommonConstants.TableName.WOR_ACTIVITY_DEFINITION.equals(chargeItem.getProductTable())) {
|
||||
// 🔧 BugFix#385: 检查申请创建的收费项 productId=0,需从 ServiceRequest.contentJson 获取项目名称
|
||||
if (chargeItem.getProductId() != null && chargeItem.getProductId() > 0) {
|
||||
ActivityDefinition activity = iActivityDefinitionService.getById(chargeItem.getProductId());
|
||||
chargeItemDetailVO.setDirClass(activity.getChrgitmLv() + "").setChargeItemName(activity.getName())
|
||||
.setTotalPrice(chargeItem.getTotalPrice()).setQuantityUnit(chargeItem.getQuantityUnit())
|
||||
.setTotalVolume("").setQuantityValue(chargeItem.getQuantityValue());
|
||||
} else {
|
||||
// productId=0 时,从关联的 ServiceRequest 获取项目名称
|
||||
ServiceRequest serviceRequest = iServiceRequestService.getById(chargeItem.getServiceId());
|
||||
String itemName = "未知项目";
|
||||
String dirClass = "3"; // 默认诊疗类
|
||||
if (serviceRequest != null && serviceRequest.getContentJson() != null) {
|
||||
try {
|
||||
JSONObject json = JSON.parseObject(serviceRequest.getContentJson());
|
||||
if (json.containsKey("adviceName")) {
|
||||
itemName = json.getString("adviceName");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("解析ServiceRequest.contentJson失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
chargeItemDetailVO.setDirClass(dirClass).setChargeItemName(itemName)
|
||||
.setTotalPrice(chargeItem.getTotalPrice()).setQuantityUnit(chargeItem.getQuantityUnit())
|
||||
.setTotalVolume("").setQuantityValue(chargeItem.getQuantityValue());
|
||||
}
|
||||
} else {
|
||||
HealthcareService healthcareService = iHealthcareServiceService.getById(chargeItem.getServiceId());
|
||||
chargeItemDetailVO.setDirClass("3").setChargeItemName(healthcareService.getName())
|
||||
@@ -347,7 +372,19 @@ public class IChargeBillServiceImpl implements IChargeBillService {
|
||||
|
||||
Long definitionId = chargeItem.getDefinitionId();
|
||||
|
||||
ChargeItemDefinition chargeItemDefinition = iChargeItemDefinitionService.getById(definitionId);
|
||||
// 🔧 BugFix#385: 检查申请创建的收费项 definition_id=0,chargeItemDefinition 会为 null
|
||||
ChargeItemDefinition chargeItemDefinition = null;
|
||||
if (definitionId != null && definitionId > 0) {
|
||||
chargeItemDefinition = iChargeItemDefinitionService.getById(definitionId);
|
||||
}
|
||||
|
||||
// 当 definitionId=0 或 chargeItemDefinition 为 null 时,跳过医保分类统计
|
||||
// 检查类项目默认归类为"检查费"
|
||||
if (chargeItemDefinition == null) {
|
||||
// 检查申请的收费项,归类为检查费(03)
|
||||
sum03 = sum03.add(chargeItem.getTotalPrice());
|
||||
continue;
|
||||
}
|
||||
|
||||
YbMedChrgItmType medChrgItmType
|
||||
= YbMedChrgItmType.getByCode(Integer.parseInt(chargeItemDefinition.getYbType()));
|
||||
|
||||
@@ -6,6 +6,7 @@ package com.openhis.web.paymentmanage.appservice.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
@@ -57,6 +58,12 @@ import com.openhis.web.paymentmanage.mapper.PaymentMapper;
|
||||
import com.openhis.web.personalization.dto.ActivityDeviceDto;
|
||||
import com.openhis.triageandqueuemanage.domain.TriageQueueItem;
|
||||
import com.openhis.triageandqueuemanage.service.TriageQueueItemService;
|
||||
import com.openhis.appointmentmanage.domain.ScheduleSlot;
|
||||
import com.openhis.appointmentmanage.domain.SchedulePool;
|
||||
import com.openhis.appointmentmanage.mapper.ScheduleSlotMapper;
|
||||
import com.openhis.appointmentmanage.mapper.SchedulePoolMapper;
|
||||
import com.openhis.clinical.domain.Order;
|
||||
import com.openhis.clinical.service.IOrderService;
|
||||
import com.openhis.workflow.domain.ServiceRequest;
|
||||
import com.openhis.workflow.service.IDeviceDispenseService;
|
||||
import com.openhis.workflow.service.IDeviceRequestService;
|
||||
@@ -186,6 +193,12 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
private YbManager ybManager;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
@Autowired
|
||||
private IOrderService iOrderService;
|
||||
@Autowired
|
||||
private ScheduleSlotMapper scheduleSlotMapper;
|
||||
@Autowired
|
||||
private SchedulePoolMapper schedulePoolMapper;
|
||||
|
||||
/**
|
||||
* 【门诊预结算】
|
||||
@@ -232,14 +245,21 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
.collect(Collectors.toList());
|
||||
// account去重
|
||||
List<Long> distinctAccountIdList = accountIdList.stream().distinct().collect(Collectors.toList());
|
||||
// 检查是否存在accountId为null的收费项
|
||||
// 检查是否存在accountId为null或0的收费项
|
||||
long nullAccountIdCount = chargeItemList.stream()
|
||||
.map(ChargeItem::getAccountId)
|
||||
.filter(Objects::isNull)
|
||||
.count();
|
||||
long zeroAccountIdCount = chargeItemList.stream()
|
||||
.map(ChargeItem::getAccountId)
|
||||
.filter(id -> id != null && id == 0L)
|
||||
.count();
|
||||
if (nullAccountIdCount > 0) {
|
||||
throw new ServiceException("部分收费项缺少账户信息,请检查收费项数据");
|
||||
}
|
||||
if (zeroAccountIdCount > 0) {
|
||||
throw new ServiceException("部分收费项账户ID为0(无效),请检查收费项数据或重新创建检查申请");
|
||||
}
|
||||
if (distinctAccountIdList.isEmpty()) {
|
||||
throw new ServiceException("未找到有效的账户信息");
|
||||
}
|
||||
@@ -248,15 +268,66 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
// 在挂号费等场景下可能因数据不一致导致查不到,引发误报
|
||||
List<Account> accountList = iAccountService.list(new LambdaQueryWrapper<Account>()
|
||||
.in(Account::getId, distinctAccountIdList));
|
||||
|
||||
// 🔧 Bug Fix: 处理账户不存在的情况(历史数据修复)
|
||||
if (accountList.size() != distinctAccountIdList.size()) {
|
||||
// 部分账户查不到时,记录警告日志,并校验是否每个收费项都能找到对应账户
|
||||
Set<Long> foundAccountIds = accountList.stream().map(Account::getId).collect(Collectors.toSet());
|
||||
List<Long> missingAccountIds = distinctAccountIdList.stream()
|
||||
.filter(id -> !foundAccountIds.contains(id)).collect(Collectors.toList());
|
||||
if (accountList.isEmpty()) {
|
||||
throw new ServiceException("未查询到任何账户信息,encounterId:" + prePaymentDto.getEncounterId()
|
||||
+ ",期望accountId列表:" + distinctAccountIdList);
|
||||
|
||||
logger.warn("预结算发现部分账户不存在,missingAccountIds={},将自动修复收费项的accountId",
|
||||
missingAccountIds);
|
||||
|
||||
// 获取或创建有效的自费账户
|
||||
Account selfAccount = iAccountService.getSelfAccount(prePaymentDto.getEncounterId());
|
||||
if (selfAccount == null) {
|
||||
// 自动创建自费账户
|
||||
Account newAccount = new Account();
|
||||
newAccount.setPatientId(chargeItemList.get(0).getPatientId());
|
||||
newAccount.setEncounterId(prePaymentDto.getEncounterId());
|
||||
newAccount.setContractNo(CommonConstants.BusinessName.DEFAULT_CONTRACT_NO);
|
||||
newAccount.setTypeCode(AccountType.PERSONAL_CASH_ACCOUNT.getCode());
|
||||
newAccount.setBalanceAmount(BigDecimal.ZERO);
|
||||
newAccount.setStatusEnum(AccountStatus.ACTIVE.getValue());
|
||||
newAccount.setEncounterFlag(Whether.YES.getValue());
|
||||
newAccount.setName(AccountType.PERSONAL_CASH_ACCOUNT.getInfo());
|
||||
Long newAccountId = iAccountService.saveAccountByRegister(newAccount);
|
||||
selfAccount = iAccountService.getById(newAccountId);
|
||||
logger.info("预结算自动创建自费账户,newAccountId={}", newAccountId);
|
||||
}
|
||||
|
||||
// 修复收费项的 accountId
|
||||
for (Long missingAccountId : missingAccountIds) {
|
||||
// 找到使用该无效 accountId 的收费项
|
||||
List<ChargeItem> affectedChargeItems = chargeItemList.stream()
|
||||
.filter(ci -> ci.getAccountId() != null && ci.getAccountId().equals(missingAccountId))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (ChargeItem ci : affectedChargeItems) {
|
||||
LambdaUpdateWrapper<ChargeItem> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(ChargeItem::getId, ci.getId())
|
||||
.set(ChargeItem::getAccountId, selfAccount.getId());
|
||||
iChargeItemService.update(updateWrapper);
|
||||
logger.info("预结算修复收费项accountId,chargeItemId={},oldAccountId={},newAccountId={}",
|
||||
ci.getId(), missingAccountId, selfAccount.getId());
|
||||
|
||||
// 更新本地对象的 accountId,以便后续处理使用正确的值
|
||||
ci.setAccountId(selfAccount.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// 重新查询账户列表
|
||||
accountList = iAccountService.list(new LambdaQueryWrapper<Account>()
|
||||
.eq(Account::getId, selfAccount.getId()));
|
||||
|
||||
// 重新构建 accountIdList(已修复)
|
||||
distinctAccountIdList = chargeItemList.stream()
|
||||
.map(ChargeItem::getAccountId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
logger.info("预结算账户修复完成,最终使用accountId={}", selfAccount.getId());
|
||||
}
|
||||
|
||||
// 账户id,对应的账单列表
|
||||
@@ -1914,6 +1985,60 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
|
||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
||||
|
||||
// Bug #409:预约签到挂号时,修正 serviceTypeId 为预约类型而非挂号类型
|
||||
// 数据链:Order → ScheduleSlot → SchedulePool → HealthcareService
|
||||
try {
|
||||
Order appointmentOrder = iOrderService.getOne(
|
||||
new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPatientId, encounterFormData.getPatientId())
|
||||
.eq(Order::getStatus, CommonConstants.AppointmentOrderStatus.CHECKED_IN)
|
||||
.eq(Order::getDeleteFlag, "0")
|
||||
.orderByDesc(Order::getCreateTime)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
|
||||
if (appointmentOrder != null && appointmentOrder.getSlotId() != null) {
|
||||
ScheduleSlot slot = scheduleSlotMapper.selectById(appointmentOrder.getSlotId());
|
||||
if (slot != null && slot.getPoolId() != null) {
|
||||
SchedulePool pool = schedulePoolMapper.selectById(slot.getPoolId());
|
||||
if (pool != null && pool.getRegType() != null) {
|
||||
// pool.getRegType() 存储号别名称如"普通号-预约",精确匹配 HealthcareService
|
||||
HealthcareService appointmentHealthcareService = healthcareServiceService.getOne(
|
||||
new LambdaQueryWrapper<HealthcareService>()
|
||||
.eq(HealthcareService::getOfferedOrgId, encounterFormData.getOrganizationId())
|
||||
.eq(HealthcareService::getDeleteFlag, "0")
|
||||
.eq(HealthcareService::getName, pool.getRegType())
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
|
||||
if (appointmentHealthcareService != null) {
|
||||
encounterFormData.setServiceTypeId(appointmentHealthcareService.getId());
|
||||
encounterFormData.setOrderId(appointmentOrder.getId());
|
||||
logger.info("预约签到挂号修正serviceTypeId={},号别={}",
|
||||
appointmentHealthcareService.getId(), pool.getRegType());
|
||||
} else {
|
||||
// 精确匹配失败,尝试 LIKE 匹配
|
||||
appointmentHealthcareService = healthcareServiceService.getOne(
|
||||
new LambdaQueryWrapper<HealthcareService>()
|
||||
.eq(HealthcareService::getOfferedOrgId, encounterFormData.getOrganizationId())
|
||||
.eq(HealthcareService::getDeleteFlag, "0")
|
||||
.like(HealthcareService::getName, pool.getRegType())
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
if (appointmentHealthcareService != null) {
|
||||
encounterFormData.setServiceTypeId(appointmentHealthcareService.getId());
|
||||
encounterFormData.setOrderId(appointmentOrder.getId());
|
||||
logger.info("预约签到挂号(LIKE)serviceTypeId={},号别={}",
|
||||
appointmentHealthcareService.getId(), pool.getRegType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("修正serviceTypeId失败,不影响挂号流程", e);
|
||||
}
|
||||
|
||||
// 保存就诊信息
|
||||
Encounter encounter = new Encounter();
|
||||
BeanUtils.copyProperties(encounterFormData, encounter);
|
||||
@@ -1985,6 +2110,31 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
}
|
||||
|
||||
// 创建队列项
|
||||
// 尝试获取预约订单的 slot_id 和 pool_id
|
||||
Long queuePoolId = null;
|
||||
Long queueSlotId = null;
|
||||
try {
|
||||
// 查询患者当天的待签到预约订单(status = 1 或 2 表示已预约或已取号)
|
||||
Order order = iOrderService.getOne(
|
||||
new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPatientId, encounter.getPatientId())
|
||||
.in(Order::getStatus, 1, 2) // 1=BOOKED 已预约, 2=CHECKED_IN 已取号
|
||||
.eq(Order::getDeleteFlag, "0")
|
||||
.orderByDesc(Order::getCreateTime)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
if (order != null && order.getSlotId() != null) {
|
||||
queueSlotId = order.getSlotId();
|
||||
// 通过 slot_id 获取 pool_id
|
||||
ScheduleSlot slot = scheduleSlotMapper.selectById(queueSlotId);
|
||||
if (slot != null) {
|
||||
queuePoolId = slot.getPoolId();
|
||||
}
|
||||
logger.info("挂号时找到预约订单,slotId={}, poolId={}, encounterId={}", queueSlotId, queuePoolId, encounterId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("查询预约订单失败,不影响挂号流程,encounterId={}", encounterId, e);
|
||||
}
|
||||
TriageQueueItem queueItem = new TriageQueueItem()
|
||||
.setTenantId(tenantId)
|
||||
.setQueueDate(queueDate)
|
||||
@@ -1997,7 +2147,9 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
.setPractitionerId(queuePractitionerId)
|
||||
.setPractitionerName(practitionerName)
|
||||
.setRoomNo(null)
|
||||
.setStatus("WAITING")
|
||||
.setPoolId(queuePoolId)
|
||||
.setSlotId(queueSlotId)
|
||||
.setStatus(TriageQueueStatus.WAITING.getValue()) // 使用枚举替代硬编码常量,保持状态值一致
|
||||
.setQueueOrder(maxOrder + 1)
|
||||
.setDeleteFlag("0")
|
||||
.setCreateTime(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS))
|
||||
|
||||
@@ -88,5 +88,10 @@ public class OrdersGroupPackageDetailQueryDto {
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 治疗类型:1-长期 2-临时
|
||||
*/
|
||||
private Integer therapyEnum;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -180,9 +180,11 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
// 药品
|
||||
List<RegAdviceSaveDto> medicineList = regAdviceSaveList.stream()
|
||||
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
// 诊疗活动
|
||||
// 诊疗活动(包含护理adviceType=26)
|
||||
List<RegAdviceSaveDto> activityList = regAdviceSaveList.stream()
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())
|
||||
|| (e.getAdviceType() != null && e.getAdviceType() == 26))
|
||||
.collect(Collectors.toList());
|
||||
// 耗材 🔧 Bug #147 修复
|
||||
List<RegAdviceSaveDto> deviceList = regAdviceSaveList.stream()
|
||||
.filter(e -> ItemType.DEVICE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
@@ -844,9 +846,11 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
List<Long> medicineRequestIds
|
||||
= medicineList.stream().map(AdviceBatchOpParam::getRequestId).collect(Collectors.toList());
|
||||
// 诊疗
|
||||
// 诊疗(包含护理adviceType=26)
|
||||
List<AdviceBatchOpParam> activityList = paramList.stream()
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())
|
||||
|| (e.getAdviceType() != null && e.getAdviceType() == 26))
|
||||
.collect(Collectors.toList());
|
||||
List<Long> activityRequestIds
|
||||
= activityList.stream().map(AdviceBatchOpParam::getRequestId).collect(Collectors.toList());
|
||||
// 查询已完成的药品请求
|
||||
@@ -902,9 +906,11 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService {
|
||||
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
List<Long> medicineRequestIds
|
||||
= medicineList.stream().map(AdviceBatchOpParam::getRequestId).collect(Collectors.toList());
|
||||
// 诊疗
|
||||
// 诊疗(包含护理adviceType=26)
|
||||
List<AdviceBatchOpParam> activityList = paramList.stream()
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())
|
||||
|| (e.getAdviceType() != null && e.getAdviceType() == 26))
|
||||
.collect(Collectors.toList());
|
||||
List<Long> activityRequestIds
|
||||
= activityList.stream().map(AdviceBatchOpParam::getRequestId).collect(Collectors.toList());
|
||||
if (!medicineRequestIds.isEmpty()) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.openhis.workflow.service.IActivityDefinitionService;
|
||||
import com.openhis.workflow.service.IServiceRequestService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@@ -40,6 +41,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class RequestFormManageAppServiceImpl implements IRequestFormManageAppService {
|
||||
|
||||
@Resource
|
||||
@@ -71,6 +73,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> saveRequestForm(RequestFormSaveDto requestFormSaveDto, String typeCode) {
|
||||
// 诊疗处方号
|
||||
String prescriptionNo;
|
||||
@@ -330,7 +333,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
|
||||
surgeryChargeItem.setBusNo(AssignSeqEnum.CHARGE_ITEM_NO.getPrefix().concat(surgeryServiceRequest.getBusNo()));
|
||||
surgeryChargeItem.setGenerateSourceEnum(GenerateSource.DOCTOR_PRESCRIPTION.getValue());
|
||||
surgeryChargeItem.setPatientId(patientId);
|
||||
surgeryChargeItem.setContextEnum(6); // 6-手术
|
||||
surgeryChargeItem.setContextEnum(3); // 3-项目(手术属于诊疗项目)
|
||||
surgeryChargeItem.setEncounterId(encounterId);
|
||||
surgeryChargeItem.setEntererId(practitionerId);
|
||||
surgeryChargeItem.setEnteredDate(curDate);
|
||||
|
||||
@@ -93,6 +93,23 @@ public interface IInfectiousCardAppService {
|
||||
*
|
||||
* @return 科室树数据
|
||||
*/
|
||||
|
||||
/**
|
||||
* 撤销审核传染病报卡
|
||||
*
|
||||
* @param cardNo 报卡编号
|
||||
* @param status 撤销后的状态
|
||||
* @return 结果
|
||||
*/
|
||||
R<?> revokeAudit(String cardNo, String status);
|
||||
R<?> getDeptTree();
|
||||
|
||||
/**
|
||||
* 查询报卡审核记录(留痕追溯)
|
||||
*
|
||||
* @param cardNo 报卡编号
|
||||
* @return 审核记录列表
|
||||
*/
|
||||
R<?> getAuditRecords(String cardNo);
|
||||
|
||||
}
|
||||
@@ -4,20 +4,25 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
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.administration.domain.Organization;
|
||||
import com.openhis.administration.service.IOrganizationService;
|
||||
import com.openhis.infectious.domain.InfectiousAudit;
|
||||
import com.openhis.web.reportManagement.appservice.IInfectiousCardAppService;
|
||||
import com.openhis.web.reportManagement.dto.InfectiousCardDto;
|
||||
import com.openhis.web.reportManagement.dto.InfectiousCardParam;
|
||||
import com.openhis.web.cardmanagement.mapper.InfectiousAuditMapper;
|
||||
import com.openhis.web.reportManagement.mapper.ReportManageCardMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 传染病报卡 AppService 实现
|
||||
@@ -35,6 +40,41 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
@Autowired
|
||||
private IOrganizationService organizationService;
|
||||
|
||||
@Autowired
|
||||
private InfectiousAuditMapper infectiousAuditMapper;
|
||||
|
||||
private void createAuditRecord(String cardNo, Integer statusFrom, Integer statusTo, String auditType,
|
||||
String auditOpinion, String reasonForReturn, boolean isBatch, Integer batchSize) {
|
||||
String safeCardNo = cardNo == null ? null : cardNo.trim();
|
||||
Integer nextSeq = infectiousAuditMapper.getNextAuditSeq(safeCardNo);
|
||||
InfectiousAudit audit = new InfectiousAudit();
|
||||
// infectious_audit.card_id 设计上应存报卡 card_no(字符串)
|
||||
audit.setCardId(safeCardNo);
|
||||
audit.setAuditSeq(nextSeq);
|
||||
audit.setAuditType(auditType);
|
||||
audit.setAuditStatusFrom(statusFrom == null ? null : String.valueOf(statusFrom));
|
||||
audit.setAuditStatusTo(statusTo == null ? null : String.valueOf(statusTo));
|
||||
audit.setAuditTime(LocalDateTime.now());
|
||||
audit.setAuditorId(SecurityUtils.getUserId() != null ? SecurityUtils.getUserId().toString() : null);
|
||||
audit.setAuditorName(SecurityUtils.getUsername());
|
||||
audit.setAuditOpinion(auditOpinion);
|
||||
audit.setReasonForReturn(reasonForReturn);
|
||||
audit.setIsBatch(isBatch);
|
||||
audit.setBatchSize(batchSize);
|
||||
// 通用审计字段(数据库字段建议为 create_time/update_time,与 HisBaseEntity 保持一致)
|
||||
audit.setCreateBy(SecurityUtils.getUsernameSafe());
|
||||
audit.setUpdateBy(SecurityUtils.getUsernameSafe());
|
||||
audit.setCreateTime(new java.util.Date());
|
||||
audit.setUpdateTime(new java.util.Date());
|
||||
audit.setTenantId(SecurityUtils.getLoginUser().getTenantId());
|
||||
audit.setDeleteFlag("0");
|
||||
|
||||
int inserted = infectiousAuditMapper.insert(audit);
|
||||
if (inserted <= 0) {
|
||||
throw new RuntimeException("写入审核记录失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询传染病报卡列表
|
||||
* @param param 查询参数
|
||||
@@ -106,15 +146,21 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 审核结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> audit(String cardNo, String auditOpinion, String status) {
|
||||
try {
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo);
|
||||
String safeCardNo = cardNo == null ? null : cardNo.trim();
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(safeCardNo);
|
||||
if (dto == null) {
|
||||
return R.fail("报卡不存在");
|
||||
}
|
||||
|
||||
int rows = reportManageCardMapper.auditCard(cardNo, Integer.parseInt(status));
|
||||
Integer fromStatus = dto.getStatus();
|
||||
Integer toStatus = Integer.parseInt(status);
|
||||
int rows = reportManageCardMapper.auditCard(safeCardNo, Integer.parseInt(status));
|
||||
if (rows > 0) {
|
||||
// 单审核通过:auditType=2
|
||||
createAuditRecord(safeCardNo, fromStatus, toStatus, "2", auditOpinion, null, false, 1);
|
||||
return R.ok("审核成功");
|
||||
} else {
|
||||
return R.fail("审核失败:未更新任何记录");
|
||||
@@ -133,15 +179,21 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 退回结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> returnCard(String cardNo, String returnReason, String status) {
|
||||
try {
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo);
|
||||
String safeCardNo = cardNo == null ? null : cardNo.trim();
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(safeCardNo);
|
||||
if (dto == null) {
|
||||
return R.fail("报卡不存在");
|
||||
}
|
||||
|
||||
int rows = reportManageCardMapper.returnCard(cardNo, Integer.parseInt(status), returnReason);
|
||||
Integer fromStatus = dto.getStatus();
|
||||
Integer toStatus = Integer.parseInt(status);
|
||||
int rows = reportManageCardMapper.returnCard(safeCardNo, Integer.parseInt(status), returnReason);
|
||||
if (rows > 0) {
|
||||
// 单退回:auditType=4
|
||||
createAuditRecord(safeCardNo, fromStatus, toStatus, "4", null, returnReason, false, 1);
|
||||
return R.ok("退回成功");
|
||||
} else {
|
||||
return R.fail("退回失败:未更新任何记录");
|
||||
@@ -160,14 +212,27 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 批量审核结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> batchAudit(List<String> cardNos, String auditOpinion, String status) {
|
||||
try {
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
for (String cardNo : cardNos) {
|
||||
try {
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo);
|
||||
int rows = reportManageCardMapper.auditCard(cardNo, Integer.parseInt(status));
|
||||
if (rows > 0) {
|
||||
// 批量审核:auditType=1
|
||||
createAuditRecord(
|
||||
cardNo,
|
||||
dto != null ? dto.getStatus() : null,
|
||||
Integer.parseInt(status),
|
||||
"1",
|
||||
auditOpinion,
|
||||
null,
|
||||
true,
|
||||
cardNos.size()
|
||||
);
|
||||
successCount++;
|
||||
} else {
|
||||
failCount++;
|
||||
@@ -192,14 +257,27 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
* @return 批量退回结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> batchReturn(List<String> cardNos, String returnReason, String status) {
|
||||
try {
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
for (String cardNo : cardNos) {
|
||||
try {
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo);
|
||||
int rows = reportManageCardMapper.returnCard(cardNo, Integer.parseInt(status), returnReason);
|
||||
if (rows > 0) {
|
||||
// 批量退回:auditType=3
|
||||
createAuditRecord(
|
||||
cardNo,
|
||||
dto != null ? dto.getStatus() : null,
|
||||
Integer.parseInt(status),
|
||||
"3",
|
||||
null,
|
||||
returnReason,
|
||||
true,
|
||||
cardNos.size()
|
||||
);
|
||||
successCount++;
|
||||
} else {
|
||||
failCount++;
|
||||
@@ -276,6 +354,46 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
throw new RuntimeException("导出失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 撤销审核传染病报卡
|
||||
*
|
||||
* @param cardNo 报卡编号
|
||||
* @param status 撤销后的状态
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> revokeAudit(String cardNo, String status) {
|
||||
try {
|
||||
// 验证参数
|
||||
if (cardNo == null || cardNo.trim().isEmpty()) {
|
||||
return R.fail("报卡编号不能为空");
|
||||
}
|
||||
String safeCardNo = cardNo.trim();
|
||||
if (status == null || status.trim().isEmpty()) {
|
||||
return R.fail("撤销后的状态不能为空");
|
||||
}
|
||||
|
||||
InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(safeCardNo);
|
||||
Integer fromStatus = dto != null ? dto.getStatus() : null;
|
||||
Integer toStatus = Integer.parseInt(status);
|
||||
|
||||
// 执行撤销审核操作
|
||||
int rows = reportManageCardMapper.revokeAuditCard(safeCardNo, Integer.parseInt(status));
|
||||
|
||||
if (rows > 0) {
|
||||
// 撤销审核:auditType=5(其他)
|
||||
createAuditRecord(safeCardNo, fromStatus, toStatus, "5", "撤销审核", null, false, 1);
|
||||
return R.ok("撤销审核成功");
|
||||
} else {
|
||||
return R.fail("撤销审核失败:未找到对应的报卡");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("撤销审核传染病报卡失败", e);
|
||||
return R.fail("撤销审核失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CSV 字段转义
|
||||
@@ -379,6 +497,20 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getAuditRecords(String cardNo) {
|
||||
try {
|
||||
if (cardNo == null || cardNo.trim().isEmpty()) {
|
||||
return R.fail("报卡编号不能为空");
|
||||
}
|
||||
List<InfectiousAudit> records = infectiousAuditMapper.selectByCardId(cardNo);
|
||||
return R.ok(records);
|
||||
} catch (Exception e) {
|
||||
log.error("查询审核记录失败, cardNo={}", cardNo, e);
|
||||
return R.fail("查询审核记录失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建树形结构
|
||||
*/
|
||||
|
||||
@@ -7,13 +7,13 @@ import com.openhis.web.reportManagement.dto.AuditInfectiousCardRequest;
|
||||
import com.openhis.web.reportManagement.dto.ReturnInfectiousCardRequest;
|
||||
import com.openhis.web.reportManagement.dto.BatchAuditInfectiousCardRequest;
|
||||
import com.openhis.web.reportManagement.dto.BatchReturnInfectiousCardRequest;
|
||||
import com.openhis.web.reportManagement.dto.RevokeAuditInfectiousCardRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
// import java.util.List; // 批量操作功能暂未实现
|
||||
|
||||
/**
|
||||
* 传染病报卡管理 Controller
|
||||
@@ -31,11 +31,6 @@ public class reportManagementController {
|
||||
|
||||
/**
|
||||
* 分页查询传染病报卡列表
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 每页数量
|
||||
* @return 传染病报卡列表
|
||||
*/
|
||||
@GetMapping("/list-page")
|
||||
public R<?> listPage(InfectiousCardParam param,
|
||||
@@ -46,9 +41,6 @@ public class reportManagementController {
|
||||
|
||||
/**
|
||||
* 根据 ID 查询传染病报卡详情
|
||||
*
|
||||
* @param id 报卡 ID
|
||||
* @return 传染病报卡详情
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<?> getById(@PathVariable Long id) {
|
||||
@@ -57,20 +49,22 @@ public class reportManagementController {
|
||||
|
||||
/**
|
||||
* 根据卡号查询传染病报卡详情
|
||||
*
|
||||
* @param cardNo 报卡编号
|
||||
* @return 传染病报卡详情
|
||||
*/
|
||||
@GetMapping("/detail/{cardNo}")
|
||||
public R<?> getByCardNo(@PathVariable String cardNo) {
|
||||
return infectiousCardAppService.getByCardNo(cardNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询报卡审核记录(留痕追溯)
|
||||
*/
|
||||
@GetMapping("/auditRecords/{cardNo}")
|
||||
public R<?> getAuditRecords(@PathVariable String cardNo) {
|
||||
return infectiousCardAppService.getAuditRecords(cardNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核传染病报卡
|
||||
*
|
||||
* @param request 审核请求
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/audit")
|
||||
public R<?> audit(@RequestBody AuditInfectiousCardRequest request) {
|
||||
@@ -79,9 +73,6 @@ public class reportManagementController {
|
||||
|
||||
/**
|
||||
* 退回传染病报卡
|
||||
*
|
||||
* @param request 退回请求
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/return")
|
||||
public R<?> returnCard(@Valid @RequestBody ReturnInfectiousCardRequest request) {
|
||||
@@ -90,9 +81,6 @@ public class reportManagementController {
|
||||
|
||||
/**
|
||||
* 批量审核传染病报卡
|
||||
*
|
||||
* @param request 批量审核请求
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/batchAudit")
|
||||
public R<?> batchAudit(@RequestBody BatchAuditInfectiousCardRequest request) {
|
||||
@@ -101,9 +89,6 @@ public class reportManagementController {
|
||||
|
||||
/**
|
||||
* 批量退回传染病报卡
|
||||
*
|
||||
* @param request 批量退回请求
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/batchReturn")
|
||||
public R<?> batchReturn(@Valid @RequestBody BatchReturnInfectiousCardRequest request) {
|
||||
@@ -111,10 +96,18 @@ public class reportManagementController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出传染病报卡
|
||||
* 撤销审核传染病报卡(Bug #395)
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @param response 响应对象
|
||||
* @param request 撤销审核请求
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/revokeAudit")
|
||||
public R<?> revokeAudit(@Valid @RequestBody RevokeAuditInfectiousCardRequest request) {
|
||||
return infectiousCardAppService.revokeAudit(request.getCardNo(), request.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出传染病报卡
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public void export(InfectiousCardParam param, HttpServletResponse response) {
|
||||
@@ -123,8 +116,6 @@ public class reportManagementController {
|
||||
|
||||
/**
|
||||
* 获取科室树
|
||||
*
|
||||
* @return 科室树数据
|
||||
*/
|
||||
@GetMapping("/dept-tree")
|
||||
public R<?> getDeptTree() {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.openhis.web.reportManagement.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 撤销审核传染病报卡请求 DTO
|
||||
*
|
||||
* @author guanyu
|
||||
* @date 2026-04-23
|
||||
*/
|
||||
@Data
|
||||
public class RevokeAuditInfectiousCardRequest {
|
||||
|
||||
/** 卡片编号(主键) */
|
||||
private String cardNo;
|
||||
|
||||
/** 撤销后的状态 (0 暂存/1 待审核/2 已审核/3 已上报/4 失败/5 退回) */
|
||||
private String status;
|
||||
|
||||
}
|
||||
@@ -55,5 +55,12 @@ public interface ReportManageCardMapper {
|
||||
* @param param 查询参数
|
||||
* @return 报卡列表
|
||||
*/
|
||||
/**
|
||||
* 撤销审核传染病报卡
|
||||
* @param cardNo 卡号
|
||||
* @param status 撤销后的状态
|
||||
* @return 影响行数
|
||||
*/
|
||||
int revokeAuditCard(@Param("cardNo") String cardNo, @Param("status") Integer status);
|
||||
List<InfectiousCardDto> selectAllCards(@Param("param") InfectiousCardParam param);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.openhis.web.reportmanage.dto;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
@@ -12,7 +13,8 @@ import java.math.BigDecimal;
|
||||
* @author yuxj
|
||||
* @date 2025/8/25
|
||||
*/
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
public class InpatientMedicalRecordHomePageCollectionDto {
|
||||
|
||||
|
||||
@@ -3,35 +3,45 @@ package com.openhis.web.triageandqueuemanage.appservice.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.triageandqueuemanage.domain.TriageQueueItem;
|
||||
import com.openhis.administration.domain.Encounter;
|
||||
import com.openhis.administration.mapper.EncounterMapper;
|
||||
import com.openhis.common.enums.EncounterStatus;
|
||||
import com.openhis.common.enums.EncounterSubjectStatus;
|
||||
import com.openhis.common.enums.TriageQueueStatus;
|
||||
import com.openhis.triageandqueuemanage.domain.CallRecord;
|
||||
import com.openhis.triageandqueuemanage.domain.DivLog;
|
||||
import com.openhis.triageandqueuemanage.domain.TriageCandidateExclusion;
|
||||
import com.openhis.triageandqueuemanage.service.TriageQueueItemService;
|
||||
import com.openhis.triageandqueuemanage.domain.TriageQueueItem;
|
||||
import com.openhis.triageandqueuemanage.service.CallRecordService;
|
||||
import com.openhis.triageandqueuemanage.service.DivLogService;
|
||||
import com.openhis.triageandqueuemanage.service.TriageCandidateExclusionService;
|
||||
import com.openhis.triageandqueuemanage.service.TriageQueueItemService;
|
||||
import com.openhis.appointmentmanage.domain.ScheduleSlot;
|
||||
import com.openhis.appointmentmanage.mapper.ScheduleSlotMapper;
|
||||
import com.openhis.common.enums.CallType;
|
||||
import com.openhis.web.triageandqueuemanage.appservice.TriageQueueAppService;
|
||||
import com.openhis.web.triageandqueuemanage.dto.CallNumberDisplayResp;
|
||||
import com.openhis.web.triageandqueuemanage.dto.TriageQueueActionReq;
|
||||
import com.openhis.web.triageandqueuemanage.dto.TriageQueueAddReq;
|
||||
import com.openhis.web.triageandqueuemanage.dto.TriageQueueAdjustReq;
|
||||
import com.openhis.web.triageandqueuemanage.dto.TriageQueueEncounterItem;
|
||||
import com.openhis.web.triageandqueuemanage.dto.*;
|
||||
import com.openhis.web.triageandqueuemanage.sse.CallNumberSseManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import com.core.common.core.domain.model.LoginUser;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
|
||||
private static final String STATUS_WAITING = "WAITING";
|
||||
private static final String STATUS_CALLING = "CALLING";
|
||||
private static final String STATUS_SKIPPED = "SKIPPED";
|
||||
private static final String STATUS_COMPLETED = "COMPLETED";
|
||||
// 状态常量已迁移至 TriageQueueStatus 枚举,原硬编码 STATU_WAITING/STATU_CALLING 等已删除,
|
||||
// 避免散落在多个 Service 类中的魔法数字造成不一致
|
||||
|
||||
@Resource
|
||||
private TriageQueueItemService triageQueueItemService;
|
||||
@@ -42,6 +52,18 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
@Resource
|
||||
private TriageCandidateExclusionService triageCandidateExclusionService;
|
||||
|
||||
@Resource
|
||||
private DivLogService divLogService;
|
||||
|
||||
@Resource
|
||||
private CallRecordService callRecordService;
|
||||
|
||||
@Resource
|
||||
private ScheduleSlotMapper scheduleSlotMapper;
|
||||
|
||||
@Resource
|
||||
private EncounterMapper encounterMapper;
|
||||
|
||||
@Override
|
||||
public R<?> list(Long organizationId, LocalDate date) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
@@ -52,7 +74,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getQueueDate, qd)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.ne(TriageQueueItem::getStatus, STATUS_COMPLETED)
|
||||
.ne(TriageQueueItem::getStatus, TriageQueueStatus.COMPLETED.getValue())
|
||||
.orderByAsc(TriageQueueItem::getQueueOrder);
|
||||
|
||||
// 如果指定了科室,按科室过滤;否则查询所有科室(全科模式)
|
||||
@@ -61,31 +83,33 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
}
|
||||
|
||||
List<TriageQueueItem> list = triageQueueItemService.list(wrapper);
|
||||
// 通过 slotId 查询 seqNo 并填充到返回结果中(用于选呼显示预约号)
|
||||
if (list != null && !list.isEmpty()) {
|
||||
Map<Long, Integer> seqNoMap = buildSlotSeqNoMap(list);
|
||||
list.forEach(item -> {
|
||||
if (item.getSlotId() != null && seqNoMap.containsKey(item.getSlotId())) {
|
||||
item.setSeqNo(seqNoMap.get(item.getSlotId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 双重保险:再次过滤掉 COMPLETED 状态的患者(防止数据库中有异常数据)
|
||||
if (list != null && !list.isEmpty()) {
|
||||
int beforeSize = list.size();
|
||||
list = list.stream()
|
||||
.filter(item -> !STATUS_COMPLETED.equals(item.getStatus()))
|
||||
.filter(item -> !TriageQueueStatus.COMPLETED.getValue().equals(item.getStatus()))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
if (beforeSize != list.size()) {
|
||||
System.out.println(">>> [TriageQueue] list() 警告:过滤掉了 " + (beforeSize - list.size()) + " 条 COMPLETED 状态的记录");
|
||||
}
|
||||
}
|
||||
|
||||
// 调试日志:检查状态值
|
||||
if (list != null && !list.isEmpty()) {
|
||||
System.out.println(">>> [TriageQueue] list() 返回 " + list.size() + " 条记录(已排除 COMPLETED)");
|
||||
for (int i = 0; i < Math.min(3, list.size()); i++) {
|
||||
TriageQueueItem item = list.get(i);
|
||||
System.out.println(" [" + i + "] patientName=" + item.getPatientName()
|
||||
+ ", status=" + item.getStatus()
|
||||
+ ", organizationId=" + item.getOrganizationId());
|
||||
}
|
||||
}
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将候选池患者的挂号移入队列操作
|
||||
* 并同时写入移入队列操作日志
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> add(TriageQueueAddReq req) {
|
||||
@@ -105,7 +129,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
.eq(TriageQueueItem::getOrganizationId, orgId)
|
||||
.eq(TriageQueueItem::getQueueDate, qd)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.ne(TriageQueueItem::getStatus, STATUS_COMPLETED));
|
||||
.ne(TriageQueueItem::getStatus, TriageQueueStatus.COMPLETED.getValue()));
|
||||
|
||||
int maxOrder = existing.stream().map(TriageQueueItem::getQueueOrder).filter(Objects::nonNull).max(Integer::compareTo).orElse(0);
|
||||
|
||||
@@ -127,14 +151,18 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
.setPractitionerName(it.getPractitionerName())
|
||||
.setPractitionerId(it.getPractitionerId()) // ✅ 新增字段(可选)
|
||||
.setRoomNo(it.getRoomNo()) // ✅ 新增字段(可选)
|
||||
.setStatus(STATUS_WAITING)
|
||||
.setPoolId(it.getPoolId()) // ✅ 号源池ID(用于div_log审计)
|
||||
.setSlotId(it.getSlotId()) // ✅ 号源槽位ID(用于div_log审计)
|
||||
.setSeqNo(it.getSeqNo()) // ✅ 预约序号(用于叫号显示)
|
||||
.setStatus(TriageQueueStatus.WAITING.getValue())
|
||||
.setQueueOrder(++maxOrder)
|
||||
.setDeleteFlag("0")
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
triageQueueItemService.save(qi);
|
||||
|
||||
// 写入分诊日志
|
||||
writeDivLog(it.getPoolId(), it.getSlotId(), "ADD_QUEUE");
|
||||
// 记录到候选池排除列表(避免刷新后重新出现在候选池)
|
||||
TriageCandidateExclusion exclusion = triageCandidateExclusionService.getOne(
|
||||
new LambdaQueryWrapper<TriageCandidateExclusion>()
|
||||
@@ -165,17 +193,26 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
return R.ok(added);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除队列操作并同时写入移除操作日志
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> remove(Long id) {
|
||||
if (id == null) return R.fail("id 不能为空");
|
||||
TriageQueueItem item = triageQueueItemService.getById(id);
|
||||
if (item == null) return R.fail("队列项不存在");
|
||||
|
||||
if (item.getStatus() != null && item.getStatus() != 0) {
|
||||
return R.fail("仅等待状态的患者可移出队列,当前状态码:" + item.getStatus());
|
||||
}
|
||||
// 逻辑删除队列项
|
||||
item.setDeleteFlag("1").setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(item);
|
||||
|
||||
// 写入分诊日志
|
||||
writeDivLog(item.getPoolId(), item.getSlotId(), "REMOVE_QUEUE");
|
||||
// 从排除列表中删除记录,使患者重新出现在候选池中
|
||||
Integer tenantId = item.getTenantId();
|
||||
LocalDate exclusionDate = item.getQueueDate();
|
||||
@@ -233,6 +270,12 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能分诊选呼功能,在进行选呼操作时同时写入叫号记录和选呼操作日志
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> call(TriageQueueActionReq req) {
|
||||
@@ -241,15 +284,17 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
if (selected == null) return R.fail("队列项不存在");
|
||||
|
||||
// 只将"等待"状态的患者转为"叫号中",允许有多个"叫号中"的患者
|
||||
if (STATUS_WAITING.equals(selected.getStatus())) {
|
||||
selected.setStatus(STATUS_CALLING).setUpdateTime(LocalDateTime.now());
|
||||
if (TriageQueueStatus.WAITING.getValue().equals(selected.getStatus())) {
|
||||
selected.setStatus(TriageQueueStatus.CALLING.getValue()).setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(selected);
|
||||
|
||||
// 叫号后推送 SSE 消息(实时通知显示屏刷新)
|
||||
pushDisplayUpdate(selected.getOrganizationId(), selected.getQueueDate(), selected.getTenantId());
|
||||
|
||||
// 写入分诊日志和叫号记录
|
||||
writeDivLog(selected.getPoolId(), selected.getSlotId(), "CALL");
|
||||
writeCallRecord(selected.getId(), selected.getPractitionerId(), CallType.CALL, selected.getRoomNo());
|
||||
return R.ok(true);
|
||||
} else if (STATUS_CALLING.equals(selected.getStatus())) {
|
||||
} else if (TriageQueueStatus.CALLING.getValue().equals(selected.getStatus())) {
|
||||
// 如果已经是"叫号中"状态,直接返回成功(不做任何操作)
|
||||
return R.ok(true);
|
||||
} else {
|
||||
@@ -258,6 +303,13 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能分诊完成操作
|
||||
* 在进行完成操作后同时写入叫号记录和完成操作日志
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> complete(TriageQueueActionReq req) {
|
||||
@@ -271,18 +323,17 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
return R.fail("队列项不存在");
|
||||
}
|
||||
// 验证状态
|
||||
if (!STATUS_CALLING.equals(calling.getStatus())) {
|
||||
if (!TriageQueueStatus.CALLING.getValue().equals(calling.getStatus())) {
|
||||
return R.fail("只能完成\"叫号中\"状态的患者,当前患者状态为:" + calling.getStatus());
|
||||
}
|
||||
} else {
|
||||
// 如果没有提供 id,通过查询条件查找(兼容旧逻辑)
|
||||
Long orgId = req != null && req.getOrganizationId() != null ? req.getOrganizationId() : null;
|
||||
System.out.println(">>> [TriageQueue] complete() 开始执行(不限制日期,通过查询条件), tenantId=" + tenantId + ", orgId=" + orgId);
|
||||
|
||||
LambdaQueryWrapper<TriageQueueItem> callingWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.eq(TriageQueueItem::getStatus, STATUS_CALLING)
|
||||
.eq(TriageQueueItem::getStatus, TriageQueueStatus.CALLING.getValue())
|
||||
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||
.last("LIMIT 1");
|
||||
|
||||
@@ -292,8 +343,6 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
|
||||
calling = triageQueueItemService.getOne(callingWrapper, false);
|
||||
|
||||
System.out.println(">>> [TriageQueue] complete() 查询叫号中患者(不限制日期): orgId=" + orgId + ", 结果=" + (calling != null ? calling.getPatientName() + "(status=" + calling.getStatus() + ", queueDate=" + calling.getQueueDate() + ")" : "null"));
|
||||
|
||||
if (calling == null) {
|
||||
return R.fail("当前没有叫号中的患者");
|
||||
}
|
||||
@@ -303,16 +352,33 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
Long actualOrgId = calling.getOrganizationId();
|
||||
|
||||
// 1) 叫号中 -> 完成(移出列表)
|
||||
calling.setStatus(STATUS_COMPLETED).setUpdateTime(LocalDateTime.now());
|
||||
calling.setStatus(TriageQueueStatus.COMPLETED.getValue()).setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(calling);
|
||||
|
||||
// 同步更新就诊状态为诊毕
|
||||
// 分诊台完诊原只更新队列状态,未同步encounter表,导致与医生站完诊行为不一致
|
||||
if (calling.getEncounterId() != null) {
|
||||
try {
|
||||
java.util.Date now = new java.util.Date();
|
||||
encounterMapper.update(null,
|
||||
new LambdaUpdateWrapper<Encounter>()
|
||||
.eq(Encounter::getId, calling.getEncounterId())
|
||||
.set(Encounter::getStatusEnum, EncounterStatus.DISCHARGED.getValue())
|
||||
.set(Encounter::getSubjectStatusEnum, EncounterSubjectStatus.DEPARTED.getValue())
|
||||
.set(Encounter::getEndTime, now)
|
||||
.set(Encounter::getUpdateTime, now));
|
||||
} catch (Exception e) {
|
||||
log.error("更新就诊状态为诊毕失败, encounterId={}", calling.getEncounterId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// 2) 自动推进下一个等待为叫号中(同一科室,包含跳过状态,不限制日期)
|
||||
LambdaQueryWrapper<TriageQueueItem> nextWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.and(w -> w.eq(TriageQueueItem::getStatus, STATUS_WAITING)
|
||||
.and(w -> w.eq(TriageQueueItem::getStatus, TriageQueueStatus.WAITING.getValue())
|
||||
.or()
|
||||
.eq(TriageQueueItem::getStatus, STATUS_SKIPPED))
|
||||
.eq(TriageQueueItem::getStatus, TriageQueueStatus.SKIPPED.getValue()))
|
||||
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||
.last("LIMIT 1");
|
||||
|
||||
@@ -323,10 +389,8 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
|
||||
TriageQueueItem next = triageQueueItemService.getOne(nextWrapper, false);
|
||||
|
||||
System.out.println(">>> [TriageQueue] complete() 查询等待患者(不限制日期): actualOrgId=" + actualOrgId + ", 结果=" + (next != null ? next.getPatientName() + "(status=" + next.getStatus() + ")" : "null"));
|
||||
|
||||
if (next != null) {
|
||||
next.setStatus(STATUS_CALLING).setUpdateTime(LocalDateTime.now());
|
||||
next.setStatus(TriageQueueStatus.CALLING.getValue()).setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(next);
|
||||
}
|
||||
|
||||
@@ -334,25 +398,54 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
|
||||
// 完成后推送 SSE 消息(实时通知显示屏刷新)
|
||||
pushDisplayUpdate(actualOrgId, calling.getQueueDate(), tenantId);
|
||||
|
||||
// 写入分诊日志和叫号记录
|
||||
writeDivLog(calling.getPoolId(), calling.getSlotId(), "COMPLETE");
|
||||
writeCallRecord(calling.getId(), calling.getPractitionerId(), CallType.COMPLETE, calling.getRoomNo());
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能队列重排序功能操作单元
|
||||
* 在进行队列重排序时同时在div_log表中写入重排序日志和叫号记录
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> requeue(TriageQueueActionReq req) {
|
||||
return doRequeue(req, "REQUEUE");
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能分诊跳过功能操作单元内部包含将队列正在叫号状态的号进行跳过
|
||||
* 同时将跳过操作日志写入div_log表中,以及写入叫号记录表。
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> skip(TriageQueueActionReq req) {
|
||||
// 当前业务"跳过"按"过号重排"处理:叫号中 -> 跳过并移到末尾,自动推进下一等待
|
||||
return doRequeue(req, "SKIP");
|
||||
}
|
||||
|
||||
/**
|
||||
* 过号重排/跳过的核心逻辑
|
||||
* @param action 日志动作:REQUEUE 或 SKIP
|
||||
*/
|
||||
private R<?> doRequeue(TriageQueueActionReq req, String action) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
TriageQueueItem calling = null;
|
||||
|
||||
|
||||
if (req != null && req.getId() != null) {
|
||||
calling = triageQueueItemService.getById(req.getId());
|
||||
if (calling == null) {
|
||||
return R.fail("队列项不存在");
|
||||
}
|
||||
// 验证状态
|
||||
if (!STATUS_CALLING.equals(calling.getStatus())) {
|
||||
return R.fail("只能对\"叫号中\"状态的患者进行过号重排,当前患者状态为:" + calling.getStatus());
|
||||
if (!TriageQueueStatus.CALLING.getValue().equals(calling.getStatus())) {
|
||||
return R.fail("只能对\"叫号中\"状态的患者进行" + ("SKIP".equals(action) ? "跳过" : "过号重排") + ",当前患者状态为:" + calling.getStatus());
|
||||
}
|
||||
} else {
|
||||
// 如果没有提供 id,通过查询条件查找(兼容旧逻辑)
|
||||
@@ -361,7 +454,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
LambdaQueryWrapper<TriageQueueItem> callingWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.eq(TriageQueueItem::getStatus, STATUS_CALLING)
|
||||
.eq(TriageQueueItem::getStatus, TriageQueueStatus.CALLING.getValue())
|
||||
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||
.last("LIMIT 1");
|
||||
|
||||
@@ -377,32 +470,23 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
// 使用实际找到的科室ID
|
||||
Long actualOrgId = calling.getOrganizationId();
|
||||
|
||||
// 关键改进:在执行"跳过"操作之前,先检查是否有等待中的患者(判断队列状态)
|
||||
// 如果没有等待中的患者,就不应该执行"过号重排"操作
|
||||
// 关键改进:在执行跳过/重排操作之前,先检查是否有等待中的患者(判断队列状态)
|
||||
LambdaQueryWrapper<TriageQueueItem> nextWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.and(w -> w.eq(TriageQueueItem::getStatus, STATUS_WAITING)
|
||||
.and(w -> w.eq(TriageQueueItem::getStatus, TriageQueueStatus.WAITING.getValue())
|
||||
.or()
|
||||
.eq(TriageQueueItem::getStatus, STATUS_SKIPPED))
|
||||
.eq(TriageQueueItem::getStatus, TriageQueueStatus.SKIPPED.getValue()))
|
||||
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||
.last("LIMIT 1");
|
||||
|
||||
// 如果指定了科室ID,则按科室过滤;否则查询所有科室(全科模式)
|
||||
if (actualOrgId != null) {
|
||||
nextWrapper.eq(TriageQueueItem::getOrganizationId, actualOrgId);
|
||||
}
|
||||
|
||||
TriageQueueItem next = triageQueueItemService.getOne(nextWrapper, false);
|
||||
|
||||
// 调试日志:检查查询结果
|
||||
System.out.println(">>> [TriageQueue] requeue() 查询等待中的患者:");
|
||||
System.out.println(">>> - 科室ID: " + actualOrgId);
|
||||
System.out.println(">>> - 找到的等待患者: " + (next != null ? next.getPatientName() + " (状态: " + next.getStatus() + ")" : "null"));
|
||||
|
||||
// 如果找不到等待中的患者,直接返回失败(不执行跳过操作)
|
||||
if (next == null) {
|
||||
System.out.println(">>> [TriageQueue] requeue() 失败:没有等待中的患者");
|
||||
return R.fail("当前没有等待中的患者");
|
||||
}
|
||||
|
||||
@@ -411,7 +495,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getOrganizationId, actualOrgId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.ne(TriageQueueItem::getStatus, STATUS_COMPLETED))
|
||||
.ne(TriageQueueItem::getStatus, TriageQueueStatus.COMPLETED.getValue()))
|
||||
.stream()
|
||||
.map(TriageQueueItem::getQueueOrder)
|
||||
.filter(Objects::nonNull)
|
||||
@@ -419,36 +503,29 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
.orElse(0);
|
||||
|
||||
// 1) 叫号中 -> 跳过,并移到末尾
|
||||
calling.setStatus(STATUS_SKIPPED).setQueueOrder(maxOrder + 1).setUpdateTime(LocalDateTime.now());
|
||||
calling.setStatus(TriageQueueStatus.SKIPPED.getValue()).setQueueOrder(maxOrder + 1).setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(calling);
|
||||
|
||||
// 2) 自动推进下一个等待为叫号中
|
||||
next.setStatus(STATUS_CALLING).setUpdateTime(LocalDateTime.now());
|
||||
next.setStatus(TriageQueueStatus.CALLING.getValue()).setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(next);
|
||||
|
||||
recalcOrders(actualOrgId, null);
|
||||
|
||||
// ✅ 过号重排后推送 SSE 消息(实时通知显示屏刷新)
|
||||
// 推送 SSE 消息
|
||||
pushDisplayUpdate(actualOrgId, calling.getQueueDate(), tenantId);
|
||||
|
||||
// 写入分诊日志和叫号记录
|
||||
writeDivLog(calling.getPoolId(), calling.getSlotId(), action);
|
||||
writeCallRecord(calling.getId(), calling.getPractitionerId(),
|
||||
"SKIP".equals(action) ? CallType.SKIP : CallType.REQUEUE, calling.getRoomNo());
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> skip(TriageQueueActionReq req) {
|
||||
// 当前业务“跳过”按“过号重排”处理:叫号中 -> 跳过并移到末尾,自动推进下一等待
|
||||
return requeue(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> next(TriageQueueActionReq req) {
|
||||
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||
TriageQueueItem calling = null;
|
||||
|
||||
System.out.println(">>> [TriageQueue] next() 开始执行(不限制日期), tenantId=" + tenantId);
|
||||
|
||||
// 关键改进:如果提供了 id,优先使用 id 直接查找(像 call 方法一样)
|
||||
if (req != null && req.getId() != null) {
|
||||
calling = triageQueueItemService.getById(req.getId());
|
||||
@@ -456,7 +533,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
return R.fail("队列项不存在");
|
||||
}
|
||||
// 验证状态:必须是"叫号中"状态
|
||||
if (!STATUS_CALLING.equals(calling.getStatus())) {
|
||||
if (!TriageQueueStatus.CALLING.getValue().equals(calling.getStatus())) {
|
||||
return R.fail("只能对\"叫号中\"状态的患者执行\"下一患者\"操作,当前患者状态为:" + calling.getStatus());
|
||||
}
|
||||
} else {
|
||||
@@ -466,7 +543,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
LambdaQueryWrapper<TriageQueueItem> callingWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.eq(TriageQueueItem::getStatus, STATUS_CALLING)
|
||||
.eq(TriageQueueItem::getStatus, TriageQueueStatus.CALLING.getValue())
|
||||
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||
.last("LIMIT 1");
|
||||
|
||||
@@ -481,7 +558,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
|
||||
// 当前叫号中 -> 完成(如果不存在,就当作从头找第一位等待)
|
||||
if (calling != null) {
|
||||
calling.setStatus(STATUS_COMPLETED).setUpdateTime(LocalDateTime.now());
|
||||
calling.setStatus(TriageQueueStatus.COMPLETED.getValue()).setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(calling);
|
||||
actualOrgId = calling.getOrganizationId(); // 使用叫号中患者所在的科室
|
||||
} else {
|
||||
@@ -496,9 +573,9 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
LambdaQueryWrapper<TriageQueueItem> nextWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.and(w -> w.eq(TriageQueueItem::getStatus, STATUS_WAITING)
|
||||
.and(w -> w.eq(TriageQueueItem::getStatus, TriageQueueStatus.WAITING.getValue())
|
||||
.or()
|
||||
.eq(TriageQueueItem::getStatus, STATUS_SKIPPED))
|
||||
.eq(TriageQueueItem::getStatus, TriageQueueStatus.SKIPPED.getValue()))
|
||||
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||
.last("LIMIT 1");
|
||||
|
||||
@@ -508,14 +585,6 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
|
||||
TriageQueueItem next = triageQueueItemService.getOne(nextWrapper, false);
|
||||
|
||||
// 调试日志:打印查询条件和结果
|
||||
System.out.println(">>> [TriageQueue] next() 查询条件(不限制日期): tenantId=" + tenantId
|
||||
+ ", actualOrgId=" + actualOrgId
|
||||
+ ", deleteFlag=0"
|
||||
+ ", status IN (WAITING, SKIPPED)");
|
||||
System.out.println(">>> [TriageQueue] next() 查询结果: calling=" + (calling != null ? calling.getPatientName() + "(status=" + calling.getStatus() + ", queueDate=" + calling.getQueueDate() + ")" : "null")
|
||||
+ ", next=" + (next != null ? next.getPatientName() + "(status=" + next.getStatus() + ", queueDate=" + next.getQueueDate() + ")" : "null"));
|
||||
|
||||
if (next == null) {
|
||||
if (actualOrgId != null) {
|
||||
recalcOrders(actualOrgId, null);
|
||||
@@ -523,12 +592,19 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
return R.fail("当前没有等待的患者");
|
||||
}
|
||||
|
||||
next.setStatus(STATUS_CALLING).setUpdateTime(LocalDateTime.now());
|
||||
next.setStatus(TriageQueueStatus.CALLING.getValue()).setUpdateTime(LocalDateTime.now());
|
||||
triageQueueItemService.updateById(next);
|
||||
|
||||
if (next.getOrganizationId() != null) {
|
||||
recalcOrders(next.getOrganizationId(), null);
|
||||
}
|
||||
|
||||
// 写入叫号记录
|
||||
if (calling != null) {
|
||||
writeCallRecord(calling.getId(), calling.getPractitionerId(), CallType.NEXT, calling.getRoomNo());
|
||||
}
|
||||
writeCallRecord(next.getId(), next.getPractitionerId(), CallType.NEXT, next.getRoomNo());
|
||||
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@@ -538,7 +614,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.eq(TriageQueueItem::getOrganizationId, orgId)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.ne(TriageQueueItem::getStatus, STATUS_COMPLETED);
|
||||
.ne(TriageQueueItem::getStatus, TriageQueueStatus.COMPLETED.getValue());
|
||||
// 如果 qd 不为 null,才添加日期限制
|
||||
if (qd != null) {
|
||||
wrapper.eq(TriageQueueItem::getQueueDate, qd);
|
||||
@@ -553,7 +629,7 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
.eq(TriageQueueItem::getOrganizationId, orgId)
|
||||
.eq(TriageQueueItem::getQueueDate, qd)
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.eq(TriageQueueItem::getStatus, STATUS_CALLING)
|
||||
.eq(TriageQueueItem::getStatus, TriageQueueStatus.CALLING.getValue())
|
||||
.last("LIMIT 1"), false);
|
||||
}
|
||||
|
||||
@@ -598,11 +674,14 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
.eq(TriageQueueItem::getQueueDate, qd)
|
||||
.eq(TriageQueueItem::getOrganizationId, organizationId)
|
||||
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||
.in(TriageQueueItem::getStatus, STATUS_WAITING, STATUS_CALLING)
|
||||
.in(TriageQueueItem::getStatus, TriageQueueStatus.WAITING.getValue(), TriageQueueStatus.CALLING.getValue())
|
||||
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||
);
|
||||
|
||||
// 通过 slotId 批量查询 seqNo(方案 B:不修改 triage_queue_item 表结构)
|
||||
Map<Long, Integer> slotSeqNoMap = buildSlotSeqNoMap(allItems);
|
||||
|
||||
CallNumberDisplayResp resp = new CallNumberDisplayResp();
|
||||
|
||||
// 1. 获取科室名称(从第一条数据中取)
|
||||
@@ -614,13 +693,14 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
|
||||
// 2. 查找当前叫号中的患者(CALLING 状态)
|
||||
TriageQueueItem callingItem = allItems.stream()
|
||||
.filter(item -> STATUS_CALLING.equals(item.getStatus()))
|
||||
.filter(item -> TriageQueueStatus.CALLING.getValue().equals(item.getStatus()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (callingItem != null) {
|
||||
CallNumberDisplayResp.CurrentCallInfo currentCall = new CallNumberDisplayResp.CurrentCallInfo();
|
||||
currentCall.setNumber(callingItem.getQueueOrder());
|
||||
Integer displayNo = resolveDisplayNumber(callingItem, slotSeqNoMap);
|
||||
currentCall.setNumber(displayNo);
|
||||
currentCall.setName(maskPatientName(callingItem.getPatientName()));
|
||||
currentCall.setRoom(callingItem.getRoomNo() != null ? callingItem.getRoomNo() : "1号");
|
||||
currentCall.setDoctor(callingItem.getPractitionerName());
|
||||
@@ -674,11 +754,11 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
patient.setId(item.getId());
|
||||
patient.setName(maskPatientName(item.getPatientName()));
|
||||
patient.setStatus(item.getStatus());
|
||||
patient.setQueueOrder(item.getQueueOrder());
|
||||
patient.setQueueOrder(resolveDisplayNumber(item, slotSeqNoMap));
|
||||
patients.add(patient);
|
||||
|
||||
// 统计等待人数(不包括 CALLING 状态)
|
||||
if (STATUS_WAITING.equals(item.getStatus())) {
|
||||
if (TriageQueueStatus.WAITING.getValue().equals(item.getStatus())) {
|
||||
totalWaiting++;
|
||||
}
|
||||
}
|
||||
@@ -742,6 +822,82 @@ public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||
System.err.println("推送显示屏更新失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入分诊操作日志
|
||||
*
|
||||
* @param poolId 号源池ID
|
||||
* @param slotId 号源槽位ID
|
||||
* @param action 操作动作:ADD_QUEUE/REMOVE_QUEUE/CALL/COMPLETE/SKIP/REQUEUE
|
||||
*/
|
||||
private void writeDivLog(Long poolId, Long slotId, String action) {
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
DivLog log = new DivLog()
|
||||
.setPoolId(poolId)
|
||||
.setSlotId(slotId)
|
||||
.setOpUserId(loginUser != null ? loginUser.getUserId() : null)
|
||||
.setAction(action)
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setUpdateAt(LocalDateTime.now())
|
||||
.setCreatedAt(LocalDateTime.now());
|
||||
divLogService.save(log);
|
||||
} catch (Exception e) {
|
||||
log.error("写入分诊日志失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入叫号记录
|
||||
*
|
||||
* @param queueId 队列ID
|
||||
* @param doctorId 医生ID
|
||||
* @param callType 叫号类型枚举
|
||||
* @param room 诊室号
|
||||
*/
|
||||
private void writeCallRecord(Long queueId, Long doctorId, CallType callType, String room) {
|
||||
try {
|
||||
CallRecord record = new CallRecord()
|
||||
.setQueueId(queueId)
|
||||
.setDoctorId(doctorId)
|
||||
.setCallTime(LocalDateTime.now())
|
||||
.setCallType(callType.getValue().toString())
|
||||
.setRoom(room)
|
||||
.setCreateAt(LocalDateTime.now());
|
||||
callRecordService.save(record);
|
||||
} catch (Exception e) {
|
||||
log.error("写入叫号记录失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 slotId 批量查询 seqNo,返回 slotId -> seqNo 映射
|
||||
*/
|
||||
private Map<Long, Integer> buildSlotSeqNoMap(List<TriageQueueItem> items) {
|
||||
List<Long> slotIds = items.stream()
|
||||
.map(TriageQueueItem::getSlotId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (slotIds.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<ScheduleSlot> slots = scheduleSlotMapper.selectSeqNoBySlotIds(slotIds);
|
||||
return slots.stream()
|
||||
.filter(s -> s.getId() != null && s.getSeqNo() != null)
|
||||
.collect(Collectors.toMap(ScheduleSlot::getId, ScheduleSlot::getSeqNo, (a, b) -> a));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算患者在叫号显示屏上应显示的号码:优先 seqNo(预约序号),否则 queueOrder(排队号)
|
||||
*/
|
||||
private Integer resolveDisplayNumber(TriageQueueItem item, Map<Long, Integer> slotSeqNoMap) {
|
||||
if (item == null) return null;
|
||||
if (item.getSlotId() != null && slotSeqNoMap.containsKey(item.getSlotId())) {
|
||||
return slotSeqNoMap.get(item.getSlotId());
|
||||
}
|
||||
return item.getQueueOrder();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CallNumberDisplayResp {
|
||||
/** 患者姓名(脱敏) */
|
||||
private String name;
|
||||
/** 状态:CALLING=就诊中,WAITING=等待 */
|
||||
private String status;
|
||||
private Integer status;
|
||||
/** 排队号 */
|
||||
private Integer queueOrder;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,12 @@ public class TriageQueueEncounterItem {
|
||||
private Long practitionerId;
|
||||
/** 诊室号(可选) */
|
||||
private String roomNo;
|
||||
/** 号源池ID(关联 adm_schedule_pool.id,用于 div_log 审计日志) */
|
||||
private Long poolId;
|
||||
/** 号源槽位ID(关联 adm_schedule_slot.id,用于 div_log 审计日志) */
|
||||
private Long slotId;
|
||||
/** 预约序号(来自 adm_schedule_slot.seq_no,用于叫号显示) */
|
||||
private Integer seqNo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ core:
|
||||
# 名称
|
||||
name: HEALTHLINK-HIS
|
||||
# 版本
|
||||
version: 0.0.1
|
||||
version: ${CORE_VERSION:0.0.1}
|
||||
# 版权年份
|
||||
copyrightYear: 2025
|
||||
# 文件路径
|
||||
|
||||
@@ -76,6 +76,8 @@
|
||||
T1.quantity_unit,
|
||||
T1.unit_price,
|
||||
T1.total_price,
|
||||
T1.generate_source_enum,
|
||||
T1.prescription_no AS source_bill_no,
|
||||
mmr.prescription_no,
|
||||
mmr.method_code AS method_code,
|
||||
mmr.rate_code,
|
||||
@@ -94,18 +96,21 @@
|
||||
T8.contract_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.surgery_name
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = #{activity} THEN T2."name"
|
||||
WHEN T1.context_enum = #{medication} THEN T3."name"
|
||||
WHEN T1.context_enum = #{device} THEN T4."name"
|
||||
END AS item_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN NULL
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL
|
||||
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
||||
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
||||
WHEN T1.context_enum = #{device} THEN T4.yb_no
|
||||
END AS yb_no,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.id
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0
|
||||
WHEN T1.context_enum = #{activity} THEN T2.id
|
||||
WHEN T1.context_enum = #{medication} THEN T3.id
|
||||
WHEN T1.context_enum = #{device} THEN T4.id
|
||||
@@ -142,15 +147,26 @@
|
||||
ON T6.contract_no = T8.bus_no
|
||||
AND T8.delete_flag = '0'
|
||||
LEFT JOIN med_medication_request AS mmr ON mmr.id = T1.service_id AND mmr.delete_flag = '0'
|
||||
LEFT JOIN wor_device_request AS wdr ON wdr.id = T1.service_id AND T1.service_table = #{worDeviceRequest} AND wdr.delete_flag = '0'
|
||||
LEFT JOIN wor_device_request AS wdr ON wdr.id = T1.service_id AND wdr.delete_flag = '0'
|
||||
LEFT JOIN wor_service_request AS wsr ON wsr.id = T1.service_id AND wsr.delete_flag = '0'
|
||||
LEFT JOIN wor_service_request AS wsrp ON wsrp.id = wsr.parent_id AND wsrp.delete_flag = '0'
|
||||
WHERE T1.encounter_id = #{encounterId}
|
||||
AND T1.status_enum IN (#{planned}
|
||||
AND T1.status_enum IN (0
|
||||
, #{planned}
|
||||
, #{billable}
|
||||
, #{billed}
|
||||
, #{refunding}
|
||||
, #{refunded}
|
||||
, #{partRefund})
|
||||
AND T1.context_enum != #{register}
|
||||
AND (
|
||||
-- 若能关联到请求表,则必须是“已签发”后才允许收费端展示
|
||||
(mmr.id IS NOT NULL AND COALESCE(mmr.status_enum, 1) != 1)
|
||||
OR (wsr.id IS NOT NULL AND (COALESCE(wsr.status_enum, 1) != 1 OR COALESCE(wsrp.status_enum, 1) != 1))
|
||||
OR (wdr.id IS NOT NULL AND COALESCE(wdr.status_enum, 1) != 1)
|
||||
-- 无法关联到任一请求表的收费项,不受签发过滤影响(如挂号费等)
|
||||
OR (mmr.id IS NULL AND wsr.id IS NULL AND wdr.id IS NULL)
|
||||
)
|
||||
AND T1.delete_flag = '0'
|
||||
</select>
|
||||
|
||||
@@ -176,6 +192,8 @@
|
||||
T1.quantity_unit,
|
||||
T1.unit_price,
|
||||
T1.total_price,
|
||||
T1.generate_source_enum,
|
||||
T1.prescription_no AS source_bill_no,
|
||||
mmr.prescription_no,
|
||||
mmr.method_code AS method_code,
|
||||
mmr.rate_code,
|
||||
@@ -194,18 +212,21 @@
|
||||
T8.contract_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.surgery_name
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name")
|
||||
WHEN T1.context_enum = #{activity} THEN T2."name"
|
||||
WHEN T1.context_enum = #{medication} THEN T3."name"
|
||||
WHEN T1.context_enum = #{device} THEN T4."name"
|
||||
END AS item_name,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN NULL
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL
|
||||
WHEN T1.context_enum = #{activity} THEN T2.yb_no
|
||||
WHEN T1.context_enum = #{medication} THEN T3.yb_no
|
||||
WHEN T1.context_enum = #{device} THEN T4.yb_no
|
||||
END AS yb_no,
|
||||
CASE
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.id
|
||||
WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0
|
||||
WHEN T1.context_enum = #{activity} THEN T2.id
|
||||
WHEN T1.context_enum = #{medication} THEN T3.id
|
||||
WHEN T1.context_enum = #{device} THEN T4.id
|
||||
@@ -243,15 +264,25 @@
|
||||
ON T6.contract_no = T8.bus_no
|
||||
AND T8.delete_flag = '0'
|
||||
LEFT JOIN med_medication_request AS mmr ON mmr.id = T1.service_id AND mmr.delete_flag = '0'
|
||||
LEFT JOIN wor_device_request AS wdr ON wdr.id = T1.service_id AND T1.service_table = #{worDeviceRequest} AND wdr.delete_flag = '0'
|
||||
LEFT JOIN wor_device_request AS wdr ON wdr.id = T1.service_id AND wdr.delete_flag = '0'
|
||||
LEFT JOIN wor_service_request AS wsr ON wsr.id = T1.service_id AND wsr.delete_flag = '0'
|
||||
WHERE T1.encounter_id = #{encounterId}
|
||||
AND T1.status_enum IN (#{planned}
|
||||
AND T1.status_enum IN (0
|
||||
, #{planned}
|
||||
, #{billable}
|
||||
, #{billed}
|
||||
, #{refunding}
|
||||
, #{refunded}
|
||||
, #{partRefund})
|
||||
AND T1.context_enum != #{register}
|
||||
AND (
|
||||
-- 若能关联到请求表,则必须是“已签发/已发送”后才允许收费端展示
|
||||
(mmr.id IS NOT NULL AND COALESCE(mmr.status_enum, 1) != 1)
|
||||
OR (wsr.id IS NOT NULL AND COALESCE(wsr.status_enum, 1) != 1)
|
||||
OR (wdr.id IS NOT NULL AND COALESCE(wdr.status_enum, 1) != 1)
|
||||
-- 无法关联到任一请求表的收费项,不受签发过滤影响(如挂号费等)
|
||||
OR (mmr.id IS NULL AND wsr.id IS NULL AND wdr.id IS NULL)
|
||||
)
|
||||
AND T1.delete_flag = '0') final_res
|
||||
</select>
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
T9.organization_id AS organizationId,
|
||||
T9.organization_name AS organizationName,
|
||||
T9.healthcare_name AS healthcareName,
|
||||
T9.clinic_room AS clinicRoom, -- Bug #410:诊室名称
|
||||
T9.practitioner_user_id AS practitionerUserId,
|
||||
T9.practitioner_name AS practitionerName,
|
||||
T9.contract_name AS contractName,
|
||||
@@ -68,7 +69,10 @@
|
||||
T9.picture_url AS pictureUrl,
|
||||
T9.birth_date AS birthDate,
|
||||
COALESCE(T9.identifier_no, T9.patient_bus_no, '') AS identifierNo,
|
||||
COALESCE(T9.order_id IS NOT NULL, false) AS isFromAppointment
|
||||
COALESCE(T9.order_id IS NOT NULL, false) AS isFromAppointment,
|
||||
T9.slot_id AS slotId,
|
||||
T9.pool_id AS poolId,
|
||||
T9.seq_no AS seqNo
|
||||
from (
|
||||
SELECT T1.tenant_id AS tenant_id,
|
||||
T1.id AS encounter_id,
|
||||
@@ -95,8 +99,15 @@
|
||||
T8.birth_date AS birth_date,
|
||||
T8.bus_no AS patient_bus_no,
|
||||
T18.identifier_no AS identifier_no,
|
||||
T1.order_id AS order_id
|
||||
T1.order_id AS order_id,
|
||||
om.slot_id AS slot_id,
|
||||
ss.seq_no AS seq_no,
|
||||
ss.pool_id AS pool_id,
|
||||
sp.clinic_room AS clinic_room -- Bug #410:从号源池获取诊室
|
||||
FROM adm_encounter AS T1
|
||||
LEFT JOIN order_main AS om ON T1.order_id = om.id AND om.delete_flag = '0'
|
||||
LEFT JOIN adm_schedule_slot AS ss ON om.slot_id = ss.id AND ss.delete_flag = '0'
|
||||
LEFT JOIN adm_schedule_pool AS sp ON ss.pool_id = sp.id AND sp.delete_flag = '0' -- Bug #410
|
||||
LEFT JOIN adm_organization AS T2 ON T1.organization_id = T2.ID AND T2.delete_flag = '0'
|
||||
LEFT JOIN adm_healthcare_service AS T3 ON T1.service_type_id = T3.ID AND T3.delete_flag = '0'
|
||||
LEFT JOIN (
|
||||
|
||||
@@ -331,11 +331,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
) t
|
||||
WHERE rn = 1
|
||||
) pi ON s.patient_id = pi.patient_id
|
||||
<!-- 排除已生成医嘱的手术 -->
|
||||
LEFT JOIN wor_service_request sr ON sr.activity_id = s.id AND sr.delete_flag = '0' AND sr.category_enum = 4
|
||||
<where>
|
||||
s.delete_flag = '0'
|
||||
<!-- 只显示未生成医嘱的手术 -->
|
||||
AND sr.id IS NULL
|
||||
<if test="ew.sqlSegment != null and ew.sqlSegment != ''">
|
||||
<![CDATA[
|
||||
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', 's.patient_name').replace('main_surgeon_name', 's.main_surgeon_name').replace('anesthetist_name', 's.anesthetist_name').replace('org_name', 's.org_name').replace('status_enum', 's.status_enum').replace('planned_time', 's.planned_time')}
|
||||
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', 's.patient_name').replace('main_surgeon_name', 's.main_surgeon_name').replace('anesthetist_name', 's.anesthetist_name').replace('org_name', 's.org_name').replace('status_enum', 's.status_enum').replace('planned_time', 's.planned_time').replace('encounter_id', 's.encounter_id')/* 补充encounter_id替换,修复多表关联时字段歧义 */}
|
||||
]]>
|
||||
</if>
|
||||
</where>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
COALESCE(pi.identifier_no, ap.bus_no, '') AS identifierNo
|
||||
FROM op_schedule os
|
||||
LEFT JOIN adm_patient ap ON os.patient_id = ap.id
|
||||
LEFT JOIN cli_surgery cs ON os.oper_code = cs.surgery_no AND cs.delete_flag = '0'
|
||||
INNER JOIN cli_surgery cs ON os.oper_code = cs.surgery_no AND cs.delete_flag = '0'
|
||||
LEFT JOIN adm_organization o ON cs.org_id = o.id
|
||||
LEFT JOIN sys_tenant st ON st.id = os.tenant_id
|
||||
LEFT JOIN sys_user su ON su.user_id = os.creator_id
|
||||
@@ -92,7 +92,7 @@
|
||||
COALESCE(pi.identifier_no, ap.bus_no, '') AS identifierNo
|
||||
FROM op_schedule os
|
||||
LEFT JOIN adm_patient ap ON os.patient_id = ap.id
|
||||
LEFT JOIN cli_surgery cs ON os.oper_code = cs.surgery_no AND cs.delete_flag = '0'
|
||||
INNER JOIN cli_surgery cs ON os.oper_code = cs.surgery_no AND cs.delete_flag = '0'
|
||||
LEFT JOIN adm_organization o ON cs.org_id = o.id
|
||||
LEFT JOIN doc_request_form drf ON drf.prescription_no=cs.surgery_no
|
||||
LEFT JOIN (
|
||||
@@ -153,7 +153,7 @@
|
||||
COALESCE(pi.identifier_no, ap.bus_no, '') AS identifierNo
|
||||
FROM op_schedule os
|
||||
LEFT JOIN adm_patient ap ON os.patient_id = ap.id
|
||||
LEFT JOIN cli_surgery cs ON os.oper_code = cs.surgery_no AND cs.delete_flag = '0'
|
||||
INNER JOIN cli_surgery cs ON os.oper_code = cs.surgery_no AND cs.delete_flag = '0'
|
||||
LEFT JOIN adm_organization o ON cs.org_id = o.id
|
||||
LEFT JOIN sys_tenant st ON st.id = os.tenant_id
|
||||
LEFT JOIN sys_user su ON su.user_id = os.creator_id
|
||||
|
||||
@@ -143,10 +143,10 @@
|
||||
</if>
|
||||
ORDER BY T1.id DESC
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
LIMIT 1500
|
||||
LIMIT 10000
|
||||
</if>
|
||||
<if test="searchKey == null or searchKey == ''">
|
||||
LIMIT 500
|
||||
LIMIT 10000
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
abi.chrgitm_lv
|
||||
FROM (
|
||||
<!-- 确保至少有一个查询被执行以避免语法错误 -->
|
||||
<if test="adviceTypes != null and !adviceTypes.isEmpty() and (adviceTypes.contains(1) or adviceTypes.contains(2) or adviceTypes.contains(3))">
|
||||
<if test="adviceTypes != null and !adviceTypes.isEmpty() and (adviceTypes.contains(1) or adviceTypes.contains(2) or adviceTypes.contains(3) or adviceTypes.contains(6))">
|
||||
<!-- 如果有有效的adviceTypes,则执行对应的查询 -->
|
||||
<if test="adviceTypes.contains(1)">
|
||||
(SELECT
|
||||
@@ -95,14 +95,29 @@
|
||||
AND T2.delete_flag = '0' AND T2.status_enum = #{statusEnum}
|
||||
LEFT JOIN adm_supplier AS T3 ON T3.ID = t1.supply_id AND T3.delete_flag = '0'
|
||||
LEFT JOIN adm_charge_item_definition AS T5 ON T5.instance_id = t1.ID AND T5.delete_flag = '0' AND T5.status_enum = #{statusEnum}
|
||||
LEFT JOIN adm_organization_location AS T6 ON T6.distribution_category_code = t1.category_code AND T6.delete_flag = '0' AND T6.item_code = '1' AND T6.organization_id = #{organizationId} AND (CURRENT_TIME :: time (6) BETWEEN T6.start_time AND T6.end_time)
|
||||
INNER JOIN adm_organization_location AS T6 ON T6.distribution_category_code = t1.category_code AND T6.delete_flag = '0' AND T6.item_code = '1' AND T6.organization_id = #{organizationId} AND (CURRENT_TIME :: time (6) BETWEEN T6.start_time AND T6.end_time)
|
||||
WHERE t1.delete_flag = '0'
|
||||
AND T2.status_enum = #{statusEnum}
|
||||
<if test="pricingFlag == 1">
|
||||
AND 1 = 2
|
||||
</if>
|
||||
<if test="categoryCode != null and categoryCode != ''">
|
||||
AND t1.category_code = #{categoryCode}
|
||||
<!-- 🔧 BugFix: 支持两种匹配方式 -->
|
||||
<!-- 1. 直接匹配:distribution_category_code = category_code(都是数字代码) -->
|
||||
<!-- 2. 字典转换匹配:通过 sys_dict_data 表将 distribution_category_code(中文)转换为 category_code(数字代码) -->
|
||||
AND (
|
||||
-- 方式1:直接匹配
|
||||
t1.category_code = #{categoryCode}
|
||||
OR
|
||||
-- 方式2:通过字典转换匹配(当 distribution_category_code 存储的是中文时)
|
||||
EXISTS (
|
||||
SELECT 1 FROM sys_dict_data sdd
|
||||
WHERE sdd.dict_type = 'med_category_code'
|
||||
AND sdd.status = '0'
|
||||
AND sdd.dict_label = T6.distribution_category_code
|
||||
AND sdd.dict_value = #{categoryCode}
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
AND (t1.name ILIKE '%' || #{searchKey} || '%' OR t1.py_str ILIKE '%' || #{searchKey} || '%')
|
||||
@@ -171,6 +186,9 @@
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
AND (t1.name ILIKE '%' || #{searchKey} || '%' OR t1.py_str ILIKE '%' || #{searchKey} || '%')
|
||||
</if>
|
||||
<if test="categoryCode != null and categoryCode != ''">
|
||||
AND t1.category_code = #{categoryCode}
|
||||
</if>
|
||||
<if test="adviceDefinitionIdParamList != null and !adviceDefinitionIdParamList.isEmpty()">
|
||||
AND t1.id IN
|
||||
<foreach collection="adviceDefinitionIdParamList" item="itemId" open="(" separator="," close=")">
|
||||
@@ -185,11 +203,15 @@
|
||||
<if test="adviceTypes.contains(3)">UNION ALL</if>
|
||||
</if>
|
||||
|
||||
<if test="adviceTypes.contains(3)">
|
||||
<if test="adviceTypes.contains(3) or adviceTypes.contains(6)">
|
||||
(SELECT
|
||||
DISTINCT ON (T1.ID)
|
||||
T1.tenant_id,
|
||||
3 AS advice_type,
|
||||
<choose>
|
||||
<when test="adviceTypes.contains(3) and adviceTypes.contains(6)">CASE T1.category_code WHEN '手术' THEN 6 WHEN '24' THEN 6 ELSE 3 END</when>
|
||||
<when test="adviceTypes.contains(6)">6</when>
|
||||
<otherwise>3</otherwise>
|
||||
</choose> AS advice_type,
|
||||
T1.bus_no AS bus_no,
|
||||
T1.category_code AS category_code,
|
||||
'' AS pharmacology_category_code,
|
||||
@@ -213,7 +235,7 @@
|
||||
WHEN '检验' THEN 1
|
||||
WHEN '检查' THEN 2
|
||||
WHEN '护理' THEN 3
|
||||
WHEN '手术' THEN 4
|
||||
WHEN '手术' THEN 4 WHEN '24' THEN 4
|
||||
WHEN '其他' THEN 5
|
||||
ELSE 0
|
||||
END AS activity_type,
|
||||
@@ -250,9 +272,20 @@
|
||||
<if test="pricingFlag != null">
|
||||
AND (t1.pricing_flag = #{pricingFlag} OR t1.pricing_flag IS NULL)
|
||||
</if>
|
||||
<!-- 如果只选择手术(adviceType=6),过滤 category_code = '手术' 或 '24' -->
|
||||
<if test="adviceTypes.contains(6) and !adviceTypes.contains(3)">
|
||||
AND (T1.category_code = '手术' OR T1.category_code = '24')
|
||||
</if>
|
||||
<!-- 如果只选择诊疗(adviceType=3),排除手术 -->
|
||||
<if test="adviceTypes.contains(3) and !adviceTypes.contains(6) and (categoryCode == null or categoryCode == '')">
|
||||
AND T1.category_code != '手术' AND T1.category_code != '24'
|
||||
</if>
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
AND (t1.name ILIKE '%' || #{searchKey} || '%' OR t1.py_str ILIKE '%' || #{searchKey} || '%')
|
||||
</if>
|
||||
<if test="categoryCode != null and categoryCode != ''">
|
||||
AND t1.category_code = #{categoryCode}
|
||||
</if>
|
||||
<if test="adviceDefinitionIdParamList != null and !adviceDefinitionIdParamList.isEmpty()">
|
||||
AND t1.id IN
|
||||
<foreach collection="adviceDefinitionIdParamList" item="itemId" open="(" separator="," close=")">
|
||||
@@ -263,7 +296,7 @@
|
||||
</if>
|
||||
</if>
|
||||
<!-- 如果没有有效的adviceTypes,提供一个空的默认查询以避免语法错误 -->
|
||||
<if test="adviceTypes == null or adviceTypes.isEmpty() or (!adviceTypes.contains(1) and !adviceTypes.contains(2) and !adviceTypes.contains(3))">
|
||||
<if test="adviceTypes == null or adviceTypes.isEmpty() or (!adviceTypes.contains(1) and !adviceTypes.contains(2) and !adviceTypes.contains(3) and !adviceTypes.contains(6))">
|
||||
SELECT
|
||||
mmd.tenant_id,
|
||||
CAST(0 AS INTEGER) AS advice_type,
|
||||
@@ -603,6 +636,8 @@
|
||||
T3.service_table = #{WOR_DEVICE_REQUEST}
|
||||
LEFT JOIN adm_location AS al ON al.ID = T1.perform_location AND al.delete_flag = '0'
|
||||
WHERE T1.delete_flag = '0' AND T1.generate_source_enum = #{generateSourceEnum}
|
||||
-- 🔧 Bug Fix: 排除基于其他医嘱生成的执行记录
|
||||
AND (T1.based_on_id IS NULL OR T1.based_on_table IS NULL)
|
||||
<if test="historyFlag == '0'.toString()">
|
||||
AND T1.encounter_id = #{encounterId}
|
||||
</if>
|
||||
@@ -659,6 +694,10 @@
|
||||
WHERE T1.delete_flag = '0' AND T1.generate_source_enum = #{generateSourceEnum}
|
||||
AND T1.parent_id IS NULL
|
||||
AND T1.refund_service_id IS NULL
|
||||
-- 🔧 Bug Fix: 排除基于药品请求生成的执行记录(输液、皮试),但保留检查/检验申请单创建的原始医嘱
|
||||
-- based_on_table='med_medication_request' → 输液/皮试执行记录,应排除
|
||||
-- based_on_table='exam_apply'/'lab_apply' → 申请单原始医嘱,应保留
|
||||
AND (T1.based_on_id IS NULL OR T1.based_on_table IS NULL OR T1.based_on_table NOT IN ('med_medication_request', 'med_medication_dispense'))
|
||||
<if test="historyFlag == '0'.toString()">
|
||||
AND T1.encounter_id = #{encounterId}
|
||||
</if>
|
||||
|
||||
@@ -4,41 +4,6 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.openhis.web.doctorstation.mapper.DoctorStationLabApplyMapper">
|
||||
|
||||
<!-- 根据申请单号查询检验申请单(返回完整字段) -->
|
||||
<select id="getInspectionApplyByApplyNo" resultType="com.openhis.web.doctorstation.dto.DoctorStationLabApplyDto">
|
||||
SELECT
|
||||
id AS applicationId,
|
||||
apply_no AS applyNo,
|
||||
patient_id AS patientId,
|
||||
patient_name AS patientName,
|
||||
medicalrecord_number AS medicalrecordNumber,
|
||||
natureof_cost AS natureofCost,
|
||||
visit_no AS visitNo,
|
||||
apply_dept_code AS applyDeptCode,
|
||||
apply_department AS applyDepartment,
|
||||
apply_doc_code AS applyDocCode,
|
||||
apply_doc_name AS applyDocName,
|
||||
apply_time AS applyTime,
|
||||
clinic_diag AS clinicDiag,
|
||||
clinic_desc AS clinicDesc,
|
||||
contraindication AS contraindication,
|
||||
medical_history_summary AS medicalHistorySummary,
|
||||
purposeof_inspection AS purposeofInspection,
|
||||
physical_examination AS physicalExamination,
|
||||
inspection_item AS inspectionItem,
|
||||
specimen_type_code AS specimenTypeCode,
|
||||
specimen_name AS specimenName,
|
||||
priority_code AS priorityCode,
|
||||
apply_status AS applyStatus,
|
||||
apply_remark AS applyRemark,
|
||||
create_time AS createTime,
|
||||
operator_id AS operatorId,
|
||||
create_by AS createBy,
|
||||
tenant_id AS tenantId
|
||||
FROM lab_apply
|
||||
WHERE apply_no = #{applyNo}
|
||||
AND delete_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 分页查询检验申请单列表(根据就诊ID查询,按申请时间降序)
|
||||
从明细表聚合项目名称和金额-->
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
T2.organization_id AS org_id, --科室ID(从就诊表取)
|
||||
T2.id AS encounter_id, --就诊ID
|
||||
T2.start_time AS admissionDate, --入院日期
|
||||
T3.ward_admission_date AS wardAdmissionDate, --入科日期
|
||||
T3.location_id AS ward_location_id, --病区
|
||||
T4.location_id AS bed_location_id --床号
|
||||
FROM adm_patient AS T1
|
||||
|
||||
@@ -81,6 +81,9 @@
|
||||
-- 记录日期
|
||||
T1.recording_date >= #{startTime}::date
|
||||
AND T1.recording_date <= #{endTime}::date
|
||||
<if test="patientId != null and patientId != ''">
|
||||
AND T1.patient_id = #{patientId}::bigint
|
||||
</if>
|
||||
AND T1.delete_flag = '0'
|
||||
|
||||
</where>
|
||||
|
||||
@@ -42,12 +42,13 @@
|
||||
togpd.quantity,
|
||||
togpd.unit_code,
|
||||
sdd.dict_label AS unit_code_name,
|
||||
togpd.dose,
|
||||
togpd.rate_code,
|
||||
togpd.method_code,
|
||||
togpd.dose_quantity,
|
||||
togpd.dose AS dose,
|
||||
togpd.rate_code AS rate_code,
|
||||
togpd.method_code AS method_code,
|
||||
togpd.dose_quantity AS dose_quantity,
|
||||
togpd.group_id,
|
||||
togpd.dispense_per_duration,
|
||||
togpd.dispense_per_duration AS dispense_per_duration,
|
||||
togpd.therapy_enum AS therapy_enum,
|
||||
CASE
|
||||
WHEN togpd.order_definition_table = 'med_medication_definition' THEN
|
||||
med.NAME
|
||||
|
||||
@@ -96,9 +96,9 @@
|
||||
fc.contract_name AS fee_type,
|
||||
COALESCE(pi.identifier_no, ap.bus_no, '') AS identifier_no
|
||||
FROM doc_request_form drf
|
||||
LEFT JOIN cli_surgery cs ON cs.surgery_no = drf.prescription_no
|
||||
LEFT JOIN adm_patient ap ON ap.id = cs.patient_id
|
||||
LEFT JOIN adm_encounter ae ON ae.id = cs.encounter_id
|
||||
LEFT JOIN cli_surgery cs ON cs.surgery_no = drf.prescription_no AND cs.delete_flag = '0'
|
||||
LEFT JOIN adm_patient ap ON ap.id = cs.patient_id AND ap.delete_flag = '0'
|
||||
LEFT JOIN adm_encounter ae ON ae.id = cs.encounter_id AND ae.delete_flag = '0'
|
||||
LEFT JOIN adm_account aa ON aa.encounter_id = ae.id AND aa.delete_flag = '0'
|
||||
LEFT JOIN fin_contract fc ON fc.bus_no = aa.contract_no AND fc.delete_flag = '0'
|
||||
LEFT JOIN op_schedule os ON os.apply_id = drf.id AND os.delete_flag = '0'
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
WHERE t1.delete_flag = '0' AND t1.card_no = #{cardNo}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 审核传染病报卡 -->
|
||||
<update id="auditCard">
|
||||
UPDATE infectious_card
|
||||
@@ -252,4 +253,11 @@
|
||||
ORDER BY t1.report_date DESC
|
||||
</select>
|
||||
|
||||
<!-- 撤销审核传染病报卡 -->
|
||||
<update id="revokeAuditCard">
|
||||
UPDATE infectious_card
|
||||
SET status = #{status}::INTEGER,
|
||||
update_time = CURRENT_TIMESTAMP
|
||||
WHERE card_no = #{cardNo}
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.openhis.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 叫号类型
|
||||
*
|
||||
* @author wangjian963
|
||||
* @date 2026-04-29
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CallType implements HisEnumInterface {
|
||||
|
||||
/** 手动叫号(选呼) */
|
||||
CALL(10, "CALL", "手动叫号(选呼)"),
|
||||
|
||||
/** 手动叫号(下一患者) */
|
||||
NEXT(20, "NEXT", "手动叫号(下一患者)"),
|
||||
|
||||
/** 自动叫号 */
|
||||
AUTO_CALL(30, "AUTO_CALL", "自动叫号"),
|
||||
|
||||
/** 跳过 */
|
||||
SKIP(40, "SKIP", "跳过"),
|
||||
|
||||
/** 完成 */
|
||||
COMPLETE(50, "COMPLETE", "完成"),
|
||||
|
||||
/** 重排 */
|
||||
REQUEUE(60, "REQUEUE", "重排");
|
||||
|
||||
/** 状态码 */
|
||||
private Integer value;
|
||||
/** 英文标识 */
|
||||
private String code;
|
||||
/** 中文描述 */
|
||||
private String info;
|
||||
|
||||
/**
|
||||
* 根据状态码获取对应的叫号类型枚举
|
||||
*
|
||||
* @param value 状态码
|
||||
* @return 对应的枚举值,未匹配时返回 null
|
||||
*/
|
||||
public static CallType getByValue(Integer value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
for (CallType val : values()) {
|
||||
if (val.getValue().equals(value)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.openhis.common.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 智能分诊队列状态
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TriageQueueStatus implements HisEnumInterface {
|
||||
WAITING(0, "waiting", "等待"),
|
||||
CALLING(10, "calling", "叫号中"),
|
||||
IN_CLINIC(20, "in-clinic", "就诊中"),
|
||||
COMPLETED(30, "completed", "完成"),
|
||||
SKIPPED(40, "skipped", "跳过");
|
||||
|
||||
@EnumValue
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
public static TriageQueueStatus getByValue(Integer value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
for (TriageQueueStatus val : values()) {
|
||||
if (val.getValue().equals(value)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -61,4 +61,9 @@ public interface ScheduleSlotMapper extends BaseMapper<ScheduleSlot> {
|
||||
*/
|
||||
List<DoctorAvailabilityDTO> selectDoctorAvailabilitySummary(@Param("query") TicketQueryDTO query);
|
||||
|
||||
/**
|
||||
* 批量查询槽位序号(用于分诊叫号显示)
|
||||
*/
|
||||
List<ScheduleSlot> selectSeqNoBySlotIds(@Param("slotIds") List<Long> slotIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -74,4 +74,9 @@ public class InspectionLabApplyItem extends HisBaseEntity {
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long itemStatus;
|
||||
/**
|
||||
* 套餐ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long feePackageId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.openhis.triageandqueuemanage.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "call_record")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CallRecord {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long recordId;
|
||||
|
||||
/** 队列ID (FK triage_queue_item.id) */
|
||||
private Long queueId;
|
||||
|
||||
/** 医生ID */
|
||||
private Long doctorId;
|
||||
|
||||
/** 叫号时间 */
|
||||
private LocalDateTime callTime;
|
||||
|
||||
/**
|
||||
* 叫号类型,使用 {@link com.openhis.common.enums.CallType} 枚举值
|
||||
* 10-CALL(选呼), 20-NEXT(下一患者), 30-AUTO_CALL(自动叫号),
|
||||
* 40-SKIP(跳过), 50-COMPLETE(完成), 60-REQUEUE(重排)
|
||||
*/
|
||||
private String callType;
|
||||
|
||||
/** 诊室(冗余) */
|
||||
private String room;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createAt;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.openhis.triageandqueuemanage.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "div_log")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class DivLog {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long logId;
|
||||
|
||||
/** 号源池ID */
|
||||
private Long poolId;
|
||||
|
||||
/** 号源槽位ID */
|
||||
private Long slotId;
|
||||
|
||||
/** 操作人ID */
|
||||
private Long opUserId;
|
||||
|
||||
/** 操作动作:ADD_QUEUE/REMOVE_QUEUE/CALL/REFUND/COMPLETE/SKIP/REQUEUE */
|
||||
private String action;
|
||||
|
||||
/** 操作时间 */
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
private LocalDateTime updateAt;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.openhis.triageandqueuemanage.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -31,10 +32,19 @@ public class TriageQueueItem {
|
||||
private String practitionerName; // 医生姓名
|
||||
private Long practitionerId; // 医生ID(新增字段)
|
||||
private String roomNo; // 诊室号(新增字段)
|
||||
private Long poolId; // 号源池ID (关联 adm_schedule_pool.id)
|
||||
private Long slotId; // 号源槽位ID (关联 adm_schedule_slot.id)
|
||||
|
||||
/** WAITING / CALLING / SKIPPED / COMPLETED */
|
||||
private String status;
|
||||
private Integer queueOrder; //“排队序号”,也就是患者在当前科室、当天队列里的 顺序号(从 1 开始递增)。
|
||||
/**
|
||||
* 分诊队列状态
|
||||
* 0=WAITING(等待中), 10=CALLING(呼叫中), 20=IN_CLINIC(诊中),
|
||||
* 30=COMPLETED(已完成), 40=SKIPPED(已跳过), 50=REFUNDED(已退费), 60=FOLLOW(已随访)
|
||||
*/
|
||||
private Integer status;
|
||||
private Integer queueOrder; //”排队序号”,也就是患者在当前科室、当天队列里的 顺序号(从 1 开始递增)。
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer seqNo; // 预约序号(来自 adm_schedule_slot.seq_no,非数据库字段,通过 JOIN 查询)
|
||||
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.openhis.triageandqueuemanage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.openhis.triageandqueuemanage.domain.CallRecord;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CallRecordMapper extends BaseMapper<CallRecord> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.openhis.triageandqueuemanage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.openhis.triageandqueuemanage.domain.DivLog;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DivLogMapper extends BaseMapper<DivLog> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.openhis.triageandqueuemanage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.triageandqueuemanage.domain.CallRecord;
|
||||
|
||||
public interface CallRecordService extends IService<CallRecord> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.openhis.triageandqueuemanage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.triageandqueuemanage.domain.DivLog;
|
||||
|
||||
public interface DivLogService extends IService<DivLog> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.openhis.triageandqueuemanage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.triageandqueuemanage.domain.CallRecord;
|
||||
import com.openhis.triageandqueuemanage.mapper.CallRecordMapper;
|
||||
import com.openhis.triageandqueuemanage.service.CallRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CallRecordServiceImpl extends ServiceImpl<CallRecordMapper, CallRecord> implements CallRecordService {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.openhis.triageandqueuemanage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.triageandqueuemanage.domain.DivLog;
|
||||
import com.openhis.triageandqueuemanage.mapper.DivLogMapper;
|
||||
import com.openhis.triageandqueuemanage.service.DivLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DivLogServiceImpl extends ServiceImpl<DivLogMapper, DivLog> implements DivLogService {
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.openhis.workflow.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.core.common.core.domain.HisBaseEntity;
|
||||
@@ -46,9 +48,11 @@ public class ActivityDefinition extends HisBaseEntity {
|
||||
private String permittedUnitCode;
|
||||
|
||||
/** 所属科室 */
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private Long orgId;
|
||||
|
||||
/** 所在位置 */
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private Long locationId;
|
||||
|
||||
/** 医保标记 */
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.openhis.workflow.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.core.common.core.domain.HisBaseEntity;
|
||||
@@ -64,6 +66,7 @@ public class ServiceRequest extends HisBaseEntity {
|
||||
private Integer performFlag;
|
||||
|
||||
/** 诊疗定义id */
|
||||
@TableField(insertStrategy = FieldStrategy.ALWAYS)
|
||||
private Long activityId;
|
||||
|
||||
/** 数量 */
|
||||
|
||||
@@ -298,8 +298,14 @@
|
||||
<if test="query.phone != null and query.phone != ''">
|
||||
AND o.phone LIKE CONCAT('%', #{query.phone}, '%')
|
||||
</if>
|
||||
<!-- 5. 核心:按系统时间过滤,只返回未过期的号源 -->
|
||||
AND (p.schedule_date > CURRENT_DATE OR (p.schedule_date = CURRENT_DATE AND s.expect_time >= CURRENT_TIME::TIME))
|
||||
<!-- 5. 按系统时间过滤(Bug #398 #399 修复:仅未预约受时间过滤,已预约/已取号/已退号不受影响) -->
|
||||
AND (
|
||||
(<include refid="slotStatusNormExpr" /> = 0 AND (p.schedule_date > CURRENT_DATE OR (p.schedule_date = CURRENT_DATE AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW())))
|
||||
OR <include refid="slotStatusNormExpr" /> = 1
|
||||
OR <include refid="slotStatusNormExpr" /> = 3
|
||||
OR <include refid="slotStatusNormExpr" /> = 5
|
||||
OR <include refid="orderStatusNormExpr" /> = 4
|
||||
)
|
||||
<!-- 6. 状态过滤 -->
|
||||
<if test="query.status != null and query.status != '' and query.status != 'all'">
|
||||
<choose>
|
||||
@@ -370,7 +376,7 @@
|
||||
p.schedule_date > CURRENT_DATE
|
||||
OR (
|
||||
p.schedule_date = CURRENT_DATE
|
||||
AND CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME) > TO_TIMESTAMP(#{query.currentTime}/1000)
|
||||
AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW()
|
||||
)
|
||||
)
|
||||
THEN s.id
|
||||
@@ -401,7 +407,7 @@
|
||||
AND p.schedule_date = CAST(#{query.date} AS DATE)
|
||||
</if>
|
||||
<!-- 增加时间过滤:排除已过去的就诊日期 -->
|
||||
AND p.schedule_date >= CURRENT_DATE
|
||||
AND (p.schedule_date > CURRENT_DATE OR (p.schedule_date = CURRENT_DATE AND (CAST(p.schedule_date AS TIMESTAMP) + CAST(s.expect_time AS TIME)) >= NOW()))
|
||||
<if test="query.department != null and query.department != '' and query.department != 'all'">
|
||||
AND org.name = #{query.department}
|
||||
</if>
|
||||
@@ -431,5 +437,15 @@
|
||||
p.doctor_name ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSeqNoBySlotIds" resultType="com.openhis.appointmentmanage.domain.ScheduleSlot">
|
||||
SELECT id, seq_no
|
||||
FROM adm_schedule_slot
|
||||
WHERE id IN
|
||||
<foreach collection="slotIds" item="slotId" open="(" separator="," close=")">
|
||||
#{slotId}
|
||||
</foreach>
|
||||
AND delete_flag = '0'
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# 页面标题
|
||||
VITE_APP_TITLE = 医院信息管理系统
|
||||
|
||||
# 测试环境配置
|
||||
VITE_APP_ENV = 'test'
|
||||
|
||||
# OpenHIS管理系统/测试环境
|
||||
|
||||
VITE_APP_BASE_API = '/test-api'
|
||||
|
||||
# 租户ID配置
|
||||
VITE_APP_TENANT_ID = '1'
|
||||
# Playwright E2E 测试环境变量
|
||||
# 注意:此文件仅用于本地开发,生产环境使用CI Secret管理
|
||||
TEST_BASE_URL=http://localhost:80
|
||||
TEST_USERNAME=admin
|
||||
TEST_PASSWORD=changeme_in_local_env
|
||||
|
||||
5
openhis-ui-vue3/.gitignore
vendored
5
openhis-ui-vue3/.gitignore
vendored
@@ -21,3 +21,8 @@ selenium-debug.log
|
||||
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
# Playwright test results
|
||||
test-results/
|
||||
tests/e2e/report/
|
||||
tests/tests/
|
||||
|
||||
59
openhis-ui-vue3/eslint.config.js
Normal file
59
openhis-ui-vue3/eslint.config.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/* eslint-env node */
|
||||
import globals from "globals";
|
||||
import pluginVue from "eslint-plugin-vue";
|
||||
import parserVue from "vue-eslint-parser";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
|
||||
export default [
|
||||
{
|
||||
name: "app/files-to-lint",
|
||||
files: ["**/*.{js,mjs,jsx,vue}"],
|
||||
},
|
||||
|
||||
{
|
||||
name: "app/files-to-ignore",
|
||||
ignores: ["**/dist/**", "**/node_modules/**", "**/help-center/**"],
|
||||
},
|
||||
|
||||
...pluginVue.configs["flat/recommended"],
|
||||
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
parser: parserVue,
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
|
||||
plugins: {
|
||||
import: importPlugin,
|
||||
},
|
||||
|
||||
rules: {
|
||||
// 确保导入的模块实际存在(核心规则,防止构建失败)
|
||||
"import/no-unresolved": "error",
|
||||
// 确保导入的命名导出实际存在
|
||||
"import/named": "error",
|
||||
// 确保默认导出存在
|
||||
"import/default": "error",
|
||||
// 确保命名空间导出存在
|
||||
"import/namespace": "error",
|
||||
// Vue 相关规则
|
||||
"vue/multi-word-component-names": "off",
|
||||
},
|
||||
|
||||
settings: {
|
||||
"import/resolver": {
|
||||
alias: {
|
||||
map: [
|
||||
["@", "./src"],
|
||||
],
|
||||
extensions: [".js", ".jsx", ".vue"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
2452
openhis-ui-vue3/package-lock.json
generated
2452
openhis-ui-vue3/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,11 @@
|
||||
"test": "vitest",
|
||||
"test:run": "vitest run",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:ui": "vitest --ui"
|
||||
"test:ui": "vitest --ui",
|
||||
"lint": "eslint . --ext .js,.vue src/",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:ui": "playwright test --ui",
|
||||
"test:e2e:report": "playwright show-report"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -67,6 +71,11 @@
|
||||
"@vitejs/plugin-vue": "4.5.0",
|
||||
"@vue/compiler-sfc": "3.3.9",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-import-resolver-alias": "^1.1.2",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-vue": "^10.9.0",
|
||||
"globals": "^17.5.0",
|
||||
"happy-dom": "^20.8.3",
|
||||
"jsdom": "^28.1.0",
|
||||
"pg": "^8.18.0",
|
||||
|
||||
28
openhis-ui-vue3/playwright.config.ts
Normal file
28
openhis-ui-vue3/playwright.config.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './tests/e2e/specs',
|
||||
fullyParallel: true,
|
||||
timeout: 60_000,
|
||||
expect: { timeout: 10_000 },
|
||||
retries: process.env.CI ? 2 : 1,
|
||||
workers: process.env.CI ? 2 : undefined,
|
||||
reporter: [
|
||||
['html', { outputFolder: 'tests/e2e/report', open: 'never' }],
|
||||
['list'],
|
||||
],
|
||||
use: {
|
||||
baseURL: process.env.TEST_BASE_URL || 'http://localhost:81',
|
||||
screenshot: 'only-on-failure',
|
||||
video: 'retain-on-failure',
|
||||
trace: 'retain-on-failure',
|
||||
viewport: { width: 1920, height: 1080 },
|
||||
locale: 'zh-CN',
|
||||
timezoneId: 'Asia/Shanghai',
|
||||
actionTimeout: 15_000,
|
||||
navigationTimeout: 30_000,
|
||||
},
|
||||
projects: [
|
||||
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
||||
],
|
||||
});
|
||||
@@ -18,34 +18,33 @@ export const TOP_KEYS = [
|
||||
const timeNew = new Date((tieml / 1000 + 86400) * 1000);
|
||||
const todayDate = dayjs(timeNew).format('YYYY-MM-DD');
|
||||
const endDate = dayjs(outdate).format('YYYY-MM-DD');
|
||||
const startDate = dayjs(hospDate).format('YYYY-MM-DD');
|
||||
let eachTime = dayjs(beginDate).add(i, 'day').format('YYYY-MM-DD');
|
||||
let eachDate = dayjs(beginDate).add(i, 'day');
|
||||
const eachTime = eachDate.format('YYYY-MM-DD');
|
||||
if (eachTime === endDate || eachTime === todayDate) {
|
||||
dateClosed.stopTime = true;
|
||||
}
|
||||
if ((startDate === eachTime && i === 0) || dayjs(eachTime).format('MM-DD') === '01-01') {
|
||||
eachTime = dayjs(eachTime).format('YYYY年MM月DD日');
|
||||
} else if (i === 0 || dayjs(eachTime).format('DD') === '01') {
|
||||
eachTime = dayjs(eachTime).format('MM月DD日');
|
||||
} else {
|
||||
eachTime = dayjs(eachTime).format('DD日');
|
||||
}
|
||||
return dateClosed.stopTime ? eachTime : '';
|
||||
// 统一补零格式:月份和日期都始终两位补零
|
||||
const month = eachDate.format('MM'); // 月份始终两位补零
|
||||
const date = eachDate.format('DD'); // 日期始终两位补零
|
||||
// 每月1号显示 MM月DD日,其他日期只显示 DD日
|
||||
return `${month}月${date}日`;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '住院日数',
|
||||
getValue: (i, renderData) => {
|
||||
const { beginDate, hospDays, outdate = '', dateClosed } = renderData.infoData;
|
||||
const tieml = new Date();
|
||||
const timeNew = new Date((tieml / 1000 + 86400) * 1000);
|
||||
const todayDate = dayjs(timeNew).format('YYYY-MM-DD');
|
||||
const endDate = dayjs(outdate).add(1, 'day').format('YYYY-MM-DD');
|
||||
const eachTime = dayjs(beginDate).add(i, 'day').format('YYYY-MM-DD');
|
||||
if (eachTime === endDate || todayDate === eachTime) {
|
||||
dateClosed.stopNumber = false;
|
||||
const beginDayjs = dayjs(beginDate);
|
||||
let num = '';
|
||||
// 只要 beginDate 有效,每一天都计算显示住院日数
|
||||
if (beginDayjs.isValid()) {
|
||||
if (hospDays !== undefined && hospDays !== null) {
|
||||
num = hospDays + i + 1;
|
||||
} else {
|
||||
// hospDays 不存在时,从入院开始直接计算
|
||||
num = i + 1;
|
||||
}
|
||||
}
|
||||
const num = dateClosed.stopNumber ? hospDays + i + 1 : '';
|
||||
let hosNum = '';
|
||||
if (num !== '') {
|
||||
hosNum = '第' + '\xa0\xa0\xa0' + num + '\xa0\xa0\xa0' + '日';
|
||||
|
||||
@@ -20,6 +20,15 @@ export function advicePrint(data) {
|
||||
}
|
||||
|
||||
// 获取全部科室列表
|
||||
// 获取科室列表(别名)
|
||||
export function getDepartmentList(data) {
|
||||
return request({
|
||||
url: '/app-common/department-list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
|
||||
export function getOrgList(data) {
|
||||
return request({
|
||||
url: '/app-common/department-list',
|
||||
@@ -60,11 +69,12 @@ export function getAdjustPriceSwitchState(params) {
|
||||
/**
|
||||
* 批次号匹配
|
||||
*/
|
||||
export function lotNumberMatch(params) {
|
||||
export function lotNumberMatch(params, config = {}) {
|
||||
return request({
|
||||
url: '/app-common/lot-number-match',
|
||||
method: 'get',
|
||||
params: params,
|
||||
...config
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
10
openhis-ui-vue3/src/api/system/info.js
Normal file
10
openhis-ui-vue3/src/api/system/info.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getSystemVersion(options = {}) {
|
||||
return request({
|
||||
url: '/system/version',
|
||||
method: 'get',
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
{
|
||||
"panels": [
|
||||
{
|
||||
"height": 210,
|
||||
"height": 297,
|
||||
"index": 1,
|
||||
"name": "会诊申请单",
|
||||
"paperFooter": 595.5,
|
||||
"paperFooter": 780,
|
||||
"paperHeader": 0,
|
||||
"paperList": {"height": 210, "type": "A4", "width": 210},
|
||||
"paperList": {"height": 297, "type": "A4", "width": 210},
|
||||
"paperNumberDisabled": true,
|
||||
"paperType": "A4",
|
||||
"printElements": [
|
||||
{"options": {"fontSize": 14, "fontWeight": "bold", "height": 15, "left": 0, "textAlign": "center", "title": "会诊申请单", "top": 5, "width": 180}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "hospitalName", "fontSize": 10, "height": 10, "left": 0, "textAlign": "center", "title": "医院名称", "top": 22, "width": 180}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "patientName", "fontSize": 10, "height": 10, "left": 5, "title": "姓名:", "top": 40, "width": 60, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "gender", "fontSize": 10, "height": 10, "left": 70, "title": "性别:", "top": 40, "width": 30, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "age", "fontSize": 10, "height": 10, "left": 105, "title": "年龄:", "top": 40, "width": 40, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "deptName", "fontSize": 10, "height": 10, "left": 150, "title": "科室:", "top": 40, "width": 30, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "diagnosis", "fontSize": 10, "height": 20, "left": 5, "title": "初步诊断:", "top": 55, "width": 170, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "consultationReason", "fontSize": 10, "height": 40, "left": 5, "title": "会诊目的:", "top": 80, "width": 170, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "applyTime", "fontSize": 10, "height": 10, "left": 5, "title": "申请时间:", "top": 130, "width": 80, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "applyDoctor", "fontSize": 10, "height": 10, "left": 100, "title": "申请医生:", "top": 130, "width": 75, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}}
|
||||
{"options": {"fontSize": 18, "fontWeight": "bold", "height": 20, "left": 0, "textAlign": "center", "title": "会诊申请单", "top": 10, "width": 210}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "hospitalName", "fontSize": 12, "height": 15, "left": 0, "textAlign": "center", "title": "医院名称", "top": 35, "width": 210}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "patientName", "fontSize": 12, "height": 15, "left": 10, "title": "姓名:", "top": 60, "width": 80, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "gender", "fontSize": 12, "height": 15, "left": 300, "title": "性别:", "top": 60, "width": 100, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "age", "fontSize": 12, "height": 15, "left": 150, "title": "年龄:", "top": 60, "width": 100, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "deptName", "fontSize": 12, "height": 15, "left": 10, "title": "科室:", "top": 80, "width": 190, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "diagnosis", "fontSize": 12, "height": 25, "left": 10, "title": "初步诊断:", "top": 100, "width": 400, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "consultationReason", "fontSize": 12, "height": 50, "left": 10, "title": "会诊目的:", "top": 130, "width": 190, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "applyTime", "fontSize": 12, "height": 15, "left": 10, "title": "申请时间:", "top": 190, "width": 300, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}},
|
||||
{"options": {"field": "applyDoctor", "fontSize": 12, "height": 15, "left": 400, "title": "申请医生:", "top": 190, "width": 300, "hideTitle": false}, "printElementType": {"title": "文本", "type": "text"}}
|
||||
],
|
||||
"width": 180
|
||||
"width": 210
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -26,7 +26,7 @@ const convertIdsToString = (obj) => {
|
||||
} else {
|
||||
const newObj = {}
|
||||
for (const key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
const value = obj[key]
|
||||
// 如果key以Id结尾或者是id,且值是数字,转为字符串
|
||||
if ((key === 'id' || key.endsWith('Id') || key.endsWith('ID')) && typeof value === 'number') {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user