76 门诊预约挂号
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.openhis.clinical.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.core.common.core.domain.HisBaseEntity;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@TableName("order_main")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Order extends HisBaseEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private Long patientId;
|
||||
|
||||
private String patientName;
|
||||
|
||||
private String medicalCard;
|
||||
|
||||
private String phone;
|
||||
|
||||
private Integer gender;
|
||||
|
||||
private Long scheduleId;
|
||||
|
||||
private Long slotId;
|
||||
|
||||
private Long departmentId;
|
||||
|
||||
private String departmentName;
|
||||
|
||||
private Long doctorId;
|
||||
|
||||
private String doctorName;
|
||||
|
||||
private String regType;
|
||||
|
||||
private BigDecimal fee;
|
||||
|
||||
private Date appointmentDate;
|
||||
|
||||
private Date appointmentTime;
|
||||
|
||||
private Date cancelTime;
|
||||
|
||||
private String cancelReason;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Integer payStatus;
|
||||
|
||||
private Integer version;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.openhis.clinical.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.core.common.core.domain.HisBaseEntity;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 号源管理Entity实体
|
||||
*
|
||||
* @author system
|
||||
*/
|
||||
@Data
|
||||
@TableName("clinical_ticket")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Ticket extends HisBaseEntity {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 号源编码
|
||||
*/
|
||||
private String busNo;
|
||||
|
||||
/**
|
||||
* 科室名称
|
||||
*/
|
||||
private String department;
|
||||
|
||||
/**
|
||||
* 医生姓名
|
||||
*/
|
||||
private String doctor;
|
||||
|
||||
/**
|
||||
* 号源类型 (普通/专家)
|
||||
*/
|
||||
private String ticketType;
|
||||
|
||||
/**
|
||||
* 挂号时间
|
||||
*/
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 状态 (unbooked:未预约, booked:已预约, checked:已取号, cancelled:已取消, locked:已锁定)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 挂号费
|
||||
*/
|
||||
private String fee;
|
||||
|
||||
/**
|
||||
* 患者ID
|
||||
*/
|
||||
private Long patientId;
|
||||
|
||||
/**
|
||||
* 患者姓名
|
||||
*/
|
||||
private String patientName;
|
||||
|
||||
/**
|
||||
* 就诊卡号
|
||||
*/
|
||||
private String medicalCard;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 预约日期
|
||||
*/
|
||||
private Date appointmentDate;
|
||||
|
||||
/**
|
||||
* 预约时间
|
||||
*/
|
||||
private Date appointmentTime;
|
||||
|
||||
/**
|
||||
* 科室ID
|
||||
*/
|
||||
private Long departmentId;
|
||||
|
||||
/**
|
||||
* 医生ID
|
||||
*/
|
||||
private Long doctorId;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.openhis.clinical.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.openhis.clinical.domain.Order;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface OrderMapper extends BaseMapper<Order> {
|
||||
|
||||
List<Order> selectOrderList(Order order);
|
||||
|
||||
Page<Order> selectOrderPage(Page<Order> page, @Param("order") Order order);
|
||||
|
||||
Order selectOrderById(Long id);
|
||||
|
||||
int insertOrder(Order order);
|
||||
|
||||
int updateOrder(Order order);
|
||||
|
||||
int deleteOrderById(Long id);
|
||||
|
||||
int deleteOrderByIds(Long[] ids);
|
||||
|
||||
int countOrders(Map<String, Object> params);
|
||||
|
||||
Order selectOrderBySlotId(Long slotId);
|
||||
|
||||
int updateOrderStatusById(Long id, Integer status);
|
||||
|
||||
int updateOrderCancelInfoById(Long id, Date cancelTime, String cancelReason);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.openhis.clinical.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.openhis.clinical.domain.Ticket;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 号源管理Mapper接口
|
||||
*
|
||||
* @author system
|
||||
*/
|
||||
public interface TicketMapper extends BaseMapper<Ticket> {
|
||||
|
||||
/**
|
||||
* 查询号源列表
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 号源集合
|
||||
*/
|
||||
List<Ticket> selectTicketList(Ticket ticket);
|
||||
|
||||
/**
|
||||
* 分页查询号源列表
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param ticket 号源信息
|
||||
* @return 号源集合
|
||||
*/
|
||||
Page<Ticket> selectTicketPage(Page<Ticket> page, @Param("ticket") Ticket ticket);
|
||||
|
||||
/**
|
||||
* 查询号源信息
|
||||
*
|
||||
* @param id 号源ID
|
||||
* @return 号源信息
|
||||
*/
|
||||
Ticket selectTicketById(Long id);
|
||||
|
||||
/**
|
||||
* 新增号源
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertTicket(Ticket ticket);
|
||||
|
||||
/**
|
||||
* 修改号源
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateTicket(Ticket ticket);
|
||||
|
||||
/**
|
||||
* 删除号源
|
||||
*
|
||||
* @param id 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTicketById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除号源
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTicketByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据条件统计号源数量
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return 号源数量
|
||||
*/
|
||||
int countTickets(Map<String, Object> params);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.openhis.clinical.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.clinical.domain.Order;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IOrderService extends IService<Order> {
|
||||
|
||||
List<Order> selectOrderList(Order order);
|
||||
|
||||
Page<Order> selectOrderPage(Page<Order> page, Order order);
|
||||
|
||||
Order selectOrderById(Long id);
|
||||
|
||||
int insertOrder(Order order);
|
||||
|
||||
int updateOrder(Order order);
|
||||
|
||||
int deleteOrderByIds(Long[] ids);
|
||||
|
||||
int deleteOrderById(Long id);
|
||||
|
||||
int countOrders(Map<String, Object> params);
|
||||
|
||||
Order selectOrderBySlotId(Long slotId);
|
||||
|
||||
int updateOrderStatusById(Long id, Integer status);
|
||||
|
||||
int updateOrderCancelInfoById(Long id, java.util.Date cancelTime, String cancelReason);
|
||||
|
||||
Order createAppointmentOrder(Map<String, Object> params);
|
||||
|
||||
int cancelAppointmentOrder(Long orderId, String cancelReason);
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.openhis.clinical.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.clinical.domain.Ticket;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 号源管理Service接口
|
||||
*
|
||||
* @author system
|
||||
*/
|
||||
public interface ITicketService extends IService<Ticket> {
|
||||
|
||||
/**
|
||||
* 查询号源列表
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 号源集合
|
||||
*/
|
||||
List<Ticket> selectTicketList(Ticket ticket);
|
||||
|
||||
/**
|
||||
* 分页查询号源列表
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param ticket 号源信息
|
||||
* @return 号源集合
|
||||
*/
|
||||
Page<Ticket> selectTicketPage(Page<Ticket> page, Ticket ticket);
|
||||
|
||||
/**
|
||||
* 查询号源信息
|
||||
*
|
||||
* @param id 号源ID
|
||||
* @return 号源信息
|
||||
*/
|
||||
Ticket selectTicketById(Long id);
|
||||
|
||||
/**
|
||||
* 新增号源
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertTicket(Ticket ticket);
|
||||
|
||||
/**
|
||||
* 修改号源
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateTicket(Ticket ticket);
|
||||
|
||||
/**
|
||||
* 批量删除号源
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTicketByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除号源信息
|
||||
*
|
||||
* @param id 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTicketById(Long id);
|
||||
|
||||
/**
|
||||
* 预约号源
|
||||
*
|
||||
* @param params 预约参数
|
||||
* @return 结果
|
||||
*/
|
||||
int bookTicket(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 取消预约
|
||||
*
|
||||
* @param ticketId 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
int cancelTicket(Long ticketId);
|
||||
|
||||
/**
|
||||
* 取号
|
||||
*
|
||||
* @param ticketId 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
int checkInTicket(Long ticketId);
|
||||
|
||||
/**
|
||||
* 停诊
|
||||
*
|
||||
* @param ticketId 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
int cancelConsultation(Long ticketId);
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.openhis.clinical.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.core.common.utils.AssignSeqUtil;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.clinical.domain.Order;
|
||||
import com.openhis.clinical.domain.Ticket;
|
||||
import com.openhis.clinical.mapper.OrderMapper;
|
||||
import com.openhis.clinical.mapper.TicketMapper;
|
||||
import com.openhis.clinical.service.IOrderService;
|
||||
import com.openhis.common.enums.AssignSeqEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
|
||||
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Resource
|
||||
private TicketMapper ticketMapper;
|
||||
|
||||
@Resource
|
||||
private AssignSeqUtil assignSeqUtil;
|
||||
|
||||
@Override
|
||||
public List<Order> selectOrderList(Order order) {
|
||||
return orderMapper.selectOrderList(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Order> selectOrderPage(Page<Order> page, Order order) {
|
||||
return orderMapper.selectOrderPage(page, order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order selectOrderById(Long id) {
|
||||
return orderMapper.selectOrderById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertOrder(Order order) {
|
||||
return orderMapper.insertOrder(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOrder(Order order) {
|
||||
return orderMapper.updateOrder(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteOrderByIds(Long[] ids) {
|
||||
return orderMapper.deleteOrderByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteOrderById(Long id) {
|
||||
return orderMapper.deleteOrderById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countOrders(Map<String, Object> params) {
|
||||
return orderMapper.countOrders(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order selectOrderBySlotId(Long slotId) {
|
||||
return orderMapper.selectOrderBySlotId(slotId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOrderStatusById(Long id, Integer status) {
|
||||
return orderMapper.updateOrderStatusById(id, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOrderCancelInfoById(Long id, Date cancelTime, String cancelReason) {
|
||||
return orderMapper.updateOrderCancelInfoById(id, cancelTime, cancelReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order createAppointmentOrder(Map<String, Object> params) {
|
||||
Long slotId = params.get("slotId") != null ? Long.valueOf(params.get("slotId").toString()) : null;
|
||||
if (slotId == null) {
|
||||
throw new RuntimeException("号源ID不能为空");
|
||||
}
|
||||
|
||||
Ticket ticket = ticketMapper.selectTicketById(slotId);
|
||||
if (ticket == null) {
|
||||
throw new RuntimeException("号源不存在");
|
||||
}
|
||||
|
||||
Order order = new Order();
|
||||
String orderNo = assignSeqUtil.getSeq(AssignSeqEnum.ORDER_NUM.getPrefix(), 18);
|
||||
order.setOrderNo(orderNo);
|
||||
|
||||
Long patientId = params.get("patientId") != null ? Long.valueOf(params.get("patientId").toString()) : null;
|
||||
String patientName = params.get("patientName") != null ? params.get("patientName").toString() : null;
|
||||
String medicalCard = params.get("medicalCard") != null ? params.get("medicalCard").toString() : null;
|
||||
String phone = params.get("phone") != null ? params.get("phone").toString() : null;
|
||||
Integer gender = params.get("gender") != null ? Integer.valueOf(params.get("gender").toString()) : null;
|
||||
|
||||
order.setPatientId(patientId);
|
||||
order.setPatientName(patientName);
|
||||
order.setMedicalCard(medicalCard);
|
||||
order.setPhone(phone);
|
||||
order.setGender(gender);
|
||||
|
||||
order.setSlotId(slotId);
|
||||
order.setDepartmentId(ticket.getDepartmentId());
|
||||
order.setDepartmentName(ticket.getDepartment());
|
||||
order.setDoctorId(ticket.getDoctorId());
|
||||
order.setDoctorName(ticket.getDoctor());
|
||||
|
||||
String regType = params.get("regType") != null ? params.get("regType").toString() : "普通";
|
||||
order.setRegType(regType);
|
||||
|
||||
BigDecimal fee = params.get("fee") != null ? new BigDecimal(params.get("fee").toString()) : BigDecimal.ZERO;
|
||||
order.setFee(fee);
|
||||
|
||||
Date appointmentDate = new Date();
|
||||
order.setAppointmentDate(appointmentDate);
|
||||
order.setAppointmentTime(new Date());
|
||||
|
||||
order.setStatus(1);
|
||||
order.setPayStatus(0);
|
||||
order.setVersion(0);
|
||||
|
||||
// 设置租户ID
|
||||
Integer tenantId = params.get("tenant_id") != null ? Integer.valueOf(params.get("tenant_id").toString()) : null;
|
||||
order.setTenantId(tenantId);
|
||||
|
||||
order.setCreateTime(new Date());
|
||||
order.setUpdateTime(new Date());
|
||||
|
||||
orderMapper.insertOrder(order);
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cancelAppointmentOrder(Long orderId, String cancelReason) {
|
||||
Order order = orderMapper.selectOrderById(orderId);
|
||||
if (order == null) {
|
||||
throw new RuntimeException("订单不存在");
|
||||
}
|
||||
if (order.getStatus() == 3) {
|
||||
throw new RuntimeException("订单已取消");
|
||||
}
|
||||
if (order.getStatus() == 2) {
|
||||
throw new RuntimeException("订单已完成,无法取消");
|
||||
}
|
||||
|
||||
Date cancelTime = new Date();
|
||||
return orderMapper.updateOrderCancelInfoById(orderId, cancelTime, cancelReason);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package com.openhis.clinical.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.clinical.domain.Order;
|
||||
import com.openhis.clinical.domain.Ticket;
|
||||
import com.openhis.clinical.mapper.TicketMapper;
|
||||
import com.openhis.clinical.service.IOrderService;
|
||||
import com.openhis.clinical.service.ITicketService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 号源管理Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
*/
|
||||
@Service
|
||||
public class TicketServiceImpl extends ServiceImpl<TicketMapper, Ticket> implements ITicketService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TicketServiceImpl.class);
|
||||
|
||||
@Resource
|
||||
private TicketMapper ticketMapper;
|
||||
|
||||
@Resource
|
||||
private IOrderService orderService;
|
||||
|
||||
/**
|
||||
* 查询号源列表
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 号源集合
|
||||
*/
|
||||
@Override
|
||||
public List<Ticket> selectTicketList(Ticket ticket) {
|
||||
return ticketMapper.selectTicketList(ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询号源列表
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param ticket 号源信息
|
||||
* @return 号源集合
|
||||
*/
|
||||
@Override
|
||||
public Page<Ticket> selectTicketPage(Page<Ticket> page, Ticket ticket) {
|
||||
return ticketMapper.selectTicketPage(page, ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询号源信息
|
||||
*
|
||||
* @param id 号源ID
|
||||
* @return 号源信息
|
||||
*/
|
||||
@Override
|
||||
public Ticket selectTicketById(Long id) {
|
||||
return ticketMapper.selectTicketById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增号源
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertTicket(Ticket ticket) {
|
||||
return ticketMapper.insertTicket(ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改号源
|
||||
*
|
||||
* @param ticket 号源信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTicket(Ticket ticket) {
|
||||
return ticketMapper.updateTicket(ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除号源
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTicketByIds(Long[] ids) {
|
||||
return ticketMapper.deleteTicketByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除号源信息
|
||||
*
|
||||
* @param id 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTicketById(Long id) {
|
||||
return ticketMapper.deleteTicketById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预约号源
|
||||
*
|
||||
* @param params 预约参数
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int bookTicket(Map<String, Object> params) {
|
||||
Long ticketId = Long.valueOf(params.get("ticketId").toString());
|
||||
Long patientId = params.get("patientId") != null ? Long.valueOf(params.get("patientId").toString()) : null;
|
||||
String patientName = params.get("patientName") != null ? params.get("patientName").toString() : null;
|
||||
String medicalCard = params.get("medicalCard") != null ? params.get("medicalCard").toString() : null;
|
||||
String phone = params.get("phone") != null ? params.get("phone").toString() : null;
|
||||
|
||||
logger.debug("开始预约号源,ticketId: {}, patientId: {}, patientName: {}", ticketId, patientId, patientName);
|
||||
|
||||
Ticket ticket = ticketMapper.selectTicketById(ticketId);
|
||||
if (ticket == null) {
|
||||
logger.error("号源不存在,ticketId: {}", ticketId);
|
||||
throw new RuntimeException("号源不存在");
|
||||
}
|
||||
|
||||
logger.debug("查询到号源信息,id: {}, status: {}, deleteFlag: {}", ticket.getId(), ticket.getStatus(), ticket.getDeleteFlag());
|
||||
|
||||
// 详细调试:检查状态字符串的详细信息
|
||||
String status = ticket.getStatus();
|
||||
logger.debug("状态字符串详细信息: value='{}', length={}, isNull={}", status, status != null ? status.length() : "null", status == null);
|
||||
if (status != null) {
|
||||
StringBuilder charInfo = new StringBuilder();
|
||||
for (int i = 0; i < status.length(); i++) {
|
||||
charInfo.append(status.charAt(i)).append("(").append((int) status.charAt(i)).append(") ");
|
||||
}
|
||||
logger.debug("状态字符串字符信息: {}", charInfo.toString());
|
||||
}
|
||||
|
||||
// 详细调试:检查每个状态比较的结果
|
||||
boolean isUnbooked = "unbooked".equals(status);
|
||||
boolean isLocked = "locked".equals(status);
|
||||
boolean isCancelled = "cancelled".equals(status);
|
||||
boolean isChecked = "checked".equals(status);
|
||||
boolean isBooked = "booked".equals(status);
|
||||
logger.debug("状态比较结果: unbooked={}, locked={}, cancelled={}, checked={}, booked={}",
|
||||
isUnbooked, isLocked, isCancelled, isChecked, isBooked);
|
||||
|
||||
if (!isUnbooked && !isLocked && !isCancelled && !isChecked && !isBooked) {
|
||||
logger.error("号源不可预约,id: {}, status: {}", ticket.getId(), ticket.getStatus());
|
||||
throw new RuntimeException("号源不可预约");
|
||||
}
|
||||
|
||||
params.put("slotId", ticketId);
|
||||
Order order = orderService.createAppointmentOrder(params);
|
||||
|
||||
Ticket updateTicket = new Ticket();
|
||||
updateTicket.setId(ticketId);
|
||||
updateTicket.setStatus("booked");
|
||||
updateTicket.setPatientId(patientId);
|
||||
updateTicket.setPatientName(patientName);
|
||||
updateTicket.setMedicalCard(medicalCard);
|
||||
updateTicket.setPhone(phone);
|
||||
updateTicket.setAppointmentDate(new Date());
|
||||
updateTicket.setAppointmentTime(new Date());
|
||||
|
||||
int result = ticketMapper.updateById(updateTicket);
|
||||
logger.debug("预约成功,更新号源状态为booked,result: {}", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消预约
|
||||
*
|
||||
* @param ticketId 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int cancelTicket(Long ticketId) {
|
||||
Ticket ticket = ticketMapper.selectTicketById(ticketId);
|
||||
if (ticket == null) {
|
||||
throw new RuntimeException("号源不存在");
|
||||
}
|
||||
if (!"booked".equals(ticket.getStatus()) && !"locked".equals(ticket.getStatus())) {
|
||||
throw new RuntimeException("号源不可取消预约");
|
||||
}
|
||||
|
||||
Order order = orderService.selectOrderBySlotId(ticketId);
|
||||
if (order != null) {
|
||||
orderService.cancelAppointmentOrder(order.getId(), "患者取消预约");
|
||||
}
|
||||
|
||||
ticket.setStatus("unbooked");
|
||||
ticket.setPatientId(null);
|
||||
ticket.setPatientName(null);
|
||||
ticket.setMedicalCard(null);
|
||||
ticket.setPhone(null);
|
||||
ticket.setAppointmentDate(null);
|
||||
ticket.setAppointmentTime(null);
|
||||
return ticketMapper.updateTicket(ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取号
|
||||
*
|
||||
* @param ticketId 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int checkInTicket(Long ticketId) {
|
||||
// 获取号源信息
|
||||
Ticket ticket = ticketMapper.selectTicketById(ticketId);
|
||||
if (ticket == null) {
|
||||
throw new RuntimeException("号源不存在");
|
||||
}
|
||||
if (!"booked".equals(ticket.getStatus()) && !"locked".equals(ticket.getStatus())) {
|
||||
throw new RuntimeException("号源不可取号");
|
||||
}
|
||||
// 更新号源状态为已取号
|
||||
ticket.setStatus("checked");
|
||||
return ticketMapper.updateTicket(ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停诊
|
||||
*
|
||||
* @param ticketId 号源ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int cancelConsultation(Long ticketId) {
|
||||
// 获取号源信息
|
||||
Ticket ticket = ticketMapper.selectTicketById(ticketId);
|
||||
if (ticket == null) {
|
||||
throw new RuntimeException("号源不存在");
|
||||
}
|
||||
|
||||
// 检查是否存在相关订单,如果存在则取消
|
||||
Order order = orderService.selectOrderBySlotId(ticketId);
|
||||
if (order != null) {
|
||||
orderService.cancelAppointmentOrder(order.getId(), "医生停诊");
|
||||
}
|
||||
|
||||
// 更新号源状态为已取消
|
||||
ticket.setStatus("cancelled");
|
||||
ticket.setPatientId(null);
|
||||
ticket.setPatientName(null);
|
||||
ticket.setMedicalCard(null);
|
||||
ticket.setPhone(null);
|
||||
ticket.setAppointmentDate(null);
|
||||
ticket.setAppointmentTime(null);
|
||||
return ticketMapper.updateTicket(ticket);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.openhis.clinical.mapper.OrderMapper">
|
||||
|
||||
<resultMap type="com.openhis.clinical.domain.Order" id="OrderResult">
|
||||
<id property="id" column="id"/>
|
||||
<result property="orderNo" column="order_no"/>
|
||||
<result property="patientId" column="patient_id"/>
|
||||
<result property="patientName" column="patient_name"/>
|
||||
<result property="medicalCard" column="medical_card"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="gender" column="gender"/>
|
||||
<result property="scheduleId" column="schedule_id"/>
|
||||
<result property="slotId" column="slot_id"/>
|
||||
<result property="departmentId" column="department_id"/>
|
||||
<result property="departmentName" column="department_name"/>
|
||||
<result property="doctorId" column="doctor_id"/>
|
||||
<result property="doctorName" column="doctor_name"/>
|
||||
<result property="regType" column="reg_type"/>
|
||||
<result property="fee" column="fee"/>
|
||||
<result property="appointmentDate" column="appointment_date"/>
|
||||
<result property="appointmentTime" column="appointment_time"/>
|
||||
<result property="cancelTime" column="cancel_time"/>
|
||||
<result property="cancelReason" column="cancel_reason"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="payStatus" column="pay_status"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectOrderList" resultMap="OrderResult">
|
||||
select * from order_main
|
||||
<where>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
and order_no = #{orderNo}
|
||||
</if>
|
||||
<if test="patientId != null">
|
||||
and patient_id = #{patientId}
|
||||
</if>
|
||||
<if test="patientName != null and patientName != ''">
|
||||
and patient_name like #{patientName}
|
||||
</if>
|
||||
<if test="medicalCard != null and medicalCard != ''">
|
||||
and medical_card = #{medicalCard}
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
and phone = #{phone}
|
||||
</if>
|
||||
<if test="scheduleId != null">
|
||||
and schedule_id = #{scheduleId}
|
||||
</if>
|
||||
<if test="slotId != null">
|
||||
and slot_id = #{slotId}
|
||||
</if>
|
||||
<if test="departmentId != null">
|
||||
and department_id = #{departmentId}
|
||||
</if>
|
||||
<if test="doctorId != null">
|
||||
and doctor_id = #{doctorId}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="payStatus != null">
|
||||
and pay_status = #{payStatus}
|
||||
</if>
|
||||
<if test="appointmentDate != null">
|
||||
and appointment_date = #{appointmentDate}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectOrderPage" resultMap="OrderResult">
|
||||
select * from order_main
|
||||
<where>
|
||||
<if test="order.orderNo != null and order.orderNo != ''">
|
||||
and order_no = #{order.orderNo}
|
||||
</if>
|
||||
<if test="order.patientId != null">
|
||||
and patient_id = #{order.patientId}
|
||||
</if>
|
||||
<if test="order.patientName != null and order.patientName != ''">
|
||||
and patient_name like #{order.patientName}
|
||||
</if>
|
||||
<if test="order.medicalCard != null and order.medicalCard != ''">
|
||||
and medical_card = #{order.medicalCard}
|
||||
</if>
|
||||
<if test="order.phone != null and order.phone != ''">
|
||||
and phone = #{order.phone}
|
||||
</if>
|
||||
<if test="order.scheduleId != null">
|
||||
and schedule_id = #{order.scheduleId}
|
||||
</if>
|
||||
<if test="order.slotId != null">
|
||||
and slot_id = #{order.slotId}
|
||||
</if>
|
||||
<if test="order.departmentId != null">
|
||||
and department_id = #{order.departmentId}
|
||||
</if>
|
||||
<if test="order.doctorId != null">
|
||||
and doctor_id = #{order.doctorId}
|
||||
</if>
|
||||
<if test="order.status != null">
|
||||
and status = #{order.status}
|
||||
</if>
|
||||
<if test="order.payStatus != null">
|
||||
and pay_status = #{order.payStatus}
|
||||
</if>
|
||||
<if test="order.appointmentDate != null">
|
||||
and appointment_date = #{order.appointmentDate}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectOrderById" resultMap="OrderResult">
|
||||
select * from order_main where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectOrderBySlotId" resultMap="OrderResult">
|
||||
select * from order_main where slot_id = #{slotId} and status = 1
|
||||
</select>
|
||||
|
||||
<insert id="insertOrder" parameterType="com.openhis.clinical.domain.Order">
|
||||
insert into order_main
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="orderNo != null and orderNo != ''">order_no,</if>
|
||||
<if test="patientId != null">patient_id,</if>
|
||||
<if test="patientName != null and patientName != ''">patient_name,</if>
|
||||
<if test="medicalCard != null and medicalCard != ''">medical_card,</if>
|
||||
<if test="phone != null and phone != ''">phone,</if>
|
||||
<if test="gender != null">gender,</if>
|
||||
<if test="scheduleId != null">schedule_id,</if>
|
||||
<if test="slotId != null">slot_id,</if>
|
||||
<if test="departmentId != null">department_id,</if>
|
||||
<if test="departmentName != null and departmentName != ''">department_name,</if>
|
||||
<if test="doctorId != null">doctor_id,</if>
|
||||
<if test="doctorName != null and doctorName != ''">doctor_name,</if>
|
||||
<if test="regType != null and regType != ''">reg_type,</if>
|
||||
<if test="fee != null">fee,</if>
|
||||
<if test="appointmentDate != null">appointment_date,</if>
|
||||
<if test="appointmentTime != null">appointment_time,</if>
|
||||
<if test="cancelTime != null">cancel_time,</if>
|
||||
<if test="cancelReason != null and cancelReason != ''">cancel_reason,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="payStatus != null">pay_status,</if>
|
||||
<if test="version != null">version,</if>
|
||||
<if test="tenantId != null">tenant_id,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
|
||||
<if test="patientId != null">#{patientId},</if>
|
||||
<if test="patientName != null and patientName != ''">#{patientName},</if>
|
||||
<if test="medicalCard != null and medicalCard != ''">#{medicalCard},</if>
|
||||
<if test="phone != null and phone != ''">#{phone},</if>
|
||||
<if test="gender != null">#{gender},</if>
|
||||
<if test="scheduleId != null">#{scheduleId},</if>
|
||||
<if test="slotId != null">#{slotId},</if>
|
||||
<if test="departmentId != null">#{departmentId},</if>
|
||||
<if test="departmentName != null and departmentName != ''">#{departmentName},</if>
|
||||
<if test="doctorId != null">#{doctorId},</if>
|
||||
<if test="doctorName != null and doctorName != ''">#{doctorName},</if>
|
||||
<if test="regType != null and regType != ''">#{regType},</if>
|
||||
<if test="fee != null">#{fee},</if>
|
||||
<if test="appointmentDate != null">#{appointmentDate},</if>
|
||||
<if test="appointmentTime != null">#{appointmentTime},</if>
|
||||
<if test="cancelTime != null">#{cancelTime},</if>
|
||||
<if test="cancelReason != null and cancelReason != ''">#{cancelReason},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="payStatus != null">#{payStatus},</if>
|
||||
<if test="version != null">#{version},</if>
|
||||
<if test="tenantId != null">#{tenantId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateOrder" parameterType="com.openhis.clinical.domain.Order">
|
||||
update order_main
|
||||
<trim prefix="set" suffixOverrides=",">
|
||||
<if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
|
||||
<if test="patientId != null">patient_id = #{patientId},</if>
|
||||
<if test="patientName != null and patientName != ''">patient_name = #{patientName},</if>
|
||||
<if test="medicalCard != null and medicalCard != ''">medical_card = #{medicalCard},</if>
|
||||
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
||||
<if test="gender != null">gender = #{gender},</if>
|
||||
<if test="scheduleId != null">schedule_id = #{scheduleId},</if>
|
||||
<if test="slotId != null">slot_id = #{slotId},</if>
|
||||
<if test="departmentId != null">department_id = #{departmentId},</if>
|
||||
<if test="departmentName != null and departmentName != ''">department_name = #{departmentName},</if>
|
||||
<if test="doctorId != null">doctor_id = #{doctorId},</if>
|
||||
<if test="doctorName != null and doctorName != ''">doctor_name = #{doctorName},</if>
|
||||
<if test="regType != null and regType != ''">reg_type = #{regType},</if>
|
||||
<if test="fee != null">fee = #{fee},</if>
|
||||
<if test="appointmentDate != null">appointment_date = #{appointmentDate},</if>
|
||||
<if test="appointmentTime != null">appointment_time = #{appointmentTime},</if>
|
||||
<if test="cancelTime != null">cancel_time = #{cancelTime},</if>
|
||||
<if test="cancelReason != null and cancelReason != ''">cancel_reason = #{cancelReason},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="payStatus != null">pay_status = #{payStatus},</if>
|
||||
<if test="version != null">version = #{version},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateOrderStatusById">
|
||||
update order_main set status = #{status} where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateOrderCancelInfoById">
|
||||
update order_main set status = 3, cancel_time = #{cancelTime}, cancel_reason = #{cancelReason} where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteOrderById">
|
||||
delete from order_main where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteOrderByIds">
|
||||
delete from order_main where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="countOrders" resultType="int">
|
||||
select count(*) from order_main
|
||||
<where>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
and order_no = #{orderNo}
|
||||
</if>
|
||||
<if test="patientId != null">
|
||||
and patient_id = #{patientId}
|
||||
</if>
|
||||
<if test="scheduleId != null">
|
||||
and schedule_id = #{scheduleId}
|
||||
</if>
|
||||
<if test="slotId != null">
|
||||
and slot_id = #{slotId}
|
||||
</if>
|
||||
<if test="departmentId != null">
|
||||
and department_id = #{departmentId}
|
||||
</if>
|
||||
<if test="doctorId != null">
|
||||
and doctor_id = #{doctorId}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="payStatus != null">
|
||||
and pay_status = #{payStatus}
|
||||
</if>
|
||||
<if test="appointmentDate != null">
|
||||
and appointment_date = #{appointmentDate}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,245 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.openhis.clinical.mapper.TicketMapper">
|
||||
|
||||
<resultMap type="com.openhis.clinical.domain.Ticket" id="TicketResult">
|
||||
<id property="id" column="id"/>
|
||||
<result property="busNo" column="bus_no"/>
|
||||
<result property="department" column="department"/>
|
||||
<result property="doctor" column="doctor"/>
|
||||
<result property="ticketType" column="ticket_type"/>
|
||||
<result property="time" column="time"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="fee" column="fee"/>
|
||||
<result property="patientId" column="patient_id"/>
|
||||
<result property="patientName" column="patient_name"/>
|
||||
<result property="medicalCard" column="medical_card"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="appointmentDate" column="appointment_date"/>
|
||||
<result property="appointmentTime" column="appointment_time"/>
|
||||
<result property="departmentId" column="department_id"/>
|
||||
<result property="doctorId" column="doctor_id"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectTicketList" parameterType="com.openhis.clinical.domain.Ticket" resultMap="TicketResult">
|
||||
select * from clinical_ticket
|
||||
<where>
|
||||
<!-- 逻辑删除条件 -->
|
||||
and delete_flag = '0'
|
||||
<!-- 其他查询条件 -->
|
||||
<if test="ticketType != null and ticketType != ''">
|
||||
and ticket_type = #{ticketType}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="appointmentDate != null">
|
||||
and appointment_date = cast(#{appointmentDate} as date)
|
||||
</if>
|
||||
<if test="doctorId != null">
|
||||
and doctor_id = #{doctorId}
|
||||
</if>
|
||||
<if test="departmentId != null">
|
||||
and department_id = #{departmentId}
|
||||
</if>
|
||||
<if test="time != null and time != ''">
|
||||
and time like #{time}
|
||||
</if>
|
||||
<if test="patientName != null and patientName != ''">
|
||||
and patient_name = #{patientName}
|
||||
</if>
|
||||
<if test="medicalCard != null and medicalCard != ''">
|
||||
and medical_card = #{medicalCard}
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
and phone = #{phone}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectTicketPage" resultMap="TicketResult">
|
||||
select * from clinical_ticket
|
||||
<where>
|
||||
<!-- 逻辑删除条件 -->
|
||||
and delete_flag = '0'
|
||||
<!-- 其他查询条件 -->
|
||||
<if test="ticket.ticketType != null and ticket.ticketType != ''">
|
||||
and ticket_type = #{ticket.ticketType}
|
||||
</if>
|
||||
<if test="ticket.status != null and ticket.status != ''">
|
||||
and status = #{ticket.status}
|
||||
</if>
|
||||
<if test="ticket.appointmentDate != null">
|
||||
and appointment_date = cast(#{ticket.appointmentDate} as date)
|
||||
</if>
|
||||
<if test="ticket.doctorId != null">
|
||||
and doctor_id = #{ticket.doctorId}
|
||||
</if>
|
||||
<if test="ticket.departmentId != null">
|
||||
and department_id = #{ticket.departmentId}
|
||||
</if>
|
||||
<if test="ticket.time != null and ticket.time != ''">
|
||||
and time like #{ticket.time}
|
||||
</if>
|
||||
<if test="ticket.patientName != null and ticket.patientName != ''">
|
||||
and patient_name = #{ticket.patientName}
|
||||
</if>
|
||||
<if test="ticket.medicalCard != null and ticket.medicalCard != ''">
|
||||
and medical_card = #{ticket.medicalCard}
|
||||
</if>
|
||||
<if test="ticket.phone != null and ticket.phone != ''">
|
||||
and phone = #{ticket.phone}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 自定义COUNT查询,解决MyBatis-Plus自动生成的COUNT查询结果不正确的问题 -->
|
||||
<select id="selectTicketPage_mpCount" resultType="java.lang.Long">
|
||||
select count(*) from clinical_ticket
|
||||
<where>
|
||||
<!-- 逻辑删除条件 -->
|
||||
and delete_flag = '0'
|
||||
<!-- 其他查询条件 -->
|
||||
<if test="ticket.ticketType != null and ticket.ticketType != ''">
|
||||
and ticket_type = #{ticket.ticketType}
|
||||
</if>
|
||||
<if test="ticket.status != null and ticket.status != ''">
|
||||
and status = #{ticket.status}
|
||||
</if>
|
||||
<if test="ticket.appointmentDate != null">
|
||||
and appointment_date = #{ticket.appointmentDate}
|
||||
</if>
|
||||
<if test="ticket.doctorId != null">
|
||||
and doctor_id = #{ticket.doctorId}
|
||||
</if>
|
||||
<if test="ticket.departmentId != null">
|
||||
and department_id = #{ticket.departmentId}
|
||||
</if>
|
||||
<if test="ticket.time != null and ticket.time != ''">
|
||||
and time like #{ticket.time}
|
||||
</if>
|
||||
<if test="ticket.patientName != null and ticket.patientName != ''">
|
||||
and patient_name = #{ticket.patientName}
|
||||
</if>
|
||||
<if test="ticket.medicalCard != null and ticket.medicalCard != ''">
|
||||
and medical_card = #{ticket.medicalCard}
|
||||
</if>
|
||||
<if test="ticket.phone != null and ticket.phone != ''">
|
||||
and phone = #{ticket.phone}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectTicketById" resultMap="TicketResult">
|
||||
select * from clinical_ticket where id = #{id} and delete_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertTicket" parameterType="com.openhis.clinical.domain.Ticket">
|
||||
insert into clinical_ticket
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="busNo != null and busNo != ''">bus_no,</if>
|
||||
<if test="department != null and department != ''">department,</if>
|
||||
<if test="doctor != null and doctor != ''">doctor,</if>
|
||||
<if test="ticketType != null and ticketType != ''">ticket_type,</if>
|
||||
<if test="time != null and time != ''">time,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="fee != null and fee != ''">fee,</if>
|
||||
<if test="patientId != null">patient_id,</if>
|
||||
<if test="patientName != null and patientName != ''">patient_name,</if>
|
||||
<if test="medicalCard != null and medicalCard != ''">medical_card,</if>
|
||||
<if test="phone != null and phone != ''">phone,</if>
|
||||
<if test="appointmentDate != null">appointment_date,</if>
|
||||
<if test="appointmentTime != null">appointment_time,</if>
|
||||
<if test="departmentId != null">department_id,</if>
|
||||
<if test="doctorId != null">doctor_id,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="busNo != null and busNo != ''">#{busNo},</if>
|
||||
<if test="department != null and department != ''">#{department},</if>
|
||||
<if test="doctor != null and doctor != ''">#{doctor},</if>
|
||||
<if test="ticketType != null and ticketType != ''">#{ticketType},</if>
|
||||
<if test="time != null and time != ''">#{time},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="fee != null and fee != ''">#{fee},</if>
|
||||
<if test="patientId != null">#{patientId},</if>
|
||||
<if test="patientName != null and patientName != ''">#{patientName},</if>
|
||||
<if test="medicalCard != null and medicalCard != ''">#{medicalCard},</if>
|
||||
<if test="phone != null and phone != ''">#{phone},</if>
|
||||
<if test="appointmentDate != null">#{appointmentDate},</if>
|
||||
<if test="appointmentTime != null">#{appointmentTime},</if>
|
||||
<if test="departmentId != null">#{departmentId},</if>
|
||||
<if test="doctorId != null">#{doctorId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateTicket" parameterType="com.openhis.clinical.domain.Ticket">
|
||||
update clinical_ticket
|
||||
<trim prefix="set" suffixOverrides=",">
|
||||
<if test="busNo != null and busNo != ''">bus_no = #{busNo},</if>
|
||||
<if test="department != null and department != ''">department = #{department},</if>
|
||||
<if test="doctor != null and doctor != ''">doctor = #{doctor},</if>
|
||||
<if test="ticketType != null and ticketType != ''">ticket_type = #{ticketType},</if>
|
||||
<if test="time != null and time != ''">time = #{time},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="fee != null and fee != ''">fee = #{fee},</if>
|
||||
<if test="patientId != null">patient_id = #{patientId},</if>
|
||||
<if test="patientName != null and patientName != ''">patient_name = #{patientName},</if>
|
||||
<if test="medicalCard != null and medicalCard != ''">medical_card = #{medicalCard},</if>
|
||||
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
||||
<if test="appointmentDate != null">appointment_date = #{appointmentDate},</if>
|
||||
<if test="appointmentTime != null">appointment_time = #{appointmentTime},</if>
|
||||
<if test="departmentId != null">department_id = #{departmentId},</if>
|
||||
<if test="doctorId != null">doctor_id = #{doctorId},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTicketById">
|
||||
delete from clinical_ticket where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTicketByIds">
|
||||
delete from clinical_ticket where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="countTickets" resultType="int">
|
||||
select count(*) from clinical_ticket
|
||||
<where>
|
||||
<if test="ticketType != null and ticketType != ''">
|
||||
and ticket_type = #{ticketType}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="appointmentDate != null">
|
||||
and appointment_date = cast(#{appointmentDate} as date)
|
||||
</if>
|
||||
<if test="doctorId != null">
|
||||
and doctor_id = #{doctorId}
|
||||
</if>
|
||||
<if test="departmentId != null">
|
||||
and department_id = #{departmentId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user