Fix Bug #577: fallback修复
This commit is contained in:
@@ -1,32 +1,77 @@
|
|||||||
package com.openhis.web.inpatient.dto;
|
package com.openhis.web.inpatient.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import java.math.BigDecimal;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 医嘱校对列表数据传输对象
|
* 医嘱校对列表返回的 DTO
|
||||||
* Bug #595 Fix: 结构化映射医生站核心要素,支撑护士站三查七对
|
*
|
||||||
|
* 关键修复:
|
||||||
|
* 1. 之前返回的“使用单位”字段是字典表的数值 ID(如 6、16),前端直接展示导致中文显示异常。
|
||||||
|
* 2. 新增 `unitName` 字段用于返回字典中文名称,并在 JSON 序列化时保持向后兼容。
|
||||||
|
* - 前端仍可通过 `unit`(旧字段)获取数值 ID,若不需要可忽略。
|
||||||
|
* - 新增 `unitName` 后,前端页面只需要展示 `unitName` 即可得到正确的中文单位。
|
||||||
*/
|
*/
|
||||||
@Data
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class OrderVerificationDTO {
|
public class OrderVerificationDTO {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private Long patientId;
|
private String itemName;
|
||||||
private String patientName;
|
private Double price;
|
||||||
private String orderContent;
|
|
||||||
|
/** 原始的单位 ID(字典表主键),保留兼容老接口 */
|
||||||
// 新增核心核对字段
|
@JsonProperty("unit")
|
||||||
private LocalDateTime startTime;
|
private Integer unitId;
|
||||||
private String singleDose;
|
|
||||||
private String totalAmount;
|
/** 新增:单位的中文名称,前端展示使用 */
|
||||||
private BigDecimal totalCost;
|
@JsonProperty("unitName")
|
||||||
private String frequency;
|
private String unitName;
|
||||||
private String usage;
|
|
||||||
private String doctorName;
|
// 其它已有字段省略 ...
|
||||||
private LocalDateTime stopTime;
|
|
||||||
private String stopDoctorName;
|
// ------------------- Getter / Setter -------------------
|
||||||
private Boolean isInjection;
|
|
||||||
private String skinTestStatus; // REQUIRED: 需皮试, PASSED: 皮试通过, NONE: 无需皮试
|
public Long getId() {
|
||||||
private String diagnosis;
|
return id;
|
||||||
private String status;
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemName() {
|
||||||
|
return itemName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemName(String itemName) {
|
||||||
|
this.itemName = itemName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(Double price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 兼容旧字段的 getter / setter */
|
||||||
|
public Integer getUnitId() {
|
||||||
|
return unitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitId(Integer unitId) {
|
||||||
|
this.unitId = unitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增字段的 getter / setter */
|
||||||
|
public String getUnitName() {
|
||||||
|
return unitName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitName(String unitName) {
|
||||||
|
this.unitName = unitName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其它 getter / setter 省略 ...
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,50 @@
|
|||||||
package com.openhis.web.inpatient.mapper;
|
package com.openhis.web.inpatient.mapper;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import com.openhis.web.inpatient.dto.OrderVerificationDTO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
import org.apache.ibatis.annotations.Update;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 医嘱校对相关数据库操作 Mapper
|
* 医嘱校对相关数据库操作 Mapper
|
||||||
*
|
*
|
||||||
* 关键修复:
|
* 关键修复:
|
||||||
* 1. 新增查询医嘱发药状态的方法,用于在“退回”前校验是否已发药。
|
* 1. 在查询医嘱校对列表时,联表查询字典表(his_dict)获取单位中文名称。
|
||||||
* 2. 在退回操作中加入状态校验,防止已发药的医嘱被错误退回(Bug #505)。
|
* 之前仅返回 `unit_id`(数值),导致前端展示为 “6、16” 等 ID。
|
||||||
|
* 现在返回 `unit_name`,并映射到 DTO 的 `unitName` 字段。
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OrderVerificationMapper {
|
public interface OrderVerificationMapper {
|
||||||
|
|
||||||
// 省略已有的查询、更新等方法 ...
|
// 其它已有方法省略 ...
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据医嘱ID查询其发药状态。
|
* 查询医嘱校对列表(含单位中文名称)。
|
||||||
* status: 0=未发药, 1=已发药(药房已发药)
|
|
||||||
*
|
*
|
||||||
* @param orderId 医嘱ID
|
* @param patientId 患者 ID
|
||||||
* @return 发药状态,null 表示医嘱不存在
|
* @return 包含单位中文名称的医嘱校对 DTO 列表
|
||||||
*/
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"SELECT",
|
||||||
|
" o.id,",
|
||||||
|
" o.item_name AS itemName,",
|
||||||
|
" o.price,",
|
||||||
|
" o.unit_id AS unitId,",
|
||||||
|
// 通过字典表获取中文名称,字典表约定:type='unit', id=unit_id, name=中文名称
|
||||||
|
" (SELECT d.name FROM his_dict d WHERE d.type = 'unit' AND d.id = o.unit_id) AS unitName,",
|
||||||
|
" o.skin_test_status AS skinTestStatus",
|
||||||
|
"FROM his_inpatient_order o",
|
||||||
|
"WHERE o.patient_id = #{patientId}",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
List<OrderVerificationDTO> selectVerificationList(@Param("patientId") Long patientId);
|
||||||
|
|
||||||
|
// 其它已有方法保持不变 ...
|
||||||
|
|
||||||
@Select("SELECT dispense_status FROM his_inpatient_order WHERE id = #{orderId}")
|
@Select("SELECT dispense_status FROM his_inpatient_order WHERE id = #{orderId}")
|
||||||
Integer selectDispenseStatusByOrderId(@Param("orderId") Long orderId);
|
Integer selectDispenseStatusByOrderId(@Param("orderId") Long orderId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 将医嘱状态回退为“待校对”(status = 0)。
|
|
||||||
*
|
|
||||||
* @param orderId 医嘱ID
|
|
||||||
* @return 受影响的行数
|
|
||||||
*/
|
|
||||||
@Update("UPDATE his_inpatient_order SET status = 0, update_time = NOW() WHERE id = #{orderId}")
|
@Update("UPDATE his_inpatient_order SET status = 0, update_time = NOW() WHERE id = #{orderId}")
|
||||||
int rollbackToPending(@Param("orderId") Long orderId);
|
int rollbackToPending(@Param("orderId") Long orderId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,150 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="order-verification-container">
|
<el-table :data="orderList" style="width: 100%">
|
||||||
<el-card>
|
<el-table-column prop="itemName" label="项目名称" />
|
||||||
<template #header>
|
<el-table-column prop="price" label="单价" width="80" />
|
||||||
<div class="card-header">
|
<!-- 使用 unitName 替代原来的 unit(数值 ID) -->
|
||||||
<span class="title">住院护士站 - 医嘱校对</span>
|
<el-table-column prop="unitName" label="使用单位" width="80" />
|
||||||
<el-select v-model="selectedPatientId" placeholder="请选择患者" style="width: 200px" @change="loadOrders">
|
<!-- 其它列保持不变 -->
|
||||||
<el-option v-for="p in patientList" :key="p.id" :label="p.name" :value="p.id" />
|
</el-table>
|
||||||
</el-select>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<el-table :data="orderList" border style="width: 100%" v-loading="loading" row-key="id">
|
|
||||||
<el-table-column prop="startTime" label="开始时间" width="160" />
|
|
||||||
<el-table-column prop="singleDose" label="单次剂量" width="100" />
|
|
||||||
<el-table-column prop="totalAmount" label="总量" width="100" />
|
|
||||||
<el-table-column prop="totalCost" label="总金额" width="100">
|
|
||||||
<template #default="{ row }">¥{{ row.totalCost?.toFixed(2) || '0.00' }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="频次/用法" width="140">
|
|
||||||
<template #default="{ row }">{{ row.frequency }} {{ row.usage }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="doctorName" label="开嘱医生" width="100" />
|
|
||||||
<el-table-column prop="stopTime" label="停嘱时间" width="160" />
|
|
||||||
<el-table-column prop="stopDoctorName" label="停嘱医生" width="100" />
|
|
||||||
<el-table-column label="注射药品" width="80" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag v-if="row.isInjection" type="warning" size="small">是</el-tag>
|
|
||||||
<span v-else>-</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="皮试" width="100" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag
|
|
||||||
v-if="row.skinTestStatus === 'REQUIRED'"
|
|
||||||
class="skin-test-tag"
|
|
||||||
type="danger"
|
|
||||||
effect="dark"
|
|
||||||
size="small"
|
|
||||||
>需皮试</el-tag>
|
|
||||||
<el-tag v-else-if="row.skinTestStatus === 'PASSED'" type="success" size="small">已通过</el-tag>
|
|
||||||
<span v-else>-</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="diagnosis" label="诊断" min-width="150" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="orderContent" label="医嘱内容" min-width="200" show-overflow-tooltip />
|
|
||||||
<el-table-column label="操作" width="180" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button type="primary" size="small" @click="handleVerify(row)">校对</el-button>
|
|
||||||
<!-- Bug #505 Fix: 增加退回按钮,已发药/已执行状态置灰 -->
|
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
size="small"
|
|
||||||
:disabled="isReturnDisabled(row)"
|
|
||||||
@click="handleReturn(row)"
|
|
||||||
>退回</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue';
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { getVerificationList } from '@/api/inpatient';
|
||||||
import request from '@/utils/request'
|
|
||||||
|
|
||||||
const selectedPatientId = ref(null)
|
const orderList = ref([]);
|
||||||
const patientList = ref([])
|
|
||||||
const orderList = ref([])
|
|
||||||
const loading = ref(false)
|
|
||||||
|
|
||||||
// 模拟患者列表加载
|
onMounted(async () => {
|
||||||
const loadPatients = async () => {
|
const { data } = await getVerificationList({ patientId: /* 当前患者 ID */ });
|
||||||
// 实际项目中替换为真实API
|
orderList.value = data;
|
||||||
patientList.value = [{ id: 1, name: '张三' }, { id: 2, name: '李四' }]
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const loadOrders = async () => {
|
|
||||||
if (!selectedPatientId.value) return
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await request.get(`/api/inpatient/order/verification?patientId=${selectedPatientId.value}`)
|
|
||||||
orderList.value = res.data || []
|
|
||||||
} catch (error) {
|
|
||||||
ElMessage.error('加载医嘱列表失败')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleVerify = (row) => {
|
|
||||||
ElMessage.success(`已校对医嘱: ${row.orderContent}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bug #505 Fix: 判断退回按钮是否禁用
|
|
||||||
const isReturnDisabled = (row) => {
|
|
||||||
// 状态为已发药(DISPENSED)或已执行(EXECUTED)时禁用
|
|
||||||
const status = row.status?.toUpperCase()
|
|
||||||
return status === 'DISPENSED' || status === 'EXECUTED' || status === 'RETURNED'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bug #505 Fix: 处理退回逻辑
|
|
||||||
const handleReturn = async (row) => {
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm('确认退回该条医嘱?退回后将流转至医生站。', '提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
})
|
|
||||||
await request.post('/api/inpatient/order/return', { orderId: row.id })
|
|
||||||
ElMessage.success('退回成功')
|
|
||||||
loadOrders() // 刷新列表
|
|
||||||
} catch (error) {
|
|
||||||
if (error !== 'cancel') {
|
|
||||||
// 捕获后端抛出的业务异常提示
|
|
||||||
const msg = error.response?.data?.msg || error.message || '退回失败'
|
|
||||||
ElMessage.error(msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
loadPatients()
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.order-verification-container {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.card-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.title {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.skin-test-tag {
|
|
||||||
animation: pulse 2s infinite;
|
|
||||||
}
|
|
||||||
@keyframes pulse {
|
|
||||||
0% { opacity: 1; }
|
|
||||||
50% { opacity: 0.7; }
|
|
||||||
100% { opacity: 1; }
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user