package thyyxxk.webserver.dao.his;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.*;
import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord;
import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.login.UserInfo;
import thyyxxk.webserver.entity.publicapi.ZkList;
import thyyxxk.webserver.entity.socketmessage.SocketMessage;
import thyyxxk.webserver.entity.inpatient.ZyActpatient;
import thyyxxk.webserver.entity.zhuyuanyisheng.PatientAllergenInfo;
import thyyxxk.webserver.entity.zhuyuanyisheng.caoyaoyizhu.YzActOrderCy;
import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.YshYjReq;
import thyyxxk.webserver.entity.zhuyuanyisheng.shoushu.OpRecord;
import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.YaoPinXiangMu;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
*
* 描述: 公共接口
*
*
* @author xc
* @date 2021-09-17 10:54
*/
@Mapper
public interface PublicDao {
/**
* 查询医嘱
*
* @return 返回医嘱号
*/
@Select("select cast(act_order_no as decimal(14)) as act_order_no from yz_sequence WITH (TABLOCKX)")
BigDecimal getActOrderNo();
/**
* @return 获取模板的自增id
*/
@Select("select pattern_code from yz_sequence WITH (TABLOCKX) ")
Integer getPatternCode();
@Update("update yz_sequence set pattern_code = #{newId} where pattern_code = #{oldId} ")
int updatePatternCode(Integer newId, Integer oldId);
@Select("select cast(p_act_order_no as decimal(9)) from yz_sequence WITH (TABLOCKX)")
BigDecimal getPatternOrderCode();
@Update("update yz_sequence set p_act_order_no = #{newId} where p_act_order_no = #{oldId} ")
int updatePatternOrderCode(BigDecimal newId, BigDecimal oldId);
@Update("update yz_sequence set act_order_no = #{newOrderNo} where act_order_no = #{oldOrderNo} ")
int updateActOrderNo(BigDecimal newOrderNo, BigDecimal oldOrderNo);
@Select("select req_no from ysh_config WITH (TABLOCKX) ")
Integer getReqNo();
@Update("update ysh_config set req_no =#{newId} where req_no = #{oldId} ")
int updateReqNo(Integer newId, Integer oldId);
@Select("select yj_template_no from ysh_config WITH (TABLOCKX) ")
Integer tempNo();
@Update("update ysh_config set yj_template_no = #{newId} where yj_template_no = #{oldId} ")
int updateTempNo(Integer newId, Integer oldId);
/**
* 获取 这个科室 的子科室
*
* @param deptCode 科室编码
* @return 返回自生和子科室
*/
@Select("select code,case when parent_code = code then null else parent_code end as parent_code from zd_unit_code where (parent_code = #{deptCode} or code = #{deptCode}) and isnull(del_flag,0) = 0")
List getKeShiLieBiao(String deptCode);
@Select("")
List getKeShiLieBiaoList(@Param("deptCodeList") List deptCodeList);
/**
* 获取人员信息
*
* @param code 人员代码
* @return 返回人员
*/
@Select("")
List getRenYuan(String code, String deptCode);
/**
* @param pyCode 拼音编码
* @return 获取项目的名称和code
*/
@Select("select distinct code,name from zd_charge_item where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})" + "union all " + "select distinct code,name from yp_zd_dict where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})")
List getChargeCode(String pyCode);
@Select("select distinct rtrim(code) + '_' + rtrim(serial) as code, name " + "from yp_zd_dict " + "where (code like #{name} or name like #{name} or py_code like #{name} or d_code like #{name})")
List getDrugInfo(String name);
@Select("select rtrim(code) code,rtrim(name) name from zd_unit_code where isnull(del_flag,0) = 0")
List getDept();
@Select("select rtrim(code) code,rtrim(name) name from zd_unit_code with(nolock)" +
"where isnull(del_flag,0) = 0 and code not like '8%' and " +
"(py_code like #{pyCode} or name like #{pyCode} or code like #{pyCode})")
List queryDept(String pyCode);
@Select("select isnull(max(ledger_sn),1) from zy_ledger_file where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes}")
Integer getLedgerSn(@Param("inpatientNo") String inpatient, @Param("admissTimes") Integer admissTimes);
@Select("select rtrim(inpatient_no) inpatient_no,admiss_times,admiss_date,dis_date,name, " + "responce_name = (select rtrim(name) name from zy_zd_responce_type where code = responce_type)," + "responce_type, " + "ward,ward_name = (select rtrim(name) name from zd_unit_code where code = ward), " + "ledger_sn = (select max(ledger_sn) from zy_ledger_file where a.inpatient_no = zy_ledger_file.inpatient_no and a.admiss_times = zy_ledger_file.admiss_times), " + "chu_yuan_yi_zhu = (case when (select count(1) from yz_act_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " + "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0 " + "then 1 " + "when (select count(1) from yz_inact_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " + "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0 " + "then 1 else 0 end ), " + "bed_no,total_charge,balance from zy_actpatient a where inpatient_no = #{inpatientNo} ")
ZyActpatient getHuanZheJiBenXinXi(@Param("inpatientNo") String inpatientNo);
@Update("update zy_detail_charge set ori_detail_sn = null where inpatient_no = #{inpatientNo} " + "and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and ori_detail_sn = -1 and charge_amount > 0")
void chongZhiZhenLiuShui(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn);
@Select("select ori_detail_sn from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " + "and ori_detail_sn is not null " + "and charge_amount < 0")
List huoQuTuiFeiYuanLiuShui(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn);
@Update("")
void genXingFuShuDuiYingZhenLiuShui(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn, @Param("list") List detailSnList);
@Select("select ori_detail_sn,sum(charge_fee) charge_fee,sum(charge_amount) charge_amount " + "from zy_detail_charge a " + "where inpatient_no=#{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and order_no <> 6 and trans_flag_yb <> 2 " + " and ori_detail_sn is not null and charge_amount<0 " + "group by ori_detail_sn having count(1) > 1")
List chongFuTuiFeiLiuShui(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn);
@Select("")
List getZhenShuLiuShui(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn, @Param("oriSn") Set oriSn);
@Update("")
void chongFuTuiFeiChongZhi(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn, @Param("list") List oriDetailSn);
@Select("select isnull(sum(charge_fee),0) from zy_detail_charge " + "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and trans_flag_yb=2")
BigDecimal zhenFuXingDiFeiYong(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn);
@Update("update zy_detail_charge set trans_flag_yb = 0 where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and " + "trans_flag_yb = 2")
void chongXingZhengFuXiangDi(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn);
@Select("select detail_sn from zy_detail_charge where inpatient_no= #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " + "and trans_flag_yb <> 2 and charge_amount > 0 and ori_detail_sn is not null")
List zhenShuLiuShui(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn);
@Select("select ori_detail_sn from zy_detail_charge where inpatient_no= #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " + "and trans_flag_yb <> 2 and charge_amount < 0 and ori_detail_sn is not null")
List fuShuLiuShui(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn);
@Update(" ")
void chongZhiFuShuYuanLiuShui(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn, @Param("list") List oriDetailSn);
@Select("select top(1) code,dept_code,name,code_rs,rtrim(yb_code) yb_code" + " from a_employee_mi where (code = #{code} or code_rs = #{code}) and isnull(del_flag,0) = 0 ")
UserInfo huoQuYuanGongBianMa(String code);
@Select("SELECT small_dept FROM zd_dept_all where dept = #{deptCode}")
List bingFangSuoSuKeShi(String deptCode);
// 重置 流水号
@Select("select row_number() over (order by charge_date ) row_index, " + " ledger_sn, " + " detail_sn " + "from zy_detail_charge " + "where inpatient_no = '${patNo}' " + " and admiss_times = ${times} ")
List huoQuZhongYeFeiYong(@Param("patNo") String patNo, @Param("times") Integer times);
@Select("select count(1) " + "from zy_detail_charge " + "where inpatient_no = '${patNo}' " + " and admiss_times = ${times}")
int maxDetailSn(@Param("patNo") String patNo, @Param("times") Integer times);
@Update("")
void chongZhiLiuShui(@Param("patNo") String patNo, @Param("times") Integer times, @Param("list") List list, @Param("maxDetailSn") int maxDetailSn);
@Select("select rtrim(code) code,rtrim(name) name from zd_anaesthesia")
List maZuiFangShi();
@Update("update ysh_config set tc_no =tc_no")
void jianYanJianChaSuo();
@Select("select tc_no from ysh_config ")
Integer jianYanJianChaXuHao();
@Update("update ysh_config set tc_no = #{tcNo}")
void genXingJianYanJianChaXuHao(Integer tcNo);
@Update("update op_config set op_record_id =op_record_id ")
void suoZhuShouShu();
@Select("select op_record_id from op_config")
Integer shouShuXuHao();
@Update("update op_config set op_record_id =#{code} ")
void genXingShouShuXuHao(Integer code);
@Select("select page_no from yz_sequence WITH (TABLOCKX) ")
Integer caoYaoDanHao();
@Select("EXEC get_the_drug_list_no")
Integer caoYaoDanHaot();
@Update("update yz_sequence set page_no = #{newId} where page_no = #{oldId} ")
int genXingCaoYaoDanHao(Integer newId, Integer oldId);
@Select("select top (1) cast(settle_type as int) as settle_type " + "from zy_ledger_file " + "where inpatient_no = #{patNo} " + " and admiss_times = #{times} " + "order by ledger_sn desc")
Integer jieSuanXinXi(@Param("patNo") String patNo, @Param("times") Integer times);
@Select("select * " + "from ysh_hz_record " + "where act_order_no = #{actOrder}")
YshHzRecord huiZhen(BigDecimal actOrder);
@Select("select * " + "from ysh_yj_req " + "where act_order_no = #{actOrder}")
YshYjReq yiJi(BigDecimal actOrder);
@Select("select * " + "from op_record " + "where act_order_no = #{actOrder}")
OpRecord shouShu(BigDecimal actOrder);
@Select("select * " + "from yz_act_order_cy " + "where order_no = #{actOrder}")
YzActOrderCy caoYao(BigDecimal actOrder);
@Select("select cast(rtrim(isnull(nullif(del_flag, ''), 0)) as int) del_flag," + "national_code,rtrim(code) + '-' + rtrim(serial) code,rtrim(name) name, rtrim(name) as zd_name,rtrim(code) zd_code,rtrim(serial) serial " + "from yp_zd_dict " + "${ew.customSqlSegment}")
List huoQuYaoPinPiPeiXinXi(@Param(Constants.WRAPPER) Wrapper> wp);
@Select("")
List huoQuXiangMuXinXi(List code);
/**
* 获取患者的科室发送信息
*
* @param wardCode 科室编码
* @return 数据
*/
@Select("select code " +
"from a_employee_mi " +
"where dept_code = #{wardCode} " +
" and isnull(del_flag, 0) <> 1 " +
" and emp_tit_code = '010' ")
List huoQuHuanZheBingFangDeHuShi(String wardCode);
@Insert({""})
void chaRuTongZhiXinXi(@Param("list") List list);
@Insert({""})
void chaRuJieShouShuJu(@Param("list") List list);
@Select("select rtrim(${id}) as code, rtrim(${name}) as name from ${table} where isnull(${pyColumn}, '')='' ")
List originalList(@Param("table") String table, @Param("id") String id, @Param("name") String name, @Param("pyColumn") String pyColumn);
@Update("update ${table} set ${pyColumn}='${pyCode}' where ${idColumn}='${id}' ")
void updatePycode(@Param("table") String table, @Param("idColumn") String idColumn, @Param("id") String id, @Param("pyColumn") String pyColumn, @Param("pyCode") String pyCode);
@Select("select code, name " + "from zd_allergen " + "where (wb_code like #{name} or py_code like #{name} or name like #{name})")
List getAllergens(@Param("name") String name);
@Select("select allergen_code, (select name from zd_allergen where zd_allergen.code = allergen_code) as allergenName, id,type " + "from patient_allergen_info " + "where pat_no = #{patNo} " + " and type = 0 " + "union all " + "select allergen_code, (select name from yp_zd_dict b where rtrim(b.code) + '_' + rtrim(b.serial) = allergen_code) as allergenName, id,type " + "from patient_allergen_info " + "where pat_no = #{patNo} " + " and type = 1")
List getPatientAllergens(@Param("patNo") String patNo);
@Select("select count(1) from patient_allergen_info where pat_no = #{patNo}")
int whetherThePatientHasAllergens(String patNo);
@Insert("insert into patient_allergen_info (pat_no, allergen_code,type) values (#{patNo},#{allergenCode},#{type})")
@Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
void newPatientAllergens(PatientAllergenInfo param);
@Delete("delete from patient_allergen_info where id = #{id}")
void removePatientAllergens(Integer id);
@Select("select * from bld_cat_code where (code = #{name} or name like #{name})")
List getBldCat(String name);
@Select("SELECT distinct rtrim(a.dept_code) as dept_code, " + " rtrim(a.dept_name) as dept_name, " + " rtrim(a.ward_code) as ward_code, " + " rtrim(a.ward_name) as ward_name, " + " rtrim(b.small_dept) as small_code, " + " small_name = (select rtrim(name) name from zd_unit_code where code = small_dept) " + "FROM zy_adtward a, " + " zd_dept_all b " + "where a.ward_code = b.dept")
List getTheTransferList();
@Select("select RTRIM(code) AS code,RTRIM(name) AS name from zd_emp_position where isnull(del_flag,0) = 0")
List getEmpPosition();
@Select("select RTRIM(code) AS code,RTRIM(name) AS name " + "from zd_emp_inmark")
List getEmpInmark();
@Select("select RTRIM(code) AS code,RTRIM(name) AS name " + "from zd_ifcadre")
List getZdIfcadre();
@Select("select RTRIM(code) AS code,RTRIM(name) AS name " + "from zd_emp_title " + "where isnull(del_flag, 0) = 0")
List getZdEmpTitle();
@Select("select RTRIM(code) AS code,RTRIM(name) AS name " + "from mzy_zd_charge_type " + "where isnull(del_flag, 0) = 0")
List getMzyZdChargeType();
@Update("update rs_config " + "set rs_code =rs_code")
void lockThePersonnelCodeTable();
@Select("select rs_code + 1 " + "from rs_config")
Integer getPersonnelCode();
@Update("update rs_config " + "set rs_code = #{code}")
void updateStaffCodeTable(Integer code);
@Select("SELECT rtrim(code_rs) as uid,\n" + " rtrim(name) as displayName,\n" + " manager = '', /*1 就是有审核权限*/\n" + " oldUid = '',\n" + " userPassword = '123456',\n" + " ou= '001',\n" + " _id = 'Emr.model.EmrUsers-' + cast(row_number() over (order by code ) + 2 as varchar),\n" + " phone_no as mobile\n" + "from a_employee_mi\n" + "where isnull(del_flag, 0) = 0\n" + " and (select role_id from dj_user_role where dj_user_role.user_code = a_employee_mi.code and role_id = 11) = 11")
List