package com.fs.his.mapper;

import java.util.List;
import com.fs.his.domain.FsDoctorPrescribe;
import com.fs.his.param.FsDoctorPrescribeListDParam;
import com.fs.his.param.FsDoctorPrescribeVO;
import com.fs.his.vo.FsDoctorPrescribeListDVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 医生处方Mapper接口
 *
 * @author fs
 * @date 2023-08-08
 */
public interface FsDoctorPrescribeMapper
{
    /**
     * 查询医生处方
     *
     * @param prescribeId 医生处方主键
     * @return 医生处方
     */
    public FsDoctorPrescribe selectFsDoctorPrescribeByPrescribeId(Long prescribeId);

    /**
     * 查询医生处方列表
     *
     * @param fsDoctorPrescribe 医生处方
     * @return 医生处方集合
     */
    public List<FsDoctorPrescribe> selectFsDoctorPrescribeList(FsDoctorPrescribe fsDoctorPrescribe);

    /**
     * 新增医生处方
     *
     * @param fsDoctorPrescribe 医生处方
     * @return 结果
     */
    public int insertFsDoctorPrescribe(FsDoctorPrescribe fsDoctorPrescribe);

    /**
     * 修改医生处方
     *
     * @param fsDoctorPrescribe 医生处方
     * @return 结果
     */
    public int updateFsDoctorPrescribe(FsDoctorPrescribe fsDoctorPrescribe);

    /**
     * 删除医生处方
     *
     * @param prescribeId 医生处方主键
     * @return 结果
     */
    public int deleteFsDoctorPrescribeByPrescribeId(Long prescribeId);

    /**
     * 批量删除医生处方
     *
     * @param prescribeIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsDoctorPrescribeByPrescribeIds(Long[] prescribeIds);
    @Select({"<script> " +
            "select p.*  from fs_doctor_prescribe p    " +
            "where 1=1  " +
            "<if test = ' maps.diagnose!=null and maps.diagnose != \"\"  '> " +
            "and p.diagnose like concat('%', #{maps.diagnose}, '%') " +
            "</if>" +
            "<if test = ' maps.prescribeType!=null  '> " +
            "and p.prescribe_type = #{maps.prescribeType} " +
            "</if>" +
            "and p.doctor_id = #{maps.doctorId} " +
            " order by p.create_time desc "+
            "</script>"})
    List<FsDoctorPrescribeListDVO> selectFsDoctorPrescribeListDVO(@Param("maps") FsDoctorPrescribeListDParam param);
    @Select({"<script> " +
            "select dp.*,s.store_name FROM fs_doctor_prescribe dp LEFT JOIN fs_store s ON s.store_id=dp.store_id "+
            " <where>  \n" +
            "            <if test=\"prescribeType != null \"> and prescribe_type = #{prescribeType}</if>\n" +
            "            <if test=\"diagnose != null  and diagnose != ''\"> and diagnose = #{diagnose}</if>\n" +
            "            <if test=\"doctorId != null \"> and doctor_id = #{doctorId}</if>\n" +
            "            <if test=\"storeId != null \"> and store_id = #{storeId}</if>\n" +
            "            <if test=\"usageJson != null  and usageJson != ''\"> and usage_json = #{usageJson}</if>\n" +
            "        </where>"+
            "</script>"})
    List<FsDoctorPrescribeVO> selectFsDoctorPrescribeListVO(FsDoctorPrescribe fsDoctorPrescribe);
}
