Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -123,6 +124,7 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
if (query == null) {
|
||||
query = new com.openhis.appointmentmanage.dto.TicketQueryDTO();
|
||||
}
|
||||
normalizeQueryStatus(query);
|
||||
|
||||
// 2. 构造 MyBatis 的分页对象 (传入前端给的当前页和每页条数)
|
||||
com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.openhis.appointmentmanage.domain.TicketSlotDTO> pageParam = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(
|
||||
@@ -140,42 +142,67 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
|
||||
// 基础字段映射
|
||||
dto.setSlot_id(raw.getSlotId());
|
||||
dto.setSeqNo(raw.getSeqNo());
|
||||
dto.setBusNo(String.valueOf(raw.getSlotId()));
|
||||
dto.setDoctor(raw.getDoctor());
|
||||
dto.setDepartment(raw.getDepartmentName()); // 注意:以前这里传成了ID,导致前端出Bug,现在修复成了真正的科室名
|
||||
dto.setFee(raw.getFee());
|
||||
dto.setPatientName(raw.getPatientName());
|
||||
dto.setPatientId(raw.getPatientId() != null ? String.valueOf(raw.getPatientId()) : null);
|
||||
dto.setPatientId(raw.getMedicalCard());
|
||||
dto.setPhone(raw.getPhone());
|
||||
dto.setIdCard(raw.getIdCard());
|
||||
dto.setDoctorId(raw.getDoctorId());
|
||||
dto.setDepartmentId(raw.getDepartmentId());
|
||||
dto.setRealPatientId(raw.getPatientId());
|
||||
|
||||
// 性别处理:直接读取优先级最高的订单性别字段 (SQL 已处理优先级)
|
||||
if (raw.getPatientGender() != null) {
|
||||
String pg = raw.getPatientGender().trim();
|
||||
dto.setGender("1".equals(pg) ? "男" : ("2".equals(pg) ? "女" : "未知"));
|
||||
} else {
|
||||
dto.setGender("未知");
|
||||
}
|
||||
|
||||
// 号源类型处理 (底层是1,前端要的是expert)
|
||||
if (raw.getRegType() != null && raw.getRegType() == 1) {
|
||||
dto.setTicketType("expert");
|
||||
} else {
|
||||
dto.setTicketType("general");
|
||||
}
|
||||
|
||||
// 拼接就诊时间
|
||||
if (raw.getScheduleDate() != null && raw.getExpectTime() != null) {
|
||||
dto.setDateTime(raw.getScheduleDate().toString() + " " + raw.getExpectTime().toString());
|
||||
try {
|
||||
dto.setAppointmentDate(
|
||||
new java.text.SimpleDateFormat("yyyy-MM-dd").parse(raw.getScheduleDate().toString()));
|
||||
String timeStr = raw.getAppointmentTime() != null ? raw.getAppointmentTime() : (raw.getScheduleDate().toString() + " " + raw.getExpectTime().toString());
|
||||
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(timeStr.length() > 10 ? "yyyy-MM-dd HH:mm" : "yyyy-MM-dd");
|
||||
java.util.Date date = sdf.parse(timeStr);
|
||||
dto.setAppointmentDate(date);
|
||||
dto.setAppointmentTime(date);
|
||||
} catch (Exception e) {
|
||||
dto.setAppointmentDate(new java.util.Date());
|
||||
}
|
||||
}
|
||||
|
||||
// 精准状态翻译!把底层的1和2,翻译回前端能懂的中文
|
||||
if (Boolean.TRUE.equals(raw.getIsStopped())) {
|
||||
dto.setStatus("已停诊");
|
||||
} else {
|
||||
Integer slotStatus = raw.getSlotStatus();
|
||||
if (slotStatus != null) {
|
||||
if (SlotStatus.BOOKED.equals(slotStatus)) {
|
||||
dto.setStatus(AppointmentOrderStatus.CHECKED_IN.equals(raw.getOrderStatus()) ? "已取号" : "已预约");
|
||||
} else if (SlotStatus.STOPPED.equals(slotStatus)) {
|
||||
if (SlotStatus.CHECKED_IN.equals(slotStatus)) {
|
||||
dto.setStatus("已取号");
|
||||
} else if (SlotStatus.BOOKED.equals(slotStatus)) {
|
||||
if (AppointmentOrderStatus.CHECKED_IN.equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("已取号");
|
||||
} else if (AppointmentOrderStatus.RETURNED.equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("已退号");
|
||||
} else {
|
||||
dto.setStatus("已预约");
|
||||
}
|
||||
} else if (SlotStatus.RETURNED.equals(slotStatus)) {
|
||||
dto.setStatus("已退号");
|
||||
} else if (SlotStatus.CANCELLED.equals(slotStatus)) {
|
||||
dto.setStatus("已停诊");
|
||||
} else if (SlotStatus.LOCKED.equals(slotStatus)) {
|
||||
dto.setStatus("已锁定");
|
||||
} else {
|
||||
dto.setStatus("未预约");
|
||||
}
|
||||
@@ -198,6 +225,62 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一状态入参,避免前端状态值大小写/中文/数字差异导致 SQL 条件失效后回全量数据
|
||||
*/
|
||||
private void normalizeQueryStatus(com.openhis.appointmentmanage.dto.TicketQueryDTO query) {
|
||||
String rawStatus = query.getStatus();
|
||||
if (rawStatus == null) {
|
||||
return;
|
||||
}
|
||||
String normalized = rawStatus.trim();
|
||||
if (normalized.isEmpty()) {
|
||||
query.setStatus(null);
|
||||
return;
|
||||
}
|
||||
String lower = normalized.toLowerCase(Locale.ROOT);
|
||||
switch (lower) {
|
||||
case "all":
|
||||
case "全部":
|
||||
query.setStatus("all");
|
||||
break;
|
||||
case "unbooked":
|
||||
case "0":
|
||||
case "未预约":
|
||||
query.setStatus("unbooked");
|
||||
break;
|
||||
case "booked":
|
||||
case "1":
|
||||
case "已预约":
|
||||
query.setStatus("booked");
|
||||
break;
|
||||
case "checked":
|
||||
case "checkin":
|
||||
case "checkedin":
|
||||
case "2":
|
||||
case "已取号":
|
||||
query.setStatus("checked");
|
||||
break;
|
||||
case "cancelled":
|
||||
case "canceled":
|
||||
case "3":
|
||||
case "已停诊":
|
||||
case "已取消":
|
||||
query.setStatus("cancelled");
|
||||
break;
|
||||
case "returned":
|
||||
case "4":
|
||||
case "5":
|
||||
case "已退号":
|
||||
query.setStatus("returned");
|
||||
break;
|
||||
default:
|
||||
// 设置为 impossible 值,配合 mapper 的 otherwise 分支直接返回空
|
||||
query.setStatus("__invalid__");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> listDoctorAvailability(com.openhis.appointmentmanage.dto.TicketQueryDTO query) {
|
||||
if (query == null) {
|
||||
@@ -237,12 +320,13 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
// --- 基础字段处理 ---
|
||||
// 注意:这里已经变成了极其舒服的 .getSlotId() 方法调用,告别魔鬼字符串!
|
||||
dto.setSlot_id(raw.getSlotId());
|
||||
dto.setSeqNo(raw.getSeqNo());
|
||||
dto.setBusNo(String.valueOf(raw.getSlotId())); // 暂时借用真实槽位ID做唯一流水号
|
||||
dto.setDoctor(raw.getDoctor());
|
||||
dto.setDepartment(raw.getDepartmentName());
|
||||
dto.setFee(raw.getFee());
|
||||
dto.setPatientName(raw.getPatientName());
|
||||
dto.setPatientId(raw.getPatientId() != null ? String.valueOf(raw.getPatientId()) : null);
|
||||
dto.setPatientId(raw.getMedicalCard());
|
||||
dto.setPhone(raw.getPhone());
|
||||
|
||||
// --- 号源类型处理 (普通/专家) ---
|
||||
@@ -258,9 +342,13 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
if (raw.getScheduleDate() != null && raw.getExpectTime() != null) {
|
||||
dto.setDateTime(raw.getScheduleDate().toString() + " " + raw.getExpectTime().toString());
|
||||
try {
|
||||
dto.setAppointmentDate(
|
||||
new java.text.SimpleDateFormat("yyyy-MM-dd").parse(raw.getScheduleDate().toString()));
|
||||
String timeStr = raw.getAppointmentTime() != null ? raw.getAppointmentTime() : (raw.getScheduleDate().toString() + " " + raw.getExpectTime().toString());
|
||||
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(timeStr.length() > 10 ? "yyyy-MM-dd HH:mm" : "yyyy-MM-dd");
|
||||
java.util.Date date = sdf.parse(timeStr);
|
||||
dto.setAppointmentDate(date);
|
||||
dto.setAppointmentTime(date);
|
||||
} catch (Exception e) {
|
||||
log.error("时间解析失败", e);
|
||||
dto.setAppointmentDate(new java.util.Date());
|
||||
}
|
||||
}
|
||||
@@ -273,10 +361,22 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
// 第二关:看独立的细分槽位状态 (0: 可用, 1: 已预约, 2: 已取消...)
|
||||
Integer slotStatus = raw.getSlotStatus();
|
||||
if (slotStatus != null) {
|
||||
if (SlotStatus.BOOKED.equals(slotStatus)) {
|
||||
dto.setStatus(AppointmentOrderStatus.CHECKED_IN.equals(raw.getOrderStatus()) ? "已取号" : "已预约");
|
||||
} else if (SlotStatus.STOPPED.equals(slotStatus)) {
|
||||
dto.setStatus("已停诊"); // 视业务可改回已取消
|
||||
if (SlotStatus.CHECKED_IN.equals(slotStatus)) {
|
||||
dto.setStatus("已取号");
|
||||
} else if (SlotStatus.BOOKED.equals(slotStatus)) {
|
||||
if (AppointmentOrderStatus.CHECKED_IN.equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("已取号");
|
||||
} else if (AppointmentOrderStatus.RETURNED.equals(raw.getOrderStatus())) {
|
||||
dto.setStatus("已退号");
|
||||
} else {
|
||||
dto.setStatus("已预约");
|
||||
}
|
||||
} else if (SlotStatus.RETURNED.equals(slotStatus)) {
|
||||
dto.setStatus("已退号");
|
||||
} else if (SlotStatus.CANCELLED.equals(slotStatus)) {
|
||||
dto.setStatus("已停诊");
|
||||
} else if (SlotStatus.LOCKED.equals(slotStatus)) {
|
||||
dto.setStatus("已锁定");
|
||||
} else {
|
||||
dto.setStatus("未预约");
|
||||
}
|
||||
@@ -355,15 +455,12 @@ public class TicketAppServiceImpl implements ITicketAppService {
|
||||
if (patient != null) {
|
||||
Integer genderEnum = patient.getGenderEnum();
|
||||
if (genderEnum != null) {
|
||||
switch (genderEnum) {
|
||||
case 1:
|
||||
dto.setGender("男");
|
||||
break;
|
||||
case 2:
|
||||
dto.setGender("女");
|
||||
break;
|
||||
default:
|
||||
dto.setGender("未知");
|
||||
if (Integer.valueOf(1).equals(genderEnum)) {
|
||||
dto.setGender("男");
|
||||
} else if (Integer.valueOf(2).equals(genderEnum)) {
|
||||
dto.setGender("女");
|
||||
} else {
|
||||
dto.setGender("未知");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ public class TicketDto {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long slot_id;
|
||||
|
||||
/**
|
||||
* 号源序号(对应 adm_schedule_slot.seq_no)
|
||||
*/
|
||||
private Integer seqNo;
|
||||
|
||||
/**
|
||||
* 号源编码
|
||||
*/
|
||||
@@ -99,4 +104,15 @@ public class TicketDto {
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long doctorId;
|
||||
|
||||
/**
|
||||
* 真实患者ID(数据库主键,区别于 patientId 存的就诊卡号)
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long realPatientId;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idCard;
|
||||
}
|
||||
|
||||
@@ -73,11 +73,10 @@ public class OutpatientPricingAppServiceImpl implements IOutpatientPricingAppSer
|
||||
} else {
|
||||
adviceTypes = List.of(1, 2, 3);
|
||||
}
|
||||
// 门诊划价:不要强制 pricingFlag=1 参与过滤(wor_activity_definition.pricing_flag 可能为 0),
|
||||
// 否则会导致诊疗项目(adviceType=3)查询结果为空 records=[]
|
||||
String categoryCode = adviceBaseDto != null ? adviceBaseDto.getCategoryCode() : null;
|
||||
// 门诊划价:仅返回划价标记为“是”的项目
|
||||
return iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId, null,
|
||||
organizationId, pageNo, pageSize, null, adviceTypes, null, categoryCode);
|
||||
organizationId, pageNo, pageSize, Whether.YES.getValue(), adviceTypes, null, categoryCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@ import com.openhis.common.enums.ybenums.YbPayment;
|
||||
import com.openhis.common.utils.EnumUtils;
|
||||
import com.openhis.common.utils.HisPageUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.appointmentmanage.mapper.SchedulePoolMapper;
|
||||
import com.openhis.appointmentmanage.mapper.ScheduleSlotMapper;
|
||||
import com.openhis.clinical.domain.Order;
|
||||
import com.openhis.clinical.service.IOrderService;
|
||||
import com.openhis.financial.domain.PaymentReconciliation;
|
||||
import com.openhis.financial.domain.RefundLog;
|
||||
import com.openhis.financial.service.IRefundLogService;
|
||||
@@ -48,6 +52,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -97,6 +102,15 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
@Resource
|
||||
IRefundLogService iRefundLogService;
|
||||
|
||||
@Resource
|
||||
IOrderService orderService;
|
||||
|
||||
@Resource
|
||||
ScheduleSlotMapper scheduleSlotMapper;
|
||||
|
||||
@Resource
|
||||
SchedulePoolMapper schedulePoolMapper;
|
||||
|
||||
/**
|
||||
* 门诊挂号 - 查询患者信息
|
||||
*
|
||||
@@ -291,6 +305,11 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
}
|
||||
}
|
||||
|
||||
// 如果本次门诊挂号来自预约签到,同步把预约订单与号源槽位状态改为已退号
|
||||
if (result != null && result.getCode() == 200) {
|
||||
syncAppointmentReturnStatus(byId, cancelRegPaymentDto.getReason());
|
||||
}
|
||||
|
||||
// 记录退号日志
|
||||
recordRefundLog(cancelRegPaymentDto, byId, result, paymentRecon);
|
||||
|
||||
@@ -399,6 +418,74 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
return R.ok("已取消挂号");
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步预约号源状态为已退号。
|
||||
* 说明:
|
||||
* 1) 门诊退号主流程不依赖该步骤成功与否,因此此方法内部异常仅记录日志,不向上抛出。
|
||||
* 2) 通过患者、科室、日期以及状态筛选最近一条预约订单,尽量避免误匹配。
|
||||
*/
|
||||
private void syncAppointmentReturnStatus(Encounter encounter, String reason) {
|
||||
if (encounter == null || encounter.getPatientId() == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getPatientId, encounter.getPatientId())
|
||||
.in(Order::getStatus, CommonConstants.AppointmentOrderStatus.BOOKED,
|
||||
CommonConstants.AppointmentOrderStatus.CHECKED_IN)
|
||||
.orderByDesc(Order::getUpdateTime)
|
||||
.orderByDesc(Order::getCreateTime)
|
||||
.last("LIMIT 1");
|
||||
|
||||
if (encounter.getOrganizationId() != null) {
|
||||
queryWrapper.eq(Order::getDepartmentId, encounter.getOrganizationId());
|
||||
}
|
||||
if (encounter.getTenantId() != null) {
|
||||
queryWrapper.eq(Order::getTenantId, encounter.getTenantId());
|
||||
}
|
||||
if (encounter.getCreateTime() != null) {
|
||||
LocalDate encounterDate = encounter.getCreateTime().toInstant()
|
||||
.atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
Date startOfDay = Date.from(encounterDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
Date nextDayStart = Date.from(encounterDate.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
queryWrapper.ge(Order::getAppointmentDate, startOfDay)
|
||||
.lt(Order::getAppointmentDate, nextDayStart);
|
||||
}
|
||||
|
||||
Order appointmentOrder = orderService.getOne(queryWrapper, false);
|
||||
if (appointmentOrder == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
if (!CommonConstants.AppointmentOrderStatus.RETURNED.equals(appointmentOrder.getStatus())) {
|
||||
Order updateOrder = new Order();
|
||||
updateOrder.setId(appointmentOrder.getId());
|
||||
updateOrder.setStatus(CommonConstants.AppointmentOrderStatus.RETURNED);
|
||||
updateOrder.setCancelTime(now);
|
||||
updateOrder.setCancelReason(
|
||||
StringUtils.isNotEmpty(reason) ? reason : "门诊退号");
|
||||
updateOrder.setUpdateTime(now);
|
||||
orderService.updateById(updateOrder);
|
||||
}
|
||||
|
||||
Long slotId = appointmentOrder.getSlotId();
|
||||
if (slotId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int slotRows = scheduleSlotMapper.updateSlotStatus(slotId, CommonConstants.SlotStatus.RETURNED);
|
||||
if (slotRows > 0) {
|
||||
Long poolId = scheduleSlotMapper.selectPoolIdBySlotId(slotId);
|
||||
if (poolId != null) {
|
||||
schedulePoolMapper.refreshPoolStats(poolId);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("同步预约号源已退号状态失败, encounterId={}", encounter.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 补打挂号
|
||||
* 补打挂号不需要修改数据库,只需要返回成功即可,前端已有所有需要的数据用于打印
|
||||
|
||||
@@ -205,6 +205,11 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
// 构建查询条件
|
||||
QueryWrapper<AdviceBaseDto> queryWrapper = HisQueryUtils.buildQueryWrapper(adviceBaseDto, searchKey,
|
||||
new HashSet<>(Arrays.asList("advice_name", "py_str", "wb_str")), null);
|
||||
// 🔧 BugFix#339: 药房筛选条件失效 - 添加 locationId 过滤条件
|
||||
if (locationId != null) {
|
||||
queryWrapper.eq("location_id", locationId);
|
||||
log.info("BugFix#339: 添加药房筛选条件 locationId={}", locationId);
|
||||
}
|
||||
IPage<AdviceBaseDto> adviceBaseInfo = doctorStationAdviceAppMapper.getAdviceBaseInfo(
|
||||
new Page<>(pageNo, pageSize), PublicationStatus.ACTIVE.getValue(), organizationId,
|
||||
CommonConstants.TableName.MED_MEDICATION_DEFINITION, CommonConstants.TableName.ADM_DEVICE_DEFINITION,
|
||||
@@ -561,6 +566,24 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
return R.fail(null, "无法获取患者信息,请重新选择患者");
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 BugFix#338: 门诊划价新增时校验就诊状态和诊断记录(患者安全)
|
||||
// 仅对新增/修改操作进行校验,删除操作不需要
|
||||
if (!DbOpType.DELETE.getCode().equals(adviceSaveDto.getDbOpType())) {
|
||||
// 1. 校验就诊状态:必须是已接诊状态
|
||||
Encounter encounterCheck = iEncounterService.getById(adviceSaveDto.getEncounterId());
|
||||
if (encounterCheck != null) {
|
||||
// 就诊状态:1001=挂号,1002=已接诊,1003=已收费,1004=已完成
|
||||
if (encounterCheck.getStatusEnum() != null &&
|
||||
encounterCheck.getStatusEnum() != 1002 &&
|
||||
encounterCheck.getStatusEnum() != 1003 &&
|
||||
encounterCheck.getStatusEnum() != 1004) {
|
||||
log.error("BugFix#338: 患者未接诊,禁止划价/保存医嘱:encounterId={}, status={}",
|
||||
adviceSaveDto.getEncounterId(), encounterCheck.getStatusEnum());
|
||||
return R.fail(null, "患者尚未接诊,无法保存医嘱。请先完成接诊操作!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 药品(前端adviceType=1)
|
||||
@@ -770,6 +793,18 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 确保practitionerId不为null
|
||||
if (adviceSaveDto.getPractitionerId() == null) {
|
||||
adviceSaveDto.setPractitionerId(SecurityUtils.getLoginUser().getPractitionerId());
|
||||
log.info("handMedication - 自动补全practitionerId: practitionerId={}", adviceSaveDto.getPractitionerId());
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 确保founderOrgId不为null
|
||||
if (adviceSaveDto.getFounderOrgId() == null) {
|
||||
adviceSaveDto.setFounderOrgId(SecurityUtils.getLoginUser().getOrgId());
|
||||
log.info("handMedication - 自动补全founderOrgId: founderOrgId={}", adviceSaveDto.getFounderOrgId());
|
||||
}
|
||||
|
||||
boolean firstTimeSave = false;// 第一次保存
|
||||
medicationRequest = new MedicationRequest();
|
||||
medicationRequest.setId(adviceSaveDto.getRequestId()); // 主键id
|
||||
@@ -1137,6 +1172,18 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 确保practitionerId不为null
|
||||
if (adviceSaveDto.getPractitionerId() == null) {
|
||||
adviceSaveDto.setPractitionerId(SecurityUtils.getLoginUser().getPractitionerId());
|
||||
log.info("自动补全practitionerId: practitionerId={}", adviceSaveDto.getPractitionerId());
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 确保founderOrgId不为null
|
||||
if (adviceSaveDto.getFounderOrgId() == null) {
|
||||
adviceSaveDto.setFounderOrgId(SecurityUtils.getLoginUser().getOrgId());
|
||||
log.info("自动补全founderOrgId: founderOrgId={}", adviceSaveDto.getFounderOrgId());
|
||||
}
|
||||
|
||||
deviceRequest = new DeviceRequest();
|
||||
deviceRequest.setId(adviceSaveDto.getRequestId()); // 主键id
|
||||
deviceRequest.setStatusEnum(is_save ? RequestStatus.DRAFT.getValue() : RequestStatus.ACTIVE.getValue()); // 请求状态
|
||||
@@ -1201,6 +1248,47 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
chargeItem.setServiceId(deviceRequest.getId()); // 医疗服务ID
|
||||
chargeItem.setProductTable(adviceSaveDto.getAdviceTableName());// 产品所在表
|
||||
chargeItem.setProductId(adviceSaveDto.getAdviceDefinitionId());// 收费项id
|
||||
|
||||
// 🔧 Bug Fix: 如果 definitionId 或 definitionDetailId 为 null,从定价信息中获取
|
||||
if (chargeItem.getDefinitionId() == null || chargeItem.getDefDetailId() == null) {
|
||||
log.warn("耗材的 definitionId 或 definitionDetailId 为 null,尝试从定价信息中获取: deviceDefId={}",
|
||||
adviceSaveDto.getAdviceDefinitionId());
|
||||
// 查询耗材定价信息
|
||||
IPage<AdviceBaseDto> devicePage = doctorStationAdviceAppMapper.getAdviceBaseInfo(
|
||||
new Page<>(1, 1),
|
||||
PublicationStatus.ACTIVE.getValue(),
|
||||
orgId,
|
||||
CommonConstants.TableName.ADM_DEVICE_DEFINITION,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Arrays.asList(adviceSaveDto.getAdviceDefinitionId()),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
if (devicePage != null && !devicePage.getRecords().isEmpty()) {
|
||||
AdviceBaseDto deviceBaseInfo = devicePage.getRecords().get(0);
|
||||
if (deviceBaseInfo.getPriceList() != null && !deviceBaseInfo.getPriceList().isEmpty()) {
|
||||
AdvicePriceDto devicePrice = deviceBaseInfo.getPriceList().get(0);
|
||||
if (chargeItem.getDefinitionId() == null) {
|
||||
chargeItem.setDefinitionId(devicePrice.getDefinitionId());
|
||||
log.info("从定价信息中获取 definitionId: {}", devicePrice.getDefinitionId());
|
||||
}
|
||||
if (chargeItem.getDefDetailId() == null) {
|
||||
chargeItem.setDefDetailId(devicePrice.getDefinitionDetailId());
|
||||
log.info("从定价信息中获取 definitionDetailId: {}", devicePrice.getDefinitionDetailId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 确保定义ID不为null
|
||||
if (chargeItem.getDefinitionId() == null) {
|
||||
log.error("无法获取耗材的 definitionId: deviceDefId={}", adviceSaveDto.getAdviceDefinitionId());
|
||||
throw new ServiceException("无法获取耗材的定价信息,请联系管理员");
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 如果accountId为null,从就诊中获取账户ID,如果没有则自动创建
|
||||
Long accountId = adviceSaveDto.getAccountId();
|
||||
if (accountId == null) {
|
||||
@@ -1323,6 +1411,18 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 确保practitionerId不为null
|
||||
if (adviceSaveDto.getPractitionerId() == null) {
|
||||
adviceSaveDto.setPractitionerId(SecurityUtils.getLoginUser().getPractitionerId());
|
||||
log.info("handService - 自动补全practitionerId: practitionerId={}", adviceSaveDto.getPractitionerId());
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 确保founderOrgId不为null
|
||||
if (adviceSaveDto.getFounderOrgId() == null) {
|
||||
adviceSaveDto.setFounderOrgId(SecurityUtils.getLoginUser().getOrgId());
|
||||
log.info("handService - 自动补全founderOrgId: founderOrgId={}", adviceSaveDto.getFounderOrgId());
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix #238: 诊疗项目执行科室非空校验
|
||||
if (adviceSaveDto.getAdviceType() != null && adviceSaveDto.getAdviceType() == 3) {
|
||||
Long effectiveOrgId = adviceSaveDto.getEffectiveOrgId();
|
||||
|
||||
@@ -115,6 +115,15 @@ public class AdviceUtils {
|
||||
matched = true;
|
||||
// 检查库存是否充足
|
||||
BigDecimal minUnitQuantity = saveDto.getMinUnitQuantity();
|
||||
// 🔧 Bug Fix: 对于耗材类型,如果没有设置minUnitQuantity,则使用quantity作为默认值
|
||||
if (minUnitQuantity == null) {
|
||||
if (CommonConstants.TableName.ADM_DEVICE_DEFINITION.equals(inventoryDto.getItemTable())) {
|
||||
// 耗材只有一个单位,minUnitQuantity等于quantity
|
||||
minUnitQuantity = saveDto.getQuantity();
|
||||
} else {
|
||||
return saveDto.getAdviceName() + "的小单位数量不能为空";
|
||||
}
|
||||
}
|
||||
BigDecimal chineseHerbsDoseQuantity = saveDto.getChineseHerbsDoseQuantity(); // 中药付数
|
||||
// 中草药医嘱的情况
|
||||
if (chineseHerbsDoseQuantity != null && chineseHerbsDoseQuantity.compareTo(BigDecimal.ZERO) > 0) {
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
T9.gender_enum AS genderEnum,
|
||||
T9.id_card AS idCard,
|
||||
T9.status_enum AS statusEnum,
|
||||
T9.register_time AS registerTime,
|
||||
T9.register_time AS register_time,
|
||||
T9.total_price AS totalPrice,
|
||||
T9.account_name AS accountName,
|
||||
T9.enterer_name AS entererName,
|
||||
|
||||
Reference in New Issue
Block a user