UpIdCollectionDao.java 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. package thyyxxk.webserver.dao.his.medicalinsurance;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4. import com.baomidou.mybatisplus.core.toolkit.Constants;
  5. import org.apache.ibatis.annotations.Delete;
  6. import org.apache.ibatis.annotations.Insert;
  7. import org.apache.ibatis.annotations.Mapper;
  8. import org.apache.ibatis.annotations.Param;
  9. import org.apache.ibatis.annotations.Select;
  10. import org.apache.ibatis.annotations.Update;
  11. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  12. import thyyxxk.webserver.entity.datamodify.TYbSetModifyTime;
  13. import thyyxxk.webserver.entity.datamodify.TYbSetlModifyReq;
  14. import thyyxxk.webserver.entity.medicalinsurance.inpatient.BatjBa4;
  15. import thyyxxk.webserver.entity.medicalinsurance.inpatient.YbZyDisDiag;
  16. import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyDisDiagYb;
  17. import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyInactpatient;
  18. import thyyxxk.webserver.entity.medicalinsurance.log.SiLog;
  19. import thyyxxk.webserver.entity.medicalinsurance.setllistupld.*;
  20. import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
  21. import thyyxxk.webserver.entity.querydata.TAutoUploadBill;
  22. import java.math.BigDecimal;
  23. import java.util.Date;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.Set;
  27. /**
  28. * <p>
  29. * 描述: 医保结算单上传
  30. * </p>
  31. *
  32. * @author xc
  33. * @date 2021-11-25 08:42
  34. */
  35. @Mapper
  36. public interface UpIdCollectionDao extends BaseMapper<SetlinfoUpld> {
  37. @Select("select count(1) from t_case_frontsheet_main where bah = #{patNo} " + " and admiss_times = #{times} and file_status =1")
  38. Integer shiFouQianShou(@Param("patNo") String patNo, @Param("times") Integer times);
  39. @Select("select a.mdtrt_id, " + // -- 就诊ID
  40. " a.setl_id, " + // -- 结算ID
  41. " a.psn_no as hi_no, " + //-- 医保编号
  42. " a.psn_no as psn_no ," +
  43. " medcasno=(a.pat_no+'_'+cast(a.times as varchar)), " + //-- 病案号
  44. " dcla_time=getdate(), " + //-- 申报时间
  45. " a.psn_name, " + //-- 人员姓名
  46. " a.gend, " + // -- 性别
  47. " a.brdy, " + //-- 出生日期
  48. " a.age, " + // -- 年龄
  49. " a.certno, " + // -- 证件号码, 医院支付
  50. " a.psn_cert_type as patnCertType, " + // -- 患者证件类别
  51. " b.insuplc_admdvs as insuplc, " + // -- 参保地
  52. " psnSelfpay=cast(a.psn_cash_pay - a.fulamt_ownpay_amt as decimal(16,2)) , " + // -- 个人自付 TODO
  53. " psnOwnpay=cast(a.fulamt_ownpay_amt as decimal(16,2)) , " + // -- 个人自费
  54. " acct_pay=cast(a.acct_pay as decimal(16,2)), " + // -- 个人账户支出
  55. " psnCashpay=cast(a.psn_cash_pay as decimal(16,2)) , " + // -- 个人现金支付
  56. " a.clr_optins as hsorg, " + // -- 医保机构
  57. " a.insutype as hi_type," + // -- 险种类型
  58. " (select rytj from batj_ba1 where zyh = #{patNo} and zycs = #{times}) as admWay, " + // 入院途径
  59. " a.setl_time as setl_end_date, " + //结算时间
  60. " a.ipt_med_type, a.hi_paymtd, " +
  61. " cast((fund_pay_sumamt-hosp_part_amt) as decimal(16,2) ) as fund_pay_sumamt," + //
  62. " cast(maf_pay as decimal(16,2)) as maf_pay," +
  63. " psn_idet_type as sp_psn_type " +
  64. "from t_si_setlinfo a," +
  65. " t_si_pat_info b " + "where a.pat_no=b.pat_no and a.times=b.times " +
  66. "and a.ledger_sn = b.ledger_sn " + "and a.pat_no = #{patNo} and a.times = #{times} " +
  67. "and a.ledger_sn = #{ledgerSn} " + "and a.revoked = 0 ")
  68. SetlinfoUpld setlinfo1(@Param("patNo") String patNo,
  69. @Param("times") Integer times,
  70. @Param("ledgerSn") Integer ledgerSn);
  71. @Select("select (select si_code from zd_country_code where code = a.country) as ntly /*国籍*/,\n" +
  72. " a.social_no as certno /*证件*/,\n" +
  73. " a.occupation as prfs /*职业 在 Prfs 中有对应的*/,\n" +
  74. " a.live_place_combo as curr_addr/*现住址*/,\n" +
  75. " a.unit_name as emp_name /*单位名称*/,\n" +
  76. " a.unit_place as emp_addr /*单位地址*/,\n" +
  77. " a.unit_phone as emp_tel /*工作单位手机*/,\n" +
  78. " a.addr_zip_code as poscode /* 邮编*/,\n" +
  79. " (select wjw_code from zd_nation_code where code = a.nation) as naty/*民族*/,\n" +
  80. " a.contact_name as coner_name/*联系人姓名*/,\n" +
  81. "a.birth_date,a.age,"+
  82. " (select rtrim(yb_code)\n" +
  83. " from zy_zd_relative_code\n" +
  84. " where code = a.contact_relation) as patn_rlts /*与患者的关系*/,\n" +
  85. " a.contact_phone as coner_tel /*联系人电话*/,\n" +
  86. " a.coma_days_before_admiss + '/' + a.coma_hours_before_admiss + '/' +\n" +
  87. " a.coma_minutes_before_admiss as pwcry_bfadm_coma_dura/*颅脑损伤患者入院前昏迷时长*/,\n" +
  88. " a.coma_days_after_admiss + '/' + a.coma_hours_after_admiss + '/' +\n" +
  89. " a.coma_minutes_after_admiss as pwcry_afadm_coma_dura/*颅脑损伤患者入院后昏迷时长*/,\n" +
  90. " a.zy_dismiss_way as dscg_way /*离院方式*/,\n" +
  91. " a.dismiss_destination as acp_medins_name/*拟接收机构名称*/,\n" +
  92. " a.admiss_again_in_one_month as days_rinp_flag_31 /*出院31天内再住院计划标志*/,\n" +
  93. " a.admiss_again_purpose as days_rinp_pup_31/*出院31天内再住院目的*/,\n" +
  94. " rtrim(isnull(a.main_doctor_name,a.admiss_doctor_name)) as chfpdr_name/*主诊医师姓名*/,\n" +
  95. " (select rtrim(yb_code)\n" +
  96. " from a_employee_mi\n" +
  97. " where code = isnull(a.main_doctor,a.admiss_doctor)) as chfpdr_code/*主诊医师代码*/,\n" +
  98. " (select rtrim(si_caty)\n" +
  99. " from zd_unit_code\n" +
  100. " where code = b.small_dept) as adm_caty/*入院科别*/,\n" +
  101. " (select rtrim(si_caty)\n" +
  102. " from zd_unit_code\n" +
  103. " where code = isnull(a.trans_dept_code,b.zk_ward)) as refldept_dept /*转科科别*/,\n" +
  104. " (select rtrim(si_caty)\n" +
  105. " from zd_unit_code\n" +
  106. " where code = isnull(a.dismiss_dept_code,b.zk_ward)) as dscg_caty /*出院科别*/,\n" +
  107. " b.zy_serial_no as biz_sn /*业务流水号*/,\n" +
  108. " case a.age_days\n" +
  109. " when '-' then 0\n" +
  110. " else a.age_days\n" +
  111. " end as nwb_age/*新生儿年龄*/,\n" +
  112. " a.contact_addr_name as coner_addr /*联系人地址*/,\n" +
  113. " case a.new_born_weight\n" +
  114. " when '-' then 0\n" +
  115. " else a.new_born_weight\n" +
  116. " end as nwb_bir_wt/*新生儿体重*/,\n" +
  117. " a.birth_date brdy , a.age , a.sex gend,"+
  118. " resp_nurs_code = (select rtrim(yb_code)\n" +
  119. " from a_employee_mi\n" +
  120. " where a_employee_mi.code = isnull(a.duty_nurse,b.job_nurse)) /*责任护士*/,\n" +
  121. " case when a.duty_nurse is not null then a.duty_nurse_name else (select name\n" +
  122. " from a_employee_mi\n" +
  123. " where a_employee_mi.code = b.job_nurse) end as resp_nurs_name\n" +
  124. " from zy_inactpatient b\n" +
  125. " left join\n" +
  126. " t_case_frontsheet_main a\n" +
  127. " on (\n" +
  128. " a.bah = b.inpatient_no\n" +
  129. " and a.admiss_times = b.admiss_times\n" +
  130. " )\n" +
  131. " where b.inpatient_no = #{patNo}\n" +
  132. " and b.admiss_times = #{times};")
  133. SetlinfoUpld setlinfo2(@Param("patNo") String patNo, @Param("times") Integer times);
  134. @Select("select begntime as adm_time,\n" +
  135. " begntime as setl_begn_date,\n" +
  136. " endtime as dscg_time,\n" +
  137. " begntime,\n" +
  138. " case\n" +
  139. " when datediff(day,\n" +
  140. " begntime,\n" +
  141. " endtime) <= 0 then 1\n" +
  142. " else datediff(day,\n" +
  143. " begntime,\n" +
  144. " endtime)\n" +
  145. " end as act_ipt_days\n " +
  146. "from t_si_setlinfo,\n" +
  147. " zy_inactpatient\n" +
  148. "where pat_no = #{patNo}\n" +
  149. " and times = #{times}\n" +
  150. " and ledger_sn = #{ledgerSn}\n" +
  151. " and revoked = 0\n" +
  152. " and inpatient_no = pat_no\n" +
  153. " and admiss_times = times")
  154. SetlinfoUpld setlinfo5(@Param("patNo") String patNo,
  155. @Param("times") Integer times,
  156. @Param("ledgerSn") Integer ledgerSn);
  157. @Select("select home_street as currAddr," +
  158. "(select wjw_code from zd_nation_code where code = nation_code) as naty/*民族*/,\n" +
  159. " relation_name as coner_name,\n" +
  160. " (select rtrim(yb_code) from zy_zd_relative_code where code = relation_code) as patn_rlts,\n" +
  161. " relation_street as conerAddr," +
  162. " relation_tel as conerTel " +
  163. "from a_patient_mi " +
  164. "where ${patNo}")
  165. SetlinfoUpld setlinfo3(@Param("patNo") String patNo);
  166. @Select("select clinic_diag_code as wmDiseCode, clinic_diag_str otpWmDise " +
  167. "from t_case_frontsheet_main " +
  168. "where bah = #{patNo} " +
  169. " and admiss_times = #{times}" +
  170. " and nullif(clinic_diag_code, '') is not null ")
  171. SetlinfoUpld setlinfo4(@Param("patNo") String patNo,
  172. @Param("times") Integer times);
  173. @Select("select (select si_code from zd_country_code where code = country) as ntly, " +
  174. " dis_date as setl_end_date, " +
  175. " admiss_date as setl_begn_date, " +
  176. " admiss_date as adm_time," +
  177. " case " + " when datediff(day, admiss_date, dis_date) <= 0 then 1 " +
  178. " else datediff(day, admiss_date, dis_date) end as act_ipt_days,/*实际住院天数*/ " +
  179. " dis_date as dscg_time, " +
  180. " isnull(nullif(occupation_code, ''), 90) as prfs," +
  181. " adm_way = '2' " +
  182. "from a_patient_mi a, " +
  183. " zy_inactpatient b " +
  184. "where a.inpatient_no = #{patNo} " +
  185. " and b.inpatient_no = #{patNo} " +
  186. " and b.admiss_times = #{times}")
  187. SetlinfoUpld singleDiseasePatientInformation(@Param("patNo") String patNo,
  188. @Param("times") Integer times);
  189. @Select("select top(1) rtrim(name) name,dept_name = (select rtrim(name) from zd_unit_code where code = dept_code) " +
  190. "from a_employee_mi where code = #{code}")
  191. GetDropdownBox userInfo(String code);
  192. @Select("select sum(charge_amount) 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')")
  193. Integer teJiHuLi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn, @Param("infantFlag") Integer infantFlag);
  194. @Select("select sum(charge_amount) 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')")
  195. Integer yiJiHuLi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn, @Param("infantFlag") Integer infantFlag);
  196. @Select("select sum(charge_amount) 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')")
  197. Integer erJiHuLi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn, @Param("infantFlag") Integer infantFlag);
  198. @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')")
  199. Integer sanJiHuLi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn, @Param("infantFlag") Integer infantFlag);
  200. /**
  201. * 这里是 住院诊断消息
  202. *
  203. * @param patNo 住院号
  204. * @param times 住院次数
  205. * @param tableName 表格名
  206. * @return 数据
  207. */
  208. @Select("select si_diag_type as diag_type, " +
  209. "case when yb_code is null then rtrim(dis_diag) else rtrim(yb_code) end as diag_code," +
  210. "case when yb_name is null then rtrim(dis_diag_comment) else rtrim(yb_name) end as diag_name " +
  211. "from ${tableName} left join " +
  212. "zd_icd_code_new on (dis_diag = code) " +
  213. "where inpatient_no = #{patNo} and admiss_times = #{times} " +
  214. "order by dis_diag_no ")
  215. List<DiseinfoUpld> diseinfo(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
  216. // 这里是手术操作信息
  217. @Select("select " +
  218. " case when yb_code is null then rtrim(ssbm) else rtrim(yb_code) end oprn_oprt_code ," +
  219. " case when yb_name is null then rtrim(ssmc) else rtrim(yb_name) end oprn_oprt_name," +
  220. " ssrq as oprn_oprt_date, " +
  221. " (select rtrim(yb_code) from zd_anaesthesia where code = mzff ) as anst_way, " +
  222. " (select top(1) rtrim(name) from a_employee_mi where code = ssys) as oper_dr_name, " +
  223. " (select rtrim(yb_code) from a_employee_mi where code = ssys) as oper_dr_code, " +
  224. " (select rtrim(name) from a_employee_mi where code = mzys) as anst_dr_name, " +
  225. " (select rtrim(yb_code) from a_employee_mi where code = mzys) as anst_dr_code," +
  226. " op_start_date as oprn_oprt_begntime," +
  227. " op_end_date as oprn_oprt_endtime," +
  228. " anst_start_date as anst_begntime," +
  229. " anst_end_date as anst_endtime" +
  230. " from ${tableName} left join zd_icd9_cm3 on (ssbm = zd_icd9_cm3.code) " +
  231. "where zyh = #{patNo} and zycs = #{times} " + "order by ssxh")
  232. List<OprninfoUpld> oprninfoUplds(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
  233. @Select("select rtrim(receipt_no) 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")
  234. String billNo(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn);
  235. @Select("select receipt_bill " +
  236. "from mz_receipt_serial " +
  237. "where patient_id = #{patNo} " +
  238. "and times = #{times} " +
  239. " and nullif(receipt_bill, '') is not null" +
  240. " and obsolete_dcount_no = 0 ")
  241. String mzBillNo(@Param("patNo") String patNo, @Param("times") Integer times);
  242. @Select("select med_type " +
  243. "from t_si_setlinfo " +
  244. "where pat_no = #{patNo} " +
  245. " and times = #{times} " +
  246. " and ledger_sn = #{ledgerSn} and revoked = 0")
  247. String getMedicalCategory(@Param("patNo") String patNo,
  248. @Param("times") Integer times,
  249. @Param("ledgerSn") Integer ledgerSn);
  250. @Select("select isnull(audit_flag,0) from t_yb_setl_modify_req where pat_no = #{patNo} " + "and times = #{times}")
  251. Integer setlModifyReqAuditFlag(@Param("patNo") String patNo, @Param("times") Integer times);
  252. // 基金支付信息
  253. @Select("select fund_pay_type,fund_payamt=cast(sum(fund_payamt) as decimal(16,2)) from t_si_setldetail " +
  254. "where pat_no = #{patNo} and times = #{times} and ledger_sn = #{ledgerSn} " +
  255. "group by fund_pay_type ")
  256. List<PayinfoUpld> payinfoUpld(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn);
  257. /* 收费项目信息 */
  258. // 总金额 和 全自费 和 医疗收费项目
  259. @Select("select med_chrgitm_type as med_chrgitm," +
  260. "amt=cast(sum(det_item_fee_sumamt) as decimal(16,2)), " +
  261. "fulamt_ownpay_amt=cast(sum(det_item_fee_sumamt * (selfpay_prop)) as decimal(16,2)), " +
  262. "claa_sumfee = 0,clab_amt = 0,oth_amt = 0 from t_si_setl_fee_detl " +
  263. "where setl_id = #{setlId} group by med_chrgitm_type")
  264. List<IteminfoUpld> amtAndOthAmt(@Param("setlId") String setlId);
  265. @Select("select med_chrgitm_type as med_chrgitm," +
  266. " sum(det_item_fee_sumamt) as amt\n" +
  267. "from t_si_setl_fee_detl\n" +
  268. "where setl_id = #{setlId}\n" +
  269. "group by med_chrgitm_type")
  270. List<IteminfoUpld> totalCost(@Param("setlId") String setlId);
  271. @Select("select med_chrgitm_type as med_chrgitm,\n" +
  272. " sum(det_item_fee_sumamt - fulamt_ownpay_amt) as ${feeName} " +
  273. "from t_si_setl_fee_detl " +
  274. "where setl_id = #{setlId} " +
  275. " and chrgitm_lv = #{chrgitmLv} " +
  276. "group by med_chrgitm_type")
  277. List<IteminfoUpld> aAndBFees(@Param("setlId") String setlId,
  278. @Param("chrgitmLv") String chrgitmLv,
  279. @Param("feeName") String feeName);
  280. @Select("SELECT med_chrgitm_type as med_chrgitm,\n" +
  281. " sum(fulamt_ownpay_amt) as fulamtOwnpayAmt\n" +
  282. "FROM t_si_setl_fee_detl " +
  283. "where setl_id = #{setlId} " +
  284. "group by med_chrgitm_type")
  285. List<IteminfoUpld> patientPays(@Param("setlId") String setlId);
  286. @Select("SELECT sum(DATEDIFF(second, start_time, end_time))\n" +
  287. "from yz_inact_order\n" +
  288. "where order_code in ('05181', '06563')\n" +
  289. " and inpatient_no = #{patNo}\n" +
  290. " and admiss_times = #{times}")
  291. Integer ventilatorUseTime(@Param("patNo") String patNo, @Param("times") Integer times);
  292. /**
  293. * 重症监护信息
  294. *
  295. * @param patNo 住院号
  296. * @param times 住院次数
  297. * @return 返回转科信息
  298. */
  299. @Select("select op_time from zy_zk_list where inpatient_no=#{patNo} and admiss_times=#{times} and " +
  300. "(dept_code in ('1160000','8000160') or f_dept_code in ('1160000','8000160')) " +
  301. "order by zk_times")
  302. List<Date> zhuanKeShiJian(@Param("patNo") String patNo, @Param("times") Integer times);
  303. /**
  304. * 保存结算单上传返回的 流水号
  305. *
  306. * @param setlListId 结算id
  307. * @param setlId 返回的数据
  308. */
  309. @Update("update t_si_setlinfo set setl_list_id = #{setlListId} where setl_id = #{setlId} ")
  310. void fanHuiLiuShuiHao(@Param("setlListId") String setlListId, @Param("setlId") String setlId);
  311. @Select("select top ${pageSize} * from (" +
  312. "select " +
  313. "row_number() over (order by setl_time) as rowNumber," +
  314. "rtrim(a.pat_no) pat_no,a.age,a.times,ledger_sn,psn_name,gend,brdy,insutype,psn_type,mdtrt_id,setl_id,setl_time, " +
  315. " a.med_type,medfee_sumamt,fund_pay_sumamt, b.dis_date, a.hi_paymtd," +
  316. " acct_pay,psn_cash_pay,clr_optins,clr_optins_name = (select name from t_region where code=clr_optins), " +
  317. " outDeptName=(select rtrim(name) from zd_unit_code where code=isnull(zk_ward,small_dept))," +
  318. " rtrim(isnull(zk_ward,small_dept)) as out_dept," +
  319. " insuplc_admdvs, " +
  320. " setl_list_id,datediff(day ,b.admiss_date ,b.dis_date) as act_ipt_days,b.operation,b.dec_type," +
  321. " id,req_op_id,rtrim(req_op_name) req_op_name,req_op_date,req_remark," +
  322. "audit_staff,audit_name,audit_date,audit_remark,audit_flag," +
  323. "refer_physician_name = (select top 1 rtrim(name) from a_employee_mi where code = b.refer_physician),b.refer_physician,a.ipt_med_type " +
  324. "from t_si_setlinfo a left join zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) " +
  325. "left join t_yb_setl_modify_req c on (a.pat_no = c.pat_no and a.times = c.times) " +
  326. "where revoked = 0 and " +
  327. " ${ew.sqlSegment} " +
  328. ") temp where rowNumber > ${pageSize} * (${currentPage} - 1)")
  329. List<SiSetlinfoTemp> huoQuJieSuanRenYuan(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper,
  330. @Param("currentPage") long currentPage,
  331. @Param("pageSize") long pageSize);
  332. @Select(" select count(*) from t_si_setlinfo a " +
  333. " left join zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) " +
  334. " left join t_yb_setl_modify_req c on (a.pat_no = c.pat_no and a.times = c.times) " +
  335. " where revoked = 0 and " +
  336. " ${ew.sqlSegment} ")
  337. long huoQuJieSuanRenYuanTotal(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
  338. @Select("select opName = (select top(1) rtrim(name) from a_employee_mi where code = op_id_code)," +
  339. "rtrim(inpatient_no) inpatient_no, admiss_times, dis_diag_no, dis_diag_type," +
  340. "case when yb_code is null then rtrim(dis_diag) else rtrim(yb_code) end dis_diag," +
  341. "case when yb_name is null then rtrim(dis_diag_comment) else rtrim(yb_name) end dis_diag_comment," +
  342. "op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, operation, si_diag_type,admiss_cond," +
  343. "dept_code," +
  344. "(select name from zd_unit_code where code = dept_code) as dept_code_name " +
  345. "from ${tableName} left join zd_icd_code_new on (dis_diag = code) " +
  346. "where inpatient_no = #{patNo} and admiss_times = #{times} " +
  347. "order by dis_diag_no ")
  348. List<YbZyDisDiag> zhenDuanXinXi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
  349. @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}")
  350. List<PatientBldInfo> shuXueXinXi(@Param("patNo") String patNo, @Param("times") Integer times);
  351. @Select("select ssys_name = (select top(1) rtrim(name) from a_employee_mi where code = ssys), " +
  352. " sszsName1 = (select top(1) rtrim(name) from a_employee_mi where code = sszs1), " +
  353. " sszsName2 = (select top(1) rtrim(name) from a_employee_mi where code = sszs2), " +
  354. " mzys_name = (select top(1) rtrim(name) from a_employee_mi where code = mzys)," +
  355. " bah, zyh, zycs, ssxh, ssrq, sstj, " +
  356. " ssys , sszs1, sszs2, mzys ,op_start_date, op_end_date, anst_start_date, anst_end_date," +
  357. " op_start_date as oprn_oprt_begntime," +
  358. " op_end_date as oprn_oprt_endtime," +
  359. " anst_start_date as anst_begntime," +
  360. " anst_end_date as anst_endtime, " +
  361. " case when yb_code is null then rtrim(ssbm) else rtrim(yb_code) end ssbm ," +
  362. " case when yb_name is null then rtrim(ssmc) else rtrim(yb_name) end ssmc," +
  363. " rtrim(mzff) mzff, rtrim(qkjb) qkjb," +
  364. "rtrim(yhqk) yhqk, ssbfz, fhqk, ssjb, cut_heal," +
  365. "(select top(1) rtrim(yb_code) from a_employee_mi where code = ssys) as oper_dr_code, " +
  366. "(select top(1) rtrim(yb_code) from a_employee_mi where code = mzys) as anst_dr_code," +
  367. "dept_code," +
  368. "(select name from zd_unit_code where code = dept_code) as dept_code_name " +
  369. "from ${tableName} left join zd_icd9_cm3 on (ssbm = zd_icd9_cm3.code) " +
  370. "where zyh = #{patNo} and zycs = #{times} " +
  371. "order by ssxh")
  372. List<BatjBa4> shouShuXinXi(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
  373. @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,rtrim(name) name,admiss_date,dis_date,responce_type,operation,rtrim(small_dept) small_dept, " + " responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type),sex,rtrim(refer_physician) refer_physician " +
  374. " from zy_inactpatient where inpatient_no = #{patNo} and admiss_times = #{times}")
  375. ZyInactpatient huanZheXinXi(@Param("patNo") String patNo, @Param("times") Integer times);
  376. @Select("select top(1) * from t_yb_set_modify_time")
  377. TYbSetModifyTime keXiuGaiShiJian();
  378. @Select("<script>" +
  379. "select rtrim(inpatient_no) inpatient_no,admiss_times," +
  380. "case when yb_code is null then rtrim(dis_diag) else rtrim(yb_code) end as dis_diag," +
  381. "case when yb_name is null then rtrim(dis_diag_comment) else rtrim(yb_name) end as dis_diag_comment " +
  382. "from ${tableName} left join " +
  383. "zd_icd_code_new on (dis_diag = code) " +
  384. "where inpatient_no in " +
  385. "<foreach collection='patNos' item='item' index='index' open='(' close=')' separator=','>" +
  386. "#{item}" +
  387. "</foreach>" +
  388. " and dis_diag_no = 1" +
  389. "</script>")
  390. List<ZyDisDiagYb> zhuZhenDuan(@Param("patNos") Set<String> patNos, @Param("tableName") String tableName);
  391. @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>")
  392. List<SiSetlinfoTemp> zhuanKeKeShi(@Param("patNos") Set<String> patNos);
  393. @Select("select top 10 rtrim(yb_code) as code,rtrim(name) as name," +
  394. "rtrim(yb_code) as yb_code from " +
  395. "(SELECT ROW_NUMBER() OVER(ORDER BY code) AS Number, * " +
  396. "from zd_icd9_cm3 where del_flag=0 and (code like #{content} or name like #{content} or yb_code like #{content})) a " +
  397. "where Number > (${page}-1) * 10 ")
  398. List<GetDropdownBox> searchSurgeryByAlpha(@Param("content") String content, @Param("page") long page);
  399. @Select("select count(1) from zd_icd9_cm3 where del_flag=0 and (code like #{content} or name" +
  400. " like #{content} or py_code like #{content} or yb_code like #{content})")
  401. long searchSurgeryTotal(@Param("content") String content);
  402. @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};")
  403. void delReq(@Param("patNo") String patNo, @Param("times") Integer times);
  404. @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}; ")
  405. void delDiseAndOprt(@Param("patNo") String patNo, @Param("times") Integer times);
  406. @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})")
  407. void setlModifyReq(@Param("patNo") String patNo, @Param("times") Integer times, @Param("opIdCode") String opIdCode, @Param("opIdName") String opIdName, @Param("reqRemark") String reqRemark);
  408. @Insert("insert into t_yb_setl_modify_req (pat_no, times, req_op_id, req_op_name, req_op_date, req_remark, audit_staff, audit_name, audit_date, audit_remark, audit_flag) " +
  409. " values (#{patNo}, #{times}, #{reqOpId}, #{reqOpName}, #{reqOpDate}, #{reqRemark}, #{auditStaff}, #{auditName}, #{auditDate}, #{auditRemark}, #{auditFlag})")
  410. void insertSetlModifyReq(TYbSetlModifyReq tYbSetlModifyReq);
  411. @Insert("<script>" +
  412. "insert into ${tableName} (inpatient_no, admiss_times, dis_diag_no, dis_diag_type, dis_diag, dis_diag_comment, " +
  413. "op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, operation, si_diag_type,admiss_cond,dept_code) " +
  414. "values " + "<foreach collection='list' item='param' separator=','>" +
  415. "(#{param.inpatientNo},#{param.admissTimes},#{param.disDiagNo},'13',#{param.disDiag},#{param.disDiagComment}, " +
  416. "#{param.opIdCode},#{param.opDiagDate},'001',#{param.disDiagStatus},null,#{param.siDiagType}," +
  417. "#{param.admissCond},#{param.deptCode})" +
  418. "</foreach>" +
  419. "</script>")
  420. void setlModDis(@Param("list") List<YbZyDisDiag> param, @Param("tableName") String tableName);
  421. @Insert("<script>" +
  422. "insert into ${tableName} (bah, zyh, zycs, ssxh, ssrq, sstj, ssys, sszs1, sszs2, " +
  423. "mzys, ssbm, ssmc, mzff, qkjb, yhqk, ssbfz, fhqk, ssjb, cut_heal," +
  424. "op_start_date,op_end_date,anst_start_date,anst_end_date,dept_code) " +
  425. "values " +
  426. "<foreach collection='list' item='param' separator=','>" +
  427. "(#{param.zyh},#{param.zyh},#{param.zycs},#{param.ssxh},#{param.ssrq},null,#{param.ssys},#{param.sszs1}," +
  428. "#{param.sszs2},#{param.mzys},#{param.ssbm},#{param.ssmc},#{param.mzff},#{param.qkjb},#{param.yhqk},null,null," +
  429. "#{param.ssjb},null,#{param.opStartDate, jdbcType = TIMESTAMP},#{param.opEndDate, jdbcType = TIMESTAMP}," +
  430. "#{param.anstStartDate, jdbcType = TIMESTAMP},#{param.anstEndDate, jdbcType = TIMESTAMP}," +
  431. "#{param.deptCode,jdbcType = VARCHAR})" +
  432. "</foreach>" +
  433. "</script>")
  434. void setlModBat(@Param("list") List<BatjBa4> batjBa4s, @Param("tableName") String tableName);
  435. @Select("update zy_inactpatient set operation = #{operation} /*治疗方式*/ , dec_type = #{decType} /*申报类型*/ " + "where inpatient_no = #{patNo} and admiss_times = #{times}")
  436. void shenBao(@Param("operation") String operation, @Param("decType") Integer decType, @Param("patNo") String patNo, @Param("times") Integer times);
  437. @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}")
  438. TYbSetlModifyReq shenHeXinXi(Integer id);
  439. @Select("select rtrim(code_rs) from a_employee_mi where code = #{code}")
  440. String yuanGongGongHao(String code);
  441. @Update("update t_yb_setl_modify_req set audit_flag = #{auditFlag} where id = #{id}")
  442. void upAuditFlag(@Param("id") Integer id, @Param("auditFlag") Integer auditFlag);
  443. @Update("update t_yb_setl_modify_req set audit_staff = #{auditStaff},audit_remark = #{remark},audit_name = #{auditName}," + "audit_date = getdate() " + "where id = #{id}")
  444. void updateReq(@Param("id") Integer id, @Param("remark") String remark, @Param("auditStaff") String auditStaff, @Param("auditName") String auditName);
  445. @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")
  446. TYbSetModifyTime xianZhiShiJian();
  447. @Select("update t_yb_set_modify_time set start_time = #{startTime} ,end_time = #{endTime}, op_id = #{opId} ,op_date = getdate()")
  448. void sheZhiShiJian(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("opId") String opId);
  449. @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")
  450. List<Map<String, String>> getHuanZheFeiYong(@Param("patNo") String patNo, @Param("times") Integer times);
  451. @Update("update zy_inactpatient set refer_physician = #{code} where inpatient_no = #{patNo} and admiss_times = #{times}")
  452. void xiuGaiGuanChaungYiShen(@Param("patNo") String patNo, @Param("times") Integer times, @Param("code") String code);
  453. @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} ")
  454. List<YbZyDisDiag> huanZheBingAnShouYeZhenDuanRuYuanBingQing(String patNo, Integer times);
  455. @Update("<script>" + "<foreach collection='list' item='item' separator=';'>" +
  456. "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>")
  457. void genXingLaoZhenDuan(@Param("list") List<YbZyDisDiag> ybZyDisDiagList);
  458. @Select("select rtrim(name) from zd_country_code where si_code = #{ntly}")
  459. String getNtlyName(String ntly);
  460. @Select("select rtrim(name) from zd_nation_code where wjw_code = #{naty}")
  461. String getNatyName(String naty);
  462. @Select("select rtrim(name) from t_zd_psn_cert_type where code = #{cert}")
  463. String getPatnCertTypeName(String cert);
  464. @Select("select rtrim(name) name from zy_occupation_code where code = #{prfs}")
  465. String getPrfsName(String prfs);
  466. @Select("select rtrim(name) name from zy_zd_relative_code where yb_code = #{code}")
  467. String getPatnRltsName(String code);
  468. @Select("select rtrim(name) from t_si_admdvs where code = #{code} ")
  469. String getInsuplcName(String code);
  470. @Select("select rtrim(name) from t_yb_dept where code = #{code}")
  471. String getYbDeptName(String code);
  472. @Select("select dise_code as diag_code," +
  473. " dise_name as diag_name " +
  474. // " ,oprn_oprt_name = '00000'," +
  475. // " oprn_oprt_code = '无手术' " +
  476. " from t_si_pat_info " +
  477. "where pat_no = #{patNo} and times = #{times} " +
  478. "and ledger_sn = #{ledgerSn} " +
  479. "and nullif(dise_code, '') is not null")
  480. List<OpspdiseinfoUpld> diagnosisOfMenterSDisease(@Param("patNo") String patNo,
  481. @Param("times") Integer times,
  482. @Param("ledgerSn") Integer ledgerSn);
  483. @Select("select icd_code_new as diag_code " +
  484. "from mz_visit_table " +
  485. "where nullif(icd_code_new, '') is not null " +
  486. " and patient_id = #{patNo} and times = #{times}")
  487. OpspdiseinfoUpld outpatientDiagnosis1(@Param("patNo") String patNo,
  488. @Param("times") Integer times);
  489. @Select("select top 1 yb_code as diag_code,yb_name as diag_name " +
  490. "from zd_icd_code_new where yb_code = #{ybCode} ")
  491. OpspdiseinfoUpld outpatientSlowDiagnosis(String ybCode);
  492. @Select("select diag_code as diag_code, " +
  493. " diag_name as diag_name, " +
  494. " '00000' as oprn_oprt_name, " +
  495. " '无手术' as oprn_oprt_code " +
  496. "from t_si_mz_diag\n" +
  497. "where pat_no = #{patNo} and times = #{times} ")
  498. List<OpspdiseinfoUpld> outpatientDiagnosis2(@Param("patNo") String patNo,
  499. @Param("times") Integer times);
  500. @Select("select top 1 rtrim(a.name) as psnName, " +
  501. " isnull(nullif(rtrim(b.occupation_code), " +
  502. " ''), " +
  503. " 90) as prfs, " +
  504. " (select si_code from zd_country_code where code = b.country) as ntly, " +
  505. " a.sex as gend, " +
  506. " a.birth_day as brdy, " +
  507. " a.age as age, " +
  508. " a.social_no as certno, " +
  509. " a.response_type, " +
  510. " a.phone_no as coner_tel, " +
  511. " a.adress as currAddr, " +
  512. " a.certificate_type as patnCertType, " +
  513. " d.setl_time as setl_begn_date, " +
  514. " d.setl_time as setl_end_date, " +
  515. " c.psn_no as psn_no," +
  516. " c.psn_no as hi_no, " +
  517. " rtrim(a.patient_id) + '_' + cast(a.times as varchar) as bizSn," +
  518. " dclaTime = getdate()," +
  519. " c.insutype as hi_type," +
  520. " isnull(work_unit,b.employer_name) as emp_name, " +
  521. " isnull(work_address,employer_district) as emp_addr, " +
  522. " isnull(work_tel,employer_tel) as emp_tel, " +
  523. " employer_zipcode as poscode, " +
  524. " relation_name as coner_name, " +
  525. " relation_district as coner_addr, " +
  526. " relation_tel as coner_tel, " +
  527. " c.insuplc_admdvs as insuplc," +
  528. " (select wjw_code from zd_nation_code where code = b.nation_code) as naty/*民族*/,\n" +
  529. " '1' as patnRlts," +
  530. " a.adress as conerAddr," +
  531. " '1' as hiPaymtd, " +
  532. " cast(fund_pay_sumamt as decimal(16,2)) as fund_pay_sumamt," +
  533. " cast(maf_pay as decimal(16,2)) as maf_pay, " +
  534. "psn_idet_type as sp_psn_type," +
  535. "(select doctor_code\n" +
  536. "from mz_visit_table\n" +
  537. "where patient_id = #{patNo}\n" +
  538. " and times = #{times}) as chfpdr_code " +
  539. "from mz_patient_mi a " +
  540. " left join " +
  541. " a_patient_mi b on (a.patient_id = b.mz_no) " +
  542. " left join t_si_pat_info c on (a.patient_id = c.pat_no and c.times = #{times}) " +
  543. " left join t_si_setlinfo d on (a.patient_id = d.pat_no and d.times = #{times} and revoked = 0 ) " +
  544. "where a.patient_id = #{patNo}")
  545. SetlinfoUpld mzPatInfo(@Param("patNo") String patNo,
  546. @Param("times") Integer times);
  547. @Select("select opsp_diag_caty = (select si_caty from zd_unit_code where code = visit_dept_code),\n" +
  548. " visit_date as opsp_mdtrt_date\n" +
  549. "from mz_visit_table\n" +
  550. "where patient_id = #{patNo} and times = #{times}")
  551. SetlinfoUpld mzPatInfo1(@Param("patNo") String patNo,
  552. @Param("times") Integer times);
  553. @Select("select setl_id,mdtrt_id,insuplc_admdvs " +
  554. "from t_si_setlinfo " +
  555. "where pat_no = #{patNo} " +
  556. " and times = #{times} and revoked = 0 ")
  557. SetlinfoUpld mzJieSuanXinXi(@Param("patNo") String patNo, @Param("times") Integer times);
  558. @Update("update t_si_setlinfo set ipt_med_type = #{iptMenType} where setl_id = #{setlId} and revoked = 0")
  559. void modifyMedicalCategory(@Param("iptMenType") String iptMenType, @Param("setlId") String setlId);
  560. @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 = ''))")
  561. void addBloodTransfusionInformation(PatientBldInfo param);
  562. @Update("update patient_bld_info set bld_cat = #{bldCat} ,bld_amt = cast(#{bldAmt} as decimal(6,1)) ,bld_unit = #{bldUnit} " + "where id = #{id}")
  563. void updateBloodTransfusionVarieties(PatientBldInfo param);
  564. @Delete("delete patient_bld_info where id = #{id}")
  565. void removeBloodTransfusion(Integer id);
  566. @Select("select setl_list_id from t_si_setlinfo where " +
  567. "pat_no = #{patNo} and times = #{times} and ledger_sn = #{ledgerSn} and revoked = 0")
  568. String billingListSerialNumber(@Param("patNo") String patNo,
  569. @Param("times") Integer times,
  570. @Param("ledgerSn") Integer ledgerSn);
  571. @Select("select pat_no, times, ledger_sn,setl_time " +
  572. "from t_si_setlinfo " +
  573. "where nullif(setl_list_id,'') is null " +
  574. " and revoked = 0 " +
  575. " and insuplc_admdvs like '43%' " +
  576. " and DATEDIFF(day,setl_time,GETDATE()) >=6" +
  577. "and setl_time >= '${firstDate}'"
  578. )
  579. List<SiSetlinfoTemp> getBillingPatientsToday(String firstDate);
  580. /**
  581. * 自动上传的信息
  582. *
  583. * @param patNo 住院号
  584. * @param times 住院次数
  585. * @param ledgerSn 账页号
  586. * @param logText 日志
  587. */
  588. @Select("insert into t_auto_upload_bill (pat_no, times, ledger_sn,log_text,type_flag,flag,setl_time, upload_date) " +
  589. "values (#{patNo},#{times},#{ledgerSn},#{logText},#{typeFlag},#{flag},#{setlTime},'${uploadDate}')")
  590. void insertAutoLongPassError(@Param("patNo") String patNo,
  591. @Param("times") Integer times,
  592. @Param("ledgerSn") Integer ledgerSn,
  593. @Param("logText") String logText,
  594. @Param("typeFlag") Integer typeFlag,
  595. @Param("flag") Integer flag,
  596. @Param("uploadDate") String uploadDate,
  597. @Param("setlTime") Date setlTime
  598. );
  599. @Select("select * " +
  600. "from t_auto_upload_bill " +
  601. "where upload_date >= '${startTime}' " +
  602. " and upload_date <= '${endTime}'")
  603. List<TAutoUploadBill> exportAutoUploadInfo(@Param("startTime") String startTime,
  604. @Param("endTime") String endTime);
  605. @Select("select count(1)\n" +
  606. "from t_si_setlinfo a,\n" +
  607. " t_si_log b\n" +
  608. "where (b.infno = '4101' and a.pat_no = b.pat_no and a.times = b.times and a.ledger_sn = b.ledger_sn)")
  609. Integer 获取已经上传的数据总数();
  610. @Select("select top ${pageSize} *\n" +
  611. "from (select row_number() over (order by create_datetime) row_index, create_datetime, body, result\n" +
  612. " from t_si_setlinfo a,\n" +
  613. " t_si_log b\n" +
  614. " where (b.infno = '4101' and a.pat_no = b.pat_no and a.times = b.times and a.ledger_sn = b.ledger_sn)) temp\n" +
  615. "where row_index > (${currentPage} - 1) * ${pageSize}\n" +
  616. "order by row_index")
  617. List<SiLog> 获取上传的文件(int currentPage, int pageSize);
  618. /**
  619. * 是否有上传结算单信息
  620. *
  621. * @param setlId
  622. * @return
  623. */
  624. @Select("select max(setl_id) from t_settlement_setlinfo where setl_id = #{setlId}")
  625. Integer whetherThereIsUploadInfo(String setlId);
  626. /**
  627. * 根据setld 删除
  628. *
  629. * @param id
  630. */
  631. @Delete("delete t_settlement_diseinfo where setl_id = #{setlId};" +
  632. "delete t_settlement_opspdiseinfo where setl_id = #{setlId};" +
  633. "delete t_settlement_oprninfo where setl_id = #{setlId}; " +
  634. "delete t_settlement_setlinfo where setl_id = #{setlId};" +
  635. "delete t_settlement_icuinfo where setl_id = #{setlId};" +
  636. "delete t_settlement_bldinfo where setl_id = #{setlId};" +
  637. "delete t_settlement_payinfo where setl_id = #{setlId};" +
  638. "delete t_settlement_iteminfo where setl_id = #{setlId};")
  639. void deleteAccordingToSetlId(String id);
  640. /**
  641. * 插入结算单诊断信息
  642. *
  643. * @param setlId id
  644. * @param list 诊断数据
  645. */
  646. @Insert("<script>" +
  647. "insert into t_settlement_diseinfo " +
  648. "(setl_id, subscript, diag_type, diag_code, diag_name, adm_cond_type, maindiag_flag) " +
  649. "values " +
  650. "<foreach collection='list' item='item' index='index' separator=','>" +
  651. "(#{setlId}, ${index} + 1, #{item.diagType}, #{item.diagCode}, #{item.diagName}, #{item.admCondType}, " +
  652. "#{item.maindiagFlag})" +
  653. "</foreach>" +
  654. "</script>")
  655. void insertStatementDiagnosisInfo(String setlId, List<DiseinfoUpld> list);
  656. /**
  657. * 插入结算单基金支付信息
  658. *
  659. * @param setlId id
  660. * @param list 基金支付信息
  661. */
  662. @Insert("<script>" +
  663. "insert into t_settlement_payinfo (setl_id, subscript, fund_pay_type, fund_payamt) " +
  664. " values " +
  665. "<foreach collection='list' item='item' index='index' separator=','>" +
  666. " (#{setlId},${index} + 1,#{item.fundPayType},#{item.fundPayamt}) " +
  667. "</foreach>" +
  668. "</script>")
  669. void insertFundPaymentInfoOfStatement(String setlId, List<PayinfoUpld> list);
  670. /**
  671. * 插入收费项目信息
  672. *
  673. * @param setlId id
  674. * @param list 收费项目
  675. */
  676. @Insert("<script>" +
  677. "insert into t_settlement_iteminfo (setl_id, subscript, med_chrgitm, amt, claa_sumfee, clab_amt, fulamt_ownpay_amt," +
  678. " oth_amt)" +
  679. "values " +
  680. "<foreach collection='list' item='item' index='index' separator=','>" +
  681. "(#{setlId},${index} + 1,#{item.medChrgitm},#{item.amt},#{item.claaSumfee},#{item.clabAmt},#{item.fulamtOwnpayAmt}," +
  682. "#{item.othAmt})" +
  683. "</foreach>" +
  684. "</script>")
  685. void insertChargingItemInfo(String setlId, List<IteminfoUpld> list);
  686. /**
  687. * 插入门诊慢特病
  688. *
  689. * @param setlId id
  690. * @param list 数据
  691. */
  692. @Insert("<script>" +
  693. "insert into t_settlement_opspdiseinfo (setl_id, subscript, diag_name, diag_code, oprn_oprt_name, oprn_oprt_code," +
  694. "maindiag_flag) " +
  695. " values " +
  696. "<foreach collection='list' item='item' index='index' separator=','>" +
  697. "(#{setlId}, ${index} + 1, #{item.diagName}, #{item.diagCode}, #{item.oprnOprtName}, #{item.oprnOprtCode}," +
  698. "#{item.maindiagFlag})" +
  699. "</foreach>" +
  700. "</script>")
  701. void insertionOfOutpatientChronicDiseases(String setlId, List<OpspdiseinfoUpld> list);
  702. /**
  703. * 插入手术操作信息
  704. *
  705. * @param setlId id
  706. * @param list 数据
  707. */
  708. @Insert("<script>" +
  709. "insert into t_settlement_oprninfo(setl_id, subscript, oprn_oprt_type, oprn_oprt_name, oprn_oprt_code," +
  710. "oprn_oprt_date, " +
  711. "anst_way, oper_dr_name, oper_dr_code, anst_dr_name, anst_dr_code, oprn_oprt_begntime,\n" +
  712. "oprn_oprt_endtime, anst_begntime, anst_endtime)\n" +
  713. "values " +
  714. "<foreach collection='list' item='item' index='index' separator=','>" +
  715. "(#{setlId},${index} + 1,#{item.oprnOprtType},#{item.oprnOprtName},#{item.oprnOprtCode}," +
  716. "#{item.oprnOprtDate},#{item.anstWay},#{item.operDrName},#{item.operDrCode},#{item.anstDrName},#{item.anstDrCode}," +
  717. "#{item.oprnOprtBegntime},#{item.oprnOprtEndtime},#{item.anstBegntime},#{item.anstEndtime})" +
  718. "</foreach>" +
  719. "</script>")
  720. void insertSurgicalOperationInfo(String setlId, List<OprninfoUpld> list);
  721. /**
  722. * 插入重症监护信息
  723. *
  724. * @param setlId id
  725. * @param list 数据
  726. */
  727. @Insert("<script>" +
  728. "insert into t_settlement_icuinfo (setl_id, subscript, scs_cutd_ward_type, scs_cutd_inpool_time, " +
  729. "scs_cutd_exit_time,scs_cutd_sum_dura) " +
  730. "values " +
  731. "<foreach collection='list' item='item' index='index' separator=','>" +
  732. "(#{setlId},${index} + 1,#{item.scsCutdWardType},#{item.scsCutdInpoolTime}," +
  733. "#{item.scsCutdExitTime},#{item.scsCutdSumDura})" +
  734. "</foreach>" +
  735. "</script>")
  736. void insertIntensiveCareInfor(String setlId, List<IcuinfoUpld> list);
  737. /**
  738. * 插入 输血信息
  739. *
  740. * @param setlId id
  741. * @param list 数据
  742. */
  743. @Insert("<script>" +
  744. "insert into t_settlement_bldinfo (setl_id, subscript, bld_cat, bld_amt, bld_unt) " +
  745. " values " +
  746. "<foreach collection='list' item='item' index='index' separator=','>" +
  747. " (#{setlId},${index} + 1,#{item.bldCat},#{item.bldAmt},#{item.bldUnt})" +
  748. "</foreach>" +
  749. "</script>")
  750. void insertTransfusionInfo(String setlId, List<Bldinfo> list);
  751. /**
  752. * @description:插入结算单审核日志表
  753. * @author: lihong
  754. * @date: 2022/12/12 16:50
  755. * @param: setlAuditLog
  756. **/
  757. @Insert("insert into t_setl_audit_log(create_name, create_code, remark, audit_flag, audit_type, pat_no, times) " +
  758. " values (#{createName},#{createCode},#{remark},#{auditFlag},#{auditType},#{patNo},#{times})")
  759. void insertSetlAuditLog(SetlAuditLog setlAuditLog);
  760. /**
  761. * @description:查询审核日志
  762. * @author: lihong
  763. * @date: 2022/12/13 9:25
  764. * @param: patNo
  765. * @param: times
  766. **/
  767. @Select("select create_name," +
  768. " create_code," +
  769. " create_time," +
  770. " remark," +
  771. " audit_flag," +
  772. " audit_type," +
  773. " id"+
  774. " from t_setl_audit_log where pat_no=#{patNo} and times=#{times} order by create_time")
  775. List<SetlAuditLog> listSetlAuditLog(String patNo, Integer times);
  776. /**
  777. * @description:删除审核申请记录
  778. * @author: lihong
  779. * @date: 2022/12/13 10:17
  780. * @param: patNo
  781. * @param: times
  782. **/
  783. @Delete("delete from t_yb_setl_modify_req where pat_no=#{patNo} and times=#{times} ")
  784. void deleteModifReq(String patNo, Integer times);
  785. @Select("select audit_flag from t_yb_setl_modify_req where pat_no=#{patNo} and times=#{times}")
  786. Integer getAuditFlag(String patNo, Integer times);
  787. @Select(" <script> " +
  788. " select b.audit_flag from (" +
  789. " select pat_no + cast(times as varchar) as visit_id,pat_no,times from t_yb_setl_modify_req\n" +
  790. " ) a join t_yb_setl_modify_req b on a.pat_no=b.pat_no and a.times = b.times" +
  791. " where a.visit_id in"+
  792. "<foreach collection='visitIds' item='patNo' open='(' close=')' separator=','>"+
  793. " #{patNo}"+
  794. " </foreach>"+
  795. " </script>")
  796. List<Integer> listSetlModifyReq(List<String> visitIds);
  797. @Select("<script>" +
  798. " select rtrim(code) code ,rtrim(yb_code) yb_code,rtrim(yb_name) yb_name from ${tableName} where code in" +
  799. " <foreach collection='glCodes' item='item' open='(' close=')' separator=','>" +
  800. " #{item}" +
  801. " </foreach>"+
  802. " </script>")
  803. List<Map<String,String>> listYbDiseOrOprt(@Param("glCodes") List<String> glCodes,@Param("tableName") String tableName);
  804. @Select("<script>" +
  805. " select rtrim(yb_code) yb_code,rtrim(code) code from a_employee_mi where code in" +
  806. " <foreach collection='ssysCode' item='item' open='(' close=')' separator=','>" +
  807. " #{item}" +
  808. " </foreach>"+
  809. " </script>")
  810. List<Map<String,String>> listYbSsys(List<String> ssysCode);
  811. @Select("<script>" +
  812. " select rtrim(code) code,rtrim(yb_code) yb_code,rtrim(name) yb_name from zd_anaesthesia where code in " +
  813. " <foreach collection='mzfsCodes' item='item' open='(' close=')' separator=','>" +
  814. " #{item}" +
  815. " </foreach>"+
  816. " </script>")
  817. List<Map<String,String>> listZdAnaesthesia(List<String> mzfsCodes);
  818. /**
  819. * @description:查询字典值
  820. * @author: lihong
  821. * @date: 2022/12/26 9:47
  822. * @param: s
  823. * @param: s1
  824. **/
  825. @Select("select dict_value from t_dict_data where dict_type=#{dictType} and dict_name=#{dictName} and status='0'"
  826. )
  827. String getDictValueByDictName(@Param("dictType") String dictType, @Param("dictName")String dictName);
  828. /**
  829. * @description:查询审核状态
  830. * @author: lihong
  831. * @date: 2022/12/26 11:02
  832. * @param: patNo
  833. * @param: times
  834. **/
  835. @Select("select audit_flag from t_yb_setl_modify_req where pat_no=#{patNo} and times=#{times} ")
  836. Integer qualityPass(@Param("patNo") String patNo, @Param("times") Integer times);
  837. @Select(" select count(*) from zy_inactpatient where inpatient_no=#{patNo} and admiss_times=#{times} ")
  838. Integer isInHospital(@Param("patNo")String patNo, @Param("times") Integer times);
  839. @Select(" select rtrim(a.pat_no) pat_no,a.times,ledger_sn,psn_name,gend,brdy,insutype,psn_type,mdtrt_id,setl_id,setl_time, \n" +
  840. " a.med_type,medfee_sumamt,fund_pay_sumamt, \n" +
  841. " acct_pay,psn_cash_pay,clr_optins,clr_optins_name = (select name from t_region where code=clr_optins), \n" +
  842. " outDeptName=(select rtrim(name) from zd_unit_code where code=isnull(zk_ward,small_dept)), \n" +
  843. " rtrim(isnull(zk_ward,small_dept)) as out_dept, \n" +
  844. " insuplc_admdvs, \n" +
  845. " setl_list_id,datediff(day ,b.admiss_date ,b.dis_date) as act_ipt_days,b.operation,b.dec_type, \n" +
  846. " id,req_op_id,rtrim(req_op_name) req_op_name,req_op_date,req_remark, \n" +
  847. " audit_staff,audit_name,audit_date,audit_remark,audit_flag, \n" +
  848. " refer_physician_name = (select top 1 rtrim(name) from a_employee_mi where code = b.refer_physician),b.refer_physician,a.ipt_med_type \n" +
  849. " from t_si_setlinfo a left join zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) \n" +
  850. " left join t_yb_setl_modify_req c on (a.pat_no = c.pat_no and a.times = c.times) \n" +
  851. " where revoked = 0\n" +
  852. " and a.pat_no=#{patNo} and a.times=#{times} and a.ledger_sn=#{ledgerSn}")
  853. SiSetlinfoTemp getJieSuanDetail(String patNo, Integer times, Integer ledgerSn);
  854. @Select("select top 1 * from t_yb_setl_modify_req where pat_no=#{patNo} and times=#{times} ")
  855. TYbSetlModifyReq getSetlModifyReq(@Param("patNo") String patNo, @Param("times") Integer times);
  856. /**
  857. * @description:删除最近的历史记录
  858. * @author: lihong
  859. * @date: 2022/12/28 15:19
  860. * @param: patNo
  861. * @param: times
  862. **/
  863. @Delete(" delete" +
  864. " from t_setl_audit_log" +
  865. " where id in (" +
  866. " select b.id" +
  867. " from (" +
  868. " select max(create_time) create_time, pat_no, times" +
  869. " from t_setl_audit_log" +
  870. " where pat_no = #{patNo}" +
  871. " and times = #{times}" +
  872. " group by pat_no, times" +
  873. " ) a" +
  874. " join t_setl_audit_log b on a.create_time = b.create_time and a.pat_no = b.pat_no and a.times = b.times" +
  875. ")")
  876. void deletelatestSetlAuditLog(@Param("patNo") String patNo, @Param("times") Integer times);
  877. @Update("update t_yb_setl_modify_req set audit_staff = '' ,audit_name='',audit_remark='',audit_flag=0 where pat_no=#{patNo} and times=#{times}")
  878. void updateSetlModifyReq(@Param("patNo") String patNo, @Param("times") Integer times);
  879. @Select(" select b.pat_no,b.times,b.ledger_sn,b.setl_time from t_yb_setl_modify_req a join t_si_setlinfo b on a.pat_no=b.pat_no and a.times=b.times" +
  880. " where a.audit_flag =1" +
  881. " and b.revoked = 0" +
  882. " and nullif(b.setl_list_id,'') is null" +
  883. " and b.setl_time >= '${firstDate}'"
  884. )
  885. List<SiSetlinfoTemp> getQualityPass(String firstDate);
  886. @Select(" select count(1) from t_case_frontsheet_main where bah=#{inpatientNo} and admiss_times = #{admissTimes}")
  887. Integer queryCountTCaseFrontsheetMain(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
  888. @Select(" select medfee_sumamt from t_si_setlinfo where pat_no = #{patNo} and times =#{times} and ledger_sn = #{ledgerSn}")
  889. BigDecimal getsetlTotalFee(@Param("patNo") String patNo, @Param("times") Integer times,@Param("ledgerSn")Integer ledgerSn);
  890. }