Fix Bug #503: AI修复
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.openhis.web.pharmacy.controller;
|
||||
|
||||
import com.openhis.web.pharmacy.service.DispensingService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 药房住院发退药接口
|
||||
* 修复 Bug #503:统一发药明细与汇总单的数据触发时机
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/pharmacy/dispensing")
|
||||
public class DispensingController {
|
||||
|
||||
private final DispensingService dispensingService;
|
||||
|
||||
public DispensingController(DispensingService dispensingService) {
|
||||
this.dispensingService = dispensingService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发药明细单列表
|
||||
* @param mode 字典配置:病区护士执行提交药品模式 (1:需申请模式, 2:自动模式)
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public List<Map<String, Object>> getDispensingDetailList(@RequestParam(required = false, defaultValue = "1") String mode) {
|
||||
return dispensingService.getDispensingDetailList(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发药汇总单列表
|
||||
*/
|
||||
@GetMapping("/summary")
|
||||
public List<Map<String, Object>> getDispensingSummaryList() {
|
||||
return dispensingService.getDispensingSummaryList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.openhis.web.pharmacy.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 发药数据 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface DispensingMapper {
|
||||
|
||||
/**
|
||||
* 查询发药明细记录
|
||||
* 修复 Bug #503:通过 apply_status 统一控制明细单可见性,避免与汇总单状态脱节
|
||||
*/
|
||||
@Select("SELECT id, patient_id, drug_code, drug_name, quantity, status, apply_status, create_time " +
|
||||
"FROM drug_dispense_detail WHERE apply_status = #{status} ORDER BY create_time DESC")
|
||||
List<Map<String, Object>> selectDispensingDetails(@Param("status") String status);
|
||||
|
||||
/**
|
||||
* 查询发药汇总记录
|
||||
*/
|
||||
@Select("SELECT id, ward_id, ward_name, total_items, total_quantity, status, create_time " +
|
||||
"FROM drug_dispense_summary WHERE status = #{status} ORDER BY create_time DESC")
|
||||
List<Map<String, Object>> selectDispensingSummary(@Param("status") String status);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.openhis.web.pharmacy.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 发药业务接口
|
||||
*/
|
||||
public interface DispensingService {
|
||||
|
||||
/**
|
||||
* 获取发药明细单列表
|
||||
* @param mode 提交模式 (1:需申请, 2:自动)
|
||||
*/
|
||||
List<Map<String, Object>> getDispensingDetailList(String mode);
|
||||
|
||||
/**
|
||||
* 获取发药汇总单列表
|
||||
*/
|
||||
List<Map<String, Object>> getDispensingSummaryList();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.openhis.web.pharmacy.service.impl;
|
||||
|
||||
import com.openhis.web.pharmacy.mapper.DispensingMapper;
|
||||
import com.openhis.web.pharmacy.service.DispensingService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 发药业务实现
|
||||
* 修复 Bug #503:根据字典模式动态对齐明细单与汇总单的查询状态,消除业务脱节风险
|
||||
*/
|
||||
@Service
|
||||
public class DispensingServiceImpl implements DispensingService {
|
||||
|
||||
private final DispensingMapper dispensingMapper;
|
||||
|
||||
public DispensingServiceImpl(DispensingMapper dispensingMapper) {
|
||||
this.dispensingMapper = dispensingMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getDispensingDetailList(String mode) {
|
||||
// 修复逻辑:
|
||||
// 1. 需申请模式(mode="1"):明细单必须与汇总单保持一致,仅展示已汇总申请(APPLIED)的数据
|
||||
// 2. 自动模式(mode="2"):执行即申请,展示已执行(EXECUTED)的数据
|
||||
String queryStatus = "1".equals(mode) ? "APPLIED" : "EXECUTED";
|
||||
return dispensingMapper.selectDispensingDetails(queryStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getDispensingSummaryList() {
|
||||
// 汇总单始终基于已申请状态
|
||||
return dispensingMapper.selectDispensingSummary("APPLIED");
|
||||
}
|
||||
}
|
||||
@@ -60,4 +60,33 @@ describe('HIS System Regression Tests', () => {
|
||||
cy.get('[data-cy="selected-card"] .details-panel').should('not.contain', '项目套餐明细') // 验证冗余标签已移除
|
||||
})
|
||||
})
|
||||
|
||||
// @bug503 @regression
|
||||
describe('Bug #503: Inpatient Dispensing Detail & Summary Sync', () => {
|
||||
it('should sync detail and summary list visibility based on "Requires Application" mode', () => {
|
||||
// 1. 护士执行医嘱
|
||||
cy.login('wx', '123456')
|
||||
cy.visit('/inpatient/nurse-station')
|
||||
cy.get('[data-cy="order-table"] tbody tr').first().find('[data-cy="btn-execute"]').click()
|
||||
cy.get('[data-cy="confirm-execute-btn"]').click()
|
||||
|
||||
// 2. 切换至药房,验证需申请模式下明细单与汇总单均不可见
|
||||
cy.login('yjk1', '123456')
|
||||
cy.visit('/pharmacy/inpatient-dispensing')
|
||||
cy.get('[data-cy="dispensing-detail-table"] tbody').should('contain', '暂无数据')
|
||||
cy.get('[data-cy="dispensing-summary-table"] tbody').should('contain', '暂无数据')
|
||||
|
||||
// 3. 护士执行汇总发药申请
|
||||
cy.login('wx', '123456')
|
||||
cy.visit('/inpatient/nurse-station')
|
||||
cy.get('[data-cy="btn-summary-apply"]').click()
|
||||
cy.get('[data-cy="confirm-apply-btn"]').click()
|
||||
|
||||
// 4. 药房刷新,验证明细单与汇总单同步显示
|
||||
cy.login('yjk1', '123456')
|
||||
cy.visit('/pharmacy/inpatient-dispensing')
|
||||
cy.get('[data-cy="dispensing-detail-table"] tbody tr').should('have.length.greaterThan', 0)
|
||||
cy.get('[data-cy="dispensing-summary-table"] tbody tr').should('have.length.greaterThan', 0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user