SiManageDao.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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.medicalinsurance.manage.InstSetlLdgChkBrf;
  7. import thyyxxk.webserver.entity.medicalinsurance.manage.detailanalyse.FsiDiagnoseDtos;
  8. import thyyxxk.webserver.entity.medicalinsurance.manage.detailanalyse.FsiEncounterDtos;
  9. import thyyxxk.webserver.entity.medicalinsurance.manage.detailanalyse.FsiOrderDtos;
  10. import thyyxxk.webserver.entity.medicalinsurance.manage.detailanalyse.PatientDtos;
  11. import thyyxxk.webserver.entity.medicalinsurance.manage.frontsheet.Baseinfo;
  12. import thyyxxk.webserver.entity.medicalinsurance.manage.frontsheet.Diseinfo;
  13. import thyyxxk.webserver.entity.medicalinsurance.manage.orderinfo.ActOrder;
  14. import java.util.List;
  15. /**
  16. * @author: DingJie
  17. * @create: 2021/8/99:45
  18. */
  19. @Mapper
  20. public interface SiManageDao {
  21. @Update("<script>" +
  22. "update ${table} set uploaded_flag=#{flag} where code in " +
  23. "<foreach collection='codes' item='code' separator=',' open='(' close=')'>" +
  24. "#{code}</foreach>" +
  25. "</script>")
  26. void updateUploadedFlag(@Param("table") String table,
  27. @Param("flag") int flag,
  28. @Param("codes") List<String> codes);
  29. @Update("update ${table} set uploaded_flag=0 where code=#{code}")
  30. void updateUploadedFlag2(@Param("table") String table,
  31. @Param("code") String codes);
  32. @Select("select name from t_region where code=#{code}")
  33. String selectRegion(@Param("code") String code);
  34. @Select("select pat_no,times,ledger_sn,medfee_sumamt,acct_pay,fund_pay_sumamt, " +
  35. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
  36. "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996'))" +
  37. "from t_si_setlinfo a where insutype=#{insutype} and setl_type=#{setlType} and revoked=0 " +
  38. "and clr_optins=#{clrOptins} and setl_time>=#{start} and setl_time<=#{end} and fund_pay_sumamt!=0 " +
  39. "and (insuplc_admdvs='439900' or insuplc_admdvs like '4301%')")
  40. List<InstSetlLdgChkBrf> selectSetlChkBrfsWithInsutype(@Param("setlType") String setlType,
  41. @Param("insutype") String insutype,
  42. @Param("clrOptins") String clrOptins,
  43. @Param("start") String start,
  44. @Param("end") String end);
  45. @Select("select pat_no,times,ledger_sn,setl_id,mdtrt_id,psn_no,medfee_sumamt,acct_pay,fund_pay_sumamt,psn_cash_pay, " +
  46. "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no and b.times=a.times " +
  47. "and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996'))" +
  48. "from t_si_setlinfo a where setl_type=#{setlType} and revoked=0 and clr_optins=#{clrOptins} and fund_pay_sumamt!=0 " +
  49. "and setl_time>=#{start} and setl_time<=#{end} and (insuplc_admdvs='439900' or insuplc_admdvs like '4301%')")
  50. List<InstSetlLdgChkBrf> selectSetlChkBrfs(@Param("setlType") String setlType,
  51. @Param("clrOptins") String clrOptins,
  52. @Param("start") String start,
  53. @Param("end") String end);
  54. @Select("select count(1) from dj_user_role where user_code=#{code} and role_id=41")
  55. Integer recoveryTradePermission(@Param("code") String code);
  56. @Select("select mdtrtSn='H43010500370'+bah+'_'+cast(admiss_times as varchar), " +
  57. "mdtrtId=(select top 1 mdtrt_id from t_si_setlinfo where pat_no=bah and times=admiss_times and revoked=0), " +
  58. "psnNo=(select top 1 psn_no from t_si_setlinfo where pat_no=bah and times=admiss_times and revoked=0), " +
  59. "admiss_times as patnIptCnt,bah as iptNo,medcasno=bah+'_'+cast(admiss_times as varchar), " +
  60. "name as psnName,sex as gend,birth_date as brdy, " +
  61. "ntly=(select si_code from zd_country_code where code=country), " +
  62. "ntlyName=(select rtrim(name) from zd_country_code where code=country), " +
  63. "nwbBirWt=case when new_born_weight='-' then '' else new_born_weight end, " +
  64. "nwbAdmWt=case when new_born_admiss_weight='-' then '' else new_born_admiss_weight end, " +
  65. "birth_place_name as birplc,native_place_name as napl, " +
  66. "naty=(select wjw_code from zd_nation_code where code=nation), " +
  67. "natyName=(select rtrim(name) from zd_nation_code where code=nation), " +
  68. "social_no as certno,occupation as prfs, " +
  69. "mrgStas=(select si_code from zd_marital_status where code=marriage), " +
  70. "live_place as currAddr,phone as psnTel,hk_place_name as resdAddr, " +
  71. "unit_phone as emprTel,unit_place as emprAddr,contact_phone as conerTel, " +
  72. "contact_name as conerName,contact_addr_name as conerAddr,zy_admiss_way as admWayCode, " +
  73. "admWayName=(select name from zy_zd_admiss_way where code=zy_admiss_way), " +
  74. "admCaty=(select si_caty from zd_unit_code where code=admiss_dept_code), " +
  75. "admiss_ward as admWard,admiss_date as admDate,dismiss_date as dscgDate, " +
  76. "dscgCaty=(select si_caty from zd_unit_code where code=dismiss_dept_code), " +
  77. "dismiss_ward as dscgWard,admiss_days as iptDays,allergy as drugDicmFlag, " +
  78. "allergic_medicine as dicmDrugName,autopsy as dieAutpFlag,blood_type as aboCode, " +
  79. "aboName=(select rtrim(name) from zd_blood_type where code=blood_type), " +
  80. "rhCode=(select wjw_code from zd_hbsag where code=rh), " +
  81. "rhName=(select rtrim(name) from zd_hbsag where code=rh), " +
  82. "dept_leader_name as deptdrtName,leader_doctor_name as chfdrName, " +
  83. "main_doctor_name as atddrName,admiss_doctor_name as iptDrName, " +
  84. "duty_nurse_name as respNursName,study_doctor_name as trainDrName, " +
  85. "internship_doctor_name as intnDrName,coder_name as codrName, " +
  86. "quality_control_doctor_name as qltctrlDrName, " +
  87. "quality_control_nurse_name as qltctrlNursName, " +
  88. "quality_control_level as medcasQltCode, " +
  89. "quality_control_date as qltctrlDate, " +
  90. "dscgWay=(select wjw_code from zd_zy_dismiss_way where code=zy_dismiss_way), " +
  91. "dscgWayName=(select name from zd_zy_dismiss_way where code=zy_dismiss_way), " +
  92. "acpMedinsName=case when dismiss_destination='-' then '' else dismiss_destination end, " +
  93. "admiss_again_in_one_month as dscg31DaysRinpFlag, " +
  94. "dscg31DaysRinpPup=case when admiss_again_purpose='-' then '' else admiss_again_purpose end, " +
  95. "damgIntxExtRea=case when hurt_reason_name='-' then '' else hurt_reason_name end, " +
  96. "damgIntxExtReaDisecode=case when hurt_reason_code='-' then '' else hurt_reason_code end, " +
  97. "brn_damg_bfadm_coma_dura=coma_days_before_admiss+'/'+coma_hours_before_admiss+'/'+coma_minutes_before_admiss, " +
  98. "brn_damg_afadm_coma_dura=coma_days_after_admiss+'/'+coma_hours_after_admiss+'/'+coma_minutes_after_admiss, " +
  99. "fixmedinsCode='H43010500370',age,hbs_ag as hbsag,hcv_ab,hiv_ab, " +
  100. "rescue_times as rescCnt,rescue_success_times as rescSuccCnt,total_cost as medfeeSumamt, " +
  101. "valiFlag='1',case_classification as ctd,dept_leader as deptdrtCode,leader_doctor as chfdrCode, " +
  102. "main_doctor as atddrCode,admiss_doctor as iptDrCode,duty_nurse as respNursCode, " +
  103. "quality_control_doctor as qltctrlDrCode,quality_control_nurse as qltctrlNursCode " +
  104. "from t_case_frontsheet_main where bah=#{patNo} and admiss_times=#{times}")
  105. Baseinfo selectFrontSheetBaseInfo(@Param("patNo") String patNo, @Param("times") int times);
  106. @Select("select maindiagFlag=case when dis_diag_no=1 then '1' else '0' end, " +
  107. "rtrim(dis_diag) as diagCode,rtrim(dis_diag) as inhospDiagCode, " +
  108. "rtrim(dis_diag_comment) as diagName,rtrim(dis_diag_comment) as inhospDiagName, " +
  109. "valiFlag='1',iptMedcasHmpgSn=rtrim(inpatient_no)+'_'+cast(admiss_times as varchar), " +
  110. "mdtrtSn='H43010500370'+rtrim(inpatient_no)+'_'+cast(admiss_times as varchar), " +
  111. "fixmedinsCode='H43010500370' " +
  112. "from zy_dis_diag_yb where inpatient_no=#{patNo} and admiss_times=#{times}")
  113. List<Diseinfo> selectYbDisdiags(@Param("patNo") String patNo, @Param("times") int times);
  114. @Select("select maindiagFlag=case when no=1 then '1' else '0' end, " +
  115. "code as diagCode,code as inhospDiagCode, " +
  116. "name as diagName,name as inhospDiagName, " +
  117. "valiFlag='1',iptMedcasHmpgSn=bah+'_'+cast(times as varchar), " +
  118. "mdtrtSn='H43010500370'+bah+'_'+cast(times as varchar), " +
  119. "fixmedinsCode='H43010500370' " +
  120. "from t_case_frontsheet_disdiag where bah=#{patNo} and times=#{times}")
  121. List<Diseinfo> selectFrontSheetDiseInfo(@Param("patNo") String patNo, @Param("times") int times);
  122. @Select("select mdtrtSn='H43010500370'+rtrim(a.inpatient_no)+'_'+cast(a.admiss_times as varchar), " +
  123. "mdtrtId=(select top 1 mdtrt_id from t_si_pat_info where " +
  124. "pat_no=a.inpatient_no and times=a.admiss_times and mdtrt_id is not null and med_type!='42' ), " +
  125. "psnNo=(select top 1 psn_no from t_si_pat_info where " +
  126. "pat_no=a.inpatient_no and times=a.admiss_times and mdtrt_id is not null and med_type!='42' ), " +
  127. "iptBedNo=rtrim(b.bed_no),drordNo=cast(cast(act_order_no as decimal) as varchar), " +
  128. "isuDeptCode=(select si_caty from zd_unit_code t where t.code=(select dept_code from a_employee_mi e where e.code=a.enter_oper)), " +
  129. "order_time as drordIsuNo,exeDeptCode=(select si_caty from zd_unit_code where code=exec_unit), " +
  130. "exeDeptCode=(select si_caty from zd_unit_code t where t.code=(select top 1 exec_unit from zy_detail_charge e where e.order_no=a.act_order_no)), " +
  131. "exedeptName=(select t.name from zd_unit_code t where t.code=(select top 1 exec_unit from zy_detail_charge e where e.order_no=a.act_order_no)), " +
  132. "drordPtrName=(select t.name from a_employee_mi t where t.code=a.executer1), " +
  133. "order_code as drordDetlCode,order_name as drordDetlName,valiFlag='1', " +
  134. "iptDeptCode=(select si_caty from zd_unit_code t where t.code=b.small_dept), " +
  135. "medcasDrordDetlId='H43010500370'+cast(cast(act_order_no as decimal) as varchar) " +
  136. "from yz_act_order a, zy_actpatient b where a.inpatient_no=#{patNo} and a.admiss_times=#{times} " +
  137. "and a.inpatient_no=b.inpatient_no and a.admiss_times=b.admiss_times")
  138. List<ActOrder> selectActOrders(@Param("patNo") String patNo, @Param("times") int times);
  139. @Select("select psn_no as patnId, psn_name as patnName, gend, brdy, insuplc_admdvs as poolarea, mdtrt_id as currMdtrtId " +
  140. "from t_si_pat_info where pat_no=#{patNo} and times=#{times}")
  141. PatientDtos selectPatientDto(@Param("patNo") String patNo, @Param("times") int times);
  142. @Select("select mdtrt_id,medinsAdmdvs='430105',medinsLv='03',begntime as adm_date,endtime as dscg_date,\n" +
  143. " dscgMainDiseCodg=(select rtrim(dis_diag) from zy_dis_diag_yb where inpatient_no=a.pat_no and\n" +
  144. " admiss_times=a.times and dis_diag_no=1),\n" +
  145. " dscgMainDiseName=(select rtrim(dis_diag_comment) from zy_dis_diag_yb where inpatient_no=a.pat_no and\n" +
  146. " admiss_times=a.times and dis_diag_no=1),\n" +
  147. " drCodg=(select rtrim(op_id_code) from zy_dis_diag_yb where inpatient_no=a.pat_no and\n" +
  148. " admiss_times=a.times and dis_diag_no=1),\n" +
  149. " admDeptCodg=(select rtrim(small_dept) from zy_inactpatient where inpatient_no=a.pat_no and admiss_times=a.times),\n" +
  150. " medMdtrtType=case when setl_type='11' then 1 else 2 end,med_type,medfee_sumamt,fulamt_ownpay_amt,\n" +
  151. " psn_cash_pay,insutype\n" +
  152. "from t_si_setlinfo a where a.pat_no=#{patNo} and a.times=#{times} and a.revoked=0")
  153. FsiEncounterDtos selectFsiEncounterDto(@Param("patNo") String patNo, @Param("times") int times);
  154. @Select("select dise_id=rtrim(inpatient_no)+'_'+cast(admiss_times as varchar)+'_'+cast(dis_diag_no as varchar),\n" +
  155. " inout_dise_type='2',maindise_flag=case when dis_diag_no=1 then 1 else 0 end,\n" +
  156. " dis_diag_no as dias_srt_no,rtrim(dis_diag) as dise_codg,rtrim(dis_diag_comment) as dise_name,\n" +
  157. " op_diag_date as dise_date\n" +
  158. "from zy_dis_diag_yb where inpatient_no=#{patNo} and admiss_times=#{times}")
  159. List<FsiDiagnoseDtos> selectFsiDiagnoseDtos(@Param("patNo") String patNo, @Param("times") int times);
  160. @Select("select\n" +
  161. " rxId=cast(cast(act_order_no as decimal) as varchar)+'_'+charge_code_mx,\n" +
  162. " rxno=cast(cast(act_order_no as decimal) as varchar),\n" +
  163. " longDrordFlag=case when frequ_code='ONCE' then 0 else 1 end,\n" +
  164. " listType=(select list_type from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  165. " chrgType=(select med_chrgitm_type from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  166. " drordBhvr=case when frequ_code='ONCE' then 1 else 2 end,\n" +
  167. " hilist_code=(select hilist_code from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  168. " hilist_name=(select hilist_name from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  169. " hilist_lv=(select chrgitm_lv from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  170. " pric=(select pric from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  171. " a.charge_code_mx as hosplist_code,a.charge_amount as cnt,\n" +
  172. " hosplistName=(select medins_list_name from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  173. " a.charge_fee as sumamt,\n" +
  174. " ownpayAmt=(select fulamt_ownpay_amt from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  175. " selfpayAmt=(select preselfpay_amt from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  176. " b.start_time as drord_begn_date,b.end_time as drord_stop_date,\n" +
  177. " drord_dept_codg=(select bilg_dept_codg from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  178. " drord_dept_name=(select bilg_dept_name from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  179. " drord_dr_codg=(select bilg_dr_codg from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  180. " drord_dr_name=(select bilg_dr_name from t_si_setl_fee_detl where setl_id=#{setlId} and feedetl_sn=a.detail_sn),\n" +
  181. " drord_dr_profttl=(select rtrim(emp_tit_code) from a_employee_mi where code=b.enter_oper),\n" +
  182. " curr_drord_flag='1'\n" +
  183. "from zy_detail_charge a, yz_inact_order b where order_no>100 and a.inpatient_no=#{patNo} and a.admiss_times=#{times}\n" +
  184. "and a.ledger_sn>0 and a.inpatient_no=b.inpatient_no and a.admiss_times=b.admiss_times")
  185. List<FsiOrderDtos> selectFsiOrderDtos(@Param("patNo") String patNo, @Param("times") int times, @Param("setlId") String setlId);
  186. @Select("select setl_id from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
  187. String selectSetlId(@Param("patNo") String patNo, @Param("times") int times);
  188. }