SiQueryDao.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. package thyyxxk.webserver.dao.his.medicalinsurance;
  2. import org.apache.ibatis.annotations.*;
  3. import thyyxxk.webserver.entity.dictionary.PureCodeName;
  4. import thyyxxk.webserver.entity.medicalinsurance.query.*;
  5. import thyyxxk.webserver.entity.medicalinsurance.setllist.BrfChrgitm;
  6. import thyyxxk.webserver.entity.medicalinsurance.setllist.InptntSetlmtLst;
  7. import thyyxxk.webserver.entity.medicalinsurance.setllist.OtptntSetlmtLst;
  8. import thyyxxk.webserver.entity.yibao.ZyActpatient;
  9. import java.util.Date;
  10. import java.util.List;
  11. /**
  12. * @description: 查询服务Mapper
  13. * @author: DingJie
  14. * @create: 2021/7/2111:17
  15. */
  16. @Mapper
  17. public interface SiQueryDao {
  18. /**
  19. * 查询门诊患者的身份证和姓名
  20. *
  21. * @param patNo 门诊号
  22. * @return 门诊患者的身份证和姓名
  23. */
  24. @Select("select social_no,rtrim(name) as name,times from mz_patient_mi where patient_id=#{patNo}")
  25. QryPsnBsInfo selectMzSocialAndName(@Param("patNo") String patNo);
  26. /**
  27. * 是否已保存过此患者的医保基本信息
  28. *
  29. * @param inpatientNo 住院号
  30. * @param admissTimes 住院次数
  31. * @param ledgerSn 账页号
  32. * @return 0-未保存 1-已保存
  33. */
  34. @Select("select count(1) from t_si_pat_info where pat_no=#{inpatientNo} " +
  35. "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  36. int selectSiZyInfoCount(@Param("inpatientNo") String inpatientNo,
  37. @Param("admissTimes") int admissTimes,
  38. @Param("ledgerSn") int ledgerSn);
  39. /**
  40. * 新增患者的医保基本信息(个人编码)
  41. *
  42. * @param psnBaseinfo 个人基本信息
  43. */
  44. @Insert("insert into t_si_pat_info (pat_no, times, ledger_sn, psn_no, psn_cert_type, " +
  45. "certno, psn_name, gend, naty, brdy, age, med_type, psn_idet_type, create_datetime) " +
  46. "values (#{patNo},#{times},#{ledgerSn},#{psnNo},#{psnCertType},#{certno}," +
  47. "#{psnName},#{gend},#{naty},#{brdy},#{age},#{medType},#{psnIdetType},getdate())")
  48. void insertSiZyInfoPsnNo(PsnBaseInfo psnBaseinfo);
  49. /**
  50. * 更新患者的医保基本信息(个人编码)
  51. *
  52. * @param psnBaseinfo 个人基本信息
  53. */
  54. @Update("update t_si_pat_info set age=#{age}, med_type=#{medType} where pat_no=#{patNo} " +
  55. "and times=#{times} and ledger_sn=#{ledgerSn}")
  56. void updateSiZyInfoPsnNo(PsnBaseInfo psnBaseinfo);
  57. @Update("update zy_actpatient set med_type=#{medType} where inpatient_no=#{patNo}")
  58. void updateZyActpatient(PsnBaseInfo psnBaseInfo);
  59. @Update("update t_si_pat_info set psn_idet_type=#{psnIdetType} where psn_no=#{psnNo} ")
  60. void updatePsnIdetType(@Param("psnIdetType") String psnIdetType,
  61. @Param("psnNo") String psnNo);
  62. /**
  63. * 获取患者的医保基本信息
  64. *
  65. * @param patNo 住院号
  66. * @param times 住院次数
  67. * @param ledgerSn 账页号
  68. * @return 医保基本信息
  69. */
  70. @Select("select * from t_si_pat_info where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  71. SiPatInfo selectSiPatInfoForZy(@Param("patNo") String patNo,
  72. @Param("times") int times,
  73. @Param("ledgerSn") int ledgerSn);
  74. /**
  75. * 获取患者的医保个人编号
  76. *
  77. * @param patNo 住院号/门诊ID
  78. * @return 患者的医保个人编号
  79. */
  80. @Select("select top 1 psn_no from t_si_pat_info where pat_no=#{patNo}")
  81. String selectPsnNo(@Param("patNo") String patNo);
  82. @Select("select * from t_si_pat_info where mdtrt_id=#{mdtrtId}")
  83. SiPatInfo selectSiPatInfoByMdtrtId(@Param("mdtrtId") String mdtrtId);
  84. /**
  85. * 获取患者的医保个人编号
  86. *
  87. * @param patNo 住院号
  88. * @param medType 医疗类别
  89. * @return 患者的医保个人编号
  90. */
  91. @Select("select top 1 insuplc_admdvs as code, psn_no as name from t_si_pat_info where pat_no=#{patNo} and med_type=#{medType} " +
  92. "and insuplc_admdvs is not null ")
  93. PureCodeName selectPsnNoByPatNoAndMedType(@Param("patNo") String patNo,
  94. @Param("medType") String medType);
  95. /**
  96. * 获取患者的医保基本信息
  97. *
  98. * @param patNo 门诊号
  99. * @param times 门诊次数
  100. * @return 医保基本信息
  101. */
  102. @Select("select * from t_si_pat_info where pat_no=#{patNo} and times=#{times}")
  103. SiPatInfo selectSiPatInfoForMz(@Param("patNo") String patNo,
  104. @Param("times") int times);
  105. /**
  106. * 取消入院登记后清空就诊id
  107. *
  108. * @param inpatientNo 住院号
  109. * @param admissTimes 住院次数
  110. * @param ledgerSn 账页号
  111. */
  112. @Update("update t_si_pat_info set mdtrt_id=#{nullCtnt}, adm_reg_msgid=#{nullCtnt}, setl_id=#{nullCtnt} " +
  113. "where pat_no=#{inpatientNo} and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  114. void clearMdtrtIdForZy(@Param("inpatientNo") String inpatientNo,
  115. @Param("admissTimes") int admissTimes,
  116. @Param("ledgerSn") int ledgerSn,
  117. @Param("nullCtnt") String nullCtnt);
  118. @Select("select type=#{type},pat_no,times,ledger_sn,psn_name,setl_id,gend,setl_time,medfee_sumamt,psn_no " +
  119. "from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
  120. List<SetlIndex> selectSetlIndex(QrySetlListPrm q);
  121. @Select("select top 1 * from t_si_pat_info where pat_no=#{patNo} and times=#{times} order by ledger_sn desc")
  122. SiPatInfo selectSiPatInfo(@Param("patNo") String patNo, @Param("times") int times);
  123. @Select("select top 1 insuplc_admdvs from t_si_pat_info where pat_no=#{patNo} and times=#{times} " +
  124. "and insuplc_admdvs is not null order by ledger_sn desc")
  125. String selectAdmdvs(@Param("patNo") String patNo, @Param("times") int times);
  126. @Select("select top 1 insuplc_admdvs from t_si_pat_info where pat_no=#{patNo} and insuplc_admdvs is not null order by times desc")
  127. String selectAdmdvsByPatNo(@Param("patNo") String patNo);
  128. @Select("select top 1 insuplc_admdvs from t_si_pat_info where psn_no=#{psnNo} and insuplc_admdvs is not null order by times desc")
  129. String selectAdmdvsByPsnNo(@Param("psnNo") String psnNo);
  130. @Select("select top 1 insuplc_admdvs from t_si_pat_info where pat_no=#{patNo} and psn_no=#{psnNo} " +
  131. "and insuplc_admdvs is not null order by times desc")
  132. String selectAdmdvsByPatNoAndPsnNo(@Param("patNo") String patNo, @Param("psnNo") String psnNo);
  133. @Select("select a.mdtrt_id,a.psn_name,a.gend,a.age,a.psn_no,b.emp_name," +
  134. "a.psn_type,a.cvlserv_flag,a.pat_no,a.setl_id,b.insuplc_admdvs, " +
  135. "tel=(select rtrim(home_tel) from a_patient_mi where a_patient_mi.inpatient_no=a.pat_no), " +
  136. "admDeptName=(select rtrim(name) from zd_unit_code where code=isnull(c.zk_ward,c.small_dept)), " +
  137. "c.bed_no as admBed,c.admiss_date as begntime, c.dis_date as endtime, " +
  138. "a.certno,a.mdtrt_cert_type, b.psn_idet_type, " +
  139. "dscgMaindiagName=(select rtrim(dis_diag_comment) from zy_dis_diag_yb where zy_dis_diag_yb.inpatient_no=a.pat_no " +
  140. "and zy_dis_diag_yb.admiss_times=a.times and zy_dis_diag_yb.dis_diag_no=1), " +
  141. "a.med_type,a.setl_time,a.hifes_pay, " +
  142. "chfpdrName=(select rtrim(name) from a_employee_mi where code=c.refer_physician), " +
  143. "staffName=(select rtrim(name) from a_employee_mi where a_employee_mi.code=a.staff_id), " +
  144. "a.balc,a.medfee_sumamt,a.hifp_pay,a.acct_pay,a.cvlserv_pay,a.psn_cash_pay, " +
  145. "a.hifob_pay,a.oth_pay,a.hifmi_pay,a.maf_pay " +
  146. "from t_si_setlinfo a, t_si_pat_info b, ${table} c where a.setl_id=#{setlId} " +
  147. "and a.pat_no=b.pat_no and a.times=b.times and a.ledger_sn=b.ledger_sn and a.pat_no=c.inpatient_no " +
  148. "and a.times=c.admiss_times")
  149. InptntSetlmtLst selectZySetlifo(@Param("setlId") String setlId, @Param("table") String table);
  150. @Select("select account_date from zy_ledger_file where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{sn}")
  151. Date selectAccountDate(@Param("patNo") String patNo,
  152. @Param("times") int times,
  153. @Param("sn") int sn);
  154. @Select("select a.mdtrt_id,a.psn_name,a.gend,a.age,a.cvlserv_flag,a.psn_type, " +
  155. "b.emp_name,a.certno,a.med_type,b.dise_code,a.medfee_sumamt,a.psn_no, " +
  156. "a.hifp_pay,a.acct_pay,a.cvlserv_pay,a.psn_cash_pay,b.insuplc_admdvs, " +
  157. "a.hifmi_pay,a.maf_pay,a.hifob_pay,a.oth_pay,a.staff_id,a.hifes_pay, " +
  158. "staffName=(select rtrim(name) from a_employee_mi where code=staff_id) " +
  159. "from t_si_setlinfo a, t_si_pat_info b where a.pat_no=#{patNo} " +
  160. "and a.times=#{times} and isnull(a.revoked,0)!=1 " +
  161. "and a.pat_no=b.pat_no and a.times=b.times")
  162. OtptntSetlmtLst selectMzSetlifo(@Param("patNo") String patNo,
  163. @Param("times") int times);
  164. @Select("select charge_fee,med_chrgitm_type,chrgitm_lv from t_mt_receipt where patient_id=#{patNo} " +
  165. "and times=#{times} and yb_trans_flag=1")
  166. List<BrfChrgitm> selectMzBrfChrgitms(@Param("patNo") String patNo,
  167. @Param("times") int times);
  168. @Select("select name from t_region where code=#{code}")
  169. String selectRegionName(@Param("code") String code);
  170. @Select("select insuplc_admdvs from t_si_pat_info where mdtrt_id=#{mdtrtId}")
  171. String selectInsuplcAdmdvsByMdtrtId(@Param("mdtrtId") String mdtrtId);
  172. @Select("select times from t_si_setlinfo where pat_no=#{patNo} and revoked=0")
  173. List<Integer> fetchSiTimesList(@Param("patNo") String patNo);
  174. @Select("select * from t_si_setl_fee_detl where mdtrt_id=#{mdtrtId}")
  175. List<SiSetlFeeDetl> selectAllSetlFeeDtle(@Param("mdtrtId") String mdtrtId);
  176. @Select("select a.feedetl_sn,a.fee_ocur_time,a.cnt,cast(a.pric as decimal(16,2)) as pric," +
  177. "cast(a.det_item_fee_sumamt as decimal(16,2)) as det_item_fee_sumamt, " +
  178. "a.selfpay_prop,cast(a.fulamt_ownpay_amt as decimal(16,2)) as fulamt_ownpay_amt," +
  179. "cast(a.overlmt_amt as decimal(16,2)) as overlmt_amt,cast(a.preselfpay_amt as decimal(16,2)) as preselfpay_amt, " +
  180. "cast(a.inscp_scp_amt as decimal(16,2)) as inscp_scp_amt,a.chrgitm_lv,a.medins_list_name,a.med_list_codg, " +
  181. "a.med_chrgitm_type,a.bilg_dept_codg,a.bilg_dept_name,a.bilg_dr_codg, " +
  182. "a.bilg_dr_name,a.selfpay_prop_percent,a.chrgitm_lv_name, " +
  183. "rtrim(b.charge_code_mx) as medins_list_codg from t_si_setl_fee_detl a, " +
  184. "zy_detail_charge b where mdtrt_id=#{mdtrtId} and b.inpatient_no=#{patNo} " +
  185. "and b.admiss_times=#{times} and b.ledger_sn=#{sn} and b.detail_sn=a.feedetl_sn")
  186. List<SiSetlFeeDetl> selectFeeDetlList(@Param("mdtrtId") String mdtrtId,
  187. @Param("patNo") String patNo,
  188. @Param("times") int times,
  189. @Param("sn") int sn);
  190. @Select("select a.feedetl_sn,b.charge_date as fee_ocur_time,a.cnt," +
  191. "cast(a.pric as decimal(16,2)) as pric, cast(a.det_item_fee_sumamt as decimal(16,2)) as det_item_fee_sumamt, " +
  192. "a.selfpay_prop,cast(a.fulamt_ownpay_amt as decimal(16,2)) as fulamt_ownpay_amt, " +
  193. "cast(a.overlmt_amt as decimal(16,2)) as overlmt_amt,cast(a.preselfpay_amt as decimal(16,2)) as preselfpay_amt, " +
  194. "cast(a.inscp_scp_amt as decimal(16,2)) as inscp_scp_amt,a.chrgitm_lv, " +
  195. "med_list_codg=case when b.serial in ('','00') then (select max(national_code) from zd_charge_item where code=b.charge_code_mx) " +
  196. "else (select max(national_code) from yp_zd_dict where code=b.charge_code_mx) end, " +
  197. "medins_list_name=case when b.serial in ('','00') then (select max(name) from zd_charge_item where code=b.charge_code_mx) " +
  198. "else (select max(name) from yp_zd_dict where code=b.charge_code_mx) end, " +
  199. "a.med_chrgitm_type,rtrim(b.ward_code) as bilg_dept_codg, " +
  200. "bilg_dept_name=(select rtrim(name) from zd_unit_code where code=ward_code), " +
  201. "bilg_dr_codg=isnull(isnull(b.doctor_code,b.refer_physician), b.op_id_code), " +
  202. "bilg_dr_name=isnull(isnull((select rtrim(name) from a_employee_mi where code=doctor_code), " +
  203. "(select rtrim(name) from a_employee_mi where code=refer_physician)), " +
  204. "(select rtrim(name) from a_employee_mi where code=op_id_code)), " +
  205. "rtrim(b.charge_code_mx) as medins_list_codg from t_si_charge_temp a, " +
  206. "zy_detail_charge b where a.pat_no=#{patNo} and a.times=#{times} and a.ledger_sn=#{sn} " +
  207. "and a.pat_no=b.inpatient_no and a.times=b.admiss_times and a.ledger_sn=b.ledger_sn " +
  208. "and a.feedetl_sn=b.detail_sn order by a.feedetl_sn")
  209. List<SiSetlFeeDetl> selectTempCharge(@Param("patNo") String patNo,
  210. @Param("times") int times,
  211. @Param("sn") int sn);
  212. @Insert("<script>" +
  213. "insert into t_si_setl_fee_detl (mdtrt_id, setl_id, feedetl_sn, fee_ocur_time, cnt, pric, " +
  214. "det_item_fee_sumamt, selfpay_prop, fulamt_ownpay_amt, overlmt_amt, preselfpay_amt, inscp_scp_amt, " +
  215. "chrgitm_lv, hilist_code, hilist_name, list_type, med_list_codg, medins_list_codg, medins_list_name, " +
  216. "med_chrgitm_type, bilg_dept_codg, bilg_dept_name, bilg_dr_codg, bilg_dr_name, lmt_used_flag, " +
  217. "hosp_prep_flag, hosp_appr_flag, tcmdrug_used_way, prodplac_type, bas_medn_flag, hi_nego_drug_flag, " +
  218. "chld_medc_flag, etip_flag, etip_hosp_code, dscg_tkdrug_flag, list_sp_item_flag, matn_fee_flag, " +
  219. "drt_reim_flag, memo, opter_id, opter_name, opt_time, selfpay_prop_percent, chrgitm_lv_name) " +
  220. "values " +
  221. "<foreach collection='list' item='fee' open='' separator=',' close=''>" +
  222. "(#{fee.mdtrtId}, #{fee.setlId}, #{fee.feedetlSn}, #{fee.feeOcurTime}, #{fee.cnt}, #{fee.pric}, " +
  223. "#{fee.detItemFeeSumamt}, #{fee.selfpayProp}, #{fee.fulamtOwnpayAmt}, #{fee.overlmtAmt}, " +
  224. "#{fee.preselfpayAmt}, #{fee.inscpScpAmt}, #{fee.chrgitmLv}, #{fee.hilistCode}, #{fee.hilistName}, " +
  225. "#{fee.listType}, #{fee.medListCodg}, #{fee.medinsListCodg}, #{fee.medinsListName}, " +
  226. "#{fee.medChrgitmType}, #{fee.bilgDeptCodg}, #{fee.bilgDeptName}, #{fee.bilgDrCodg}, #{fee.bilgDrName}, " +
  227. "#{fee.lmtUsedFlag}, #{fee.hospPrepFlag}, #{fee.hospApprFlag}, #{fee.tcmdrugUsedWay}, #{fee.prodplacType}, " +
  228. "#{fee.basMednFlag}, #{fee.hiNegoDrugFlag}, #{fee.chldMedcFlag}, #{fee.etipFlag}, #{fee.etipHospCode}, " +
  229. "#{fee.dscgTkdrugFlag}, #{fee.listSpItemFlag}, #{fee.matnFeeFlag}, #{fee.drtReimFlag}, #{fee.memo}, " +
  230. "#{fee.opterId}, #{fee.opterName}, #{fee.optTime}, #{fee.selfpayPropPercent}, #{fee.chrgitmLvName})" +
  231. "</foreach>" +
  232. "</script>")
  233. void insertSetlFeeDetlBatch(List<SiSetlFeeDetl> list);
  234. @Select("select * from t_si_mz_matn_dise")
  235. List<SiMzMatnDise> selectAllMzMatnDises();
  236. @Update("update t_si_pat_info set mdtrt_id=#{mdtrtId},insutype=#{insutype} where pat_no=#{patNo} " +
  237. "and times=#{times} and ledger_sn=#{sn}")
  238. void updateInhospInfo(@Param("patNo") String patNo,
  239. @Param("times") int times,
  240. @Param("sn") int sn,
  241. @Param("mdtrtId") String mdtrtId,
  242. @Param("insutype") String insutype);
  243. @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
  244. "psn_cash_pay,setl_time, " +
  245. "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  246. "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
  247. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  248. "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
  249. "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
  250. "and setl_time<=#{endtime} and insuplc_admdvs='439900' ")
  251. List<BaseSetlStatistics> selectBaseSetlStatisticsInProvinceLevel(@Param("begntime") String begntime,
  252. @Param("endtime") String endtime,
  253. @Param("insutype") String insutype,
  254. @Param("setlType") String setlType);
  255. @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
  256. "psn_cash_pay,setl_time, " +
  257. "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  258. "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
  259. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  260. "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
  261. "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
  262. "and setl_time<=#{endtime} and insuplc_admdvs not in ('439900','430121','430181') and insuplc_admdvs like '4301%' ")
  263. List<BaseSetlStatistics> selectBaseSetlStatisticsInChangshaCity(@Param("begntime") String begntime,
  264. @Param("endtime") String endtime,
  265. @Param("insutype") String insutype,
  266. @Param("setlType") String setlType);
  267. @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
  268. "psn_cash_pay,setl_time, " +
  269. "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  270. "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
  271. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  272. "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
  273. "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
  274. "and setl_time<=#{endtime} and insuplc_admdvs='430121' ")
  275. List<BaseSetlStatistics> selectBaseSetlStatisticsInChangshaCounty(@Param("begntime") String begntime,
  276. @Param("endtime") String endtime,
  277. @Param("insutype") String insutype,
  278. @Param("setlType") String setlType);
  279. @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
  280. "psn_cash_pay,setl_time, " +
  281. "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  282. "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
  283. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  284. "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
  285. "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
  286. "and setl_time<=#{endtime} and insuplc_admdvs='430181' ")
  287. List<BaseSetlStatistics> selectBaseSetlStatisticsInLiuYangCity(@Param("begntime") String begntime,
  288. @Param("endtime") String endtime,
  289. @Param("insutype") String insutype,
  290. @Param("setlType") String setlType);
  291. @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
  292. "psn_cash_pay,setl_time, " +
  293. "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  294. "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
  295. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  296. "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
  297. "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
  298. "and setl_time<=#{endtime} and insuplc_admdvs!='439900' and insuplc_admdvs like '43%' and insuplc_admdvs not like '4301%' ")
  299. List<BaseSetlStatistics> selectBaseSetlStatisticsInProvinceOtherCities(@Param("begntime") String begntime,
  300. @Param("endtime") String endtime,
  301. @Param("insutype") String insutype,
  302. @Param("setlType") String setlType);
  303. @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
  304. "psn_cash_pay,setl_time, " +
  305. "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  306. "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
  307. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  308. "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
  309. "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
  310. "and setl_time<=#{endtime} and insuplc_admdvs!='439900' and insuplc_admdvs not like '43%' ")
  311. List<BaseSetlStatistics> selectBaseSetlStatisticsOutProvince(@Param("begntime") String begntime,
  312. @Param("endtime") String endtime,
  313. @Param("insutype") String insutype,
  314. @Param("setlType") String setlType);
  315. @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay,setl_list_id,psn_name, " +
  316. "psn_cash_pay,setl_time, " +
  317. "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  318. "and b.times=a.times and b.ledger_sn=a.ledger_sn),a.insutype, " +
  319. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  320. "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
  321. "from t_si_setlinfo a where revoked=0 and setl_type=#{setlType} and insutype like #{insutype} and setl_time>=#{begntime} " +
  322. "and setl_time<=#{endtime} ")
  323. List<BaseSetlStatistics> selectBaseSetlStatisticsInAllPlaces(@Param("begntime") String begntime,
  324. @Param("endtime") String endtime,
  325. @Param("insutype") String insutype,
  326. @Param("setlType") String setlType);
  327. @Select("select code=(select b.name from t_region b where b.code=a.parent_code),a.name from t_region a where code=#{code}")
  328. PureCodeName selectAdmdvsNameAndParentName(@Param("code") String code);
  329. @Select("select name,code='' from t_si_admdvs where code=#{code}")
  330. PureCodeName selectAdmdvsName(@Param("code") String code);
  331. @Select("<script>" +
  332. "select rtrim(a.inpatient_no) inpatient_no," +
  333. " a.admiss_times," +
  334. " rtrim(name) name," +
  335. " refer_physician_name = (select rtrim(name) from a_employee_mi where code = refer_physician)," +
  336. " small_dept_name = (select rtrim(name) from zd_unit_code where code = small_dept)," +
  337. " responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type)," +
  338. " total_charge," +
  339. " sex," +
  340. " rtrim(c.dis_diag) dis_diag," +
  341. " rtrim(c.dis_diag_comment) dis_diag_comment," +
  342. " certno," +
  343. " insuplc_admdvs, " +
  344. " insuplc_admdvs_name = isnull((select name from t_region where code = insuplc_admdvs), " +
  345. " (select name from t_si_admdvs where code = insuplc_admdvs))" +
  346. "from zy_actpatient a " +
  347. " left join t_si_pat_info b on (a.inpatient_no = b.pat_no and a.admiss_times = b.times) " +
  348. " left join zy_dis_diag_yb c on (a.inpatient_no = c.inpatient_no and a.admiss_times = c.admiss_times and c.dis_diag_no = 1) " +
  349. "where " +
  350. "setl_id is null and b.mdtrt_id is not null " +
  351. "<if test=\"startTime !=null and startTime != '' \">" +
  352. " and admiss_date &gt;= #{startTime} and admiss_date &lt;= #{endTime} " +
  353. "</if>" +
  354. "<if test=\"patNo != null and patNo != '' \">" +
  355. " and a.inpatient_no = #{patNo} /* 住院号 */ " +
  356. "</if>" +
  357. "<if test=\"name != null and name != ''\">" +
  358. " and name like #{name} /*姓名*/ " +
  359. "</if>" +
  360. "<if test=\"certno !=null and certno != '' \">" +
  361. " and certno = '' /*身份证号码*/" +
  362. "</if>" +
  363. "</script>")
  364. List<ZyActpatient> zaiYuanHuanZheXinXi(@Param("patNo") String patNo,
  365. @Param("startTime") String startTime,
  366. @Param("endTime") String endTime,
  367. @Param("name") String name,
  368. @Param("certno") String certno);
  369. }