package thyyxxk.webserver.dao.his.medicaladvice.patientinfo;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.medicaladvice.medicamanage.patientinfo.BabyInfoVo;

import java.util.List;

/**
 * @Description: 婴儿信息
 * @Author:lihong
 * @Date: 2023/12/19
 */
@Mapper
public interface BaByInfoDao {

    @Select(" select distinct a.admiss_times, a.inpatient_no,a.name,a.sex,b.birth_date,case when a.sex = 1 then '男' when a.sex = 2 then '女' else '未知' end sex_name,1 as flag  from zy_actpatient a left join  a_patient_mi b " +
            "      on a.inpatient_no = b.inpatient_no " +
            "     where a.inpatient_no like #{inpatientNo}   ")
    List<BabyInfoVo> selectInfo(@Param("inpatientNo") String inpatientNo);
    @Delete(" delete from a_patient_mi where inpatient_no =#{inpatientNo}  ")
    void deleteAPatientMi(String inpatientNo);
    @Delete(" delete from zy_actpatient where inpatient_no =#{inpatientNo} and admiss_times =#{admissTimes}   ")
    void deletezyActpatient(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
    @Insert(" INSERT INTO a_patient_mi ( outpatient_no, inpatient_no, name, birth_date, sex ) VALUES ( #{inpatientNo}, #{inpatientNo}, #{name}, #{birthDate}, #{sex} ) ")
    void insertAPatientMi(BabyInfoVo query);
     @Insert("  INSERT INTO zy_actpatient (admiss_times, name, outpatient_no, charge_type, visit_type, admiss_date, admiss_status, " +
             "                           clinic_diag, inpatient_no, admiss_physician, refer_physician, consult_physician, " +
             "                           dept_director, admiss_dept, admiss_ward, responce_type, times_billed, balance, total_charge, " +
             "                           charge1, charge2, charge3, charge4, charge5, charge6, charge7, charge8, charge9, charge10, " +
             "                           charge11, charge12, charge13, charge14, charge15, charge16, charge17, charge18, charge19, " +
             "                           charge20, charge21, charge22, charge24, charge23, charge25, charge27, charge26, charge28, " +
             "                           charge29, charge30, ward, bed_no, dept, sex, op_id_code, intern_code, admiss_diag_str, " +
             "                           yb_jzlb, zk_ward, zy_serial_no, mz_no, clinic_diag_str, bed_status, room, small_dept, " +
             "                           own_flag, own_time) " +
             " select admiss_times, #{query.name}, outpatient_no, charge_type, visit_type, #{query.birthDate}, admiss_status, " +
             "       clinic_diag, #{query.inpatientNo}, admiss_physician, refer_physician, consult_physician, " +
             "       dept_director, admiss_dept, admiss_ward, responce_type, times_billed, balance, total_charge, " +
             "       charge1, charge2, charge3, charge4, charge5, charge6, charge7, charge8, charge9, charge10, " +
             "       charge11, charge12, charge13, charge14, charge15, charge16, charge17, charge18, charge19, " +
             "       charge20, charge21, charge22, charge24, charge23, charge25, charge27, charge26, charge28, " +
             "       charge29, charge30, ward, bed_no, dept, #{query.sex}, op_id_code, intern_code, admiss_diag_str, " +
             "       yb_jzlb, zk_ward, zy_serial_no, mz_no, clinic_diag_str, bed_status, room, small_dept, " +
             "       own_flag, own_time from  zy_actpatient where inpatient_no = #{inpatientNo}")
    void insertZyActpatient(@Param("query") BabyInfoVo query,@Param("inpatientNo") String inpatientNo);
}
