华佗 e0554d7416 fix(#763): 请修复 Bug #763
根因:
- Bug #665 引入的 `queryWrapper.le("end_time", deadlineTime)` 对 NULL 值处理不当
- 住院临时医嘱签发时 `effectiveDoseEnd` 未赋值 → DB 中 `effective_dose_end = NULL`
- PostgreSQL 中 `NULL <= anything` 结果为 NULL(等价 FALSE),导致行被排除
- deadline` 条件对 NULL 值(临时医嘱 `effective_dose_end` 未设置)返回 FALSE,导致住院临时医嘱被排除 |
- ###  2. 编译通过
- `mvn compile -DskipTests` — **BUILD SUCCESS** (exit 0)
- 涉及 11 个模块全部 SUCCESS
- ###  3. 测试通过
- `mvn test` — **126 tests run, 0 failures, 0 errors, 0 skipped**
- 8 个测试类全部通过(DoctorWorkstationTest, NurseStationTest, RegistrationApiTest, BillingApiTest, InpatientApiTest, PharmacyApiTest, InspectionApiTest, ReportApiTest)
- ###  4. 无回归

修复:
- 文件:`AdviceProcessAppServiceImpl.java:222`
- 改动:`queryWrapper.le("end_time", deadlineTime)` → `queryWrapper.and(w -> w.le("end_time", deadlineTime).or().isNull("end_time"))`
- 生成 SQL:`(end_time <= ? OR end_time IS NULL)`,临时医嘱(end_time=NULL)不再被排除
- 验证结果**:
- | 检查项 | 结果 |
- |--------|------|
- | `mvn clean compile -DskipTests` |  BUILD SUCCESS (01:02 min) |
- | 回归风险 |  仅影响 `selectInpatientAdvicePage` 一个查询路径,长期医嘱 deadline 筛选仍生效 |
- Bug #763 修复已完整应用,编译通过,无需额外改动。
- Review ---
- Compilation confirmed clean (warnings only, no errors). I have all the evidence needed for a thorough review.
- ## Bug #763 Code Review Report
- ### Change Summary
- | 项目 | 详情 |
- |------|------|
- | 文件 | `AdviceProcessAppServiceImpl.java:222` |
- | 变更行数 | 1 行 |
- | 变更前 | `queryWrapper.le("end_time", deadlineTime);` |
- | 变更后 | `queryWrapper.and(w -> w.le("end_time", deadlineTime).or().isNull("end_time"));` |
- ### Review Findings
- SQL 语义 `end_time <= ? OR end_time IS NULL` 逻辑完备:
- 长期医嘱:`end_time` 有值 → `end_time <= deadline` 筛选仍生效
- 临时医嘱:`end_time = NULL` → `IS NULL` 通过,不再被排除
- 耗材医嘱(`wor_device_request`):Mapper XML 中 `NULL::timestamp AS end_time` → 同样通过
- Mapper XML 验证**  — `selectInpatientAdvicePage` 三段 UNION 中 `end_time` 别名一致:
- `med_medication_request`: `T1.effective_dose_end AS end_time` (line 167)
- `wor_service_request`: `T1.occurrence_end_time AS end_time` (line 313)
- `wor_device_request`: `NULL::timestamp AS end_time` (line 448)
- `${ew.customSqlSegment}` 应用于外层查询,列名匹配无误。
- 模式一致性**  — 与同文件第 216 行 `therapyEnum` NULL 安全处理完全一致:
- ```java
- // line 216
- queryWrapper.and(w -> w.eq("therapy_enum", therapyEnum).or().isNull("therapy_enum"));
- // line 222 (fixed)
- queryWrapper.and(w -> w.le("end_time", deadlineTime).or().isNull("end_time"));
- Lambda 风格、缩进、调用链完全一致。
- 前置守卫**  — `deadline != null && !deadline.isEmpty()` 已存在,不会 NPE。
- 回归风险**  — 仅影响 `selectInpatientAdvicePage` 一个查询路径,长期医嘱 deadline 筛选不受影响。
- 编译验证**  — `mvn compile` 通过(仅 sun.misc.Unsafe deprecation warning,与本次改动无关)。
- ### 评分
- | 维度 | 分数 | 说明 |
- |------|------|------|
- | 设计质量 | 4 | NULL 语义正确;可考虑加注释说明 NULL end_time 代表临时医嘱无截止时间 |
- | 工艺性 | 4 | NULL 安全、异常处理、前置守卫均到位;与 line 216 模式复用 |
- | 风格一致性 | 5 | 与代码库现有 NULL 安全处理模式完全一致 |
- | **总分** | **18/20** | |
- ### 改进建议(非阻塞)
- `// Bug #763: NULL end_time 表示临时医嘱无截止时间,需兼容`
- 2. 建议补充集成测试用例覆盖"临时医嘱 + deadline 过滤"场景,防止回归
- ### 结论
- VERDICT: PASS**
- Test ---
- All tests passed across the entire application module. Here's the summary:
- ## Bug #763 — 测试报告
- | 项目 | 详情 |
- |------|------|
- | 文件 | `AdviceProcessAppServiceImpl.java:222` |
- | 变更 | 1 行:`queryWrapper.le("end_time", deadlineTime)` → `queryWrapper.and(w -> w.le("end_time", deadlineTime).or().isNull("end_time"))` |
- deadline OR end_time IS NULL)` — NULL 表示无截止时间,不应被过滤 |
- | 风格一致性 | 与同文件第 216 行 `therapyEnum` NULL 安全写法完全一致 |
- ### 验证结果
- | 检查项 | 结果 |
- |--------|------|
- | `mvn compile -pl healthlink-his-application -am -q` |  Exit 0 |
- | `mvn install -DskipTests` (全量) |  BUILD SUCCESS (11 modules) |
- | `mvn test -pl healthlink-his-application` (全量) |  126 tests run, 0 failures, 0 errors |
- | 改动范围 | 1 文件 1 行,严格限定 |
- | 回归检查 | `le` 条件保留,deadline 筛选仍对长期医嘱生效 |
- | Mapper XML 别名验证 |  `T1.effective_dose_end AS end_time` 确认映射正确 |
- ### 结论
- VERDICT: PASS
- Verify ---
- All checks complete. Here's the verification report:
- ## Bug #763 验收报告
- ###  1. Git Commit 存在且包含 Bug #763
- `a41222286` — `fix(#763): 请修复 Bug #763`
- 222` 一行
- 将 `queryWrapper.le("end_time", deadlineTime)` 改为 `queryWrapper.and(w -> w.le("end_time", deadlineTime).or().isNull("end_time"))`
- SQL 语义:`end_time <= deadline OR end_time IS NULL`,保留 deadline 筛选功能,同时兼容 NULL 值的临时医嘱
- 风格与同文件第 216 行 `therapyEnum` NULL 安全处理一致
- ###  5. 文件变更合理(未删除必要文件)
- 仅修改 1 个文件,0 个删除,0 个新增
- 1 insertion, 1 deletion — 极小变更,风险极低
- VERDICT: PASS**
2026-06-12 18:12:17 +08:00
2026-05-27 08:59:07 +08:00
2026-06-12 18:12:17 +08:00
2026-05-27 08:59:07 +08:00
Description
No description provided
320 MiB
Languages
Java 47.5%
Vue 45.4%
JavaScript 4.4%
Python 1.3%
HTML 0.6%
Other 0.7%