package thyyxxk.sizyfeeoprnsystm.dao; 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.sizyfeeoprnsystm.pojo.FeeCounteract; import thyyxxk.sizyfeeoprnsystm.pojo.selfpay.BriefLedgerFile; import thyyxxk.sizyfeeoprnsystm.pojo.selfpay.FmiOwnpayPatnDise; import thyyxxk.sizyfeeoprnsystm.pojo.selfpay.FmiOwnpayPatnFee; import thyyxxk.sizyfeeoprnsystm.pojo.selfpay.FmiOwnpayPatnMdtrt; import java.math.BigDecimal; import java.util.LinkedList; import java.util.List; @Mapper public interface SelfpayDao { @Update("update zy_ledger_file set selfpay_uploaded=0 where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn};" + "update zy_detail_charge set trans_flag_yb=0 where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn} " + "and trans_flag_yb!=2") void resetSelfUploadStatus(BriefLedgerFile ledgerFile); @Select("select psnCertType='01',certno=b.social_no,psnName=rtrim(a.name),begntime=a.admiss_date,endtime=a.dis_date, " + "medType=isnull(a.med_type,'2101'),iptOpNo=rtrim(b.inpatient_no),inhospStas='0',valiFlag='1' from ${table} a, " + "a_patient_mi b where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and a.inpatient_no=b.inpatient_no") FmiOwnpayPatnMdtrt selectPatnMdtrt(@Param("table") String table, @Param("patNo") String patNo, @Param("times") int times); @Select("select inoutDiagType='2',diagType='1',maindiagFlag='1',diagSrtNo=1, " + "diagCode=rtrim(dis_diag),diagName=rtrim(dis_diag_comment) " + "from ba_first_page1 where inpatient_no=#{patNo} and admiss_times=#{times} and dis_diag_no=1") FmiOwnpayPatnDise selectPatnDise(@Param("patNo") String patNo, @Param("times") int times); @Select("select bkkpSn=detail_sn,feeOcurTime=charge_date,valiFlag='1',fixmedinsName='长沙泰和医院', medinsListCodg=rtrim(charge_code_mx)," + "cnt=charge_amount,pric=charge_fee/charge_amount,detItemFeeSumamt=charge_fee, fixmedinsCode='H43010500370', " + "medListCodg=isnull((select max(national_code) from yp_zd_dict where code=charge_code_mx),(select max(national_code) from zd_charge_item where code=charge_code_mx)), " + "medinsListName=isnull((select top 1 name from yp_zd_dict where code=charge_code_mx),(select name from zd_charge_item where code=charge_code_mx)) " + "from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0)=0") LinkedList selectOwnpayFees(BriefLedgerFile ledgerFile); @Select("select sum(charge_fee) from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}") BigDecimal selectSumFee(BriefLedgerFile ledgerFile); @Select("select social_no from a_patient_mi where inpatient_no=#{patNo}") String selectSocialNo(@Param("patNo") String patNo); @Update("") void updateTransFlag(@Param("patNo") String patNo, @Param("times") int times, @Param("fees") List fees); @Select("select charge_amount,charge_fee,detail_sn,ori_detail_sn from zy_detail_charge " + "where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn} " + "and isnull(infant_flag,0)!=1 and isnull(trans_flag_yb,0) not in (1,2) " + "and isnull(ori_detail_sn,-1)!=-1") List selectNegativeFeesWithOriDetlSn(BriefLedgerFile ledgerFile); @Select("") List selectPositiveFeesByDetlSn(@Param("ledger") BriefLedgerFile ledgerFile, @Param("list") List list); @Update("update zy_detail_charge set trans_flag_yb=2 where inpatient_no=#{patNo} and " + "admiss_times=#{times} and detail_sn in (#{sn1}, #{sn2})") void updateYbTransFlagInPair(@Param("patNo") String patNo, @Param("times") Integer times, @Param("sn1") Integer sn1, @Param("sn2") Integer sn2); @Select("select rtrim(inpatient_no) as patNo,admiss_times as times,ledger_sn " + "from zy_ledger_file where ledger_sn>0 and account_date is not null and selfpay_uploaded in (0,2) " + "and isnull(responce_type,'01')='01' and account_date>='2022-01-01 00:00:00.000'") List selectBriefLedgerFile(); @Update("update zy_ledger_file set selfpay_uploaded=#{selfpayUploaded} where inpatient_no=#{patNo} " + "and admiss_times=#{times} and ledger_sn=#{ledgerSn}") void updateLedgerFileUploaded(BriefLedgerFile ledgerFile); }