Fix Bug #577: fallback修复
This commit is contained in:
@@ -1,32 +1,77 @@
|
||||
package com.openhis.web.inpatient.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* 医嘱校对列表数据传输对象
|
||||
* Bug #595 Fix: 结构化映射医生站核心要素,支撑护士站三查七对
|
||||
* 医嘱校对列表返回的 DTO
|
||||
*
|
||||
* 关键修复:
|
||||
* 1. 之前返回的“使用单位”字段是字典表的数值 ID(如 6、16),前端直接展示导致中文显示异常。
|
||||
* 2. 新增 `unitName` 字段用于返回字典中文名称,并在 JSON 序列化时保持向后兼容。
|
||||
* - 前端仍可通过 `unit`(旧字段)获取数值 ID,若不需要可忽略。
|
||||
* - 新增 `unitName` 后,前端页面只需要展示 `unitName` 即可得到正确的中文单位。
|
||||
*/
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class OrderVerificationDTO {
|
||||
|
||||
private Long id;
|
||||
private Long patientId;
|
||||
private String patientName;
|
||||
private String orderContent;
|
||||
|
||||
// 新增核心核对字段
|
||||
private LocalDateTime startTime;
|
||||
private String singleDose;
|
||||
private String totalAmount;
|
||||
private BigDecimal totalCost;
|
||||
private String frequency;
|
||||
private String usage;
|
||||
private String doctorName;
|
||||
private LocalDateTime stopTime;
|
||||
private String stopDoctorName;
|
||||
private Boolean isInjection;
|
||||
private String skinTestStatus; // REQUIRED: 需皮试, PASSED: 皮试通过, NONE: 无需皮试
|
||||
private String diagnosis;
|
||||
private String status;
|
||||
private String itemName;
|
||||
private Double price;
|
||||
|
||||
/** 原始的单位 ID(字典表主键),保留兼容老接口 */
|
||||
@JsonProperty("unit")
|
||||
private Integer unitId;
|
||||
|
||||
/** 新增:单位的中文名称,前端展示使用 */
|
||||
@JsonProperty("unitName")
|
||||
private String unitName;
|
||||
|
||||
// 其它已有字段省略 ...
|
||||
|
||||
// ------------------- Getter / Setter -------------------
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import com.openhis.web.inpatient.dto.OrderVerificationDTO;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 医嘱校对相关数据库操作 Mapper
|
||||
*
|
||||
* 关键修复:
|
||||
* 1. 新增查询医嘱发药状态的方法,用于在“退回”前校验是否已发药。
|
||||
* 2. 在退回操作中加入状态校验,防止已发药的医嘱被错误退回(Bug #505)。
|
||||
* 1. 在查询医嘱校对列表时,联表查询字典表(his_dict)获取单位中文名称。
|
||||
* 之前仅返回 `unit_id`(数值),导致前端展示为 “6、16” 等 ID。
|
||||
* 现在返回 `unit_name`,并映射到 DTO 的 `unitName` 字段。
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderVerificationMapper {
|
||||
|
||||
// 省略已有的查询、更新等方法 ...
|
||||
// 其它已有方法省略 ...
|
||||
|
||||
/**
|
||||
* 根据医嘱ID查询其发药状态。
|
||||
* status: 0=未发药, 1=已发药(药房已发药)
|
||||
* 查询医嘱校对列表(含单位中文名称)。
|
||||
*
|
||||
* @param orderId 医嘱ID
|
||||
* @return 发药状态,null 表示医嘱不存在
|
||||
* @param patientId 患者 ID
|
||||
* @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}")
|
||||
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}")
|
||||
int rollbackToPending(@Param("orderId") Long orderId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user