package thyyxxk.webserver.dao.lis;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.examinations.adicon.AdiconHeader;
import thyyxxk.webserver.entity.examinations.adicon.AdiconIndex;
import thyyxxk.webserver.entity.examinations.adicon.AdiconItem;

import java.util.List;

@Mapper
public interface AdiconDao {

    @Select("select a.RptID as ordrId, " +
            "a.PatientNumberType as ptntNoType, " +
            "a.PatientName as ptntName, " +
            "a.PatientSex as ptntSex, " +
            "a.PatientBirthday as ptntBirth, " +
            "a.PatientAge as ptntAge, " +
            "a.BarCode as sampleNumber, " +
            "b.ordr_create_date as ordrCreateDate, " +
            "a.PatientNumber as ptntId, " +
            "a.IDCard as idCard, " +
            "b.aply_cntn as aplyCtnt " +
            "from m_third_push_report a, m_third_party_ordr b " +
            "where a.PatientNumber=#{patNo} and a.RptID=b.third_party_report_code")
    List<AdiconIndex> selectAdiconReportIndex(@Param("patNo") String patNo);

    @Select("select a.RptID as ordrId, " +
            "b.ordr_date as aplyDate, " +
            "a.DoctorName as docName, " +
            "b.ordr_create_date as ordrCreateDate, " +
            "b.audt_time as audtTime, " +
            "a.BarCode as smplNum, " +
            "b.smpl_name as smplName, " +
            "b.prnt_time as prntTime, " +
            "b.prnt_status as prntStatus, " +
            "b.test_usr_name as testUsrName, " +
            "b.ordr_usr_name as ordrUsrName, " +
            "b.audt_usr_name as audtUsrName, " +
            "b.prnt_usr_name as prntUsrName, " +
            "b.aply_cntn as aplyCntn, " +
            "b.ordr_remark as ordrRemark, " +
            "a.EmergencyMrk as emcyMrk, " +
            "a.DepartName as deptName, " +
            "a.IDCard as idCard, " +
            "a.ICCard as icCard, " +
            "a.PatientNumberType as patientType, " +
            "a.PatientNumber as ptntNo, " +
            "a.PatientNumberType as ptntNoType, " +
            "a.PatientName as ptntName, " +
            "a.PatientSex as ptntSex, " +
            "a.PatientBirthday as ptntBirth, " +
            "a.PatientAge as ptntAge, " +
            "a.PatientAgeUnit as ptntAgeUnit, " +
            "a.PatientBedNum as ptntBedNo " +
            "from m_third_push_report a, m_third_party_ordr b " +
            "where a.RptID=#{reportId} and a.RptID=b.third_party_report_code")
    AdiconHeader selectAdiconReportHeader(@Param("reportId") String reportId);

    @Select("select RptItemID as itmId, " +
            "ItemCode as itmCode, " +
            "ItemName as itmName, " +
            "ItemUnit as itmUnit, " +
            "ItemID as itmOrdr, " +
            "ItemValue as itmValue, " +
            "RangeLowLimit as rangeLow, " +
            "RangeHighLimit as rangeHigh, " +
            "Range as range, " +
            "ItemAlert as itmAlert, " +
            "CriticalAlert as criticalAlert, " +
            "ItemStringValue as itmStrValue, " +
            "StringRange as rangeStr, " +
            "ResType as resType " +
            "from m_third_push_report_item where RptID=#{reportId}")
    List<AdiconItem> selectAdiconReportItems(@Param("reportId") String reportId);
}
