package thyyxxk.webserver.dao.lis;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.lis.LabRpt;
import thyyxxk.webserver.entity.lis.MzYjReq;

import java.util.List;

@Mapper
public interface LisDao {

    @Select("select m.req_no, m.trans_dt, m.order_name, m.group_name, m.report_id, m.p_name, m.patient_id, z.name as req_ward_name, j.name as inspect_stuff_name, " +
            "mi.sex, mi.age, m.req_date, m.charge_date, m.req_comment, a.name as doctor_name, m.trans_user, m.pdf " +
            "from mz_yj_req m " +
            "left join zd_unit_code z on m.req_ward=z.code " +
            "left join jy_zd_sample j on m.inspect_stuff=j.code " +
            "left join mz_patient_mi mi on m.patient_id=mi.patient_id " +
            "left join a_employee_mi a on m.req_doctor=a.code " +
            "where m.patient_id = #{patientId} and req_type= #{reqType} " +
            "order by req_date desc")
    List<MzYjReq> getMzYjReqByPatientId(String patientId, String reqType);

    @Select("select m.req_no, m.trans_dt, m.order_name, m.group_name, m.report_id, m.p_name, m.inpatient_no, z.name as req_ward_name, j.name as inspect_stuff_name, " +
            "mi.sex, m.req_date, m.charge_date, m.req_comment, a.name as doctor_name, m.trans_user, m.pdf " +
            "from mz_yj_req m " +
            "left join zd_unit_code z on m.req_ward=z.code " +
            "left join jy_zd_sample j on m.inspect_stuff=j.code " +
            "left join zy_actpatient mi on m.inpatient_no=mi.inpatient_no " +
            "left join a_employee_mi a on m.req_doctor=a.code " +
            "where m.inpatient_no = #{patientId} and req_type= #{reqType} " +
            "order by req_date desc")
    List<MzYjReq> getYshYjReqByPatientId(String inPatientNo, String reqType);

    @Select("select * " +
            "from mz_yj_req " +
            "where req_no = #{reqNo} " +
            "order by req_no desc")
    MzYjReq getMzJyReqDetail(Integer reqNo);

    @Select("select * " +
            "from lab_rpt " +
            "where report_id = #{reportId} ")
    List<LabRpt> getLabRpt(String reportId);
}
