package cn.hnthyy.thmz.mapper.his;

import cn.hnthyy.thmz.entity.his.MzYpFydl;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface MzYpFydlMapper {
    /**
     * 新增发药队列记录
     * @param mzYpFydl
     * @return
     */
    @Insert("INSERT INTO mz_yp_fydl(patient_id,times,receipt_no,order_no,group_no,windows_no_yf,confirm_time,seq_no,name,print_date,serial_no," +
            "order_time,status_flag,status_led,yf_no,slow_flag,call_flag,call_time) VALUES(#{patientId,jdbcType=CHAR},#{times,jdbcType=INTEGER}," +
            "#{receiptNo,jdbcType=INTEGER},#{orderNo,jdbcType=INTEGER},#{groupNo,jdbcType=CHAR},#{windowsNoYf,jdbcType=CHAR},#{confirmTime,jdbcType=TIMESTAMP}" +
            ",#{seqNo,jdbcType=INTEGER},#{name,jdbcType=CHAR},#{printDate,jdbcType=TIMESTAMP},#{serialNo,jdbcType=INTEGER},#{orderTime,jdbcType=TIMESTAMP}," +
            "#{statusFlag,jdbcType=CHAR},#{statusLed,jdbcType=INTEGER},#{yfNo,jdbcType=INTEGER},#{slowFlag,jdbcType=CHAR},#{callFlag,jdbcType=CHAR},#{callTime,jdbcType=TIMESTAMP}) ")
    int insertMzYpFydl(MzYpFydl mzYpFydl);

    /**
     * 按照病人当前就诊次数查询发药队列
     * @param patientId
     * @param times
     * @return
     */
    @Select("select * from mz_yp_fydl where patient_id = #{patientId} and times = #{times} ")
   List<MzYpFydl> selectMzYpFydl(@Param(value = "patientId") String patientId, @Param("times") Integer times);

    /**
     * 删除发药队列
     * @param patientId
     * @param times
     * @return
     */
    @Delete("delete from mz_yp_fydl  where patient_id = #{patientId} and times = #{times}")
    int deleteMzYpFydl(@Param(value = "patientId") String patientId, @Param("times") Integer times);

    /**
     * 修改本院记账的发药队列的流水号为新收款的流水号
     * @param mzYpFydl
     * @return
     */
    @Update("update mz_yp_fydl set serial_no=#{serialNo},receipt_no = #{receiptNo} where patient_id = #{patientId} and times = #{times} ")
    int updateSeralNoForByjz(MzYpFydl mzYpFydl);
}
