根因: - Bug #请修复 Bug #764 存在的问题 修复: - 修改文件:`healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/doctorstation/appservice/impl/DoctorStationLabApplyServiceImpl.java` - 核心改动:将门诊医嘱创建阶段的检验项目定义查询从 `wor_activity_definition`(按名称)改为 `lab_activity_definition`(按 `activityId`),与阶段一(保存申请单明细)的查询方式保持一致。编译通过,可进入测试/验收流程。 - Review --- - Now I have all the information needed for a thorough review. - Bug #764 Fix - ### Summary - What the fix does**: Replaces the `wor_activity_definition` name-based lookup with `lab_activity_definition` ID-based lookup using `activityId` from the DTO, matching the pattern already used in stage one (line ~182). - ### Dimension Scores - 1. Design Quality (4/5)** - ✅ Correct root-cause fix: switches from wrong table to correct table - ✅ Uses ID-based lookup (more reliable than name-based) - ✅ Consistent with stage one's query pattern (line 182) - ✅ Error messages are specific and actionable (include item name and ID) - ⚠ Minor: `activityDefinitionService` field (line 79) is now unused — Spring still injects it harmlessly, but it's dead code - 2. Craftsmanship (4/5)** - ✅ Null check on `labActivityId` before query — prevents NPE - ✅ Null check on result — handles missing records gracefully - ✅ `LabActivityDefinition` entity verified: has `categoryCode`, `permittedUnitCode`, `feePackageId` — all fields accessed in the fix exist - ✅ `adviceTableName` correctly changed to `"lab_activity_definition"` for downstream tracking - ⚠ Minor: unused `activityDefinitionService` field could be cleaned up in a follow-up - 3. Functionality (5/5)** - lab items now correctly resolve from `lab_activity_definition` - ✅ `adviceDefinitionId`, `definitionId`, `activityId` all set to `labActivityId` — consistent - ✅ `categoryCode`, `permittedUnitCode`, `feePackageId` correctly read from `LabActivityDefinition` - ✅ Fee package logic preserved: `feePackageId` flows through to package price lookup correctly - ✅ Compilation passes (verified, exit code 0) - 4. Style Consistency (4/5)** - ✅ Matches stage one's pattern (`labActivityDefinitionService.getById(...)`) - ✅ Same error-throwing style (`throw new RuntimeException(...)`) - ✅ Uses Lombok `@Data` entity accessors consistent with project style - ✅ Comments updated to explain the change rationale - ⚠ Comment numbering jumped from "1" to "3" (skipping "2") — the old "2. 获取诊疗定义详情" was removed but the remaining steps weren't renumbered - ### Total: 17/20 (Functionality: 5) - ### Minor Issues (non-blocking) - | Issue | Severity | Recommendation | - |-------|----------|----------------| - | `activityDefinitionService` field now unused | Low | Remove in follow-up cleanup if no other caller exists | - | Step numbering gap ("1" → "3") | Cosmetic | Renumber to 1, 2, 3... in a follow-up | - | `activityId == null` throws RuntimeException | Low | Consider returning a structured error, but this matches existing project patterns | - ### VERDICT: PASS - Test --- - All verification complete. Here's the summary: - ## Bug #764 Verification Report - ### Verification Results - | Check | Result | - |-------|--------| - | `mvn compile -pl healthlink-his-application -am` | ✅ BUILD SUCCESS (33.8s, 11 modules) | - | `mvn test` — 8 test classes | ✅ **126 tests, 0 failures, 0 errors, 0 skipped** | - | InspectionApiTest (direct regression) | ✅ 11 tests, 0 failures | - | DoctorWorkstationTest (closest module) | ✅ 20 tests, 0 failures | - | Import/injection correctness | ✅ `LabActivityDefinition` + `ILabActivityDefinitionService` properly imported and `@Autowired` | - | Entity field coverage | ✅ All 3 fields (`categoryCode`, `permittedUnitCode`, `feePackageId`) exist in entity | - | No unrelated changes | ✅ Only `DoctorStationLabApplyServiceImpl.java` modified | - | No regressions | ✅ All pre-existing warnings unchanged, zero new warnings | - VERDICT: PASS** - Verify --- - ## Bug #764 验收报告 - ### 1. Git Commit 存在性 — ❌ 未提交 - 最新 commit 为 `fix(#763)` — Bug #763 - 诸葛亮分析报告 Bug #764`(仅文档,非修复) - M ...DoctorStationLabApplyServiceImpl.java`) - ### 2. 编译 — ✅ 通过 - `mvn clean compile -DskipTests` → **BUILD SUCCESS**(12 模块全部 SUCCESS) - ### 3. 测试 — ✅ 通过 - 全量测试:**126 tests, 0 failures, 0 errors, 0 skipped** - 相关模块 `InspectionApiTest`:11 tests 全通过 - 其他模块:Registration(18), Billing(7), Inpatient(19), Pharmacy(17) 全通过 - ### 4. 无回归 — ✅ - 全部 5 个测试套件通过,无新增失败 - ### 5. 文件变更合理性 — ✅ - 仅修改 **1 个文件**:`DoctorStationLabApplyServiceImpl.java`(+15 / -17 行) - 未删除任何源文件** - 变更内容合理:将检验申请从错误查询 `activityDefinitionService`(wor_activity_definition)切换为正确的 `labActivityDefinitionService`(lab_activity_definition) - 所有依赖就位:`LabActivityDefinition` 实体含 `categoryCode`/`permittedUnitCode`/`feePackageId`;DTO 含 `activityId`;Service 已注入 - ### 变更质量评估 - 检验项目走独立表 `lab_activity_definition`,不再误查 `wor_activity_definition`。`adviceTableName` 也正确改为 `"lab_activity_definition"`。 - 修复代码未提交。需要执行 `git add` + `git commit -m "fix(#764): ..."` 后方可视为完成。 - FAIL [修复代码已验证正确(编译通过、126测试全通过、无回归、变更合理),但缺少 git commit,不符合铁律3"测试通过后才提交"的完成标准]
This commit is contained in:
@@ -251,18 +251,16 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
|
||||
// 遍历检验申请单明细,为每个检验项目创建对应的门诊医嘱记录
|
||||
for (DoctorStationLabApplyItemDto labApplyItemDto : doctorStationLabApplyDto.getLabApplyItemList()) {
|
||||
// 1. 根据检验项目名称查询诊疗定义(检验项目)
|
||||
// 1. Bug #764: 使用 lab_activity_definition 表的 activityId 查询检验项目定义
|
||||
// 检验项目存储在 lab_activity_definition 独立表中,不走 wor_activity_definition
|
||||
String itemName = labApplyItemDto.getItemName();
|
||||
Long activityDefinitionId = activityDefinitionService.getAppointActivityDefinitionId(itemName);
|
||||
|
||||
if (activityDefinitionId == null) {
|
||||
throw new RuntimeException("未找到检验项目 '" + itemName + "' 对应的诊疗定义");
|
||||
Long labActivityId = labApplyItemDto.getActivityId();
|
||||
if (labActivityId == null) {
|
||||
throw new RuntimeException("检验项目 '" + itemName + "' 未传入 activityId,请重新选择检验项目");
|
||||
}
|
||||
|
||||
// 2. 获取诊疗定义详情
|
||||
ActivityDefinition activityDefinition = activityDefinitionService.getById(activityDefinitionId);
|
||||
if (activityDefinition == null) {
|
||||
throw new RuntimeException("诊疗定义不存在");
|
||||
LabActivityDefinition labActivityDef = labActivityDefinitionService.getById(labActivityId);
|
||||
if (labActivityDef == null) {
|
||||
throw new RuntimeException("检验项目 '" + itemName + "' 对应的检验项目定义不存在(ID: " + labActivityId + ")");
|
||||
}
|
||||
|
||||
// 3. 根据执行科室代码获取科室 ID(positionId)
|
||||
@@ -297,17 +295,17 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
|
||||
// 设置检验项目相关信息
|
||||
// 医嘱定义 ID(诊疗定义 ID)
|
||||
adviceSaveDto.setAdviceDefinitionId(activityDefinitionId);
|
||||
adviceSaveDto.setAdviceDefinitionId(labActivityId);
|
||||
// 费用定价主表 ID(对应 adm_charge_item 表的 definition_id 字段)
|
||||
adviceSaveDto.setDefinitionId(activityDefinitionId);
|
||||
adviceSaveDto.setDefinitionId(labActivityId);
|
||||
// 医嘱名称
|
||||
adviceSaveDto.setAdviceName(itemName);
|
||||
// 医嘱详细分类
|
||||
adviceSaveDto.setCategoryCode(activityDefinition.getCategoryCode());
|
||||
adviceSaveDto.setCategoryCode(labActivityDef.getCategoryCode());
|
||||
// 活动 ID(诊疗定义 ID)
|
||||
adviceSaveDto.setActivityId(activityDefinitionId);
|
||||
adviceSaveDto.setActivityId(labActivityId);
|
||||
// 医嘱定义对应表名
|
||||
adviceSaveDto.setAdviceTableName("wor_activity_definition");
|
||||
adviceSaveDto.setAdviceTableName("lab_activity_definition");
|
||||
// 执行科室 ID
|
||||
adviceSaveDto.setPositionId(positionId);
|
||||
|
||||
@@ -346,13 +344,13 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
|
||||
// 请求数量
|
||||
adviceSaveDto.setQuantity(labApplyItemDto.getItemQty() != null ? labApplyItemDto.getItemQty() : java.math.BigDecimal.ONE);
|
||||
// 请求单位编码(使用诊疗定义的使用单位)
|
||||
adviceSaveDto.setUnitCode(activityDefinition.getPermittedUnitCode());
|
||||
adviceSaveDto.setUnitCode(labActivityDef.getPermittedUnitCode());
|
||||
|
||||
// 单价处理(BugFix#CodeReview: 根据套餐ID从正确的数据源获取价格)
|
||||
// 套餐项目:从 inspection_basic_information 表获取 package_amount
|
||||
// 普通项目:使用前端传入的 itemPrice(已从诊疗项目获取)
|
||||
java.math.BigDecimal unitPrice;
|
||||
Long feePackageId = activityDefinition.getFeePackageId();
|
||||
Long feePackageId = labActivityDef.getFeePackageId();
|
||||
|
||||
if (feePackageId != null) {
|
||||
// 套餐项目:查询套餐价格
|
||||
|
||||
Reference in New Issue
Block a user