SiManageDao.java 19 KB

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