package thyyxxk.webserver.dao.his.zhuyuanyisheng; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.*; import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord; import thyyxxk.webserver.entity.datamodify.GetDropdownBox; import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.*; import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.dto.JyJcCheckItemDto; import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.vo.ViewInspectionItemDetailsVo; import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.PatientTemp; import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.Map; /** *

* 描述: 检查申请 *

* * @author xc * @date 2022-02-10 15:42 */ @Mapper public interface JianYanJianChaDao { @Select("select order_name,req_no,act_order_no, " + "start_time,inpatient_no,admiss_times,receive_flag," + "patient_uid,inspect_stuff_name = (select rtrim(name) from ysh_zd_part_code where code = inspect_stuff)," + " (select rtrim(name)\n" + " from ysh_zd_part_code\n" + " where code = inspect_part) inspect_part_name " + "from ysh_yj_req with (NOLOCK) " + " ${ew.customSqlSegment} ") List huoQuJianChaShenQingV2(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); @Select("select req_no,\n" + " inpatient_no,\n" + " p_name,\n" + " p_age,\n" + " admiss_times,\n" + " bed_no,\n" + " p_bar_code,\n" + " group_name,\n" + " act_order_no,\n" + " order_code,\n" + " order_name,\n" + " page_no,\n" + " req_comment,\n" + " req_doctor,\n" + " req_dept,\n" + " req_ward,\n" + " exec_dept,\n" + " req_date,\n" + " sample_status,\n" + " print_flag,\n" + " receive_flag,\n" + " req_type,\n" + " result_comment,\n" + " sys_date,\n" + " start_time,\n" + " isnull(diag_text,\n" + " (select name\n" + " from zd_icd_code_new\n" + " where code = diag_code)) as diag_text,\n" + " order_type,\n" + " report_no,\n" + " jz_flag,\n" + " req_studyid,\n" + " req_tz_comment,\n" + " req_other_result,\n" + " receive_jc,\n" + " diag_code,\n" + " confirm_flag,\n" + " confirm_time,\n" + " confirm_id,\n" + " quantity,\n" + " inspect_part,\n" + " inspect_stuff,\n" + " (select rtrim(name)\n" + " from jy_zd_sample with (NOLOCK)\n" + " where code = inspect_stuff) inspect_stuff_name,\n" + " (select rtrim(name)\n" + " from ysh_zd_part_code\n" + " where code = inspect_part) inspect_part_name,\n" + " (select rtrim(name)\n" + " from zd_unit_code\n" + " where code = req_dept) as req_dept_name,\n" + " (select rtrim(name)\n" + " from zd_unit_code\n" + " where code = req_ward) as req_ward_name,\n" + " (select rtrim(name)\n" + " from a_employee_mi\n" + " where code = req_doctor) as req_doctor_name,\n" + " case\n" + " when req_type = '2' then (select rtrim(class)\n" + " from jy_zd_item c\n" + " where c.zy_order_code = order_code)\n" + " else '00'\n" + " end classes\n" + "from ysh_yj_req with (NOLOCK)" + "${ew.customSqlSegment}") List huoQuShengQingXiangQing(@Param("ew") QueryWrapper reqNo); @Select("select top 1 sex, " + " rtrim(home_street) as home_street," + " rtrim(home_tel) as home_tel," + " responceTypeName = (select responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type) \n" + "from zy_actpatient with (NOLOCK) \n" + "where inpatient_no = #{patNo}) " + "from a_patient_mi with (NOLOCK) " + "where inpatient_no = #{patNo}") PatientTemp huoQuHuanZheXinXi(@Param("patNo") String patNo); @Select("select responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type) " + "from zy_actpatient with (NOLOCK) " + "where inpatient_no = #{patNo}") String huoQuHuanZheShenFen(@Param("patNo") String patNo); @Select("select rtrim(comm) comm, " + " comment1, " + " comment2, " + " comment3, " + " comment4, " + " comment5, " + " comment6, " + " comment7, " + " comment8 " + "from jc_zd_class with (NOLOCK) " + "where code = #{code}") JcZdClass daYingXiangQing(@Param("code") String code); @Select("select tc_name as name," + " rtrim(tc_no) as code," + " '1' as isTheParentNode " + "from zy_tc_yj c with (NOLOCK)" + "where isnull(del_flag, '0') = '0' and " + "${ew.sqlSegment}") List getTemplate(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); @Select("select op_id,tc_exec " + "from zy_tc_yj with (NOLOCK) " + "where tc_no = #{code}") ZyTcYj jianChaLuRuRen(String code); @Delete("delete zy_tc_yj " + "where tc_no = #{code}; " + "delete zy_tc_detail_yj " + "where tc_no = #{code};") void shanChuJianChaMuBan(String code); @Select("SELECT rtrim(a.order_code) as orderCode, " + " rtrim(a.order_name) as orderName, " + " rtrim(a.order_code) as code, " + " rtrim(a.order_name) as name, " + " rtrim(a.yb_comment) ybComment, " + " '0' as checkFlag, " + " a.exec_dept as execDept, " + " a.order_type as orderType, " + " (select rtrim(name) from zd_unit_code with (NOLOCK) where code = a.exec_dept) execDeptName, " + " CONVERT(varchar(100), GETDATE(), 20) as startTime," + " inspect_stuff as inspectStuff , " + " inspectStuffName = (select rtrim(name) from jy_zd_sample with (NOLOCK) where code = inspect_stuff)," + " rtrim(c.tc_no) as tc_no," + " '2' as isTheParentNode, " + " case when c.req_type = '2' then (select rtrim(class) from jy_zd_item yj where yj.zy_order_code = a.order_code) " + " else (select rtrim(class) from jc_zd_item yj where yj.zy_order_code = a.order_code) end as classes " + "FROM yz_order_item a with (NOLOCK), " + " zy_tc_detail_yj b with (NOLOCK), " + " zy_tc_yj c with (NOLOCK) " + "where b.tc_no = c.tc_no " + " and a.order_code = b.order_code " + " and isnull(a.del_flag, '') <> '1'" + " and isnull(c.del_flag, '') <> '1' " + " and ${ew.sqlSegment} " + " order by sort_no desc ") List> selectTemplateContent(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); @Select("SELECT rtrim(a.order_code) as orderCode,\n" + " rtrim(a.order_name) as orderName,\n" + " rtrim(a.order_code) as code,\n" + " rtrim(a.order_name) as name,\n" + " rtrim(a.yb_comment) ybComment,\n" + " '0' as checkFlag,\n" + " a.exec_dept as execDept,\n" + " a.order_type as orderType,\n" + " (select rtrim(name)\n" + " from zd_unit_code with (NOLOCK)\n" + " where code = a.exec_dept) execDeptName,\n" + " CONVERT(varchar(100), GETDATE(), 20) as startTime,\n" + " inspect_stuff as inspectStuff,\n" + " inspectStuffName = (select rtrim(name) from jy_zd_sample with (NOLOCK) where code = inspect_stuff)," + " inspect_part AS inspectPart, " + " (select rtrim(name)\n" + " from ysh_zd_part_code\n" + " where code = inspect_part) inspectPartName,\n" + " rtrim(c.tc_no) as tc_no,\n" + " '2' as isTheParentNode,\n" + " class as classes,\n" + " note,\n" + " collection_info as collectionInfo,\n" + " gender_restriction AS genderRestriction,\n" + " min_age_restriction AS minAgeRestriction,\n" + " max_age_restriction AS maxAgeRestriction\n" + "FROM yz_order_item a with (NOLOCK),\n" + " zy_tc_detail_yj b with (NOLOCK),\n" + " zy_tc_yj c with (NOLOCK),\n" + " ${tableName} jyjc\n" + "where b.tc_no = c.tc_no\n" + " and a.order_code = b.order_code\n" + " and isnull(a.del_flag, '') <> '1'\n" + " and isnull(c.del_flag, '') <> '1'\n" + " and jyjc.zy_order_code = a.order_code\n" + " and isnull(jyjc.zy_flag, '0') != '1'\n" + " and c.tc_no = #{code}\n" + " and c.req_type = #{type}\n" + "order by item_no ") List> getTemplateByCodeAndType(@Param("code") String code, @Param("type") String type, @Param("tableName") String tableName); @Select("") Page huoQuShuoMingMuBan(IPage page, @Param("name") String name, @Param("leiXing") Integer leiXing, @Param("userCode") String userCode); @Select("select * from ysh_zd_yj_template with (NOLOCK) where code = #{code}") YshZdYjTemplate muBanShuJu(String code); @Update("update ysh_zd_yj_template " + "set jc_text = #{jcText}, " + " name = #{name}, " + " py_code = #{pyCode}, " + " d_code = #{dCode}, " + " sys_date = getdate() " + "where code = #{code} ") void genXingShouMingMuBan(@Param("jcText") String jcText, @Param("name") String name, @Param("pyCode") String pyCode, @Param("dCode") String dCode, @Param("code") String code); @Delete("delete from ysh_zd_yj_template where code = #{code} ") void shanChuShouMingMuBan(String code); @Insert("insert into ysh_zd_yj_template (code, name, py_code, d_code, jc_text, jc_type, dept_code, op_id, sys_date, wh_flag) " + "values (#{code}, #{name}, #{pyCode}, #{dCode}, #{jcText}, 3, " + "(select rtrim(a_employee_mi.dept_code) from a_employee_mi where a_employee_mi.code = #{opId}), #{opId}, getdate(), #{whFlag})") void xinZengShouMingMuBan(YshZdYjTemplate param); @Select("select rtrim(code) as code, rtrim(name) as name " + "from zd_icd_code_new with (NOLOCK) where del_flag=0 " + "and (yb_code like #{name} or yb_name like #{name} or yb_py_code like #{name})") List diagnosisInOurHospital(String name); @Select("select tc_no " + "from zy_tc_yj with (NOLOCK) " + "where op_id = #{code} " + " and tc_name = #{name}" + " and req_type = #{reqType} ") List huoQuJianChaJianYanChongFuMuBanMing(@Param("name") String name, @Param("code") String code, @Param("reqType") String reqType); /** * 插入检查或检验模板 */ @Insert("INSERT INTO zy_tc_yj (tc_no, tc_name, tc_exec, del_flag, py_code, d_code, n_code, order_type/*1个人 2-科室*/,op_id, " + " req_type, tc_flag/*录入方式 1-手工选择 0-自动选择*/, create_date, sort_no) " + "VALUES (#{tcNo}, #{tcName}, #{tcExec}, N'0',#{pyCode}, #{dCode}, null, #{orderType}, #{opId}, #{reqType}, #{tcFlag}, getdate(), #{sortNo});") void chaRuJCJYMuBan(ZyTcYj param); @Insert("") void chaRuJCJYMuBanNeiRong(List list, @Param("tcNo") String tcNo, @Param("reqType") String reqType); @Insert("") void chaRuShenQing(@Param("list") List list, @Param("inpatientNo") String inpatientNo, @Param("name") String name, @Param("age") String age, @Param("admissTimes") Integer admissTimes, @Param("bedNo") String bedNo, @Param("userCode") String userCode, @Param("deptCode") String deptCode, @Param("wardCode") String wardCode, @Param("reqType") String reqType, @Param("orderTypeTable") String orderTypeTable, @Param("reqDate") Date reqDate); @Insert("") void chaRuShenQingYiZhu(@Param("list") List list, @Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("userCode") String userCode, @Param("deptCode") String deptCode, @Param("wardCode") String wardCode, @Param("infantFlag") Integer infantFlag, @Param("reqDate") Date reqDate); @Select("select req_no," + " inpatient_no," + " admiss_times, " + " group_name," + " order_name, " + " act_order_no, " + " order_code, " + " req_comment, " + " req_doctor, " + " req_doctor_name= (select rtrim(name) from a_employee_mi with (NOLOCK) where code = req_doctor), " + " req_dept, " + " req_dept_name = (select rtrim(name) from zd_unit_code with (NOLOCK) where code = req_dept)," + " req_ward_name = (select rtrim(name) from zd_unit_code where code = req_ward), " + " exec_dept, " + " exec_dept_name = (select rtrim(name) from zd_unit_code with (NOLOCK) where code = exec_dept), " + " req_date, " + " inspect_stuff, " + " inspect_stuff_name = (select rtrim(name) from jy_zd_sample with (NOLOCK) where code = inspect_stuff), " + " jz_flag," + " receive_flag " + " from ysh_yj_req with (NOLOCK) " + " ${ew.customSqlSegment} ") List huoQuJianYanV2(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); @Select("SELECT rtrim(a.code) as code, " + " rtrim(a.name) as name " + "FROM jy_zd_class a with (NOLOCK), " + " yz_order_item b with (NOLOCK) " + "where a.code = b.jy_type " + " and isnull(b.del_flag, '') <> '1' " + "group by a.code, a.name ") IPage jianYanFenLei(IPage page); @Select("select rtrim(code) as code,name from ${tableName} with (NOLOCK) " + "where isnull(del_flag, '0') = '0' and (name like #{name} " + " or py_code like #{name} " + " or code like #{name} or d_code like #{name} )") List biaoBenOrBuWei(String name, String tableName); @Select("select * " + "from ysh_yj_req with (NOLOCK) where req_no = #{reqNo} and inpatient_no = #{patNo} and admiss_times = #{times}") YshYjReq huoQuJianYanJianCha(@Param("reqNo") Integer reqNo, @Param("patNo") String patNo, @Param("times") Integer times); @Select("select count(1) " + "from yz_zy_patient_fee " + "where act_order_no = #{yj.actOrderNo} " + " and inpatient_no = #{yj.inpatientNo} " + " and admiss_times = #{yj.admissTimes} " + " and charge_status not in ('3','2') ") int selecePatientFee(@Param("yj") YshYjReq yj); @Delete("delete from ysh_yj_req where req_no = #{reqNo} and inpatient_no = #{patNo} and admiss_times = #{times}") void shanChuJianYanJianCha(@Param("reqNo") Integer reqNo, @Param("patNo") String patNo, @Param("times") Integer times); @Update("update yz_zy_patient_fee " + "set charge_status = '2', " + " op_id = #{userCode}, " + " op_date = getdate() " + "where inpatient_no = #{yj.inpatientNo} " + " and admiss_times = #{yj.admissTimes} " + " and act_order_no = #{yj.actOrderNo} " + " and charge_status = '3'") void cancellationOfConfirmedFees(@Param("yj") YshYjReq yj, @Param("userCode") String userCode); @Update("update yz_act_order " + "set status_flag = '-1', " + " instruction = N'作废'," + " order_name = N'作废' + order_name " + "where act_order_no = #{orderNo} ") void shanChuYiZhu(@Param("orderNo") BigDecimal orderNo); @Select("select a.order_code, " + " a.occ_code, " + " b.name, " + " a.amount, " + " cast(a.amount * b.charge_amount as varchar) as charge_amount, " + " cast(b.charge_amount as varchar) as unit_price," + " national_code, " + " national_name " + "from yz_order_occurence a, " + " zd_charge_item b " + "where a.occ_code = b.code " + " and a.order_code = #{orderCode}") List viewInspectionItemDetails(String orderCode); @Select("select top 1 jc_id from yj_jc_patient where ba_no = #{patNo} ") String getJcIdByPatNo(String patNo); @Select("select count(1) from zy_detail_charge where order_no = #{yj.actOrderNo} and inpatient_no = #{yj.inpatientNo} and admiss_times = #{yj.admissTimes} ") int selectedFeeCount(@Param("yj") YshYjReq yj); @Select("select fs_icd_text,report_no,check_date,his_req_no,report_id," + "report_name = (select name from a_employee_mi where code = report_id)," + "report_date,confirm_id,confirm_name = (select name from a_employee_mi where code = confirm_id),confirm_date " + "from yj_jc_record where his_req_no = #{reqNo} and jc_id = #{jcId}") YjJcRecord getJcRecord(String reqNo, String jcId); @Select("select text_zd,text_jc from " + "yj_jc_record_report where report_no = #{report} and title_code = '01' ") Map selectTextJc(String report); @Select("select time_limit, note, collection_info\n" + "from ${tableName}\n" + "where zy_order_code = #{code}\n") ViewInspectionItemDetailsVo selectJcJyItem(String tableName, String code); /** * 获取检验大类 * * @return */ @Select("select rtrim(code) as code,name as name from jy_zd_class") List queryInspectionClassification(); /** * 获取详细的检验项目 * * @return */ @Select("select rtrim(a.zy_order_code) as code,\n" + " rtrim(a.name) as name,\n" + " rtrim(a.class) as classes,\n" + " exec_unit,\n" + " exec_unit_name = (select name from zd_unit_code where code = a.exec_unit),\n" + " '2' as type,\n" + " isnull(b.sample, a.sample_code) as inspectStuff,\n" + " inspectStuffName = (select rtrim(name)\n" + " from jy_zd_sample with (NOLOCK)\n" + " where code = isnull(b.sample, a.sample_code)),\n" + " note,\n" + " collection_info,\n" + " gender_restriction,\n" + " min_age_restriction,\n" + " max_age_restriction,\n" + " rtrim(a.py_code) as py_code,\n" + " rtrim(a.d_code) as d_code\n" + "from jy_zd_item a\n" + " left join yz_order_item b on (a.zy_order_code = b.order_code)\n" + "where isnull(a.del_flag, '0') != '1'\n" + " and isnull(b.del_flag, '0') <> '1'") List getJyDetailedItems(); @Select("select rtrim(code) as code,rtrim(name) as name from jc_zd_class") List queryCheckClassification(); @Select("select a.zy_order_code as code, " + " isnull(b.name,'') as bw, " + " a.name, " + " rtrim(class) as classes, " + " exec_unit," + " exec_unit_name = (select name from zd_unit_code where zd_unit_code.code = exec_unit)," + " note , collection_info , gender_restriction ," + " min_age_restriction, max_age_restriction, " + "rtrim(a.py_code) as py_code , " + "rtrim(a.d_code) as d_code " + "from jc_zd_item a " + " left join ysh_zd_part_code b on (a.bw_code = b.code)" + " left join yz_order_item c on (c.order_code = a.zy_order_code) " + "where isnull(a.del_flag, '0')<> '1' " + " and isnull(zy_flag, '0') <> '1'" + " and isnull(c.del_flag, '0') <> '1' " + "order by class") List selectJcDetailItems(); @Select("select top 1 req_comment,req_tz_comment,req_other_result,diag_code,diag_text " + "from ysh_yj_req where inpatient_no = #{patNo} and admiss_times = #{times} and req_comment is not null order by start_time desc") YshYjReq getAncillaryInformation(@Param("patNo") String patNo, @Param("times") Integer times); @Update("update ysh_yj_req set patient_uid = #{uid} where req_no = #{reqNo}") void setCheckPatientUid(String uid, Integer reqNo); @Select("select jc_id from yj_jc_patient where ba_no = #{patNo}") List getJcIdByPatNoList(String patNo); @Select("select apply_date,\n" + " apply_doctor_name = (select rtrim(name) from a_employee_mi where code = apply_doctor),\n" + " orderName = (select rtrim(name) from jc_zd_item where zy_order_code = order_code),\n" + " text_zd,\n" + " text_jc " + "from yj_jc_record a,\n" + " yj_jc_record_report b\n" + "where a.jc_id = #{jcId}" + " and a.report_no = b.report_no\n" + " and b.title_code = '01' " + " order by apply_date desc") List selectJieGuo(String jcId); @Select("select note , collection_info as collectionInfo from ${tableName} where zy_order_code= #{orderCode}") JSONObject getExamineIllustrate(String orderCode, String tableName); @Select("select gender_restriction,\n" + " max_age_restriction,\n" + " min_age_restriction,\n" + " zy_order_code as code,rtrim(class) as order_type," + " rtrim(name) as name," + " cast(rtrim(isnull(nullif(del_flag,\n" + " ''),\n" + " 0)) as int) as del_flag ${col} " + " from ${tableName} \n" + " where ${ew.sqlSegment};") List selectJyJcCheckItemDtoByOrderCode(@Param("ew") QueryWrapper queryWrapper, @Param("tableName") String tableName, @Param("col") String col); @Select("select cast(rtrim(isnull(nullif(c.del_flag,\n" + " ''),\n" + " 0)) as int) item_del_flag,\n" + " cast(rtrim(isnull(nullif(a.del_flag,\n" + " ''),\n" + " 0)) as int) as order_del_flag,\n" + " a.order_name,\n" + " c.name,rtrim(a.order_code) as code " + "from yz_order_item a\n" + " left join yz_order_occurence b on (a.order_code = b.order_code)\n" + " left join zd_charge_item c on (c.code = b.occ_code)\n" + "where ${ew.sqlSegment};") List selectItemDetailsByOrderCode(@Param("ew") QueryWrapper queryWrapper); @Select("select rtrim(code) code, rtrim(name) name , rtrim(parent_code) as parent_code\n" + "from ysh_zd_part_code\n" + "where isnull(del_flag, 0) = 0\n") List selectBuWeiAll(); @Select("select rtrim(parent_code) as parent_code\n" + "from ysh_zd_part_code\n" + "where isnull(del_flag, 0) = 0\n" + " and parent_code is not null\n" + "group by parent_code") List selectBuWeiParentCode(); }