package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalOrderItem;
import org.apache.ibatis.annotations.Select;

/**
 * 诊疗项目Mapper接口
 *
 * @author fs
 * @date 2024-03-22
 */
public interface HospitalOrderItemMapper
{
    /**
     * 查询诊疗项目
     *
     * @param itemId 诊疗项目主键
     * @return 诊疗项目
     */
    public HospitalOrderItem selectHospitalOrderItemByItemId(Long itemId);

    /**
     * 查询诊疗项目列表
     *
     * @param hospitalOrderItem 诊疗项目
     * @return 诊疗项目集合
     */
    public List<HospitalOrderItem> selectHospitalOrderItemList(HospitalOrderItem hospitalOrderItem);

    /**
     * 新增诊疗项目
     *
     * @param hospitalOrderItem 诊疗项目
     * @return 结果
     */
    public int insertHospitalOrderItem(HospitalOrderItem hospitalOrderItem);

    /**
     * 修改诊疗项目
     *
     * @param hospitalOrderItem 诊疗项目
     * @return 结果
     */
    public int updateHospitalOrderItem(HospitalOrderItem hospitalOrderItem);

    /**
     * 删除诊疗项目
     *
     * @param itemId 诊疗项目主键
     * @return 结果
     */
    public int deleteHospitalOrderItemByItemId(Long itemId);

    /**
     * 批量删除诊疗项目
     *
     * @param itemIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalOrderItemByItemIds(Long[] itemIds);

    @Select("select * from hospital_order_item where outpatient_order_id =#{orderId} and item_type != 0")
    List<HospitalOrderItem> selectHospitalOrderItemByOutpatientOrder(Long orderId);

    @Select("select * from hospital_order_item where treat_order_id =#{orderId}")
    List<HospitalOrderItem> selectHospitalOrderItemByTreatId(Long orderId);

    @Select("select * from hospital_order_item where order_id =#{orderId}")
    List<HospitalOrderItem> selectHospitalOrderItemByOrder(Long orderId);

    @Select("select * from hospital_order_item where order_id =#{orderId} and item_type != 0")
    List<HospitalOrderItem> selectHospitalOrderItemByOrderAndType(Long orderId);

    @Select("select * from hospital_order_item where pharmacy_order_id =#{orderId}")
    List<HospitalOrderItem> selectHospitalPharmacyOrderByOrder(Long orderId);

    @Select("select * from hospital_order_item where outpatient_order_id =#{orderId} and item_type = 0 ")
    HospitalOrderItem selectHospitalOrderItemByRegistration(Long orderId);

    @Select("select * from hospital_order_item where treat_order_id =#{orderId} and item_type = 3 and treat_status = 0 ")
    List<HospitalOrderItem> selectHospitalOrderItemByExecute(Long orderId);

    @Select("select Count(*) from hospital_order_item where treat_order_id =#{orderId} and item_type = 3 and treat_status = 0 ")
    Integer selectHospitalOrderItemIsExecute(Long orderId);

}
