UpIdCollectionDao.java 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. package thyyxxk.webserver.dao.his.medicalinsurance;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.toolkit.Constants;
  4. import org.apache.ibatis.annotations.*;
  5. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  6. import thyyxxk.webserver.entity.datamodify.TYbSetModifyTime;
  7. import thyyxxk.webserver.entity.datamodify.TYbSetlModifyReq;
  8. import thyyxxk.webserver.entity.medicalinsurance.inpatient.BatjBa4;
  9. import thyyxxk.webserver.entity.medicalinsurance.inpatient.YbZyDisDiag;
  10. import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyDisDiagYb;
  11. import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyInactpatient;
  12. import thyyxxk.webserver.entity.medicalinsurance.query.SiPatInfo;
  13. import thyyxxk.webserver.entity.medicalinsurance.setllistupld.*;
  14. import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
  15. import java.util.Date;
  16. import java.util.List;
  17. import java.util.Map;
  18. import java.util.Set;
  19. /**
  20. * <p>
  21. * 描述: 医保结算单上传
  22. * </p>
  23. *
  24. * @author xc
  25. * @date 2021-11-25 08:42
  26. */
  27. @Mapper
  28. public interface UpIdCollectionDao {
  29. @Select("select count(1) from t_case_frontsheet_main where bah = #{patNo} " + " and admiss_times = #{times}")
  30. Integer shiFouQianShou(@Param("patNo") String patNo, @Param("times") Integer times);
  31. @Select("select a.mdtrt_id, " + // -- 就诊ID
  32. " a.setl_id, " + // -- 结算ID
  33. " a.psn_no as hi_no, " + //-- 医保编号
  34. " a.psn_no as psn_no ," +
  35. " medcasno=(a.pat_no+'_'+cast(a.times as varchar)), " + //-- 病案号
  36. " dcla_time=getdate(), " + //-- 申报时间
  37. " a.psn_name, " + //-- 人员姓名
  38. " a.gend, " + // -- 性别
  39. " a.brdy, " + //-- 出生日期
  40. " a.age, " + // -- 年龄
  41. " a.certno, " + // -- 证件号码
  42. " a.psn_cert_type as patnCertType, " + // -- 患者证件类别
  43. " b.insuplc_admdvs as insuplc, " + // -- 参保地
  44. " psnSelfpay=cast(a.psn_cash_pay - a.fulamt_ownpay_amt as decimal(16,2)) , " + // -- 个人自付
  45. " psnOwnpay=cast(a.fulamt_ownpay_amt as decimal(16,2)) , " + // -- 个人自费
  46. " acct_pay=cast(a.acct_pay as decimal(16,2)), " + // -- 个人账户支出
  47. " psnCashpay=cast(a.psn_cash_pay as decimal(16,2)) , " + // -- 个人现金支付
  48. " a.clr_optins as hsorg, " + // -- 医保机构
  49. " a.insutype as hi_type," + // -- 险种类型
  50. " (select rytj from batj_ba1 where zyh = #{patNo} and zycs = #{times}) as admWay, " + // 入院途径
  51. " a.setl_time as setl_end_date, " + //结算时间
  52. " a.ipt_med_type, a.hi_paymtd, " +
  53. " cast(fund_pay_sumamt as decimal(16,2)) as fund_pay_sumamt," + //
  54. " cast(maf_pay as decimal(16,2)) as maf_pay," +
  55. " psn_idet_type as sp_psn_type " +
  56. "from t_si_setlinfo a," +
  57. " t_si_pat_info b " + "where a.pat_no=b.pat_no and a.times=b.times " +
  58. "and a.ledger_sn = b.ledger_sn " + "and a.pat_no = #{patNo} and a.times = #{times} " + "and a.ledger_sn = #{ledgerSn} " + "and a.revoked = 0 ")
  59. SetlinfoUpld setlinfo1(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn);
  60. @Select("select (select si_code from zd_country_code where code = country) as ntly /*国籍*/,\n" +
  61. " social_no as certno /*证件*/,\n" +
  62. " occupation as prfs /*职业 在 Prfs 中有对应的*/,\n" +
  63. " live_place as curr_addr/*现住址*/,\n" +
  64. " unit_name as emp_name /*单位名称*/,\n" +
  65. " unit_place as emp_addr /*单位地址*/,\n" +
  66. " unit_phone as emp_tel /*工作单位手机*/,\n" +
  67. " addr_zip_code as poscode /* 邮编*/,\n" +
  68. " (select wjw_code from zd_nation_code where code = nation) as naty/*民族*/,\n" +
  69. " contact_name as coner_name/*联系人姓名*/,\n" +
  70. " (select rtrim(yb_code)\n" +
  71. " from zy_zd_relative_code\n" +
  72. " where code = contact_relation) as patn_rlts /*与患者的关系*/,\n" +
  73. " contact_phone as coner_tel /*联系人电话*/,\n" +
  74. " coma_days_before_admiss + '/' + coma_hours_before_admiss + '/' +\n" +
  75. " coma_minutes_before_admiss as pwcry_bfadm_coma_dur/*颅脑损伤患者入院前昏迷时长*/,\n" +
  76. " coma_days_after_admiss + '/' + coma_hours_after_admiss + '/' +\n" +
  77. " coma_minutes_after_admiss as pwcry_afadm_coma_dura/*颅脑损伤患者入院后昏迷时长*/,\n" +
  78. " zy_dismiss_way as dscg_way /*离院方式*/,\n" +
  79. " dismiss_destination as acp_medins_name/*拟接收机构名称*/,\n" +
  80. " admiss_again_in_one_month as days_rinp_flag_31 /*出院31天内再住院计划标志*/,\n" +
  81. " admiss_again_purpose as days_rinp_pup_31/*出院31天内再住院目的*/,\n" +
  82. " main_doctor_name as chfpdr_name/*主诊医师姓名*/,\n" +
  83. " (select yb_code\n" +
  84. " from a_employee_mi\n" +
  85. " where code = main_doctor) as chfpdr_code/*主诊医师代码*/,\n" +
  86. " (select rtrim(si_caty)\n" +
  87. " from zd_unit_code\n" +
  88. " where code = b.small_dept) as adm_caty/*入院科别*/,\n" +
  89. " (select rtrim(si_caty)\n" +
  90. " from zd_unit_code\n" +
  91. " where code = b.zk_ward) as refldept_dept /*转科科别*/,\n" +
  92. " (select rtrim(si_caty)\n" +
  93. " from zd_unit_code\n" +
  94. " where code = isnull(zk_ward, small_dept)) as dscg_caty /*出院科别*/,\n" +
  95. " /*实际住院天数*/\n" +
  96. " zy_serial_no as biz_sn /*业务流水号*/,\n" +
  97. " case age_days\n" +
  98. " when '-' then 0\n" +
  99. " else age_days\n" +
  100. " end as nwb_age/*新生儿年龄*/,\n" +
  101. " contact_addr_name as coner_addr /*联系人地址*/,\n" +
  102. " case new_born_weight\n" +
  103. " when '-' then 0\n" +
  104. " else new_born_weight\n" +
  105. " end as nwb_bir_wt/*新生儿体重*/,\n" +
  106. // " case new_born_admiss_weight\n" +
  107. // " when '-' then 0\n" +
  108. // " else new_born_admiss_weight\n" +
  109. // " end as nwb_adm_wt/*新生儿入院体重*/,\n" +
  110. " resp_nurs_code = (select yb_code\n" +
  111. " from a_employee_mi\n" +
  112. " where a_employee_mi.code = job_nurse) /*责任护士*/,\n" +
  113. " resp_nurs_name = (select name\n" +
  114. " from a_employee_mi\n" +
  115. " where a_employee_mi.code = job_nurse)\n" +
  116. "from zy_inactpatient b\n" +
  117. " left join\n" +
  118. " t_case_frontsheet_main a\n" +
  119. " on (\n" +
  120. " a.bah = b.inpatient_no\n" +
  121. " and a.admiss_times = b.admiss_times\n" +
  122. " )\n" +
  123. "where b.inpatient_no = #{patNo}\n" +
  124. " and b.admiss_times = #{times};")
  125. SetlinfoUpld setlinfo2(@Param("patNo") String patNo, @Param("times") Integer times);
  126. @Select("select begntime as adm_time,\n" +
  127. " begntime as setl_begn_date,\n" +
  128. " endtime as dscg_time,\n" +
  129. " begntime,\n" +
  130. " case\n" +
  131. " when datediff(day,\n" +
  132. " begntime,\n" +
  133. " endtime) <= 0 then 1\n" +
  134. " else datediff(day,\n" +
  135. " begntime,\n" +
  136. " endtime)\n" +
  137. " end as act_ipt_days\n " +
  138. "from t_si_setlinfo,\n" +
  139. " zy_inactpatient\n" +
  140. "where pat_no = #{patNo}\n" +
  141. " and times = #{times}\n" +
  142. " and ledger_sn = #{ledgerSn}\n" +
  143. " and revoked = 0\n" +
  144. " and inpatient_no = pat_no\n" +
  145. " and admiss_times = times")
  146. SetlinfoUpld setlinfo5(@Param("patNo") String patNo,
  147. @Param("times") Integer times,
  148. @Param("ledgerSn") Integer ledgerSn);
  149. @Select("select home_street as currAddr," +
  150. "(select wjw_code from zd_nation_code where code = nation_code) as naty/*民族*/,\n" +
  151. " relation_name as coner_name,\n" +
  152. " (select yb_code from zy_zd_relative_code where code = relation_code) as patn_rlts,\n" +
  153. " relation_street as conerAddr," +
  154. " relation_tel as conerTel " +
  155. "from a_patient_mi " +
  156. "where ${patNo}")
  157. SetlinfoUpld setlinfo3(@Param("patNo") String patNo);
  158. @Select("select clinic_diag as wmDiseCode, clinic_diag_str otpWmDise " +
  159. "from zy_inactpatient " +
  160. "where inpatient_no = #{patNo} " +
  161. " and admiss_times = #{times}")
  162. SetlinfoUpld setlinfo4(@Param("patNo") String patNo, @Param("times") Integer times);
  163. @Select("select (select si_code from zd_country_code where code = country) as ntly, " +
  164. " dis_date as setl_end_date, " +
  165. " begntime as setl_begn_date, " +
  166. " begntime as adm_time," +
  167. " case " + " when datediff(day, begntime, dis_date) <= 0 then 1 " +
  168. " else datediff(day, begntime, dis_date) end as act_ipt_days,/*实际住院天数*/ " +
  169. " dis_date as dscg_time, " +
  170. " isnull(nullif(occupation_code, ''), 90) as prfs," +
  171. " adm_way = '2' " +
  172. "from a_patient_mi a, " +
  173. " zy_inactpatient b " +
  174. "where a.inpatient_no = #{patNo} " +
  175. " and b.inpatient_no = #{patNo} " +
  176. " and b.admiss_times = #{times}")
  177. SetlinfoUpld singleDiseasePatientInformation(@Param("patNo") String patNo,
  178. @Param("times") Integer times);
  179. @Select("select top(1) rtrim(name) name,dept_name = (select rtrim(name) from zd_unit_code where code = dept_code) " +
  180. "from a_employee_mi where code = #{code}")
  181. GetDropdownBox userInfo(String code);
  182. @Select("select isnull(sum(charge_amount),0) from zy_detail_charge where inpatient_no = #{patNo} and admiss_times = #{times} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag}" + " and charge_code_mx in ('F01464','017051')")
  183. int teJiHuLi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn, @Param("infantFlag") Integer infantFlag);
  184. @Select("select isnull(sum(charge_amount),0) from zy_detail_charge where inpatient_no = #{patNo} and admiss_times = #{times} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag}" + " and charge_code_mx in ('F01465','017052')")
  185. int yiJiHuLi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn, @Param("infantFlag") Integer infantFlag);
  186. @Select("select isnull(sum(charge_amount),0) from zy_detail_charge where inpatient_no = #{patNo} and admiss_times = #{times} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag}" + " and charge_code_mx in ('F01466','017053')")
  187. int erJiHuLi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn, @Param("infantFlag") Integer infantFlag);
  188. @Select("select isnull(sum(charge_amount),0) from zy_detail_charge where inpatient_no = #{patNo} and admiss_times = #{times} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag}" + " and charge_code_mx in ('F01467','017054')")
  189. int sanJiHuLi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn, @Param("infantFlag") Integer infantFlag);
  190. /**
  191. * 这里是 住院诊断消息
  192. *
  193. * @param patNo 住院号
  194. * @param times 住院次数
  195. * @param tableName 表格名
  196. * @return 数据
  197. */
  198. @Select("select si_diag_type as diag_type, " +
  199. "case\n" +
  200. " when yb_code is null then rtrim(dis_diag)\n" +
  201. " else rtrim(yb_code)\n" +
  202. " end diag_code," +
  203. "case\n" +
  204. " when yb_name is null then rtrim(dis_diag_comment)\n" +
  205. " else rtrim(yb_name)\n" +
  206. " end diag_name " +
  207. " from ${tableName} left join " +
  208. " zd_icd_code_new on (dis_diag = code) " +
  209. "where inpatient_no = #{patNo} and admiss_times = #{times} " +
  210. "order by dis_diag_no ")
  211. List<DiseinfoUpld> diseinfo(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
  212. // 这里是手术操作信息
  213. @Select("select " +
  214. " case when yb_code is null then rtrim(ssbm) else rtrim(yb_code) end oprn_oprt_code ," +
  215. " case when yb_name is null then rtrim(ssmc) else rtrim(yb_name) end oprn_oprt_name," +
  216. " ssrq as oprn_oprt_date, " +
  217. " (select rtrim(isnull(yb_code,9)) from zd_anaesthesia where code = mzff ) as anst_way, " +
  218. " (select top(1) rtrim(name) from a_employee_mi where code = ssys) as oper_dr_name, " +
  219. " (select rtrim(yb_code) from a_employee_mi where code = ssys) as oper_dr_code, " +
  220. " (select rtrim(name) from a_employee_mi where code = mzys) as anst_dr_name, " +
  221. " (select rtrim(yb_code) from a_employee_mi where code = mzys) as anst_dr_code," +
  222. " op_start_date as oprn_oprt_begntime," +
  223. " op_end_date as oprn_oprt_endtime," +
  224. " anst_start_date as anst_begntime," +
  225. " anst_end_date as anst_endtime" +
  226. " from ${tableName} left join zd_icd9_cm3 on (ssbm = zd_icd9_cm3.code) " +
  227. "where zyh = #{patNo} and zycs = #{times} " + "order by ssxh")
  228. List<OprninfoUpld> oprninfoUplds(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
  229. @Select("select receipt_no from zy_receipt where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn} and receipt_no<>'0000000'" + "and receipt_sn = 1")
  230. String billNo(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn);
  231. @Select("select receipt_bill " +
  232. "from mz_receipt_serial " +
  233. "where patient_id = #{patNo} " +
  234. "and times = #{times} " +
  235. " and nullif(receipt_bill, '') is not null ")
  236. String mzBillNo(@Param("patNo") String patNo, @Param("times") Integer times);
  237. @Select("select med_type " +
  238. "from t_si_setlinfo " +
  239. "where pat_no = #{patNo} " +
  240. " and times = #{times} " +
  241. " and ledger_sn = #{ledgerSn} and revoked = 0")
  242. String getMedicalCategory(@Param("patNo") String patNo,
  243. @Param("times") Integer times,
  244. @Param("ledgerSn") Integer ledgerSn);
  245. @Select("select isnull(audit_flag,0) from t_yb_setl_modify_req where pat_no = #{patNo} " + "and times = #{times}")
  246. Integer setlModifyReqAuditFlag(@Param("patNo") String patNo, @Param("times") Integer times);
  247. // 基金支付信息
  248. @Select("select fund_pay_type,fund_payamt=cast(sum(fund_payamt) as decimal(16,2)) from t_si_setldetail " +
  249. "where pat_no = #{patNo} and times = #{times} and ledger_sn = #{ledgerSn} " + "group by fund_pay_type ")
  250. List<PayinfoUpld> payinfoUpld(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn);
  251. /* 收费项目信息 */
  252. // 总金额 和 全自费 和 医疗收费项目
  253. @Select("select med_chrgitm_type as med_chrgitm," +
  254. "amt=cast(sum(det_item_fee_sumamt) as decimal(16,2)), " +
  255. "fulamt_ownpay_amt=cast(sum(det_item_fee_sumamt * (selfpay_prop)) as decimal(16,2)), " +
  256. "claa_sumfee = 0,clab_amt = 0,oth_amt = 0 from t_si_setl_fee_detl " +
  257. "where setl_id = #{setlId} group by med_chrgitm_type")
  258. List<IteminfoUpld> amtAndOthAmt(@Param("setlId") String setlId);
  259. @Select("select med_chrgitm_type as med_chrgitm," +
  260. " sum(det_item_fee_sumamt) as amt\n" +
  261. "from t_si_setl_fee_detl\n" +
  262. "where setl_id = #{setlId}\n" +
  263. "group by med_chrgitm_type")
  264. List<IteminfoUpld> totalCost(@Param("setlId") String setlId);
  265. @Select("select med_chrgitm_type as med_chrgitm,\n" +
  266. " sum(det_item_fee_sumamt) as ${feeName} " +
  267. "from t_si_setl_fee_detl " +
  268. "where setl_id = #{setlId} " +
  269. " and chrgitm_lv = #{chrgitmLv} " +
  270. "group by med_chrgitm_type")
  271. List<IteminfoUpld> aAndBFees(@Param("setlId") String setlId,
  272. @Param("chrgitmLv") String chrgitmLv,
  273. @Param("feeName") String feeName);
  274. @Select("select med_chrgitm_type as med_chrgitm,\n" +
  275. " sum(case\n" +
  276. " when chrgitm_lv = '03' then det_item_fee_sumamt\n" +
  277. " else det_item_fee_sumamt * selfpay_prop end) as fulamtOwnpayAmt\n" +
  278. "from t_si_setl_fee_detl\n" +
  279. "where setl_id = #{setlId}\n" +
  280. "group by med_chrgitm_type")
  281. List<IteminfoUpld> fulamtOwnpayAmt(@Param("setlId") String setlId);
  282. // -- 01 甲类
  283. @Select("select med_chrgitm_type as med_chrgitm," +
  284. "claa_sumfee=cast(sum(det_item_fee_sumamt * (1- selfpay_prop)) as decimal(16,2)) " +
  285. "from t_si_setl_fee_detl " +
  286. "where setl_id = #{setlId} and chrgitm_lv = '01' " +
  287. "group by med_chrgitm_type")
  288. List<IteminfoUpld> jiaLeiFeiYong(@Param("setlId") String setlId);
  289. // -- 02 乙类
  290. @Select("select med_chrgitm_type as med_chrgitm," +
  291. "clab_amt=cast(sum(det_item_fee_sumamt * (1- selfpay_prop)) as decimal(16,2)) " +
  292. "from t_si_setl_fee_detl " +
  293. "where setl_id = #{setlId} and chrgitm_lv = '02' " +
  294. "group by med_chrgitm_type")
  295. List<IteminfoUpld> yiLeiFeiYong(@Param("setlId") String setlId);
  296. /**
  297. * 重症监护信息
  298. *
  299. * @param patNo 住院号
  300. * @param times 住院次数
  301. * @return 返回转科信息
  302. */
  303. @Select("select op_time from zy_zk_list where inpatient_no=#{patNo} and admiss_times=#{times} and " +
  304. "(dept_code in ('1160000','8000160') or f_dept_code in ('1160000','8000160')) " +
  305. "order by zk_times")
  306. List<Date> zhuanKeShiJian(@Param("patNo") String patNo, @Param("times") Integer times);
  307. /**
  308. * 保存结算单上传返回的 流水号
  309. *
  310. * @param setlListId 结算id
  311. * @param setlId 返回的数据
  312. */
  313. @Update("update t_si_setlinfo set setl_list_id = #{setlListId} where setl_id = #{setlId} ")
  314. void fanHuiLiuShuiHao(@Param("setlListId") String setlListId, @Param("setlId") String setlId);
  315. @Select("select top ${pageSize} * from (" +
  316. "select " +
  317. "row_number() over (order by setl_time) as rowNumber," +
  318. "rtrim(a.pat_no) pat_no,a.times,ledger_sn,psn_name,gend,brdy,insutype,psn_type,mdtrt_id,setl_id,setl_time, " +
  319. " a.med_type,medfee_sumamt,fund_pay_sumamt, " +
  320. " acct_pay,psn_cash_pay,clr_optins,clr_optins_name = (select name from t_region where code=clr_optins), " +
  321. " outDeptName=(select rtrim(name) from zd_unit_code where code=isnull(zk_ward,small_dept))," +
  322. " rtrim(isnull(zk_ward,small_dept)) as out_dept, " +
  323. " setl_list_id,datediff(day ,b.admiss_date ,b.dis_date) as act_ipt_days,b.operation,b.dec_type," +
  324. " id,req_op_id,rtrim(req_op_name) req_op_name,req_op_date,req_remark," +
  325. "audit_staff,audit_name,audit_date,audit_remark,audit_flag," +
  326. "refer_physician_name = (select top 1 rtrim(name) from a_employee_mi where code = b.refer_physician),b.refer_physician,a.ipt_med_type " +
  327. "from t_si_setlinfo a left join zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) " +
  328. "left join t_yb_setl_modify_req c on (a.pat_no = c.pat_no and a.times = c.times) " +
  329. "where revoked = 0 and " +
  330. " ${ew.sqlSegment} " +
  331. ") temp where rowNumber > ${pageSize} * (${currentPage} - 1)")
  332. List<SiSetlinfoTemp> huoQuJieSuanRenYuan(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper,
  333. @Param("currentPage") long currentPage,
  334. @Param("pageSize") long pageSize);
  335. @Select("<script>" + "select count(*) " + "from t_si_setlinfo a left join zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) " + "left join t_yb_setl_modify_req c on (a.pat_no = c.pat_no and a.times = c.times) " + "where revoked = 0 " + "<if test=\"startTime !=null and startTime != '' \">" + " and setl_time &gt;= #{startTime} and setl_time &lt;= #{endTime} " + "</if>" + "<if test=\"setlType !=null and setlType != '' \">" + " and setl_type = #{setlType} " + "</if>" + "<if test=\"patNo !=null and patNo != '' \">" + " and a.pat_no = #{patNo} " + "</if>" + "<if test=\"insutypes.size > 0 \">" + " and insutype in " + "<foreach collection='insutypes' item='item' index='index' open='(' close=')' separator=','>" + "#{item}" + "</foreach>" + "</if>" + "<if test=\"outDepts.size > 0 \">" + "and isnull(zk_ward,small_dept) in " + "<foreach collection='outDepts' item='item' index='index' open='(' close=')' separator=','>" + "#{item} " + "</foreach>" + "</if>" + "<if test=\"medTypes.size > 0 \">" + " and a.med_type in " + "<foreach collection='medTypes' item='item' index='index' open='(' close=')' separator=','>" + "#{item}" + "</foreach>" + "</if>" + "<if test=\"psnTypes.size > 0 \">" + " and psn_type in " + "<foreach collection='psnTypes' item='item' index='index' open='(' close=')' separator=','>" + "#{item}" + "</foreach>" + "</if>" + "<if test=\"decTypes.size > 0 \">" + " and b.dec_type in " + "<foreach collection='decTypes' item='item' index='index' open='(' close=')' separator=','>" + "#{item}" + "</foreach>" + "</if>" + "<if test=\"clrOptins.size > 0 \">" + " and clr_optins in " + "<foreach collection='clrOptins' item='item' index='index' open='(' close=')' separator=','>" + "#{item}" + "</foreach>" + "</if>" + "<if test=\"flag == 1 \">" + " and a.setl_list_id is null " + "</if>" + "<if test=\"flag == 2 \">" + " and a.setl_list_id is not null " + "</if>" + "<if test=\"auditFlag != 4 \">" + " and c.audit_flag = #{auditFlag} " + "</if>" + "<if test=\"referPhysician != null and referPhysician != '' \">" + " and b.refer_physician = #{referPhysician} " + "</if>" + "<if test=\"hiPaymtd != null and hiPaymtd != 0 \">" + " and a.hi_paymtd = #{hiPaymtd} " + "</if>" + "</script>")
  336. long huoQuJieSuanRenYuanTotal(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("setlType") String setlTyle, @Param("patNo") String patNo, @Param("insutypes") List<String> insutypes, @Param("outDepts") List<String> outDepts, @Param("medTypes") List<String> medTypes, @Param("psnTypes") List<String> psnTypes, @Param("clrOptins") List<String> clrOptins, @Param("decTypes") List<Integer> decTypes, @Param("flag") Integer flag, @Param("referPhysician") String referPhysician, @Param("auditFlag") Integer auditFlag, @Param("hiPaymtd") Integer hiPaymtd);
  337. @Select("select opName = (select top(1) rtrim(name) from a_employee_mi where code = op_id_code)," + "rtrim(inpatient_no) inpatient_no, admiss_times, dis_diag_no, dis_diag_type," + "case when yb_code is null then rtrim(dis_diag) else rtrim(yb_code) end dis_diag," + "case when yb_name is null then rtrim(dis_diag_comment) else rtrim(yb_name) end dis_diag_comment," + "op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, operation, si_diag_type,admiss_cond " + "from ${tableName} left join zd_icd_code_new on (dis_diag = code) " + "where inpatient_no = #{patNo} and admiss_times = #{times} " + "order by dis_diag_no ")
  338. List<YbZyDisDiag> zhenDuanXinXi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
  339. @Select("select *,bldCatName = (select name from bld_cat_code where bld_cat_code.code = bld_cat) " + "from patient_bld_info " + "where pat_no = #{patNo} " + " and times = #{times}")
  340. List<PatientBldInfo> shuXueXinXi(@Param("patNo") String patNo, @Param("times") Integer times);
  341. @Select("select ssys_name = (select top(1) rtrim(name) from a_employee_mi where code = ssys), " + " sszsName1 = (select top(1) rtrim(name) from a_employee_mi where code = sszs1), " + " sszsName2 = (select top(1) rtrim(name) from a_employee_mi where code = sszs2), " + " mzys_name = (select top(1) rtrim(name) from a_employee_mi where code = mzys)," + " bah, zyh, zycs, ssxh, ssrq, sstj, " + " ssys , sszs1, sszs2, mzys ,op_start_date, op_end_date, anst_start_date, anst_end_date," + " op_start_date as oprn_oprt_begntime," + " op_end_date as oprn_oprt_endtime," + " anst_start_date as anst_begntime," + " anst_end_date as anst_endtime, " + " case when yb_code is null then rtrim(ssbm) else rtrim(yb_code) end ssbm ," + " case when yb_name is null then rtrim(ssmc) else rtrim(yb_name) end ssmc," + " rtrim(mzff) mzff, rtrim(qkjb) qkjb," + "rtrim(yhqk) yhqk, ssbfz, fhqk, ssjb, cut_heal," + "(select top(1) yb_code from a_employee_mi where code = ssys) as oper_dr_code, " + "(select top(1) yb_code from a_employee_mi where code = mzys) as anst_dr_code " + "from ${tableName} left join zd_icd9_cm3 on (ssbm = zd_icd9_cm3.code) " + "where zyh = #{patNo} and zycs = #{times} " + "order by ssxh")
  342. List<BatjBa4> shouShuXinXi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
  343. @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,rtrim(name) name,admiss_date,dis_date,responce_type,operation, " + " responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type),sex,rtrim(refer_physician) refer_physician " +
  344. "from zy_inactpatient where inpatient_no = #{patNo} and admiss_times = #{times}")
  345. ZyInactpatient huanZheXinXi(@Param("patNo") String patNo, @Param("times") Integer times);
  346. @Select("select top(1) * from t_yb_set_modify_time")
  347. TYbSetModifyTime keXiuGaiShiJian();
  348. @Select("<script>" +
  349. "select rtrim(inpatient_no) inpatient_no,admiss_times," +
  350. "case\n" +
  351. " when yb_code is null then rtrim(dis_diag)\n" +
  352. " else rtrim(yb_code)\n" +
  353. " end dis_diag," +
  354. "case\n" +
  355. " when yb_name is null then rtrim(dis_diag_comment)\n" +
  356. " else rtrim(yb_name)\n" +
  357. " end dis_diag_comment " +
  358. " from ${tableName} left join " +
  359. " zd_icd_code_new on (dis_diag = code) " +
  360. "where inpatient_no in " +
  361. "<foreach collection='patNos' item='item' index='index' open='(' close=')' separator=','>" +
  362. "#{item}" +
  363. "</foreach>" +
  364. " and dis_diag_no = 1" +
  365. "</script>")
  366. List<ZyDisDiagYb> zhuZhenDuan(@Param("patNos") Set<String> patNos, @Param("tableName") String tableName);
  367. @Select("<script>" + "select ward_code,ward_code_name = (select rtrim(name) from zd_unit_code where code = ward_code), " + " rtrim(inpatient_no) patNo,admiss_times times " + "from zy_detail_charge where inpatient_no in " + "<foreach collection='patNos' item='item' index='index' open='(' close=')' separator=','>" + "#{item}" + "</foreach>" + " order by times,charge_date" + "</script>")
  368. List<SiSetlinfoTemp> zhuanKeKeShi(@Param("patNos") Set<String> patNos);
  369. @Select("select top 10 rtrim(yb_code) as code,rtrim(name) as name," + "rtrim(yb_code) as yb_code" + " from " + "(SELECT ROW_NUMBER() OVER(ORDER BY code) AS Number, * " + "from zd_icd9_cm3 where (code like #{content} or name like #{content} or yb_code like #{content})) a " + "where Number > (${page}-1) * 10 ")
  370. List<GetDropdownBox> searchSurgeryByAlpha(@Param("content") String content, @Param("page") long page);
  371. @Select("select count(1) from zd_icd9_cm3 where (code like #{content} or name" + " like #{content} or py_code like #{content} or yb_code like #{content})")
  372. long searchSurgeryTotal(@Param("content") String content);
  373. @Delete("delete zy_dis_diag_yb_modify where inpatient_no = #{patNo} and admiss_times = #{times}; " + "delete batj_ba4_modify where zyh = #{patNo} and zycs = #{times}; " + "delete t_yb_setl_modify_req where pat_no = #{patNo} and times = #{times};")
  374. void delReq(@Param("patNo") String patNo, @Param("times") Integer times);
  375. @Insert("insert into t_yb_setl_modify_req (pat_no, times, req_op_id, req_op_name, req_remark) " + "values (#{patNo},#{times},#{opIdCode},#{opIdName},#{reqRemark})")
  376. void setlModifyReq(@Param("patNo") String patNo, @Param("times") Integer times, @Param("opIdCode") String opIdCode, @Param("opIdName") String opIdName, @Param("reqRemark") String reqRemark);
  377. @Insert("<script>" + "insert into ${tableName} (inpatient_no, admiss_times, dis_diag_no, dis_diag_type, dis_diag, dis_diag_comment, " + "op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, operation, si_diag_type,admiss_cond) " + "values " + "<foreach collection='list' item='param' separator=','>" + "(#{param.inpatientNo},#{param.admissTimes},#{param.disDiagNo},'13',#{param.disDiag},#{param.disDiagComment}, " + " #{param.opIdCode},#{param.opDiagDate},'001',#{param.disDiagStatus},null,#{param.siDiagType},#{param.admissCond})" + "</foreach>" + "</script>")
  378. void setlModDis(@Param("list") List<YbZyDisDiag> param, @Param("tableName") String tableName);
  379. @Insert("<script>" +
  380. "insert into ${tableName} (bah, zyh, zycs, ssxh, ssrq, sstj, ssys, sszs1, sszs2, " +
  381. "mzys, ssbm, ssmc, mzff, qkjb, yhqk, ssbfz, fhqk, ssjb, cut_heal," +
  382. "op_start_date,op_end_date,anst_start_date,anst_end_date) " +
  383. "values " +
  384. "<foreach collection='list' item='param' separator=','>" +
  385. "(#{param.zyh},#{param.zyh},#{param.zycs},#{param.ssxh},#{param.ssrq},null,#{param.ssys},#{param.sszs1}," +
  386. "#{param.sszs2},#{param.mzys},#{param.ssbm},#{param.ssmc},#{param.mzff},#{param.qkjb},#{param.yhqk},null,null," +
  387. "#{param.ssjb},null,#{param.opStartDate, jdbcType = TIMESTAMP},#{param.opEndDate, jdbcType = TIMESTAMP}," +
  388. "#{param.anstStartDate, jdbcType = TIMESTAMP},#{param.anstEndDate, jdbcType = TIMESTAMP})" +
  389. "</foreach>" + "</script>")
  390. void setlModBat(@Param("list") List<BatjBa4> batjBa4s, @Param("tableName") String tableName);
  391. @Select("update zy_inactpatient set operation = #{operation} /*治疗方式*/ , dec_type = #{decType} /*申报类型*/ " + "where inpatient_no = #{patNo} and admiss_times = #{times}")
  392. void shenBao(@Param("operation") String operation, @Param("decType") Integer decType, @Param("patNo") String patNo, @Param("times") Integer times);
  393. @Select("select pat_name = (select top 1 rtrim(name) from zy_inactpatient where inpatient_no = pat_no),* from t_yb_setl_modify_req where id = #{id}")
  394. TYbSetlModifyReq shenHeXinXi(Integer id);
  395. @Select("select rtrim(code_rs) from a_employee_mi where code = #{code}")
  396. String yuanGongGongHao(String code);
  397. @Update("update t_yb_setl_modify_req set audit_flag = #{auditFlag} where id = #{id}")
  398. void upAuditFlag(@Param("id") Integer id, @Param("auditFlag") Integer auditFlag);
  399. @Update("update t_yb_setl_modify_req set audit_staff = #{auditStaff},audit_remark = #{remark},audit_name = #{auditName}," + "audit_date = getdate() " + "where id = #{id}")
  400. void updateReq(@Param("id") Integer id, @Param("remark") String remark, @Param("auditStaff") String auditStaff, @Param("auditName") String auditName);
  401. @Select("select top 1 *,op_id_name = (select top 1 rtrim(name) from a_employee_mi where op_id = code) from t_yb_set_modify_time")
  402. TYbSetModifyTime xianZhiShiJian();
  403. @Select("update t_yb_set_modify_time set start_time = #{startTime} ,end_time = #{endTime}, op_id = #{opId} ,op_date = getdate()")
  404. void sheZhiShiJian(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("opId") String opId);
  405. @Select("select ward_code as execUnit,execUnitName = (select rtrim(name) from zd_unit_code where code = ward_code), " + " sum(charge_amount) chargeAmount,sum(charge_fee) chargeFee " + "from zy_detail_charge where inpatient_no = #{patNo} and admiss_times = #{times} " + "group by ward_code order by chargeFee desc")
  406. List<Map<String, String>> getHuanZheFeiYong(@Param("patNo") String patNo, @Param("times") Integer times);
  407. @Update("update zy_inactpatient set refer_physician = #{code} where inpatient_no = #{patNo} and admiss_times = #{times}")
  408. void xiuGaiGuanChaungYiShen(@Param("patNo") String patNo, @Param("times") Integer times, @Param("code") String code);
  409. @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,rtrim(dis_diag) dis_diag,case admiss_status when '' then null else admiss_status end admiss_cond " + "from ba_first_page1 " + "where isnull(dis_diag,'') <> '' and inpatient_no = #{patNo} and admiss_times = #{times} ")
  410. List<YbZyDisDiag> huanZheBingAnShouYeZhenDuanRuYuanBingQing(String patNo, Integer times);
  411. @Update("<script>" + "<foreach collection='list' item='item' separator=';'>" + "update zy_dis_diag_yb set admiss_cond = #{item.admissCond} where inpatient_no = #{item.inpatientNo} and admiss_times = #{item.admissTimes} and dis_diag_no = #{item.disDiagNo}" + "</foreach>" + "</script>")
  412. void genXingLaoZhenDuan(@Param("list") List<YbZyDisDiag> ybZyDisDiagList);
  413. @Select("select rtrim(name) from zd_country_code where si_code = #{ntly}")
  414. String getNtlyName(String ntly);
  415. @Select("select rtrim(name) from zd_nation_code where wjw_code = #{naty}")
  416. String getNatyName(String naty);
  417. @Select("select rtrim(name) from t_zd_psn_cert_type where code = #{cert}")
  418. String getPatnCertTypeName(String cert);
  419. @Select("select rtrim(name) name from zy_occupation_code where code = #{prfs}")
  420. String getPrfsName(String prfs);
  421. @Select("select rtrim(name) name from zy_zd_relative_code where yb_code = #{code}")
  422. String getPatnRltsName(String code);
  423. @Select("select rtrim(name) from t_si_admdvs where code = #{code} ")
  424. String getInsuplcName(String code);
  425. @Select("select rtrim(name) from t_yb_dept where code = #{code}")
  426. String getYbDeptName(String code);
  427. @Select("select dise_code as diag_code," +
  428. " dise_name as diag_name, " +
  429. " oprn_oprt_name = '00000'," +
  430. " oprn_oprt_code = '无手术' " +
  431. " from t_si_pat_info " +
  432. "where pat_no = #{patNo} and times = #{times} " +
  433. "and ledger_sn = #{ledgerSn}")
  434. List<OpspdiseinfoUpld> diagnosisOfMenterSDisease(@Param("patNo") String patNo,
  435. @Param("times") Integer times,
  436. @Param("ledgerSn") Integer ledgerSn);
  437. @Select("select diag_code as diag_code, " +
  438. " diag_name as diag_name, " +
  439. " '00000' as oprn_oprt_name, " +
  440. " '无手术' as oprn_oprt_code " +
  441. "from t_si_mz_diag\n" +
  442. "where pat_no = #{patNo} and times = #{times} ")
  443. List<OpspdiseinfoUpld> outpatientDiagnosis(@Param("patNo") String patNo,
  444. @Param("times") Integer times);
  445. @Select("select rtrim(a.name) as psnName, " +
  446. " isnull(nullif(rtrim(b.occupation_code), " +
  447. " ''), " +
  448. " 90) as prfs, " +
  449. " (select si_code from zd_country_code where code = b.country) as ntly, " +
  450. " a.sex as gend, " +
  451. " a.birth_day as brdy, " +
  452. " a.age as age, " +
  453. " a.social_no as certno, " +
  454. " a.response_type, " +
  455. " a.phone_no as coner_tel, " +
  456. " a.adress as currAddr, " +
  457. " a.certificate_type as patnCertType, " +
  458. " d.setl_time as setl_begn_date, " +
  459. " d.setl_time as setl_end_date, " +
  460. " c.psn_no as psn_no," +
  461. " c.psn_no as hi_no, " +
  462. " rtrim(a.patient_id) + '_' + cast(a.times as varchar) as bizSn," +
  463. " dclaTime = getdate()," +
  464. " c.insutype as hi_type," +
  465. " isnull(work_unit,b.employer_name) as emp_name, " +
  466. " isnull(work_address,employer_district) as emp_addr, " +
  467. " isnull(work_tel,employer_tel) as emp_tel, " +
  468. " employer_zipcode as poscode, " +
  469. " relation_name as coner_name, " +
  470. " (select rtrim(yb_code) from zy_zd_relative_code where code = relation_code) " +
  471. " as patn_rlts, " +
  472. " relation_district as coner_addr, " +
  473. " relation_tel as coner_tel, " +
  474. " c.insuplc_admdvs as insuplc," +
  475. " (select wjw_code from zd_nation_code where code = b.nation_code) as naty/*民族*/,\n" +
  476. " '01' as patnRlts," +
  477. " a.adress as conerAddr," +
  478. " '1' as hiPaymtd, " +
  479. " cast(fund_pay_sumamt as decimal(16,2)) as fund_pay_sumamt," +
  480. " cast(maf_pay as decimal(16,2)) as maf_pay, " +
  481. "psn_idet_type as sp_psn_type " +
  482. "from mz_patient_mi a " +
  483. " left join " +
  484. " a_patient_mi b on (a.patient_id = b.mz_no) " +
  485. " left join t_si_pat_info c on (a.patient_id = c.pat_no and c.times = #{times}) " +
  486. " left join t_si_setlinfo d on (a.patient_id = d.pat_no and d.times = #{times} and revoked = 0 ) " +
  487. "where a.patient_id = #{patNo}")
  488. SetlinfoUpld mzPatInfo(@Param("patNo") String patNo,
  489. @Param("times") Integer times);
  490. @Select("select setl_id,mdtrt_id,insuplc_admdvs " +
  491. "from t_si_setlinfo " +
  492. "where pat_no = #{patNo} " +
  493. " and times = #{times} and revoked = 0 ")
  494. SetlinfoUpld mzJieSuanXinXi(@Param("patNo") String patNo, @Param("times") Integer times);
  495. @Update("update t_si_setlinfo set ipt_med_type = #{iptMenType} where setl_id = #{setlId} and revoked = 0")
  496. void modifyMedicalCategory(@Param("iptMenType") String iptMenType, @Param("setlId") String setlId);
  497. @Insert("insert into patient_bld_info (pat_no, times, bld_cat, bld_amt, bld_unit, bld_count) " + "values (#{patNo}, #{times}, #{bldCat}, cast(#{bldAmt} as decimal(6,1)), #{bldUnit}, (select isnull(max(bld_count), 0) from patient_bld_info where pat_no = ''))")
  498. void addBloodTransfusionInformation(PatientBldInfo param);
  499. @Update("update patient_bld_info set bld_cat = #{bldCat} ,bld_amt = cast(#{bldAmt} as decimal(6,1)) ,bld_unit = #{bldUnit} " + "where id = #{id}")
  500. void updateBloodTransfusionVarieties(PatientBldInfo param);
  501. @Delete("delete patient_bld_info where id = #{id}")
  502. void removeBloodTransfusion(Integer id);
  503. @Select("select setl_list_id from t_si_setlinfo where " +
  504. "pat_no = #{patNo} and times = #{times} and ledger_sn = #{ledgerSn} and revoked = 0")
  505. String billingListSerialNumber(@Param("patNo") String patNo,
  506. @Param("times") Integer times,
  507. @Param("ledgerSn") Integer ledgerSn);
  508. }