package thyyxxk.webserver.dao.his;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
import thyyxxk.webserver.entity.login.UserInfo;
import thyyxxk.webserver.entity.yibao.ZyActpatient;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;
/**
*
* 描述: 公共接口
*
*
* @author xc
* @date 2021-09-17 10:54
*/
@Mapper
public interface PublicDao {
@Select("select role_id from dj_user_role where user_code = #{code}")
List huoQuJueSe(@Param("code") String code);
/**
* 把表锁住
*/
@Update("update yz_sequence set act_order_no = act_order_no")
void lockTable();
/**
* 查询医嘱
*
* @return 返回医嘱号
*/
@Select("select act_order_no from yz_sequence")
float getActOrderNo();
/**
* 插入新的医嘱
*
* @param actOrderNo 医嘱号
*/
@Update("update yz_sequence set act_order_no = #{actOrderNo}")
void updateActOrderNo(float actOrderNo);
/**
* 获取 这个科室 的子科室
*
* @param deptCode 科室编码
* @return 返回自生和子科室
*/
@Select("select 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("select distinct rtrim(code) code,rtrim(name) name from a_employee_mi where (name like #{code} or code_rs like #{code} or py_code like #{code}) and isnull(del_flag,0) = 0")
List getRenYuan(String code);
/**
* @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 rtrim(code) code,rtrim(name) name from zd_unit_code where isnull(del_flag,0) = 0")
List getDept();
@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 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 detail_sn from zy_detail_charge where inpatient_no= #{patNo} and admiss_times = #{times} " +
"group by detail_sn having count(1) > 1 ")
List huoQuZhongYeFeiYong(@Param("patNo") String patNo,
@Param("times") Integer times);
@Update("")
void chongZhiLiuShui(@Param("patNo") String patNo,
@Param("times") Integer times,
@Param("ledgerSn") Integer ledgerSn,
@Param("list") List list);
}