UpIdCollectionDao.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. package thyyxxk.webserver.dao.his.medicalinsurance;
  2. import org.apache.ibatis.annotations.Mapper;
  3. import org.apache.ibatis.annotations.Param;
  4. import org.apache.ibatis.annotations.Select;
  5. import org.apache.ibatis.annotations.Update;
  6. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  7. import thyyxxk.webserver.entity.medicalinsurance.query.SiPatInfo;
  8. import thyyxxk.webserver.entity.medicalinsurance.setllistupload.*;
  9. import java.util.Date;
  10. import java.util.List;
  11. /**
  12. * <p>
  13. * 描述: 医保结算单上传
  14. * </p>
  15. *
  16. * @author xc
  17. * @date 2021-11-25 08:42
  18. */
  19. @Mapper
  20. public interface UpIdCollectionDao {
  21. @Select("select a.mdtrt_id, " + // -- 就诊ID
  22. " a.setl_id, " + // -- 结算ID
  23. " a.psn_no as hi_no, " + //-- 医保编号
  24. " medcasno=(a.pat_no+'_'+cast(a.times as varchar)), " + //-- 病案号
  25. " dcla_time=getdate(), " + //-- 申报时间
  26. " a.psn_name, " + //-- 人员姓名
  27. " a.gend, " + // -- 性别
  28. " a.brdy, " + //-- 出生日期
  29. " a.age, " + // -- 年龄
  30. " a.naty, " + // -- 名族
  31. " a.certno, " + // -- 证件号码
  32. " a.psn_cert_type as patnCertType, " + // -- 患者证件类别
  33. " b.insuplc_admdvs as insuplc, " + // -- 参保地
  34. " a.psn_cash_pay as psnSelfpay, " + // -- 个人自付
  35. " a.fulamt_ownpay_amt as psnOwnpay, " + // -- 个人自费c
  36. " a.acct_pay, " + // -- 个人账户支出
  37. " a.psn_cash_pay as psnCashpay, " + // -- 个人现金支付
  38. " hiPaymtd='3', " + // -- 医保支付方式
  39. " a.clr_optins as hsorg, " + // -- 医保机构
  40. " a.insutype as hi_type " + // -- 枚举 MdcsType
  41. "from t_si_setlinfo a, t_si_pat_info b " +
  42. "where a.pat_no=b.pat_no and a.times=b.times " +
  43. "and a.pat_no = #{patNo} and a.times = #{times} " +
  44. "and a.revoked = 0 ")
  45. SetlinfoUpld setlinfo1(@Param("patNo") String patNo,
  46. @Param("times") Integer times,
  47. @Param("ledgerSn") Integer ledgerSn);
  48. @Select("select rtrim(country) as ntly, " + // 国籍
  49. " rtrim(social_no) as certno, " + // 证件
  50. " rtrim(occupation_code) as prfs, " + // -- 职业 在 Prfs 中有对应的
  51. " rtrim(home_street) as curr_addr ," + // -- 现住址
  52. " rtrim(employer_name) as emp_name, " + //-- 单位名称
  53. " rtrim(employer_street) as emp_addr, " + //-- 单位地址
  54. " rtrim(employer_tel) as emp_tel, " +
  55. " rtrim(employer_zipcode) as poscode, " +
  56. " rtrim(relation_name) as coner_name, " +
  57. " relation_code as patn_rlts, " + // TODO: 2021/11/26 这里可能要转成医保的类型
  58. " rtrim(relation_tel) as coner_tel " + // 联系人电话
  59. "from a_patient_mi " +
  60. "where inpatient_no = #{patNo} or mz_no = #{patNo}")
  61. SetlinfoUpld setlinfo2(@Param("patNo") String patNo);
  62. @Select("select " +
  63. " pwcry_bfadm_coma_dura = isnull(ryq_hmsj_day,0) + '/' + isnull(ryq_hmsj_hour,0) + '/' + isnull(ryq_hmsj_min,0), " + // -- 颅脑损伤患者入院前昏迷时长
  64. " pwcry_afadm_coma_dura = isnull(ryh_hmsj_day,0) + '/' + isnull(ryh_hmsj_hour,0) + '/' + isnull(ryh_hmsj_min,0), " + // -- 颅脑损伤患者入院后昏迷时长
  65. " lyfs as dscg_way, " + // -- 离院方式
  66. " jsjg as acp_medins_name, " + // -- 拟接收机构名称
  67. " acp_optins_code = '', " + // -- 拟接收机构代码 (占时为空)
  68. " zzy_flag as days_rinp_flag_31, " + // -- 出院31天内再住院计划标志
  69. " rtrim(zzy_md) as days_rinp_pup_31, " + // -- 出院31天内再住院目的
  70. " chfpdr_name = (select rtrim(name) from a_employee_mi where code = isnull(zzys,b.consult_physician)), " + // -- 主诊医师姓名
  71. " isnull(zzys,b.consult_physician) as chfpdr_code, " + //-- 主诊医师代码
  72. " b.admiss_date as adm_time, " + //-- 入院时间
  73. " adm_caty = (select rtrim(si_caty) from zd_unit_code where code = b.small_dept), " + // -- 入院科别
  74. " refldept_dept = (select rtrim(si_caty) from zd_unit_code where code = b.zk_ward), " + //--转科科别
  75. " b.dis_date as dscg_time, " + // -- 出院时间
  76. " dscg_caty = (select rtrim(si_caty) from zd_unit_code where code = b.dis_dept), " + // -- 出院科别
  77. " datediff(day ,b.admiss_date ,b.dis_date) as act_ipt_days, " + // 实际住院天数
  78. " zy_serial_no as biz_sn," +// 业务流水号
  79. " operation as trt_type " + // 治疗类别
  80. "from batj_ba2 a,zy_inactpatient b " +
  81. "where a.bah = b.inpatient_no and a.zycs = b.admiss_times " +
  82. "and a.bah = #{patNo} and a.zycs = #{times}")
  83. SetlinfoUpld setlinfo3(@Param("patNo") String patNo,
  84. @Param("times") Integer times);
  85. @Select("select case age_days when '-' then 0 else age_days end as nwb_age, " +
  86. " rtrim(lxdz2) as coner_addr, " +
  87. " rtrim(rytj) as adm_way, " +
  88. " case new_born_weight when '-' then 0 else age_days end as nwb_bir_wt, " +
  89. " case new_born_admiss_weight when '-' then 0 else age_days end as nwb_bir_wt" +
  90. " from batj_ba1 where zyh = #{patNo} and zycs = #{times} ")
  91. SetlinfoUpld setlinfo4(@Param("patNo") String patNo,
  92. @Param("times") Integer times);
  93. @Select("select top(1) rtrim(name) name,dept_name = (select rtrim(name) from zd_unit_code where code = dept_code) " +
  94. "from a_employee_mi where code = #{code}")
  95. GetDropdownBox userInfo(String code);
  96. @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}" +
  97. " and charge_code_mx in ('F01464','017051')")
  98. int teJiHuLi(@Param("patNo") String patNo,
  99. @Param("times") Integer times,
  100. @Param("ledgerSn") Integer ledgerSn,
  101. @Param("infantFlag") Integer infantFlag);
  102. @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}" +
  103. " and charge_code_mx in ('F01465','017052')")
  104. int yiJiHuLi(@Param("patNo") String patNo,
  105. @Param("times") Integer times,
  106. @Param("ledgerSn") Integer ledgerSn,
  107. @Param("infantFlag") Integer infantFlag);
  108. @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}" +
  109. " and charge_code_mx in ('F01466','017053')")
  110. int erJiHuLi(@Param("patNo") String patNo,
  111. @Param("times") Integer times,
  112. @Param("ledgerSn") Integer ledgerSn,
  113. @Param("infantFlag") Integer infantFlag);
  114. @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}" +
  115. " and charge_code_mx in ('F01467','017054')")
  116. int sanJiHuLi(@Param("patNo") String patNo,
  117. @Param("times") Integer times,
  118. @Param("ledgerSn") Integer ledgerSn,
  119. @Param("infantFlag") Integer infantFlag);
  120. // 这里是 住院诊断消息
  121. @Select("select si_diag_type as diag_type, " +
  122. " rtrim(dis_diag) as diag_code, " +
  123. " rtrim(dis_diag_comment) as diag_name, " +
  124. " case when dis_diag_no = 1 then 1 else 0 end as maindiag_flag " +
  125. "from zy_dis_diag_yb " +
  126. "where inpatient_no = #{patNo} and admiss_times = #{times}")
  127. List<DiseinfoUpld> diseinfo(@Param("patNo") String patNo,
  128. @Param("times") Integer times);
  129. // 这里是手术操作信息
  130. @Select("select rtrim(ssjb) as oprn_oprt_type, " +
  131. " rtrim(ssmc) as oprn_oprt_name, " +
  132. " rtrim(ssbm) as oprn_oprt_code, " +
  133. " ssrq as oprn_oprt_date, " +
  134. " rtrim(mzff) as anst_way, " +
  135. " (select top(1) rtrim(name) from a_employee_mi where code = ssys) as oper_dr_name, " +
  136. " rtrim(ssys) as oper_dr_code, " +
  137. " (select top(1) rtrim(name) from a_employee_mi where code = mzys) as anst_dr_name, " +
  138. " rtrim(mzys) as anst_dr_code " +
  139. " from batj_ba4 " +
  140. "where zyh = #{patNo} and zycs = #{times}")
  141. List<OprninfoUpld> oprninfoUplds(@Param("patNo") String patNo,
  142. @Param("times") Integer times);
  143. // 基金支付信息
  144. @Select("select fund_pay_type,fund_payamt from t_si_setldetail " +
  145. "where pat_no = #{patNo} and times = #{times} and ledger_sn = #{ledgerSn} ")
  146. List<PayinfoUpld> payinfoUpld(@Param("patNo") String patNo,
  147. @Param("times") Integer times,
  148. @Param("ledgerSn") Integer ledgerSn);
  149. /* 收费项目信息 */
  150. // 总金额 和 全自费 和 医疗收费项目
  151. @Select("select med_chrgitm_type as med_chrgitm,sum(det_item_fee_sumamt) as amt, " +
  152. " sum(fulamt_ownpay_amt) fulamt_ownpay_amt,claa_sumfee = 0,clab_amt = 0,oth_amt = 0 from t_si_setl_fee_detl " +
  153. "where setl_id = #{setlId} " +
  154. "group by med_chrgitm_type")
  155. List<IteminfoUpld> amtAndOthAmt(@Param("setlId") String setlId);
  156. // -- 01 甲类
  157. @Select("select med_chrgitm_type as med_chrgitm,sum(det_item_fee_sumamt) as claa_sumfee from t_si_setl_fee_detl " +
  158. "where setl_id = #{setlId} and chrgitm_lv = '01' " +
  159. "group by med_chrgitm_type")
  160. List<IteminfoUpld> jiaLeiFeiYong(@Param("setlId") String setlId);
  161. // -- 02 乙类
  162. @Select("select med_chrgitm_type as med_chrgitm,sum(det_item_fee_sumamt) as clab_amt from t_si_setl_fee_detl " +
  163. "where setl_id = #{setlId} and chrgitm_lv = '02' " +
  164. "group by med_chrgitm_type")
  165. List<IteminfoUpld> yiLeiFeiYong(@Param("setlId") String setlId);
  166. // 重症监护信息
  167. @Select("select op_time from zy_zk_list where inpatient_no=#{patNo} and admiss_times=#{times} and " +
  168. "(dept_code in ('1160000','8000160') or f_dept_code in ('1160000','8000160')) " +
  169. "order by zk_times")
  170. List<Date> zhuanKeShiJian(@Param("patNo") String patNo,
  171. @Param("times") Integer times);
  172. // 保存返回信息
  173. @Update("update t_si_setlinfo set setl_list_id = #{setlListId} where setl_id = #{setlId} ")
  174. void fanHuiLiuShuiHao(@Param("setlListId") String setlListId,
  175. @Param("setlId") String setlId);
  176. @Select("<script>" +
  177. "select a.pat_no,a.times,a.ledger_sn from t_si_setlinfo a,t_si_pat_info b where a.pat_no = b.pat_no " +
  178. "and a.times = b.times and a.ledger_sn = b.ledger_sn and revoked = 0 and setl_type = 21 and " +
  179. "b.insuplc_admdvs like '4301%' and b.insuplc_admdvs != '430182' and setl_list_id is null " +
  180. "and a.setl_time &gt;= #{startTime} and a.setl_time &lt;= #{endTime} " +
  181. "<if test=\"insutype!=null and insutype!=''\">" +
  182. "and a.insutype=#{insutype}" +
  183. "</if>" +
  184. "</script>")
  185. List<SiPatInfo> getHuanZheXinXi(@Param("startTime") String startTime,
  186. @Param("endTime") String endTime,
  187. @Param("insutype") String insutype);
  188. }