package cn.hnthyy.thmz.mapper.his.mz;

import cn.hnthyy.thmz.entity.his.mz.MzBlRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 病历数据库操作接口
 */
public interface MzBlRecordMapper {
    @Insert("insert into mz_bl_record(patient_id,times,emr_no,emr_type,visit_date,doctor_code,dept_code,first_or_not,emr_chief_complaint,emr_hpi,emr_ps,emr_pe,emr_fzjc," +
            "emr_process,emr_xyy,emr_yypg,emr_gnpg,emr_jkjy) VALUES (#{patientId,jdbcType=CHAR}," +
            "#{times,jdbcType=INTEGER},#{emrNo,jdbcType=VARCHAR},#{emrType,jdbcType=CHAR},#{visitDate,jdbcType=TIMESTAMP},#{doctorCode,jdbcType=CHAR}," +
            "#{deptCode,jdbcType=VARCHAR},#{firstOrNot,jdbcType=CHAR},#{emrChiefComplaint,jdbcType=VARCHAR},#{emrHpi,jdbcType=VARCHAR},#{emrPs,jdbcType=VARCHAR}," +
            "#{emrPe,jdbcType=VARCHAR},#{emrFzjc,jdbcType=VARCHAR},#{emrProcess,jdbcType=VARCHAR},#{emrXyy,jdbcType=VARCHAR},#{emrYypg,jdbcType=VARCHAR}," +
            "#{emrGnpg,jdbcType=VARCHAR},#{emrJkjy,jdbcType=VARCHAR})")
    int insertMzBlRecord(MzBlRecord mzBlRecord);


    /**
     * 按照病人编号查询最后一次病历信息
     *
     * @param patientId 病人编号
     * @return
     */
    @Select("select top 1rtrim(patient_id) patient_id,times from mz_bl_record where patient_id= #{patientId,jdbcType=VARCHAR} order by times desc")
    MzBlRecord selectLastMzVisitTableByPatientId(@Param("patientId") String patientId);
}

